diff --git a/.azure-pipelines/azure-pipelines-UpgrateVersion.yml b/.azure-pipelines/azure-pipelines-UpgrateVersion.yml index 33f802b0d56c..1d2a0fbae6dc 100644 --- a/.azure-pipelines/azure-pipelines-UpgrateVersion.yml +++ b/.azure-pipelines/azure-pipelines-UpgrateVersion.yml @@ -42,12 +42,32 @@ parameters: - mellanox stages: +- stage: Prepare + jobs: + - job: Prepare + steps: + - script: | + DEFAULT_MIRROR_URL_PREFIX=http://packages.trafficmanager.net + DEBIAN_TIMESTAMP=$(curl $DEFAULT_MIRROR_URL_PREFIX/snapshot/debian/latest/timestamp) + DEBIAN_SECURITY_TIMESTAMP=$(curl $DEFAULT_MIRROR_URL_PREFIX/snapshot/debian-security/latest/timestamp) + echo "DEBIAN_TIMESTAMP=$DEBIAN_TIMESTAMP, DEBIAN_SECURITY_TIMESTAMP=$DEBIAN_SECURITY_TIMESTAMP" + echo "##vso[task.setvariable variable=DEBIAN_TIMESTAMP;isOutput=true]$DEBIAN_TIMESTAMP" + echo "##vso[task.setvariable variable=DEBIAN_SECURITY_TIMESTAMP;isOutput=true]$DEBIAN_SECURITY_TIMESTAMP" + name: SetVersions + displayName: 'Set snapshot versions' - stage: Build + dependsOn: Prepare variables: - name: CACHE_MODE value: none - name: VERSION_CONTROL_OPTIONS value: 'SONIC_VERSION_CONTROL_COMPONENTS=' + - name: SKIP_CHECKOUT + value: true + - name: DEBIAN_TIMESTAMP + value: $[ stageDependencies.Prepare.Prepare.outputs['SetVersions.DEBIAN_TIMESTAMP'] ] + - name: DEBIAN_SECURITY_TIMESTAMP + value: $[ stageDependencies.Prepare.Prepare.outputs['SetVersions.DEBIAN_SECURITY_TIMESTAMP'] ] - template: .azure-pipelines/template-variables.yml@buildimage jobs: - template: azure-pipelines-build.yml @@ -56,6 +76,21 @@ stages: buildOptions: '${{ variables.VERSION_CONTROL_OPTIONS }} ENABLE_DOCKER_BASE_PULL=n SONIC_BUILD_JOBS=$(nproc) ENABLE_IMAGE_SIGNATURE=y' preSteps: - template: .azure-pipelines/template-clean-sonic-slave.yml@buildimage + - checkout: self + submodules: recursive + fetchDepth: 0 + path: s + displayName: 'Checkout code' + - script: | + echo "DEBIAN_TIMESTAMP=$DEBIAN_TIMESTAMP, DEBIAN_SECURITY_TIMESTAMP=$DEBIAN_SECURITY_TIMESTAMP" + if [ "$MIRROR_SNAPSHOT" == y ]; then + mkdir -p target/versions/default/ + echo "debian==$DEBIAN_TIMESTAMP" > target/versions/default/versions-mirror + echo "debian-security==$DEBIAN_SECURITY_TIMESTAMP" >> target/versions/default/versions-mirror + cat target/versions/default/versions-mirror + fi + displayName: 'Set snapshot versions' + - stage: UpgradeVersions jobs: - job: UpgradeVersions diff --git a/.azure-pipelines/azure-pipelines-build.yml b/.azure-pipelines/azure-pipelines-build.yml index c5f270665873..53a8466076e5 100644 --- a/.azure-pipelines/azure-pipelines-build.yml +++ b/.azure-pipelines/azure-pipelines-build.yml @@ -108,7 +108,8 @@ jobs: platform_rpc: nephos buildSteps: - - template: template-skipvstest.yml + - template: .azure-pipelines/template-skipvstest.yml@buildimage + - template: .azure-pipelines/template-daemon.yml@buildimage - bash: | set -ex if [ $(GROUP_NAME) == vs ]; then @@ -124,7 +125,7 @@ jobs: make $BUILD_OPTIONS target/docker-ptf-sai.gz if [ $(Build.Reason) != 'PullRequest' ];then gzip -kd target/sonic-vs.img.gz - SONIC_RUN_CMDS="qemu-img convert target/sonic-vs.img -O vhdx -o subformat=dynamic target/sonic-vs.vhdx" make sonic-slave-run + SONIC_RUN_CMDS="qemu-img convert target/sonic-vs.img -O vhdx -o subformat=dynamic target/sonic-vs.vhdx" make $BUILD_OPTIONS sonic-slave-run rm target/sonic-vs.img fi else @@ -139,9 +140,20 @@ jobs: make $BUILD_OPTIONS target/sonic-$(GROUP_NAME).raw fi if [ $(docker_syncd_rpc_image) == yes ]; then + # workaround for issue in rules/sairedis.dep, git ls-files will list un-exist files for cache make $BUILD_OPTIONS ENABLE_SYNCD_RPC=y target/docker-syncd-$(platform_rpc)-rpc.gz + pushd ./src/sonic-sairedis/SAI + git stash + popd if [ $(GROUP_NAME) == broadcom ]; then make $BUILD_OPTIONS ENABLE_SYNCD_RPC=y target/docker-syncd-$(platform_rpc)-dnx-rpc.gz + pushd ./src/sonic-sairedis/SAI + git stash + popd + make $BUILD_OPTIONS ENABLE_SYNCD_RPC=y SAITHRIFT_V2=y target/docker-saiserverv2-brcm.gz + pushd ./src/sonic-sairedis/SAI + git stash + popd fi fi if [ $(syncd_rpc_image) == yes ]; then @@ -151,4 +163,4 @@ jobs: make $BUILD_OPTIONS target/sonic-$(GROUP_NAME).bin fi displayName: "Build sonic image" - - template: check-dirty-version.yml + - template: .azure-pipelines/check-dirty-version.yml@buildimage diff --git a/.azure-pipelines/azure-pipelines-image-template.yml b/.azure-pipelines/azure-pipelines-image-template.yml index f055414e137d..d4d2c96e1c61 100644 --- a/.azure-pipelines/azure-pipelines-image-template.yml +++ b/.azure-pipelines/azure-pipelines-image-template.yml @@ -25,7 +25,7 @@ jobs: jobFilters: ${{ parameters.jobFilters }} jobVariables: ${{ parameters.jobVariables }} preSteps: - - template: cleanup.yml + - template: .azure-pipelines/cleanup.yml@buildimage - ${{ parameters.preSteps }} - script: | if [ -n "$(CACHE_MODE)" ] && echo $(PLATFORM_AZP) | grep -E -q "^(vs|broadcom|mellanox|marvell-armhf)$"; then @@ -36,6 +36,7 @@ jobs: displayName: "Set cache options" - checkout: self submodules: recursive + fetchDepth: 0 condition: and(succeeded(), eq(variables.SKIP_CHECKOUT, '')) displayName: 'Checkout code' - script: | @@ -66,6 +67,6 @@ jobs: artifactName: 'sonic-buildimage.$(GROUP_NAME)$(GROUP_EXTNAME)' publishPrefix: '$(Build.DefinitionName)/$(Build.SourceBranchName)/$(GROUP_NAME)' - ${{ parameters.postSteps }} - - template: cleanup.yml + - template: .azure-pipelines/cleanup.yml@buildimage jobGroups: ${{ parameters.jobGroups }} buildSteps: ${{ parameters.buildSteps }} diff --git a/.azure-pipelines/build-template.yml b/.azure-pipelines/build-template.yml index e1188924a18a..52bff4aa9e51 100644 --- a/.azure-pipelines/build-template.yml +++ b/.azure-pipelines/build-template.yml @@ -106,6 +106,16 @@ jobs: fi if [ ${{ parameters.sync_rpc_image }} == true ]; then make USERNAME=admin $CACHE_OPTIONS SONIC_BUILD_JOBS=$(nproc) ENABLE_SYNCD_RPC=y target/docker-syncd-${{ parameters.platform_short }}-rpc.gz + # workaround for issue in rules/sairedis.dep, git ls-files will list un-exist files for cache + pushd ./src/sonic-sairedis/SAI + git stash + popd + if [ ${{ parameters.platform }} == broadcom ]; then + make USERNAME=admin $CACHE_OPTIONS SONIC_BUILD_JOBS=$(nproc) ENABLE_SYNCD_RPC=y SAITHRIFT_V2=y target/docker-saiserverv2-brcm.gz + pushd ./src/sonic-sairedis/SAI + git stash + popd + fi fi make USERNAME=admin $CACHE_OPTIONS SONIC_BUILD_JOBS=$(nproc) target/sonic-${{ parameters.platform }}.bin diff --git a/.azure-pipelines/cleanup.yml b/.azure-pipelines/cleanup.yml index 6569c8ed0bf3..4f74de0f413a 100644 --- a/.azure-pipelines/cleanup.yml +++ b/.azure-pipelines/cleanup.yml @@ -1,5 +1,11 @@ steps: - script: | + set -x + # kill daemon process + ps $(cat /tmp/azp_daemon_kill_docker_pid) + sudo kill $(cat /tmp/azp_daemon_kill_docker_pid) + rm /tmp/azp_daemon_kill_docker_pid + if sudo [ -f /var/run/march/docker.pid ] ; then pid=`sudo cat /var/run/march/docker.pid` ; sudo kill $pid fi @@ -11,4 +17,5 @@ steps: pid=`sudo cat dockerfs/var/run/docker.pid` ; sudo kill $pid fi sudo rm -rf $(ls -A1) + condition: always() displayName: "Clean Workspace" diff --git a/.azure-pipelines/docker-sonic-slave-template.yml b/.azure-pipelines/docker-sonic-slave-template.yml index 142ff5fa3f6f..828f958e5ed2 100644 --- a/.azure-pipelines/docker-sonic-slave-template.yml +++ b/.azure-pipelines/docker-sonic-slave-template.yml @@ -35,7 +35,7 @@ parameters: - sonicbld-armhf jobs: -- job: Build_${{ parameters.dist }}_${{ parameters.march }}${{ parameters.arch }} +- job: sonic_slave_${{ parameters.dist }}${{ parameters.march }} timeoutInMinutes: 360 variables: - template: /.azure-pipelines/template-variables.yml@buildimage @@ -46,7 +46,6 @@ jobs: - template: /.azure-pipelines/template-clean-sonic-slave.yml@buildimage - checkout: self clean: true - submodules: recursive - task: Docker@2 displayName: Login to ACR inputs: @@ -56,6 +55,10 @@ jobs: set -ex image_tag=$(BLDENV=${{ parameters.dist }} make -f Makefile.work showtag PLATFORM=generic PLATFORM_ARCH=${{ parameters.arch }} | grep sonic-slave | tail -n 1) image_latest=$(echo $(echo $image_tag | awk -F: '{print$1}'):latest) + if echo ${{ parameters.pool }} | grep ${{ parameters.arch }};then + image_latest=$(echo ${image_latest} | sed 's/:/-${{ parameters.arch }}:/') + fi + image_branch=$(echo $(echo $image_latest | awk -F: '{print$1}'):$(Build.SourceBranchName)) docker rmi $image_tag || true if [[ "$(Build.Reason)" =~ [a-zA-Z]*CI ]] && docker pull ${{ parameters.registry_url }}/${image_tag};then @@ -69,7 +72,9 @@ jobs: docker tag ${image_tag} ${REGISTRY_SERVER}/${image_tag} docker push ${REGISTRY_SERVER}/${image_tag} - if [[ "${{ parameters.arch }}" == "amd64" ]];then + docker tag ${image_tag} ${REGISTRY_SERVER}/${image_branch} + docker push ${REGISTRY_SERVER}/${image_branch} + if [[ "$(Build.SourceBranchName)" == "master" ]];then docker tag ${image_tag} ${REGISTRY_SERVER}/${image_latest} docker push ${REGISTRY_SERVER}/${image_latest} fi diff --git a/.azure-pipelines/docker-sonic-slave.yml b/.azure-pipelines/docker-sonic-slave.yml index dd7a11d2c531..4c679f7f9518 100644 --- a/.azure-pipelines/docker-sonic-slave.yml +++ b/.azure-pipelines/docker-sonic-slave.yml @@ -30,7 +30,6 @@ trigger: paths: include: - sonic-slave-* - - src/sonic-build-hooks - files/build/versions - Makefile - Makefile.work @@ -57,7 +56,7 @@ parameters: default: sonicdev stages: -- stage: Build +- stage: Build_in_amd64 jobs: - ${{ each dist in parameters.dists }}: - ${{ if endswith(variables['Build.DefinitionName'], dist) }}: @@ -67,7 +66,9 @@ stages: pool: sonicbld arch: ${{ arch }} dist: ${{ dist }} -- stage: Build_march + ${{ if ne(arch, 'amd64') }}: + march: _march_${{ arch }} +- stage: Build_native_arm dependsOn: [] jobs: - ${{ each dist in parameters.dists }}: @@ -79,4 +80,4 @@ stages: pool: sonicbld-${{ arch }} arch: ${{ arch }} dist: ${{ dist }} - march: march_ + march: _${{ arch }} diff --git a/.azure-pipelines/run-test-scheduler-template.yml b/.azure-pipelines/run-test-scheduler-template.yml index f43ce59d8a57..ad5a1b1c6ef8 100644 --- a/.azure-pipelines/run-test-scheduler-template.yml +++ b/.azure-pipelines/run-test-scheduler-template.yml @@ -11,12 +11,12 @@ parameters: default: 36000 - name: MIN_WORKER - type: number + type: string default: 1 - name: MAX_WORKER - type: number - default: 2 + type: string + default: 1 - name: TEST_SET type: string @@ -81,11 +81,10 @@ steps: echo "TestbedV2 is just online and might not be stable enough, for any issue, please send email to sonictestbedtools@microsoft.com" echo "Runtime detailed progress at https://www.testbed-tools.org/scheduler/testplan/$TEST_PLAN_ID" # When "LOCK_TESTBED" finish, it changes into "PREPARE_TESTBED" - python ./.azure-pipelines/test_plan.py poll -i "$(TEST_PLAN_ID)" --timeout 43200 --expected-states PREPARE_TESTBED EXECUTING KVMDUMP FINISHED CANCELLED FAILED + python ./.azure-pipelines/test_plan.py poll -i "$(TEST_PLAN_ID)" --expected-state LOCK_TESTBED env: TESTBED_TOOLS_URL: $(TESTBED_TOOLS_URL) displayName: Lock testbed - timeoutInMinutes: 240 - script: | set -ex @@ -95,11 +94,10 @@ steps: echo "TestbedV2 is just online and might not be stable enough, for any issue, please send email to sonictestbedtools@microsoft.com" echo "Runtime detailed progress at https://www.testbed-tools.org/scheduler/testplan/$TEST_PLAN_ID" # When "PREPARE_TESTBED" finish, it changes into "EXECUTING" - python ./.azure-pipelines/test_plan.py poll -i "$(TEST_PLAN_ID)" --timeout 2400 --expected-states EXECUTING KVMDUMP FINISHED CANCELLED FAILED + python ./.azure-pipelines/test_plan.py poll -i "$(TEST_PLAN_ID)" --expected-state PREPARE_TESTBED env: TESTBED_TOOLS_URL: $(TESTBED_TOOLS_URL) displayName: Prepare testbed - timeoutInMinutes: 40 - script: | set -ex @@ -107,11 +105,10 @@ steps: echo "TestbedV2 is just online and might not be stable enough, for any issue, please send email to sonictestbedtools@microsoft.com" echo "Runtime detailed progress at https://www.testbed-tools.org/scheduler/testplan/$TEST_PLAN_ID" # When "EXECUTING" finish, it changes into "KVMDUMP", "FAILED", "CANCELLED" or "FINISHED" - python ./.azure-pipelines/test_plan.py poll -i "$(TEST_PLAN_ID)" --timeout 18000 --expected-states KVMDUMP FINISHED CANCELLED FAILED + python ./.azure-pipelines/test_plan.py poll -i "$(TEST_PLAN_ID)" --expected-state EXECUTING env: TESTBED_TOOLS_URL: $(TESTBED_TOOLS_URL) displayName: Run test - timeoutInMinutes: 300 - script: | set -ex @@ -119,12 +116,11 @@ steps: echo "TestbedV2 is just online and might not be stable enough, for any issue, please send email to sonictestbedtools@microsoft.com" echo "Runtime detailed progress at https://www.testbed-tools.org/scheduler/testplan/$TEST_PLAN_ID" # When "KVMDUMP" finish, it changes into "FAILED", "CANCELLED" or "FINISHED" - python ./.azure-pipelines/test_plan.py poll -i "$(TEST_PLAN_ID)" --timeout 43200 --expected-states FINISHED CANCELLED FAILED + python ./.azure-pipelines/test_plan.py poll -i "$(TEST_PLAN_ID)" --expected-state KVMDUMP condition: succeededOrFailed() env: TESTBED_TOOLS_URL: $(TESTBED_TOOLS_URL) displayName: KVM dump - timeoutInMinutes: 20 - script: | set -ex diff --git a/.azure-pipelines/template-daemon.yml b/.azure-pipelines/template-daemon.yml new file mode 100644 index 000000000000..903e10c2d5c6 --- /dev/null +++ b/.azure-pipelines/template-daemon.yml @@ -0,0 +1,24 @@ +steps: +- bash: | + ( + while true + do + sleep 120 + now=$(date +%s) + pids=$(ps -C docker -o pid,etime,args | grep "docker build" | cut -d" " -f2) + for pid in $pids + do + start=$(date --date="$(ls -dl /proc/$pid --time-style full-iso | awk '{print$6,$7}')" +%s) + time_s=$(($now-$start)) + if [[ $time_s -gt $(DOCKER_BUILD_TIMEOUT) ]]; then + echo =========== $(date +%F%T) $time_s &>> target/daemon.log + ps $pid &>> target/daemon.log + sudo kill $pid + fi + done + done + ) & + daemon_pid=$! + ps $daemon_pid + echo $daemon_pid >> /tmp/azp_daemon_kill_docker_pid + displayName: start daemon to kill hang docker diff --git a/.azure-pipelines/template-variables.yml b/.azure-pipelines/template-variables.yml index 462a417c0173..42d46182d263 100644 --- a/.azure-pipelines/template-variables.yml +++ b/.azure-pipelines/template-variables.yml @@ -2,3 +2,7 @@ variables: DEFAULT_CONTAINER_REGISTRY: 'publicmirror.azurecr.io' COMMON_LIB_BUILD_ENVS: 'bullseye' SONIC_SLAVE_DOCKER_DRIVER: 'overlay2' + SONIC_BUILD_RETRY_COUNT: 3 + SONIC_BUILD_RETRY_INTERVAL: 600 + DOCKER_BUILDKIT: 0 + DOCKER_BUILD_TIMEOUT: 3600 diff --git a/.github/workflows/automerge_scan.yml b/.github/workflows/automerge_scan.yml new file mode 100644 index 000000000000..d2c970a159dc --- /dev/null +++ b/.github/workflows/automerge_scan.yml @@ -0,0 +1,59 @@ +name: AutoMergeScan +on: + schedule: + - cron: '31 */2 * * *' + workflow_dispatch: + +jobs: + automerge_scan: + runs-on: ubuntu-latest + steps: + - name: Debug + env: + TOKEN: ${{ secrets.TOKEN }} + run: | + set -e + + echo ${TOKEN} | gh auth login --with-token + gh pr list -R sonic-net/sonic-buildimage -A mssonicbld --json additions,assignees,author,baseRefName,body,changedFiles,closed,closedAt,comments,commits,createdAt,deletions,files,headRefName,headRepository,headRepositoryOwner,id,isCrossRepository,isDraft,labels,latestReviews,maintainerCanModify,mergeCommit,mergeStateStatus,mergeable,mergedAt,mergedBy,milestone,number,potentialMergeCommit,projectCards,reactionGroups,reviewDecision,reviewRequests,reviews,state,statusCheckRollup,title,updatedAt,url > prs.log + cat prs.log | jq + - name: Main + run: | + set -e + + count=$(cat prs.log | jq 'length') + for ((i=0;i<$count;i++)) + do + url=$(cat prs.log | jq -r ".[$i].url") + created_at=$(cat prs.log | jq -r ".[$i].createdAt") + echo PR: $(($i+1))/$count, URL: $url, createdAt: $created_at, now: $(date -u +"%FT%TZ") + [[ "$url" == "" ]] && continue + [[ $created_at > $(date --date "1 hour ago" -u +"%FT%TZ") ]] && continue + checks=$(cat prs.log | jq ".[$i].statusCheckRollup") + checks_count=$(echo $checks | jq 'length') + echo Checks count: $checks_count + for ((j=0;j<$checks_count;j++)) + do + check=$(echo $checks | jq ".[$j]") + state=$(echo $check | jq -r '.state') + conclusion=$(echo $check | jq -r '.conclusion') + + # EasyCLA success flag: state=SUCCESS + # Others success flag: conclusion in SUCCESS,NEUTRAL + if [[ "$state" == "SUCCESS" ]];then + # check pass + continue + elif [[ "$conclusion" == "SUCCESS" ]] || [[ "$conclusion" == "NEUTRAL" ]];then + # check pass + continue + else + echo "$url Check failed!!!" + echo $check | jq + continue 2 + fi + done + # merge the PR + echo ========Merging PR======== + gh pr merge --rebase --admin -R sonic-net/sonic-buildimage $url || true + echo ========Finished PR======== + done diff --git a/.github/workflows/pr_cherrypick_poststep.yml b/.github/workflows/pr_cherrypick_poststep.yml index 1e9e497075d7..7be0b7d7cbe5 100644 --- a/.github/workflows/pr_cherrypick_poststep.yml +++ b/.github/workflows/pr_cherrypick_poststep.yml @@ -46,4 +46,4 @@ jobs: exit 1 fi gh pr edit $origin_pr_url --add-label "Included in ${base_ref} Branch" - gh pr edit $origin_pr_url --remove-label "Created PR to ${base_ref} Branch,Request for ${base_ref} Branch,Approved for ${base_ref} Branch" + gh pr edit $origin_pr_url --remove-label "Created PR to ${base_ref} Branch,Approved for ${base_ref} Branch" diff --git a/.gitmodules b/.gitmodules index 09ebc6da2373..5e715468a4ac 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,15 +1,19 @@ [submodule "sonic-swss-common"] path = src/sonic-swss-common url = https://github.com/sonic-net/sonic-swss-common + branch = 202211 [submodule "sonic-linux-kernel"] path = src/sonic-linux-kernel url = https://github.com/sonic-net/sonic-linux-kernel + branch = 202211 [submodule "sonic-sairedis"] path = src/sonic-sairedis url = https://github.com/sonic-net/sonic-sairedis + branch = 202211 [submodule "sonic-swss"] path = src/sonic-swss url = https://github.com/sonic-net/sonic-swss + branch = 202211 [submodule "src/p4c-bm/p4c-bm"] path = platform/p4/p4c-bm/p4c-bm url = https://github.com/krambn/p4c-bm @@ -31,15 +35,18 @@ [submodule "src/sonic-utilities"] path = src/sonic-utilities url = https://github.com/sonic-net/sonic-utilities + branch = 202211 [submodule "platform/broadcom/sonic-platform-modules-arista"] path = platform/broadcom/sonic-platform-modules-arista url = https://github.com/aristanetworks/sonic [submodule "src/sonic-platform-common"] path = src/sonic-platform-common url = https://github.com/sonic-net/sonic-platform-common + branch = 202211 [submodule "src/sonic-platform-daemons"] path = src/sonic-platform-daemons url = https://github.com/sonic-net/sonic-platform-daemons + branch = 202211 [submodule "src/sonic-platform-pde"] path = src/sonic-platform-pde url = https://github.com/sonic-net/sonic-platform-pdk-pde @@ -71,9 +78,6 @@ [submodule "src/sonic-mgmt-framework"] path = src/sonic-mgmt-framework url = https://github.com/sonic-net/sonic-mgmt-framework -[submodule "Switch-SDK-drivers"] - path = platform/mellanox/sdk-src/sx-kernel/Switch-SDK-drivers - url = https://github.com/Mellanox/Switch-SDK-drivers [submodule "src/sonic-ztp"] path = src/sonic-ztp url = https://github.com/sonic-net/sonic-ztp @@ -97,6 +101,7 @@ [submodule "src/linkmgrd"] path = src/linkmgrd url = https://github.com/sonic-net/sonic-linkmgrd.git + branch = 202211 [submodule "src/sonic-p4rt/sonic-pins"] path = src/sonic-p4rt/sonic-pins url = https://github.com/sonic-net/sonic-pins.git diff --git a/Makefile b/Makefile index ccfefc6c183c..048673234d09 100644 --- a/Makefile +++ b/Makefile @@ -33,20 +33,21 @@ PLATFORM_PATH := platform/$(if $(PLATFORM),$(PLATFORM),$(CONFIGURED_PLATFORM)) PLATFORM_CHECKOUT := platform/checkout PLATFORM_CHECKOUT_FILE := $(PLATFORM_CHECKOUT)/$(PLATFORM).ini PLATFORM_CHECKOUT_CMD := $(shell if [ -f $(PLATFORM_CHECKOUT_FILE) ]; then PLATFORM_PATH=$(PLATFORM_PATH) j2 $(PLATFORM_CHECKOUT)/template.j2 $(PLATFORM_CHECKOUT_FILE); fi) +MAKE_WITH_RETRY := ./scripts/run_with_retry $(MAKE) %:: @echo "+++ --- Making $@ --- +++" ifeq ($(NOJESSIE), 0) - EXTRA_DOCKER_TARGETS=$(notdir $@) $(MAKE) -f Makefile.work jessie + $(MAKE_WITH_RETRY) EXTRA_DOCKER_TARGETS=$(notdir $@) -f Makefile.work jessie endif ifeq ($(NOSTRETCH), 0) - EXTRA_DOCKER_TARGETS=$(notdir $@) BLDENV=stretch $(MAKE) -f Makefile.work stretch + $(MAKE_WITH_RETRY) EXTRA_DOCKER_TARGETS=$(notdir $@) BLDENV=stretch -f Makefile.work stretch endif ifeq ($(NOBUSTER), 0) - EXTRA_DOCKER_TARGETS=$(notdir $@) BLDENV=buster $(MAKE) -f Makefile.work buster + $(MAKE_WITH_RETRY) EXTRA_DOCKER_TARGETS=$(notdir $@) BLDENV=buster -f Makefile.work buster endif ifeq ($(NOBULLSEYE), 0) - BLDENV=bullseye $(MAKE) -f Makefile.work $@ + $(MAKE_WITH_RETRY) BLDENV=bullseye -f Makefile.work $@ endif BLDENV=bullseye $(MAKE) -f Makefile.work docker-cleanup diff --git a/Makefile.work b/Makefile.work index 360433ce7922..9db59cf22511 100644 --- a/Makefile.work +++ b/Makefile.work @@ -37,6 +37,9 @@ # * ENABLE_TRANSLIB_WRITE: Enable translib write/config operations via the gNMI interface. # * Default: unset # * Values: y +# * ENABLE_NATIVE_WRITE: Enable native write/config operations via the gNMI interface. +# * Default: unset +# * Values: y # * SONIC_DPKG_CACHE_METHOD: Specifying method of obtaining the Debian packages from cache: none or cache # * SONIC_DPKG_CACHE_SOURCE: Debian package cache location when cache enabled for debian packages # * BUILD_LOG_TIMESTAMP: Set timestamp in the build log (simple/none) @@ -50,6 +53,10 @@ # * ENABLE_BOOTCHART: Enable SONiC bootchart # * Default: n # * Values: y,n +# * UNATTENDED: Don't wait for interactive input from terminal, setting this +# * value to anything will enable it +# * Default: unset +# * Value: y # ############################################################################### @@ -177,6 +184,7 @@ $(shell \ SONIC_VERSION_CONTROL_COMPONENTS=$(SONIC_VERSION_CONTROL_COMPONENTS) \ TRUSTED_GPG_URLS=$(TRUSTED_GPG_URLS) \ PACKAGE_URL_PREFIX=$(PACKAGE_URL_PREFIX) \ + MIRROR_SNAPSHOT=$(MIRROR_SNAPSHOT) \ scripts/generate_buildinfo_config.sh) # Generate the slave Dockerfile, and prepare build info for it @@ -195,6 +203,7 @@ $(shell CONFIGURED_ARCH=$(CONFIGURED_ARCH) \ PREPARE_DOCKER=BUILD_SLAVE=y \ DEFAULT_CONTAINER_REGISTRY=$(DEFAULT_CONTAINER_REGISTRY) \ + MIRROR_SNAPSHOT=$(MIRROR_SNAPSHOT) \ scripts/prepare_docker_buildinfo.sh \ $(SLAVE_BASE_IMAGE) \ $(SLAVE_DIR)/Dockerfile \ @@ -225,8 +234,12 @@ SLAVE_TAG = $(shell \ COLLECT_DOCKER=DEFAULT_CONTAINER_REGISTRY=$(DEFAULT_CONTAINER_REGISTRY) \ scripts/collect_docker_version_files.sh \ - $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) \ - target + $(SLAVE_BASE_IMAGE) \ + target \ + $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) \ + $(SLAVE_DIR) \ + $(SLAVE_DIR)/Dockerfile + OVERLAY_MODULE_CHECK := \ lsmod | grep -q "^overlay " &>/dev/null || \ zgrep -q 'CONFIG_OVERLAY_FS=y' /proc/config.gz &>/dev/null || \ @@ -373,7 +386,8 @@ DOCKER_SLAVE_BASE_BUILD = docker build --no-cache \ --build-arg http_proxy=$(http_proxy) \ --build-arg https_proxy=$(https_proxy) \ --build-arg no_proxy=$(no_proxy) \ - $(SLAVE_DIR) $(SPLIT_LOG) $(DOCKER_BASE_LOG) + $(SLAVE_DIR) \ + $(SPLIT_LOG) $(DOCKER_BASE_LOG) DOCKER_BASE_PULL = docker pull \ $(REGISTRY_SERVER):$(REGISTRY_PORT)/$(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) @@ -480,6 +494,7 @@ SONIC_BUILD_INSTRUCTION := $(MAKE) \ SONIC_INCLUDE_RESTAPI=$(INCLUDE_RESTAPI) \ SONIC_INCLUDE_MUX=$(INCLUDE_MUX) \ ENABLE_TRANSLIB_WRITE=$(ENABLE_TRANSLIB_WRITE) \ + ENABLE_NATIVE_WRITE=$(ENABLE_NATIVE_WRITE) \ EXTRA_DOCKER_TARGETS=$(EXTRA_DOCKER_TARGETS) \ BUILD_LOG_TIMESTAMP=$(BUILD_LOG_TIMESTAMP) \ SONIC_ENABLE_IMAGE_SIGNATURE=$(ENABLE_IMAGE_SIGNATURE) \ @@ -497,13 +512,15 @@ SONIC_BUILD_INSTRUCTION := $(MAKE) \ SONIC_SLAVE_DOCKER_DRIVER=$(SONIC_SLAVE_DOCKER_DRIVER) \ MIRROR_URLS=$(MIRROR_URLS) \ MIRROR_SECURITY_URLS=$(MIRROR_SECURITY_URLS) \ + MIRROR_SNAPSHOT=$(MIRROR_SNAPSHOT) \ + SONIC_OS_VERSION=$(SONIC_OS_VERSION) \ $(SONIC_OVERRIDE_BUILD_VARS) .PHONY: sonic-slave-build sonic-slave-bash init reset ifeq ($(filter clean,$(MAKECMDGOALS)),) -COLLECT_BUILD_VERSION = { DBGOPT='$(DBGOPT)' scripts/collect_build_version_files.sh \$$?; } +COLLECT_BUILD_VERSION = { scripts/collect_build_version_files.sh \$$?; } endif ifdef SOURCE_FOLDER @@ -519,6 +536,7 @@ endif export MIRROR_URLS export MIRROR_SECURITY_URLS +export SONIC_VERSION_CONTROL_COMPONENTS %:: | sonic-build-hooks ifneq ($(filter y, $(MULTIARCH_QEMU_ENVIRON) $(CROSS_BUILD_ENVIRON)),) @@ -545,7 +563,7 @@ sonic-build-hooks: $(Q)pushd src/sonic-build-hooks; TRUSTED_GPG_URLS=$(TRUSTED_GPG_URLS) $(MAKE) all; popd $(Q)mkdir -p $(SLAVE_DIR)/buildinfo $(Q)cp src/sonic-build-hooks/buildinfo/sonic-build-hooks* $(SLAVE_DIR)/buildinfo - $(Q)[ "$(MULTIARCH_QEMU_ENVIRON)" == y ] && scripts/build_mirror_config.sh $(SLAVE_DIR) amd64 $(BLDENV) + $(Q)if [ "$(MULTIARCH_QEMU_ENVIRON)" == y ]; then scripts/build_mirror_config.sh $(SLAVE_DIR) amd64 $(BLDENV); fi $(Q)scripts/build_mirror_config.sh $(SLAVE_DIR) $(CONFIGURED_ARCH) $(BLDENV) sonic-slave-base-build : | sonic-build-hooks @@ -574,23 +592,28 @@ init : .ONESHELL : reset reset : - $(Q)echo && echo -n "Warning! All local changes will be lost. Proceed? [y/N]: " - $(Q)read ans && ( - if [ $$ans == y ]; then - echo "Resetting local repository. Please wait..."; - sudo rm -rf fsroot*; - if [ "$(MULTIARCH_QEMU_ENVIRON)" == y ] && [[ "$(CONFIGURED_ARCH)" == "armhf" || "$(CONFIGURED_ARCH)" == "arm64" ]]; then - echo "Stopping march $(CONFIGURED_ARCH) docker" - sudo kill -9 `sudo cat /var/run/march/docker.pid` || true - sudo rm -f /var/run/march/docker.pid || true - fi - git clean -xfdf; - git reset --hard; - git submodule foreach --recursive 'git clean -xfdf || true'; - git submodule foreach --recursive 'git reset --hard || true'; - git submodule foreach --recursive 'git remote update || true'; - git submodule update --init --recursive; - echo "Reset complete!"; - else - echo "Reset aborted"; - fi ) + $(Q)echo && ( + if [ -z "$(UNATTENDED)" ]; then + echo -n "Warning! All local changes will be lost. Proceed? [y/N]: " + @read ans + else + ans=y + fi + if [ $$ans == y ]; then + echo "Resetting local repository. Please wait..."; + sudo rm -rf fsroot*; + if [ "$(MULTIARCH_QEMU_ENVIRON)" == y ] && [[ "$(CONFIGURED_ARCH)" == "armhf" || "$(CONFIGURED_ARCH)" == "arm64" ]]; then + echo "Stopping march $(CONFIGURED_ARCH) docker" + sudo kill -9 `sudo cat /var/run/march/docker.pid` || true + sudo rm -f /var/run/march/docker.pid || true + fi + git clean -xfdf; + git reset --hard; + git submodule foreach --recursive 'git clean -xfdf || true'; + git submodule foreach --recursive 'git reset --hard || true'; + git submodule foreach --recursive 'git remote update || true'; + git submodule update --init --recursive; + echo "Reset complete!"; + else + echo "Reset aborted"; + fi ) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 073702ba3f68..ff62e1af43f4 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -177,21 +177,21 @@ stages: pool: vmImage: 'ubuntu-20.04' displayName: "kvmtest-t0 by TestbedV2" - timeoutInMinutes: 1080 + timeoutInMinutes: 240 condition: and(succeeded(), eq(variables.BUILD_IMG_RUN_TESTBEDV2_TEST, 'YES')) continueOnError: false steps: - template: .azure-pipelines/run-test-scheduler-template.yml parameters: TOPOLOGY: t0 - MIN_WORKER: 2 - MAX_WORKER: 3 + MIN_WORKER: $(T0_INSTANCE_NUM) + MAX_WORKER: $(T0_INSTANCE_NUM) - job: t0_2vlans_testbedv2 pool: vmImage: 'ubuntu-20.04' displayName: "kvmtest-t0-2vlans by TestbedV2" - timeoutInMinutes: 1080 + timeoutInMinutes: 240 condition: and(succeeded(), eq(variables.BUILD_IMG_RUN_TESTBEDV2_TEST, 'YES')) continueOnError: false steps: @@ -199,7 +199,8 @@ stages: parameters: TOPOLOGY: t0 TEST_SET: t0-2vlans - MAX_WORKER: 1 + MIN_WORKER: $(T0_2VLANS_INSTANCE_NUM) + MAX_WORKER: $(T0_2VLANS_INSTANCE_NUM) DEPLOY_MG_EXTRA_PARAMS: "-e vlan_config=two_vlan_a" - job: @@ -254,15 +255,15 @@ stages: pool: vmImage: 'ubuntu-20.04' displayName: "kvmtest-t1-lag by TestbedV2" - timeoutInMinutes: 600 + timeoutInMinutes: 240 condition: and(succeeded(), eq(variables.BUILD_IMG_RUN_TESTBEDV2_TEST, 'YES')) continueOnError: false steps: - template: .azure-pipelines/run-test-scheduler-template.yml parameters: TOPOLOGY: t1-lag - MIN_WORKER: 2 - MAX_WORKER: 3 + MIN_WORKER: $(T1_LAG_INSTANCE_NUM) + MAX_WORKER: $(T1_LAG_INSTANCE_NUM) - job: pool: @@ -320,47 +321,62 @@ stages: displayName: "kvmtest-multi-asic-t1-lag by TestbedV2" pool: vmImage: 'ubuntu-20.04' - timeoutInMinutes: 1080 + timeoutInMinutes: 240 condition: and(succeeded(), eq(variables.BUILD_IMG_RUN_TESTBEDV2_TEST, 'YES')) - continueOnError: true + continueOnError: false steps: - template: .azure-pipelines/run-test-scheduler-template.yml parameters: TOPOLOGY: t1-8-lag TEST_SET: multi-asic-t1-lag - MIN_WORKER: 1 - MAX_WORKER: 1 + MIN_WORKER: $(MULTI_ASIC_INSTANCE_NUM) + MAX_WORKER: $(MULTI_ASIC_INSTANCE_NUM) NUM_ASIC: 4 - job: dualtor_testbedv2 pool: vmImage: 'ubuntu-20.04' displayName: "kvmtest-dualtor-t0 by TestbedV2" - timeoutInMinutes: 1080 + timeoutInMinutes: 240 condition: and(succeeded(), eq(variables.BUILD_IMG_RUN_TESTBEDV2_TEST, 'YES')) continueOnError: false steps: - template: .azure-pipelines/run-test-scheduler-template.yml parameters: TOPOLOGY: dualtor - MIN_WORKER: 1 - MAX_WORKER: 1 + MIN_WORKER: $(T0_DUALTOR_INSTANCE_NUM) + MAX_WORKER: $(T0_DUALTOR_INSTANCE_NUM) COMMON_EXTRA_PARAMS: "--disable_loganalyzer " - job: sonic_t0_testbedv2 displayName: "kvmtest-t0-sonic by TestbedV2" pool: vmImage: 'ubuntu-20.04' - timeoutInMinutes: 1080 + timeoutInMinutes: 240 condition: and(succeeded(), eq(variables.BUILD_IMG_RUN_TESTBEDV2_TEST, 'YES')) - continueOnError: true + continueOnError: false steps: - template: .azure-pipelines/run-test-scheduler-template.yml parameters: TOPOLOGY: t0-64-32 - MIN_WORKER: 1 - MAX_WORKER: 2 + MIN_WORKER: $(T0_SONIC_INSTANCE_NUM) + MAX_WORKER: $(T0_SONIC_INSTANCE_NUM) TEST_SET: t0-sonic COMMON_EXTRA_PARAMS: "--neighbor_type=sonic --enable_macsec --macsec_profile=128_SCI,256_XPN_SCI" VM_TYPE: vsonic SPECIFIED_PARAMS: '{\"test_pretest.py\":[\"--completeness_level=confident\",\"--allow_recover\"],\"test_posttest.py\":[\"--completeness_level=confident\",\"--allow_recover\"]}' + + - job: wan_testbedv2 + displayName: "kvmtest-wan by TestbedV2" + pool: + vmImage: 'ubuntu-20.04' + timeoutInMinutes: 1080 + condition: and(succeeded(), eq(variables.BUILD_IMG_RUN_TESTBEDV2_TEST, 'YES')) + continueOnError: true + steps: + - template: .azure-pipelines/run-test-scheduler-template.yml + parameters: + TOPOLOGY: wan-pub + MIN_WORKER: $(WAN_INSTANCE_NUM) + MAX_WORKER: $(WAN_INSTANCE_NUM) + COMMON_EXTRA_PARAMS: "--skip_sanity " diff --git a/build_debian.sh b/build_debian.sh index c4d748ac4d21..6c8880144423 100755 --- a/build_debian.sh +++ b/build_debian.sh @@ -110,7 +110,7 @@ sudo LANG=C chroot $FILESYSTEM_ROOT mount ## Pointing apt to public apt mirrors and getting latest packages, needed for latest security updates scripts/build_mirror_config.sh files/apt $CONFIGURED_ARCH $IMAGE_DISTRO sudo cp files/apt/sources.list.$CONFIGURED_ARCH $FILESYSTEM_ROOT/etc/apt/sources.list -sudo cp files/apt/apt.conf.d/{81norecommends,apt-{clean,gzip-indexes,no-languages},no-check-valid-until} $FILESYSTEM_ROOT/etc/apt/apt.conf.d/ +sudo cp files/apt/apt.conf.d/{81norecommends,apt-{clean,gzip-indexes,no-languages},no-check-valid-until,apt-multiple-retries} $FILESYSTEM_ROOT/etc/apt/apt.conf.d/ ## Note: set lang to prevent locale warnings in your chroot sudo LANG=C chroot $FILESYSTEM_ROOT apt-get -y update @@ -262,6 +262,7 @@ install_kubernetes () { ## Check out the sources list update matches current Debian version sudo cp files/image_config/kubernetes/kubernetes.list $FILESYSTEM_ROOT/etc/apt/sources.list.d/ sudo LANG=C chroot $FILESYSTEM_ROOT apt-get update + sudo LANG=C chroot $FILESYSTEM_ROOT apt-get -y install kubernetes-cni=${KUBERNETES_CNI_VERSION} sudo LANG=C chroot $FILESYSTEM_ROOT apt-get -y install kubelet=${ver} sudo LANG=C chroot $FILESYSTEM_ROOT apt-get -y install kubectl=${ver} sudo LANG=C chroot $FILESYSTEM_ROOT apt-get -y install kubeadm=${ver} @@ -272,7 +273,6 @@ then ## Install Kubernetes echo '[INFO] Install kubernetes' install_kubernetes ${KUBERNETES_VERSION} - sudo LANG=C chroot $FILESYSTEM_ROOT apt-get -y install kubernetes-cni=${KUBERNETES_CNI_VERSION} else echo '[INFO] Skipping Install kubernetes' fi @@ -387,7 +387,10 @@ sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y in gpg \ jq \ auditd \ - linux-perf + linux-perf \ + resolvconf \ + lsof \ + sysstat # default rsyslog version is 8.2110.0 which has a bug on log rate limit, # use backport version @@ -468,16 +471,12 @@ rm /files/etc/ssh/sshd_config/ClientAliveInterval rm /files/etc/ssh/sshd_config/ClientAliveCountMax touch /files/etc/ssh/sshd_config/EmptyLineHack rename /files/etc/ssh/sshd_config/EmptyLineHack "" -set /files/etc/ssh/sshd_config/ClientAliveInterval 300 +set /files/etc/ssh/sshd_config/ClientAliveInterval 900 set /files/etc/ssh/sshd_config/ClientAliveCountMax 0 ins #comment before /files/etc/ssh/sshd_config/ClientAliveInterval -set /files/etc/ssh/sshd_config/#comment[following-sibling::*[1][self::ClientAliveInterval]] "Close inactive client sessions after 5 minutes" -rm /files/etc/ssh/sshd_config/MaxAuthTries -set /files/etc/ssh/sshd_config/MaxAuthTries 3 +set /files/etc/ssh/sshd_config/#comment[following-sibling::*[1][self::ClientAliveInterval]] "Close inactive client sessions after 15 minutes" rm /files/etc/ssh/sshd_config/LogLevel set /files/etc/ssh/sshd_config/LogLevel VERBOSE -rm /files/etc/ssh/sshd_config/Banner -set /files/etc/ssh/sshd_config/Banner /etc/issue save quit EOF @@ -574,6 +573,7 @@ export release="$(if [ -f $FILESYSTEM_ROOT/etc/sonic/sonic_release ]; then cat $ export build_date="$(date -u)" export build_number="${BUILD_NUMBER:-0}" export built_by="$USER@$BUILD_HOSTNAME" +export sonic_os_version="${SONIC_OS_VERSION}" j2 files/build_templates/sonic_version.yml.j2 | sudo tee $FILESYSTEM_ROOT/etc/sonic/sonic_version.yml ## Copy over clean-up script @@ -679,7 +679,11 @@ sudo rm -f $ONIE_INSTALLER_PAYLOAD $FILESYSTEM_SQUASHFS ## Note: -x to skip directories on different file systems, such as /proc sudo du -hsx $FILESYSTEM_ROOT sudo mkdir -p $FILESYSTEM_ROOT/var/lib/docker -sudo cp files/image_config/resolv-config/resolv.conf $FILESYSTEM_ROOT/etc/resolv.conf + +## Clear DNS configuration inherited from the build server +sudo rm -f $FILESYSTEM_ROOT/etc/resolvconf/resolv.conf.d/original +sudo cp files/image_config/resolv-config/resolv.conf.head $FILESYSTEM_ROOT/etc/resolvconf/resolv.conf.d/head + sudo mksquashfs $FILESYSTEM_ROOT $FILESYSTEM_SQUASHFS -comp zstd -b 1M -e boot -e var/lib/docker -e $PLATFORM_DIR # Ensure admin gid is 1000 diff --git a/device/arista/x86_64-arista_7050cx3_32s/Arista-7050CX3-32S-C32/BALANCED/qos.json.j2 b/device/arista/x86_64-arista_7050cx3_32s/Arista-7050CX3-32S-C32/BALANCED/qos.json.j2 index 040da33dd79f..74059a27d24b 100644 --- a/device/arista/x86_64-arista_7050cx3_32s/Arista-7050CX3-32S-C32/BALANCED/qos.json.j2 +++ b/device/arista/x86_64-arista_7050cx3_32s/Arista-7050CX3-32S-C32/BALANCED/qos.json.j2 @@ -1,4 +1,6 @@ {% if 'subtype' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['subtype'] == 'DualToR' %} +{% set different_dscp_to_tc_map = true %} +{% set different_tc_to_queue_map = true %} {%- macro generate_dscp_to_tc_map() %} "DSCP_TO_TC_MAP": { "AZURE": { @@ -67,7 +69,73 @@ "62": "1", "63": "1" }, - "AZURE_TUNNEL": { + "AZURE_UPLINK": { + "0" : "1", + "1" : "1", + "2" : "2", + "3" : "3", + "4" : "4", + "5" : "1", + "6" : "6", + "7" : "1", + "8" : "0", + "9" : "1", + "10": "1", + "11": "1", + "12": "1", + "13": "1", + "14": "1", + "15": "1", + "16": "1", + "17": "1", + "18": "1", + "19": "1", + "20": "1", + "21": "1", + "22": "1", + "23": "1", + "24": "1", + "25": "1", + "26": "1", + "27": "1", + "28": "1", + "29": "1", + "30": "1", + "31": "1", + "32": "1", + "33": "8", + "34": "1", + "35": "1", + "36": "1", + "37": "1", + "38": "1", + "39": "1", + "40": "1", + "41": "1", + "42": "1", + "43": "1", + "44": "1", + "45": "1", + "46": "5", + "47": "1", + "48": "7", + "49": "1", + "50": "1", + "51": "1", + "52": "1", + "53": "1", + "54": "1", + "55": "1", + "56": "1", + "57": "1", + "58": "1", + "59": "1", + "60": "1", + "61": "1", + "62": "1", + "63": "1" + }, + "AZURE_TUNNEL": { "0" : "1", "1" : "1", "2" : "1", @@ -174,6 +242,17 @@ "7": "7", "8": "1" }, + "AZURE_UPLINK": { + "0": "0", + "1": "1", + "2": "2", + "3": "3", + "4": "4", + "5": "5", + "6": "6", + "7": "7", + "8": "1" + }, "AZURE_TUNNEL": { "0": "0", "1": "1", diff --git a/device/arista/x86_64-arista_7050cx3_32s/Arista-7050CX3-32S-D48C8/BALANCED/qos.json.j2 b/device/arista/x86_64-arista_7050cx3_32s/Arista-7050CX3-32S-D48C8/BALANCED/qos.json.j2 index 040da33dd79f..74059a27d24b 100644 --- a/device/arista/x86_64-arista_7050cx3_32s/Arista-7050CX3-32S-D48C8/BALANCED/qos.json.j2 +++ b/device/arista/x86_64-arista_7050cx3_32s/Arista-7050CX3-32S-D48C8/BALANCED/qos.json.j2 @@ -1,4 +1,6 @@ {% if 'subtype' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['subtype'] == 'DualToR' %} +{% set different_dscp_to_tc_map = true %} +{% set different_tc_to_queue_map = true %} {%- macro generate_dscp_to_tc_map() %} "DSCP_TO_TC_MAP": { "AZURE": { @@ -67,7 +69,73 @@ "62": "1", "63": "1" }, - "AZURE_TUNNEL": { + "AZURE_UPLINK": { + "0" : "1", + "1" : "1", + "2" : "2", + "3" : "3", + "4" : "4", + "5" : "1", + "6" : "6", + "7" : "1", + "8" : "0", + "9" : "1", + "10": "1", + "11": "1", + "12": "1", + "13": "1", + "14": "1", + "15": "1", + "16": "1", + "17": "1", + "18": "1", + "19": "1", + "20": "1", + "21": "1", + "22": "1", + "23": "1", + "24": "1", + "25": "1", + "26": "1", + "27": "1", + "28": "1", + "29": "1", + "30": "1", + "31": "1", + "32": "1", + "33": "8", + "34": "1", + "35": "1", + "36": "1", + "37": "1", + "38": "1", + "39": "1", + "40": "1", + "41": "1", + "42": "1", + "43": "1", + "44": "1", + "45": "1", + "46": "5", + "47": "1", + "48": "7", + "49": "1", + "50": "1", + "51": "1", + "52": "1", + "53": "1", + "54": "1", + "55": "1", + "56": "1", + "57": "1", + "58": "1", + "59": "1", + "60": "1", + "61": "1", + "62": "1", + "63": "1" + }, + "AZURE_TUNNEL": { "0" : "1", "1" : "1", "2" : "1", @@ -174,6 +242,17 @@ "7": "7", "8": "1" }, + "AZURE_UPLINK": { + "0": "0", + "1": "1", + "2": "2", + "3": "3", + "4": "4", + "5": "5", + "6": "6", + "7": "7", + "8": "1" + }, "AZURE_TUNNEL": { "0": "0", "1": "1", diff --git a/device/arista/x86_64-arista_7050cx3_32s/platform_components.json b/device/arista/x86_64-arista_7050cx3_32s/platform_components.json index 0d30d1b13e1b..6fdd182db485 100644 --- a/device/arista/x86_64-arista_7050cx3_32s/platform_components.json +++ b/device/arista/x86_64-arista_7050cx3_32s/platform_components.json @@ -3,7 +3,7 @@ "DCS-7050CX3-32S": { "component": { "Aboot()": {}, - "Scd(addr=0000:00:18.7)": {}, + "Scd(addr=0000:02:00.0)": {}, "Ucd90120A(addr=3-004e)": {}, "Ucd90120A(addr=16-004e)": {}, "CrowSysCpld(addr=2-0023)": {} diff --git a/device/arista/x86_64-arista_7050dx4_32s/platform_env.conf b/device/arista/x86_64-arista_7050dx4_32s/platform_env.conf index d72ffde2f262..dd7cf4fe01c5 100644 --- a/device/arista/x86_64-arista_7050dx4_32s/platform_env.conf +++ b/device/arista/x86_64-arista_7050dx4_32s/platform_env.conf @@ -1,2 +1,2 @@ -SYNCD_SHM_SIZE=256m +SYNCD_SHM_SIZE=512m is_ltsw_chip=1 diff --git a/device/arista/x86_64-arista_7050px4_32s/platform_env.conf b/device/arista/x86_64-arista_7050px4_32s/platform_env.conf index d72ffde2f262..dd7cf4fe01c5 100644 --- a/device/arista/x86_64-arista_7050px4_32s/platform_env.conf +++ b/device/arista/x86_64-arista_7050px4_32s/platform_env.conf @@ -1,2 +1,2 @@ -SYNCD_SHM_SIZE=256m +SYNCD_SHM_SIZE=512m is_ltsw_chip=1 diff --git a/device/arista/x86_64-arista_7060_cx32s/platform.json b/device/arista/x86_64-arista_7060_cx32s/platform.json index 92c0d40a3758..f322ac0aab87 100644 --- a/device/arista/x86_64-arista_7060_cx32s/platform.json +++ b/device/arista/x86_64-arista_7060_cx32s/platform.json @@ -1,7 +1,23 @@ { "chassis": { "name": "DCS-7060CX-32S", - "components": [], + "components": [ + { + "name": "Aboot()" + }, + { + "name": "Scd(addr=0000:02:00.0)" + }, + { + "name": "Ucd90120A(addr=4-004e)" + }, + { + "name": "Ucd90120A(addr=8-004e)" + }, + { + "name": "CrowSysCpld(addr=2-0023)" + } + ], "fans": [], "fan_drawers": [ { @@ -40,52 +56,55 @@ "psus": [ { "name": "psu1", - "fans": [] + "fans": [ + { + "name": "psu1/1", + "speed": { + "controllable": false + } + } + ] }, { "name": "psu2", - "fans": [] + "fans": [ + { + "name": "psu2/1", + "speed": { + "controllable": false + } + } + ] } ], "thermals": [ { - "name": "Cpu temp sensor" - }, - { - "name": "Cpu board temp sensor" - }, - { - "name": "Back-panel temp sensor" - }, - { - "name": "Board sensor" - }, - { - "name": "Switch chip left sensor" - }, - { - "name": "Switch chip right sensor" - }, - { - "name": "Front-panel temp sensor" + "name": "Cpu temp sensor", + "controllable": false }, { - "name": "Power supply 1 hotspot sensor" + "name": "Cpu board temp sensor", + "controllable": false }, { - "name": "Power supply 1 inlet temp sensor" + "name": "Back-panel temp sensor", + "controllable": false }, { - "name": "Power supply 1 exhaust temp sensor" + "name": "Board sensor", + "controllable": false }, { - "name": "Power supply 2 hotspot sensor" + "name": "Switch chip left sensor", + "controllable": false }, { - "name": "Power supply 2 inlet temp sensor" + "name": "Switch chip right sensor", + "controllable": false }, { - "name": "Power supply 2 exhaust temp sensor" + "name": "Front-panel temp sensor", + "controllable": false } ], "sfps": [ @@ -821,4 +840,4 @@ } } } -} \ No newline at end of file +} diff --git a/device/arista/x86_64-arista_7060_cx32s/platform_components.json b/device/arista/x86_64-arista_7060_cx32s/platform_components.json new file mode 100644 index 000000000000..d7647e359b86 --- /dev/null +++ b/device/arista/x86_64-arista_7060_cx32s/platform_components.json @@ -0,0 +1,13 @@ +{ + "chassis": { + "DCS-7050CX3-32S": { + "component": { + "Aboot()": {}, + "Scd(addr=0000:02:00.0)": {}, + "Ucd90120A(addr=4-004e)": {}, + "Ucd90120A(addr=8-004e)": {}, + "CrowSysCpld(addr=2-0023)": {} + } + } + } +} diff --git a/device/arista/x86_64-arista_7060dx5_64s/platform_env.conf b/device/arista/x86_64-arista_7060dx5_64s/platform_env.conf index 77174634dce9..dd7cf4fe01c5 100644 --- a/device/arista/x86_64-arista_7060dx5_64s/platform_env.conf +++ b/device/arista/x86_64-arista_7060dx5_64s/platform_env.conf @@ -1,2 +1,2 @@ -SYNCD_SHM_SIZE=128m +SYNCD_SHM_SIZE=512m is_ltsw_chip=1 diff --git a/device/arista/x86_64-arista_7060px5_64s/platform_env.conf b/device/arista/x86_64-arista_7060px5_64s/platform_env.conf index 77174634dce9..dd7cf4fe01c5 100644 --- a/device/arista/x86_64-arista_7060px5_64s/platform_env.conf +++ b/device/arista/x86_64-arista_7060px5_64s/platform_env.conf @@ -1,2 +1,2 @@ -SYNCD_SHM_SIZE=128m +SYNCD_SHM_SIZE=512m is_ltsw_chip=1 diff --git a/device/arista/x86_64-arista_720dt_48s/Arista-720DT-G48S4 b/device/arista/x86_64-arista_720dt_48s/Arista-720DT-G48S4 new file mode 120000 index 000000000000..02f438669cad --- /dev/null +++ b/device/arista/x86_64-arista_720dt_48s/Arista-720DT-G48S4 @@ -0,0 +1 @@ +Arista-720DT-48S \ No newline at end of file diff --git a/device/arista/x86_64-arista_720dt_48s/platform_components.json b/device/arista/x86_64-arista_720dt_48s/platform_components.json index ea8bbb5e3346..c77e3ca9a7da 100644 --- a/device/arista/x86_64-arista_720dt_48s/platform_components.json +++ b/device/arista/x86_64-arista_720dt_48s/platform_components.json @@ -5,6 +5,30 @@ "Aboot()": {}, "Scd(addr=0000:00:18.7)": {} } + }, + "CCS-720DT-48S-2F": { + "component": { + "Aboot()": {}, + "Scd(addr=0000:00:18.7)": {} + } + }, + "CCS-720DT-48S-2R": { + "component": { + "Aboot()": {}, + "Scd(addr=0000:00:18.7)": {} + } + }, + "CCS-720DT-48S-2F": { + "component": { + "Aboot()": {}, + "Scd(addr=0000:00:18.7)": {} + } + }, + "CCS-720DT-48S-2R": { + "component": { + "Aboot()": {}, + "Scd(addr=0000:00:18.7)": {} + } } } } diff --git a/device/arista/x86_64-arista_720dt_48s/td3x2-a720dt-48s-flex.config.bcm b/device/arista/x86_64-arista_720dt_48s/td3x2-a720dt-48s-flex.config.bcm index 033a19a9f06d..5c49982b9631 100644 --- a/device/arista/x86_64-arista_720dt_48s/td3x2-a720dt-48s-flex.config.bcm +++ b/device/arista/x86_64-arista_720dt_48s/td3x2-a720dt-48s-flex.config.bcm @@ -10,6 +10,7 @@ dma_desc_timeout_usec.0=15000000 fpem_mem_entries.0=0 higig2_hdr_mode.0=1 ifp_inports_support_enable.0=1 +ipv6_lpm_128b_enable.0=1 l2xmsg_mode.0=1 l2_mem_entries.0=65536 l3_mem_entries.0=32768 @@ -301,3 +302,4 @@ stable_size=0x5500000 tdma_timeout_usec.0=15000000 tslam_timeout_usec.0=15000000 sai_mdio_access_clause22=1 +sai_verify_incoming_chksum=0 diff --git a/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C10/BALANCED b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C10/BALANCED new file mode 120000 index 000000000000..a270c70ffc36 --- /dev/null +++ b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C10/BALANCED @@ -0,0 +1 @@ +../../../common/profiles/th2/7260/BALANCED \ No newline at end of file diff --git a/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C10/RDMA-CENTRIC b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C10/RDMA-CENTRIC new file mode 120000 index 000000000000..8d1ec6d277a8 --- /dev/null +++ b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C10/RDMA-CENTRIC @@ -0,0 +1 @@ +../../../common/profiles/th2/7260/RDMA-CENTRIC \ No newline at end of file diff --git a/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C10/TCP-CENTRIC b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C10/TCP-CENTRIC new file mode 120000 index 000000000000..7ee783aac6a4 --- /dev/null +++ b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C10/TCP-CENTRIC @@ -0,0 +1 @@ +../../../common/profiles/th2/7260/TCP-CENTRIC \ No newline at end of file diff --git a/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C10/buffer_ports_t0.j2 b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C10/buffer_ports_t0.j2 new file mode 100644 index 000000000000..a6506c3c30dd --- /dev/null +++ b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C10/buffer_ports_t0.j2 @@ -0,0 +1,17 @@ +{%- macro generate_port_lists(PORT_ALL) %} + {# Generate list of ports #} + {%- for port_idx in range(2,12) %} + {%- 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(20,64) %} + {%- 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(0,2) %} + {%- if PORT_ALL.append("Ethernet%d" % (port_idx * 4)) %}{%- endif %} + {%- endfor %} + {%- for port_idx in range(12,20) %} + {%- if PORT_ALL.append("Ethernet%d" % (port_idx * 4)) %}{%- endif %} + {%- endfor %} +{%- endmacro %} diff --git a/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C10/buffers.json.j2 b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C10/buffers.json.j2 new file mode 100644 index 000000000000..e6e9e844469b --- /dev/null +++ b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C10/buffers.json.j2 @@ -0,0 +1,3 @@ +{%- set default_topo = 't0' %} +{%- include 'buffers_config.j2' %} + diff --git a/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C10/buffers_defaults_t0.j2 b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C10/buffers_defaults_t0.j2 new file mode 120000 index 000000000000..9524e6a476ac --- /dev/null +++ b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C10/buffers_defaults_t0.j2 @@ -0,0 +1 @@ +BALANCED/buffers_defaults_t0.j2 \ No newline at end of file diff --git a/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C10/buffers_extra_queues.j2 b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C10/buffers_extra_queues.j2 new file mode 120000 index 000000000000..92b7e9ffbee5 --- /dev/null +++ b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C10/buffers_extra_queues.j2 @@ -0,0 +1 @@ +../Arista-7260CX3-C64/buffers_extra_queues.j2 \ No newline at end of file diff --git a/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C10/buffers_pool_sizes_t0.j2 b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C10/buffers_pool_sizes_t0.j2 new file mode 120000 index 000000000000..72e16a608268 --- /dev/null +++ b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C10/buffers_pool_sizes_t0.j2 @@ -0,0 +1 @@ +../Arista-7260CX3-C64/buffers_pool_sizes_t0.j2 \ No newline at end of file diff --git a/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C10/config.bcm.j2 b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C10/config.bcm.j2 new file mode 100644 index 000000000000..2255d7149b6b --- /dev/null +++ b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C10/config.bcm.j2 @@ -0,0 +1,951 @@ +{# Construct config.bcm to include additional soc properties per specific device metadata requirement #} +{%- set IPinIP_sock = '' -%} +{%- set map_prio = '' -%} +{%- if DEVICE_METADATA is defined and DEVICE_METADATA['localhost'] is defined and DEVICE_METADATA['localhost']['subtype'] is defined -%} +{%- set switch_subtype = DEVICE_METADATA['localhost']['subtype'] -%} +{%- if 'dualtor' in switch_subtype.lower() %} +{%- set IPinIP_sock = 'sai_tunnel_support=1 + sai_tunnel_underlay_route_mode=1 + host_as_route_disable=1 + l3_ecmp_levels=2' -%} +{%- set map_prio = 'sai_remap_prio_on_tnl_egress=1' -%} +{%- endif %} +{%- endif %} +{# The following is the common soc properties that used to be named "th2-a7260cx3-64-112x50G+8x100G.config.bcm" #} +l3_alpm_hit_skip=1 +sai_adjust_acl_drop_in_rx_drop=1 +{{ map_prio }} +PHY_AN_ALLOW_PLL_CHANGE=1 +arl_clean_timeout_usec=15000000 +asf_mem_profile=2 +bcm_num_cos=10 +bcm_stat_flags=1 +bcm_stat_jumbo=9236 +cdma_timeout_usec=15000000 +core_clock_frequency=1700 +dma_desc_timeout_usec=15000000 +dpp_clock_ratio=2:3 +higig2_hdr_mode=1 +ipv6_lpm_128b_enable=1 +l3_alpm_enable=2 +lpm_scaling_enable=0 +l2xmsg_mode=1 +max_vp_lags=0 +mem_scan_enable=1 +miim_intr_enable=0 +module_64ports=1 +os=unix +oversubscribe_mode=1 +pbmp_xport_xe=0xfffffffd3fffffff4fffffffc7ffffffe +#pbmp_xport_xe=0x47fffffff1fffffffcfffffffe7ffffffe +phy_an_allow_pll_change_hg=0 +phy_an_c73=1 +phy_chain_rx_lane_map_physical{1.0}=0x3210 +phy_chain_rx_lane_map_physical{101.0}=0x0123 +phy_chain_rx_lane_map_physical{105.0}=0x0123 +phy_chain_rx_lane_map_physical{109.0}=0x0123 +phy_chain_rx_lane_map_physical{113.0}=0x2301 +phy_chain_rx_lane_map_physical{117.0}=0x3210 +phy_chain_rx_lane_map_physical{121.0}=0x3210 +phy_chain_rx_lane_map_physical{125.0}=0x1203 +phy_chain_rx_lane_map_physical{129.0}=0x3210 +phy_chain_rx_lane_map_physical{13.0}=0x0321 +phy_chain_rx_lane_map_physical{133.0}=0x1032 +phy_chain_rx_lane_map_physical{137.0}=0x3210 +phy_chain_rx_lane_map_physical{141.0}=0x0123 +phy_chain_rx_lane_map_physical{145.0}=0x3210 +phy_chain_rx_lane_map_physical{149.0}=0x2310 +phy_chain_rx_lane_map_physical{153.0}=0x0132 +phy_chain_rx_lane_map_physical{157.0}=0x1302 +phy_chain_rx_lane_map_physical{161.0}=0x3021 +phy_chain_rx_lane_map_physical{165.0}=0x2031 +phy_chain_rx_lane_map_physical{169.0}=0x2031 +phy_chain_rx_lane_map_physical{17.0}=0x3210 +phy_chain_rx_lane_map_physical{173.0}=0x1302 +phy_chain_rx_lane_map_physical{177.0}=0x2031 +phy_chain_rx_lane_map_physical{181.0}=0x0213 +phy_chain_rx_lane_map_physical{185.0}=0x0213 +phy_chain_rx_lane_map_physical{189.0}=0x1302 +phy_chain_rx_lane_map_physical{193.0}=0x3120 +phy_chain_rx_lane_map_physical{197.0}=0x0231 +phy_chain_rx_lane_map_physical{201.0}=0x2031 +phy_chain_rx_lane_map_physical{205.0}=0x0213 +phy_chain_rx_lane_map_physical{209.0}=0x2013 +phy_chain_rx_lane_map_physical{21.0}=0x3021 +phy_chain_rx_lane_map_physical{213.0}=0x3021 +phy_chain_rx_lane_map_physical{217.0}=0x0231 +phy_chain_rx_lane_map_physical{221.0}=0x2031 +phy_chain_rx_lane_map_physical{225.0}=0x1203 +phy_chain_rx_lane_map_physical{229.0}=0x1230 +phy_chain_rx_lane_map_physical{233.0}=0x3021 +phy_chain_rx_lane_map_physical{237.0}=0x1032 +phy_chain_rx_lane_map_physical{241.0}=0x2301 +phy_chain_rx_lane_map_physical{245.0}=0x0321 +phy_chain_rx_lane_map_physical{249.0}=0x2301 +phy_chain_rx_lane_map_physical{25.0}=0x2301 +phy_chain_rx_lane_map_physical{253.0}=0x2301 +phy_chain_rx_lane_map_physical{257.0}=0x3210 +phy_chain_rx_lane_map_physical{29.0}=0x3021 +phy_chain_rx_lane_map_physical{33.0}=0x1302 +phy_chain_rx_lane_map_physical{37.0}=0x2031 +phy_chain_rx_lane_map_physical{41.0}=0x3021 +phy_chain_rx_lane_map_physical{45.0}=0x1023 +phy_chain_rx_lane_map_physical{49.0}=0x0213 +phy_chain_rx_lane_map_physical{5.0}=0x3201 +phy_chain_rx_lane_map_physical{53.0}=0x3201 +phy_chain_rx_lane_map_physical{57.0}=0x2013 +phy_chain_rx_lane_map_physical{61.0}=0x0213 +phy_chain_rx_lane_map_physical{65.0}=0x1203 +phy_chain_rx_lane_map_physical{69.0}=0x0213 +phy_chain_rx_lane_map_physical{73.0}=0x0213 +phy_chain_rx_lane_map_physical{77.0}=0x3120 +phy_chain_rx_lane_map_physical{81.0}=0x0213 +phy_chain_rx_lane_map_physical{85.0}=0x2031 +phy_chain_rx_lane_map_physical{89.0}=0x2031 +phy_chain_rx_lane_map_physical{9.0}=0x0321 +phy_chain_rx_lane_map_physical{93.0}=0x3120 +phy_chain_rx_lane_map_physical{97.0}=0x1203 +phy_chain_rx_polarity_flip_physical{1.0}=0x1 +phy_chain_rx_polarity_flip_physical{10.0}=0x0 +phy_chain_rx_polarity_flip_physical{100.0}=0x1 +phy_chain_rx_polarity_flip_physical{101.0}=0x1 +phy_chain_rx_polarity_flip_physical{102.0}=0x0 +phy_chain_rx_polarity_flip_physical{103.0}=0x1 +phy_chain_rx_polarity_flip_physical{104.0}=0x0 +phy_chain_rx_polarity_flip_physical{105.0}=0x1 +phy_chain_rx_polarity_flip_physical{106.0}=0x0 +phy_chain_rx_polarity_flip_physical{107.0}=0x1 +phy_chain_rx_polarity_flip_physical{108.0}=0x0 +phy_chain_rx_polarity_flip_physical{109.0}=0x0 +phy_chain_rx_polarity_flip_physical{11.0}=0x1 +phy_chain_rx_polarity_flip_physical{110.0}=0x1 +phy_chain_rx_polarity_flip_physical{111.0}=0x0 +phy_chain_rx_polarity_flip_physical{112.0}=0x1 +phy_chain_rx_polarity_flip_physical{113.0}=0x1 +phy_chain_rx_polarity_flip_physical{114.0}=0x0 +phy_chain_rx_polarity_flip_physical{115.0}=0x1 +phy_chain_rx_polarity_flip_physical{116.0}=0x0 +phy_chain_rx_polarity_flip_physical{117.0}=0x0 +phy_chain_rx_polarity_flip_physical{118.0}=0x0 +phy_chain_rx_polarity_flip_physical{119.0}=0x1 +phy_chain_rx_polarity_flip_physical{12.0}=0x1 +phy_chain_rx_polarity_flip_physical{120.0}=0x0 +phy_chain_rx_polarity_flip_physical{121.0}=0x1 +phy_chain_rx_polarity_flip_physical{122.0}=0x0 +phy_chain_rx_polarity_flip_physical{123.0}=0x1 +phy_chain_rx_polarity_flip_physical{124.0}=0x0 +phy_chain_rx_polarity_flip_physical{125.0}=0x0 +phy_chain_rx_polarity_flip_physical{126.0}=0x1 +phy_chain_rx_polarity_flip_physical{127.0}=0x1 +phy_chain_rx_polarity_flip_physical{128.0}=0x1 +phy_chain_rx_polarity_flip_physical{129.0}=0x0 +phy_chain_rx_polarity_flip_physical{13.0}=0x1 +phy_chain_rx_polarity_flip_physical{130.0}=0x1 +phy_chain_rx_polarity_flip_physical{131.0}=0x1 +phy_chain_rx_polarity_flip_physical{132.0}=0x0 +phy_chain_rx_polarity_flip_physical{133.0}=0x1 +phy_chain_rx_polarity_flip_physical{134.0}=0x1 +phy_chain_rx_polarity_flip_physical{135.0}=0x1 +phy_chain_rx_polarity_flip_physical{136.0}=0x0 +phy_chain_rx_polarity_flip_physical{137.0}=0x0 +phy_chain_rx_polarity_flip_physical{138.0}=0x0 +phy_chain_rx_polarity_flip_physical{139.0}=0x1 +phy_chain_rx_polarity_flip_physical{14.0}=0x0 +phy_chain_rx_polarity_flip_physical{140.0}=0x0 +phy_chain_rx_polarity_flip_physical{141.0}=0x1 +phy_chain_rx_polarity_flip_physical{142.0}=0x0 +phy_chain_rx_polarity_flip_physical{143.0}=0x1 +phy_chain_rx_polarity_flip_physical{144.0}=0x0 +phy_chain_rx_polarity_flip_physical{145.0}=0x1 +phy_chain_rx_polarity_flip_physical{146.0}=0x0 +phy_chain_rx_polarity_flip_physical{147.0}=0x1 +phy_chain_rx_polarity_flip_physical{148.0}=0x0 +phy_chain_rx_polarity_flip_physical{149.0}=0x0 +phy_chain_rx_polarity_flip_physical{15.0}=0x1 +phy_chain_rx_polarity_flip_physical{150.0}=0x1 +phy_chain_rx_polarity_flip_physical{151.0}=0x1 +phy_chain_rx_polarity_flip_physical{152.0}=0x0 +phy_chain_rx_polarity_flip_physical{153.0}=0x0 +phy_chain_rx_polarity_flip_physical{154.0}=0x1 +phy_chain_rx_polarity_flip_physical{155.0}=0x1 +phy_chain_rx_polarity_flip_physical{156.0}=0x0 +phy_chain_rx_polarity_flip_physical{157.0}=0x0 +phy_chain_rx_polarity_flip_physical{158.0}=0x0 +phy_chain_rx_polarity_flip_physical{159.0}=0x1 +phy_chain_rx_polarity_flip_physical{16.0}=0x0 +phy_chain_rx_polarity_flip_physical{160.0}=0x0 +phy_chain_rx_polarity_flip_physical{161.0}=0x1 +phy_chain_rx_polarity_flip_physical{162.0}=0x1 +phy_chain_rx_polarity_flip_physical{163.0}=0x0 +phy_chain_rx_polarity_flip_physical{164.0}=0x1 +phy_chain_rx_polarity_flip_physical{165.0}=0x0 +phy_chain_rx_polarity_flip_physical{166.0}=0x0 +phy_chain_rx_polarity_flip_physical{167.0}=0x1 +phy_chain_rx_polarity_flip_physical{168.0}=0x1 +phy_chain_rx_polarity_flip_physical{169.0}=0x1 +phy_chain_rx_polarity_flip_physical{17.0}=0x1 +phy_chain_rx_polarity_flip_physical{170.0}=0x1 +phy_chain_rx_polarity_flip_physical{171.0}=0x0 +phy_chain_rx_polarity_flip_physical{172.0}=0x0 +phy_chain_rx_polarity_flip_physical{173.0}=0x0 +phy_chain_rx_polarity_flip_physical{174.0}=0x0 +phy_chain_rx_polarity_flip_physical{175.0}=0x1 +phy_chain_rx_polarity_flip_physical{176.0}=0x1 +phy_chain_rx_polarity_flip_physical{177.0}=0x1 +phy_chain_rx_polarity_flip_physical{178.0}=0x1 +phy_chain_rx_polarity_flip_physical{179.0}=0x0 +phy_chain_rx_polarity_flip_physical{18.0}=0x0 +phy_chain_rx_polarity_flip_physical{180.0}=0x0 +phy_chain_rx_polarity_flip_physical{181.0}=0x1 +phy_chain_rx_polarity_flip_physical{182.0}=0x1 +phy_chain_rx_polarity_flip_physical{183.0}=0x0 +phy_chain_rx_polarity_flip_physical{184.0}=0x0 +phy_chain_rx_polarity_flip_physical{185.0}=0x0 +phy_chain_rx_polarity_flip_physical{186.0}=0x0 +phy_chain_rx_polarity_flip_physical{187.0}=0x1 +phy_chain_rx_polarity_flip_physical{188.0}=0x1 +phy_chain_rx_polarity_flip_physical{189.0}=0x0 +phy_chain_rx_polarity_flip_physical{19.0}=0x1 +phy_chain_rx_polarity_flip_physical{190.0}=0x0 +phy_chain_rx_polarity_flip_physical{191.0}=0x1 +phy_chain_rx_polarity_flip_physical{192.0}=0x0 +phy_chain_rx_polarity_flip_physical{193.0}=0x0 +phy_chain_rx_polarity_flip_physical{194.0}=0x0 +phy_chain_rx_polarity_flip_physical{195.0}=0x1 +phy_chain_rx_polarity_flip_physical{196.0}=0x1 +phy_chain_rx_polarity_flip_physical{197.0}=0x1 +phy_chain_rx_polarity_flip_physical{198.0}=0x1 +phy_chain_rx_polarity_flip_physical{199.0}=0x0 +phy_chain_rx_polarity_flip_physical{2.0}=0x0 +phy_chain_rx_polarity_flip_physical{20.0}=0x0 +phy_chain_rx_polarity_flip_physical{200.0}=0x0 +phy_chain_rx_polarity_flip_physical{201.0}=0x0 +phy_chain_rx_polarity_flip_physical{202.0}=0x0 +phy_chain_rx_polarity_flip_physical{203.0}=0x1 +phy_chain_rx_polarity_flip_physical{204.0}=0x0 +phy_chain_rx_polarity_flip_physical{205.0}=0x1 +phy_chain_rx_polarity_flip_physical{206.0}=0x1 +phy_chain_rx_polarity_flip_physical{207.0}=0x0 +phy_chain_rx_polarity_flip_physical{208.0}=0x0 +phy_chain_rx_polarity_flip_physical{209.0}=0x1 +phy_chain_rx_polarity_flip_physical{21.0}=0x0 +phy_chain_rx_polarity_flip_physical{210.0}=0x1 +phy_chain_rx_polarity_flip_physical{211.0}=0x0 +phy_chain_rx_polarity_flip_physical{212.0}=0x0 +phy_chain_rx_polarity_flip_physical{213.0}=0x0 +phy_chain_rx_polarity_flip_physical{214.0}=0x0 +phy_chain_rx_polarity_flip_physical{215.0}=0x1 +phy_chain_rx_polarity_flip_physical{216.0}=0x0 +phy_chain_rx_polarity_flip_physical{217.0}=0x0 +phy_chain_rx_polarity_flip_physical{218.0}=0x0 +phy_chain_rx_polarity_flip_physical{219.0}=0x1 +phy_chain_rx_polarity_flip_physical{22.0}=0x0 +phy_chain_rx_polarity_flip_physical{220.0}=0x1 +phy_chain_rx_polarity_flip_physical{221.0}=0x0 +phy_chain_rx_polarity_flip_physical{222.0}=0x0 +phy_chain_rx_polarity_flip_physical{223.0}=0x1 +phy_chain_rx_polarity_flip_physical{224.0}=0x1 +phy_chain_rx_polarity_flip_physical{225.0}=0x1 +phy_chain_rx_polarity_flip_physical{226.0}=0x0 +phy_chain_rx_polarity_flip_physical{227.0}=0x0 +phy_chain_rx_polarity_flip_physical{228.0}=0x1 +phy_chain_rx_polarity_flip_physical{229.0}=0x0 +phy_chain_rx_polarity_flip_physical{23.0}=0x1 +phy_chain_rx_polarity_flip_physical{230.0}=0x0 +phy_chain_rx_polarity_flip_physical{231.0}=0x1 +phy_chain_rx_polarity_flip_physical{232.0}=0x1 +phy_chain_rx_polarity_flip_physical{233.0}=0x1 +phy_chain_rx_polarity_flip_physical{234.0}=0x0 +phy_chain_rx_polarity_flip_physical{235.0}=0x0 +phy_chain_rx_polarity_flip_physical{236.0}=0x0 +phy_chain_rx_polarity_flip_physical{237.0}=0x1 +phy_chain_rx_polarity_flip_physical{238.0}=0x0 +phy_chain_rx_polarity_flip_physical{239.0}=0x1 +phy_chain_rx_polarity_flip_physical{24.0}=0x0 +phy_chain_rx_polarity_flip_physical{240.0}=0x0 +phy_chain_rx_polarity_flip_physical{241.0}=0x1 +phy_chain_rx_polarity_flip_physical{242.0}=0x0 +phy_chain_rx_polarity_flip_physical{243.0}=0x1 +phy_chain_rx_polarity_flip_physical{244.0}=0x0 +phy_chain_rx_polarity_flip_physical{245.0}=0x1 +phy_chain_rx_polarity_flip_physical{246.0}=0x1 +phy_chain_rx_polarity_flip_physical{247.0}=0x1 +phy_chain_rx_polarity_flip_physical{248.0}=0x0 +phy_chain_rx_polarity_flip_physical{249.0}=0x0 +phy_chain_rx_polarity_flip_physical{25.0}=0x1 +phy_chain_rx_polarity_flip_physical{250.0}=0x1 +phy_chain_rx_polarity_flip_physical{251.0}=0x0 +phy_chain_rx_polarity_flip_physical{252.0}=0x1 +phy_chain_rx_polarity_flip_physical{253.0}=0x1 +phy_chain_rx_polarity_flip_physical{254.0}=0x0 +phy_chain_rx_polarity_flip_physical{255.0}=0x1 +phy_chain_rx_polarity_flip_physical{256.0}=0x0 +phy_chain_rx_polarity_flip_physical{257.0}=0x0 +phy_chain_rx_polarity_flip_physical{259.0}=0x0 +phy_chain_rx_polarity_flip_physical{26.0}=0x0 +phy_chain_rx_polarity_flip_physical{27.0}=0x1 +phy_chain_rx_polarity_flip_physical{28.0}=0x0 +phy_chain_rx_polarity_flip_physical{29.0}=0x0 +phy_chain_rx_polarity_flip_physical{3.0}=0x1 +phy_chain_rx_polarity_flip_physical{30.0}=0x0 +phy_chain_rx_polarity_flip_physical{31.0}=0x0 +phy_chain_rx_polarity_flip_physical{32.0}=0x1 +phy_chain_rx_polarity_flip_physical{33.0}=0x0 +phy_chain_rx_polarity_flip_physical{34.0}=0x0 +phy_chain_rx_polarity_flip_physical{35.0}=0x1 +phy_chain_rx_polarity_flip_physical{36.0}=0x1 +phy_chain_rx_polarity_flip_physical{37.0}=0x1 +phy_chain_rx_polarity_flip_physical{38.0}=0x1 +phy_chain_rx_polarity_flip_physical{39.0}=0x0 +phy_chain_rx_polarity_flip_physical{4.0}=0x0 +phy_chain_rx_polarity_flip_physical{40.0}=0x0 +phy_chain_rx_polarity_flip_physical{41.0}=0x0 +phy_chain_rx_polarity_flip_physical{42.0}=0x1 +phy_chain_rx_polarity_flip_physical{43.0}=0x1 +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}=0x1 +phy_chain_rx_polarity_flip_physical{5.0}=0x1 +phy_chain_rx_polarity_flip_physical{50.0}=0x1 +phy_chain_rx_polarity_flip_physical{51.0}=0x0 +phy_chain_rx_polarity_flip_physical{52.0}=0x0 +phy_chain_rx_polarity_flip_physical{53.0}=0x0 +phy_chain_rx_polarity_flip_physical{54.0}=0x0 +phy_chain_rx_polarity_flip_physical{55.0}=0x1 +phy_chain_rx_polarity_flip_physical{56.0}=0x0 +phy_chain_rx_polarity_flip_physical{57.0}=0x0 +phy_chain_rx_polarity_flip_physical{58.0}=0x0 +phy_chain_rx_polarity_flip_physical{59.0}=0x1 +phy_chain_rx_polarity_flip_physical{6.0}=0x0 +phy_chain_rx_polarity_flip_physical{60.0}=0x1 +phy_chain_rx_polarity_flip_physical{61.0}=0x0 +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}=0x1 +phy_chain_rx_polarity_flip_physical{65.0}=0x1 +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{7.0}=0x0 +phy_chain_rx_polarity_flip_physical{70.0}=0x0 +phy_chain_rx_polarity_flip_physical{71.0}=0x1 +phy_chain_rx_polarity_flip_physical{72.0}=0x1 +phy_chain_rx_polarity_flip_physical{73.0}=0x1 +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}=0x0 +phy_chain_rx_polarity_flip_physical{77.0}=0x0 +phy_chain_rx_polarity_flip_physical{78.0}=0x0 +phy_chain_rx_polarity_flip_physical{79.0}=0x1 +phy_chain_rx_polarity_flip_physical{8.0}=0x1 +phy_chain_rx_polarity_flip_physical{80.0}=0x1 +phy_chain_rx_polarity_flip_physical{81.0}=0x1 +phy_chain_rx_polarity_flip_physical{82.0}=0x1 +phy_chain_rx_polarity_flip_physical{83.0}=0x0 +phy_chain_rx_polarity_flip_physical{84.0}=0x0 +phy_chain_rx_polarity_flip_physical{85.0}=0x1 +phy_chain_rx_polarity_flip_physical{86.0}=0x1 +phy_chain_rx_polarity_flip_physical{87.0}=0x0 +phy_chain_rx_polarity_flip_physical{88.0}=0x0 +phy_chain_rx_polarity_flip_physical{89.0}=0x0 +phy_chain_rx_polarity_flip_physical{9.0}=0x1 +phy_chain_rx_polarity_flip_physical{90.0}=0x0 +phy_chain_rx_polarity_flip_physical{91.0}=0x1 +phy_chain_rx_polarity_flip_physical{92.0}=0x1 +phy_chain_rx_polarity_flip_physical{93.0}=0x0 +phy_chain_rx_polarity_flip_physical{94.0}=0x0 +phy_chain_rx_polarity_flip_physical{95.0}=0x1 +phy_chain_rx_polarity_flip_physical{96.0}=0x0 +phy_chain_rx_polarity_flip_physical{97.0}=0x1 +phy_chain_rx_polarity_flip_physical{98.0}=0x1 +phy_chain_rx_polarity_flip_physical{99.0}=0x0 +phy_chain_tx_lane_map_physical{1.0}=0x2031 +phy_chain_tx_lane_map_physical{101.0}=0x1023 +phy_chain_tx_lane_map_physical{105.0}=0x1302 +phy_chain_tx_lane_map_physical{109.0}=0x0321 +phy_chain_tx_lane_map_physical{113.0}=0x2301 +phy_chain_tx_lane_map_physical{117.0}=0x3120 +phy_chain_tx_lane_map_physical{121.0}=0x3102 +phy_chain_tx_lane_map_physical{125.0}=0x3210 +phy_chain_tx_lane_map_physical{129.0}=0x1023 +phy_chain_tx_lane_map_physical{13.0}=0x3021 +phy_chain_tx_lane_map_physical{133.0}=0x3210 +phy_chain_tx_lane_map_physical{137.0}=0x2031 +phy_chain_tx_lane_map_physical{141.0}=0x1302 +phy_chain_tx_lane_map_physical{145.0}=0x3210 +phy_chain_tx_lane_map_physical{149.0}=0x0213 +phy_chain_tx_lane_map_physical{153.0}=0x3210 +phy_chain_tx_lane_map_physical{157.0}=0x1320 +phy_chain_tx_lane_map_physical{161.0}=0x3210 +phy_chain_tx_lane_map_physical{165.0}=0x0231 +phy_chain_tx_lane_map_physical{169.0}=0x3120 +phy_chain_tx_lane_map_physical{17.0}=0x1032 +phy_chain_tx_lane_map_physical{173.0}=0x0312 +phy_chain_tx_lane_map_physical{177.0}=0x0231 +phy_chain_tx_lane_map_physical{181.0}=0x3210 +phy_chain_tx_lane_map_physical{185.0}=0x3210 +phy_chain_tx_lane_map_physical{189.0}=0x1320 +phy_chain_tx_lane_map_physical{193.0}=0x0321 +phy_chain_tx_lane_map_physical{197.0}=0x3120 +phy_chain_tx_lane_map_physical{201.0}=0x3120 +phy_chain_tx_lane_map_physical{205.0}=0x0123 +phy_chain_tx_lane_map_physical{209.0}=0x3120 +phy_chain_tx_lane_map_physical{21.0}=0x0213 +phy_chain_tx_lane_map_physical{213.0}=0x3021 +phy_chain_tx_lane_map_physical{217.0}=0x0312 +phy_chain_tx_lane_map_physical{221.0}=0x2301 +phy_chain_tx_lane_map_physical{225.0}=0x0123 +phy_chain_tx_lane_map_physical{229.0}=0x2031 +phy_chain_tx_lane_map_physical{233.0}=0x0231 +phy_chain_tx_lane_map_physical{237.0}=0x0213 +phy_chain_tx_lane_map_physical{241.0}=0x1320 +phy_chain_tx_lane_map_physical{245.0}=0x2031 +phy_chain_tx_lane_map_physical{249.0}=0x3120 +phy_chain_tx_lane_map_physical{25.0}=0x0231 +phy_chain_tx_lane_map_physical{253.0}=0x0321 +phy_chain_tx_lane_map_physical{257.0}=0x3210 +phy_chain_tx_lane_map_physical{29.0}=0x1230 +phy_chain_tx_lane_map_physical{33.0}=0x1032 +phy_chain_tx_lane_map_physical{37.0}=0x0123 +phy_chain_tx_lane_map_physical{41.0}=0x0213 +phy_chain_tx_lane_map_physical{45.0}=0x0132 +phy_chain_tx_lane_map_physical{49.0}=0x2031 +phy_chain_tx_lane_map_physical{5.0}=0x2301 +phy_chain_tx_lane_map_physical{53.0}=0x2301 +phy_chain_tx_lane_map_physical{57.0}=0x2031 +phy_chain_tx_lane_map_physical{61.0}=0x2031 +phy_chain_tx_lane_map_physical{65.0}=0x1230 +phy_chain_tx_lane_map_physical{69.0}=0x2013 +phy_chain_tx_lane_map_physical{73.0}=0x0213 +phy_chain_tx_lane_map_physical{77.0}=0x2310 +phy_chain_tx_lane_map_physical{81.0}=0x0321 +phy_chain_tx_lane_map_physical{85.0}=0x2013 +phy_chain_tx_lane_map_physical{89.0}=0x0213 +phy_chain_tx_lane_map_physical{9.0}=0x3012 +phy_chain_tx_lane_map_physical{93.0}=0x3102 +phy_chain_tx_lane_map_physical{97.0}=0x3210 +phy_chain_tx_polarity_flip_physical{1.0}=0x0 +phy_chain_tx_polarity_flip_physical{10.0}=0x1 +phy_chain_tx_polarity_flip_physical{100.0}=0x0 +phy_chain_tx_polarity_flip_physical{101.0}=0x0 +phy_chain_tx_polarity_flip_physical{102.0}=0x1 +phy_chain_tx_polarity_flip_physical{103.0}=0x0 +phy_chain_tx_polarity_flip_physical{104.0}=0x0 +phy_chain_tx_polarity_flip_physical{105.0}=0x0 +phy_chain_tx_polarity_flip_physical{106.0}=0x1 +phy_chain_tx_polarity_flip_physical{107.0}=0x1 +phy_chain_tx_polarity_flip_physical{108.0}=0x1 +phy_chain_tx_polarity_flip_physical{109.0}=0x0 +phy_chain_tx_polarity_flip_physical{11.0}=0x1 +phy_chain_tx_polarity_flip_physical{110.0}=0x0 +phy_chain_tx_polarity_flip_physical{111.0}=0x0 +phy_chain_tx_polarity_flip_physical{112.0}=0x1 +phy_chain_tx_polarity_flip_physical{113.0}=0x1 +phy_chain_tx_polarity_flip_physical{114.0}=0x1 +phy_chain_tx_polarity_flip_physical{115.0}=0x1 +phy_chain_tx_polarity_flip_physical{116.0}=0x0 +phy_chain_tx_polarity_flip_physical{117.0}=0x1 +phy_chain_tx_polarity_flip_physical{118.0}=0x0 +phy_chain_tx_polarity_flip_physical{119.0}=0x0 +phy_chain_tx_polarity_flip_physical{12.0}=0x0 +phy_chain_tx_polarity_flip_physical{120.0}=0x0 +phy_chain_tx_polarity_flip_physical{121.0}=0x0 +phy_chain_tx_polarity_flip_physical{122.0}=0x0 +phy_chain_tx_polarity_flip_physical{123.0}=0x0 +phy_chain_tx_polarity_flip_physical{124.0}=0x1 +phy_chain_tx_polarity_flip_physical{125.0}=0x0 +phy_chain_tx_polarity_flip_physical{126.0}=0x1 +phy_chain_tx_polarity_flip_physical{127.0}=0x1 +phy_chain_tx_polarity_flip_physical{128.0}=0x1 +phy_chain_tx_polarity_flip_physical{129.0}=0x1 +phy_chain_tx_polarity_flip_physical{13.0}=0x0 +phy_chain_tx_polarity_flip_physical{130.0}=0x0 +phy_chain_tx_polarity_flip_physical{131.0}=0x1 +phy_chain_tx_polarity_flip_physical{132.0}=0x0 +phy_chain_tx_polarity_flip_physical{133.0}=0x1 +phy_chain_tx_polarity_flip_physical{134.0}=0x1 +phy_chain_tx_polarity_flip_physical{135.0}=0x1 +phy_chain_tx_polarity_flip_physical{136.0}=0x1 +phy_chain_tx_polarity_flip_physical{137.0}=0x1 +phy_chain_tx_polarity_flip_physical{138.0}=0x1 +phy_chain_tx_polarity_flip_physical{139.0}=0x1 +phy_chain_tx_polarity_flip_physical{14.0}=0x1 +phy_chain_tx_polarity_flip_physical{140.0}=0x1 +phy_chain_tx_polarity_flip_physical{141.0}=0x0 +phy_chain_tx_polarity_flip_physical{142.0}=0x1 +phy_chain_tx_polarity_flip_physical{143.0}=0x1 +phy_chain_tx_polarity_flip_physical{144.0}=0x1 +phy_chain_tx_polarity_flip_physical{145.0}=0x1 +phy_chain_tx_polarity_flip_physical{146.0}=0x1 +phy_chain_tx_polarity_flip_physical{147.0}=0x1 +phy_chain_tx_polarity_flip_physical{148.0}=0x0 +phy_chain_tx_polarity_flip_physical{149.0}=0x1 +phy_chain_tx_polarity_flip_physical{15.0}=0x0 +phy_chain_tx_polarity_flip_physical{150.0}=0x0 +phy_chain_tx_polarity_flip_physical{151.0}=0x0 +phy_chain_tx_polarity_flip_physical{152.0}=0x0 +phy_chain_tx_polarity_flip_physical{153.0}=0x1 +phy_chain_tx_polarity_flip_physical{154.0}=0x0 +phy_chain_tx_polarity_flip_physical{155.0}=0x0 +phy_chain_tx_polarity_flip_physical{156.0}=0x0 +phy_chain_tx_polarity_flip_physical{157.0}=0x0 +phy_chain_tx_polarity_flip_physical{158.0}=0x0 +phy_chain_tx_polarity_flip_physical{159.0}=0x0 +phy_chain_tx_polarity_flip_physical{16.0}=0x0 +phy_chain_tx_polarity_flip_physical{160.0}=0x0 +phy_chain_tx_polarity_flip_physical{161.0}=0x0 +phy_chain_tx_polarity_flip_physical{162.0}=0x1 +phy_chain_tx_polarity_flip_physical{163.0}=0x1 +phy_chain_tx_polarity_flip_physical{164.0}=0x0 +phy_chain_tx_polarity_flip_physical{165.0}=0x1 +phy_chain_tx_polarity_flip_physical{166.0}=0x1 +phy_chain_tx_polarity_flip_physical{167.0}=0x1 +phy_chain_tx_polarity_flip_physical{168.0}=0x0 +phy_chain_tx_polarity_flip_physical{169.0}=0x0 +phy_chain_tx_polarity_flip_physical{17.0}=0x0 +phy_chain_tx_polarity_flip_physical{170.0}=0x1 +phy_chain_tx_polarity_flip_physical{171.0}=0x1 +phy_chain_tx_polarity_flip_physical{172.0}=0x1 +phy_chain_tx_polarity_flip_physical{173.0}=0x0 +phy_chain_tx_polarity_flip_physical{174.0}=0x0 +phy_chain_tx_polarity_flip_physical{175.0}=0x1 +phy_chain_tx_polarity_flip_physical{176.0}=0x0 +phy_chain_tx_polarity_flip_physical{177.0}=0x1 +phy_chain_tx_polarity_flip_physical{178.0}=0x0 +phy_chain_tx_polarity_flip_physical{179.0}=0x0 +phy_chain_tx_polarity_flip_physical{18.0}=0x1 +phy_chain_tx_polarity_flip_physical{180.0}=0x0 +phy_chain_tx_polarity_flip_physical{181.0}=0x0 +phy_chain_tx_polarity_flip_physical{182.0}=0x0 +phy_chain_tx_polarity_flip_physical{183.0}=0x0 +phy_chain_tx_polarity_flip_physical{184.0}=0x1 +phy_chain_tx_polarity_flip_physical{185.0}=0x0 +phy_chain_tx_polarity_flip_physical{186.0}=0x1 +phy_chain_tx_polarity_flip_physical{187.0}=0x1 +phy_chain_tx_polarity_flip_physical{188.0}=0x1 +phy_chain_tx_polarity_flip_physical{189.0}=0x0 +phy_chain_tx_polarity_flip_physical{19.0}=0x1 +phy_chain_tx_polarity_flip_physical{190.0}=0x0 +phy_chain_tx_polarity_flip_physical{191.0}=0x0 +phy_chain_tx_polarity_flip_physical{192.0}=0x0 +phy_chain_tx_polarity_flip_physical{193.0}=0x1 +phy_chain_tx_polarity_flip_physical{194.0}=0x1 +phy_chain_tx_polarity_flip_physical{195.0}=0x1 +phy_chain_tx_polarity_flip_physical{196.0}=0x0 +phy_chain_tx_polarity_flip_physical{197.0}=0x0 +phy_chain_tx_polarity_flip_physical{198.0}=0x1 +phy_chain_tx_polarity_flip_physical{199.0}=0x1 +phy_chain_tx_polarity_flip_physical{2.0}=0x1 +phy_chain_tx_polarity_flip_physical{20.0}=0x1 +phy_chain_tx_polarity_flip_physical{200.0}=0x1 +phy_chain_tx_polarity_flip_physical{201.0}=0x1 +phy_chain_tx_polarity_flip_physical{202.0}=0x1 +phy_chain_tx_polarity_flip_physical{203.0}=0x1 +phy_chain_tx_polarity_flip_physical{204.0}=0x1 +phy_chain_tx_polarity_flip_physical{205.0}=0x0 +phy_chain_tx_polarity_flip_physical{206.0}=0x1 +phy_chain_tx_polarity_flip_physical{207.0}=0x1 +phy_chain_tx_polarity_flip_physical{208.0}=0x1 +phy_chain_tx_polarity_flip_physical{209.0}=0x1 +phy_chain_tx_polarity_flip_physical{21.0}=0x0 +phy_chain_tx_polarity_flip_physical{210.0}=0x1 +phy_chain_tx_polarity_flip_physical{211.0}=0x1 +phy_chain_tx_polarity_flip_physical{212.0}=0x0 +phy_chain_tx_polarity_flip_physical{213.0}=0x0 +phy_chain_tx_polarity_flip_physical{214.0}=0x1 +phy_chain_tx_polarity_flip_physical{215.0}=0x0 +phy_chain_tx_polarity_flip_physical{216.0}=0x1 +phy_chain_tx_polarity_flip_physical{217.0}=0x1 +phy_chain_tx_polarity_flip_physical{218.0}=0x1 +phy_chain_tx_polarity_flip_physical{219.0}=0x0 +phy_chain_tx_polarity_flip_physical{22.0}=0x0 +phy_chain_tx_polarity_flip_physical{220.0}=0x1 +phy_chain_tx_polarity_flip_physical{221.0}=0x0 +phy_chain_tx_polarity_flip_physical{222.0}=0x0 +phy_chain_tx_polarity_flip_physical{223.0}=0x0 +phy_chain_tx_polarity_flip_physical{224.0}=0x1 +phy_chain_tx_polarity_flip_physical{225.0}=0x1 +phy_chain_tx_polarity_flip_physical{226.0}=0x1 +phy_chain_tx_polarity_flip_physical{227.0}=0x1 +phy_chain_tx_polarity_flip_physical{228.0}=0x0 +phy_chain_tx_polarity_flip_physical{229.0}=0x0 +phy_chain_tx_polarity_flip_physical{23.0}=0x0 +phy_chain_tx_polarity_flip_physical{230.0}=0x1 +phy_chain_tx_polarity_flip_physical{231.0}=0x1 +phy_chain_tx_polarity_flip_physical{232.0}=0x1 +phy_chain_tx_polarity_flip_physical{233.0}=0x0 +phy_chain_tx_polarity_flip_physical{234.0}=0x0 +phy_chain_tx_polarity_flip_physical{235.0}=0x0 +phy_chain_tx_polarity_flip_physical{236.0}=0x0 +phy_chain_tx_polarity_flip_physical{237.0}=0x1 +phy_chain_tx_polarity_flip_physical{238.0}=0x1 +phy_chain_tx_polarity_flip_physical{239.0}=0x1 +phy_chain_tx_polarity_flip_physical{24.0}=0x0 +phy_chain_tx_polarity_flip_physical{240.0}=0x0 +phy_chain_tx_polarity_flip_physical{241.0}=0x1 +phy_chain_tx_polarity_flip_physical{242.0}=0x1 +phy_chain_tx_polarity_flip_physical{243.0}=0x1 +phy_chain_tx_polarity_flip_physical{244.0}=0x0 +phy_chain_tx_polarity_flip_physical{245.0}=0x1 +phy_chain_tx_polarity_flip_physical{246.0}=0x1 +phy_chain_tx_polarity_flip_physical{247.0}=0x1 +phy_chain_tx_polarity_flip_physical{248.0}=0x1 +phy_chain_tx_polarity_flip_physical{249.0}=0x1 +phy_chain_tx_polarity_flip_physical{25.0}=0x1 +phy_chain_tx_polarity_flip_physical{250.0}=0x0 +phy_chain_tx_polarity_flip_physical{251.0}=0x0 +phy_chain_tx_polarity_flip_physical{252.0}=0x0 +phy_chain_tx_polarity_flip_physical{253.0}=0x1 +phy_chain_tx_polarity_flip_physical{254.0}=0x1 +phy_chain_tx_polarity_flip_physical{255.0}=0x1 +phy_chain_tx_polarity_flip_physical{256.0}=0x0 +phy_chain_tx_polarity_flip_physical{257.0}=0x0 +phy_chain_tx_polarity_flip_physical{259.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}=0x1 +phy_chain_tx_polarity_flip_physical{3.0}=0x1 +phy_chain_tx_polarity_flip_physical{30.0}=0x1 +phy_chain_tx_polarity_flip_physical{31.0}=0x1 +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}=0x1 +phy_chain_tx_polarity_flip_physical{37.0}=0x1 +phy_chain_tx_polarity_flip_physical{38.0}=0x1 +phy_chain_tx_polarity_flip_physical{39.0}=0x1 +phy_chain_tx_polarity_flip_physical{4.0}=0x1 +phy_chain_tx_polarity_flip_physical{40.0}=0x0 +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}=0x1 +phy_chain_tx_polarity_flip_physical{46.0}=0x0 +phy_chain_tx_polarity_flip_physical{47.0}=0x1 +phy_chain_tx_polarity_flip_physical{48.0}=0x1 +phy_chain_tx_polarity_flip_physical{49.0}=0x0 +phy_chain_tx_polarity_flip_physical{5.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}=0x1 +phy_chain_tx_polarity_flip_physical{53.0}=0x0 +phy_chain_tx_polarity_flip_physical{54.0}=0x1 +phy_chain_tx_polarity_flip_physical{55.0}=0x1 +phy_chain_tx_polarity_flip_physical{56.0}=0x0 +phy_chain_tx_polarity_flip_physical{57.0}=0x0 +phy_chain_tx_polarity_flip_physical{58.0}=0x1 +phy_chain_tx_polarity_flip_physical{59.0}=0x1 +phy_chain_tx_polarity_flip_physical{6.0}=0x1 +phy_chain_tx_polarity_flip_physical{60.0}=0x1 +phy_chain_tx_polarity_flip_physical{61.0}=0x0 +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}=0x1 +phy_chain_tx_polarity_flip_physical{65.0}=0x0 +phy_chain_tx_polarity_flip_physical{66.0}=0x1 +phy_chain_tx_polarity_flip_physical{67.0}=0x1 +phy_chain_tx_polarity_flip_physical{68.0}=0x0 +phy_chain_tx_polarity_flip_physical{69.0}=0x1 +phy_chain_tx_polarity_flip_physical{7.0}=0x1 +phy_chain_tx_polarity_flip_physical{70.0}=0x1 +phy_chain_tx_polarity_flip_physical{71.0}=0x1 +phy_chain_tx_polarity_flip_physical{72.0}=0x0 +phy_chain_tx_polarity_flip_physical{73.0}=0x1 +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}=0x1 +phy_chain_tx_polarity_flip_physical{8.0}=0x0 +phy_chain_tx_polarity_flip_physical{80.0}=0x0 +phy_chain_tx_polarity_flip_physical{81.0}=0x1 +phy_chain_tx_polarity_flip_physical{82.0}=0x1 +phy_chain_tx_polarity_flip_physical{83.0}=0x1 +phy_chain_tx_polarity_flip_physical{84.0}=0x0 +phy_chain_tx_polarity_flip_physical{85.0}=0x1 +phy_chain_tx_polarity_flip_physical{86.0}=0x0 +phy_chain_tx_polarity_flip_physical{87.0}=0x0 +phy_chain_tx_polarity_flip_physical{88.0}=0x0 +phy_chain_tx_polarity_flip_physical{89.0}=0x1 +phy_chain_tx_polarity_flip_physical{9.0}=0x0 +phy_chain_tx_polarity_flip_physical{90.0}=0x1 +phy_chain_tx_polarity_flip_physical{91.0}=0x1 +phy_chain_tx_polarity_flip_physical{92.0}=0x0 +phy_chain_tx_polarity_flip_physical{93.0}=0x0 +phy_chain_tx_polarity_flip_physical{94.0}=0x0 +phy_chain_tx_polarity_flip_physical{95.0}=0x0 +phy_chain_tx_polarity_flip_physical{96.0}=0x0 +phy_chain_tx_polarity_flip_physical{97.0}=0x0 +phy_chain_tx_polarity_flip_physical{98.0}=0x1 +phy_chain_tx_polarity_flip_physical{99.0}=0x1 + +port_init_cl72_hg=1 + + + + + + + +robust_hash_disable_egress_vlan=1 +robust_hash_disable_mpls=1 +robust_hash_disable_vlan=1 +stable_size=0x5500000 +stable_size=0x5500000 +tdma_timeout_usec=15000000 +tslam_timeout_usec=15000000 +dport_map_direct=1 +portmap_1=5:50 +portmap_2=7:50 +portmap_3=13:50 +portmap_4=15:50 +portmap_5=25:50 +portmap_6=27:50 +portmap_7=21:50 +portmap_8=23:50 +portmap_9=37:50 +portmap_10=39:50 +portmap_11=45:50 +portmap_12=47:50 +portmap_13=57:100 +portmap_14=53:100 +portmap_15=9:50 +portmap_16=11:50 +portmap_17=1:50 +portmap_18=3:50 +portmap_19=17:50 +portmap_20=19:50 +portmap_21=29:50 +portmap_22=31:50 +portmap_23=41:50 +portmap_24=43:50 +portmap_25=33:50 +portmap_26=35:50 +portmap_27=49:50 +portmap_28=51:50 +portmap_29=61:50 +portmap_30=63:50 +portmap_34=77:100 +portmap_35=65:100 +portmap_38=85:50 +portmap_39=87:50 +portmap_40=89:50 +portmap_41=91:50 +portmap_42=109:50 +portmap_43=111:50 +portmap_44=97:50 +portmap_45=99:50 +portmap_46=117:100 +portmap_47=121:100 +portmap_48=69:50 +portmap_49=71:50 +portmap_50=73:50 +portmap_51=75:50 +portmap_52=93:50 +portmap_53=95:50 +portmap_54=81:50 +portmap_55=83:50 +portmap_56=101:50 +portmap_57=103:50 +portmap_58=105:50 +portmap_59=107:50 +portmap_60=125:50 +portmap_61=127:50 +portmap_62=113:50 +portmap_63=115:50 +portmap_66=257:10 +portmap_68=141:100 +portmap_69=133:100 +portmap_70=149:50 +portmap_71=151:50 +portmap_72=153:50 +portmap_73=155:50 +portmap_74=173:50 +portmap_75=175:50 +portmap_76=161:50 +portmap_77=163:50 +portmap_78=181:50 +portmap_79=183:50 +portmap_80=185:50 +portmap_81=187:50 +portmap_82=129:50 +portmap_83=131:50 +portmap_84=137:50 +portmap_85=139:50 +portmap_86=157:50 +portmap_87=159:50 +portmap_88=145:50 +portmap_89=147:50 +portmap_90=165:50 +portmap_91=167:50 +portmap_92=169:50 +portmap_93=171:50 +portmap_94=189:50 +portmap_95=191:50 +portmap_96=177:50 +portmap_97=179:50 +portmap_100=259:10 +portmap_102=197:100 +portmap_103=205:100 +portmap_104=217:50 +portmap_105=219:50 +portmap_106=213:50 +portmap_107=215:50 +portmap_108=229:50 +portmap_109=231:50 +portmap_110=237:50 +portmap_111=239:50 +portmap_112=249:50 +portmap_113=251:50 +portmap_114=245:50 +portmap_115=247:50 +portmap_116=201:50 +portmap_117=203:50 +portmap_118=193:50 +portmap_119=195:50 +portmap_120=209:50 +portmap_121=211:50 +portmap_122=221:50 +portmap_123=223:50 +portmap_124=233:50 +portmap_125=235:50 +portmap_126=225:50 +portmap_127=227:50 +portmap_128=241:50 +portmap_129=243:50 +portmap_130=253:50 +portmap_131=255:50 + +# tuning parameters +serdes_preemphasis_1=0x580c +serdes_preemphasis_2=0x580c +serdes_preemphasis_3=0x580c +serdes_preemphasis_4=0x580c +serdes_preemphasis_5=0x580c +serdes_preemphasis_6=0x580c +serdes_preemphasis_7=0x580c +serdes_preemphasis_8=0x580c +serdes_preemphasis_9=0x580c +serdes_preemphasis_10=0x580c +serdes_preemphasis_11=0x580c +serdes_preemphasis_12=0x580c +serdes_preemphasis_13=0x83404 +serdes_preemphasis_14=0x83404 +serdes_preemphasis_15=0x580c +serdes_preemphasis_16=0x580c +serdes_preemphasis_17=0x580c +serdes_preemphasis_18=0x580c +serdes_preemphasis_19=0x580c +serdes_preemphasis_20=0x580c +serdes_preemphasis_21=0x580c +serdes_preemphasis_22=0x580c +serdes_preemphasis_23=0x580c +serdes_preemphasis_24=0x580c +serdes_preemphasis_25=0x580c +serdes_preemphasis_26=0x580c +serdes_preemphasis_27=0x580c +serdes_preemphasis_28=0x580c +serdes_preemphasis_29=0x580c +serdes_preemphasis_30=0x580c +serdes_preemphasis_34=0xf3d05 +serdes_preemphasis_35=0xd3804 +serdes_preemphasis_38=0x580c +serdes_preemphasis_39=0x580c +serdes_preemphasis_40=0x580c +serdes_preemphasis_41=0x580c +serdes_preemphasis_42=0x580c +serdes_preemphasis_43=0x580c +serdes_preemphasis_44=0x580c +serdes_preemphasis_45=0x580c +serdes_preemphasis_46=0xb3604 +serdes_preemphasis_47=0x72b03 +serdes_preemphasis_48=0x580c +serdes_preemphasis_49=0x580c +serdes_preemphasis_50=0x580c +serdes_preemphasis_51=0x580c +serdes_preemphasis_52=0x580c +serdes_preemphasis_53=0x580c +serdes_preemphasis_54=0x580c +serdes_preemphasis_55=0x580c +serdes_preemphasis_56=0x580c +serdes_preemphasis_57=0x580c +serdes_preemphasis_58=0x580c +serdes_preemphasis_59=0x580c +serdes_preemphasis_60=0x580c +serdes_preemphasis_61=0x580c +serdes_preemphasis_62=0x580c +serdes_preemphasis_63=0x580c +serdes_preemphasis_66=0x43004 +serdes_preemphasis_68=0xf4006 +serdes_preemphasis_69=0xf4006 +serdes_preemphasis_70=0x580c +serdes_preemphasis_71=0x580c +serdes_preemphasis_72=0x580c +serdes_preemphasis_73=0x580c +serdes_preemphasis_74=0x580c +serdes_preemphasis_75=0x580c +serdes_preemphasis_76=0x580c +serdes_preemphasis_77=0x580c +serdes_preemphasis_78=0x580c +serdes_preemphasis_79=0x580c +serdes_preemphasis_80=0x580c +serdes_preemphasis_81=0x580c +serdes_preemphasis_82=0x580c +serdes_preemphasis_83=0x580c +serdes_preemphasis_84=0x580c +serdes_preemphasis_85=0x580c +serdes_preemphasis_86=0x580c +serdes_preemphasis_87=0x580c +serdes_preemphasis_88=0x580c +serdes_preemphasis_89=0x580c +serdes_preemphasis_90=0x580c +serdes_preemphasis_91=0x580c +serdes_preemphasis_92=0x580c +serdes_preemphasis_93=0x580c +serdes_preemphasis_94=0x580c +serdes_preemphasis_95=0x580c +serdes_preemphasis_96=0x580c +serdes_preemphasis_97=0x580c +serdes_preemphasis_100=0x43004 +serdes_preemphasis_102=0xf3c05 +serdes_preemphasis_103=0xf3c05 +serdes_preemphasis_104=0x580c +serdes_preemphasis_105=0x580c +serdes_preemphasis_106=0x580c +serdes_preemphasis_107=0x580c +serdes_preemphasis_108=0x580c +serdes_preemphasis_109=0x580c +serdes_preemphasis_110=0x580c +serdes_preemphasis_111=0x580c +serdes_preemphasis_112=0x580c +serdes_preemphasis_113=0x580c +serdes_preemphasis_114=0x580c +serdes_preemphasis_115=0x580c +serdes_preemphasis_116=0x580c +serdes_preemphasis_117=0x580c +serdes_preemphasis_118=0x580c +serdes_preemphasis_119=0x580c +serdes_preemphasis_120=0x580c +serdes_preemphasis_121=0x580c +serdes_preemphasis_122=0x580c +serdes_preemphasis_123=0x580c +serdes_preemphasis_124=0x580c +serdes_preemphasis_125=0x580c +serdes_preemphasis_126=0x580c +serdes_preemphasis_127=0x580c +serdes_preemphasis_128=0x580c +serdes_preemphasis_129=0x580c +serdes_preemphasis_130=0x580c +serdes_preemphasis_131=0x580c + +mmu_init_config="MSFT-TH2-Tier0" +{{ IPinIP_sock }} +phy_an_lt_msft=1 diff --git a/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C10/pg_profile_lookup.ini b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C10/pg_profile_lookup.ini new file mode 120000 index 000000000000..297cddb2d223 --- /dev/null +++ b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C10/pg_profile_lookup.ini @@ -0,0 +1 @@ +BALANCED/pg_profile_lookup.ini \ No newline at end of file diff --git a/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C10/port_config.ini b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C10/port_config.ini new file mode 100644 index 000000000000..1ea0f1d505a9 --- /dev/null +++ b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C10/port_config.ini @@ -0,0 +1,121 @@ +# name lanes alias index speed +Ethernet0 77,78,79,80 Ethernet1/1 1 100000 +Ethernet4 65,66,67,68 Ethernet2/1 2 100000 +Ethernet8 85,86 Ethernet3/1 3 50000 +Ethernet10 87,88 Ethernet3/3 3 50000 +Ethernet12 89,90 Ethernet4/1 4 50000 +Ethernet14 91,92 Ethernet4/3 4 50000 +Ethernet16 109,110 Ethernet5/1 5 50000 +Ethernet18 111,112 Ethernet5/3 5 50000 +Ethernet20 97,98 Ethernet6/1 6 50000 +Ethernet22 99,100 Ethernet6/3 6 50000 +Ethernet24 5,6 Ethernet7/1 7 50000 +Ethernet26 7,8 Ethernet7/3 7 50000 +Ethernet28 13,14 Ethernet8/1 8 50000 +Ethernet30 15,16 Ethernet8/3 8 50000 +Ethernet32 25,26 Ethernet9/1 9 50000 +Ethernet34 27,28 Ethernet9/3 9 50000 +Ethernet36 21,22 Ethernet10/1 10 50000 +Ethernet38 23,24 Ethernet10/3 10 50000 +Ethernet40 37,38 Ethernet11/1 11 50000 +Ethernet42 39,40 Ethernet11/3 11 50000 +Ethernet44 45,46 Ethernet12/1 12 50000 +Ethernet46 47,48 Ethernet12/3 12 50000 +Ethernet48 57,58,59,60 Ethernet13/1 13 100000 +Ethernet52 53,54,55,56 Ethernet14/1 14 100000 +Ethernet56 117,118,119,120 Ethernet15/1 15 100000 +Ethernet60 121,122,123,124 Ethernet16/1 16 100000 +Ethernet64 141,142,143,144 Ethernet17/1 17 100000 +Ethernet68 133,134,135,136 Ethernet18/1 18 100000 +Ethernet72 197,198,199,200 Ethernet19/1 19 100000 +Ethernet76 205,206,207,208 Ethernet20/1 20 100000 +Ethernet80 217,218 Ethernet21/1 21 50000 +Ethernet82 219,220 Ethernet21/3 21 50000 +Ethernet84 213,214 Ethernet22/1 22 50000 +Ethernet86 215,216 Ethernet22/3 22 50000 +Ethernet88 229,230 Ethernet23/1 23 50000 +Ethernet90 231,232 Ethernet23/3 23 50000 +Ethernet92 237,238 Ethernet24/1 24 50000 +Ethernet94 239,240 Ethernet24/3 24 50000 +Ethernet96 249,250 Ethernet25/1 25 50000 +Ethernet98 251,252 Ethernet25/3 25 50000 +Ethernet100 245,246 Ethernet26/1 26 50000 +Ethernet102 247,248 Ethernet26/3 26 50000 +Ethernet104 149,150 Ethernet27/1 27 50000 +Ethernet106 151,152 Ethernet27/3 27 50000 +Ethernet108 153,154 Ethernet28/1 28 50000 +Ethernet110 155,156 Ethernet28/3 28 50000 +Ethernet112 173,174 Ethernet29/1 29 50000 +Ethernet114 175,176 Ethernet29/3 29 50000 +Ethernet116 161,162 Ethernet30/1 30 50000 +Ethernet118 163,164 Ethernet30/3 30 50000 +Ethernet120 181,182 Ethernet31/1 31 50000 +Ethernet122 183,184 Ethernet31/3 31 50000 +Ethernet124 185,186 Ethernet32/1 32 50000 +Ethernet126 187,188 Ethernet32/3 32 50000 +Ethernet128 69,70 Ethernet33/1 33 50000 +Ethernet130 71,72 Ethernet33/3 33 50000 +Ethernet132 73,74 Ethernet34/1 34 50000 +Ethernet134 75,76 Ethernet34/3 34 50000 +Ethernet136 93,94 Ethernet35/1 35 50000 +Ethernet138 95,96 Ethernet35/3 35 50000 +Ethernet140 81,82 Ethernet36/1 36 50000 +Ethernet142 83,84 Ethernet36/3 36 50000 +Ethernet144 101,102 Ethernet37/1 37 50000 +Ethernet146 103,104 Ethernet37/3 37 50000 +Ethernet148 105,106 Ethernet38/1 38 50000 +Ethernet150 107,108 Ethernet38/3 38 50000 +Ethernet152 9,10 Ethernet39/1 39 50000 +Ethernet154 11,12 Ethernet39/3 39 50000 +Ethernet156 1,2 Ethernet40/1 40 50000 +Ethernet158 3,4 Ethernet40/3 40 50000 +Ethernet160 17,18 Ethernet41/1 41 50000 +Ethernet162 19,20 Ethernet41/3 41 50000 +Ethernet164 29,30 Ethernet42/1 42 50000 +Ethernet166 31,32 Ethernet42/3 42 50000 +Ethernet168 41,42 Ethernet43/1 43 50000 +Ethernet170 43,44 Ethernet43/3 43 50000 +Ethernet172 33,34 Ethernet44/1 44 50000 +Ethernet174 35,36 Ethernet44/3 44 50000 +Ethernet176 49,50 Ethernet45/1 45 50000 +Ethernet178 51,52 Ethernet45/3 45 50000 +Ethernet180 61,62 Ethernet46/1 46 50000 +Ethernet182 63,64 Ethernet46/3 46 50000 +Ethernet184 125,126 Ethernet47/1 47 50000 +Ethernet186 127,128 Ethernet47/3 47 50000 +Ethernet188 113,114 Ethernet48/1 48 50000 +Ethernet190 115,116 Ethernet48/3 48 50000 +Ethernet192 129,130 Ethernet49/1 49 50000 +Ethernet194 131,132 Ethernet49/3 49 50000 +Ethernet196 137,138 Ethernet50/1 50 50000 +Ethernet198 139,140 Ethernet50/3 50 50000 +Ethernet200 201,202 Ethernet51/1 51 50000 +Ethernet202 203,204 Ethernet51/3 51 50000 +Ethernet204 193,194 Ethernet52/1 52 50000 +Ethernet206 195,196 Ethernet52/3 52 50000 +Ethernet208 209,210 Ethernet53/1 53 50000 +Ethernet210 211,212 Ethernet53/3 53 50000 +Ethernet212 221,222 Ethernet54/1 54 50000 +Ethernet214 223,224 Ethernet54/3 54 50000 +Ethernet216 233,234 Ethernet55/1 55 50000 +Ethernet218 235,236 Ethernet55/3 55 50000 +Ethernet220 225,226 Ethernet56/1 56 50000 +Ethernet222 227,228 Ethernet56/3 56 50000 +Ethernet224 241,242 Ethernet57/1 57 50000 +Ethernet226 243,244 Ethernet57/3 57 50000 +Ethernet228 253,254 Ethernet58/1 58 50000 +Ethernet230 255,256 Ethernet58/3 58 50000 +Ethernet232 157,158 Ethernet59/1 59 50000 +Ethernet234 159,160 Ethernet59/3 59 50000 +Ethernet236 145,146 Ethernet60/1 60 50000 +Ethernet238 147,148 Ethernet60/3 60 50000 +Ethernet240 165,166 Ethernet61/1 61 50000 +Ethernet242 167,168 Ethernet61/3 61 50000 +Ethernet244 169,170 Ethernet62/1 62 50000 +Ethernet246 171,172 Ethernet62/3 62 50000 +Ethernet248 189,190 Ethernet63/1 63 50000 +Ethernet250 191,192 Ethernet63/3 63 50000 +Ethernet252 177,178 Ethernet64/1 64 50000 +Ethernet254 179,180 Ethernet64/3 64 50000 +Ethernet256 257 Ethernet65 65 10000 +Ethernet260 259 Ethernet66 66 10000 diff --git a/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C10/qos.json.j2 b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C10/qos.json.j2 new file mode 120000 index 000000000000..aef6b6765cf2 --- /dev/null +++ b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C10/qos.json.j2 @@ -0,0 +1 @@ +BALANCED/qos.json.j2 \ No newline at end of file diff --git a/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C10/sai.profile b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C10/sai.profile new file mode 100644 index 000000000000..5163d6140f0e --- /dev/null +++ b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C10/sai.profile @@ -0,0 +1,2 @@ +SAI_INIT_CONFIG_FILE=/etc/sai.d/config.bcm +SAI_NUM_ECMP_MEMBERS=64 diff --git a/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D92C16 b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D92C16 new file mode 120000 index 000000000000..fd5bbe75f37c --- /dev/null +++ b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D92C16 @@ -0,0 +1 @@ +Arista-7260CX3-D96C16 \ No newline at end of file diff --git a/device/arista/x86_64-arista_7260cx3_64/platform.json b/device/arista/x86_64-arista_7260cx3_64/platform.json index a646ce80945e..522c5b61b0c8 100644 --- a/device/arista/x86_64-arista_7260cx3_64/platform.json +++ b/device/arista/x86_64-arista_7260cx3_64/platform.json @@ -1,7 +1,26 @@ { "chassis": { "name": "DCS-7260CX3-64", - "components": [], + "components": [ + { + "name": "Aboot()" + }, + { + "name": "Scd(addr=0000:06:00.0)" + }, + { + "name": "Scd(addr=0000:ff:0b.3)" + }, + { + "name": "Ucd90160(addr=74-004e)" + }, + { + "name": "Ucd90120A(addr=83-0034)" + }, + { + "name": "RookSysCpld(addr=81-0023)" + } + ], "fans": [], "fan_drawers": [ { @@ -40,55 +59,59 @@ "psus": [ { "name": "psu1", - "fans": [] + "fans": [ + { + "name": "psu1/1", + "speed": { + "controllable": false + } + } + ] }, { "name": "psu2", - "fans": [] + "fans": [ + { + "name": "psu2/1", + "speed": { + "controllable": false + } + } + ] } ], "thermals": [ { - "name": "Board sensor" - }, - { - "name": "PCH temp sensor" - }, - { - "name": "Physical id 0" - }, - { - "name": "CPU core0 temp sensor" - }, - { - "name": "CPU core1 temp sensor" - }, - { - "name": "CPU board temp sensor" - }, - { - "name": "Back-panel temp sensor" + "name": "Board sensor", + "controllable": false }, { - "name": "Front-panel temp sensor" + "name": "PCH temp sensor", + "controllable": false }, { - "name": "Power supply 1 hotspot sensor" + "name": "Physical id 0", + "controllable": false }, { - "name": "Power supply 1 inlet temp sensor" + "name": "CPU core0 temp sensor", + "controllable": false }, { - "name": "Power supply 1 exhaust temp sensor" + "name": "CPU core1 temp sensor", + "controllable": false }, { - "name": "Power supply 2 hotspot sensor" + "name": "CPU board temp sensor", + "controllable": false }, { - "name": "Power supply 2 inlet temp sensor" + "name": "Back-panel temp sensor", + "controllable": false }, { - "name": "Power supply 2 exhaust temp sensor" + "name": "Front-panel temp sensor", + "controllable": false } ], "sfps": [ @@ -1528,4 +1551,4 @@ } } } -} \ No newline at end of file +} diff --git a/device/arista/x86_64-arista_7260cx3_64/platform_components.json b/device/arista/x86_64-arista_7260cx3_64/platform_components.json new file mode 100644 index 000000000000..a95e59009f06 --- /dev/null +++ b/device/arista/x86_64-arista_7260cx3_64/platform_components.json @@ -0,0 +1,14 @@ +{ + "chassis": { + "DCS-7260CX3-64": { + "component": { + "Aboot()": {}, + "Scd(addr=0000:06:00.0)": {}, + "Scd(addr=0000:ff:0b.3)": {}, + "Ucd90160(addr=74-004e)": {}, + "Ucd90120A(addr=83-0034)": {}, + "RookSysCpld(addr=81-0023)": {} + } + } + } +} diff --git a/device/arista/x86_64-arista_7280cr3_32d4/Arista-7280CR3-C32D4/jr2-a7280cr3-32d4-32x100G+4x400G.config.bcm b/device/arista/x86_64-arista_7280cr3_32d4/Arista-7280CR3-C32D4/jr2-a7280cr3-32d4-32x100G+4x400G.config.bcm index 003579a88692..a8e711e7bd09 100644 --- a/device/arista/x86_64-arista_7280cr3_32d4/Arista-7280CR3-C32D4/jr2-a7280cr3-32d4-32x100G+4x400G.config.bcm +++ b/device/arista/x86_64-arista_7280cr3_32d4/Arista-7280CR3-C32D4/jr2-a7280cr3-32d4-32x100G+4x400G.config.bcm @@ -270,10 +270,10 @@ tdma_timeout_usec.BCM8869X=1000000 tslam_timeout_usec.BCM8869X=1000000 appl_enable_intr_init.BCM8869X=1 -polled_irq_mode.BCM8869X=1 +polled_irq_mode.BCM8869X=0 polled_irq_delay.BCM8869X=1000 -bcm_stat_interval.BCM8869X=1000 +bcm_stat_interval.BCM8869X=1000000 mem_cache_enable_ecc.BCM8869X=1 mem_cache_enable_parity.BCM8869X=1 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 03b4b8bbf03e..8dbd850d30e6 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 @@ -273,10 +273,10 @@ tdma_timeout_usec.BCM8869X=1000000 tslam_timeout_usec.BCM8869X=1000000 appl_enable_intr_init.BCM8869X=1 -polled_irq_mode.BCM8869X=1 +polled_irq_mode.BCM8869X=0 polled_irq_delay.BCM8869X=1000 -bcm_stat_interval.BCM8869X=1000 +bcm_stat_interval.BCM8869X=1000000 mem_cache_enable_ecc.BCM8869X=1 mem_cache_enable_parity.BCM8869X=1 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 f66e7061c6f3..f9a5d0f36ff6 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 @@ -269,10 +269,10 @@ tdma_timeout_usec.BCM8869X=1000000 tslam_timeout_usec.BCM8869X=1000000 appl_enable_intr_init.BCM8869X=1 -polled_irq_mode.BCM8869X=1 +polled_irq_mode.BCM8869X=0 polled_irq_delay.BCM8869X=1000 -bcm_stat_interval.BCM8869X=1000 +bcm_stat_interval.BCM8869X=1000000 mem_cache_enable_ecc.BCM8869X=1 mem_cache_enable_parity.BCM8869X=1 diff --git a/device/arista/x86_64-arista_7280cr3_32p4/Arista-7280CR3-C32P4/jr2-a7280cr3-32p4-32x100G+4x400G.config.bcm b/device/arista/x86_64-arista_7280cr3_32p4/Arista-7280CR3-C32P4/jr2-a7280cr3-32p4-32x100G+4x400G.config.bcm index 5b2bbbf89254..3d4f595f2d30 100644 --- a/device/arista/x86_64-arista_7280cr3_32p4/Arista-7280CR3-C32P4/jr2-a7280cr3-32p4-32x100G+4x400G.config.bcm +++ b/device/arista/x86_64-arista_7280cr3_32p4/Arista-7280CR3-C32P4/jr2-a7280cr3-32p4-32x100G+4x400G.config.bcm @@ -270,10 +270,10 @@ tdma_timeout_usec.BCM8869X=1000000 tslam_timeout_usec.BCM8869X=1000000 appl_enable_intr_init.BCM8869X=1 -polled_irq_mode.BCM8869X=1 +polled_irq_mode.BCM8869X=0 polled_irq_delay.BCM8869X=1000 -bcm_stat_interval.BCM8869X=1000 +bcm_stat_interval.BCM8869X=1000000 mem_cache_enable_ecc.BCM8869X=1 mem_cache_enable_parity.BCM8869X=1 diff --git a/device/arista/x86_64-arista_7800_sup/platform.json b/device/arista/x86_64-arista_7800_sup/platform.json index 8dc0a4565258..0f9e91af98e8 100644 --- a/device/arista/x86_64-arista_7800_sup/platform.json +++ b/device/arista/x86_64-arista_7800_sup/platform.json @@ -7,6 +7,9 @@ "psus": [ { "name": "psu1", + "status_led": { + "controllable": false + }, "fans": [ { "name": "psu1/1", @@ -21,6 +24,9 @@ }, { "name": "psu2", + "status_led": { + "controllable": false + }, "fans": [ { "name": "psu2/1", @@ -35,6 +41,9 @@ }, { "name": "psu3", + "status_led": { + "controllable": false + }, "fans": [ { "name": "psu3/1", @@ -49,6 +58,9 @@ }, { "name": "psu4", + "status_led": { + "controllable": false + }, "fans": [ { "name": "psu4/1", @@ -63,6 +75,9 @@ }, { "name": "psu5", + "status_led": { + "controllable": false + }, "fans": [ { "name": "psu5/1", @@ -77,6 +92,9 @@ }, { "name": "psu6", + "status_led": { + "controllable": false + }, "fans": [ { "name": "psu6/1", @@ -91,6 +109,9 @@ }, { "name": "psu7", + "status_led": { + "controllable": false + }, "fans": [ { "name": "psu7/1", @@ -105,6 +126,9 @@ }, { "name": "psu8", + "status_led": { + "controllable": false + }, "fans": [ { "name": "psu8/1", @@ -119,6 +143,9 @@ }, { "name": "psu9", + "status_led": { + "controllable": false + }, "fans": [ { "name": "psu9/1", @@ -133,6 +160,9 @@ }, { "name": "psu10", + "status_led": { + "controllable": false + }, "fans": [ { "name": "psu10/1", @@ -147,6 +177,9 @@ }, { "name": "psu11", + "status_led": { + "controllable": false + }, "fans": [ { "name": "psu11/1", @@ -161,6 +194,9 @@ }, { "name": "psu12", + "status_led": { + "controllable": false + }, "fans": [ { "name": "psu12/1", diff --git a/device/arista/x86_64-arista_7800r3_48cq2_lc/Arista-7800R3-48CQ2-C48/jr2-a7280cr3-32d4-40x100G.config.bcm b/device/arista/x86_64-arista_7800r3_48cq2_lc/Arista-7800R3-48CQ2-C48/jr2-a7280cr3-32d4-40x100G.config.bcm index 3db7f3a5147b..93c5c8d21560 100644 --- a/device/arista/x86_64-arista_7800r3_48cq2_lc/Arista-7800R3-48CQ2-C48/jr2-a7280cr3-32d4-40x100G.config.bcm +++ b/device/arista/x86_64-arista_7800r3_48cq2_lc/Arista-7800R3-48CQ2-C48/jr2-a7280cr3-32d4-40x100G.config.bcm @@ -763,10 +763,10 @@ tdma_timeout_usec.BCM8869X=1000000 tslam_timeout_usec.BCM8869X=1000000 appl_enable_intr_init.BCM8869X=1 -polled_irq_mode.BCM8869X=1 +polled_irq_mode.BCM8869X=0 polled_irq_delay.BCM8869X=1000 -bcm_stat_interval.BCM8869X=1000 +bcm_stat_interval.BCM8869X=1000000 mem_cache_enable_ecc.BCM8869X=1 mem_cache_enable_parity.BCM8869X=1 diff --git a/device/arista/x86_64-arista_7800r3_48cq2_lc/platform_components.json b/device/arista/x86_64-arista_7800r3_48cq2_lc/platform_components.json new file mode 100644 index 000000000000..02bd5e6d4abb --- /dev/null +++ b/device/arista/x86_64-arista_7800r3_48cq2_lc/platform_components.json @@ -0,0 +1,11 @@ +{ + "chassis": { + "7800R3-48CQ2-LC": { + "component": { + "Aboot()": {}, + "Scd(addr=0000:00:18.7)": {}, + "Scd(addr=0000:07:00.0)": {} + } + } + } +} diff --git a/device/arista/x86_64-arista_7800r3_48cqm2_lc/platform_components.json b/device/arista/x86_64-arista_7800r3_48cqm2_lc/platform_components.json new file mode 100644 index 000000000000..a90881ca60d2 --- /dev/null +++ b/device/arista/x86_64-arista_7800r3_48cqm2_lc/platform_components.json @@ -0,0 +1,11 @@ +{ + "chassis": { + "7800R3-48CQM2-LC": { + "component": { + "Aboot()": {}, + "Scd(addr=0000:00:18.7)": {}, + "Scd(addr=0000:07:00.0)": {} + } + } + } +} diff --git a/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C36/0/buffers.json.j2 b/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C36/0/buffers.json.j2 new file mode 100644 index 000000000000..f34a844f4a87 --- /dev/null +++ b/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C36/0/buffers.json.j2 @@ -0,0 +1,2 @@ +{%- set default_topo = 't2' %} +{%- include 'buffers_config.j2' %} diff --git a/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C36/0/buffers_defaults_t2.j2 b/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C36/0/buffers_defaults_t2.j2 new file mode 100644 index 000000000000..e7af0aff4934 --- /dev/null +++ b/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C36/0/buffers_defaults_t2.j2 @@ -0,0 +1,37 @@ +{%- set default_cable = '300m' %} + +{%- macro generate_port_lists(PORT_ALL) %} + {# Generate list of ports #} + {%- for port_idx in range(0,144,8) %} + {%- if PORT_ALL.append("Ethernet%d" % (port_idx)) %}{%- endif %} + {%- endfor %} +{%- endmacro %} + +{%- macro generate_buffer_pool_and_profiles() %} + "BUFFER_POOL": { + "ingress_lossless_pool": { + "size": "6441610000", + "type": "both", + "mode": "dynamic", + "xoff": "11354112" + } + }, + "BUFFER_PROFILE": { + "ingress_lossy_profile": { + "pool":"ingress_lossless_pool", + "size":"1280", + "xon_offset": "2560", + "dynamic_th":"0" + }, + "egress_lossless_profile": { + "pool":"ingress_lossless_pool", + "size":"0", + "static_th":"33030144" + }, + "egress_lossy_profile": { + "pool":"ingress_lossless_pool", + "size":"0", + "dynamic_th":"-1" + } + }, +{%- endmacro %} diff --git a/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C36/0/j2p-a7800r3a-36d-36x400G.config.bcm b/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C36/0/j2p-a7800r3a-36d-36x400G.config.bcm index 9be5d8e836f3..f4c5952cb083 100644 --- a/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C36/0/j2p-a7800r3a-36d-36x400G.config.bcm +++ b/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C36/0/j2p-a7800r3a-36d-36x400G.config.bcm @@ -251,17 +251,6 @@ tm_port_header_type_out_202=ETH tm_port_header_type_in_203=INJECTED_2_PP tm_port_header_type_out_203=ETH -### SAT -## Enable SAT Interface. 0 - Disable, 1 - Enable (Default) -sat_enable=1 -ucode_port_218=SAT:core_0.218 -tm_port_header_type_out_218=CPU -tm_port_header_type_in_218=INJECTED_2 -ucode_port_219=SAT:core_1.219 -tm_port_header_type_out_219=CPU -tm_port_header_type_in_219=INJECTED_2 -port_init_speed_sat=400000 - ### RCY sai_recycle_port_lane_base=0 ucode_port_221=RCY.21:core_0.221 @@ -634,12 +623,12 @@ tslam_timeout_usec=1000000 ### Interrupts appl_enable_intr_init=1 -polled_irq_mode=1 +polled_irq_mode=0 # reduce CPU load, configure delay 100ms polled_irq_delay=1000 # reduce the CPU load over adapter (caused by counter thread) -bcm_stat_interval=1000 +bcm_stat_interval=1000000 # shadow memory mem_cache_enable_ecc=1 diff --git a/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C36/0/pg_profile_lookup.ini b/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C36/0/pg_profile_lookup.ini new file mode 100644 index 000000000000..e8289ab03112 --- /dev/null +++ b/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C36/0/pg_profile_lookup.ini @@ -0,0 +1,17 @@ +# PG lossless profiles. +# speed cable size xon xoff threshold xon_offset + 40000 300m 1280 2560 69632 0 1280 + 100000 300m 1280 2560 110592 0 1280 + 400000 300m 1280 2560 315392 0 1280 + 40000 1000m 1280 2560 114688 0 1280 + 100000 1000m 1280 2560 225280 0 1280 + 400000 1000m 1280 2560 778240 0 1280 + 40000 2000m 1280 2560 184320 0 1280 + 100000 2000m 1280 2560 393216 0 1280 + 400000 2000m 1280 2560 1445888 0 1280 + 40000 80000m 1280 2560 5369856 0 1280 + 100000 80000m 1280 2560 13357056 0 1280 + 400000 80000m 1280 2560 53305344 0 1280 + 40000 120000m 1280 2560 8028160 0 1280 + 100000 120000m 1280 2560 20004864 0 1280 + 400000 120000m 1280 2560 79900672 0 1280 diff --git a/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C36/0/qos.json.j2 b/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C36/0/qos.json.j2 new file mode 100644 index 000000000000..3e548325ea30 --- /dev/null +++ b/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C36/0/qos.json.j2 @@ -0,0 +1 @@ +{%- include 'qos_config.j2' %} diff --git a/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C36/1/buffers.json.j2 b/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C36/1/buffers.json.j2 new file mode 100644 index 000000000000..f34a844f4a87 --- /dev/null +++ b/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C36/1/buffers.json.j2 @@ -0,0 +1,2 @@ +{%- set default_topo = 't2' %} +{%- include 'buffers_config.j2' %} diff --git a/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C36/1/buffers_defaults_t2.j2 b/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C36/1/buffers_defaults_t2.j2 new file mode 100644 index 000000000000..3555175244d4 --- /dev/null +++ b/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C36/1/buffers_defaults_t2.j2 @@ -0,0 +1,37 @@ +{%- set default_cable = '300m' %} + +{%- macro generate_port_lists(PORT_ALL) %} + {# Generate list of ports #} + {%- for port_idx in range(144,288,8) %} + {%- if PORT_ALL.append("Ethernet%d" % (port_idx)) %}{%- endif %} + {%- endfor %} +{%- endmacro %} + +{%- macro generate_buffer_pool_and_profiles() %} + "BUFFER_POOL": { + "ingress_lossless_pool": { + "size": "6441610000", + "type": "both", + "mode": "dynamic", + "xoff": "11354112" + } + }, + "BUFFER_PROFILE": { + "ingress_lossy_profile": { + "pool":"ingress_lossless_pool", + "size":"1280", + "xon_offset": "2560", + "dynamic_th":"0" + }, + "egress_lossless_profile": { + "pool":"ingress_lossless_pool", + "size":"0", + "static_th":"33030144" + }, + "egress_lossy_profile": { + "pool":"ingress_lossless_pool", + "size":"0", + "dynamic_th":"-1" + } + }, +{%- endmacro %} diff --git a/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C36/1/j2p-a7800r3a-36d-36x400G.config.bcm b/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C36/1/j2p-a7800r3a-36d-36x400G.config.bcm index b30d9d238b29..581277b9783e 100644 --- a/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C36/1/j2p-a7800r3a-36d-36x400G.config.bcm +++ b/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C36/1/j2p-a7800r3a-36d-36x400G.config.bcm @@ -250,17 +250,6 @@ tm_port_header_type_out_202=ETH tm_port_header_type_in_203=INJECTED_2_PP tm_port_header_type_out_203=ETH -### SAT -## Enable SAT Interface. 0 - Disable, 1 - Enable (Default) -sat_enable=1 -ucode_port_218=SAT:core_0.218 -tm_port_header_type_out_218=CPU -tm_port_header_type_in_218=INJECTED_2 -ucode_port_219=SAT:core_1.219 -tm_port_header_type_out_219=CPU -tm_port_header_type_in_219=INJECTED_2 -port_init_speed_sat=400000 - ### RCY sai_recycle_port_lane_base=0 ucode_port_221=RCY.21:core_0.221 @@ -633,12 +622,12 @@ tslam_timeout_usec=1000000 ### Interrupts appl_enable_intr_init=1 -polled_irq_mode=1 +polled_irq_mode=0 # reduce CPU load, configure delay 100ms polled_irq_delay=1000 # reduce the CPU load over adapter (caused by counter thread) -bcm_stat_interval=1000 +bcm_stat_interval=1000000 # shadow memory mem_cache_enable_ecc=1 diff --git a/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C36/1/pg_profile_lookup.ini b/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C36/1/pg_profile_lookup.ini new file mode 100644 index 000000000000..e8289ab03112 --- /dev/null +++ b/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C36/1/pg_profile_lookup.ini @@ -0,0 +1,17 @@ +# PG lossless profiles. +# speed cable size xon xoff threshold xon_offset + 40000 300m 1280 2560 69632 0 1280 + 100000 300m 1280 2560 110592 0 1280 + 400000 300m 1280 2560 315392 0 1280 + 40000 1000m 1280 2560 114688 0 1280 + 100000 1000m 1280 2560 225280 0 1280 + 400000 1000m 1280 2560 778240 0 1280 + 40000 2000m 1280 2560 184320 0 1280 + 100000 2000m 1280 2560 393216 0 1280 + 400000 2000m 1280 2560 1445888 0 1280 + 40000 80000m 1280 2560 5369856 0 1280 + 100000 80000m 1280 2560 13357056 0 1280 + 400000 80000m 1280 2560 53305344 0 1280 + 40000 120000m 1280 2560 8028160 0 1280 + 100000 120000m 1280 2560 20004864 0 1280 + 400000 120000m 1280 2560 79900672 0 1280 diff --git a/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C36/1/qos.json.j2 b/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C36/1/qos.json.j2 new file mode 100644 index 000000000000..3e548325ea30 --- /dev/null +++ b/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C36/1/qos.json.j2 @@ -0,0 +1 @@ +{%- include 'qos_config.j2' %} diff --git a/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C72/0/j2p-a7800r3a-36d-36x400G.config.bcm b/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C72/0/j2p-a7800r3a-36d-36x400G.config.bcm index 99dfb9e3e264..1ec47834148d 100644 --- a/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C72/0/j2p-a7800r3a-36d-36x400G.config.bcm +++ b/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C72/0/j2p-a7800r3a-36d-36x400G.config.bcm @@ -269,17 +269,6 @@ tm_port_header_type_out_202=ETH tm_port_header_type_in_203=INJECTED_2_PP tm_port_header_type_out_203=ETH -### SAT -## Enable SAT Interface. 0 - Disable, 1 - Enable (Default) -sat_enable=1 -ucode_port_218=SAT:core_0.218 -tm_port_header_type_out_218=CPU -tm_port_header_type_in_218=INJECTED_2 -ucode_port_219=SAT:core_1.219 -tm_port_header_type_out_219=CPU -tm_port_header_type_in_219=INJECTED_2 -port_init_speed_sat=400000 - ### RCY sai_recycle_port_lane_base=0 ucode_port_221=RCY.21:core_0.221 @@ -652,12 +641,12 @@ tslam_timeout_usec=1000000 ### Interrupts appl_enable_intr_init=1 -polled_irq_mode=1 +polled_irq_mode=0 # reduce CPU load, configure delay 100ms polled_irq_delay=1000 # reduce the CPU load over adapter (caused by counter thread) -bcm_stat_interval=1000 +bcm_stat_interval=1000000 # shadow memory mem_cache_enable_ecc=1 diff --git a/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C72/1/j2p-a7800r3a-36d-36x400G.config.bcm b/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C72/1/j2p-a7800r3a-36d-36x400G.config.bcm index bccc2d5be9f1..edc384b4cb8e 100644 --- a/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C72/1/j2p-a7800r3a-36d-36x400G.config.bcm +++ b/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C72/1/j2p-a7800r3a-36d-36x400G.config.bcm @@ -268,17 +268,6 @@ tm_port_header_type_out_202=ETH tm_port_header_type_in_203=INJECTED_2_PP tm_port_header_type_out_203=ETH -### SAT -## Enable SAT Interface. 0 - Disable, 1 - Enable (Default) -sat_enable=1 -ucode_port_218=SAT:core_0.218 -tm_port_header_type_out_218=CPU -tm_port_header_type_in_218=INJECTED_2 -ucode_port_219=SAT:core_1.219 -tm_port_header_type_out_219=CPU -tm_port_header_type_in_219=INJECTED_2 -port_init_speed_sat=400000 - ### RCY sai_recycle_port_lane_base=0 ucode_port_221=RCY.21:core_0.221 @@ -651,12 +640,12 @@ tslam_timeout_usec=1000000 ### Interrupts appl_enable_intr_init=1 -polled_irq_mode=1 +polled_irq_mode=0 # reduce CPU load, configure delay 100ms polled_irq_delay=1000 # reduce the CPU load over adapter (caused by counter thread) -bcm_stat_interval=1000 +bcm_stat_interval=1000000 # shadow memory mem_cache_enable_ecc=1 diff --git a/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-D36/0/j2p-a7800r3a-36d-36x400G.config.bcm b/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-D36/0/j2p-a7800r3a-36d-36x400G.config.bcm index 62fe61d49c9c..0d9cc9cde1fd 100644 --- a/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-D36/0/j2p-a7800r3a-36d-36x400G.config.bcm +++ b/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-D36/0/j2p-a7800r3a-36d-36x400G.config.bcm @@ -251,17 +251,6 @@ tm_port_header_type_out_202=ETH tm_port_header_type_in_203=INJECTED_2_PP tm_port_header_type_out_203=ETH -### SAT -## Enable SAT Interface. 0 - Disable, 1 - Enable (Default) -sat_enable=1 -ucode_port_218=SAT:core_0.218 -tm_port_header_type_out_218=CPU -tm_port_header_type_in_218=INJECTED_2 -ucode_port_219=SAT:core_1.219 -tm_port_header_type_out_219=CPU -tm_port_header_type_in_219=INJECTED_2 -port_init_speed_sat=400000 - ### RCY sai_recycle_port_lane_base=0 ucode_port_221=RCY.21:core_0.221 @@ -634,12 +623,12 @@ tslam_timeout_usec=1000000 ### Interrupts appl_enable_intr_init=1 -polled_irq_mode=1 +polled_irq_mode=0 # reduce CPU load, configure delay 100ms polled_irq_delay=1000 # reduce the CPU load over adapter (caused by counter thread) -bcm_stat_interval=1000 +bcm_stat_interval=1000000 # shadow memory mem_cache_enable_ecc=1 diff --git a/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-D36/1/j2p-a7800r3a-36d-36x400G.config.bcm b/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-D36/1/j2p-a7800r3a-36d-36x400G.config.bcm index 56d425f9f9c2..9e845dc4c782 100644 --- a/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-D36/1/j2p-a7800r3a-36d-36x400G.config.bcm +++ b/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-D36/1/j2p-a7800r3a-36d-36x400G.config.bcm @@ -251,17 +251,6 @@ tm_port_header_type_out_202=ETH tm_port_header_type_in_203=INJECTED_2_PP tm_port_header_type_out_203=ETH -### SAT -## Enable SAT Interface. 0 - Disable, 1 - Enable (Default) -sat_enable=1 -ucode_port_218=SAT:core_0.218 -tm_port_header_type_out_218=CPU -tm_port_header_type_in_218=INJECTED_2 -ucode_port_219=SAT:core_1.219 -tm_port_header_type_out_219=CPU -tm_port_header_type_in_219=INJECTED_2 -port_init_speed_sat=400000 - ### RCY sai_recycle_port_lane_base=0 ucode_port_221=RCY.21:core_0.221 @@ -634,12 +623,12 @@ tslam_timeout_usec=1000000 ### Interrupts appl_enable_intr_init=1 -polled_irq_mode=1 +polled_irq_mode=0 # reduce CPU load, configure delay 100ms polled_irq_delay=1000 # reduce the CPU load over adapter (caused by counter thread) -bcm_stat_interval=1000 +bcm_stat_interval=1000000 # shadow memory mem_cache_enable_ecc=1 diff --git a/device/arista/x86_64-arista_7800r3a_36d2_lc/media_settings.json b/device/arista/x86_64-arista_7800r3a_36d2_lc/media_settings.json new file mode 100644 index 000000000000..7ce47e003202 --- /dev/null +++ b/device/arista/x86_64-arista_7800r3a_36d2_lc/media_settings.json @@ -0,0 +1,3676 @@ +{ + "PORT_MEDIA_SETTINGS": { + "1": { + "QSFP-DD-sm_media_interface": { + "main": { + "lane0": "0x94", + "lane1": "0x8d", + "lane2": "0x8b", + "lane3": "0x90", + "lane4": "0x89", + "lane5": "0x8d", + "lane6": "0x94", + "lane7": "0x88" + }, + "post1": { + "lane0": "-0x3", + "lane1": "-0x5", + "lane2": "-0x7", + "lane3": "-0x1", + "lane4": "-0xc", + "lane5": "-0x5", + "lane6": "-0x3", + "lane7": "-0xe" + }, + "post2": { + "lane0": "0x0", + "lane1": "-0x2", + "lane2": "-0x2", + "lane3": "-0x3", + "lane4": "0x0", + "lane5": "-0x2", + "lane6": "0x0", + "lane7": "0x0" + }, + "post3": { + "lane0": "-0x1", + "lane1": "-0x3", + "lane2": "-0x3", + "lane3": "-0x3", + "lane4": "-0x3", + "lane5": "-0x3", + "lane6": "-0x1", + "lane7": "-0x4" + }, + "pre1": { + "lane0": "-0x10", + "lane1": "-0x10", + "lane2": "-0x10", + "lane3": "-0x11", + "lane4": "-0x10", + "lane5": "-0x10", + "lane6": "-0x10", + "lane7": "-0xe" + }, + "pre2": { + "lane0": "0x2", + "lane1": "0x3", + "lane2": "0x3", + "lane3": "0x2", + "lane4": "0x2", + "lane5": "0x3", + "lane6": "0x2", + "lane7": "0x2" + } + }, + "Default": { + "main": { + "lane0": "0x59", + "lane1": "0x55", + "lane2": "0x50", + "lane3": "0x4b" + }, + "post1": { + "lane0": "-0x1d", + "lane1": "-0x19", + "lane2": "-0x17", + "lane3": "-0x15" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "post3": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "pre1": { + "lane0": "-0x8", + "lane1": "-0x7", + "lane2": "-0x5", + "lane3": "-0x4" + }, + "pre2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + } + } + }, + "2": { + "QSFP-DD-sm_media_interface": { + "main": { + "lane0": "0x8d", + "lane1": "0x8d", + "lane2": "0x89", + "lane3": "0x8d", + "lane4": "0x8d", + "lane5": "0x84", + "lane6": "0x8d", + "lane7": "0x8d" + }, + "post1": { + "lane0": "-0x5", + "lane1": "-0x8", + "lane2": "-0xc", + "lane3": "-0x5", + "lane4": "-0x8", + "lane5": "-0xa", + "lane6": "-0x5", + "lane7": "-0x8" + }, + "post2": { + "lane0": "-0x2", + "lane1": "-0x3", + "lane2": "0x0", + "lane3": "-0x2", + "lane4": "-0x3", + "lane5": "-0x2", + "lane6": "-0x2", + "lane7": "-0x3" + }, + "post3": { + "lane0": "-0x3", + "lane1": "-0x1", + "lane2": "-0x3", + "lane3": "-0x3", + "lane4": "-0x1", + "lane5": "-0x3", + "lane6": "-0x3", + "lane7": "-0x1" + }, + "pre1": { + "lane0": "-0x10", + "lane1": "-0xf", + "lane2": "-0x10", + "lane3": "-0x10", + "lane4": "-0xf", + "lane5": "-0x14", + "lane6": "-0x10", + "lane7": "-0xf" + }, + "pre2": { + "lane0": "0x3", + "lane1": "0x2", + "lane2": "0x2", + "lane3": "0x3", + "lane4": "0x2", + "lane5": "0x3", + "lane6": "0x3", + "lane7": "0x2" + } + }, + "Default": { + "main": { + "lane0": "0x4b", + "lane1": "0x4b", + "lane2": "0x4e", + "lane3": "0x4e" + }, + "post1": { + "lane0": "-0x14", + "lane1": "-0x14", + "lane2": "-0x16", + "lane3": "-0x16" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "post3": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "pre1": { + "lane0": "-0x5", + "lane1": "-0x5", + "lane2": "-0x5", + "lane3": "-0x5" + }, + "pre2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + } + } + }, + "3": { + "QSFP-DD-sm_media_interface": { + "main": { + "lane0": "0x89", + "lane1": "0x88", + "lane2": "0x8b", + "lane3": "0x8b", + "lane4": "0x94", + "lane5": "0x88", + "lane6": "0x8b", + "lane7": "0x94" + }, + "post1": { + "lane0": "-0xc", + "lane1": "-0xe", + "lane2": "-0x7", + "lane3": "-0x7", + "lane4": "-0x3", + "lane5": "-0xe", + "lane6": "-0x7", + "lane7": "-0x3" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "-0x2", + "lane3": "-0x2", + "lane4": "0x0", + "lane5": "0x0", + "lane6": "-0x2", + "lane7": "0x0" + }, + "post3": { + "lane0": "-0x3", + "lane1": "-0x4", + "lane2": "-0x3", + "lane3": "-0x3", + "lane4": "-0x1", + "lane5": "-0x4", + "lane6": "-0x3", + "lane7": "-0x1" + }, + "pre1": { + "lane0": "-0x10", + "lane1": "-0xe", + "lane2": "-0x10", + "lane3": "-0x10", + "lane4": "-0x10", + "lane5": "-0xe", + "lane6": "-0x10", + "lane7": "-0x10" + }, + "pre2": { + "lane0": "0x2", + "lane1": "0x2", + "lane2": "0x3", + "lane3": "0x3", + "lane4": "0x2", + "lane5": "0x2", + "lane6": "0x3", + "lane7": "0x2" + } + }, + "Default": { + "main": { + "lane0": "0x50", + "lane1": "0x50", + "lane2": "0x55", + "lane3": "0x55" + }, + "post1": { + "lane0": "-0x17", + "lane1": "-0x17", + "lane2": "-0x19", + "lane3": "-0x19" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "post3": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "pre1": { + "lane0": "-0x5", + "lane1": "-0x5", + "lane2": "-0x7", + "lane3": "-0x7" + }, + "pre2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + } + } + }, + "4": { + "QSFP-DD-sm_media_interface": { + "main": { + "lane0": "0x89", + "lane1": "0x8d", + "lane2": "0x8d", + "lane3": "0x8d", + "lane4": "0x89", + "lane5": "0x8d", + "lane6": "0x8d", + "lane7": "0x8d" + }, + "post1": { + "lane0": "-0xc", + "lane1": "-0x5", + "lane2": "-0x8", + "lane3": "-0x5", + "lane4": "-0xc", + "lane5": "-0x8", + "lane6": "-0x8", + "lane7": "-0x5" + }, + "post2": { + "lane0": "0x0", + "lane1": "-0x2", + "lane2": "-0x3", + "lane3": "-0x2", + "lane4": "0x0", + "lane5": "-0x3", + "lane6": "-0x3", + "lane7": "-0x2" + }, + "post3": { + "lane0": "-0x3", + "lane1": "-0x3", + "lane2": "-0x1", + "lane3": "-0x3", + "lane4": "-0x3", + "lane5": "-0x1", + "lane6": "-0x1", + "lane7": "-0x3" + }, + "pre1": { + "lane0": "-0x10", + "lane1": "-0x10", + "lane2": "-0xf", + "lane3": "-0x10", + "lane4": "-0x10", + "lane5": "-0xf", + "lane6": "-0xf", + "lane7": "-0x10" + }, + "pre2": { + "lane0": "0x2", + "lane1": "0x3", + "lane2": "0x2", + "lane3": "0x3", + "lane4": "0x2", + "lane5": "0x2", + "lane6": "0x2", + "lane7": "0x3" + } + }, + "Default": { + "main": { + "lane0": "0x59", + "lane1": "0x59", + "lane2": "0x59", + "lane3": "0x59" + }, + "post1": { + "lane0": "-0x1d", + "lane1": "-0x1d", + "lane2": "-0x1d", + "lane3": "-0x1d" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "post3": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "pre1": { + "lane0": "-0x8", + "lane1": "-0x8", + "lane2": "-0x8", + "lane3": "-0x8" + }, + "pre2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + } + } + }, + "5": { + "QSFP-DD-sm_media_interface": { + "main": { + "lane0": "0x94", + "lane1": "0x89", + "lane2": "0x88", + "lane3": "0x8b", + "lane4": "0x88", + "lane5": "0x8b", + "lane6": "0x88", + "lane7": "0x94" + }, + "post1": { + "lane0": "-0x3", + "lane1": "-0xc", + "lane2": "-0xe", + "lane3": "-0x7", + "lane4": "-0xe", + "lane5": "-0x7", + "lane6": "-0xe", + "lane7": "-0x3" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "-0x2", + "lane4": "0x0", + "lane5": "-0x2", + "lane6": "0x0", + "lane7": "0x0" + }, + "post3": { + "lane0": "-0x1", + "lane1": "-0x3", + "lane2": "-0x4", + "lane3": "-0x3", + "lane4": "-0x4", + "lane5": "-0x3", + "lane6": "-0x4", + "lane7": "-0x1" + }, + "pre1": { + "lane0": "-0x10", + "lane1": "-0x10", + "lane2": "-0xe", + "lane3": "-0x10", + "lane4": "-0xe", + "lane5": "-0x10", + "lane6": "-0xe", + "lane7": "-0x10" + }, + "pre2": { + "lane0": "0x2", + "lane1": "0x2", + "lane2": "0x2", + "lane3": "0x3", + "lane4": "0x2", + "lane5": "0x3", + "lane6": "0x2", + "lane7": "0x2" + } + }, + "Default": { + "main": { + "lane0": "0x59", + "lane1": "0x59", + "lane2": "0x59", + "lane3": "0x59" + }, + "post1": { + "lane0": "-0x1d", + "lane1": "-0x1d", + "lane2": "-0x1d", + "lane3": "-0x1d" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "post3": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "pre1": { + "lane0": "-0x8", + "lane1": "-0x8", + "lane2": "-0x8", + "lane3": "-0x8" + }, + "pre2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + } + } + }, + "6": { + "QSFP-DD-sm_media_interface": { + "main": { + "lane0": "0x94", + "lane1": "0x88", + "lane2": "0x8b", + "lane3": "0x8b", + "lane4": "0x94", + "lane5": "0x88", + "lane6": "0x8b", + "lane7": "0x94" + }, + "post1": { + "lane0": "-0x3", + "lane1": "-0xe", + "lane2": "-0x7", + "lane3": "-0x7", + "lane4": "-0x3", + "lane5": "-0xe", + "lane6": "-0x7", + "lane7": "-0x3" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "-0x2", + "lane3": "-0x2", + "lane4": "0x0", + "lane5": "0x0", + "lane6": "-0x2", + "lane7": "0x0" + }, + "post3": { + "lane0": "-0x1", + "lane1": "-0x4", + "lane2": "-0x3", + "lane3": "-0x3", + "lane4": "-0x1", + "lane5": "-0x4", + "lane6": "-0x3", + "lane7": "-0x1" + }, + "pre1": { + "lane0": "-0x10", + "lane1": "-0xe", + "lane2": "-0x10", + "lane3": "-0x10", + "lane4": "-0x10", + "lane5": "-0xe", + "lane6": "-0x10", + "lane7": "-0x10" + }, + "pre2": { + "lane0": "0x2", + "lane1": "0x2", + "lane2": "0x3", + "lane3": "0x3", + "lane4": "0x2", + "lane5": "0x2", + "lane6": "0x3", + "lane7": "0x2" + } + }, + "Default": { + "main": { + "lane0": "0x59", + "lane1": "0x59", + "lane2": "0x59", + "lane3": "0x59" + }, + "post1": { + "lane0": "-0x1d", + "lane1": "-0x1d", + "lane2": "-0x1d", + "lane3": "-0x1d" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "post3": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "pre1": { + "lane0": "-0x8", + "lane1": "-0x8", + "lane2": "-0x8", + "lane3": "-0x8" + }, + "pre2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + } + } + }, + "7": { + "QSFP-DD-sm_media_interface": { + "main": { + "lane0": "0x94", + "lane1": "0x88", + "lane2": "0x8b", + "lane3": "0x88", + "lane4": "0x94", + "lane5": "0x8b", + "lane6": "0x8b", + "lane7": "0x88" + }, + "post1": { + "lane0": "-0x3", + "lane1": "-0xe", + "lane2": "-0x7", + "lane3": "-0xe", + "lane4": "-0x3", + "lane5": "-0x7", + "lane6": "-0x7", + "lane7": "-0xe" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "-0x2", + "lane3": "0x0", + "lane4": "0x0", + "lane5": "-0x2", + "lane6": "-0x2", + "lane7": "0x0" + }, + "post3": { + "lane0": "-0x1", + "lane1": "-0x4", + "lane2": "-0x3", + "lane3": "-0x4", + "lane4": "-0x1", + "lane5": "-0x3", + "lane6": "-0x3", + "lane7": "-0x4" + }, + "pre1": { + "lane0": "-0x10", + "lane1": "-0xe", + "lane2": "-0x10", + "lane3": "-0xe", + "lane4": "-0x10", + "lane5": "-0x10", + "lane6": "-0x10", + "lane7": "-0xe" + }, + "pre2": { + "lane0": "0x2", + "lane1": "0x2", + "lane2": "0x3", + "lane3": "0x2", + "lane4": "0x2", + "lane5": "0x3", + "lane6": "0x3", + "lane7": "0x2" + } + }, + "Default": { + "main": { + "lane0": "0x59", + "lane1": "0x59", + "lane2": "0x59", + "lane3": "0x59" + }, + "post1": { + "lane0": "-0x1d", + "lane1": "-0x1d", + "lane2": "-0x1d", + "lane3": "-0x1d" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "post3": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "pre1": { + "lane0": "-0x8", + "lane1": "-0x8", + "lane2": "-0x8", + "lane3": "-0x8" + }, + "pre2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + } + } + }, + "8": { + "QSFP-DD-sm_media_interface": { + "main": { + "lane0": "0x94", + "lane1": "0x94", + "lane2": "0x88", + "lane3": "0x8b", + "lane4": "0x88", + "lane5": "0x8b", + "lane6": "0x88", + "lane7": "0x94" + }, + "post1": { + "lane0": "-0x3", + "lane1": "-0x3", + "lane2": "-0xe", + "lane3": "-0x7", + "lane4": "-0xe", + "lane5": "-0x7", + "lane6": "-0xe", + "lane7": "-0x3" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "-0x2", + "lane4": "0x0", + "lane5": "-0x2", + "lane6": "0x0", + "lane7": "0x0" + }, + "post3": { + "lane0": "-0x1", + "lane1": "-0x1", + "lane2": "-0x4", + "lane3": "-0x3", + "lane4": "-0x4", + "lane5": "-0x3", + "lane6": "-0x4", + "lane7": "-0x1" + }, + "pre1": { + "lane0": "-0x10", + "lane1": "-0x10", + "lane2": "-0xe", + "lane3": "-0x10", + "lane4": "-0xe", + "lane5": "-0x10", + "lane6": "-0xe", + "lane7": "-0x10" + }, + "pre2": { + "lane0": "0x2", + "lane1": "0x2", + "lane2": "0x2", + "lane3": "0x3", + "lane4": "0x2", + "lane5": "0x3", + "lane6": "0x2", + "lane7": "0x2" + } + }, + "Default": { + "main": { + "lane0": "0x59", + "lane1": "0x59", + "lane2": "0x59", + "lane3": "0x59" + }, + "post1": { + "lane0": "-0x1d", + "lane1": "-0x1d", + "lane2": "-0x1d", + "lane3": "-0x1d" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "post3": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "pre1": { + "lane0": "-0x8", + "lane1": "-0x8", + "lane2": "-0x8", + "lane3": "-0x8" + }, + "pre2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + } + } + }, + "9": { + "QSFP-DD-sm_media_interface": { + "main": { + "lane0": "0x94", + "lane1": "0x88", + "lane2": "0x8b", + "lane3": "0x8b", + "lane4": "0x94", + "lane5": "0x88", + "lane6": "0x8b", + "lane7": "0x94" + }, + "post1": { + "lane0": "-0x3", + "lane1": "-0xe", + "lane2": "-0x7", + "lane3": "-0x7", + "lane4": "-0x3", + "lane5": "-0xe", + "lane6": "-0x7", + "lane7": "-0x3" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "-0x2", + "lane3": "-0x2", + "lane4": "0x0", + "lane5": "0x0", + "lane6": "-0x2", + "lane7": "0x0" + }, + "post3": { + "lane0": "-0x1", + "lane1": "-0x4", + "lane2": "-0x3", + "lane3": "-0x3", + "lane4": "-0x1", + "lane5": "-0x4", + "lane6": "-0x3", + "lane7": "-0x1" + }, + "pre1": { + "lane0": "-0x10", + "lane1": "-0xe", + "lane2": "-0x10", + "lane3": "-0x10", + "lane4": "-0x10", + "lane5": "-0xe", + "lane6": "-0x10", + "lane7": "-0x10" + }, + "pre2": { + "lane0": "0x2", + "lane1": "0x2", + "lane2": "0x3", + "lane3": "0x3", + "lane4": "0x2", + "lane5": "0x2", + "lane6": "0x3", + "lane7": "0x2" + } + }, + "Default": { + "main": { + "lane0": "0x59", + "lane1": "0x59", + "lane2": "0x59", + "lane3": "0x59" + }, + "post1": { + "lane0": "-0x1d", + "lane1": "-0x1d", + "lane2": "-0x1d", + "lane3": "-0x1d" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "post3": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "pre1": { + "lane0": "-0x8", + "lane1": "-0x8", + "lane2": "-0x8", + "lane3": "-0x8" + }, + "pre2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + } + } + }, + "10": { + "QSFP-DD-sm_media_interface": { + "main": { + "lane0": "0x94", + "lane1": "0x88", + "lane2": "0x8b", + "lane3": "0x8b", + "lane4": "0x94", + "lane5": "0x88", + "lane6": "0x8b", + "lane7": "0x94" + }, + "post1": { + "lane0": "-0x3", + "lane1": "-0xe", + "lane2": "-0x7", + "lane3": "-0x7", + "lane4": "-0x3", + "lane5": "-0xe", + "lane6": "-0x7", + "lane7": "-0x3" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "-0x2", + "lane3": "-0x2", + "lane4": "0x0", + "lane5": "0x0", + "lane6": "-0x2", + "lane7": "0x0" + }, + "post3": { + "lane0": "-0x1", + "lane1": "-0x4", + "lane2": "-0x3", + "lane3": "-0x3", + "lane4": "-0x1", + "lane5": "-0x4", + "lane6": "-0x3", + "lane7": "-0x1" + }, + "pre1": { + "lane0": "-0x10", + "lane1": "-0xe", + "lane2": "-0x10", + "lane3": "-0x10", + "lane4": "-0x10", + "lane5": "-0xe", + "lane6": "-0x10", + "lane7": "-0x10" + }, + "pre2": { + "lane0": "0x2", + "lane1": "0x2", + "lane2": "0x3", + "lane3": "0x3", + "lane4": "0x2", + "lane5": "0x2", + "lane6": "0x3", + "lane7": "0x2" + } + }, + "Default": { + "main": { + "lane0": "0x55", + "lane1": "0x4e", + "lane2": "0x4b", + "lane3": "0x53" + }, + "post1": { + "lane0": "-0x15", + "lane1": "-0x16", + "lane2": "-0x14", + "lane3": "-0x16" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "post3": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "pre1": { + "lane0": "-0x6", + "lane1": "-0x5", + "lane2": "-0x5", + "lane3": "-0x5" + }, + "pre2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + } + } + }, + "11": { + "QSFP-DD-sm_media_interface": { + "main": { + "lane0": "0x94", + "lane1": "0x94", + "lane2": "0x88", + "lane3": "0x8b", + "lane4": "0x88", + "lane5": "0x8b", + "lane6": "0x88", + "lane7": "0x94" + }, + "post1": { + "lane0": "-0x3", + "lane1": "-0x3", + "lane2": "-0xe", + "lane3": "-0x7", + "lane4": "-0xe", + "lane5": "-0x7", + "lane6": "-0xe", + "lane7": "-0x3" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "-0x2", + "lane4": "0x0", + "lane5": "-0x2", + "lane6": "0x0", + "lane7": "0x0" + }, + "post3": { + "lane0": "-0x1", + "lane1": "-0x1", + "lane2": "-0x4", + "lane3": "-0x3", + "lane4": "-0x4", + "lane5": "-0x3", + "lane6": "-0x4", + "lane7": "-0x1" + }, + "pre1": { + "lane0": "-0x10", + "lane1": "-0x10", + "lane2": "-0xe", + "lane3": "-0x10", + "lane4": "-0xe", + "lane5": "-0x10", + "lane6": "-0xe", + "lane7": "-0x10" + }, + "pre2": { + "lane0": "0x2", + "lane1": "0x2", + "lane2": "0x2", + "lane3": "0x3", + "lane4": "0x2", + "lane5": "0x3", + "lane6": "0x2", + "lane7": "0x2" + } + }, + "Default": { + "main": { + "lane0": "0x4b", + "lane1": "0x4b", + "lane2": "0x59", + "lane3": "0x59" + }, + "post1": { + "lane0": "-0x15", + "lane1": "-0x15", + "lane2": "-0x1d", + "lane3": "-0x1d" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "post3": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "pre1": { + "lane0": "-0x4", + "lane1": "-0x4", + "lane2": "-0x8", + "lane3": "-0x8" + }, + "pre2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + } + } + }, + "12": { + "QSFP-DD-sm_media_interface": { + "main": { + "lane0": "0x94", + "lane1": "0x88", + "lane2": "0x8b", + "lane3": "0x88", + "lane4": "0x94", + "lane5": "0x8b", + "lane6": "0x8b", + "lane7": "0x88" + }, + "post1": { + "lane0": "-0x3", + "lane1": "-0xe", + "lane2": "-0x7", + "lane3": "-0xe", + "lane4": "-0x3", + "lane5": "-0x7", + "lane6": "-0x7", + "lane7": "-0xe" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "-0x2", + "lane3": "0x0", + "lane4": "0x0", + "lane5": "-0x2", + "lane6": "-0x2", + "lane7": "0x0" + }, + "post3": { + "lane0": "-0x1", + "lane1": "-0x4", + "lane2": "-0x3", + "lane3": "-0x4", + "lane4": "-0x1", + "lane5": "-0x3", + "lane6": "-0x3", + "lane7": "-0x4" + }, + "pre1": { + "lane0": "-0x10", + "lane1": "-0xe", + "lane2": "-0x10", + "lane3": "-0xe", + "lane4": "-0x10", + "lane5": "-0x10", + "lane6": "-0x10", + "lane7": "-0xe" + }, + "pre2": { + "lane0": "0x2", + "lane1": "0x2", + "lane2": "0x3", + "lane3": "0x2", + "lane4": "0x2", + "lane5": "0x3", + "lane6": "0x3", + "lane7": "0x2" + } + }, + "Default": { + "main": { + "lane0": "0x55", + "lane1": "0x53", + "lane2": "0x55", + "lane3": "0x53" + }, + "post1": { + "lane0": "-0x15", + "lane1": "-0x16", + "lane2": "-0x15", + "lane3": "-0x16" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "post3": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "pre1": { + "lane0": "-0x6", + "lane1": "-0x5", + "lane2": "-0x6", + "lane3": "-0x5" + }, + "pre2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + } + } + }, + "13": { + "QSFP-DD-sm_media_interface": { + "main": { + "lane0": "0x94", + "lane1": "0x88", + "lane2": "0x8b", + "lane3": "0x8b", + "lane4": "0x94", + "lane5": "0x88", + "lane6": "0x8b", + "lane7": "0x94" + }, + "post1": { + "lane0": "-0x3", + "lane1": "-0xe", + "lane2": "-0x7", + "lane3": "-0x7", + "lane4": "-0x3", + "lane5": "-0xe", + "lane6": "-0x7", + "lane7": "-0x3" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "-0x2", + "lane3": "-0x2", + "lane4": "0x0", + "lane5": "0x0", + "lane6": "-0x2", + "lane7": "0x0" + }, + "post3": { + "lane0": "-0x1", + "lane1": "-0x4", + "lane2": "-0x3", + "lane3": "-0x3", + "lane4": "-0x1", + "lane5": "-0x4", + "lane6": "-0x3", + "lane7": "-0x1" + }, + "pre1": { + "lane0": "-0x10", + "lane1": "-0xe", + "lane2": "-0x10", + "lane3": "-0x10", + "lane4": "-0x10", + "lane5": "-0xe", + "lane6": "-0x10", + "lane7": "-0x10" + }, + "pre2": { + "lane0": "0x2", + "lane1": "0x2", + "lane2": "0x3", + "lane3": "0x3", + "lane4": "0x2", + "lane5": "0x2", + "lane6": "0x3", + "lane7": "0x2" + } + }, + "Default": { + "main": { + "lane0": "0x4e", + "lane1": "0x4e", + "lane2": "0x53", + "lane3": "0x4b" + }, + "post1": { + "lane0": "-0x16", + "lane1": "-0x16", + "lane2": "-0x16", + "lane3": "-0x14" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "post3": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "pre1": { + "lane0": "-0x5", + "lane1": "-0x5", + "lane2": "-0x5", + "lane3": "-0x5" + }, + "pre2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + } + } + }, + "14": { + "QSFP-DD-sm_media_interface": { + "main": { + "lane0": "0x94", + "lane1": "0x94", + "lane2": "0x88", + "lane3": "0x8b", + "lane4": "0x88", + "lane5": "0x8b", + "lane6": "0x88", + "lane7": "0x94" + }, + "post1": { + "lane0": "-0x3", + "lane1": "-0x3", + "lane2": "-0xe", + "lane3": "-0x7", + "lane4": "-0xe", + "lane5": "-0x7", + "lane6": "-0xe", + "lane7": "-0x3" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "-0x2", + "lane4": "0x0", + "lane5": "-0x2", + "lane6": "0x0", + "lane7": "0x0" + }, + "post3": { + "lane0": "-0x1", + "lane1": "-0x1", + "lane2": "-0x4", + "lane3": "-0x3", + "lane4": "-0x4", + "lane5": "-0x3", + "lane6": "-0x4", + "lane7": "-0x1" + }, + "pre1": { + "lane0": "-0x10", + "lane1": "-0x10", + "lane2": "-0xe", + "lane3": "-0x10", + "lane4": "-0xe", + "lane5": "-0x10", + "lane6": "-0xe", + "lane7": "-0x10" + }, + "pre2": { + "lane0": "0x2", + "lane1": "0x2", + "lane2": "0x2", + "lane3": "0x3", + "lane4": "0x2", + "lane5": "0x3", + "lane6": "0x2", + "lane7": "0x2" + } + }, + "Default": { + "main": { + "lane0": "0x55", + "lane1": "0x55", + "lane2": "0x4b", + "lane3": "0x50" + }, + "post1": { + "lane0": "-0x19", + "lane1": "-0x19", + "lane2": "-0x15", + "lane3": "-0x17" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "post3": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "pre1": { + "lane0": "-0x7", + "lane1": "-0x7", + "lane2": "-0x4", + "lane3": "-0x5" + }, + "pre2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + } + } + }, + "15": { + "QSFP-DD-sm_media_interface": { + "main": { + "lane0": "0x86", + "lane1": "0x88", + "lane2": "0x8b", + "lane3": "0x8d", + "lane4": "0x94", + "lane5": "0x8b", + "lane6": "0x8b", + "lane7": "0x88" + }, + "post1": { + "lane0": "-0xc", + "lane1": "-0xe", + "lane2": "-0x7", + "lane3": "-0x5", + "lane4": "-0x3", + "lane5": "-0x7", + "lane6": "-0x7", + "lane7": "-0xe" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "-0x2", + "lane3": "-0x2", + "lane4": "0x0", + "lane5": "-0x2", + "lane6": "-0x2", + "lane7": "0x0" + }, + "post3": { + "lane0": "-0x5", + "lane1": "-0x4", + "lane2": "-0x3", + "lane3": "-0x3", + "lane4": "-0x1", + "lane5": "-0x3", + "lane6": "-0x3", + "lane7": "-0x4" + }, + "pre1": { + "lane0": "-0x10", + "lane1": "-0xe", + "lane2": "-0x10", + "lane3": "-0x10", + "lane4": "-0x10", + "lane5": "-0x10", + "lane6": "-0x10", + "lane7": "-0xe" + }, + "pre2": { + "lane0": "0x3", + "lane1": "0x2", + "lane2": "0x3", + "lane3": "0x3", + "lane4": "0x2", + "lane5": "0x3", + "lane6": "0x3", + "lane7": "0x2" + } + }, + "Default": { + "main": { + "lane0": "0x4e", + "lane1": "0x53", + "lane2": "0x55", + "lane3": "0x53" + }, + "post1": { + "lane0": "-0x16", + "lane1": "-0x16", + "lane2": "-0x15", + "lane3": "-0x16" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "post3": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "pre1": { + "lane0": "-0x5", + "lane1": "-0x5", + "lane2": "-0x6", + "lane3": "-0x5" + }, + "pre2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + } + } + }, + "16": { + "QSFP-DD-sm_media_interface": { + "main": { + "lane0": "0x94", + "lane1": "0x88", + "lane2": "0x8b", + "lane3": "0x8b", + "lane4": "0x94", + "lane5": "0x88", + "lane6": "0x8b", + "lane7": "0x94" + }, + "post1": { + "lane0": "-0x3", + "lane1": "-0xe", + "lane2": "-0x7", + "lane3": "-0x7", + "lane4": "-0x3", + "lane5": "-0xe", + "lane6": "-0x7", + "lane7": "-0x3" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "-0x2", + "lane3": "-0x2", + "lane4": "0x0", + "lane5": "0x0", + "lane6": "-0x2", + "lane7": "0x0" + }, + "post3": { + "lane0": "-0x1", + "lane1": "-0x4", + "lane2": "-0x3", + "lane3": "-0x3", + "lane4": "-0x1", + "lane5": "-0x4", + "lane6": "-0x3", + "lane7": "-0x1" + }, + "pre1": { + "lane0": "-0x10", + "lane1": "-0xe", + "lane2": "-0x10", + "lane3": "-0x10", + "lane4": "-0x10", + "lane5": "-0xe", + "lane6": "-0x10", + "lane7": "-0x10" + }, + "pre2": { + "lane0": "0x2", + "lane1": "0x2", + "lane2": "0x3", + "lane3": "0x3", + "lane4": "0x2", + "lane5": "0x2", + "lane6": "0x3", + "lane7": "0x2" + } + }, + "Default": { + "main": { + "lane0": "0x55", + "lane1": "0x4b", + "lane2": "0x59", + "lane3": "0x50" + }, + "post1": { + "lane0": "-0x19", + "lane1": "-0x15", + "lane2": "-0x1d", + "lane3": "-0x17" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "post3": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "pre1": { + "lane0": "-0x7", + "lane1": "-0x4", + "lane2": "-0x8", + "lane3": "-0x5" + }, + "pre2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + } + } + }, + "17": { + "QSFP-DD-sm_media_interface": { + "main": { + "lane0": "0x8d", + "lane1": "0x90", + "lane2": "0x89", + "lane3": "0x88", + "lane4": "0x8b", + "lane5": "0x89", + "lane6": "0x8d", + "lane7": "0x90" + }, + "post1": { + "lane0": "-0x5", + "lane1": "-0x1", + "lane2": "-0xc", + "lane3": "-0xe", + "lane4": "-0x7", + "lane5": "-0xc", + "lane6": "-0x5", + "lane7": "-0x1" + }, + "post2": { + "lane0": "-0x2", + "lane1": "-0x3", + "lane2": "0x0", + "lane3": "0x0", + "lane4": "-0x2", + "lane5": "0x0", + "lane6": "-0x2", + "lane7": "-0x3" + }, + "post3": { + "lane0": "-0x3", + "lane1": "-0x3", + "lane2": "-0x3", + "lane3": "-0x4", + "lane4": "-0x3", + "lane5": "-0x3", + "lane6": "-0x3", + "lane7": "-0x3" + }, + "pre1": { + "lane0": "-0x10", + "lane1": "-0x11", + "lane2": "-0x10", + "lane3": "-0xe", + "lane4": "-0x10", + "lane5": "-0x10", + "lane6": "-0x10", + "lane7": "-0x11" + }, + "pre2": { + "lane0": "0x3", + "lane1": "0x2", + "lane2": "0x2", + "lane3": "0x2", + "lane4": "0x3", + "lane5": "0x2", + "lane6": "0x3", + "lane7": "0x2" + } + }, + "Default": { + "main": { + "lane0": "0x53", + "lane1": "0x53", + "lane2": "0x55", + "lane3": "0x55" + }, + "post1": { + "lane0": "-0x16", + "lane1": "-0x16", + "lane2": "-0x15", + "lane3": "-0x15" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "post3": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "pre1": { + "lane0": "-0x5", + "lane1": "-0x5", + "lane2": "-0x6", + "lane3": "-0x6" + }, + "pre2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + } + } + }, + "18": { + "QSFP-DD-sm_media_interface": { + "main": { + "lane0": "0x89", + "lane1": "0x8d", + "lane2": "0x8d", + "lane3": "0x8d", + "lane4": "0x89", + "lane5": "0x8d", + "lane6": "0x89", + "lane7": "0x8d" + }, + "post1": { + "lane0": "-0xc", + "lane1": "-0x5", + "lane2": "-0x8", + "lane3": "-0x8", + "lane4": "-0xc", + "lane5": "-0x5", + "lane6": "-0xc", + "lane7": "-0x5" + }, + "post2": { + "lane0": "0x0", + "lane1": "-0x2", + "lane2": "-0x3", + "lane3": "-0x3", + "lane4": "0x0", + "lane5": "-0x2", + "lane6": "0x0", + "lane7": "-0x2" + }, + "post3": { + "lane0": "-0x3", + "lane1": "-0x3", + "lane2": "-0x1", + "lane3": "-0x1", + "lane4": "-0x3", + "lane5": "-0x3", + "lane6": "-0x3", + "lane7": "-0x3" + }, + "pre1": { + "lane0": "-0x10", + "lane1": "-0x10", + "lane2": "-0xf", + "lane3": "-0xf", + "lane4": "-0x10", + "lane5": "-0x10", + "lane6": "-0x10", + "lane7": "-0x10" + }, + "pre2": { + "lane0": "0x2", + "lane1": "0x3", + "lane2": "0x2", + "lane3": "0x2", + "lane4": "0x2", + "lane5": "0x3", + "lane6": "0x2", + "lane7": "0x3" + } + }, + "Default": { + "main": { + "lane0": "0x4b", + "lane1": "0x59", + "lane2": "0x59", + "lane3": "0x4b" + }, + "post1": { + "lane0": "-0x15", + "lane1": "-0x1d", + "lane2": "-0x1d", + "lane3": "-0x15" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "post3": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "pre1": { + "lane0": "-0x4", + "lane1": "-0x8", + "lane2": "-0x8", + "lane3": "-0x4" + }, + "pre2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + } + } + }, + "19": { + "QSFP-DD-sm_media_interface": { + "main": { + "lane0": "0x89", + "lane1": "0x8d", + "lane2": "0x90", + "lane3": "0x90", + "lane4": "0x89", + "lane5": "0x8d", + "lane6": "0x89", + "lane7": "0x8d" + }, + "post1": { + "lane0": "-0xc", + "lane1": "-0x5", + "lane2": "-0x1", + "lane3": "-0x1", + "lane4": "-0xc", + "lane5": "-0x5", + "lane6": "-0xc", + "lane7": "-0x5" + }, + "post2": { + "lane0": "0x0", + "lane1": "-0x2", + "lane2": "-0x3", + "lane3": "-0x3", + "lane4": "0x0", + "lane5": "-0x2", + "lane6": "0x0", + "lane7": "-0x2" + }, + "post3": { + "lane0": "-0x3", + "lane1": "-0x3", + "lane2": "-0x3", + "lane3": "-0x3", + "lane4": "-0x3", + "lane5": "-0x3", + "lane6": "-0x3", + "lane7": "-0x3" + }, + "pre1": { + "lane0": "-0x10", + "lane1": "-0x10", + "lane2": "-0x11", + "lane3": "-0x11", + "lane4": "-0x10", + "lane5": "-0x10", + "lane6": "-0x10", + "lane7": "-0x10" + }, + "pre2": { + "lane0": "0x2", + "lane1": "0x3", + "lane2": "0x2", + "lane3": "0x2", + "lane4": "0x2", + "lane5": "0x3", + "lane6": "0x2", + "lane7": "0x3" + } + }, + "Default": { + "main": { + "lane0": "0x55", + "lane1": "0x55", + "lane2": "0x50", + "lane3": "0x50" + }, + "post1": { + "lane0": "-0x19", + "lane1": "-0x19", + "lane2": "-0x17", + "lane3": "-0x17" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "post3": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "pre1": { + "lane0": "-0x7", + "lane1": "-0x7", + "lane2": "-0x5", + "lane3": "-0x5" + }, + "pre2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + } + } + }, + "20": { + "QSFP-DD-sm_media_interface": { + "main": { + "lane0": "0x8d", + "lane1": "0x8d", + "lane2": "0x89", + "lane3": "0x8d", + "lane4": "0x8d", + "lane5": "0x89", + "lane6": "0x8d", + "lane7": "0x8d" + }, + "post1": { + "lane0": "-0x5", + "lane1": "-0x8", + "lane2": "-0xc", + "lane3": "-0x5", + "lane4": "-0x8", + "lane5": "-0xc", + "lane6": "-0x5", + "lane7": "-0x8" + }, + "post2": { + "lane0": "-0x2", + "lane1": "-0x3", + "lane2": "0x0", + "lane3": "-0x2", + "lane4": "-0x3", + "lane5": "0x0", + "lane6": "-0x2", + "lane7": "-0x3" + }, + "post3": { + "lane0": "-0x3", + "lane1": "-0x1", + "lane2": "-0x3", + "lane3": "-0x3", + "lane4": "-0x1", + "lane5": "-0x3", + "lane6": "-0x3", + "lane7": "-0x1" + }, + "pre1": { + "lane0": "-0x10", + "lane1": "-0xf", + "lane2": "-0x10", + "lane3": "-0x10", + "lane4": "-0xf", + "lane5": "-0x10", + "lane6": "-0x10", + "lane7": "-0xf" + }, + "pre2": { + "lane0": "0x3", + "lane1": "0x2", + "lane2": "0x2", + "lane3": "0x3", + "lane4": "0x2", + "lane5": "0x2", + "lane6": "0x3", + "lane7": "0x2" + } + }, + "Default": { + "main": { + "lane0": "0x4b", + "lane1": "0x4b", + "lane2": "0x4e", + "lane3": "0x4e" + }, + "post1": { + "lane0": "-0x14", + "lane1": "-0x14", + "lane2": "-0x16", + "lane3": "-0x16" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "post3": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "pre1": { + "lane0": "-0x5", + "lane1": "-0x5", + "lane2": "-0x5", + "lane3": "-0x5" + }, + "pre2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + } + } + }, + "21": { + "QSFP-DD-sm_media_interface": { + "main": { + "lane0": "0x94", + "lane1": "0x88", + "lane2": "0x8b", + "lane3": "0x8b", + "lane4": "0x94", + "lane5": "0x88", + "lane6": "0x8b", + "lane7": "0x89" + }, + "post1": { + "lane0": "-0x3", + "lane1": "-0xe", + "lane2": "-0x7", + "lane3": "-0x7", + "lane4": "-0x3", + "lane5": "-0xe", + "lane6": "-0x7", + "lane7": "-0xc" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "-0x2", + "lane3": "-0x2", + "lane4": "0x0", + "lane5": "0x0", + "lane6": "-0x2", + "lane7": "0x0" + }, + "post3": { + "lane0": "-0x1", + "lane1": "-0x4", + "lane2": "-0x3", + "lane3": "-0x3", + "lane4": "-0x1", + "lane5": "-0x4", + "lane6": "-0x3", + "lane7": "-0x3" + }, + "pre1": { + "lane0": "-0x10", + "lane1": "-0xe", + "lane2": "-0x10", + "lane3": "-0x10", + "lane4": "-0x10", + "lane5": "-0xe", + "lane6": "-0x10", + "lane7": "-0x10" + }, + "pre2": { + "lane0": "0x2", + "lane1": "0x2", + "lane2": "0x3", + "lane3": "0x3", + "lane4": "0x2", + "lane5": "0x2", + "lane6": "0x3", + "lane7": "0x2" + } + }, + "Default": { + "main": { + "lane0": "0x50", + "lane1": "0x50", + "lane2": "0x55", + "lane3": "0x55" + }, + "post1": { + "lane0": "-0x17", + "lane1": "-0x17", + "lane2": "-0x19", + "lane3": "-0x19" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "post3": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "pre1": { + "lane0": "-0x5", + "lane1": "-0x5", + "lane2": "-0x7", + "lane3": "-0x7" + }, + "pre2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + } + } + }, + "22": { + "QSFP-DD-sm_media_interface": { + "main": { + "lane0": "0x89", + "lane1": "0x88", + "lane2": "0x8b", + "lane3": "0x88", + "lane4": "0x94", + "lane5": "0x8b", + "lane6": "0x8b", + "lane7": "0x88" + }, + "post1": { + "lane0": "-0xc", + "lane1": "-0xe", + "lane2": "-0x7", + "lane3": "-0xe", + "lane4": "-0x3", + "lane5": "-0x7", + "lane6": "-0x7", + "lane7": "-0xe" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "-0x2", + "lane3": "0x0", + "lane4": "0x0", + "lane5": "-0x2", + "lane6": "-0x2", + "lane7": "0x0" + }, + "post3": { + "lane0": "-0x3", + "lane1": "-0x4", + "lane2": "-0x3", + "lane3": "-0x4", + "lane4": "-0x1", + "lane5": "-0x3", + "lane6": "-0x3", + "lane7": "-0x4" + }, + "pre1": { + "lane0": "-0x10", + "lane1": "-0xe", + "lane2": "-0x10", + "lane3": "-0xe", + "lane4": "-0x10", + "lane5": "-0x10", + "lane6": "-0x10", + "lane7": "-0xe" + }, + "pre2": { + "lane0": "0x2", + "lane1": "0x2", + "lane2": "0x3", + "lane3": "0x2", + "lane4": "0x2", + "lane5": "0x3", + "lane6": "0x3", + "lane7": "0x2" + } + }, + "Default": { + "main": { + "lane0": "0x59", + "lane1": "0x59", + "lane2": "0x59", + "lane3": "0x59" + }, + "post1": { + "lane0": "-0x1d", + "lane1": "-0x1d", + "lane2": "-0x1d", + "lane3": "-0x1d" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "post3": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "pre1": { + "lane0": "-0x8", + "lane1": "-0x8", + "lane2": "-0x8", + "lane3": "-0x8" + }, + "pre2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + } + } + }, + "23": { + "QSFP-DD-sm_media_interface": { + "main": { + "lane0": "0x94", + "lane1": "0x94", + "lane2": "0x88", + "lane3": "0x8b", + "lane4": "0x88", + "lane5": "0x8b", + "lane6": "0x88", + "lane7": "0x94" + }, + "post1": { + "lane0": "-0x3", + "lane1": "-0x3", + "lane2": "-0xe", + "lane3": "-0x7", + "lane4": "-0xe", + "lane5": "-0x7", + "lane6": "-0xe", + "lane7": "-0x3" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "-0x2", + "lane4": "0x0", + "lane5": "-0x2", + "lane6": "0x0", + "lane7": "0x0" + }, + "post3": { + "lane0": "-0x1", + "lane1": "-0x1", + "lane2": "-0x4", + "lane3": "-0x3", + "lane4": "-0x4", + "lane5": "-0x3", + "lane6": "-0x4", + "lane7": "-0x1" + }, + "pre1": { + "lane0": "-0x10", + "lane1": "-0x10", + "lane2": "-0xe", + "lane3": "-0x10", + "lane4": "-0xe", + "lane5": "-0x10", + "lane6": "-0xe", + "lane7": "-0x10" + }, + "pre2": { + "lane0": "0x2", + "lane1": "0x2", + "lane2": "0x2", + "lane3": "0x3", + "lane4": "0x2", + "lane5": "0x3", + "lane6": "0x2", + "lane7": "0x2" + } + }, + "Default": { + "main": { + "lane0": "0x59", + "lane1": "0x59", + "lane2": "0x59", + "lane3": "0x59" + }, + "post1": { + "lane0": "-0x1d", + "lane1": "-0x1d", + "lane2": "-0x1d", + "lane3": "-0x1d" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "post3": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "pre1": { + "lane0": "-0x8", + "lane1": "-0x8", + "lane2": "-0x8", + "lane3": "-0x8" + }, + "pre2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + } + } + }, + "24": { + "QSFP-DD-sm_media_interface": { + "main": { + "lane0": "0x94", + "lane1": "0x88", + "lane2": "0x8b", + "lane3": "0x8b", + "lane4": "0x94", + "lane5": "0x88", + "lane6": "0x8b", + "lane7": "0x94" + }, + "post1": { + "lane0": "-0x3", + "lane1": "-0xe", + "lane2": "-0x7", + "lane3": "-0x7", + "lane4": "-0x3", + "lane5": "-0xe", + "lane6": "-0x7", + "lane7": "-0x3" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "-0x2", + "lane3": "-0x2", + "lane4": "0x0", + "lane5": "0x0", + "lane6": "-0x2", + "lane7": "0x0" + }, + "post3": { + "lane0": "-0x1", + "lane1": "-0x4", + "lane2": "-0x3", + "lane3": "-0x3", + "lane4": "-0x1", + "lane5": "-0x4", + "lane6": "-0x3", + "lane7": "-0x1" + }, + "pre1": { + "lane0": "-0x10", + "lane1": "-0xe", + "lane2": "-0x10", + "lane3": "-0x10", + "lane4": "-0x10", + "lane5": "-0xe", + "lane6": "-0x10", + "lane7": "-0x10" + }, + "pre2": { + "lane0": "0x2", + "lane1": "0x2", + "lane2": "0x3", + "lane3": "0x3", + "lane4": "0x2", + "lane5": "0x2", + "lane6": "0x3", + "lane7": "0x2" + } + }, + "Default": { + "main": { + "lane0": "0x59", + "lane1": "0x59", + "lane2": "0x59", + "lane3": "0x59" + }, + "post1": { + "lane0": "-0x1d", + "lane1": "-0x1d", + "lane2": "-0x1d", + "lane3": "-0x1d" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "post3": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "pre1": { + "lane0": "-0x8", + "lane1": "-0x8", + "lane2": "-0x8", + "lane3": "-0x8" + }, + "pre2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + } + } + }, + "25": { + "QSFP-DD-sm_media_interface": { + "main": { + "lane0": "0x94", + "lane1": "0x88", + "lane2": "0x8b", + "lane3": "0x88", + "lane4": "0x94", + "lane5": "0x8b", + "lane6": "0x8b", + "lane7": "0x88" + }, + "post1": { + "lane0": "-0x3", + "lane1": "-0xe", + "lane2": "-0x7", + "lane3": "-0xe", + "lane4": "-0x3", + "lane5": "-0x7", + "lane6": "-0x7", + "lane7": "-0xe" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "-0x2", + "lane3": "0x0", + "lane4": "0x0", + "lane5": "-0x2", + "lane6": "-0x2", + "lane7": "0x0" + }, + "post3": { + "lane0": "-0x1", + "lane1": "-0x4", + "lane2": "-0x3", + "lane3": "-0x4", + "lane4": "-0x1", + "lane5": "-0x3", + "lane6": "-0x3", + "lane7": "-0x4" + }, + "pre1": { + "lane0": "-0x10", + "lane1": "-0xe", + "lane2": "-0x10", + "lane3": "-0xe", + "lane4": "-0x10", + "lane5": "-0x10", + "lane6": "-0x10", + "lane7": "-0xe" + }, + "pre2": { + "lane0": "0x2", + "lane1": "0x2", + "lane2": "0x3", + "lane3": "0x2", + "lane4": "0x2", + "lane5": "0x3", + "lane6": "0x3", + "lane7": "0x2" + } + }, + "Default": { + "main": { + "lane0": "0x59", + "lane1": "0x59", + "lane2": "0x59", + "lane3": "0x59" + }, + "post1": { + "lane0": "-0x1d", + "lane1": "-0x1d", + "lane2": "-0x1d", + "lane3": "-0x1d" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "post3": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "pre1": { + "lane0": "-0x8", + "lane1": "-0x8", + "lane2": "-0x8", + "lane3": "-0x8" + }, + "pre2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + } + } + }, + "26": { + "QSFP-DD-sm_media_interface": { + "main": { + "lane0": "0x94", + "lane1": "0x94", + "lane2": "0x88", + "lane3": "0x8b", + "lane4": "0x88", + "lane5": "0x8b", + "lane6": "0x88", + "lane7": "0x94" + }, + "post1": { + "lane0": "-0x3", + "lane1": "-0x3", + "lane2": "-0xe", + "lane3": "-0x7", + "lane4": "-0xe", + "lane5": "-0x7", + "lane6": "-0xe", + "lane7": "-0x3" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "-0x2", + "lane4": "0x0", + "lane5": "-0x2", + "lane6": "0x0", + "lane7": "0x0" + }, + "post3": { + "lane0": "-0x1", + "lane1": "-0x1", + "lane2": "-0x4", + "lane3": "-0x3", + "lane4": "-0x4", + "lane5": "-0x3", + "lane6": "-0x4", + "lane7": "-0x1" + }, + "pre1": { + "lane0": "-0x10", + "lane1": "-0x10", + "lane2": "-0xe", + "lane3": "-0x10", + "lane4": "-0xe", + "lane5": "-0x10", + "lane6": "-0xe", + "lane7": "-0x10" + }, + "pre2": { + "lane0": "0x2", + "lane1": "0x2", + "lane2": "0x2", + "lane3": "0x3", + "lane4": "0x2", + "lane5": "0x3", + "lane6": "0x2", + "lane7": "0x2" + } + }, + "Default": { + "main": { + "lane0": "0x59", + "lane1": "0x59", + "lane2": "0x59", + "lane3": "0x59" + }, + "post1": { + "lane0": "-0x1d", + "lane1": "-0x1d", + "lane2": "-0x1d", + "lane3": "-0x1d" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "post3": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "pre1": { + "lane0": "-0x8", + "lane1": "-0x8", + "lane2": "-0x8", + "lane3": "-0x8" + }, + "pre2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + } + } + }, + "27": { + "QSFP-DD-sm_media_interface": { + "main": { + "lane0": "0x94", + "lane1": "0x88", + "lane2": "0x8b", + "lane3": "0x8b", + "lane4": "0x94", + "lane5": "0x88", + "lane6": "0x8b", + "lane7": "0x94" + }, + "post1": { + "lane0": "-0x3", + "lane1": "-0xe", + "lane2": "-0x7", + "lane3": "-0x7", + "lane4": "-0x3", + "lane5": "-0xe", + "lane6": "-0x7", + "lane7": "-0x3" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "-0x2", + "lane3": "-0x2", + "lane4": "0x0", + "lane5": "0x0", + "lane6": "-0x2", + "lane7": "0x0" + }, + "post3": { + "lane0": "-0x1", + "lane1": "-0x4", + "lane2": "-0x3", + "lane3": "-0x3", + "lane4": "-0x1", + "lane5": "-0x4", + "lane6": "-0x3", + "lane7": "-0x1" + }, + "pre1": { + "lane0": "-0x10", + "lane1": "-0xe", + "lane2": "-0x10", + "lane3": "-0x10", + "lane4": "-0x10", + "lane5": "-0xe", + "lane6": "-0x10", + "lane7": "-0x10" + }, + "pre2": { + "lane0": "0x2", + "lane1": "0x2", + "lane2": "0x3", + "lane3": "0x3", + "lane4": "0x2", + "lane5": "0x2", + "lane6": "0x3", + "lane7": "0x2" + } + }, + "Default": { + "main": { + "lane0": "0x59", + "lane1": "0x59", + "lane2": "0x59", + "lane3": "0x59" + }, + "post1": { + "lane0": "-0x1d", + "lane1": "-0x1d", + "lane2": "-0x1d", + "lane3": "-0x1d" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "post3": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "pre1": { + "lane0": "-0x8", + "lane1": "-0x8", + "lane2": "-0x8", + "lane3": "-0x8" + }, + "pre2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + } + } + }, + "28": { + "QSFP-DD-sm_media_interface": { + "main": { + "lane0": "0x94", + "lane1": "0x88", + "lane2": "0x8b", + "lane3": "0x8b", + "lane4": "0x94", + "lane5": "0x88", + "lane6": "0x8b", + "lane7": "0x94" + }, + "post1": { + "lane0": "-0x3", + "lane1": "-0xe", + "lane2": "-0x7", + "lane3": "-0x7", + "lane4": "-0x3", + "lane5": "-0xe", + "lane6": "-0x7", + "lane7": "-0x3" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "-0x2", + "lane3": "-0x2", + "lane4": "0x0", + "lane5": "0x0", + "lane6": "-0x2", + "lane7": "0x0" + }, + "post3": { + "lane0": "-0x1", + "lane1": "-0x4", + "lane2": "-0x3", + "lane3": "-0x3", + "lane4": "-0x1", + "lane5": "-0x4", + "lane6": "-0x3", + "lane7": "-0x1" + }, + "pre1": { + "lane0": "-0x10", + "lane1": "-0xe", + "lane2": "-0x10", + "lane3": "-0x10", + "lane4": "-0x10", + "lane5": "-0xe", + "lane6": "-0x10", + "lane7": "-0x10" + }, + "pre2": { + "lane0": "0x2", + "lane1": "0x2", + "lane2": "0x3", + "lane3": "0x3", + "lane4": "0x2", + "lane5": "0x2", + "lane6": "0x3", + "lane7": "0x2" + } + }, + "Default": { + "main": { + "lane0": "0x4e", + "lane1": "0x4e", + "lane2": "0x4b", + "lane3": "0x4b" + }, + "post1": { + "lane0": "-0x16", + "lane1": "-0x16", + "lane2": "-0x14", + "lane3": "-0x14" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "post3": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "pre1": { + "lane0": "-0x5", + "lane1": "-0x5", + "lane2": "-0x5", + "lane3": "-0x5" + }, + "pre2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + } + } + }, + "29": { + "QSFP-DD-sm_media_interface": { + "main": { + "lane0": "0x94", + "lane1": "0x94", + "lane2": "0x88", + "lane3": "0x8b", + "lane4": "0x88", + "lane5": "0x8b", + "lane6": "0x88", + "lane7": "0x94" + }, + "post1": { + "lane0": "-0x3", + "lane1": "-0x3", + "lane2": "-0xe", + "lane3": "-0x7", + "lane4": "-0xe", + "lane5": "-0x7", + "lane6": "-0xe", + "lane7": "-0x3" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "-0x2", + "lane4": "0x0", + "lane5": "-0x2", + "lane6": "0x0", + "lane7": "0x0" + }, + "post3": { + "lane0": "-0x1", + "lane1": "-0x1", + "lane2": "-0x4", + "lane3": "-0x3", + "lane4": "-0x4", + "lane5": "-0x3", + "lane6": "-0x4", + "lane7": "-0x1" + }, + "pre1": { + "lane0": "-0x10", + "lane1": "-0x10", + "lane2": "-0xe", + "lane3": "-0x10", + "lane4": "-0xe", + "lane5": "-0x10", + "lane6": "-0xe", + "lane7": "-0x10" + }, + "pre2": { + "lane0": "0x2", + "lane1": "0x2", + "lane2": "0x2", + "lane3": "0x3", + "lane4": "0x2", + "lane5": "0x3", + "lane6": "0x2", + "lane7": "0x2" + } + }, + "Default": { + "main": { + "lane0": "0x4b", + "lane1": "0x50", + "lane2": "0x55", + "lane3": "0x59" + }, + "post1": { + "lane0": "-0x15", + "lane1": "-0x17", + "lane2": "-0x19", + "lane3": "-0x1d" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "post3": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "pre1": { + "lane0": "-0x4", + "lane1": "-0x5", + "lane2": "-0x7", + "lane3": "-0x8" + }, + "pre2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + } + } + }, + "30": { + "QSFP-DD-sm_media_interface": { + "main": { + "lane0": "0x94", + "lane1": "0x88", + "lane2": "0x8b", + "lane3": "0x88", + "lane4": "0x94", + "lane5": "0x8b", + "lane6": "0x8b", + "lane7": "0x88" + }, + "post1": { + "lane0": "-0x3", + "lane1": "-0xe", + "lane2": "-0x7", + "lane3": "-0xe", + "lane4": "-0x3", + "lane5": "-0x7", + "lane6": "-0x7", + "lane7": "-0xe" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "-0x2", + "lane3": "0x0", + "lane4": "0x0", + "lane5": "-0x2", + "lane6": "-0x2", + "lane7": "0x0" + }, + "post3": { + "lane0": "-0x1", + "lane1": "-0x4", + "lane2": "-0x3", + "lane3": "-0x4", + "lane4": "-0x1", + "lane5": "-0x3", + "lane6": "-0x3", + "lane7": "-0x4" + }, + "pre1": { + "lane0": "-0x10", + "lane1": "-0xe", + "lane2": "-0x10", + "lane3": "-0xe", + "lane4": "-0x10", + "lane5": "-0x10", + "lane6": "-0x10", + "lane7": "-0xe" + }, + "pre2": { + "lane0": "0x2", + "lane1": "0x2", + "lane2": "0x3", + "lane3": "0x2", + "lane4": "0x2", + "lane5": "0x3", + "lane6": "0x3", + "lane7": "0x2" + } + }, + "Default": { + "main": { + "lane0": "0x4e", + "lane1": "0x53", + "lane2": "0x4e", + "lane3": "0x4b" + }, + "post1": { + "lane0": "-0x16", + "lane1": "-0x16", + "lane2": "-0x16", + "lane3": "-0x14" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "post3": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "pre1": { + "lane0": "-0x5", + "lane1": "-0x5", + "lane2": "-0x5", + "lane3": "-0x5" + }, + "pre2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + } + } + }, + "31": { + "QSFP-DD-sm_media_interface": { + "main": { + "lane0": "0x94", + "lane1": "0x88", + "lane2": "0x8b", + "lane3": "0x8b", + "lane4": "0x94", + "lane5": "0x88", + "lane6": "0x8b", + "lane7": "0x94" + }, + "post1": { + "lane0": "-0x3", + "lane1": "-0xe", + "lane2": "-0x7", + "lane3": "-0x7", + "lane4": "-0x3", + "lane5": "-0xe", + "lane6": "-0x7", + "lane7": "-0x3" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "-0x2", + "lane3": "-0x2", + "lane4": "0x0", + "lane5": "0x0", + "lane6": "-0x2", + "lane7": "0x0" + }, + "post3": { + "lane0": "-0x1", + "lane1": "-0x4", + "lane2": "-0x3", + "lane3": "-0x3", + "lane4": "-0x1", + "lane5": "-0x4", + "lane6": "-0x3", + "lane7": "-0x1" + }, + "pre1": { + "lane0": "-0x10", + "lane1": "-0xe", + "lane2": "-0x10", + "lane3": "-0x10", + "lane4": "-0x10", + "lane5": "-0xe", + "lane6": "-0x10", + "lane7": "-0x10" + }, + "pre2": { + "lane0": "0x2", + "lane1": "0x2", + "lane2": "0x3", + "lane3": "0x3", + "lane4": "0x2", + "lane5": "0x2", + "lane6": "0x3", + "lane7": "0x2" + } + }, + "Default": { + "main": { + "lane0": "0x4e", + "lane1": "0x4e", + "lane2": "0x4b", + "lane3": "0x4b" + }, + "post1": { + "lane0": "-0x16", + "lane1": "-0x16", + "lane2": "-0x14", + "lane3": "-0x14" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "post3": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "pre1": { + "lane0": "-0x5", + "lane1": "-0x5", + "lane2": "-0x5", + "lane3": "-0x5" + }, + "pre2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + } + } + }, + "32": { + "QSFP-DD-sm_media_interface": { + "main": { + "lane0": "0x94", + "lane1": "0x94", + "lane2": "0x88", + "lane3": "0x8b", + "lane4": "0x88", + "lane5": "0x8b", + "lane6": "0x88", + "lane7": "0x94" + }, + "post1": { + "lane0": "-0x3", + "lane1": "-0x3", + "lane2": "-0xe", + "lane3": "-0x7", + "lane4": "-0xe", + "lane5": "-0x7", + "lane6": "-0xe", + "lane7": "-0x3" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "-0x2", + "lane4": "0x0", + "lane5": "-0x2", + "lane6": "0x0", + "lane7": "0x0" + }, + "post3": { + "lane0": "-0x1", + "lane1": "-0x1", + "lane2": "-0x4", + "lane3": "-0x3", + "lane4": "-0x4", + "lane5": "-0x3", + "lane6": "-0x4", + "lane7": "-0x1" + }, + "pre1": { + "lane0": "-0x10", + "lane1": "-0x10", + "lane2": "-0xe", + "lane3": "-0x10", + "lane4": "-0xe", + "lane5": "-0x10", + "lane6": "-0xe", + "lane7": "-0x10" + }, + "pre2": { + "lane0": "0x2", + "lane1": "0x2", + "lane2": "0x2", + "lane3": "0x3", + "lane4": "0x2", + "lane5": "0x3", + "lane6": "0x2", + "lane7": "0x2" + } + }, + "Default": { + "main": { + "lane0": "0x55", + "lane1": "0x55", + "lane2": "0x50", + "lane3": "0x50" + }, + "post1": { + "lane0": "-0x19", + "lane1": "-0x19", + "lane2": "-0x17", + "lane3": "-0x17" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "post3": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "pre1": { + "lane0": "-0x7", + "lane1": "-0x7", + "lane2": "-0x5", + "lane3": "-0x5" + }, + "pre2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + } + } + }, + "33": { + "QSFP-DD-sm_media_interface": { + "main": { + "lane0": "0x94", + "lane1": "0x88", + "lane2": "0x8b", + "lane3": "0x88", + "lane4": "0x94", + "lane5": "0x8b", + "lane6": "0x8b", + "lane7": "0x88" + }, + "post1": { + "lane0": "-0x3", + "lane1": "-0xe", + "lane2": "-0x7", + "lane3": "-0xe", + "lane4": "-0x3", + "lane5": "-0x7", + "lane6": "-0x7", + "lane7": "-0xe" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "-0x2", + "lane3": "0x0", + "lane4": "0x0", + "lane5": "-0x2", + "lane6": "-0x2", + "lane7": "0x0" + }, + "post3": { + "lane0": "-0x1", + "lane1": "-0x4", + "lane2": "-0x3", + "lane3": "-0x4", + "lane4": "-0x1", + "lane5": "-0x3", + "lane6": "-0x3", + "lane7": "-0x4" + }, + "pre1": { + "lane0": "-0x10", + "lane1": "-0xe", + "lane2": "-0x10", + "lane3": "-0xe", + "lane4": "-0x10", + "lane5": "-0x10", + "lane6": "-0x10", + "lane7": "-0xe" + }, + "pre2": { + "lane0": "0x2", + "lane1": "0x2", + "lane2": "0x3", + "lane3": "0x2", + "lane4": "0x2", + "lane5": "0x3", + "lane6": "0x3", + "lane7": "0x2" + } + }, + "Default": { + "main": { + "lane0": "0x4e", + "lane1": "0x4b", + "lane2": "0x4e", + "lane3": "0x4b" + }, + "post1": { + "lane0": "-0x16", + "lane1": "-0x14", + "lane2": "-0x16", + "lane3": "-0x14" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "post3": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "pre1": { + "lane0": "-0x5", + "lane1": "-0x5", + "lane2": "-0x5", + "lane3": "-0x5" + }, + "pre2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + } + } + }, + "34": { + "QSFP-DD-sm_media_interface": { + "main": { + "lane0": "0x89", + "lane1": "0x88", + "lane2": "0x8b", + "lane3": "0x8d", + "lane4": "0x94", + "lane5": "0x8d", + "lane6": "0x81", + "lane7": "0x94" + }, + "post1": { + "lane0": "-0xc", + "lane1": "-0xe", + "lane2": "-0x7", + "lane3": "-0x8", + "lane4": "-0x3", + "lane5": "-0x5", + "lane6": "-0xf", + "lane7": "-0x3" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "-0x2", + "lane3": "-0x3", + "lane4": "0x0", + "lane5": "-0x2", + "lane6": "-0x3", + "lane7": "0x0" + }, + "post3": { + "lane0": "-0x3", + "lane1": "-0x4", + "lane2": "-0x3", + "lane3": "-0x1", + "lane4": "-0x1", + "lane5": "-0x3", + "lane6": "-0x2", + "lane7": "-0x1" + }, + "pre1": { + "lane0": "-0x10", + "lane1": "-0xe", + "lane2": "-0x10", + "lane3": "-0xf", + "lane4": "-0x10", + "lane5": "-0x10", + "lane6": "-0x12", + "lane7": "-0x10" + }, + "pre2": { + "lane0": "0x2", + "lane1": "0x2", + "lane2": "0x3", + "lane3": "0x2", + "lane4": "0x2", + "lane5": "0x3", + "lane6": "0x3", + "lane7": "0x2" + } + }, + "Default": { + "main": { + "lane0": "0x55", + "lane1": "0x50", + "lane2": "0x55", + "lane3": "0x50" + }, + "post1": { + "lane0": "-0x19", + "lane1": "-0x17", + "lane2": "-0x19", + "lane3": "-0x17" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "post3": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "pre1": { + "lane0": "-0x7", + "lane1": "-0x5", + "lane2": "-0x7", + "lane3": "-0x5" + }, + "pre2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + } + } + }, + "35": { + "QSFP-DD-sm_media_interface": { + "main": { + "lane0": "0x8d", + "lane1": "0x90", + "lane2": "0x89", + "lane3": "0x8d", + "lane4": "0x90", + "lane5": "0x89", + "lane6": "0x8d", + "lane7": "0x90" + }, + "post1": { + "lane0": "-0x5", + "lane1": "-0x1", + "lane2": "-0xc", + "lane3": "-0x5", + "lane4": "-0x1", + "lane5": "-0xc", + "lane6": "-0x5", + "lane7": "-0x1" + }, + "post2": { + "lane0": "-0x2", + "lane1": "-0x3", + "lane2": "0x0", + "lane3": "-0x2", + "lane4": "-0x3", + "lane5": "0x0", + "lane6": "-0x2", + "lane7": "-0x3" + }, + "post3": { + "lane0": "-0x3", + "lane1": "-0x3", + "lane2": "-0x3", + "lane3": "-0x3", + "lane4": "-0x3", + "lane5": "-0x3", + "lane6": "-0x3", + "lane7": "-0x3" + }, + "pre1": { + "lane0": "-0x10", + "lane1": "-0x11", + "lane2": "-0x10", + "lane3": "-0x10", + "lane4": "-0x11", + "lane5": "-0x10", + "lane6": "-0x10", + "lane7": "-0x11" + }, + "pre2": { + "lane0": "0x3", + "lane1": "0x2", + "lane2": "0x2", + "lane3": "0x3", + "lane4": "0x2", + "lane5": "0x2", + "lane6": "0x3", + "lane7": "0x2" + } + }, + "Default": { + "main": { + "lane0": "0x4b", + "lane1": "0x4b", + "lane2": "0x4e", + "lane3": "0x4e" + }, + "post1": { + "lane0": "-0x14", + "lane1": "-0x14", + "lane2": "-0x16", + "lane3": "-0x16" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "post3": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "pre1": { + "lane0": "-0x5", + "lane1": "-0x5", + "lane2": "-0x5", + "lane3": "-0x5" + }, + "pre2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + } + } + }, + "36": { + "QSFP-DD-sm_media_interface": { + "main": { + "lane0": "0x89", + "lane1": "0x8d", + "lane2": "0x8d", + "lane3": "0x8d", + "lane4": "0x89", + "lane5": "0x8d", + "lane6": "0x89", + "lane7": "0x8d" + }, + "post1": { + "lane0": "-0xc", + "lane1": "-0x5", + "lane2": "-0x8", + "lane3": "-0x8", + "lane4": "-0xc", + "lane5": "-0x5", + "lane6": "-0xc", + "lane7": "-0x5" + }, + "post2": { + "lane0": "0x0", + "lane1": "-0x2", + "lane2": "-0x3", + "lane3": "-0x3", + "lane4": "0x0", + "lane5": "-0x2", + "lane6": "0x0", + "lane7": "-0x2" + }, + "post3": { + "lane0": "-0x3", + "lane1": "-0x3", + "lane2": "-0x1", + "lane3": "-0x1", + "lane4": "-0x3", + "lane5": "-0x3", + "lane6": "-0x3", + "lane7": "-0x3" + }, + "pre1": { + "lane0": "-0x10", + "lane1": "-0x10", + "lane2": "-0xf", + "lane3": "-0xf", + "lane4": "-0x10", + "lane5": "-0x10", + "lane6": "-0x10", + "lane7": "-0x10" + }, + "pre2": { + "lane0": "0x2", + "lane1": "0x3", + "lane2": "0x2", + "lane3": "0x2", + "lane4": "0x2", + "lane5": "0x3", + "lane6": "0x2", + "lane7": "0x3" + } + }, + "Default": { + "main": { + "lane0": "0x50", + "lane1": "0x55", + "lane2": "0x55", + "lane3": "0x50" + }, + "post1": { + "lane0": "-0x17", + "lane1": "-0x19", + "lane2": "-0x19", + "lane3": "-0x17" + }, + "post2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "post3": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + }, + "pre1": { + "lane0": "-0x5", + "lane1": "-0x7", + "lane2": "-0x7", + "lane3": "-0x5" + }, + "pre2": { + "lane0": "0x0", + "lane1": "0x0", + "lane2": "0x0", + "lane3": "0x0" + } + } + } + } +} diff --git a/device/arista/x86_64-arista_7800r3a_36d2_lc/platform.json b/device/arista/x86_64-arista_7800r3a_36d2_lc/platform.json new file mode 100644 index 000000000000..2c91765fcfd1 --- /dev/null +++ b/device/arista/x86_64-arista_7800r3a_36d2_lc/platform.json @@ -0,0 +1,140 @@ +{ + "chassis": { + "name": "7800R3A-36DM2-LC", + "components": [ + { + "name": "Aboot()" + }, + { + "name": "Scd(addr=0000:00:18.7)" + }, + { + "name": "Scd(addr=0000:08:00.0)" + } + ], + "fans": [], + "fan_drawers": [], + "psus": [], + "thermals": [ + { + "name": "Cpu temp sensor", + "controllable": false + }, + { + "name": "Cpu SBTSI", + "controllable": false + } + ], + "sfps": [ + { + "name": "osfp1" + }, + { + "name": "osfp2" + }, + { + "name": "osfp3" + }, + { + "name": "osfp4" + }, + { + "name": "osfp5" + }, + { + "name": "osfp6" + }, + { + "name": "osfp7" + }, + { + "name": "osfp8" + }, + { + "name": "osfp9" + }, + { + "name": "osfp10" + }, + { + "name": "osfp11" + }, + { + "name": "osfp12" + }, + { + "name": "osfp13" + }, + { + "name": "osfp14" + }, + { + "name": "osfp15" + }, + { + "name": "osfp16" + }, + { + "name": "osfp17" + }, + { + "name": "osfp18" + }, + { + "name": "osfp19" + }, + { + "name": "osfp20" + }, + { + "name": "osfp21" + }, + { + "name": "osfp22" + }, + { + "name": "osfp23" + }, + { + "name": "osfp24" + }, + { + "name": "osfp25" + }, + { + "name": "osfp26" + }, + { + "name": "osfp27" + }, + { + "name": "osfp28" + }, + { + "name": "osfp29" + }, + { + "name": "osfp30" + }, + { + "name": "osfp31" + }, + { + "name": "osfp32" + }, + { + "name": "osfp33" + }, + { + "name": "osfp34" + }, + { + "name": "osfp35" + }, + { + "name": "osfp36" + } + ] + }, + "interfaces": {} +} diff --git a/device/arista/x86_64-arista_7800r3a_36d2_lc/platform_components.json b/device/arista/x86_64-arista_7800r3a_36d2_lc/platform_components.json new file mode 100644 index 000000000000..9666c8e0b0cc --- /dev/null +++ b/device/arista/x86_64-arista_7800r3a_36d2_lc/platform_components.json @@ -0,0 +1,11 @@ +{ + "chassis": { + "7800R3A-36DM2-LC": { + "component": { + "Aboot()": {}, + "Scd(addr=0000:00:18.7)": {}, + "Scd(addr=0000:08:00.0)": {} + } + } + } +} diff --git a/device/broadcom/x86_64-broadcom_common/syncd_shm.ini b/device/broadcom/x86_64-broadcom_common/syncd_shm.ini new file mode 100644 index 000000000000..07a68ca0f3ea --- /dev/null +++ b/device/broadcom/x86_64-broadcom_common/syncd_shm.ini @@ -0,0 +1,14 @@ +# This file contains the default memory size for each ASICs in broadcom platform +# Format: ASIC_ID=Memory_size +#b77->td3 +b77=256m +#b85->td2 +b85=256m +#b87->td3 +b87=512m +#b96->th +b96=256m +#b97->th2 +b97=256m +#b98->th3 +b98=300m diff --git a/device/celestica/x86_64-cel_belgite-r0/CELESTICA-BELGITE/hwsku.json b/device/celestica/x86_64-cel_belgite-r0/CELESTICA-BELGITE/hwsku.json new file mode 100644 index 000000000000..160d768bde98 --- /dev/null +++ b/device/celestica/x86_64-cel_belgite-r0/CELESTICA-BELGITE/hwsku.json @@ -0,0 +1,284 @@ +{ + "interfaces": { + "Ethernet0": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet1": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet2": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet3": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet4": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet5": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet6": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet7": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet8": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet9": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet10": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet11": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet12": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet13": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet14": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet15": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet16": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet17": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet18": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet19": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet20": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet21": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet22": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet23": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet24": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet25": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet26": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet27": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet28": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet29": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet30": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet31": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet32": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet33": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet34": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet35": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet36": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet37": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet38": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet39": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet40": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet41": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet42": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet43": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet44": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet45": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet46": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet47": { + "default_brkout_mode": "1x1000[100,10]", + "autoneg": "on", + "fec": "none" + }, + "Ethernet48": { + "default_brkout_mode": "1x10G[1G]", + "autoneg": "off", + "fec": "none" + }, + "Ethernet49": { + "default_brkout_mode": "1x10G[1G]", + "autoneg": "off", + "fec": "none" + }, + "Ethernet50": { + "default_brkout_mode": "1x10G[1G]", + "autoneg": "off", + "fec": "none" + }, + "Ethernet51": { + "default_brkout_mode": "1x10G[1G]", + "autoneg": "off", + "fec": "none" + }, + "Ethernet52": { + "default_brkout_mode": "1x10G[1G]", + "autoneg": "off", + "fec": "none" + }, + "Ethernet53": { + "default_brkout_mode": "1x10G[1G]", + "autoneg": "off", + "fec": "none" + }, + "Ethernet54": { + "default_brkout_mode": "1x10G[1G]", + "autoneg": "off", + "fec": "none" + }, + "Ethernet55": { + "default_brkout_mode": "1x10G[1G]", + "autoneg": "off", + "fec": "none" + } + } +} \ No newline at end of file diff --git a/device/celestica/x86_64-cel_belgite-r0/led-source-code/cmicx/custom_led.c b/device/celestica/x86_64-cel_belgite-r0/led-source-code/cmicx/custom_led.c index 92fe25f5b898..712b5503e34b 100755 --- a/device/celestica/x86_64-cel_belgite-r0/led-source-code/cmicx/custom_led.c +++ b/device/celestica/x86_64-cel_belgite-r0/led-source-code/cmicx/custom_led.c @@ -105,7 +105,7 @@ unsigned short portmap[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, - 58, 60, 57, 59, 64, 62, 63, 61 + 60, 58, 59, 57, 62, 64, 61, 63 }; diff --git a/device/celestica/x86_64-cel_belgite-r0/led_proc_init.soc b/device/celestica/x86_64-cel_belgite-r0/led_proc_init.soc index f7192c5b081c..57ee7fedaf2b 100644 --- a/device/celestica/x86_64-cel_belgite-r0/led_proc_init.soc +++ b/device/celestica/x86_64-cel_belgite-r0/led_proc_init.soc @@ -1,3 +1,3 @@ m0 load 0 0x3800 /usr/share/sonic/platform/custom_led.bin +led auto on led start - diff --git a/device/celestica/x86_64-cel_belgite-r0/pddf/pd-plugin.json b/device/celestica/x86_64-cel_belgite-r0/pddf/pd-plugin.json index 05d724f3622b..454afd239964 100644 --- a/device/celestica/x86_64-cel_belgite-r0/pddf/pd-plugin.json +++ b/device/celestica/x86_64-cel_belgite-r0/pddf/pd-plugin.json @@ -5,7 +5,7 @@ { "i2c": { - "valmap-SFP28": {"1":false, "0":true } + "valmap-SFP+": {"1":false, "0":true } } } }, @@ -29,7 +29,7 @@ { "i2c": { - "valmap": { "F2B":"INTAKE", "B2F":"EXHAUST" } + "valmap": { "0":"INTAKE", "1":"EXHAUST" } } }, "PSU_FAN_MAX_SPEED":"18000" @@ -50,10 +50,6 @@ "valmap": {"1":false, "0":true} } }, - "fan_master_led_color": - { - "colmap": {"green":"green", "red":"amber"} - }, "duty_cycle_to_pwm": "lambda dc: dc*255/100", "pwm_to_duty_cycle": "lambda pwm: pwm/255*100" diff --git a/device/celestica/x86_64-cel_belgite-r0/pddf/pddf-device.json b/device/celestica/x86_64-cel_belgite-r0/pddf/pddf-device.json index 7ccbd41fffea..a97102c1f4cb 100644 --- a/device/celestica/x86_64-cel_belgite-r0/pddf/pddf-device.json +++ b/device/celestica/x86_64-cel_belgite-r0/pddf/pddf-device.json @@ -179,7 +179,7 @@ { "attr_name":"psu_v_out", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0x8b", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, { "attr_name":"psu_i_out", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0x8c", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, { "attr_name":"psu_p_out", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0x96", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, - { "attr_name":"psu_fan_dir", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0xc5", "attr_mask":"0x18", "attr_cmpval":"0x08", "attr_len":"1"}, + { "attr_name":"psu_fan_dir", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0x80", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"1"}, { "attr_name":"psu_fan1_speed_rpm", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0x90", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, { "attr_name":"psu_temp1_input", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0x8d", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"} ] @@ -215,7 +215,7 @@ { "attr_name":"psu_v_out", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x8b", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, { "attr_name":"psu_i_out", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x8c", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, { "attr_name":"psu_p_out", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x96", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, - { "attr_name":"psu_fan_dir", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0xc5", "attr_mask":"0x18", "attr_cmpval":"0x08", "attr_len":"1"}, + { "attr_name":"psu_fan_dir", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x80", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"1"}, { "attr_name":"psu_fan1_speed_rpm", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x90", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, { "attr_name":"psu_temp1_input", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x8d", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"} ] @@ -283,7 +283,7 @@ }, "PORT49": { - "dev_info": { "device_type":"SFP28", "device_name":"PORT49", "device_parent":"MUX2"}, + "dev_info": { "device_type":"SFP+", "device_name":"PORT49", "device_parent":"MUX2"}, "dev_attr": { "dev_idx":"49"}, "i2c": { @@ -324,7 +324,7 @@ }, "PORT50": { - "dev_info": { "device_type":"SFP28", "device_name":"PORT50", "device_parent":"MUX2"}, + "dev_info": { "device_type":"SFP+", "device_name":"PORT50", "device_parent":"MUX2"}, "dev_attr": { "dev_idx":"50"}, "i2c": { @@ -366,7 +366,7 @@ }, "PORT51": { - "dev_info": { "device_type":"SFP28", "device_name":"PORT51", "device_parent":"MUX2"}, + "dev_info": { "device_type":"SFP+", "device_name":"PORT51", "device_parent":"MUX2"}, "dev_attr": { "dev_idx":"51"}, "i2c": { @@ -407,7 +407,7 @@ }, "PORT52": { - "dev_info": { "device_type":"SFP28", "device_name":"PORT52", "device_parent":"MUX2"}, + "dev_info": { "device_type":"SFP+", "device_name":"PORT52", "device_parent":"MUX2"}, "dev_attr": { "dev_idx":"52"}, "i2c": { @@ -449,7 +449,7 @@ }, "PORT53": { - "dev_info": { "device_type":"SFP28", "device_name":"PORT53", "device_parent":"MUX2"}, + "dev_info": { "device_type":"SFP+", "device_name":"PORT53", "device_parent":"MUX2"}, "dev_attr": { "dev_idx":"53"}, "i2c": { @@ -491,7 +491,7 @@ }, "PORT54": { - "dev_info": { "device_type":"SFP28", "device_name":"PORT54", "device_parent":"MUX2"}, + "dev_info": { "device_type":"SFP+", "device_name":"PORT54", "device_parent":"MUX2"}, "dev_attr": { "dev_idx":"54"}, "i2c": { @@ -532,7 +532,7 @@ }, "PORT55": { - "dev_info": { "device_type":"SFP28", "device_name":"PORT55", "device_parent":"MUX2"}, + "dev_info": { "device_type":"SFP+", "device_name":"PORT55", "device_parent":"MUX2"}, "dev_attr": { "dev_idx":"55"}, "i2c": { @@ -573,7 +573,7 @@ }, "PORT56": { - "dev_info": { "device_type":"SFP28", "device_name":"PORT56", "device_parent":"MUX2"}, + "dev_info": { "device_type":"SFP+", "device_name":"PORT56", "device_parent":"MUX2"}, "dev_attr": { "dev_idx":"56"}, "i2c": { @@ -642,7 +642,7 @@ [ {"attr_name":"STATUS_LED_COLOR_AMBER","swpld_addr":"0x32","attr_devtype":"cpld","attr_devname":"CPLD1", "bits":"5:4","descr":"","value":"0x1","swpld_addr_offset":"0x43"}, {"attr_name":"STATUS_LED_COLOR_GREEN","swpld_addr":"0x32","attr_devtype":"cpld","attr_devname":"CPLD1", "bits":"5:4","descr":"","value":"0x2","swpld_addr_offset":"0x43"}, - {"attr_name":"STATUS_LED_COLOR_OFF","swpld_addr":"0x32","attr_devtype":"cpld","attr_devname":"CPLD1", "bits":"5:4","descr":"","value":"0x0","swpld_addr_offset":"0x43"} + {"attr_name":"STATUS_LED_COLOR_OFF","swpld_addr":"0x32","attr_devtype":"cpld","attr_devname":"CPLD1", "bits":"5:4","descr":"","value":"0x3","swpld_addr_offset":"0x43"} ] } }, @@ -666,7 +666,7 @@ "attr_list": [ {"attr_name":"STATUS_LED_COLOR_GREEN","attr_devtype":"cpld","attr_devname":"CPLD1","bits":"1:0","descr":"","value":"0x1","swpld_addr":"0x32","swpld_addr_offset":"0x37"}, - {"attr_name":"STATUS_LED_COLOR_AMBER","attr_devtype":"cpld","attr_devname":"CPLD1B","bits":"1:0","descr":"","value":"0x2","swpld_addr":"0x32","swpld_addr_offset":"0x37"} + {"attr_name":"STATUS_LED_COLOR_AMBER","attr_devtype":"cpld","attr_devname":"CPLD1","bits":"1:0","descr":"","value":"0x2","swpld_addr":"0x32","swpld_addr_offset":"0x37"} ] } }, diff --git a/device/celestica/x86_64-cel_belgite-r0/platform.json b/device/celestica/x86_64-cel_belgite-r0/platform.json index 1d4a1f9e3420..0e40fe8a88fa 100644 --- a/device/celestica/x86_64-cel_belgite-r0/platform.json +++ b/device/celestica/x86_64-cel_belgite-r0/platform.json @@ -11,10 +11,7 @@ "name": "SWCPLD" }, { - "name": "Main_BIOS" - }, - { - "name": "Backup_BIOS" + "name": "BIOS" } ], "fans": [ @@ -391,5 +388,398 @@ } ] }, - "interfaces": {} + "interfaces": { + "Ethernet0": { + "index": "1", + "lanes": "26", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/1"] + } + }, + "Ethernet1": { + "index": "2", + "lanes": "25", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/2"] + } + }, + "Ethernet2": { + "index": "3", + "lanes": "28", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/3"] + } + }, + "Ethernet3": { + "index": "4", + "lanes": "27", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/4"] + } + }, + "Ethernet4": { + "index": "5", + "lanes": "30", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/5"] + } + }, + "Ethernet5": { + "index": "6", + "lanes": "29", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/6"] + } + }, + "Ethernet6": { + "index": "7", + "lanes": "32", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/7"] + } + }, + "Ethernet7": { + "index": "8", + "lanes": "31", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/8"] + } + }, + "Ethernet8": { + "index": "9", + "lanes": "34", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/9"] + } + }, + "Ethernet9": { + "index": "10", + "lanes": "33", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/10"] + } + }, + "Ethernet10": { + "index": "11", + "lanes": "36", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/11"] + } + }, + "Ethernet11": { + "index": "12", + "lanes": "35", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/12"] + } + }, + "Ethernet12": { + "index": "13", + "lanes": "38", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/13"] + } + }, + "Ethernet13": { + "index": "14", + "lanes": "37", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/14"] + } + }, + "Ethernet14": { + "index": "15", + "lanes": "40", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/15"] + } + }, + "Ethernet15": { + "index": "16", + "lanes": "39", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/16"] + } + }, + "Ethernet16": { + "index": "17", + "lanes": "42", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/17"] + } + }, + "Ethernet17": { + "index": "18", + "lanes": "41", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/18"] + } + }, + "Ethernet18": { + "index": "19", + "lanes": "44", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/19"] + } + }, + "Ethernet19": { + "index": "20", + "lanes": "43", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/20"] + } + }, + "Ethernet20": { + "index": "21", + "lanes": "50", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/21"] + } + }, + "Ethernet21": { + "index": "22", + "lanes": "49", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/22"] + } + }, + "Ethernet22": { + "index": "23", + "lanes": "52", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/23"] + } + }, + "Ethernet23": { + "index": "24", + "lanes": "51", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/24"] + } + }, + "Ethernet24": { + "index": "25", + "lanes": "2", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/25"] + } + }, + "Ethernet25": { + "index": "26", + "lanes": "1", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/26"] + } + }, + "Ethernet26": { + "index": "27", + "lanes": "4", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/27"] + } + }, + "Ethernet27": { + "index": "28", + "lanes": "3", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/28"] + } + }, + "Ethernet28": { + "index": "29", + "lanes": "6", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/29"] + } + }, + "Ethernet29": { + "index": "30", + "lanes": "5", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/30"] + } + }, + "Ethernet30": { + "index": "31", + "lanes": "8", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/31"] + } + }, + "Ethernet31": { + "index": "32", + "lanes": "7", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/32"] + } + }, + "Ethernet32": { + "index": "33", + "lanes": "10", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/33"] + } + }, + "Ethernet33": { + "index": "34", + "lanes": "9", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/34"] + } + }, + "Ethernet34": { + "index": "35", + "lanes": "12", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/35"] + } + }, + "Ethernet35": { + "index": "36", + "lanes": "11", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/36"] + } + }, + "Ethernet36": { + "index": "37", + "lanes": "14", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/37"] + } + }, + "Ethernet37": { + "index": "38", + "lanes": "13", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/38"] + } + }, + "Ethernet38": { + "index": "39", + "lanes": "16", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/39"] + } + }, + "Ethernet39": { + "index": "40", + "lanes": "15", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/40"] + } + }, + "Ethernet40": { + "index": "41", + "lanes": "18", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/41"] + } + }, + "Ethernet41": { + "index": "42", + "lanes": "17", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/42"] + } + }, + "Ethernet42": { + "index": "43", + "lanes": "20", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/43"] + } + }, + "Ethernet43": { + "index": "44", + "lanes": "19", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/44"] + } + }, + "Ethernet44": { + "index": "45", + "lanes": "22", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/45"] + } + }, + "Ethernet45": { + "index": "46", + "lanes": "21", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/46"] + } + }, + "Ethernet46": { + "index": "47", + "lanes": "24", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/47"] + } + }, + "Ethernet47": { + "index": "48", + "lanes": "23", + "breakout_modes": { + "1x1000[100,10]": ["Ethernet1/0/48"] + } + }, + "Ethernet48": { + "index": "49", + "lanes": "60", + "breakout_modes": { + "1x10G[1G]": ["Ethernet1/0/49"] + } + }, + "Ethernet49": { + "index": "50", + "lanes": "58", + "breakout_modes": { + "1x10G[1G]": ["Ethernet1/0/50"] + } + }, + "Ethernet50": { + "index": "51", + "lanes": "59", + "breakout_modes": { + "1x10G[1G]": ["Ethernet1/0/51"] + } + }, + "Ethernet51": { + "index": "52", + "lanes": "57", + "breakout_modes": { + "1x10G[1G]": ["Ethernet1/0/52"] + } + }, + "Ethernet52": { + "index": "53", + "lanes": "62", + "breakout_modes": { + "1x10G[1G]": ["Ethernet1/0/53"] + } + }, + "Ethernet53": { + "index": "54", + "lanes": "64", + "breakout_modes": { + "1x10G[1G]": ["Ethernet1/0/54"] + } + }, + "Ethernet54": { + "index": "55", + "lanes": "61", + "breakout_modes": { + "1x10G[1G]": ["Ethernet1/0/55"] + } + }, + "Ethernet55": { + "index": "56", + "lanes": "63", + "breakout_modes": { + "1x10G[1G]": ["Ethernet1/0/56"] + } + } + } } diff --git a/device/celestica/x86_64-cel_belgite-r0/platform_components.json b/device/celestica/x86_64-cel_belgite-r0/platform_components.json new file mode 100644 index 000000000000..23a4ce41cd67 --- /dev/null +++ b/device/celestica/x86_64-cel_belgite-r0/platform_components.json @@ -0,0 +1,10 @@ +{ + "chassis": { + "E1070": { + "component": { + "SWCPLD": {}, + "BIOS": {} + } + } + } +} diff --git a/device/celestica/x86_64-cel_belgite-r0/plugins/psuutil.py b/device/celestica/x86_64-cel_belgite-r0/plugins/psuutil.py new file mode 100644 index 000000000000..056a3f1b179c --- /dev/null +++ b/device/celestica/x86_64-cel_belgite-r0/plugins/psuutil.py @@ -0,0 +1,78 @@ +# +# psuutil.py +# Platform-specific PSU status interface for SONiC +# + +import os + +try: + from sonic_psu.psu_base import PsuBase +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +class PsuUtil(PsuBase): + """Platform-specific PSUutil class""" + + def __init__(self): + PsuBase.__init__(self) + + def get_num_psus(self): + """ + Retrieves the number of PSUs available on the device + :return: An integer, the number of PSUs available on the device + """ + return 2 + + def get_psu_status(self, index): + """ + Retrieves the oprational status of power supply unit (PSU) defined + by 1-based index + :param index: An integer, 1-based index of the PSU of which to query status + :return: Boolean, True if PSU is operating properly, False if PSU is faulty + """ + if index is None: + return False + + if index == 1: + status_path = "/sys/devices/pci0000:00/0000:00:12.0/i2c-0/i2c-4/4-0058/psu_power_good" + elif index == 2: + status_path = "/sys/devices/pci0000:00/0000:00:12.0/i2c-0/i2c-4/4-0059/psu_power_good" + else: + return False + + try: + with open(status_path, 'r') as fd: + status = fd.read().rstrip('\r\n') + if status == '0': + return True + else: + return False + except IOError: + return False + + def get_psu_presence(self, index): + """ + Retrieves the presence status of power supply unit (PSU) defined + by 1-based index + :param index: An integer, 1-based index of the PSU of which to query status + :return: Boolean, True if PSU is plugged, False if not + """ + if index is None: + return False + + if index == 1: + status_path = "/sys/devices/pci0000:00/0000:00:12.0/i2c-0/i2c-4/4-0058/psu_present" + elif index == 2: + status_path = "/sys/devices/pci0000:00/0000:00:12.0/i2c-0/i2c-4/4-0059/psu_present" + else: + return False + + try: + with open(status_path, 'r') as fd: + status = fd.read().rstrip('\r\n') + if status == '1': + return True + else: + return False + except IOError: + return False diff --git a/device/celestica/x86_64-cel_belgite-r0/plugins/sfputil.py b/device/celestica/x86_64-cel_belgite-r0/plugins/sfputil.py new file mode 100644 index 000000000000..d938bf4c1a26 --- /dev/null +++ b/device/celestica/x86_64-cel_belgite-r0/plugins/sfputil.py @@ -0,0 +1,142 @@ +# Platform-specific SFP transceiver interface for SONiC +# + +try: + import time + from sonic_sfp.sfputilbase import SfpUtilBase +except ImportError as e: + raise ImportError("%s - required module not found" % str(e)) + + +class SfpUtil(SfpUtilBase): + """Platform-specific SfpUtil class""" + + PORT_START = 1 + PORT_END = 56 + SFP_PORT_START = 49 + SFP_PORT_END = 56 + SFP_I2C_BUS_START = 0xa + PORTS_IN_BLOCK = 56 + + _port_to_eeprom_mapping = {} + sfp_status_dict = {} + + @property + def port_start(self): + return self.PORT_START + + @property + def port_end(self): + return self.PORT_END + + @property + def qsfp_ports(self): + return list(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): + # Override port_to_eeprom_mapping for class initialization + eeprom_path = '/sys/bus/i2c/devices/i2c-{0}/{0}-0050/eeprom' + + for port_idx in range(self.SFP_PORT_START, self.SFP_PORT_END + 1): + self._port_to_eeprom_mapping[port_idx] = eeprom_path.format(self.SFP_I2C_BUS_START + (port_idx - self.SFP_PORT_START)) + self.sfp_status_dict[port_idx] = 0 #Initialize all modules as absent/removed + SfpUtilBase.__init__(self) + + def get_presence(self, port_num): + # Check for invalid port_num + if port_num < self.SFP_PORT_START or port_num > self.SFP_PORT_END: + return False + + sfp_status_path = "/sys/devices/pci0000:00/0000:00:12.0/i2c-0/i2c-9/i2c-{0}/{0}-0066/xcvr_present"\ + .format(self.SFP_I2C_BUS_START + (port_num - self.SFP_PORT_START)) + try: + with open(sfp_status_path, 'r') as fd: + status = fd.read().rstrip('\r\n') + if status == '0': + return True + else: + return False + except IOError as e: + print("Error: unable to open file: %s" % str(e)) + return False + + return False + + def get_low_power_mode(self, port_num): + # Check for invalid port_num + if port_num < self.SFP_PORT_START or port_num > self.SFP_PORT_END: + return False + + sfp_lpmode_path = "/sys/devices/pci0000:00/0000:00:12.0/i2c-0/i2c-9/i2c-{0}/{0}-0066/xcvr_lpmode"\ + .format(self.SFP_I2C_BUS_START + (port_num - self.SFP_PORT_START)) + try: + with open(sfp_lpmode_path, 'r') as fd: + status = fd.read().rstrip('\r\n') + if status == '1': + return True + else: + return False + except IOError as e: + print("Error: unable to open file: %s" % str(e)) + return False + + return False + + def set_low_power_mode(self, port_num, lpmode): + # Check for invalid port_num + if port_num < self.SFP_PORT_START or port_num > self.SFP_PORT_END: + return False + + sfp_lpmode_path = "/sys/devices/pci0000:00/0000:00:12.0/i2c-0/i2c-9/i2c-{0}/{0}-0066/xcvr_lpmode"\ + .format(self.SFP_I2C_BUS_START + (port_num - self.SFP_PORT_START)) + try: + with open(sfp_lpmode_path, 'w') as fd: + if lpmode: + fd.write('1') + else: + fd.write('0') + + return True + except IOError as e: + print("Error: unable to open file: %s" % str(e)) + return False + + return False + + def reset(self, port_num): + # SFP reset is not supported + return False + + def get_transceiver_change_event(self, timeout=0): + sfp_dict = {} + + SFP_REMOVED = '0' + SFP_INSERTED = '1' + + SFP_PRESENT = True + SFP_ABSENT = False + + start_time = time.time() + time_period = timeout/float(1000) #Convert msecs to secs + + while time.time() < (start_time + time_period) or timeout == 0: + for port_idx in range(self.SFP_PORT_START, self.SFP_PORT_END + 1): + if self.sfp_status_dict[port_idx] == SFP_REMOVED and \ + self.get_presence(port_idx) == SFP_PRESENT: + sfp_dict[str(port_idx)] = SFP_INSERTED + self.sfp_status_dict[port_idx] = SFP_INSERTED + elif self.sfp_status_dict[port_idx] == SFP_INSERTED and \ + self.get_presence(port_idx) == SFP_ABSENT: + sfp_dict[str(port_idx)] = SFP_REMOVED + self.sfp_status_dict[port_idx] = SFP_REMOVED + + if sfp_dict != {}: + return (True, {'sfp':sfp_dict}) + + time.sleep(0.5) + + return (True, {}) # Timeout diff --git a/device/celestica/x86_64-cel_belgite-r0/pmon_daemon_control.json b/device/celestica/x86_64-cel_belgite-r0/pmon_daemon_control.json index 689def2c1e25..32250390cde4 100644 --- a/device/celestica/x86_64-cel_belgite-r0/pmon_daemon_control.json +++ b/device/celestica/x86_64-cel_belgite-r0/pmon_daemon_control.json @@ -1,4 +1,6 @@ { "skip_ledd": true, - "skip_pcied": true + "skip_pcied": true, + "skip_fancontrol": true, + "skip_xcvrd_cmis_mgr": true } diff --git a/device/celestica/x86_64-cel_belgite-r0/system_health_monitoring_config.json b/device/celestica/x86_64-cel_belgite-r0/system_health_monitoring_config.json index 4dc38d035ab4..28b3e30a6699 100644 --- a/device/celestica/x86_64-cel_belgite-r0/system_health_monitoring_config.json +++ b/device/celestica/x86_64-cel_belgite-r0/system_health_monitoring_config.json @@ -3,14 +3,14 @@ "devices_to_ignore": [ "asic", "psu.temperature", - "PSU2 Fan", - "PSU1 Fan" + "PSU1_FAN1", + "PSU2_FAN1" ], "user_defined_checkers": [], "polling_interval": 60, "led_color": { - "fault": "orange", + "fault": "amber", "normal": "green", "booting": "orange_blink" } -} \ No newline at end of file +} diff --git a/device/celestica/x86_64-cel_seastone-r0/platform.json b/device/celestica/x86_64-cel_seastone-r0/platform.json index 6c874fcfcc53..a3778ae81aef 100644 --- a/device/celestica/x86_64-cel_seastone-r0/platform.json +++ b/device/celestica/x86_64-cel_seastone-r0/platform.json @@ -1,6 +1,10 @@ { "chassis": { - "name": "Celestica-DX010-C32", + "name": "DX010", + "status_led": { + "controllable": true, + "colors": ["green", "off"] + }, "components": [ { "name": "CPLD1" @@ -14,95 +18,238 @@ { "name": "CPLD4" }, + { + "name": "CPLD5" + }, { "name": "BIOS" } ], "fans": [ { - "name": "FAN-1F" - }, - { - "name": "FAN-1R" - }, - { - "name": "FAN-2F" - }, - { - "name": "FAN-2R" - }, - { - "name": "FAN-3F" - }, - { - "name": "FAN-3R" - }, - { - "name": "FAN-4F" - }, - { - "name": "FAN-4R" - }, - { - "name": "FAN-5F" - }, - { - "name": "FAN-5R" + "name": "FAN-1F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-1R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-2F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-2R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-3F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-3R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-4F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-4R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-5F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-5R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } } ], "fan_drawers": [ { "name": "Drawer1", + "status_led": { + "controllable": true, + "colors": ["red", "green", "amber", "off"] + }, "fans": [ { - "name": "FAN-1F" + "name": "FAN-1F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } }, { - "name": "FAN-1R" + "name": "FAN-1R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } } ] }, { "name": "Drawer2", + "status_led": { + "controllable": true, + "colors": ["red", "green", "amber", "off"] + }, "fans": [ { - "name": "FAN-2F" + "name": "FAN-2F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } }, { - "name": "FAN-2R" + "name": "FAN-2R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } } ] }, { "name": "Drawer3", + "status_led": { + "controllable": true, + "colors": ["red", "green", "amber", "off"] + }, "fans": [ { - "name": "FAN-3F" + "name": "FAN-3F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } }, { - "name": "FAN-3R" + "name": "FAN-3R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } } ] }, { "name": "Drawer4", + "status_led": { + "controllable": true, + "colors": ["red", "green", "amber", "off"] + }, "fans": [ { - "name": "FAN-4F" + "name": "FAN-4F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } }, { - "name": "FAN-4R" + "name": "FAN-4R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } } ] }, { "name": "Drawer5", + "status_led": { + "controllable": true, + "colors": ["red", "green", "amber", "off"] + }, "fans": [ { - "name": "FAN-5F" + "name": "FAN-5F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } }, { - "name": "FAN-5R" + "name": "FAN-5R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } } ] } @@ -110,36 +257,60 @@ "psus": [ { "name": "PSU-1", + "status_led": { + "controllable": true, + "colors": ["green", "off"] + }, "fans": [ { - "name": "PSU-1 FAN-1" + "name": "PSU-1 FAN-1", + "speed": { + "controllable": false + } } ] }, { "name": "PSU-2", + "status_led": { + "controllable": true, + "colors": ["green", "off"] + }, "fans": [ { - "name": "PSU-2 FAN-1" + "name": "PSU-2 FAN-1", + "speed": { + "controllable": false + } } ] } ], "thermals": [ { - "name": "Front-panel temp sensor 1" + "name": "Front-panel temp sensor 1", + "controllable": false, + "low-crit-threshold": false }, { - "name": "Front-panel temp sensor 2" + "name": "Front-panel temp sensor 2", + "controllable": false, + "low-crit-threshold": false }, { - "name": "ASIC temp sensor" + "name": "ASIC temp sensor", + "controllable": false, + "low-crit-threshold": false }, { - "name": "Rear-panel temp sensor 1" + "name": "Rear-panel temp sensor 1", + "controllable": false, + "low-crit-threshold": false }, { - "name": "Rear-panel temp sensor 2" + "name": "Rear-panel temp sensor 2", + "controllable": false, + "low-crit-threshold": false } ], "sfps": [ diff --git a/device/celestica/x86_64-cel_seastone-r0/platform_components.json b/device/celestica/x86_64-cel_seastone-r0/platform_components.json index cd89d358d46f..1574e1bd2c38 100644 --- a/device/celestica/x86_64-cel_seastone-r0/platform_components.json +++ b/device/celestica/x86_64-cel_seastone-r0/platform_components.json @@ -1,13 +1,14 @@ { "chassis": { - "Celestica-DX010-C32": { + "DX010": { "component": { "CPLD1": {}, "CPLD2": {}, "CPLD3": {}, "CPLD4": {}, + "CPLD5": {}, "BIOS": {} } } } -} \ No newline at end of file +} 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 8a9ed17139df..51da9c2353fb 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 @@ -20,7 +20,7 @@ NUM_PSU = 2 NUM_THERMAL = 5 NUM_SFP = 32 -NUM_COMPONENT = 5 +NUM_COMPONENT = 6 RESET_REGISTER = "0x103" HOST_REBOOT_CAUSE_PATH = "/host/reboot-cause/" REBOOT_CAUSE_FILE = "reboot-cause.txt" @@ -44,6 +44,7 @@ def __init__(self): self.__initialize_psu() self.__initialize_thermals() self.__initialize_components() + self.__initialize_system_led() def __initialize_sfp(self): sfputil_helper = SfpUtilHelper() @@ -86,6 +87,9 @@ def __initialize_components(self): component = Component(index) self._component_list.append(component) + def __initialize_system_led(self): + self.set_status_led(self.STATUS_LED_COLOR_GREEN) + def __get_air_flow(self): air_flow_path = '/usr/share/sonic/device/{}/fan_airflow'.format( self._api_helper.platform) \ @@ -266,7 +270,7 @@ def get_name(self): Returns: string: The name of the device """ - return self._api_helper.hwsku + return self._eeprom.get_product_name() def get_presence(self): """ @@ -317,6 +321,14 @@ def is_replaceable(self): """ return False + def initizalize_system_led(self): + """ + This function is not defined in chassis base class, + system-health command would invoke chassis.initizalize_system_led(), + add this stub function just to let the command sucessfully execute + """ + pass + def set_status_led(self, color): """ Sets the state of the PSU status LED @@ -345,7 +357,7 @@ def get_status_led(self): """ status = self._api_helper.read_txt_file(STATUS_LED_PATH) status_str = { - '255': self.STATUS_LED_COLOR_GREEN, + '1': self.STATUS_LED_COLOR_GREEN, '0': self.STATUS_LED_COLOR_OFF }.get(status, None) diff --git a/device/celestica/x86_64-cel_seastone-r0/sonic_platform/component.py b/device/celestica/x86_64-cel_seastone-r0/sonic_platform/component.py index 782708025ab6..03f879805a5e 100644 --- a/device/celestica/x86_64-cel_seastone-r0/sonic_platform/component.py +++ b/device/celestica/x86_64-cel_seastone-r0/sonic_platform/component.py @@ -25,9 +25,11 @@ } GETREG_PATH = "/sys/devices/platform/dx010_cpld/getreg" BIOS_VERSION_PATH = "/sys/class/dmi/id/bios_version" -COMPONENT_NAME_LIST = ["CPLD1", "CPLD2", "CPLD3", "CPLD4", "BIOS"] +COMPONENT_NAME_LIST = ["CPLD1", "CPLD2", "CPLD3", "CPLD4", "CPLD5", "BIOS"] COMPONENT_DES_LIST = ["Used for managing the CPU", - "Used for managing QSFP+ ports (1-10)", "Used for managing QSFP+ ports (11-20)", "Used for managing QSFP+ ports (22-32)", "Basic Input/Output System"] + "Used for managing QSFP+ ports (1-10)", "Used for managing QSFP+ ports (11-21)", + "Used for misc status and control", "Used for managing QSFP+ ports (22-32)", + "Basic Input/Output System"] class Component(ComponentBase): diff --git a/device/celestica/x86_64-cel_seastone-r0/sonic_platform/eeprom.py b/device/celestica/x86_64-cel_seastone-r0/sonic_platform/eeprom.py index bfde69c8d296..9652ae8c3b75 100644 --- a/device/celestica/x86_64-cel_seastone-r0/sonic_platform/eeprom.py +++ b/device/celestica/x86_64-cel_seastone-r0/sonic_platform/eeprom.py @@ -131,6 +131,9 @@ def _valid_tlv(self, eeprom_data): def get_eeprom(self): return self._valid_tlv(self._eeprom) + def get_product_name(self): + return self._eeprom.get('0x21', NULL) + def get_pn(self): return self._eeprom.get('0x22', NULL) diff --git a/device/celestica/x86_64-cel_seastone-r0/sonic_platform/fan_drawer.py b/device/celestica/x86_64-cel_seastone-r0/sonic_platform/fan_drawer.py index e35ecf65195a..0fa37fba86ce 100644 --- a/device/celestica/x86_64-cel_seastone-r0/sonic_platform/fan_drawer.py +++ b/device/celestica/x86_64-cel_seastone-r0/sonic_platform/fan_drawer.py @@ -106,3 +106,13 @@ def is_replaceable(self): bool: True if it is replaceable. """ return True + + def get_maximum_consumed_power(self): + """ + Retrives the maximum power drawn by Fan Drawer + + Returns: + A float, with value of the maximum consumable power of the + component. + """ + return 33.60 diff --git a/device/celestica/x86_64-cel_seastone-r0/sonic_platform/psu.py b/device/celestica/x86_64-cel_seastone-r0/sonic_platform/psu.py index 7dd647be4e2c..8f3b561fd18e 100644 --- a/device/celestica/x86_64-cel_seastone-r0/sonic_platform/psu.py +++ b/device/celestica/x86_64-cel_seastone-r0/sonic_platform/psu.py @@ -197,7 +197,7 @@ def set_status_led(self, color): """ set_status_str = { - self.STATUS_LED_COLOR_GREEN: '1', + self.STATUS_LED_COLOR_GREEN: '255', self.STATUS_LED_COLOR_OFF: '0' }.get(color, 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 a90c82b50fcb..0521ca56480a 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 @@ -1520,7 +1520,7 @@ def get_power_override(self): if dom_control_raw is not None: dom_control_data = sfpd_obj.parse_control_bytes( dom_control_raw, 0) - return ('On' == dom_control_data['data']['PowerOverride']) + return ('On' == dom_control_data['data']['PowerOverride']['value']) else: return False else: @@ -2202,3 +2202,16 @@ def is_replaceable(self): A boolean value, True if replaceable """ return True + + def get_error_description(self): + """ + Retrives the error descriptions of the SFP module + Returns: + String that represents the current error descriptions of vendor specific errors + In case there are multiple errors, they should be joined by '|', + like: "Bad EEPROM|Unsupported cable" + """ + if not self.get_presence(): + return self.SFP_STATUS_UNPLUGGED + + return self.SFP_STATUS_OK 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 122b5d90ddb6..2bb8f2d57aa3 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 @@ -135,7 +135,7 @@ def arm(self, seconds): ret = WDT_COMMON_ERROR if seconds < 0: return ret - if seconds > 16779: + if seconds > 16777: return ret 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 index 4dc38d035ab4..c18399188153 100644 --- 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 @@ -1,10 +1,8 @@ { "services_to_ignore": [], "devices_to_ignore": [ - "asic", - "psu.temperature", - "PSU2 Fan", - "PSU1 Fan" + "PSU-1 FAN-1", + "PSU-2 FAN-1" ], "user_defined_checkers": [], "polling_interval": 60, @@ -13,4 +11,4 @@ "normal": "green", "booting": "orange_blink" } -} \ No newline at end of file +} diff --git a/device/common/profiles/td2/gen/BALANCED/pg_profile_lookup.ini b/device/common/profiles/td2/gen/BALANCED/pg_profile_lookup.ini index 389a7da97287..b4cd51281bae 100644 --- a/device/common/profiles/td2/gen/BALANCED/pg_profile_lookup.ini +++ b/device/common/profiles/td2/gen/BALANCED/pg_profile_lookup.ini @@ -1,17 +1,17 @@ # PG lossless profiles. # speed cable size xon xoff threshold xon_offset - 1000 5m 41808 18432 40560 -3 2496 - 10000 5m 41808 18432 40560 -3 2496 - 40000 5m 46384 18432 45136 -3 2496 - 50000 5m 46592 18432 45344 -3 2496 - 100000 5m 48464 18432 47216 -3 2496 - 1000 40m 41808 18432 40560 -3 2496 - 10000 40m 41808 18432 40560 -3 2496 - 40000 40m 48464 18432 47216 -3 2496 - 50000 40m 49296 18432 48048 -3 2496 - 100000 40m 53872 18432 52624 -3 2496 - 1000 300m 41808 18432 40560 -3 2496 - 10000 300m 41808 18432 40560 -3 2496 - 40000 300m 64064 18432 62816 -3 2496 - 50000 300m 68848 18432 67600 -3 2496 - 100000 300m 92976 18432 91728 -3 2496 + 1000 5m 41808 18432 40560 -1 2496 + 10000 5m 41808 18432 40560 -1 2496 + 40000 5m 46384 18432 45136 -1 2496 + 50000 5m 46592 18432 45344 -1 2496 + 100000 5m 48464 18432 47216 -1 2496 + 1000 40m 41808 18432 40560 -1 2496 + 10000 40m 41808 18432 40560 -1 2496 + 40000 40m 48464 18432 47216 -1 2496 + 50000 40m 49296 18432 48048 -1 2496 + 100000 40m 53872 18432 52624 -1 2496 + 1000 300m 41808 18432 40560 -1 2496 + 10000 300m 41808 18432 40560 -1 2496 + 40000 300m 64064 18432 62816 -1 2496 + 50000 300m 68848 18432 67600 -1 2496 + 100000 300m 92976 18432 91728 -1 2496 diff --git a/device/common/profiles/td2/gen/BALANCED/qos.json.j2 b/device/common/profiles/td2/gen/BALANCED/qos.json.j2 index 3e548325ea30..853a6f812b1d 100644 --- a/device/common/profiles/td2/gen/BALANCED/qos.json.j2 +++ b/device/common/profiles/td2/gen/BALANCED/qos.json.j2 @@ -1 +1,23 @@ +{% if ('type' in DEVICE_METADATA['localhost'] and 'BackEnd' in DEVICE_METADATA['localhost']['type'] and 'storage_device' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['storage_device'] == 'true') %} +{%- 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" : "12000144", + "green_min_threshold" : "1048576", + "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 %} +{% endif %} + {%- include 'qos_config.j2' %} diff --git a/device/common/profiles/td2/gen/RDMA-CENTRIC/pg_profile_lookup.ini b/device/common/profiles/td2/gen/RDMA-CENTRIC/pg_profile_lookup.ini index 389a7da97287..b4cd51281bae 100644 --- a/device/common/profiles/td2/gen/RDMA-CENTRIC/pg_profile_lookup.ini +++ b/device/common/profiles/td2/gen/RDMA-CENTRIC/pg_profile_lookup.ini @@ -1,17 +1,17 @@ # PG lossless profiles. # speed cable size xon xoff threshold xon_offset - 1000 5m 41808 18432 40560 -3 2496 - 10000 5m 41808 18432 40560 -3 2496 - 40000 5m 46384 18432 45136 -3 2496 - 50000 5m 46592 18432 45344 -3 2496 - 100000 5m 48464 18432 47216 -3 2496 - 1000 40m 41808 18432 40560 -3 2496 - 10000 40m 41808 18432 40560 -3 2496 - 40000 40m 48464 18432 47216 -3 2496 - 50000 40m 49296 18432 48048 -3 2496 - 100000 40m 53872 18432 52624 -3 2496 - 1000 300m 41808 18432 40560 -3 2496 - 10000 300m 41808 18432 40560 -3 2496 - 40000 300m 64064 18432 62816 -3 2496 - 50000 300m 68848 18432 67600 -3 2496 - 100000 300m 92976 18432 91728 -3 2496 + 1000 5m 41808 18432 40560 -1 2496 + 10000 5m 41808 18432 40560 -1 2496 + 40000 5m 46384 18432 45136 -1 2496 + 50000 5m 46592 18432 45344 -1 2496 + 100000 5m 48464 18432 47216 -1 2496 + 1000 40m 41808 18432 40560 -1 2496 + 10000 40m 41808 18432 40560 -1 2496 + 40000 40m 48464 18432 47216 -1 2496 + 50000 40m 49296 18432 48048 -1 2496 + 100000 40m 53872 18432 52624 -1 2496 + 1000 300m 41808 18432 40560 -1 2496 + 10000 300m 41808 18432 40560 -1 2496 + 40000 300m 64064 18432 62816 -1 2496 + 50000 300m 68848 18432 67600 -1 2496 + 100000 300m 92976 18432 91728 -1 2496 diff --git a/device/common/profiles/td2/gen/RDMA-CENTRIC/qos.json.j2 b/device/common/profiles/td2/gen/RDMA-CENTRIC/qos.json.j2 index 3e548325ea30..853a6f812b1d 100644 --- a/device/common/profiles/td2/gen/RDMA-CENTRIC/qos.json.j2 +++ b/device/common/profiles/td2/gen/RDMA-CENTRIC/qos.json.j2 @@ -1 +1,23 @@ +{% if ('type' in DEVICE_METADATA['localhost'] and 'BackEnd' in DEVICE_METADATA['localhost']['type'] and 'storage_device' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['storage_device'] == 'true') %} +{%- 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" : "12000144", + "green_min_threshold" : "1048576", + "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 %} +{% endif %} + {%- include 'qos_config.j2' %} diff --git a/device/common/profiles/th2/7260/BALANCED/qos.json.j2 b/device/common/profiles/th2/7260/BALANCED/qos.json.j2 index 750d0fb0ea77..743002c4f022 100644 --- a/device/common/profiles/th2/7260/BALANCED/qos.json.j2 +++ b/device/common/profiles/th2/7260/BALANCED/qos.json.j2 @@ -151,6 +151,8 @@ }, {%- endmacro %} {% elif ('subtype' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['subtype'] == 'DualToR') %} +{% set different_dscp_to_tc_map = true %} +{% set different_tc_to_queue_map = true %} {%- macro generate_dscp_to_tc_map() %} "DSCP_TO_TC_MAP": { "AZURE": { @@ -219,6 +221,72 @@ "62": "1", "63": "1" }, + "AZURE_UPLINK": { + "0" : "1", + "1" : "1", + "2" : "2", + "3" : "3", + "4" : "4", + "5" : "1", + "6" : "6", + "7" : "1", + "8" : "0", + "9" : "1", + "10": "1", + "11": "1", + "12": "1", + "13": "1", + "14": "1", + "15": "1", + "16": "1", + "17": "1", + "18": "1", + "19": "1", + "20": "1", + "21": "1", + "22": "1", + "23": "1", + "24": "1", + "25": "1", + "26": "1", + "27": "1", + "28": "1", + "29": "1", + "30": "1", + "31": "1", + "32": "1", + "33": "8", + "34": "1", + "35": "1", + "36": "1", + "37": "1", + "38": "1", + "39": "1", + "40": "1", + "41": "1", + "42": "1", + "43": "1", + "44": "1", + "45": "1", + "46": "5", + "47": "1", + "48": "7", + "49": "1", + "50": "1", + "51": "1", + "52": "1", + "53": "1", + "54": "1", + "55": "1", + "56": "1", + "57": "1", + "58": "1", + "59": "1", + "60": "1", + "61": "1", + "62": "1", + "63": "1" + }, "AZURE_TUNNEL": { "0" : "1", "1" : "1", @@ -326,6 +394,17 @@ "7": "7", "8": "1" }, + "AZURE_UPLINK": { + "0": "0", + "1": "1", + "2": "2", + "3": "3", + "4": "4", + "5": "5", + "6": "6", + "7": "7", + "8": "1" + }, "AZURE_TUNNEL": { "0": "0", "1": "1", diff --git a/device/common/profiles/th2/7260/RDMA-CENTRIC/qos.json.j2 b/device/common/profiles/th2/7260/RDMA-CENTRIC/qos.json.j2 index 771b8305f8f0..743002c4f022 100644 --- a/device/common/profiles/th2/7260/RDMA-CENTRIC/qos.json.j2 +++ b/device/common/profiles/th2/7260/RDMA-CENTRIC/qos.json.j2 @@ -1,4 +1,5 @@ {% if ('type' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['type'] == 'LeafRouter') %} +{% set different_dscp_to_tc_map = true %} {%- macro generate_dscp_to_tc_map() %} "DSCP_TO_TC_MAP": { "AZURE": { @@ -150,6 +151,8 @@ }, {%- endmacro %} {% elif ('subtype' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['subtype'] == 'DualToR') %} +{% set different_dscp_to_tc_map = true %} +{% set different_tc_to_queue_map = true %} {%- macro generate_dscp_to_tc_map() %} "DSCP_TO_TC_MAP": { "AZURE": { @@ -218,6 +221,72 @@ "62": "1", "63": "1" }, + "AZURE_UPLINK": { + "0" : "1", + "1" : "1", + "2" : "2", + "3" : "3", + "4" : "4", + "5" : "1", + "6" : "6", + "7" : "1", + "8" : "0", + "9" : "1", + "10": "1", + "11": "1", + "12": "1", + "13": "1", + "14": "1", + "15": "1", + "16": "1", + "17": "1", + "18": "1", + "19": "1", + "20": "1", + "21": "1", + "22": "1", + "23": "1", + "24": "1", + "25": "1", + "26": "1", + "27": "1", + "28": "1", + "29": "1", + "30": "1", + "31": "1", + "32": "1", + "33": "8", + "34": "1", + "35": "1", + "36": "1", + "37": "1", + "38": "1", + "39": "1", + "40": "1", + "41": "1", + "42": "1", + "43": "1", + "44": "1", + "45": "1", + "46": "5", + "47": "1", + "48": "7", + "49": "1", + "50": "1", + "51": "1", + "52": "1", + "53": "1", + "54": "1", + "55": "1", + "56": "1", + "57": "1", + "58": "1", + "59": "1", + "60": "1", + "61": "1", + "62": "1", + "63": "1" + }, "AZURE_TUNNEL": { "0" : "1", "1" : "1", @@ -325,6 +394,17 @@ "7": "7", "8": "1" }, + "AZURE_UPLINK": { + "0": "0", + "1": "1", + "2": "2", + "3": "3", + "4": "4", + "5": "5", + "6": "6", + "7": "7", + "8": "1" + }, "AZURE_TUNNEL": { "0": "0", "1": "1", diff --git a/device/dell/x86_64-dellemc_z9332f_d1508-r0/DellEMC-Z9332f-O32/hwsku.json b/device/dell/x86_64-dellemc_z9332f_d1508-r0/DellEMC-Z9332f-O32/hwsku.json new file mode 100644 index 000000000000..a4ad1b352e4c --- /dev/null +++ b/device/dell/x86_64-dellemc_z9332f_d1508-r0/DellEMC-Z9332f-O32/hwsku.json @@ -0,0 +1,106 @@ +{ + "interfaces": { + "Ethernet0": { + "default_brkout_mode": "1x400G" + }, + "Ethernet8": { + "default_brkout_mode": "1x400G" + }, + "Ethernet16": { + "default_brkout_mode": "1x400G" + }, + "Ethernet24": { + "default_brkout_mode": "1x400G" + }, + "Ethernet32": { + "default_brkout_mode": "1x400G" + }, + "Ethernet40": { + "default_brkout_mode": "1x400G" + }, + "Ethernet48": { + "default_brkout_mode": "1x400G" + }, + "Ethernet56": { + "default_brkout_mode": "1x400G" + }, + "Ethernet64": { + "default_brkout_mode": "1x400G" + }, + "Ethernet72": { + "default_brkout_mode": "1x400G" + }, + "Ethernet80": { + "default_brkout_mode": "1x400G" + }, + "Ethernet88": { + "default_brkout_mode": "1x400G" + }, + "Ethernet96": { + "default_brkout_mode": "1x400G" + }, + "Ethernet104": { + "default_brkout_mode": "1x400G" + }, + "Ethernet112": { + "default_brkout_mode": "1x400G" + }, + "Ethernet120": { + "default_brkout_mode": "1x400G" + }, + "Ethernet128": { + "default_brkout_mode": "1x400G" + }, + "Ethernet136": { + "default_brkout_mode": "1x400G" + }, + "Ethernet144": { + "default_brkout_mode": "1x400G" + }, + "Ethernet152": { + "default_brkout_mode": "1x400G" + }, + "Ethernet160": { + "default_brkout_mode": "1x400G" + }, + "Ethernet168": { + "default_brkout_mode": "1x400G" + }, + "Ethernet176": { + "default_brkout_mode": "1x400G" + }, + "Ethernet184": { + "default_brkout_mode": "1x400G" + }, + "Ethernet192": { + "default_brkout_mode": "1x400G" + }, + "Ethernet200": { + "default_brkout_mode": "1x400G" + }, + "Ethernet208": { + "default_brkout_mode": "1x400G" + }, + "Ethernet216": { + "default_brkout_mode": "1x400G" + }, + "Ethernet224": { + "default_brkout_mode": "1x400G" + }, + "Ethernet232": { + "default_brkout_mode": "1x400G" + }, + "Ethernet240": { + "default_brkout_mode": "1x400G" + }, + "Ethernet248": { + "default_brkout_mode": "1x400G" + }, + "Ethernet256": { + "default_brkout_mode": "1x10G" + }, + "Ethernet257": { + "default_brkout_mode": "1x10G" + } + } +} diff --git a/device/dell/x86_64-dellemc_z9332f_d1508-r0/platform.json b/device/dell/x86_64-dellemc_z9332f_d1508-r0/platform.json index 694f3e41d7c4..c8688b8c713d 100644 --- a/device/dell/x86_64-dellemc_z9332f_d1508-r0/platform.json +++ b/device/dell/x86_64-dellemc_z9332f_d1508-r0/platform.json @@ -611,5 +611,340 @@ ] }, - "interfaces": {} + "interfaces": { + "Ethernet0": { + "index": "1,1,1,1,1,1,1,1", + "lanes": "33,34,35,36,37,38,39,40", + "breakout_modes": { + "1x400G": ["etp1"], + "2x200G[100G,40G]": ["etp1a", "etp1b"], + "4x100G[50G]": ["etp1a", "etp1b", "etp1c", "etp1d"], + "1x100G(4)": ["etp1"] + } + }, + "Ethernet8": { + "index": "2,2,2,2,2,2,2,2", + "lanes": "41,42,43,44,45,46,47,48", + "breakout_modes": { + "1x400G": ["etp2"], + "2x200G[100G,40G]": ["etp2a", "etp2b"], + "4x100G[50G]": ["etp2a", "etp2b", "etp2c", "etp2d"], + "1x100G(4)": ["etp2"] + } + }, + "Ethernet16": { + "index": "3,3,3,3,3,3,3,3", + "lanes": "49,50,51,52,53,54,55,56", + "breakout_modes": { + "1x400G": ["etp3"], + "2x200G[100G,40G]": ["etp3a", "etp3b"], + "4x100G[50G]": ["etp3a", "etp3b", "etp3c", "etp3d"], + "1x100G(4)": ["etp3"] + } + }, + "Ethernet24": { + "index": "4,4,4,4,4,4,4,4", + "lanes": "57,58,59,60,61,62,63,64", + "breakout_modes": { + "1x400G": ["etp4"], + "2x200G[100G,40G]": ["etp4a", "etp4b"], + "4x100G[50G]": ["etp4a", "etp4b", "etp4c", "etp4d"], + "1x100G(4)": ["etp4"] + } + }, + "Ethernet32": { + "index": "5,5,5,5,5,5,5,5", + "lanes": "65,66,67,68,69,70,71,72", + "breakout_modes": { + "1x400G": ["etp5"], + "2x200G[100G,40G]": ["etp5a", "etp5b"], + "4x100G[50G]": ["etp5a", "etp5b", "etp5c", "etp5d"], + "1x100G(4)": ["etp5"] + } + }, + "Ethernet40": { + "index": "6,6,6,6,6,6,6,6", + "lanes": "73,74,75,76,77,78,79,80", + "breakout_modes": { + "1x400G": ["etp6"], + "2x200G[100G,40G]": ["etp6a", "etp6b"], + "4x100G[50G]": ["etp6a", "etp6b", "etp6c", "etp6d"], + "1x100G(4)": ["etp6"] + } + }, + "Ethernet48": { + "index": "7,7,7,7,7,7,7,7", + "lanes": "81,82,83,84,85,86,87,88", + "breakout_modes": { + "1x400G": ["etp7"], + "2x200G[100G,40G]": ["etp7a", "etp7b"], + "4x100G[50G]": ["etp7a", "etp7b", "etp7c", "etp7d"], + "1x100G(4)": ["etp7"] + } + }, + "Ethernet56": { + "index": "8,8,8,8,8,8,8,8", + "lanes": "89,90,91,92,93,94,95,96", + "breakout_modes": { + "1x400G": ["etp8"], + "2x200G[100G,40G]": ["etp8a", "etp8b"], + "4x100G[50G]": ["etp8a", "etp8b", "etp8c", "etp8d"], + "1x100G(4)": ["etp8"] + } + }, + "Ethernet64": { + "index": "9,9,9,9,9,9,9,9", + "lanes": "1,2,3,4,5,6,7,8", + "breakout_modes": { + "1x400G": ["etp9"], + "2x200G[100G,40G]": ["etp9a", "etp9b"], + "4x100G[50G]": ["etp9a", "etp9b", "etp9c", "etp9d"], + "1x100G(4)": ["etp9"] + } + }, + "Ethernet72": { + "index": "10,10,10,10,10,10,10,10", + "lanes": "9,10,11,12,13,14,15,16", + "breakout_modes": { + "1x400G": ["etp10"], + "2x200G[100G,40G]": ["etp10a", "etp10b"], + "4x100G[50G]": ["etp10a", "etp10b", "etp10c", "etp10d"], + "1x100G(4)": ["etp10"] + } + }, + "Ethernet80": { + "index": "11,11,11,11,11,11,11,11", + "lanes": "17,18,19,20,21,22,23,24", + "breakout_modes": { + "1x400G": ["etp11"], + "2x200G[100G,40G]": ["etp11a", "etp11b"], + "4x100G[50G]": ["etp11a", "etp11b", "etp11c", "etp11d"], + "1x100G(4)": ["etp11"] + } + }, + "Ethernet88": { + "index": "12,12,12,12,12,12,12,12", + "lanes": "25,26,27,28,29,30,31,32", + "breakout_modes": { + "1x400G": ["etp12"], + "2x200G[100G,40G]": ["etp12a", "etp12b"], + "4x100G[50G]": ["etp12a", "etp12b", "etp12c", "etp12d"], + "1x100G(4)": ["etp12"] + } + }, + "Ethernet96": { + "index": "13,13,13,13,13,13,13,13", + "lanes": "97,98,99,100,101,102,103,104", + "breakout_modes": { + "1x400G": ["etp13"], + "2x200G[100G,40G]": ["etp13a", "etp13b"], + "4x100G[50G]": ["etp13a", "etp13b", "etp13c", "etp13d"], + "1x100G(4)": ["etp13"] + } + }, + "Ethernet104": { + "index": "14,14,14,14,14,14,14,14", + "lanes": "105,106,107,108,109,110,111,112", + "breakout_modes": { + "1x400G": ["etp14"], + "2x200G[100G,40G]": ["etp14a", "etp14b"], + "4x100G[50G]": ["etp14a", "etp14b", "etp14c", "etp14d"], + "1x100G(4)": ["etp14"] + } + }, + "Ethernet112": { + "index": "15,15,15,15,15,15,15,15", + "lanes": "113,114,115,116,117,118,119,120", + "breakout_modes": { + "1x400G": ["etp15"], + "2x200G[100G,40G]": ["etp15a", "etp15b"], + "4x100G[50G]": ["etp15a", "etp15b", "etp15c", "etp15d"], + "1x100G(4)": ["etp15"] + } + }, + "Ethernet120": { + "index": "16,16,16,16,16,16,16,16", + "lanes": "121,122,123,124,125,126,127,128", + "breakout_modes": { + "1x400G": ["etp16"], + "2x200G[100G,40G]": ["etp16a", "etp16b"], + "4x100G[50G]": ["etp16a", "etp16b", "etp16c", "etp16d"], + "1x100G(4)": ["etp16"] + } + }, + "Ethernet128": { + "index": "17,17,17,17,17,17,17,17", + "lanes": "129,130,131,132,133,134,135,136", + "breakout_modes": { + "1x400G": ["etp17"], + "2x200G[100G,40G]": ["etp17a", "etp17b"], + "4x100G[50G]": ["etp17a", "etp17b", "etp17c", "etp17d"], + "1x100G(4)": ["etp17"] + } + }, + "Ethernet136": { + "index": "18,18,18,18,18,18,18,18", + "lanes": "137,138,139,140,141,142,143,144", + "breakout_modes": { + "1x400G": ["etp18"], + "2x200G[100G,40G]": ["etp18a", "etp18b"], + "4x100G[50G]": ["etp18a", "etp18b", "etp18c", "etp18d"], + "1x100G(4)": ["etp18"] + } + }, + "Ethernet144": { + "index": "19,19,19,19,19,19,19,19", + "lanes": "145,146,147,148,149,150,151,152", + "breakout_modes": { + "1x400G": ["etp19"], + "2x200G[100G,40G]": ["etp19a", "etp19b"], + "4x100G[50G]": ["etp19a", "etp19b", "etp19c", "etp19d"], + "1x100G(4)": ["etp19"] + } + }, + "Ethernet152": { + "index": "20,20,20,20,20,20,20,20", + "lanes": "153,154,155,156,157,158,159,160", + "breakout_modes": { + "1x400G": ["etp20"], + "2x200G[100G,40G]": ["etp20a", "etp20b"], + "4x100G[50G]": ["etp20a", "etp20b", "etp20c", "etp20d"], + "1x100G(4)": ["etp20"] + } + }, + "Ethernet160": { + "index": "21,21,21,21,21,21,21,21", + "lanes": "225,226,227,228,229,230,231,232", + "breakout_modes": { + "1x400G": ["etp21"], + "2x200G[100G,40G]": ["etp21a", "etp21b"], + "4x100G[50G]": ["etp21a", "etp21b", "etp21c", "etp21d"], + "1x100G(4)": ["etp21"] + } + }, + "Ethernet168": { + "index": "22,22,22,22,22,22,22,22", + "lanes": "233,234,235,236,237,238,239,240", + "breakout_modes": { + "1x400G": ["etp22"], + "2x200G[100G,40G]": ["etp22a", "etp22b"], + "4x100G[50G]": ["etp22a", "etp22b", "etp22c", "etp22d"], + "1x100G(4)": ["etp22"] + } + }, + "Ethernet176": { + "index": "23,23,23,23,23,23,23,23", + "lanes": "241,242,243,244,245,246,247,248", + "breakout_modes": { + "1x400G": ["etp23"], + "2x200G[100G,40G]": ["etp23a", "etp23b"], + "4x100G[50G]": ["etp23a", "etp23b", "etp23c", "etp23d"], + "1x100G(4)": ["etp23"] + } + }, + "Ethernet184": { + "index": "24,24,24,24,24,24,24,24", + "lanes": "249,250,251,252,253,254,255,256", + "breakout_modes": { + "1x400G": ["etp24"], + "2x200G[100G,40G]": ["etp24a", "etp24b"], + "4x100G[50G]": ["etp24a", "etp24b", "etp24c", "etp24d"], + "1x100G(4)": ["etp24"] + } + }, + "Ethernet192": { + "index": "25,25,25,25,25,25,25,25", + "lanes": "161,162,163,164,165,166,167,168", + "breakout_modes": { + "1x400G": ["etp25"], + "2x200G[100G,40G]": ["etp25a", "etp25b"], + "4x100G[50G]": ["etp25a", "etp25b", "etp25c", "etp25d"], + "1x100G(4)": ["etp25"] + } + }, + "Ethernet200": { + "index": "26,26,26,26,26,26,26,26", + "lanes": "169,170,171,172,173,174,175,176", + "breakout_modes": { + "1x400G": ["etp26"], + "2x200G[100G,40G]": ["etp26a", "etp26b"], + "4x100G[50G]": ["etp26a", "etp26b", "etp26c", "etp26d"], + "1x100G(4)": ["etp26"] + } + }, + "Ethernet208": { + "index": "27,27,27,27,27,27,27,27", + "lanes": "177,178,179,180,181,182,183,184", + "breakout_modes": { + "1x400G": ["etp27"], + "2x200G[100G,40G]": ["etp27a", "etp27b"], + "4x100G[50G]": ["etp27a", "etp27b", "etp27c", "etp27d"], + "1x100G(4)": ["etp27"] + } + }, + "Ethernet216": { + "index": "28,28,28,28,28,28,28,28", + "lanes": "185,186,187,188,189,190,191,192", + "breakout_modes": { + "1x400G": ["etp28"], + "2x200G[100G,40G]": ["etp28a", "etp28b"], + "4x100G[50G]": ["etp28a", "etp28b", "etp28c", "etp28d"], + "1x100G(4)": ["etp28"] + } + }, + "Ethernet224": { + "index": "29,29,29,29,29,29,29,29", + "lanes": "193,194,195,196,197,198,199,200", + "breakout_modes": { + "1x400G": ["etp29"], + "2x200G[100G,40G]": ["etp29a", "etp29b"], + "4x100G[50G]": ["etp29a", "etp29b", "etp29c", "etp29d"], + "1x100G(4)": ["etp29"] + } + }, + "Ethernet232": { + "index": "30,30,30,30,30,30,30,30", + "lanes": "201,202,203,204,205,206,207,208", + "breakout_modes": { + "1x400G": ["etp30"], + "2x200G[100G,40G]": ["etp30a", "etp30b"], + "4x100G[50G]": ["etp30a", "etp30b", "etp30c", "etp30d"], + "1x100G(4)": ["etp30"] + } + }, + "Ethernet240": { + "index": "31,31,31,31,31,31,31,31", + "lanes": "209,210,211,212,213,214,215,216", + "breakout_modes": { + "1x400G": ["etp31"], + "2x200G[100G,40G]": ["etp31a", "etp31b"], + "4x100G[50G]": ["etp31a", "etp31b", "etp31c", "etp31d"], + "1x100G(4)": ["etp31"] + } + }, + "Ethernet248": { + "index": "32,32,32,32,32,32,32,32", + "lanes": "217,218,219,220,221,222,223,224", + "breakout_modes": { + "1x400G": ["etp32"], + "2x200G[100G,40G]": ["etp32a", "etp32b"], + "4x100G[50G]": ["etp32a", "etp32b", "etp32c", "etp32d"], + "1x100G(4)": ["etp32"] + } + }, + "Ethernet256": { + "index": "33", + "lanes": "257", + "breakout_modes": { + "1x10G": ["etp33"] + } + }, + "Ethernet257": { + "index": "34", + "lanes": "258", + "breakout_modes": { + "1x10G": ["etp34"] + } + } + } } diff --git a/device/juniper/x86_64-juniper_qfx5200-r0/plugins/qfx5200_eeprom_data.py b/device/juniper/x86_64-juniper_qfx5200-r0/plugins/qfx5200_eeprom_data.py index ea53f11e698d..e5d51d302f10 100644 --- a/device/juniper/x86_64-juniper_qfx5200-r0/plugins/qfx5200_eeprom_data.py +++ b/device/juniper/x86_64-juniper_qfx5200-r0/plugins/qfx5200_eeprom_data.py @@ -34,13 +34,9 @@ import binascii import os -import sys +import subprocess from sonic_eeprom import eeprom_tlvinfo - -if sys.version_info[0] < 3: - import commands -else: - import subprocess as commands +from sonic_py_common.general import getstatusoutput_noshell def fantype_detect(): @@ -56,9 +52,7 @@ def fantype_detect(): for filename in os.listdir(refpgaTMC_path): if filename.endswith('_type'): fantype_path = os.path.join(refpgaTMC_path, filename) - cat_string = "cat " - fantype_string = cat_string + fantype_path - status, fan_type = commands.getstatusoutput(fantype_string) + status, fan_type = getstatusoutput_noshell(['cat', fantype_path]) if ((fan_type == AFO) or (fan_type == AFI)): return fan_type else: @@ -176,17 +170,21 @@ def main(): eeprom_file.write("Main board eeprom (0x57)\r\n") eeprom_file.write("===============================\r\n") - MainEepromCreate = 'sudo echo 24c02 0x57 > /sys/bus/i2c/devices/i2c-0/new_device' + MainEepromCreate = '24c02 0x57' + out_file = '/sys/bus/i2c/devices/i2c-0/new_device' # Write the contents of Main Board EEPROM to file try: - os.system(MainEepromCreate) + with open(out_file, 'w') as file: + file.write(MainEepromCreate) except OSError: print('Error: Execution of "%s" failed', MainEepromCreate) return False - MainEepromFileCmd = 'cat /sys/bus/i2c/devices/i2c-0/0-0057/eeprom > /etc/init.d/MainEeprom_qfx5200_ascii' + MainEepromFileCmd = ['cat', '/sys/bus/i2c/devices/i2c-0/0-0057/eeprom'] + out_file = '/etc/init.d/MainEeprom_qfx5200_ascii' try: - os.system(MainEepromFileCmd) + with open(out_file, 'w') as file: + subprocess.call(MainEepromFileCmd, universal_newlines=True, stdout=file) except OSError: print('Error: Execution of "%s" failed', MainEepromFileCmd) return False diff --git a/device/juniper/x86_64-juniper_qfx5210-r0/plugins/qfx5210_eeprom_data.py b/device/juniper/x86_64-juniper_qfx5210-r0/plugins/qfx5210_eeprom_data.py index b0aef43ba273..347e2472ff8f 100644 --- a/device/juniper/x86_64-juniper_qfx5210-r0/plugins/qfx5210_eeprom_data.py +++ b/device/juniper/x86_64-juniper_qfx5210-r0/plugins/qfx5210_eeprom_data.py @@ -32,8 +32,8 @@ # components is subject to the terms and conditions of the respective license # as noted in the Third-Party source code file. -import os import binascii +import subprocess from sonic_eeprom import eeprom_tlvinfo @@ -81,10 +81,12 @@ def main(): eeprom_file.write("Vendor Name=%s\r\n" % eeprom_qfx5210.vendor_name_str()) eeprom_file.write("Manufacture Name=%s\r\n" % eeprom_qfx5210.manufacture_name_str()) - CPUeepromFileCmd = 'cat /sys/devices/pci0000:00/0000:00:1f.3/i2c-0/0-0056/eeprom > /etc/init.d/eeprom_qfx5210_ascii' + CPUeepromFileCmd = ['cat', '/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/0-0056/eeprom'] # Write the contents of CPU EEPROM to file + out_file = '/etc/init.d/eeprom_qfx5210_ascii' try: - os.system(CPUeepromFileCmd) + with open(out_file, 'w') as file: + subprocess.call(CPUeepromFileCmd, universal_newlines=True, stdout=file) except OSError: print('Error: Execution of "%s" failed', CPUeepromFileCmd) return False diff --git a/device/marvell/arm64-marvell_db98cx8580_16cd-r0/plugins/sfputil.py b/device/marvell/arm64-marvell_db98cx8580_16cd-r0/plugins/sfputil.py index 4463e687e695..500bdda8f2d6 100644 --- a/device/marvell/arm64-marvell_db98cx8580_16cd-r0/plugins/sfputil.py +++ b/device/marvell/arm64-marvell_db98cx8580_16cd-r0/plugins/sfputil.py @@ -1,17 +1,13 @@ try: import os import time - import sys import re + import subprocess from sonic_sfp.sfputilbase import SfpUtilBase + from sonic_py_common.general import getstatusoutput_noshell except ImportError as e: raise ImportError(str(e) + "- required module not found") -if sys.version_info[0] < 3: - import commands -else: - import subprocess as commands - smbus_present = 1 try: @@ -31,9 +27,10 @@ class SfpUtil(SfpUtilBase): _qsfp_ports = list(range(_port_start, ports_in_block + 1)) def __init__(self): - os.system("modprobe i2c-dev") + subprocess.call(["modprobe", "i2c-dev"]) if not os.path.exists("/sys/bus/i2c/devices/0-0050"): - os.system("echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-0/new_device") + with open("/sys/bus/i2c/devices/i2c-0/new_device", 'w') as file: + file.write("optoe2 0x50") eeprom_path = '/sys/bus/i2c/devices/0-0050/eeprom' # for x in range(self.port _start, self.port_end +1): @@ -74,8 +71,8 @@ def get_low_power_mode(self, port_num): def i2c_get(self, device_addr, offset): status = 0 if smbus_present == 0: - x = "i2cget -y 0 " + hex(device_addr) + " " + hex(offset) - cmdstatus, status = commands.getstatusoutput(x) + x = ["i2cget", "-y", "0", hex(device_addr), hex(offset)] + cmdstatus, status = getstatusoutput_noshell(x) if cmdstatus != 0: return cmdstatus status = int(status, 16) @@ -86,8 +83,8 @@ def i2c_get(self, device_addr, offset): def i2c_set(self, device_addr, offset, value): if smbus_present == 0: - cmd = "i2cset -y 0 " + hex(device_addr) + " " + hex(offset) + " " + hex(value) - os.system(cmd) + cmd = ["i2cset", "-y", "0", hex(device_addr), hex(offset), hex(value)] + subprocess.call(cmd) else: bus = smbus.SMBus(0) bus.write_byte_data(device_addr, offset, value) diff --git a/device/marvell/arm64-marvell_db98cx8580_32cd-r0/plugins/sfputil.py b/device/marvell/arm64-marvell_db98cx8580_32cd-r0/plugins/sfputil.py index b3d1ea371454..280593c60be1 100644 --- a/device/marvell/arm64-marvell_db98cx8580_32cd-r0/plugins/sfputil.py +++ b/device/marvell/arm64-marvell_db98cx8580_32cd-r0/plugins/sfputil.py @@ -1,17 +1,13 @@ try: import os import time - import sys import re + import subprocess from sonic_sfp.sfputilbase import SfpUtilBase + from sonic_py_common.general import getstatusoutput_noshell except ImportError as e: raise ImportError(str(e) + "- required module not found") -if sys.version_info[0] < 3: - import commands -else: - import subprocess as commands - smbus_present = 1 try: @@ -31,9 +27,10 @@ class SfpUtil(SfpUtilBase): _qsfp_ports = list(range(_port_start, ports_in_block + 1)) def __init__(self): - os.system("modprobe i2c-dev") + subprocess.call(["modprobe", "i2c-dev"]) if not os.path.exists("/sys/bus/i2c/devices/0-0050"): - os.system("echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-0/new_device") + with open("/sys/bus/i2c/devices/i2c-0/new_device", 'w') as file: + file.write("optoe2 0x50") eeprom_path = '/sys/bus/i2c/devices/0-0050/eeprom' # for x in range(self.port _start, self.port_end +1): @@ -74,8 +71,8 @@ def get_low_power_mode(self, port_num): def i2c_get(self, device_addr, offset): status = 0 if smbus_present == 0: - x = "i2cget -y 0 " + hex(device_addr) + " " + hex(offset) - cmdstatus, status = commands.getstatusoutput(x) + x = ["i2cget", "-y", "0", hex(device_addr), hex(offset)] + cmdstatus, status = getstatusoutput_noshell(x) if cmdstatus != 0: return cmdstatus status = int(status, 16) @@ -86,8 +83,8 @@ def i2c_get(self, device_addr, offset): def i2c_set(self, device_addr, offset, value): if smbus_present == 0: - cmd = "i2cset -y 0 " + hex(device_addr) + " " + hex(offset) + " " + hex(value) - os.system(cmd) + cmd = ["i2cset", "-y", "0", hex(device_addr), hex(offset), hex(value)] + subprocess.call(cmd) else: bus = smbus.SMBus(0) bus.write_byte_data(device_addr, offset, value) diff --git a/device/marvell/armhf-marvell_et6448m_52x-r0/plugins/psuutil.py b/device/marvell/armhf-marvell_et6448m_52x-r0/plugins/psuutil.py index ab6aeff2b20b..a75832ee4d2d 100755 --- a/device/marvell/armhf-marvell_et6448m_52x-r0/plugins/psuutil.py +++ b/device/marvell/armhf-marvell_et6448m_52x-r0/plugins/psuutil.py @@ -1,9 +1,4 @@ -import sys -import os.path -if sys.version_info[0] < 3: - import commands -else: - import subprocess as commands +from sonic_py_common.general import getstatusoutput_noshell smbus_present = 1 try: @@ -32,8 +27,7 @@ def get_psu_status(self, index): if index is None: return False if smbus_present == 0: - cmdstatus, psustatus = commands.getstatusoutput( - 'i2cget -y 0 0x41 0xa') # need to verify the cpld register logic + cmdstatus, psustatus = getstatusoutput_noshell(["i2cget", "-y", "0", "0x41", "0xa"]) psustatus = int(psustatus, 16) else: bus = smbus.SMBus(0) @@ -56,8 +50,7 @@ def get_psu_presence(self, index): return False if smbus_present == 0: - cmdstatus, psustatus = commands.getstatusoutput( - 'i2cget -y 0 0x41 0xa') # need to verify the cpld register logic + cmdstatus, psustatus = getstatusoutput_noshell(["i2cget", "-y", "0", "0x41", "0xa"]) psustatus = int(psustatus, 16) else: bus = smbus.SMBus(0) diff --git a/device/marvell/armhf-marvell_et6448m_52x-r0/plugins/sfputil.py b/device/marvell/armhf-marvell_et6448m_52x-r0/plugins/sfputil.py index 39d5db4ce7f4..a160becb6fef 100755 --- a/device/marvell/armhf-marvell_et6448m_52x-r0/plugins/sfputil.py +++ b/device/marvell/armhf-marvell_et6448m_52x-r0/plugins/sfputil.py @@ -2,17 +2,13 @@ import os import time import re - import sys import glob + import subprocess from sonic_sfp.sfputilbase import SfpUtilBase + from sonic_py_common.general import getstatusoutput_noshell except ImportError as e: raise ImportError(str(e) + "- required module not found") -if sys.version_info[0] < 3: - import commands -else: - import subprocess as commands - smbus_present = 1 try: @@ -43,7 +39,7 @@ def __init__(self): # Enable optical SFP Tx if smbus_present == 0: - os.system("i2cset -y -m 0x0f 0 0x41 0x5 0x00") + subprocess.call(["i2cset", "-y", "-m", "0x0f", "0", "0x41", "0x5", "0x00"]) else: bus = smbus.SMBus(0) DEVICE_ADDRESS = 0x41 @@ -66,8 +62,9 @@ def __init__(self): port_eeprom_path = eeprom_path.format(self.port_to_i2c_mapping[x]) #print port_eeprom_path if not os.path.exists(port_eeprom_path): - bus_dev_path = bus_path.format(self.port_to_i2c_mapping[x]) - os.system("echo optoe2 0x50 > " + bus_dev_path + "/new_device") + bus_dev_path = bus_path.format(self.port_to_i2c_mapping[x]) + "/new_device" + with open(bus_dev_path, 'w') as f: + f.write("optoe2 0x50") self.port_to_eeprom_mapping[x] = port_eeprom_path self._port_to_eeprom_mapping[x] = port_eeprom_path SfpUtilBase.__init__(self) @@ -113,8 +110,7 @@ def get_presence(self, port_num): pos = [1, 2, 4, 8] bit_pos = pos[prt] if smbus_present == 0: - cmdstatus, sfpstatus = commands.getstatusoutput( - 'i2cget -y 0 0x41 0x3') # need to verify the cpld register logic + cmdstatus, sfpstatus = getstatusoutput_noshell(['i2cget', '-y', '0', '0x41', '0x3']) sfpstatus = int(sfpstatus, 16) else: bus = smbus.SMBus(0) diff --git a/device/marvell/x86_64-marvell_db98cx8580_16cd-r0/plugins/sfputil.py b/device/marvell/x86_64-marvell_db98cx8580_16cd-r0/plugins/sfputil.py index 4463e687e695..500bdda8f2d6 100644 --- a/device/marvell/x86_64-marvell_db98cx8580_16cd-r0/plugins/sfputil.py +++ b/device/marvell/x86_64-marvell_db98cx8580_16cd-r0/plugins/sfputil.py @@ -1,17 +1,13 @@ try: import os import time - import sys import re + import subprocess from sonic_sfp.sfputilbase import SfpUtilBase + from sonic_py_common.general import getstatusoutput_noshell except ImportError as e: raise ImportError(str(e) + "- required module not found") -if sys.version_info[0] < 3: - import commands -else: - import subprocess as commands - smbus_present = 1 try: @@ -31,9 +27,10 @@ class SfpUtil(SfpUtilBase): _qsfp_ports = list(range(_port_start, ports_in_block + 1)) def __init__(self): - os.system("modprobe i2c-dev") + subprocess.call(["modprobe", "i2c-dev"]) if not os.path.exists("/sys/bus/i2c/devices/0-0050"): - os.system("echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-0/new_device") + with open("/sys/bus/i2c/devices/i2c-0/new_device", 'w') as file: + file.write("optoe2 0x50") eeprom_path = '/sys/bus/i2c/devices/0-0050/eeprom' # for x in range(self.port _start, self.port_end +1): @@ -74,8 +71,8 @@ def get_low_power_mode(self, port_num): def i2c_get(self, device_addr, offset): status = 0 if smbus_present == 0: - x = "i2cget -y 0 " + hex(device_addr) + " " + hex(offset) - cmdstatus, status = commands.getstatusoutput(x) + x = ["i2cget", "-y", "0", hex(device_addr), hex(offset)] + cmdstatus, status = getstatusoutput_noshell(x) if cmdstatus != 0: return cmdstatus status = int(status, 16) @@ -86,8 +83,8 @@ def i2c_get(self, device_addr, offset): def i2c_set(self, device_addr, offset, value): if smbus_present == 0: - cmd = "i2cset -y 0 " + hex(device_addr) + " " + hex(offset) + " " + hex(value) - os.system(cmd) + cmd = ["i2cset", "-y", "0", hex(device_addr), hex(offset), hex(value)] + subprocess.call(cmd) else: bus = smbus.SMBus(0) bus.write_byte_data(device_addr, offset, value) diff --git a/device/marvell/x86_64-marvell_db98cx8580_32cd-r0/plugins/sfputil.py b/device/marvell/x86_64-marvell_db98cx8580_32cd-r0/plugins/sfputil.py index b3d1ea371454..280593c60be1 100644 --- a/device/marvell/x86_64-marvell_db98cx8580_32cd-r0/plugins/sfputil.py +++ b/device/marvell/x86_64-marvell_db98cx8580_32cd-r0/plugins/sfputil.py @@ -1,17 +1,13 @@ try: import os import time - import sys import re + import subprocess from sonic_sfp.sfputilbase import SfpUtilBase + from sonic_py_common.general import getstatusoutput_noshell except ImportError as e: raise ImportError(str(e) + "- required module not found") -if sys.version_info[0] < 3: - import commands -else: - import subprocess as commands - smbus_present = 1 try: @@ -31,9 +27,10 @@ class SfpUtil(SfpUtilBase): _qsfp_ports = list(range(_port_start, ports_in_block + 1)) def __init__(self): - os.system("modprobe i2c-dev") + subprocess.call(["modprobe", "i2c-dev"]) if not os.path.exists("/sys/bus/i2c/devices/0-0050"): - os.system("echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-0/new_device") + with open("/sys/bus/i2c/devices/i2c-0/new_device", 'w') as file: + file.write("optoe2 0x50") eeprom_path = '/sys/bus/i2c/devices/0-0050/eeprom' # for x in range(self.port _start, self.port_end +1): @@ -74,8 +71,8 @@ def get_low_power_mode(self, port_num): def i2c_get(self, device_addr, offset): status = 0 if smbus_present == 0: - x = "i2cget -y 0 " + hex(device_addr) + " " + hex(offset) - cmdstatus, status = commands.getstatusoutput(x) + x = ["i2cget", "-y", "0", hex(device_addr), hex(offset)] + cmdstatus, status = getstatusoutput_noshell(x) if cmdstatus != 0: return cmdstatus status = int(status, 16) @@ -86,8 +83,8 @@ def i2c_get(self, device_addr, offset): def i2c_set(self, device_addr, offset, value): if smbus_present == 0: - cmd = "i2cset -y 0 " + hex(device_addr) + " " + hex(offset) + " " + hex(value) - os.system(cmd) + cmd = ["i2cset", "-y", "0", hex(device_addr), hex(offset), hex(value)] + subprocess.call(cmd) else: bus = smbus.SMBus(0) bus.write_byte_data(device_addr, offset, value) diff --git a/device/mellanox/x86_64-mlnx_msn2010-r0/platform.json b/device/mellanox/x86_64-mlnx_msn2010-r0/platform.json index 1e8fe747f906..d48b4e8e8fc8 100644 --- a/device/mellanox/x86_64-mlnx_msn2010-r0/platform.json +++ b/device/mellanox/x86_64-mlnx_msn2010-r0/platform.json @@ -67,6 +67,9 @@ }, { "name": "CPU Core 3 Temp" + }, + { + "name": "SODIMM 1 Temp" } ], "sfps": [ diff --git a/device/mellanox/x86_64-mlnx_msn2100-r0/platform.json b/device/mellanox/x86_64-mlnx_msn2100-r0/platform.json index 74b4397759c1..485a3614b66b 100644 --- a/device/mellanox/x86_64-mlnx_msn2100-r0/platform.json +++ b/device/mellanox/x86_64-mlnx_msn2100-r0/platform.json @@ -67,6 +67,9 @@ }, { "name": "CPU Core 3 Temp" + }, + { + "name": "SODIMM 1 Temp" } ], "sfps": [ diff --git a/device/mellanox/x86_64-mlnx_msn2410-r0/platform.json b/device/mellanox/x86_64-mlnx_msn2410-r0/platform.json index 6ed5a3a84aa8..98a60a5e898f 100644 --- a/device/mellanox/x86_64-mlnx_msn2410-r0/platform.json +++ b/device/mellanox/x86_64-mlnx_msn2410-r0/platform.json @@ -114,6 +114,9 @@ }, { "name": "CPU Pack Temp" + }, + { + "name": "SODIMM 1 Temp" } ], "sfps": [ 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 3a3f2499c8d8..e94c7693824d 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,5 +1,5 @@ {# - Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. + Copyright (c) 2021-2023 NVIDIA CORPORATION & AFFILIATES. Apache-2.0 Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,10 +15,17 @@ limitations under the License. #} {% set default_cable = '5m' %} -{% set ingress_lossless_pool_size = '7719936' %} -{% set ingress_lossless_pool_xoff = '1032192' %} +{%- if ((SYSTEM_DEFAULTS is defined) and ('tunnel_qos_remap' in SYSTEM_DEFAULTS) and (SYSTEM_DEFAULTS['tunnel_qos_remap']['status'] == 'enabled')) -%} +{% set ingress_lossless_pool_size = '9047040' %} +{% set ingress_lossless_pool_xoff = '851968' %} {% set egress_lossless_pool_size = '13945824' %} -{% set egress_lossy_pool_size = '7719936' %} +{% set egress_lossy_pool_size = '9047040' %} +{%- else -%} +{% set ingress_lossless_pool_size = '9595904' %} +{% set ingress_lossless_pool_xoff = '614400' %} +{% set egress_lossless_pool_size = '13945824' %} +{% set egress_lossy_pool_size = '9595904' %} +{%- endif -%} {% import 'buffers_defaults_objects.j2' as defs with context %} @@ -30,10 +37,18 @@ {{ defs.generate_profile_lists(port_names_active, port_names_inactive) }} {%- endmacro %} +{%- macro generate_queue_buffers_with_extra_lossless_queues_with_inactive_ports(port_names_active, port_names_extra_queues, port_names_inactive) %} +{{ defs.generate_queue_buffers_with_extra_lossless_queues(port_names_active, port_names_extra_queues, port_names_inactive) }} +{%- endmacro %} + {%- macro generate_queue_buffers_with_inactive_ports(port_names_active, port_names_inactive) %} {{ defs.generate_queue_buffers(port_names_active, port_names_inactive) }} {%- endmacro %} +{%- macro generate_pg_profiles_with_extra_lossless_pgs_with_inactive_ports(port_names_active, port_names_extra_pgs, port_names_inactive) %} +{{ defs.generate_pg_profiles_with_extra_lossless_pgs(port_names_active, port_names_extra_pgs, port_names_inactive) }} +{%- endmacro %} + {%- macro generate_pg_profiles_with_inactive_ports(port_names_active, port_names_inactive) %} {{ defs.generate_pg_profiles(port_names_active, port_names_inactive) }} {%- endmacro %} diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/qos.json.j2 b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/qos.json.j2 deleted file mode 100644 index 94bd7dda2c37..000000000000 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/qos.json.j2 +++ /dev/null @@ -1,17 +0,0 @@ -{# - Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. - Apache-2.0 - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -#} -{%- include 'qos_config.j2' %} diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/qos.json.j2 b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/qos.json.j2 new file mode 120000 index 000000000000..48221aa2b3de --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/qos.json.j2 @@ -0,0 +1 @@ +../../x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-C64/qos.json.j2 \ No newline at end of file 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 e36cc754fa52..e94c7693824d 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,5 +1,5 @@ {# - Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. + Copyright (c) 2021-2023 NVIDIA CORPORATION & AFFILIATES. Apache-2.0 Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,10 +15,17 @@ limitations under the License. #} {% set default_cable = '5m' %} -{% set ingress_lossless_pool_size = '10177536' %} -{% set ingress_lossless_pool_xoff = '688128' %} +{%- if ((SYSTEM_DEFAULTS is defined) and ('tunnel_qos_remap' in SYSTEM_DEFAULTS) and (SYSTEM_DEFAULTS['tunnel_qos_remap']['status'] == 'enabled')) -%} +{% set ingress_lossless_pool_size = '9047040' %} +{% set ingress_lossless_pool_xoff = '851968' %} {% set egress_lossless_pool_size = '13945824' %} -{% set egress_lossy_pool_size = '10177536' %} +{% set egress_lossy_pool_size = '9047040' %} +{%- else -%} +{% set ingress_lossless_pool_size = '9595904' %} +{% set ingress_lossless_pool_xoff = '614400' %} +{% set egress_lossless_pool_size = '13945824' %} +{% set egress_lossy_pool_size = '9595904' %} +{%- endif -%} {% import 'buffers_defaults_objects.j2' as defs with context %} @@ -30,10 +37,18 @@ {{ defs.generate_profile_lists(port_names_active, port_names_inactive) }} {%- endmacro %} +{%- macro generate_queue_buffers_with_extra_lossless_queues_with_inactive_ports(port_names_active, port_names_extra_queues, port_names_inactive) %} +{{ defs.generate_queue_buffers_with_extra_lossless_queues(port_names_active, port_names_extra_queues, port_names_inactive) }} +{%- endmacro %} + {%- macro generate_queue_buffers_with_inactive_ports(port_names_active, port_names_inactive) %} {{ defs.generate_queue_buffers(port_names_active, port_names_inactive) }} {%- endmacro %} +{%- macro generate_pg_profiles_with_extra_lossless_pgs_with_inactive_ports(port_names_active, port_names_extra_pgs, port_names_inactive) %} +{{ defs.generate_pg_profiles_with_extra_lossless_pgs(port_names_active, port_names_extra_pgs, port_names_inactive) }} +{%- endmacro %} + {%- macro generate_pg_profiles_with_inactive_ports(port_names_active, port_names_inactive) %} {{ defs.generate_pg_profiles(port_names_active, port_names_inactive) }} {%- endmacro %} diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700/qos.json.j2 b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700/qos.json.j2 index 8bd2d26567b8..48221aa2b3de 120000 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700/qos.json.j2 +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700/qos.json.j2 @@ -1 +1 @@ -../ACS-MSN2700/qos.json.j2 \ No newline at end of file +../../x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-C64/qos.json.j2 \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/platform.json b/device/mellanox/x86_64-mlnx_msn2700-r0/platform.json index 063a211e785c..22599926e3fa 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/platform.json +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/platform.json @@ -114,6 +114,9 @@ }, { "name": "CPU Pack Temp" + }, + { + "name": "SODIMM 1 Temp" } ], "sfps": [ diff --git a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-C64/buffers_defaults_t0.j2 b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-C64/buffers_defaults_t0.j2 index a66a404bb2c2..0269b1b52f35 100644 --- a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-C64/buffers_defaults_t0.j2 +++ b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-C64/buffers_defaults_t0.j2 @@ -1,5 +1,5 @@ {# - Copyright (c) 2018-2021 NVIDIA CORPORATION & AFFILIATES. + Copyright (c) 2018-2023 NVIDIA CORPORATION & AFFILIATES. Apache-2.0 Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,10 +15,17 @@ limitations under the License. #} {% set default_cable = '5m' %} -{% set ingress_lossless_pool_size = '49905664' %} -{% set ingress_lossless_pool_xoff = '3702784' %} +{%- if ((SYSTEM_DEFAULTS is defined) and ('tunnel_qos_remap' in SYSTEM_DEFAULTS) and (SYSTEM_DEFAULTS['tunnel_qos_remap']['status'] == 'enabled')) -%} +{% set ingress_lossless_pool_size = '50667520' %} +{% set ingress_lossless_pool_xoff = '2629632' %} {% set egress_lossless_pool_size = '60817392' %} -{% set egress_lossy_pool_size = '49905664' %} +{% set egress_lossy_pool_size = '50667520' %} +{%- else -%} +{% set ingress_lossless_pool_size = '51511296' %} +{% set ingress_lossless_pool_xoff = '2097152' %} +{% set egress_lossless_pool_size = '60817392' %} +{% set egress_lossy_pool_size = '51511296' %} +{%- endif -%} {% import 'buffers_defaults_objects.j2' as defs with context %} @@ -30,10 +37,18 @@ {{ defs.generate_profile_lists(port_names_active, port_names_inactive) }} {%- endmacro %} +{%- macro generate_queue_buffers_with_extra_lossless_queues_with_inactive_ports(port_names_active, port_names_extra_queues, port_names_inactive) %} +{{ defs.generate_queue_buffers_with_extra_lossless_queues(port_names_active, port_names_extra_queues, port_names_inactive) }} +{%- endmacro %} + {%- macro generate_queue_buffers_with_inactive_ports(port_names_active, port_names_inactive) %} {{ defs.generate_queue_buffers(port_names_active, port_names_inactive) }} {%- endmacro %} +{%- macro generate_pg_profiles_with_extra_lossless_pgs_with_inactive_ports(port_names_active, port_names_extra_pgs, port_names_inactive) %} +{{ defs.generate_pg_profiles_with_extra_lossless_pgs(port_names_active, port_names_extra_pgs, port_names_inactive) }} +{%- endmacro %} + {%- macro generate_pg_profiles_with_inactive_ports(port_names_active, port_names_inactive) %} {{ defs.generate_pg_profiles(port_names_active, port_names_inactive) }} {%- endmacro %} diff --git a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-C64/qos.json.j2 b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-C64/qos.json.j2 index 6134402aad53..b3bc96fb83c3 100644 --- a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-C64/qos.json.j2 +++ b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-C64/qos.json.j2 @@ -1,5 +1,5 @@ {# - Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. + Copyright (c) 2020-2023 NVIDIA CORPORATION & AFFILIATES. Apache-2.0 Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,18 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. #} -{% if ('type' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['type'] == 'LeafRouter') %} + +{% if (('type' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['type'] == 'LeafRouter') or + ('type' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['type'] == 'ToRRouter') and + ('subtype' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['subtype'] == 'DualToR')) %} {% set different_dscp_to_tc_map = true %} -{%- macro generate_dscp_to_tc_map() %} - "DSCP_TO_TC_MAP": { - "AZURE": { +{%- macro generate_normal_dscp_to_tc_map(tc_mapped_from_dscp_33) -%} + { "0" : "1", "1" : "1", - "2" : "2", + "2" : "1", "3" : "3", "4" : "4", "5" : "1", - "6" : "6", + "6" : "1", "7" : "1", "8" : "0", "9" : "1", @@ -52,7 +54,7 @@ "30": "1", "31": "1", "32": "1", - "33": "1", + "33": "{{tc_mapped_from_dscp_33}}", "34": "1", "35": "1", "36": "1", @@ -83,15 +85,17 @@ "61": "1", "62": "1", "63": "1" - }, - "AZURE_UPLINK": { + } +{%- endmacro -%} +{%- macro generate_dscp_to_tc_map_with_addition_lossless_pgs_n_queues(tc_mapped_from_dscp_33) -%} + { "0" : "1", "1" : "1", - "2" : "1", + "2" : "2", "3" : "3", "4" : "4", "5" : "1", - "6" : "1", + "6" : "6", "7" : "1", "8" : "0", "9" : "1", @@ -118,7 +122,7 @@ "30": "1", "31": "1", "32": "1", - "33": "1", + "33": "{{tc_mapped_from_dscp_33}}", "34": "1", "35": "1", "36": "1", @@ -150,10 +154,52 @@ "62": "1", "63": "1" } +{%- endmacro -%} +{%- macro generate_dscp_to_tc_map() %} + "DSCP_TO_TC_MAP": { +{% if ('type' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['type'] == 'LeafRouter') %} + "AZURE_UPLINK": + {{ generate_normal_dscp_to_tc_map("1") }}, + "AZURE": + {{ generate_dscp_to_tc_map_with_addition_lossless_pgs_n_queues("1") }} +{% endif %} +{% if ('type' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['type'] == 'ToRRouter') %} + "AZURE_UPLINK": + {{ generate_dscp_to_tc_map_with_addition_lossless_pgs_n_queues("8") }}, + "AZURE_TUNNEL": + {{ generate_normal_dscp_to_tc_map("8") }}, + "AZURE": + {{ generate_normal_dscp_to_tc_map("8") }} +{% endif %} }, {%- endmacro %} {%- macro generate_tc_to_pg_map() %} "TC_TO_PRIORITY_GROUP_MAP": { +{% if (('type' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['type'] == 'ToRRouter') and + ('subtype' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['subtype'] == 'DualToR')) %} + "AZURE_TUNNEL": { + "0": "0", + "1": "0", + "2": "0", + "3": "2", + "4": "6", + "5": "0", + "6": "0", + "7": "0", + "8": "0" + }, + "AZURE": { + "0": "0", + "1": "0", + "2": "2", + "3": "3", + "4": "4", + "5": "0", + "6": "6", + "7": "0", + "8": "0" + } +{% else %} "AZURE": { "0": "0", "1": "0", @@ -164,8 +210,67 @@ "6": "6", "7": "0" } +{% endif %} + }, +{%- endmacro %} +{%- macro generate_tc_to_queue_map() %} + "TC_TO_QUEUE_MAP": { +{% if (('type' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['type'] == 'ToRRouter') and + ('subtype' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['subtype'] == 'DualToR')) %} + "AZURE_TUNNEL": { + "0": "0", + "1": "1", + "2": "2", + "3": "2", + "4": "6", + "5": "5", + "6": "6", + "7": "7", + "8": "1" + }, + "AZURE": { + "0": "0", + "1": "1", + "2": "2", + "3": "3", + "4": "4", + "5": "5", + "6": "6", + "7": "7", + "8": "1" + } +{% else %} + "AZURE": { + "0": "0", + "1": "1", + "2": "2", + "3": "3", + "4": "4", + "5": "5", + "6": "6", + "7": "7" + } +{% endif %} + }, +{%- endmacro %} +{% if (('type' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['type'] == 'ToRRouter') and + ('subtype' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['subtype'] == 'DualToR')) %} +{%- macro generate_tc_to_dscp_map() %} + "TC_TO_DSCP_MAP": { + "AZURE_TUNNEL": { + "0": "8", + "1": "0", + "2": "2", + "3": "2", + "4": "6", + "5": "46", + "6": "6", + "7": "48", + "8": "33" + } }, {%- endmacro %} +{%- endif %} {%- macro generate_global_dscp_to_tc_map() %} {# This is an empty macro since the global DSCP_TO_TC map is not required #} {%- endmacro %} diff --git a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D48C40/buffers_defaults_t0.j2 b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D48C40/buffers_defaults_t0.j2 index 87d8bda4c55f..87f8207ab75f 100644 --- a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D48C40/buffers_defaults_t0.j2 +++ b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D48C40/buffers_defaults_t0.j2 @@ -1,5 +1,5 @@ {# - Copyright (c) 2018-2021 NVIDIA CORPORATION & AFFILIATES. + Copyright (c) 2018-2023 NVIDIA CORPORATION & AFFILIATES. Apache-2.0 Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,10 +15,17 @@ limitations under the License. #} {% set default_cable = '5m' %} -{% set ingress_lossless_pool_size = '47398912' %} -{% set ingress_lossless_pool_xoff = '3604480' %} +{%- if ((SYSTEM_DEFAULTS is defined) and ('tunnel_qos_remap' in SYSTEM_DEFAULTS) and (SYSTEM_DEFAULTS['tunnel_qos_remap']['status'] == 'enabled')) -%} +{% set ingress_lossless_pool_size = '55058432' %} +{% set ingress_lossless_pool_xoff = '1712128' %} {% set egress_lossless_pool_size = '60817392' %} -{% set egress_lossy_pool_size = '47398912' %} +{% set egress_lossy_pool_size = '55058432' %} +{%- else -%} +{% set ingress_lossless_pool_size = '55902208' %} +{% set ingress_lossless_pool_xoff = '1179648' %} +{% set egress_lossless_pool_size = '60817392' %} +{% set egress_lossy_pool_size = '55902208' %} +{%- endif -%} {% import 'buffers_defaults_objects.j2' as defs with context %} @@ -30,10 +37,18 @@ {{ defs.generate_profile_lists(port_names_active, port_names_inactive) }} {%- endmacro %} +{%- macro generate_queue_buffers_with_extra_lossless_queues_with_inactive_ports(port_names_active, port_names_extra_queues, port_names_inactive) %} +{{ defs.generate_queue_buffers_with_extra_lossless_queues(port_names_active, port_names_extra_queues, port_names_inactive) }} +{%- endmacro %} + {%- macro generate_queue_buffers_with_inactive_ports(port_names_active, port_names_inactive) %} {{ defs.generate_queue_buffers(port_names_active, port_names_inactive) }} {%- endmacro %} +{%- macro generate_pg_profiles_with_extra_lossless_pgs_with_inactive_ports(port_names_active, port_names_extra_pgs, port_names_inactive) %} +{{ defs.generate_pg_profiles_with_extra_lossless_pgs(port_names_active, port_names_extra_pgs, port_names_inactive) }} +{%- endmacro %} + {%- macro generate_pg_profiles_with_inactive_ports(port_names_active, port_names_inactive) %} {{ defs.generate_pg_profiles(port_names_active, port_names_inactive) }} {%- endmacro %} diff --git a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D48C40/qos.json.j2 b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D48C40/qos.json.j2 index 05394016a129..c06f6bddc387 120000 --- a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D48C40/qos.json.j2 +++ b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D48C40/qos.json.j2 @@ -1 +1 @@ -../ACS-MSN4600C/qos.json.j2 \ No newline at end of file +../Mellanox-SN4600C-C64/qos.json.j2 \ No newline at end of file diff --git a/device/mellanox/x86_64-nvidia_sn2201-r0/platform.json b/device/mellanox/x86_64-nvidia_sn2201-r0/platform.json index 83250c75f74e..b0ab14793910 100644 --- a/device/mellanox/x86_64-nvidia_sn2201-r0/platform.json +++ b/device/mellanox/x86_64-nvidia_sn2201-r0/platform.json @@ -101,6 +101,9 @@ }, { "name": "ASIC" + }, + { + "name": "SODIMM 1 Temp" } ], "sfps": [{ diff --git a/device/mellanox/x86_64-nvidia_sn5600-r0/ACS-SN5600/buffers.json.j2 b/device/mellanox/x86_64-nvidia_sn5600-r0/ACS-SN5600/buffers.json.j2 new file mode 120000 index 000000000000..add8bf8bb7c2 --- /dev/null +++ b/device/mellanox/x86_64-nvidia_sn5600-r0/ACS-SN5600/buffers.json.j2 @@ -0,0 +1 @@ +../../x86_64-mlnx_msn2700-r0/ACS-MSN2700/buffers.json.j2 \ No newline at end of file diff --git a/device/mellanox/x86_64-nvidia_sn5600-r0/ACS-SN5600/buffers_defaults_objects.j2 b/device/mellanox/x86_64-nvidia_sn5600-r0/ACS-SN5600/buffers_defaults_objects.j2 new file mode 120000 index 000000000000..33b6704f9902 --- /dev/null +++ b/device/mellanox/x86_64-nvidia_sn5600-r0/ACS-SN5600/buffers_defaults_objects.j2 @@ -0,0 +1 @@ +../../x86_64-mlnx_msn2700-r0/ACS-MSN2700/buffers_defaults_objects.j2 \ No newline at end of file diff --git a/device/mellanox/x86_64-nvidia_sn5600-r0/ACS-SN5600/buffers_defaults_t0.j2 b/device/mellanox/x86_64-nvidia_sn5600-r0/ACS-SN5600/buffers_defaults_t0.j2 new file mode 100644 index 000000000000..b03bcf004505 --- /dev/null +++ b/device/mellanox/x86_64-nvidia_sn5600-r0/ACS-SN5600/buffers_defaults_t0.j2 @@ -0,0 +1,128 @@ +{# + Copyright (c) 2021-2022 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} +{% set default_cable = '5m' %} +{% set ingress_lossless_pool_size = '67737959' %} +{% set ingress_lossy_pool_size = '67737959' %} +{% set egress_lossless_pool_size = '158229504' %} +{% set egress_lossy_pool_size = '67737959' %} + +{%- 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": { + {%- if dynamic_mode is not defined %} + "size": "{{ ingress_lossless_pool_size }}", + {%- endif %} + "type": "ingress", + "mode": "dynamic" + }, + "ingress_lossy_pool": { + {%- if dynamic_mode is not defined %} + "size": "{{ ingress_lossy_pool_size }}", + {%- endif %} + "type": "ingress", + "mode": "dynamic" + }, + "egress_lossless_pool": { + "size": "{{ egress_lossless_pool_size }}", + "type": "egress", + "mode": "dynamic" + }, + "egress_lossy_pool": { + {%- if dynamic_mode is not defined %} + "size": "{{ egress_lossy_pool_size }}", + {%- endif %} + "type": "egress", + "mode": "dynamic" + } + }, + "BUFFER_PROFILE": { + "ingress_lossless_profile": { + "pool":"ingress_lossless_pool", + "size":"0", + "dynamic_th":"7" + }, + "ingress_lossy_profile": { + "pool":"ingress_lossy_pool", + "size":"0", + "dynamic_th":"3" + }, + "egress_lossless_profile": { + "pool":"egress_lossless_pool", + "size":"0", + "dynamic_th":"7" + }, + "egress_lossy_profile": { + "pool":"egress_lossy_pool", + "size":"9216", + "dynamic_th":"7" + }, + "q_lossy_profile": { + "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" : "ingress_lossless_profile,ingress_lossy_profile" + }{% if not loop.last %},{% endif %} + +{% endfor %} + }, + "BUFFER_PORT_EGRESS_PROFILE_LIST": { +{% for port in port_names.split(',') %} + "{{ port }}": { + "profile_list" : "egress_lossless_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" : "egress_lossless_profile" + }, +{% endfor %} +{% for port in port_names.split(',') %} + "{{ port }}|0-2": { + "profile" : "q_lossy_profile" + }, +{% endfor %} +{% for port in port_names.split(',') %} + "{{ port }}|5-6": { + "profile" : "q_lossy_profile" + }{% if not loop.last %},{% endif %} + +{% endfor %} + } +{%- endmacro %} + + diff --git a/device/mellanox/x86_64-nvidia_sn5600-r0/ACS-SN5600/buffers_defaults_t1.j2 b/device/mellanox/x86_64-nvidia_sn5600-r0/ACS-SN5600/buffers_defaults_t1.j2 new file mode 100644 index 000000000000..374c23fd8ddc --- /dev/null +++ b/device/mellanox/x86_64-nvidia_sn5600-r0/ACS-SN5600/buffers_defaults_t1.j2 @@ -0,0 +1,128 @@ +{# + Copyright (c) 2021-2022 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} +{% set default_cable = '5m' %} +{% set ingress_lossless_pool_size = '52161690' %} +{% set ingress_lossy_pool_size = '52161690' %} +{% set egress_lossless_pool_size = '158229504' %} +{% set egress_lossy_pool_size = '52161690' %} + +{%- 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": { + {%- if dynamic_mode is not defined %} + "size": "{{ ingress_lossless_pool_size }}", + {%- endif %} + "type": "ingress", + "mode": "dynamic" + }, + "ingress_lossy_pool": { + {%- if dynamic_mode is not defined %} + "size": "{{ ingress_lossy_pool_size }}", + {%- endif %} + "type": "ingress", + "mode": "dynamic" + }, + "egress_lossless_pool": { + "size": "{{ egress_lossless_pool_size }}", + "type": "egress", + "mode": "dynamic" + }, + "egress_lossy_pool": { + {%- if dynamic_mode is not defined %} + "size": "{{ egress_lossy_pool_size }}", + {%- endif %} + "type": "egress", + "mode": "dynamic" + } + }, + "BUFFER_PROFILE": { + "ingress_lossless_profile": { + "pool":"ingress_lossless_pool", + "size":"0", + "dynamic_th":"7" + }, + "ingress_lossy_profile": { + "pool":"ingress_lossy_pool", + "size":"0", + "dynamic_th":"3" + }, + "egress_lossless_profile": { + "pool":"egress_lossless_pool", + "size":"0", + "dynamic_th":"7" + }, + "egress_lossy_profile": { + "pool":"egress_lossy_pool", + "size":"9216", + "dynamic_th":"7" + }, + "q_lossy_profile": { + "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" : "ingress_lossless_profile,ingress_lossy_profile" + }{% if not loop.last %},{% endif %} + +{% endfor %} + }, + "BUFFER_PORT_EGRESS_PROFILE_LIST": { +{% for port in port_names.split(',') %} + "{{ port }}": { + "profile_list" : "egress_lossless_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" : "egress_lossless_profile" + }, +{% endfor %} +{% for port in port_names.split(',') %} + "{{ port }}|0-2": { + "profile" : "q_lossy_profile" + }, +{% endfor %} +{% for port in port_names.split(',') %} + "{{ port }}|5-6": { + "profile" : "q_lossy_profile" + }{% if not loop.last %},{% endif %} + +{% endfor %} + } +{%- endmacro %} + + diff --git a/device/mellanox/x86_64-nvidia_sn5600-r0/ACS-SN5600/buffers_dynamic.json.j2 b/device/mellanox/x86_64-nvidia_sn5600-r0/ACS-SN5600/buffers_dynamic.json.j2 new file mode 120000 index 000000000000..8c4117c66214 --- /dev/null +++ b/device/mellanox/x86_64-nvidia_sn5600-r0/ACS-SN5600/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-nvidia_sn5600-r0/ACS-SN5600/hwsku.json b/device/mellanox/x86_64-nvidia_sn5600-r0/ACS-SN5600/hwsku.json new file mode 100644 index 000000000000..3593da62c767 --- /dev/null +++ b/device/mellanox/x86_64-nvidia_sn5600-r0/ACS-SN5600/hwsku.json @@ -0,0 +1,199 @@ +{ + "interfaces": { + "Ethernet0": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet8": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet16": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet24": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet32": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet40": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet48": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet56": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet64": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet72": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet80": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet88": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet96": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet104": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet112": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet120": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet128": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet136": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet144": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet152": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet160": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet168": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet176": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet184": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet192": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet200": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet208": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet216": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet224": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet232": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet240": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet248": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet256": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet264": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet272": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet280": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet288": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet296": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet304": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet312": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet320": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet328": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet336": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet344": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet352": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet360": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet368": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet376": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet384": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet392": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet400": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet408": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet416": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet424": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet432": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet440": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet448": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet456": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet464": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet472": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet480": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet488": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet496": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet504": { + "default_brkout_mode": "1x800G[400G,200G,100G,50G,40G,25G,10G]" + }, + "Ethernet512": { + "default_brkout_mode": "1x25G[10G]" + } + } +} diff --git a/device/mellanox/x86_64-nvidia_sn5600-r0/ACS-SN5600/pg_profile_lookup.ini b/device/mellanox/x86_64-nvidia_sn5600-r0/ACS-SN5600/pg_profile_lookup.ini new file mode 100644 index 000000000000..d67d2d7a1691 --- /dev/null +++ b/device/mellanox/x86_64-nvidia_sn5600-r0/ACS-SN5600/pg_profile_lookup.ini @@ -0,0 +1,42 @@ +## +## Copyright (c) 2021-2022 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## +# PG lossless profiles. +# speed cable size xon xoff threshold + 10000 5m 64512 19456 45056 0 + 25000 5m 67584 19456 48128 0 + 40000 5m 75776 19456 57344 0 + 50000 5m 82944 19456 63488 0 + 100000 5m 133120 19456 113664 0 + 200000 5m 150528 19456 131072 0 + 400000 5m 250880 19456 231424 0 + 800000 5m 304128 38912 257024 0 + 10000 40m 65536 19456 46080 0 + 25000 40m 71680 19456 52224 0 + 40000 40m 81920 19456 62464 0 + 50000 40m 89088 19456 69632 0 + 100000 40m 146432 19456 126976 0 + 200000 40m 177152 19456 157696 0 + 400000 40m 303104 19456 283648 0 + 800000 40m 410624 38912 362496 0 + 10000 300m 75776 19456 56320 0 + 25000 300m 96256 19456 76800 0 + 40000 300m 120832 19456 101376 0 + 50000 300m 138240 19456 118784 0 + 100000 300m 244736 19456 225280 0 + 200000 300m 374784 19456 355328 0 + 400000 300m 697344 19456 677888 0 + 800000 300m 1198080 38912 1150976 0 diff --git a/device/mellanox/x86_64-nvidia_sn5600-r0/ACS-SN5600/port_config.ini b/device/mellanox/x86_64-nvidia_sn5600-r0/ACS-SN5600/port_config.ini new file mode 100644 index 000000000000..a60682342fc1 --- /dev/null +++ b/device/mellanox/x86_64-nvidia_sn5600-r0/ACS-SN5600/port_config.ini @@ -0,0 +1,82 @@ +## +## Copyright (c) 2021-2022 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## +# name lanes alias index +Ethernet0 0,1,2,3,4,5,6,7 etp1 1 +Ethernet8 8,9,10,11,12,13,14,15 etp2 2 +Ethernet16 16,17,18,19,20,21,22,23 etp3 3 +Ethernet24 24,25,26,27,28,29,30,31 etp4 4 +Ethernet32 32,33,34,35,36,37,38,39 etp5 5 +Ethernet40 40,41,42,43,44,45,46,47 etp6 6 +Ethernet48 48,49,50,51,52,53,54,55 etp7 7 +Ethernet56 56,57,58,59,60,61,62,63 etp8 8 +Ethernet64 64,65,66,67,68,69,70,71 etp9 9 +Ethernet72 72,73,74,75,76,77,78,79 etp10 10 +Ethernet80 80,81,82,83,84,85,86,87 etp11 11 +Ethernet88 88,89,90,91,92,93,94,95 etp12 12 +Ethernet96 96,97,98,99,100,101,102,103 etp13 13 +Ethernet104 104,105,106,107,108,109,110,111 etp14 14 +Ethernet112 112,113,114,115,116,117,118,119 etp15 15 +Ethernet120 120,121,122,123,124,125,126,127 etp16 16 +Ethernet128 128,129,130,131,132,133,134,135 etp17 17 +Ethernet136 136,137,138,139,140,141,142,143 etp18 18 +Ethernet144 144,145,146,147,148,149,150,151 etp19 19 +Ethernet152 152,153,154,155,156,157,158,159 etp20 20 +Ethernet160 160,161,162,163,164,165,166,167 etp21 21 +Ethernet168 168,169,170,171,172,173,174,175 etp22 22 +Ethernet176 176,177,178,179,180,181,182,183 etp23 23 +Ethernet184 184,185,186,187,188,189,190,191 etp24 24 +Ethernet192 192,193,194,195,196,197,198,199 etp25 25 +Ethernet200 200,201,202,203,204,205,206,207 etp26 26 +Ethernet208 208,209,210,211,212,213,214,215 etp27 27 +Ethernet216 216,217,218,219,220,221,222,223 etp28 28 +Ethernet224 224,225,226,227,228,229,230,231 etp29 29 +Ethernet232 232,233,234,235,236,237,238,239 etp30 30 +Ethernet240 240,241,242,243,244,245,246,247 etp31 31 +Ethernet248 248,249,250,251,252,253,254,255 etp32 32 +Ethernet256 256,257,258,259,260,261,262,263 etp33 33 +Ethernet264 264,265,266,267,268,269,270,271 etp34 34 +Ethernet272 272,273,274,275,276,277,278,279 etp35 35 +Ethernet280 280,281,282,283,284,285,286,287 etp36 36 +Ethernet288 288,289,290,291,292,293,294,295 etp37 37 +Ethernet296 296,297,298,299,300,301,302,303 etp38 38 +Ethernet304 304,305,306,307,308,309,310,311 etp39 39 +Ethernet312 312,313,314,315,316,317,318,319 etp40 40 +Ethernet320 320,321,322,323,324,325,326,327 etp41 41 +Ethernet328 328,329,330,331,332,333,334,335 etp42 42 +Ethernet336 336,337,338,339,340,341,342,343 etp43 43 +Ethernet344 344,345,346,347,348,349,350,351 etp44 44 +Ethernet352 352,353,354,355,356,357,358,359 etp45 45 +Ethernet360 360,361,362,363,364,365,366,367 etp46 46 +Ethernet368 368,369,370,371,372,373,374,375 etp47 47 +Ethernet376 376,377,378,379,380,381,382,383 etp48 48 +Ethernet384 384,385,386,387,388,389,390,391 etp49 49 +Ethernet392 392,393,394,395,396,397,398,399 etp50 50 +Ethernet400 400,401,402,403,404,405,406,407 etp51 51 +Ethernet408 408,409,410,411,412,413,414,415 etp52 52 +Ethernet416 416,417,418,419,420,421,422,423 etp53 53 +Ethernet424 424,425,426,427,428,429,430,431 etp54 54 +Ethernet432 432,433,434,435,436,437,438,439 etp55 55 +Ethernet440 440,441,442,443,444,445,446,447 etp56 56 +Ethernet448 448,449,450,451,452,453,454,455 etp57 57 +Ethernet456 456,457,458,459,460,461,462,463 etp58 58 +Ethernet464 464,465,466,467,468,469,470,471 etp59 59 +Ethernet472 472,473,474,475,476,477,478,479 etp60 60 +Ethernet480 480,481,482,483,484,485,486,487 etp61 61 +Ethernet488 488,489,490,491,492,493,494,495 etp62 62 +Ethernet496 496,497,498,499,500,501,502,503 etp63 63 +Ethernet504 504,505,506,507,508,509,510,511 etp64 64 +Ethernet512 512 etp65 65 diff --git a/device/mellanox/x86_64-nvidia_sn5600-r0/ACS-SN5600/qos.json.j2 b/device/mellanox/x86_64-nvidia_sn5600-r0/ACS-SN5600/qos.json.j2 new file mode 120000 index 000000000000..eccf286dc879 --- /dev/null +++ b/device/mellanox/x86_64-nvidia_sn5600-r0/ACS-SN5600/qos.json.j2 @@ -0,0 +1 @@ +../../x86_64-mlnx_msn2700-r0/ACS-MSN2700/qos.json.j2 \ No newline at end of file diff --git a/device/mellanox/x86_64-nvidia_sn5600-r0/ACS-SN5600/sai.profile b/device/mellanox/x86_64-nvidia_sn5600-r0/ACS-SN5600/sai.profile new file mode 100644 index 000000000000..b37ca8c3ed0c --- /dev/null +++ b/device/mellanox/x86_64-nvidia_sn5600-r0/ACS-SN5600/sai.profile @@ -0,0 +1,3 @@ +SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/sai_5600.xml +SAI_DUMP_STORE_PATH=/var/log/mellanox/sdk-dumps +SAI_DUMP_STORE_AMOUNT=10 diff --git a/device/mellanox/x86_64-nvidia_sn5600-r0/ACS-SN5600/sai_5600.xml b/device/mellanox/x86_64-nvidia_sn5600-r0/ACS-SN5600/sai_5600.xml new file mode 100644 index 000000000000..6f619a1fc17f --- /dev/null +++ b/device/mellanox/x86_64-nvidia_sn5600-r0/ACS-SN5600/sai_5600.xml @@ -0,0 +1,502 @@ + + + + + + + 00:02:03:04:05:00 + + + 1 + + + 65 + + + + + 1 + 8 + 34 + + + 3 + + + 1536 + + + 5 + 8 + 35 + 3 + 1536 + + + 9 + 8 + 32 + 3 + 1536 + + + 13 + 8 + 33 + 3 + 1536 + + + 17 + 8 + 38 + 3 + 1536 + + + 21 + 8 + 39 + 3 + 1536 + + + 25 + 8 + 36 + 3 + 1536 + + + 29 + 8 + 37 + 3 + 1536 + + + 33 + 8 + 42 + 3 + 1536 + + + 37 + 8 + 43 + 3 + 1536 + + + 41 + 8 + 40 + 3 + 1536 + + + 45 + 8 + 41 + 3 + 1536 + + + 49 + 8 + 46 + 3 + 1536 + + + 53 + 8 + 47 + 3 + 1536 + + + 57 + 8 + 44 + 3 + 1536 + + + 61 + 8 + 45 + 3 + 1536 + + + 65 + 8 + 58 + 3 + 1536 + + + 69 + 8 + 59 + 3 + 1536 + + + 73 + 8 + 56 + 3 + 1536 + + + 77 + 8 + 57 + 3 + 1536 + + + 81 + 8 + 62 + 3 + 1536 + + + 85 + 8 + 63 + 3 + 1536 + + + 89 + 8 + 60 + 3 + 1536 + + + 93 + 8 + 61 + 3 + 1536 + + + 97 + 8 + 50 + 3 + 1536 + + + 101 + 8 + 51 + 3 + 1536 + + + 105 + 8 + 48 + + + 3 + + + 1536 + + + 109 + 8 + 49 + 3 + 1536 + + + 113 + 8 + 54 + 3 + 1536 + + + 117 + 8 + 55 + 3 + 1536 + + + 121 + 8 + 52 + 3 + 1536 + + + 125 + 8 + 53 + 3 + 1536 + + + 129 + 8 + 28 + 3 + 1536 + + + 133 + 8 + 29 + 3 + 1536 + + + 137 + 8 + 30 + 3 + 1536 + + + 141 + 8 + 31 + 3 + 1536 + + + 145 + 8 + 24 + 3 + 1536 + + + 149 + 8 + 25 + 3 + 1536 + + + 153 + 8 + 26 + 3 + 1536 + + + 157 + 8 + 27 + 3 + 1536 + + + 161 + 8 + 20 + 3 + 1536 + + + 165 + 8 + 21 + 3 + 1536 + + + 169 + 8 + 22 + 3 + 1536 + + + 173 + 8 + 23 + 3 + 1536 + + + 177 + 8 + 16 + 3 + 1536 + + + 181 + 8 + 17 + 3 + 1536 + + + 185 + 8 + 18 + 3 + 1536 + + + 189 + 8 + 19 + 3 + 1536 + + + 193 + 8 + 4 + 3 + 1536 + + + 197 + 8 + 5 + 3 + 1536 + + + 201 + 8 + 6 + 3 + 1536 + + + 205 + 8 + 7 + 3 + 1536 + + + 209 + 8 + 0 + 3 + 1536 + + + 213 + 8 + 1 + 3 + 1536 + + + 217 + 8 + 2 + 3 + 1536 + + + 221 + 8 + 3 + 3 + 1536 + + + 225 + 8 + 12 + 3 + 1536 + + + 229 + 8 + 13 + 3 + 1536 + + + 233 + 8 + 14 + + + 3 + + + 1536 + + + 237 + 8 + 15 + 3 + 1536 + + + 241 + 8 + 8 + 3 + 1536 + + + 245 + 8 + 9 + 3 + 1536 + + + 249 + 8 + 10 + 3 + 1536 + + + 253 + 8 + 11 + 3 + 1536 + + + 257 + 1 + 64 + 0 + 64 + + + + + diff --git a/device/mellanox/x86_64-nvidia_sn5600-r0/default_sku b/device/mellanox/x86_64-nvidia_sn5600-r0/default_sku new file mode 100644 index 000000000000..38a760f3c747 --- /dev/null +++ b/device/mellanox/x86_64-nvidia_sn5600-r0/default_sku @@ -0,0 +1 @@ +ACS-SN5600 t1 diff --git a/device/mellanox/x86_64-nvidia_sn5600-r0/pcie.yaml b/device/mellanox/x86_64-nvidia_sn5600-r0/pcie.yaml new file mode 100644 index 000000000000..20da81d7dc86 --- /dev/null +++ b/device/mellanox/x86_64-nvidia_sn5600-r0/pcie.yaml @@ -0,0 +1,146 @@ +## +## Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## + +- bus: '00' + dev: '00' + fn: '0' + id: 3ec4 + name: 'Host bridge: Intel Corporation 8th Gen Core Processor Host Bridge/DRAM Registers + (rev 07)' +- bus: '00' + dev: '01' + fn: '0' + id: '1901' + name: 'PCI bridge: Intel Corporation 6th-10th Gen Core Processor PCIe Controller + (x16) (rev 07)' +- bus: '00' + dev: '01' + fn: '1' + id: '1905' + name: 'PCI bridge: Intel Corporation Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor + PCIe Controller (x8) (rev 07)' +- bus: '00' + dev: 08 + fn: '0' + id: '1911' + name: 'System peripheral: Intel Corporation Xeon E3-1200 v5/v6 / E3-1500 v5 / 6th/7th/8th + Gen Core Processor Gaussian Mixture Model' +- bus: '00' + dev: '12' + fn: '0' + id: a379 + name: 'Signal processing controller: Intel Corporation Cannon Lake PCH Thermal Controller + (rev 10)' +- bus: '00' + dev: '14' + fn: '0' + id: a36d + name: 'USB controller: Intel Corporation Cannon Lake PCH USB 3.1 xHCI Host Controller + (rev 10)' +- bus: '00' + dev: '14' + fn: '2' + id: a36f + name: 'RAM memory: Intel Corporation Cannon Lake PCH Shared SRAM (rev 10)' +- bus: '00' + dev: '15' + fn: '0' + id: a368 + name: 'Serial bus controller [0c80]: Intel Corporation Cannon Lake PCH Serial IO + I2C Controller #0 (rev 10)' +- bus: '00' + dev: '16' + fn: '0' + id: a360 + name: 'Communication controller: Intel Corporation Cannon Lake PCH HECI Controller + (rev 10)' +- bus: '00' + dev: '17' + fn: '0' + id: a353 + name: 'SATA controller: Intel Corporation Cannon Lake Mobile PCH SATA AHCI Controller + (rev 10)' +- bus: '00' + dev: 1b + fn: '0' + id: a340 + name: 'PCI bridge: Intel Corporation Cannon Lake PCH PCI Express Root Port #17 (rev + f0)' +- bus: '00' + dev: 1b + fn: '2' + id: a342 + name: 'PCI bridge: Intel Corporation Cannon Lake PCH PCI Express Root Port #19 (rev + f0)' +- bus: '00' + dev: 1b + fn: '4' + id: a32c + name: 'PCI bridge: Intel Corporation Cannon Lake PCH PCI Express Root Port #21 (rev + f0)' +- bus: '00' + dev: 1c + fn: '0' + id: a33d + name: 'PCI bridge: Intel Corporation Cannon Lake PCH PCI Express Root Port #6 (rev + f0)' +- bus: '00' + dev: 1c + fn: '6' + id: a33e + name: 'PCI bridge: Intel Corporation Cannon Lake PCH PCI Express Root Port #7 (rev + f0)' +- bus: '00' + dev: 1c + fn: '7' + id: a33f + name: 'PCI bridge: Intel Corporation Cannon Lake PCH PCI Express Root Port #8 (rev + f0)' +- bus: '00' + dev: 1d + fn: '0' + id: a334 + name: 'PCI bridge: Intel Corporation Cannon Lake PCH PCI Express Root Port #13 (rev + f0)' +- bus: '00' + dev: 1e + fn: '0' + id: a328 + name: 'Communication controller: Intel Corporation Cannon Lake PCH Serial IO UART + Host Controller (rev 10)' +- bus: '00' + dev: 1f + fn: '0' + id: a30e + name: 'ISA bridge: Intel Corporation Cannon Lake LPC Controller (rev 10)' +- bus: '00' + dev: 1f + fn: '4' + id: a323 + name: 'SMBus: Intel Corporation Cannon Lake PCH SMBus Controller (rev 10)' +- bus: '00' + dev: 1f + fn: '5' + id: a324 + name: 'Serial bus controller [0c80]: Intel Corporation Cannon Lake PCH SPI Controller + (rev 10)' +- bus: '00' + dev: 1f + fn: '6' + id: 15bb + name: 'Ethernet controller: Intel Corporation Ethernet Connection (7) I219-LM (rev + 10)' \ No newline at end of file diff --git a/device/mellanox/x86_64-nvidia_sn5600-r0/platform.json b/device/mellanox/x86_64-nvidia_sn5600-r0/platform.json new file mode 100644 index 000000000000..fe98c37c47d9 --- /dev/null +++ b/device/mellanox/x86_64-nvidia_sn5600-r0/platform.json @@ -0,0 +1,1313 @@ +{ + "chassis": { + "name": "SN5600", + "components": [ + { + "name": "ONIE" + }, + { + "name": "SSD" + }, + { + "name": "BIOS" + }, + { + "name": "CPLD1" + }, + { + "name": "CPLD2" + }, + { + "name": "CPLD3" + }, + { + "name": "CPLD4" + }, + { + "name": "CPLD5" + }, + { + "name": "CPLD6" + } + ], + "fans": [], + "fan_drawers": [ + { + "name": "drawer1", + "fans": [ + { + "name": "fan1" + }, + { + "name": "fan2" + } + ] + }, + { + "name": "drawer2", + "fans": [ + { + "name": "fan3" + }, + { + "name": "fan4" + } + ] + }, + { + "name": "drawer3", + "fans": [ + { + "name": "fan5" + }, + { + "name": "fan6" + } + ] + }, + { + "name": "drawer4", + "fans": [ + { + "name": "fan7" + }, + { + "name": "fan8" + } + ] + } + ], + "psus": [ + { + "name": "PSU 1", + "fans": [ + { + "name": "psu1_fan1" + } + ], + "thermals": [ + { + "name": "PSU-1 Temp" + } + ] + }, + { + "name": "PSU 2", + "fans": [ + { + "name": "psu2_fan1" + } + ], + "thermals": [ + { + "name": "PSU-2 Temp" + } + ] + } + ], + "thermals": [ + { + "name": "ASIC" + }, + { + "name": "Ambient Fan Side Temp" + }, + { + "name": "Ambient Port Side Temp" + }, + { + "name": "CPU Core 0 Temp" + }, + { + "name": "CPU Core 1 Temp" + }, + { + "name": "CPU Core 2 Temp" + }, + { + "name": "CPU Core 3 Temp" + }, + { + "name": "CPU Core 4 Temp" + }, + { + "name": "CPU Core 5 Temp" + }, + { + "name": "CPU Pack Temp" + }, + { + "name": "SODIMM 1 Temp" + }, + { + "name": "SODIMM 2 Temp" + }, + { + "name": "PCH Temp" + } + ], + "sfps": [ + { + "name": "sfp1", + "thermals": [ + { + "name": "xSFP module 1 Temp" + } + ] + }, + { + "name": "sfp2", + "thermals": [ + { + "name": "xSFP module 2 Temp" + } + ] + }, + { + "name": "sfp3", + "thermals": [ + { + "name": "xSFP module 3 Temp" + } + ] + }, + { + "name": "sfp4", + "thermals": [ + { + "name": "xSFP module 4 Temp" + } + ] + }, + { + "name": "sfp5", + "thermals": [ + { + "name": "xSFP module 5 Temp" + } + ] + }, + { + "name": "sfp6", + "thermals": [ + { + "name": "xSFP module 6 Temp" + } + ] + }, + { + "name": "sfp7", + "thermals": [ + { + "name": "xSFP module 7 Temp" + } + ] + }, + { + "name": "sfp8", + "thermals": [ + { + "name": "xSFP module 8 Temp" + } + ] + }, + { + "name": "sfp9", + "thermals": [ + { + "name": "xSFP module 9 Temp" + } + ] + }, + { + "name": "sfp10", + "thermals": [ + { + "name": "xSFP module 10 Temp" + } + ] + }, + { + "name": "sfp11", + "thermals": [ + { + "name": "xSFP module 11 Temp" + } + ] + }, + { + "name": "sfp12", + "thermals": [ + { + "name": "xSFP module 12 Temp" + } + ] + }, + { + "name": "sfp13", + "thermals": [ + { + "name": "xSFP module 13 Temp" + } + ] + }, + { + "name": "sfp14", + "thermals": [ + { + "name": "xSFP module 14 Temp" + } + ] + }, + { + "name": "sfp15", + "thermals": [ + { + "name": "xSFP module 15 Temp" + } + ] + }, + { + "name": "sfp16", + "thermals": [ + { + "name": "xSFP module 16 Temp" + } + ] + }, + { + "name": "sfp17", + "thermals": [ + { + "name": "xSFP module 17 Temp" + } + ] + }, + { + "name": "sfp18", + "thermals": [ + { + "name": "xSFP module 18 Temp" + } + ] + }, + { + "name": "sfp19", + "thermals": [ + { + "name": "xSFP module 19 Temp" + } + ] + }, + { + "name": "sfp20", + "thermals": [ + { + "name": "xSFP module 20 Temp" + } + ] + }, + { + "name": "sfp21", + "thermals": [ + { + "name": "xSFP module 21 Temp" + } + ] + }, + { + "name": "sfp22", + "thermals": [ + { + "name": "xSFP module 22 Temp" + } + ] + }, + { + "name": "sfp23", + "thermals": [ + { + "name": "xSFP module 23 Temp" + } + ] + }, + { + "name": "sfp24", + "thermals": [ + { + "name": "xSFP module 24 Temp" + } + ] + }, + { + "name": "sfp25", + "thermals": [ + { + "name": "xSFP module 25 Temp" + } + ] + }, + { + "name": "sfp26", + "thermals": [ + { + "name": "xSFP module 26 Temp" + } + ] + }, + { + "name": "sfp27", + "thermals": [ + { + "name": "xSFP module 27 Temp" + } + ] + }, + { + "name": "sfp28", + "thermals": [ + { + "name": "xSFP module 28 Temp" + } + ] + }, + { + "name": "sfp29", + "thermals": [ + { + "name": "xSFP module 29 Temp" + } + ] + }, + { + "name": "sfp30", + "thermals": [ + { + "name": "xSFP module 30 Temp" + } + ] + }, + { + "name": "sfp31", + "thermals": [ + { + "name": "xSFP module 31 Temp" + } + ] + }, + { + "name": "sfp32", + "thermals": [ + { + "name": "xSFP module 32 Temp" + } + ] + }, + { + "name": "sfp33", + "thermals": [ + { + "name": "xSFP module 33 Temp" + } + ] + }, + { + "name": "sfp34", + "thermals": [ + { + "name": "xSFP module 34 Temp" + } + ] + }, + { + "name": "sfp35", + "thermals": [ + { + "name": "xSFP module 35 Temp" + } + ] + }, + { + "name": "sfp36", + "thermals": [ + { + "name": "xSFP module 36 Temp" + } + ] + }, + { + "name": "sfp37", + "thermals": [ + { + "name": "xSFP module 37 Temp" + } + ] + }, + { + "name": "sfp38", + "thermals": [ + { + "name": "xSFP module 38 Temp" + } + ] + }, + { + "name": "sfp39", + "thermals": [ + { + "name": "xSFP module 39 Temp" + } + ] + }, + { + "name": "sfp40", + "thermals": [ + { + "name": "xSFP module 40 Temp" + } + ] + }, + { + "name": "sfp41", + "thermals": [ + { + "name": "xSFP module 41 Temp" + } + ] + }, + { + "name": "sfp42", + "thermals": [ + { + "name": "xSFP module 42 Temp" + } + ] + }, + { + "name": "sfp43", + "thermals": [ + { + "name": "xSFP module 43 Temp" + } + ] + }, + { + "name": "sfp44", + "thermals": [ + { + "name": "xSFP module 44 Temp" + } + ] + }, + { + "name": "sfp45", + "thermals": [ + { + "name": "xSFP module 45 Temp" + } + ] + }, + { + "name": "sfp46", + "thermals": [ + { + "name": "xSFP module 46 Temp" + } + ] + }, + { + "name": "sfp47", + "thermals": [ + { + "name": "xSFP module 47 Temp" + } + ] + }, + { + "name": "sfp48", + "thermals": [ + { + "name": "xSFP module 48 Temp" + } + ] + }, + { + "name": "sfp49", + "thermals": [ + { + "name": "xSFP module 49 Temp" + } + ] + }, + { + "name": "sfp50", + "thermals": [ + { + "name": "xSFP module 50 Temp" + } + ] + }, + { + "name": "sfp51", + "thermals": [ + { + "name": "xSFP module 51 Temp" + } + ] + }, + { + "name": "sfp52", + "thermals": [ + { + "name": "xSFP module 52 Temp" + } + ] + }, + { + "name": "sfp53", + "thermals": [ + { + "name": "xSFP module 53 Temp" + } + ] + }, + { + "name": "sfp54", + "thermals": [ + { + "name": "xSFP module 54 Temp" + } + ] + }, + { + "name": "sfp55", + "thermals": [ + { + "name": "xSFP module 55 Temp" + } + ] + }, + { + "name": "sfp56", + "thermals": [ + { + "name": "xSFP module 56 Temp" + } + ] + }, + { + "name": "sfp57", + "thermals": [ + { + "name": "xSFP module 57 Temp" + } + ] + }, + { + "name": "sfp58", + "thermals": [ + { + "name": "xSFP module 58 Temp" + } + ] + }, + { + "name": "sfp59", + "thermals": [ + { + "name": "xSFP module 59 Temp" + } + ] + }, + { + "name": "sfp60", + "thermals": [ + { + "name": "xSFP module 60 Temp" + } + ] + }, + { + "name": "sfp61", + "thermals": [ + { + "name": "xSFP module 61 Temp" + } + ] + }, + { + "name": "sfp62", + "thermals": [ + { + "name": "xSFP module 62 Temp" + } + ] + }, + { + "name": "sfp63", + "thermals": [ + { + "name": "xSFP module 63 Temp" + } + ] + }, + { + "name": "sfp64", + "thermals": [ + { + "name": "xSFP module 64 Temp" + } + ] + } + ] + }, + "interfaces": { + "Ethernet0": { + "index": "1,1,1,1,1,1,1,1", + "lanes": "0,1,2,3,4,5,6,7", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp1"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp1a", "etp1b"], + "4x200G[100G,50G,25G,10G]": ["etp1a", "etp1b", "etp1c", "etp1d"], + "8x100G[50G,25G,10G]": ["etp1a", "etp1b", "etp1c", "etp1d", "etp1e", "etp1f", "etp1g", "etp1h"] + } + }, + "Ethernet8": { + "index": "2,2,2,2,2,2,2,2", + "lanes": "8,9,10,11,12,13,14,15", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp2"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp2a", "etp2b"], + "4x200G[100G,50G,25G,10G]": ["etp2a", "etp2b", "etp2c", "etp2d"], + "8x100G[50G,25G,10G]": ["etp2a", "etp2b", "etp2c", "etp2d", "etp2e", "etp2f", "etp2g", "etp2h"] + } + }, + "Ethernet16": { + "index": "3,3,3,3,3,3,3,3", + "lanes": "16,17,18,19,20,21,22,23", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp3"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp3a", "etp3b"], + "4x200G[100G,50G,25G,10G]": ["etp3a", "etp3b", "etp3c", "etp3d"], + "8x100G[50G,25G,10G]": ["etp3a", "etp3b", "etp3c", "etp3d", "etp3e", "etp3f", "etp3g", "etp3h"] + } + }, + "Ethernet24": { + "index": "4,4,4,4,4,4,4,4", + "lanes": "24,25,26,27,28,29,30,31", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp4"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp4a", "etp4b"], + "4x200G[100G,50G,25G,10G]": ["etp4a", "etp4b", "etp4c", "etp4d"], + "8x100G[50G,25G,10G]": ["etp4a", "etp4b", "etp4c", "etp4d", "etp4e", "etp4f", "etp4g", "etp4h"] + } + }, + "Ethernet32": { + "index": "5,5,5,5,5,5,5,5", + "lanes": "32,33,34,35,36,37,38,39", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp5"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp5a", "etp5b"], + "4x200G[100G,50G,25G,10G]": ["etp5a", "etp5b", "etp5c", "etp5d"], + "8x100G[50G,25G,10G]": ["etp5a", "etp5b", "etp5c", "etp5d", "etp5e", "etp5f", "etp5g", "etp5h"] + } + }, + "Ethernet40": { + "index": "6,6,6,6,6,6,6,6", + "lanes": "40,41,42,43,44,45,46,47", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp6"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp6a", "etp6b"], + "4x200G[100G,50G,25G,10G]": ["etp6a", "etp6b", "etp6c", "etp6d"], + "8x100G[50G,25G,10G]": ["etp6a", "etp6b", "etp6c", "etp6d", "etp6e", "etp6f", "etp6g", "etp6h"] + } + }, + "Ethernet48": { + "index": "7,7,7,7,7,7,7,7", + "lanes": "48,49,50,51,52,53,54,55", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp7"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp7a", "etp7b"], + "4x200G[100G,50G,25G,10G]": ["etp7a", "etp7b", "etp7c", "etp7d"], + "8x100G[50G,25G,10G]": ["etp7a", "etp7b", "etp7c", "etp7d", "etp7e", "etp7f", "etp7g", "etp7h"] + } + }, + "Ethernet56": { + "index": "8,8,8,8,8,8,8,8", + "lanes": "56,57,58,59,60,61,62,63", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp8"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp8a", "etp8b"], + "4x200G[100G,50G,25G,10G]": ["etp8a", "etp8b", "etp8c", "etp8d"], + "8x100G[50G,25G,10G]": ["etp8a", "etp8b", "etp8c", "etp8d", "etp8e", "etp8f", "etp8g", "etp8h"] + } + }, + "Ethernet64": { + "index": "9,9,9,9,9,9,9,9", + "lanes": "64,65,66,67,68,69,70,71", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp9"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp9a", "etp9b"], + "4x200G[100G,50G,25G,10G]": ["etp9a", "etp9b", "etp9c", "etp9d"], + "8x100G[50G,25G,10G]": ["etp9a", "etp9b", "etp9c", "etp9d", "etp9e", "etp9f", "etp9g", "etp9h"] + } + }, + "Ethernet72": { + "index": "10,10,10,10,10,10,10,10", + "lanes": "72,73,74,75,76,77,78,79", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp10"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp10a", "etp10b"], + "4x200G[100G,50G,25G,10G]": ["etp10a", "etp10b", "etp10c", "etp10d"], + "8x100G[50G,25G,10G]": ["etp10a", "etp10b", "etp10c", "etp10d", "etp10e", "etp10f", "etp10g", "etp10h"] + } + }, + "Ethernet80": { + "index": "11,11,11,11,11,11,11,11", + "lanes": "80,81,82,83,84,85,86,87", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp11"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp11a", "etp11b"], + "4x200G[100G,50G,25G,10G]": ["etp11a", "etp11b", "etp11c", "etp11d"], + "8x100G[50G,25G,10G]": ["etp11a", "etp11b", "etp11c", "etp11d", "etp11e", "etp11f", "etp11g", "etp11h"] + } + }, + "Ethernet88": { + "index": "12,12,12,12,12,12,12,12", + "lanes": "88,89,90,91,92,93,94,95", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp12"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp12a", "etp12b"], + "4x200G[100G,50G,25G,10G]": ["etp12a", "etp12b", "etp12c", "etp12d"], + "8x100G[50G,25G,10G]": ["etp12a", "etp12b", "etp12c", "etp12d", "etp12e", "etp12f", "etp12g", "etp12h"] + } + }, + "Ethernet96": { + "index": "13,13,13,13,13,13,13,13", + "lanes": "96,97,98,99,100,101,102,103", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp13"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp13a", "etp13b"], + "4x200G[100G,50G,25G,10G]": ["etp13a", "etp13b", "etp13c", "etp13d"], + "8x100G[50G,25G,10G]": ["etp13a", "etp13b", "etp13c", "etp13d", "etp13e", "etp13f", "etp13g", "etp13h"] + } + }, + "Ethernet104": { + "index": "14,14,14,14,14,14,14,14", + "lanes": "104,105,106,107,108,109,110,111", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp14"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp14a", "etp14b"], + "4x200G[100G,50G,25G,10G]": ["etp14a", "etp14b", "etp14c", "etp14d"], + "8x100G[50G,25G,10G]": ["etp14a", "etp14b", "etp14c", "etp14d", "etp14e", "etp14f", "etp14g", "etp14h"] + } + }, + "Ethernet112": { + "index": "15,15,15,15,15,15,15,15", + "lanes": "112,113,114,115,116,117,118,119", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp15"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp15a", "etp15b"], + "4x200G[100G,50G,25G,10G]": ["etp15a", "etp15b", "etp15c", "etp15d"], + "8x100G[50G,25G,10G]": ["etp15a", "etp15b", "etp15c", "etp15d", "etp15e", "etp15f", "etp15g", "etp15h"] + } + }, + "Ethernet120": { + "index": "16,16,16,16,16,16,16,16", + "lanes": "120,121,122,123,124,125,126,127", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp16"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp16a", "etp16b"], + "4x200G[100G,50G,25G,10G]": ["etp16a", "etp16b", "etp16c", "etp16d"], + "8x100G[50G,25G,10G]": ["etp16a", "etp16b", "etp16c", "etp16d", "etp16e", "etp16f", "etp16g", "etp16h"] + } + }, + "Ethernet128": { + "index": "17,17,17,17,17,17,17,17", + "lanes": "128,129,130,131,132,133,134,135", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp17"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp17a", "etp17b"], + "4x200G[100G,50G,25G,10G]": ["etp17a", "etp17b", "etp17c", "etp17d"], + "8x100G[50G,25G,10G]": ["etp17a", "etp17b", "etp17c", "etp17d", "etp17e", "etp17f", "etp17g", "etp17h"] + } + }, + "Ethernet136": { + "index": "18,18,18,18,18,18,18,18", + "lanes": "136,137,138,139,140,141,142,143", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp18"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp18a", "etp18b"], + "4x200G[100G,50G,25G,10G]": ["etp18a", "etp18b", "etp18c", "etp18d"], + "8x100G[50G,25G,10G]": ["etp18a", "etp18b", "etp18c", "etp18d", "etp18e", "etp18f", "etp18g", "etp18h"] + } + }, + "Ethernet144": { + "index": "19,19,19,19,19,19,19,19", + "lanes": "144,145,146,147,148,149,150,151", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp19"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp19a", "etp19b"], + "4x200G[100G,50G,25G,10G]": ["etp19a", "etp19b", "etp19c", "etp19d"], + "8x100G[50G,25G,10G]": ["etp19a", "etp19b", "etp19c", "etp19d", "etp19e", "etp19f", "etp19g", "etp19h"] + } + }, + "Ethernet152": { + "index": "20,20,20,20,20,20,20,20", + "lanes": "152,153,154,155,156,157,158,159", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp20"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp20a", "etp20b"], + "4x200G[100G,50G,25G,10G]": ["etp20a", "etp20b", "etp20c", "etp20d"], + "8x100G[50G,25G,10G]": ["etp20a", "etp20b", "etp20c", "etp20d", "etp20e", "etp20f", "etp20g", "etp20h"] + } + }, + "Ethernet160": { + "index": "21,21,21,21,21,21,21,21", + "lanes": "160,161,162,163,164,165,166,167", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp21"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp21a", "etp21b"], + "4x200G[100G,50G,25G,10G]": ["etp21a", "etp21b", "etp21c", "etp21d"], + "8x100G[50G,25G,10G]": ["etp21a", "etp21b", "etp21c", "etp21d", "etp21e", "etp21f", "etp21g", "etp21h"] + } + }, + "Ethernet168": { + "index": "22,22,22,22,22,22,22,22", + "lanes": "168,169,170,171,172,173,174,175", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp22"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp22a", "etp22b"], + "4x200G[100G,50G,25G,10G]": ["etp22a", "etp22b", "etp22c", "etp22d"], + "8x100G[50G,25G,10G]": ["etp22a", "etp22b", "etp22c", "etp22d", "etp22e", "etp22f", "etp22g", "etp22h"] + } + }, + "Ethernet176": { + "index": "23,23,23,23,23,23,23,23", + "lanes": "176,177,178,179,180,181,182,183", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp23"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp23a", "etp23b"], + "4x200G[100G,50G,25G,10G]": ["etp23a", "etp23b", "etp23c", "etp23d"], + "8x100G[50G,25G,10G]": ["etp23a", "etp23b", "etp23c", "etp23d", "etp23e", "etp23f", "etp23g", "etp23h"] + } + }, + "Ethernet184": { + "index": "24,24,24,24,24,24,24,24", + "lanes": "184,185,186,187,188,189,190,191", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp24"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp24a", "etp24b"], + "4x200G[100G,50G,25G,10G]": ["etp24a", "etp24b", "etp24c", "etp24d"], + "8x100G[50G,25G,10G]": ["etp24a", "etp24b", "etp24c", "etp24d", "etp24e", "etp24f", "etp24g", "etp24h"] + } + }, + "Ethernet192": { + "index": "25,25,25,25,25,25,25,25", + "lanes": "192,193,194,195,196,197,198,199", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp25"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp25a", "etp25b"], + "4x200G[100G,50G,25G,10G]": ["etp25a", "etp25b", "etp25c", "etp25d"], + "8x100G[50G,25G,10G]": ["etp25a", "etp25b", "etp25c", "etp25d", "etp25e", "etp25f", "etp25g", "etp25h"] + } + }, + "Ethernet200": { + "index": "26,26,26,26,26,26,26,26", + "lanes": "200,201,202,203,204,205,206,207", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp26"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp26a", "etp26b"], + "4x200G[100G,50G,25G,10G]": ["etp26a", "etp26b", "etp26c", "etp26d"], + "8x100G[50G,25G,10G]": ["etp26a", "etp26b", "etp26c", "etp26d", "etp26e", "etp26f", "etp26g", "etp26h"] + } + }, + "Ethernet208": { + "index": "27,27,27,27,27,27,27,27", + "lanes": "208,209,210,211,212,213,214,215", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp27"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp27a", "etp27b"], + "4x200G[100G,50G,25G,10G]": ["etp27a", "etp27b", "etp27c", "etp27d"], + "8x100G[50G,25G,10G]": ["etp27a", "etp27b", "etp27c", "etp27d", "etp27e", "etp27f", "etp27g", "etp27h"] + } + }, + "Ethernet216": { + "index": "28,28,28,28,28,28,28,28", + "lanes": "216,217,218,219,220,221,222,223", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp28"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp28a", "etp28b"], + "4x200G[100G,50G,25G,10G]": ["etp28a", "etp28b", "etp28c", "etp28d"], + "8x100G[50G,25G,10G]": ["etp28a", "etp28b", "etp28c", "etp28d", "etp28e", "etp28f", "etp28g", "etp28h"] + } + }, + "Ethernet224": { + "index": "29,29,29,29,29,29,29,29", + "lanes": "224,225,226,227,228,229,230,231", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp29"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp29a", "etp29b"], + "4x200G[100G,50G,25G,10G]": ["etp29a", "etp29b", "etp29c", "etp29d"], + "8x100G[50G,25G,10G]": ["etp29a", "etp29b", "etp29c", "etp29d", "etp29e", "etp29f", "etp29g", "etp29h"] + } + }, + "Ethernet232": { + "index": "30,30,30,30,30,30,30,30", + "lanes": "232,233,234,235,236,237,238,239", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp30"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp30a", "etp30b"], + "4x200G[100G,50G,25G,10G]": ["etp30a", "etp30b", "etp30c", "etp30d"], + "8x100G[50G,25G,10G]": ["etp30a", "etp30b", "etp30c", "etp30d", "etp30e", "etp30f", "etp30g", "etp30h"] + } + }, + "Ethernet240": { + "index": "31,31,31,31,31,31,31,31", + "lanes": "240,241,242,243,244,245,246,247", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp31"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp31a", "etp31b"], + "4x200G[100G,50G,25G,10G]": ["etp31a", "etp31b", "etp31c", "etp31d"], + "8x100G[50G,25G,10G]": ["etp31a", "etp31b", "etp31c", "etp31d", "etp31e", "etp31f", "etp31g", "etp31h"] + } + }, + "Ethernet248": { + "index": "32,32,32,32,32,32,32,32", + "lanes": "248,249,250,251,252,253,254,255", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp32"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp32a", "etp32b"], + "4x200G[100G,50G,25G,10G]": ["etp32a", "etp32b", "etp32c", "etp32d"], + "8x100G[50G,25G,10G]": ["etp32a", "etp32b", "etp32c", "etp32d", "etp32e", "etp32f", "etp32g", "etp32h"] + } + }, + "Ethernet256": { + "index": "33,33,33,33,33,33,33,33", + "lanes": "256,257,258,259,260,261,262,263", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp33"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp33a", "etp33b"], + "4x200G[100G,50G,25G,10G]": ["etp33a", "etp33b", "etp33c", "etp33d"], + "8x100G[50G,25G,10G]": ["etp33a", "etp33b", "etp33c", "etp33d", "etp33e", "etp33f", "etp33g", "etp33h"] + } + }, + "Ethernet264": { + "index": "34,34,34,34,34,34,34,34", + "lanes": "264,265,266,267,268,269,270,271", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp34"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp34a", "etp34b"], + "4x200G[100G,50G,25G,10G]": ["etp34a", "etp34b", "etp34c", "etp34d"], + "8x100G[50G,25G,10G]": ["etp34a", "etp34b", "etp34c", "etp34d", "etp34e", "etp34f", "etp34g", "etp34h"] + } + }, + "Ethernet272": { + "index": "35,35,35,35,35,35,35,35", + "lanes": "272,273,274,275,276,277,278,279", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp35"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp35a", "etp35b"], + "4x200G[100G,50G,25G,10G]": ["etp35a", "etp35b", "etp35c", "etp35d"], + "8x100G[50G,25G,10G]": ["etp35a", "etp35b", "etp35c", "etp35d", "etp35e", "etp35f", "etp35g", "etp35h"] + } + }, + "Ethernet280": { + "index": "36,36,36,36,36,36,36,36", + "lanes": "280,281,282,283,284,285,286,287", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp36"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp36a", "etp36b"], + "4x200G[100G,50G,25G,10G]": ["etp36a", "etp36b", "etp36c", "etp36d"], + "8x100G[50G,25G,10G]": ["etp36a", "etp36b", "etp36c", "etp36d", "etp36e", "etp36f", "etp36g", "etp36h"] + } + }, + "Ethernet288": { + "index": "37,37,37,37,37,37,37,37", + "lanes": "288,289,290,291,292,293,294,295", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp37"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp37a", "etp37b"], + "4x200G[100G,50G,25G,10G]": ["etp37a", "etp37b", "etp37c", "etp37d"], + "8x100G[50G,25G,10G]": ["etp37a", "etp37b", "etp37c", "etp37d", "etp37e", "etp37f", "etp37g", "etp37h"] + } + }, + "Ethernet296": { + "index": "38,38,38,38,38,38,38,38", + "lanes": "296,297,298,299,300,301,302,303", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp38"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp38a", "etp38b"], + "4x200G[100G,50G,25G,10G]": ["etp38a", "etp38b", "etp38c", "etp38d"], + "8x100G[50G,25G,10G]": ["etp38a", "etp38b", "etp38c", "etp38d", "etp38e", "etp38f", "etp38g", "etp38h"] + } + }, + "Ethernet304": { + "index": "39,39,39,39,39,39,39,39", + "lanes": "304,305,306,307,308,309,310,311", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp39"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp39a", "etp39b"], + "4x200G[100G,50G,25G,10G]": ["etp39a", "etp39b", "etp39c", "etp39d"], + "8x100G[50G,25G,10G]": ["etp39a", "etp39b", "etp39c", "etp39d", "etp39e", "etp39f", "etp39g", "etp39h"] + } + }, + "Ethernet312": { + "index": "40,40,40,40,40,40,40,40", + "lanes": "312,313,314,315,316,317,318,319", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp40"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp40a", "etp40b"], + "4x200G[100G,50G,25G,10G]": ["etp40a", "etp40b", "etp40c", "etp40d"], + "8x100G[50G,25G,10G]": ["etp40a", "etp40b", "etp40c", "etp40d", "etp40e", "etp40f", "etp40g", "etp40h"] + } + }, + "Ethernet320": { + "index": "41,41,41,41,41,41,41,41", + "lanes": "320,321,322,323,324,325,326,327", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp41"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp41a", "etp41b"], + "4x200G[100G,50G,25G,10G]": ["etp41a", "etp41b", "etp41c", "etp41d"], + "8x100G[50G,25G,10G]": ["etp41a", "etp41b", "etp41c", "etp41d", "etp41e", "etp41f", "etp41g", "etp41h"] + } + }, + "Ethernet328": { + "index": "42,42,42,42,42,42,42,42", + "lanes": "328,329,330,331,332,333,334,335", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp42"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp42a", "etp42b"], + "4x200G[100G,50G,25G,10G]": ["etp42a", "etp42b", "etp42c", "etp42d"], + "8x100G[50G,25G,10G]": ["etp42a", "etp42b", "etp42c", "etp42d", "etp42e", "etp42f", "etp42g", "etp42h"] + } + }, + "Ethernet336": { + "index": "43,43,43,43,43,43,43,43", + "lanes": "336,337,338,339,340,341,342,343", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp43"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp43a", "etp43b"], + "4x200G[100G,50G,25G,10G]": ["etp43a", "etp43b", "etp43c", "etp43d"], + "8x100G[50G,25G,10G]": ["etp43a", "etp43b", "etp43c", "etp43d", "etp43e", "etp43f", "etp43g", "etp43h"] + } + }, + "Ethernet344": { + "index": "44,44,44,44,44,44,44,44", + "lanes": "344,345,346,347,348,349,350,351", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp44"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp44a", "etp44b"], + "4x200G[100G,50G,25G,10G]": ["etp44a", "etp44b", "etp44c", "etp44d"], + "8x100G[50G,25G,10G]": ["etp44a", "etp44b", "etp44c", "etp44d", "etp44e", "etp44f", "etp44g", "etp44h"] + } + }, + "Ethernet352": { + "index": "45,45,45,45,45,45,45,45", + "lanes": "352,353,354,355,356,357,358,359", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp45"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp45a", "etp45b"], + "4x200G[100G,50G,25G,10G]": ["etp45a", "etp45b", "etp45c", "etp45d"], + "8x100G[50G,25G,10G]": ["etp45a", "etp45b", "etp45c", "etp45d", "etp45e", "etp45f", "etp45g", "etp45h"] + } + }, + "Ethernet360": { + "index": "46,46,46,46,46,46,46,46", + "lanes": "360,361,362,363,364,365,366,367", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp46"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp46a", "etp46b"], + "4x200G[100G,50G,25G,10G]": ["etp46a", "etp46b", "etp46c", "etp46d"], + "8x100G[50G,25G,10G]": ["etp46a", "etp46b", "etp46c", "etp46d", "etp46e", "etp46f", "etp46g", "etp46h"] + } + }, + "Ethernet368": { + "index": "47,47,47,47,47,47,47,47", + "lanes": "368,369,370,371,372,373,374,375", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp47"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp47a", "etp47b"], + "4x200G[100G,50G,25G,10G]": ["etp47a", "etp47b", "etp47c", "etp47d"], + "8x100G[50G,25G,10G]": ["etp47a", "etp47b", "etp47c", "etp47d", "etp47e", "etp47f", "etp47g", "etp47h"] + } + }, + "Ethernet376": { + "index": "48,48,48,48,48,48,48,48", + "lanes": "376,377,378,379,380,381,382,383", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp48"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp48a", "etp48b"], + "4x200G[100G,50G,25G,10G]": ["etp48a", "etp48b", "etp48c", "etp48d"], + "8x100G[50G,25G,10G]": ["etp48a", "etp48b", "etp48c", "etp48d", "etp48e", "etp48f", "etp48g", "etp48h"] + } + }, + "Ethernet384": { + "index": "49,49,49,49,49,49,49,49", + "lanes": "384,385,386,387,388,389,390,391", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp49"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp49a", "etp49b"], + "4x200G[100G,50G,25G,10G]": ["etp49a", "etp49b", "etp49c", "etp49d"], + "8x100G[50G,25G,10G]": ["etp49a", "etp49b", "etp49c", "etp49d", "etp49e", "etp49f", "etp49g", "etp49h"] + } + }, + "Ethernet392": { + "index": "50,50,50,50,50,50,50,50", + "lanes": "392,393,394,395,396,397,398,399", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp50"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp50a", "etp50b"], + "4x200G[100G,50G,25G,10G]": ["etp50a", "etp50b", "etp50c", "etp50d"], + "8x100G[50G,25G,10G]": ["etp50a", "etp50b", "etp50c", "etp50d", "etp50e", "etp50f", "etp50g", "etp50h"] + } + }, + "Ethernet400": { + "index": "51,51,51,51,51,51,51,51", + "lanes": "400,401,402,403,404,405,406,407", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp51"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp51a", "etp51b"], + "4x200G[100G,50G,25G,10G]": ["etp51a", "etp51b", "etp51c", "etp51d"], + "8x100G[50G,25G,10G]": ["etp51a", "etp51b", "etp51c", "etp51d", "etp51e", "etp51f", "etp51g", "etp51h"] + } + }, + "Ethernet408": { + "index": "52,52,52,52,52,52,52,52", + "lanes": "408,409,410,411,412,413,414,415", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp52"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp52a", "etp52b"], + "4x200G[100G,50G,25G,10G]": ["etp52a", "etp52b", "etp52c", "etp52d"], + "8x100G[50G,25G,10G]": ["etp52a", "etp52b", "etp52c", "etp52d", "etp52e", "etp52f", "etp52g", "etp52h"] + } + }, + "Ethernet416": { + "index": "53,53,53,53,53,53,53,53", + "lanes": "416,417,418,419,420,421,422,423", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp53"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp53a", "etp53b"], + "4x200G[100G,50G,25G,10G]": ["etp53a", "etp53b", "etp53c", "etp53d"], + "8x100G[50G,25G,10G]": ["etp53a", "etp53b", "etp53c", "etp53d", "etp53e", "etp53f", "etp53g", "etp53h"] + } + }, + "Ethernet424": { + "index": "54,54,54,54,54,54,54,54", + "lanes": "424,425,426,427,428,429,430,431", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp54"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp54a", "etp54b"], + "4x200G[100G,50G,25G,10G]": ["etp54a", "etp54b", "etp54c", "etp54d"], + "8x100G[50G,25G,10G]": ["etp54a", "etp54b", "etp54c", "etp54d", "etp54e", "etp54f", "etp54g", "etp54h"] + } + }, + "Ethernet432": { + "index": "55,55,55,55,55,55,55,55", + "lanes": "432,433,434,435,436,437,438,439", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp55"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp55a", "etp55b"], + "4x200G[100G,50G,25G,10G]": ["etp55a", "etp55b", "etp55c", "etp55d"], + "8x100G[50G,25G,10G]": ["etp55a", "etp55b", "etp55c", "etp55d", "etp55e", "etp55f", "etp55g", "etp55h"] + } + }, + "Ethernet440": { + "index": "56,56,56,56,56,56,56,56", + "lanes": "440,441,442,443,444,445,446,447", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp56"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp56a", "etp56b"], + "4x200G[100G,50G,25G,10G]": ["etp56a", "etp56b", "etp56c", "etp56d"], + "8x100G[50G,25G,10G]": ["etp56a", "etp56b", "etp56c", "etp56d", "etp56e", "etp56f", "etp56g", "etp56h"] + } + }, + "Ethernet448": { + "index": "57,57,57,57,57,57,57,57", + "lanes": "448,449,450,451,452,453,454,455", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp57"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp57a", "etp57b"], + "4x200G[100G,50G,25G,10G]": ["etp57a", "etp57b", "etp57c", "etp57d"], + "8x100G[50G,25G,10G]": ["etp57a", "etp57b", "etp57c", "etp57d", "etp57e", "etp57f", "etp57g", "etp57h"] + } + }, + "Ethernet456": { + "index": "58,58,58,58,58,58,58,58", + "lanes": "456,457,458,459,460,461,462,463", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp58"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp58a", "etp58b"], + "4x200G[100G,50G,25G,10G]": ["etp58a", "etp58b", "etp58c", "etp58d"], + "8x100G[50G,25G,10G]": ["etp58a", "etp58b", "etp58c", "etp58d", "etp58e", "etp58f", "etp58g", "etp58h"] + } + }, + "Ethernet464": { + "index": "59,59,59,59,59,59,59,59", + "lanes": "464,465,466,467,468,469,470,471", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp59"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp59a", "etp59b"], + "4x200G[100G,50G,25G,10G]": ["etp59a", "etp59b", "etp59c", "etp59d"], + "8x100G[50G,25G,10G]": ["etp59a", "etp59b", "etp59c", "etp59d", "etp59e", "etp59f", "etp59g", "etp59h"] + } + }, + "Ethernet472": { + "index": "60,60,60,60,60,60,60,60", + "lanes": "472,473,474,475,476,477,478,479", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp60"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp60a", "etp60b"], + "4x200G[100G,50G,25G,10G]": ["etp60a", "etp60b", "etp60c", "etp60d"], + "8x100G[50G,25G,10G]": ["etp60a", "etp60b", "etp60c", "etp60d", "etp60e", "etp60f", "etp60g", "etp60h"] + } + }, + "Ethernet480": { + "index": "61,61,61,61,61,61,61,61", + "lanes": "480,481,482,483,484,485,486,487", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp61"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp61a", "etp61b"], + "4x200G[100G,50G,25G,10G]": ["etp61a", "etp61b", "etp61c", "etp61d"], + "8x100G[50G,25G,10G]": ["etp61a", "etp61b", "etp61c", "etp61d", "etp61e", "etp61f", "etp61g", "etp61h"] + } + }, + "Ethernet488": { + "index": "62,62,62,62,62,62,62,62", + "lanes": "488,489,490,491,492,493,494,495", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp62"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp62a", "etp62b"], + "4x200G[100G,50G,25G,10G]": ["etp62a", "etp62b", "etp62c", "etp62d"], + "8x100G[50G,25G,10G]": ["etp62a", "etp62b", "etp62c", "etp62d", "etp62e", "etp62f", "etp62g", "etp62h"] + } + }, + "Ethernet496": { + "index": "63,63,63,63,63,63,63,63", + "lanes": "496,497,498,499,500,501,502,503", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp63"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp63a", "etp63b"], + "4x200G[100G,50G,25G,10G]": ["etp63a", "etp63b", "etp63c", "etp63d"], + "8x100G[50G,25G,10G]": ["etp63a", "etp63b", "etp63c", "etp63d", "etp63e", "etp63f", "etp63g", "etp63h"] + } + }, + "Ethernet504": { + "index": "64,64,64,64,64,64,64,64", + "lanes": "504,505,506,507,508,509,510,511", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp64"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp64a", "etp64b"], + "4x200G[100G,50G,25G,10G]": ["etp64a", "etp64b", "etp64c", "etp64d"], + "8x100G[50G,25G,10G]": ["etp64a", "etp64b", "etp64c", "etp64d", "etp64e", "etp64f", "etp64g", "etp64h"] + } + }, + "Ethernet512": { + "index": "65", + "lanes": "512", + "breakout_modes": { + "1x25G[10G]": ["etp65"] + } + } + } +} diff --git a/device/mellanox/x86_64-nvidia_sn5600-r0/platform_asic b/device/mellanox/x86_64-nvidia_sn5600-r0/platform_asic new file mode 100644 index 000000000000..70c074885557 --- /dev/null +++ b/device/mellanox/x86_64-nvidia_sn5600-r0/platform_asic @@ -0,0 +1 @@ +mellanox diff --git a/device/mellanox/x86_64-nvidia_sn5600-r0/platform_components.json b/device/mellanox/x86_64-nvidia_sn5600-r0/platform_components.json new file mode 100644 index 000000000000..e9b6398e7cfa --- /dev/null +++ b/device/mellanox/x86_64-nvidia_sn5600-r0/platform_components.json @@ -0,0 +1,15 @@ +{ + "chassis": { + "SN5600": { + "component": { + "ONIE": { }, + "SSD": { }, + "BIOS": { }, + "CPLD1": { }, + "CPLD2": { }, + "CPLD3": { }, + "CPLD4": { } + } + } + } +} diff --git a/device/mellanox/x86_64-nvidia_sn5600-r0/platform_reboot b/device/mellanox/x86_64-nvidia_sn5600-r0/platform_reboot new file mode 120000 index 000000000000..43c8ea567493 --- /dev/null +++ b/device/mellanox/x86_64-nvidia_sn5600-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-nvidia_sn5600-r0/platform_wait b/device/mellanox/x86_64-nvidia_sn5600-r0/platform_wait new file mode 120000 index 000000000000..4b30bd429854 --- /dev/null +++ b/device/mellanox/x86_64-nvidia_sn5600-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-nvidia_sn5600-r0/plugins/eeprom.py b/device/mellanox/x86_64-nvidia_sn5600-r0/plugins/eeprom.py new file mode 120000 index 000000000000..b4e2a6a61671 --- /dev/null +++ b/device/mellanox/x86_64-nvidia_sn5600-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-nvidia_sn5600-r0/plugins/psuutil.py b/device/mellanox/x86_64-nvidia_sn5600-r0/plugins/psuutil.py new file mode 120000 index 000000000000..9f724238a8d5 --- /dev/null +++ b/device/mellanox/x86_64-nvidia_sn5600-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-nvidia_sn5600-r0/plugins/sfplpmget.py b/device/mellanox/x86_64-nvidia_sn5600-r0/plugins/sfplpmget.py new file mode 120000 index 000000000000..2e84f435abd9 --- /dev/null +++ b/device/mellanox/x86_64-nvidia_sn5600-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-nvidia_sn5600-r0/plugins/sfplpmset.py b/device/mellanox/x86_64-nvidia_sn5600-r0/plugins/sfplpmset.py new file mode 120000 index 000000000000..6a88bac30467 --- /dev/null +++ b/device/mellanox/x86_64-nvidia_sn5600-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-nvidia_sn5600-r0/plugins/sfpreset.py b/device/mellanox/x86_64-nvidia_sn5600-r0/plugins/sfpreset.py new file mode 120000 index 000000000000..fef2063e3496 --- /dev/null +++ b/device/mellanox/x86_64-nvidia_sn5600-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-nvidia_sn5600-r0/plugins/sfputil.py b/device/mellanox/x86_64-nvidia_sn5600-r0/plugins/sfputil.py new file mode 120000 index 000000000000..45909b880fc9 --- /dev/null +++ b/device/mellanox/x86_64-nvidia_sn5600-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-nvidia_sn5600-r0/pmon_daemon_control.json b/device/mellanox/x86_64-nvidia_sn5600-r0/pmon_daemon_control.json new file mode 120000 index 000000000000..435a2ce7c0ba --- /dev/null +++ b/device/mellanox/x86_64-nvidia_sn5600-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-nvidia_sn5600-r0/sensors.conf b/device/mellanox/x86_64-nvidia_sn5600-r0/sensors.conf new file mode 100644 index 000000000000..d7f122a714a1 --- /dev/null +++ b/device/mellanox/x86_64-nvidia_sn5600-r0/sensors.conf @@ -0,0 +1,301 @@ +################################################################################## +# Copyright (c) 2019 - 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# +# Platform specific sensors config for SN5600 +################################################################################## + +# Bus names +bus "i2c-39" "i2c-1-mux (chan_id 6)" + +# Temperature sensors +chip "mlxsw-i2c-*-48" + label temp1 "Ambient ASIC Temp" + +chip "tmp102-i2c-*-49" + label temp1 "Ambient Fan Side Temp (air intake)" +chip "adt75-i2c-*-49" + label temp1 "Ambient Fan Side Temp (air intake)" +chip "tmp102-i2c-*-4a" + label temp1 "Ambient Port Side Temp (air exhaust)" +chip "adt75-i2c-*-4a" + label temp1 "Ambient Port Side Temp (air exhaust)" + +# Power controllers +chip "mp2975-i2c-*-62" + label in1 "PMIC-1 PSU 13V5 Rail (in1)" + label in2 "PMIC-1 VDD_M ADJ Rail (out1)" + ignore in3 + label temp1 "PMIC-1 VDD_M ADJ Temp 1" + ignore temp2 + label power1 "PMIC-1 13V5 VDD_M (in)" + label power2 "PMIC-1 VDD_M Rail Pwr (out1)" + ignore power3 + label curr1 "PMIC-1 13V5 VDD_M Rail Curr (in1)" + label curr2 "PMIC-1 VDD_M Rail Curr (out1)" + ignore curr3 + ignore curr4 + ignore curr5 + ignore curr6 + ignore curr7 + ignore curr8 + ignore curr9 + ignore curr10 +chip "mp2975-i2c-*-63" + label in1 "PMIC-2 PSU 13V5 Rail (in1)" + label in2 "PMIC-2 VDD_T0 ADJ Rail (out1)" + label in3 "PMIC-2 VDD_T1 ADJ Rail (out2)" + label temp1 "PMIC-2 VDD_T0 ADJ Temp 1" + label temp2 "PMIC-2 VDD_T1 ADJ Temp 2" + label power1 "PMIC-2 13V5 VDD_T0 VDD_T1 (in)" + label power2 "PMIC-2 VDD_T0 Rail Pwr (out1)" + label power3 "PMIC-2 VDD_T1 Rail Pwr (out2)" + label curr1 "PMIC-2 13V5 VDD_T0 VDD_T1 Rail Curr (in1)" + label curr2 "PMIC-2 VDD_T0 Rail Curr (out1)" + label curr3 "PMIC-2 VDD_T1 Rail Curr (out2)" + ignore curr4 + ignore curr5 + ignore curr6 +chip "mp2975-i2c-*-64" + label in1 "PMIC-3 PSU 13V5 Rail (in1)" + label in2 "PMIC-3 VDD_T2 ADJ Rail (out1)" + label in3 "PMIC-3 VDD_T3 ADJ Rail (out2)" + label temp1 "PMIC-3 VDD_T2 ADJ Temp 1" + label temp2 "PMIC-3 VDD_T3 ADJ Temp 2" + label power1 "PMIC-3 13V5 VDD_T2 VDD_T3 (in)" + label power2 "PMIC-3 VDD_T2 Rail Pwr (out1)" + label power3 "PMIC-3 VDD_T3 Rail Pwr (out2)" + label curr1 "PMIC-3 13V5 VDD_T2 VDD_T3 Rail Curr (in1)" + label curr2 "PMIC-3 VDD_T2 Rail Curr (out1)" + label curr3 "PMIC-3 VDD_T3 Rail Curr (out2)" + ignore curr4 + ignore curr5 + ignore curr6 +chip "mp2975-i2c-*-65" + label in1 "PMIC-4 PSU 13V5 Rail (in1)" + label in2 "PMIC-4 VDD_T4 ADJ Rail (out1)" + label in3 "PMIC-4 VDD_T5 ADJ Rail (out2)" + label temp1 "PMIC-4 VDD_T4 ADJ Temp 1" + label temp2 "PMIC-4 VDD_T5 ADJ Temp 2" + label power1 "PMIC-4 13V5 VDD_T4 VDD_T5 (in)" + label power2 "PMIC-4 VDD_T4 Rail Pwr (out1)" + label power3 "PMIC-4 VDD_T5 Rail Pwr (out2)" + label curr1 "PMIC-4 13V5 VDD_T4 VDD_T5 Rail Curr (in1)" + label curr2 "PMIC-4 VDD_T4 Rail Curr (out1)" + label curr3 "PMIC-4 VDD_T5 Rail Curr (out2)" + ignore curr4 + ignore curr5 + ignore curr6 +chip "mp2975-i2c-*-66" + label in1 "PMIC-5 PSU 13V5 Rail (in1)" + label in2 "PMIC-5 VDD_T6 ADJ Rail (out1)" + label in3 "PMIC-5 VDD_T7 ADJ Rail (out2)" + label temp1 "PMIC-5 VDD_T6 ADJ Temp 1" + label temp2 "PMIC-5 VDD_T7 ADJ Temp 2" + label power1 "PMIC-5 13V5 VDD_T6 VDD_T7 (in)" + label power2 "PMIC-5 VDD_T6 Rail Pwr (out1)" + label power3 "PMIC-5 VDD_T7 Rail Pwr (out2)" + label curr1 "PMIC-5 13V5 VDD_T6 VDD_T7 Rail Curr (in1)" + label curr2 "PMIC-5 VDD_T6 Rail Curr (out1)" + label curr3 "PMIC-5 VDD_T7 Rail Curr (out2)" + ignore curr4 + ignore curr5 + ignore curr6 +chip "mp2975-i2c-*-67" + label in1 "PMIC-6 PSU 13V5 Rail (in1)" + label in2 "PMIC-6 DVDD_T0 ADJ Rail (out1)" + label in3 "PMIC-6 DVDD_T1 ADJ Rail (out2)" + label temp1 "PMIC-6 DVDD_T0 ADJ Temp 1" + label temp2 "PMIC-6 DVDD_T1 ADJ Temp 2" + label power1 "PMIC-6 13V5 DVDD_T0 DVDD_T1 (in)" + label power2 "PMIC-6 DVDD_T0 Rail Pwr (out1)" + label power3 "PMIC-6 DVDD_T1 Rail Pwr (out2)" + label curr1 "PMIC-6 13V5 DVDD_T0 DVDD_T1 Rail Curr (in1)" + label curr2 "PMIC-6 DVDD_T0 Rail Curr (out1)" + label curr3 "PMIC-6 DVDD_T1 Rail Curr (out2)" + ignore curr4 + ignore curr5 + ignore curr6 +chip "mp2975-i2c-*-68" + label in1 "PMIC-7 PSU 13V5 Rail (in1)" + label in2 "PMIC-7 DVDD_T2 ADJ Rail (out1)" + label in3 "PMIC-7 DVDD_T3 ADJ Rail (out2)" + label temp1 "PMIC-7 DVDD_T2 ADJ Temp 1" + label temp2 "PMIC-7 DVDD_T3 ADJ Temp 2" + label power1 "PMIC-7 13V5 DVDD_T2 DVDD_T3 (in)" + label power2 "PMIC-7 DVDD_T2 Rail Pwr (out1)" + label power3 "PMIC-7 DVDD_T3 Rail Pwr (out2)" + label curr1 "PMIC-7 13V5 DVDD_T2 DVDD_T3 Rail Curr (in1)" + label curr2 "PMIC-7 DVDD_T2 Rail Curr (out1)" + label curr3 "PMIC-7 DVDD_T3 Rail Curr (out2)" + ignore curr4 + ignore curr5 + ignore curr6 +chip "mp2975-i2c-*-69" + label in1 "PMIC-8 PSU 13V5 Rail (in1)" + label in2 "PMIC-8 DVDD_T4 ADJ Rail (out1)" + label in3 "PMIC-8 DVDD_T5 ADJ Rail (out2)" + label temp1 "PMIC-8 DVDD_T4 ADJ Temp 1" + label temp2 "PMIC-8 DVDD_T5 ADJ Temp 2" + label power1 "PMIC-8 13V5 DVDD_T4 DVDD_T5 (in)" + label power2 "PMIC-8 DVDD_T4 Rail Pwr (out1)" + label power3 "PMIC-8 DVDD_T5 Rail Pwr (out2)" + label curr1 "PMIC-8 13V5 DVDD_T4 DVDD_T5 Rail Curr (in1)" + label curr2 "PMIC-8 DVDD_T4 Rail Curr (out1)" + label curr3 "PMIC-8 DVDD_T5 Rail Curr (out2)" + ignore curr4 + ignore curr5 + ignore curr6 +chip "mp2975-i2c-*-6a" + label in1 "PMIC-9 PSU 13V5 Rail (in1)" + label in2 "PMIC-9 DVDD_T6 ADJ Rail (out1)" + label in3 "PMIC-9 DVDD_T7 ADJ Rail (out2)" + label temp1 "PMIC-9 DVDD_T6 ADJ Temp 1" + label temp2 "PMIC-9 DVDD_T7 ADJ Temp 2" + label power1 "PMIC-9 13V5 DVDD_T6 DVDD_T7 (in)" + label power2 "PMIC-9 DVDD_T6 Rail Pwr (out1)" + label power3 "PMIC-9 DVDD_T7 Rail Pwr (out2)" + label curr1 "PMIC-9 13V5 DVDD_T6 DVDD_T7 Rail Curr (in1)" + label curr2 "PMIC-9 DVDD_T6 Rail Curr (out1)" + label curr3 "PMIC-9 DVDD_T7 Rail Curr (out2)" + ignore curr4 + ignore curr5 + ignore curr6 +chip "mp2975-i2c-*-6b" + label in1 "PMIC-10 PSU 13V5 Rail (in1)" + label in2 "PMIC-10 HVDD_T03 1V2 Rail (out1)" + label in3 "PMIC-10 HVDD_T47 1V2 Rail (out2)" + label temp1 "PMIC-10 HVDD_T03 1V2 Temp 1" + label temp2 "PMIC-10 HVDD_T47 1V2 Temp 2" + label power1 "PMIC-10 13V5 HVDD_T03 HVDD_T47 (in)" + label power2 "PMIC-10 HVDD_T03 Rail Pwr (out1)" + label power3 "PMIC-10 HVDD_T47 Rail Pwr (out2)" + label curr1 "PMIC-10 13V5 HVDD_T03 HVDD_T47 Rail Curr (in1)" + label curr2 "PMIC-10 HVDD_T03 Rail Curr (out1)" + label curr3 "PMIC-10 HVDD_T47 Rail Curr (out2)" + ignore curr4 + ignore curr5 + ignore curr6 + ignore curr7 + ignore curr8 + ignore curr9 + ignore curr10 + ignore curr11 +chip "mp2975-i2c-*-6e" + label in1 "PMIC-11 PSU 13V5 Rail (in1)" + label in2 "PMIC-11 VDDSCC 0V75 Rail (out1)" + label in3 "PMIC-11 DVDD_M ADJ Rail (out2)" + label temp1 "PMIC-11 VDDSCC 1V2 Temp 1" + label temp2 "PMIC-11 DVDD_M 1V2 Temp 2" + label power1 "PMIC-11 13V5 VDDSCC DVDD_M (in)" + label power2 "PMIC-11 VDDSCC Rail Pwr (out1)" + label power3 "PMIC-11 DVDD_M Rail Pwr (out2)" + label curr1 "PMIC-11 13V5 VDDSCC DVDD_M Rail Curr (in1)" + label curr2 "PMIC-11 VDDSCC Rail Curr (out1)" + label curr3 "PMIC-11 DVDD_M Rail Curr (out2)" + ignore curr4 + ignore curr5 + ignore curr6 + +# Power supplies + +chip "dps460-i2c-*-5a" + 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" + 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" + 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)" + +# Power converters +chip "pmbus-i2c-*-10" + label in1 "IBC-1 PWR CONV 54V Rail (in1)" + ignore in2 + ignore in3 + label temp1 "IBC-1 Temp 1" + label curr1 "IBC-1 13V5 Rail Curr (out)" + ignore curr2 +chip "pmbus-i2c-*-11" + label in1 "IBC-2 PWR CONV 54V Rail (in1)" + ignore in2 + ignore in3 + label temp1 "IBC-2 Temp 1" + label curr1 "IBC-2 13V5 Rail Curr (out)" + ignore curr2 +chip "pmbus-i2c-*-13" + label in1 "IBC-3 PWR CONV 54V Rail (in1)" + ignore in2 + ignore in3 + label temp1 "IBC-3 Temp 1" + label curr1 "IBC-3 13V5 Rail Curr (out)" + ignore curr2 +chip "pmbus-i2c-*-15" + label in1 "IBC-4 PWR CONV 54V Rail (in1)" + ignore in2 + ignore in3 + label temp1 "IBC-4 Temp 1" + label curr1 "IBC-4 13V5 Rail Curr (out)" + ignore curr2 + +#COMEX CFL +chip "mp2975-i2c-39-6b" + label in1 "PMIC-6 PSU 12V Rail (vin)" + label in2 "PMIC-6 COMEX VCORE (out1)" + label in3 "PMIC-6 COMEX VCCSA (out2)" + label temp1 "PMIC-6 Temp" + label power1 "PMIC-6 COMEX Pwr (pin)" + label power2 "PMIC-6 COMEX VCORE Pwr (pout1)" + label power3 "PMIC-6 COMEX VCCSA Pwr (pout2)" + label curr1 "PMIC-6 COMEX Curr (iin)" + label curr2 "PMIC-6 COMEX VCORE Rail Curr (out1)" + ignore curr3 + ignore curr4 + ignore curr5 + label curr6 "PMIC-6 COMEX VCCSA Rail Curr (out2)" + ignore curr7 + +# Chassis fans +chip "mlxreg_fan-isa-*" + label fan1 "Chassis Fan Drawer-1 Tach 1" + label fan2 "Chassis Fan Drawer-1 Tach 2" + label fan3 "Chassis Fan Drawer-2 Tach 1" + label fan4 "Chassis Fan Drawer-2 Tach 2" + label fan5 "Chassis Fan Drawer-3 Tach 1" + label fan6 "Chassis Fan Drawer-3 Tach 2" + label fan7 "Chassis Fan Drawer-4 Tach 1" + label fan8 "Chassis Fan Drawer-4 Tach 2" + +# Memory sensors +bus "i2c-0" "SMBus I801 adapter at efa0" +chip "jc42-i2c-0-1c" + label temp1 "SODIMM Temp" + +chip "jc42-i2c-0-1a" + label temp1 "SODIMM Temp" + +# PCH +chip "pch_cannonlake-virtual-*" + label temp1 "PCH Temp" + +# SSD +chip "drivetemp-*" + label temp1 "SSD Temp" + +chip "*-acpi-*" + label temp1 "CPU ACPI temp" diff --git a/device/mellanox/x86_64-nvidia_sn5600-r0/system_health_monitoring_config.json b/device/mellanox/x86_64-nvidia_sn5600-r0/system_health_monitoring_config.json new file mode 120000 index 000000000000..98df66c27ca5 --- /dev/null +++ b/device/mellanox/x86_64-nvidia_sn5600-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-nvidia_sn5600-r0/thermal_policy.json b/device/mellanox/x86_64-nvidia_sn5600-r0/thermal_policy.json new file mode 120000 index 000000000000..5a25cd87f70c --- /dev/null +++ b/device/mellanox/x86_64-nvidia_sn5600-r0/thermal_policy.json @@ -0,0 +1 @@ +../x86_64-mlnx_msn2700-r0/thermal_policy.json \ No newline at end of file diff --git a/device/ragile/x86_64-ragile_ra-b6510-32c-r0/monitor.py b/device/ragile/x86_64-ragile_ra-b6510-32c-r0/monitor.py index ab4d14ec3daa..fd54c133f1b9 100644 --- a/device/ragile/x86_64-ragile_ra-b6510-32c-r0/monitor.py +++ b/device/ragile/x86_64-ragile_ra-b6510-32c-r0/monitor.py @@ -5,11 +5,10 @@ # * PSU # import os -import xml.etree.ElementTree as ET import glob from fru import * from fantlv import * - +from lxml import etree as ET MAILBOX_DIR = "/sys/bus/i2c/devices/" diff --git a/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/monitor.py b/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/monitor.py index f9cbb31be401..103a2f30ac29 100755 --- a/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/monitor.py +++ b/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/monitor.py @@ -6,8 +6,8 @@ * PSU """ import os -import xml.etree.ElementTree as ET import glob +from lxml import etree as ET MAILBOX_DIR = "/sys/bus/i2c/devices/" PORTS_DIR = "/sys/class/net/" diff --git a/device/ragile/x86_64-ragile_ra-b6910-64c-r0/monitor.py b/device/ragile/x86_64-ragile_ra-b6910-64c-r0/monitor.py index b929fe4146e7..432d7670d90b 100644 --- a/device/ragile/x86_64-ragile_ra-b6910-64c-r0/monitor.py +++ b/device/ragile/x86_64-ragile_ra-b6910-64c-r0/monitor.py @@ -5,8 +5,8 @@ # * PSU # import os -import xml.etree.ElementTree as ET import glob +from lxml import etree as ET MAILBOX_DIR = "/sys/bus/i2c/devices/" PORTS_DIR = "/sys/class/net/" diff --git a/device/ragile/x86_64-ragile_ra-b6910-64c-r0/plugins/fanutil.py b/device/ragile/x86_64-ragile_ra-b6910-64c-r0/plugins/fanutil.py index f34c260035e8..c2944e7b5b89 100755 --- a/device/ragile/x86_64-ragile_ra-b6910-64c-r0/plugins/fanutil.py +++ b/device/ragile/x86_64-ragile_ra-b6910-64c-r0/plugins/fanutil.py @@ -11,6 +11,7 @@ import os.path import sys +import ast sys.path.append('/usr/share/sonic/platform/plugins') import pddfparse import json @@ -170,7 +171,7 @@ def set_speed(self, val): print("Setting fan speed is not allowed !") return False else: - duty_cycle_to_pwm = eval(plugin_data['FAN']['duty_cycle_to_pwm']) + duty_cycle_to_pwm = ast.literal_eval(plugin_data['FAN']['duty_cycle_to_pwm']) pwm = duty_cycle_to_pwm(val) print("New Speed: %d%% - PWM value to be set is %d\n" % (val, pwm)) diff --git a/device/ragile/x86_64-ragile_ra-b6920-4s-r0/monitor.py b/device/ragile/x86_64-ragile_ra-b6920-4s-r0/monitor.py index 3aa8fd3f2901..418179a85225 100644 --- a/device/ragile/x86_64-ragile_ra-b6920-4s-r0/monitor.py +++ b/device/ragile/x86_64-ragile_ra-b6920-4s-r0/monitor.py @@ -5,9 +5,9 @@ # * PSU # import os -import xml.etree.ElementTree as ET import glob from eepromutil.fru import * +from lxml import etree as ET MAILBOX_DIR = "/sys/bus/i2c/devices/" CONFIG_NAME = "dev.xml" diff --git a/device/ragile/x86_64-ragile_ra-b6920-4s-r0/plugins/ssd_util.py b/device/ragile/x86_64-ragile_ra-b6920-4s-r0/plugins/ssd_util.py index b6e5d6d3dd46..268d9ab633b1 100644 --- a/device/ragile/x86_64-ragile_ra-b6920-4s-r0/plugins/ssd_util.py +++ b/device/ragile/x86_64-ragile_ra-b6920-4s-r0/plugins/ssd_util.py @@ -7,7 +7,6 @@ from re import findall from os.path import exists -INNODISK = "iSmart -d {}" NOT_AVAILABLE = "N/A" class SsdUtil(SsdBase): @@ -30,7 +29,8 @@ def __init__(self, diskdev): self.temperature = NOT_AVAILABLE self.health = NOT_AVAILABLE - self.ssd_info = self._execute_shell(INNODISK.format(diskdev)) + INNODISK = ["iSmart", "-d", diskdev] + self.ssd_info = self._execute_shell(INNODISK) self.model = self._parse_re(r'Model Name:\s*(.+?)\n', self.ssd_info) self.serial = self._parse_re(r'Serial Number:\s*(.+?)\n', self.ssd_info) @@ -39,7 +39,7 @@ def __init__(self, diskdev): self.health = self._parse_re(r'Health:\s*(.+?)', self.ssd_info) def _execute_shell(self, cmd): - process = Popen(cmd.split(), universal_newlines=True, stdout=PIPE) + process = Popen(cmd, universal_newlines=True, stdout=PIPE) output, _ = process.communicate() return output diff --git a/device/tencent/x86_64-tencent_tcs8400-r0/TCS8400-24CC8CD/TCS8400-24CC8CD.yml b/device/tencent/x86_64-tencent_tcs8400-r0/TCS8400-24CC8CD/TCS8400-24CC8CD.yml new file mode 100755 index 000000000000..e7a029efc700 --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs8400-r0/TCS8400-24CC8CD/TCS8400-24CC8CD.yml @@ -0,0 +1,574 @@ +# +# BCM56880 128x100g port configuration. +# +# configuration yaml file +# device: +# : +# : +# ? +# : +# : +# ... +# : +# : +# : +# : +# ... +# : +# +# $Copyright: (c) 2019 Broadcom. +# Broadcom Proprietary and Confidential. All rights reserved.$ +# + +--- +bcm_device: + 0: + global: + bcm_tunnel_term_compatible_mode: 1 + # Multicast group allocated by brcm-sai, setting "vlan_flooding_l2mc_num_reserved=0" + vlan_flooding_l2mc_num_reserved: 0 + shared_block_mask_section: uc_bc + sai_tunnel_support: 1 + l3_alpm_template: 1 + l3_alpm2_bnk_threshold: 100 + uft_mode: 1 + l3_enable: 1 + l2_hitbit_enable: 1 + pktio_mode: 1 + skip_protocol_default_entries: 1 + ifa_enable: 1 +... + +--- +bcm_device: + 0: + port: + "*": + encap_mode: IEEE + dport_map_enable: 1 + 11: + dport_map_port: 1 + 13: + dport_map_port: 2 + 20: + dport_map_port: 3 + 22: + dport_map_port: 4 + 24: + dport_map_port: 5 + 26: + dport_map_port: 6 + 28: + dport_map_port: 7 + 30: + dport_map_port: 8 + 3: + dport_map_port: 9 + 5: + dport_map_port: 10 + 7: + dport_map_port: 11 + 9: + dport_map_port: 12 + 40: + dport_map_port: 13 + 42: + dport_map_port: 14 + 44: + dport_map_port: 15 + 46: + dport_map_port: 16 + 48: + dport_map_port: 17 + 50: + dport_map_port: 18 + 64: + dport_map_port: 19 + 66: + dport_map_port: 20 + 68: + dport_map_port: 21 + 70: + dport_map_port: 22 + 72: + dport_map_port: 23 + 74: + dport_map_port: 24 + 1: + dport_map_port: 25 + 15: + dport_map_port: 26 + 32: + dport_map_port: 27 + 34: + dport_map_port: 28 + 52: + dport_map_port: 29 + 54: + dport_map_port: 30 + 60: + dport_map_port: 31 + 62: + dport_map_port: 32 + +... + +--- +device: + 0: + DEVICE_CONFIG: + # CORE CLOCK FREQUENCY + CORE_CLK_FREQ: CLK_1350MHZ + # PP CLOCK FREQUENCY + PP_CLK_FREQ: CLK_1350MHZ +... + +--- +device: + 0: + PC_PM_CORE: + ? + PC_PM_ID: 1 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x73510624 + RX_LANE_MAP: 0x46270513 + TX_POLARITY_FLIP: 0xa + RX_POLARITY_FLIP: 0x17 + ? + PC_PM_ID: 2 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x52317046 + RX_LANE_MAP: 0x31247056 + TX_POLARITY_FLIP: 0x90 + RX_POLARITY_FLIP: 0x47 + ? + PC_PM_ID: 3 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x23104567 + RX_LANE_MAP: 0x64752310 + TX_POLARITY_FLIP: 0x29 + RX_POLARITY_FLIP: 0x5a + ? + PC_PM_ID: 4 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x23104567 + RX_LANE_MAP: 0x64752310 + TX_POLARITY_FLIP: 0x29 + RX_POLARITY_FLIP: 0x5a + ? + PC_PM_ID: 5 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x25047361 + RX_LANE_MAP: 0x10452736 + TX_POLARITY_FLIP: 0xf5 + RX_POLARITY_FLIP: 0xc0 + ? + PC_PM_ID: 6 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x45763210 + RX_LANE_MAP: 0x13026457 + TX_POLARITY_FLIP: 0xa + RX_POLARITY_FLIP: 0xf9 + ? + PC_PM_ID: 7 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x45763210 + RX_LANE_MAP: 0x13026457 + TX_POLARITY_FLIP: 0xa + RX_POLARITY_FLIP: 0xf9 + ? + PC_PM_ID: 8 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x45673210 + RX_LANE_MAP: 0x13026457 + TX_POLARITY_FLIP: 0x4a + RX_POLARITY_FLIP: 0xf3 + ? + PC_PM_ID: 9 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x02476531 + RX_LANE_MAP: 0x05261734 + TX_POLARITY_FLIP: 0xdf + RX_POLARITY_FLIP: 0x84 + ? + PC_PM_ID: 10 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x37065241 + RX_LANE_MAP: 0x04175263 + TX_POLARITY_FLIP: 0x36 + RX_POLARITY_FLIP: 0x39 + ? + PC_PM_ID: 11 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x54762301 + RX_LANE_MAP: 0x13025467 + TX_POLARITY_FLIP: 0x70 + RX_POLARITY_FLIP: 0x6f + ? + PC_PM_ID: 12 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x73125046 + RX_LANE_MAP: 0x21437056 + TX_POLARITY_FLIP: 0x78 + RX_POLARITY_FLIP: 0x5c + ? + PC_PM_ID: 13 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x32104567 + RX_LANE_MAP: 0x64572310 + TX_POLARITY_FLIP: 0xd6 + RX_POLARITY_FLIP: 0xad + ? + PC_PM_ID: 14 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x03172465 + RX_LANE_MAP: 0x45173620 + TX_POLARITY_FLIP: 0xed + RX_POLARITY_FLIP: 0x36 + ? + PC_PM_ID: 15 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x36175042 + RX_LANE_MAP: 0x04176253 + TX_POLARITY_FLIP: 0x10 + RX_POLARITY_FLIP: 0xfa + ? + PC_PM_ID: 16 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x74615203 + RX_LANE_MAP: 0x51704236 + TX_POLARITY_FLIP: 0x5f + RX_POLARITY_FLIP: 0x56 + ? + PC_PM_ID: 17 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x26374051 + RX_LANE_MAP: 0x37046251 + TX_POLARITY_FLIP: 0xaa + RX_POLARITY_FLIP: 0x21 + ? + PC_PM_ID: 18 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x45672310 + RX_LANE_MAP: 0x32105476 + TX_POLARITY_FLIP: 0x15 + RX_POLARITY_FLIP: 0x92 + ? + PC_PM_ID: 19 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x70465321 + RX_LANE_MAP: 0x63107542 + TX_POLARITY_FLIP: 0xe6 + RX_POLARITY_FLIP: 0xf2 + ? + PC_PM_ID: 20 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x23015476 + RX_LANE_MAP: 0x64752301 + TX_POLARITY_FLIP: 0x50 + RX_POLARITY_FLIP: 0x6c +... + +--- +device: + 0: + PC_PORT_PHYS_MAP: + ? + # CPU port + PORT_ID: 0 + : + PC_PHYS_PORT_ID: 0 + ? + PORT_ID: 1 + : + PC_PHYS_PORT_ID: 1 + ? + PORT_ID: 3 + : + PC_PHYS_PORT_ID: 9 + ? + PORT_ID: 5 + : + PC_PHYS_PORT_ID: 13 + ? + PORT_ID: 7 + : + PC_PHYS_PORT_ID: 17 + ? + PORT_ID: 9 + : + PC_PHYS_PORT_ID: 21 + ? + PORT_ID: 11 + : + PC_PHYS_PORT_ID: 25 + ? + PORT_ID: 13 + : + PC_PHYS_PORT_ID: 29 + ? + PORT_ID: 15 + : + PC_PHYS_PORT_ID: 33 + ? + PORT_ID: 20 + : + PC_PHYS_PORT_ID: 41 + ? + PORT_ID: 22 + : + PC_PHYS_PORT_ID: 45 + ? + PORT_ID: 24 + : + PC_PHYS_PORT_ID: 49 + ? + PORT_ID: 26 + : + PC_PHYS_PORT_ID: 53 + ? + PORT_ID: 28 + : + PC_PHYS_PORT_ID: 57 + ? + PORT_ID: 30 + : + PC_PHYS_PORT_ID: 61 + ? + PORT_ID: 32 + : + PC_PHYS_PORT_ID: 65 + ? + PORT_ID: 34 + : + PC_PHYS_PORT_ID: 73 + ? + PORT_ID: 40 + : + PC_PHYS_PORT_ID: 81 + ? + PORT_ID: 42 + : + PC_PHYS_PORT_ID: 85 + ? + PORT_ID: 44 + : + PC_PHYS_PORT_ID: 89 + ? + PORT_ID: 46 + : + PC_PHYS_PORT_ID: 93 + ? + PORT_ID: 48 + : + PC_PHYS_PORT_ID: 97 + ? + PORT_ID: 50 + : + PC_PHYS_PORT_ID: 101 + ? + PORT_ID: 52 + : + PC_PHYS_PORT_ID: 105 + ? + PORT_ID: 54 + : + PC_PHYS_PORT_ID: 113 + ? + PORT_ID: 60 + : + PC_PHYS_PORT_ID: 121 + ? + PORT_ID: 62 + : + PC_PHYS_PORT_ID: 129 + ? + PORT_ID: 64 + : + PC_PHYS_PORT_ID: 137 + ? + PORT_ID: 66 + : + PC_PHYS_PORT_ID: 141 + ? + PORT_ID: 68 + : + PC_PHYS_PORT_ID: 145 + ? + PORT_ID: 70 + : + PC_PHYS_PORT_ID: 149 + ? + PORT_ID: 72 + : + PC_PHYS_PORT_ID: 153 + ? + PORT_ID: 74 + : + PC_PHYS_PORT_ID: 157 + +... + +--- +device: + 0: + PC_PORT: + ? + PORT_ID: 0 + : + ENABLE: 0 + SPEED: 10000 + NUM_LANES: 1 + ? + PORT_ID: [3, 5, 7, 9, 11, 13, + 20, 22, 24, 26, 28, 30, + 40, 42, 44, 46, 48, 50, + 64, 66, 68, 70, 72, 74] + : + ENABLE: 0 + SPEED: 200000 + FEC_MODE: PC_FEC_RS544_2XN + NUM_LANES: 4 + LINK_TRAINING: 0 + MAX_FRAME_SIZE: 9416 + ? + PORT_ID: [1, 15, 32, 34, 52, 54, 60, 62] + : + ENABLE: 0 + SPEED: 400000 + FEC_MODE: PC_FEC_RS544_2XN + NUM_LANES: 8 + LINK_TRAINING: 0 + MAX_FRAME_SIZE: 9416 +... + +--- +device: + 0: + TM_SCHEDULER_CONFIG: + NUM_MC_Q: NUM_MC_Q_4 +... + +--- +device: + 0: + FP_CONFIG: + FP_ING_OPERMODE: GLOBAL_PIPE_AWARE +... +--- +device: + 0: + PORT_PROPERTY: + ? + PORT_ID: 19 + : + PORT_TYPE: 1 + PORT_PARSER: 5 + EGR_PORT_PROPERTY: 2 + ? + PORT_ID: 59 + : + PORT_TYPE: 1 + PORT_PARSER: 5 + EGR_PORT_PROPERTY: 2 +... diff --git a/device/tencent/x86_64-tencent_tcs8400-r0/TCS8400-24CC8CD/port_config.ini b/device/tencent/x86_64-tencent_tcs8400-r0/TCS8400-24CC8CD/port_config.ini new file mode 100755 index 000000000000..781cb6eb953b --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs8400-r0/TCS8400-24CC8CD/port_config.ini @@ -0,0 +1,33 @@ +# name lanes alias index speed +Ethernet1 25,26,27,28 Eth200GE0/1 1 200000 +Ethernet2 29,30,31,32 Eth200GE0/2 2 200000 +Ethernet3 41,42,43,44 Eth200GE0/3 3 200000 +Ethernet4 45,46,47,48 Eth200GE0/4 4 200000 +Ethernet5 49,50,51,52 Eth200GE0/5 5 200000 +Ethernet6 53,54,55,56 Eth200GE0/6 6 200000 +Ethernet7 57,58,59,60 Eth200GE0/7 7 200000 +Ethernet8 61,62,63,64 Eth200GE0/8 8 200000 +Ethernet9 9,10,11,12 Eth200GE0/9 9 200000 +Ethernet10 13,14,15,16 Eth200GE0/10 10 200000 +Ethernet11 17,18,19,20 Eth200GE0/11 11 200000 +Ethernet12 21,22,23,24 Eth200GE0/12 12 200000 +Ethernet13 81,82,83,84 Eth200GE0/13 13 200000 +Ethernet14 85,86,87,88 Eth200GE0/14 14 200000 +Ethernet15 89,90,91,92 Eth200GE0/15 15 200000 +Ethernet16 93,94,95,96 Eth200GE0/16 16 200000 +Ethernet17 97,98,99,100 Eth200GE0/17 17 200000 +Ethernet18 101,102,103,104 Eth200GE0/18 18 200000 +Ethernet19 137,138,139,140 Eth200GE0/19 19 200000 +Ethernet20 141,142,143,144 Eth200GE0/20 20 200000 +Ethernet21 145,146,147,148 Eth200GE0/21 21 200000 +Ethernet22 149,150,151,152 Eth200GE0/22 22 200000 +Ethernet23 153,154,155,156 Eth200GE0/23 23 200000 +Ethernet24 157,158,159,160 Eth200GE0/24 24 200000 +Ethernet25 1,2,3,4,5,6,7,8 Eth400GE0/25 25 400000 +Ethernet26 33,34,35,36,37,38,39,40 Eth400GE0/26 26 400000 +Ethernet27 65,66,67,68,69,70,71,72 Eth400GE0/27 27 400000 +Ethernet28 73,74,75,76,77,78,79,80 Eth400GE0/28 28 400000 +Ethernet29 105,106,107,108,109,110,111,112 Eth400GE0/29 29 400000 +Ethernet30 113,114,115,116,117,118,119,120 Eth400GE0/30 30 400000 +Ethernet31 121,122,123,124,125,126,127,128 Eth400GE0/31 31 400000 +Ethernet32 129,130,131,132,133,134,135,136 Eth400GE0/32 32 400000 diff --git a/device/tencent/x86_64-tencent_tcs8400-r0/TCS8400-24CC8CD/sai.profile b/device/tencent/x86_64-tencent_tcs8400-r0/TCS8400-24CC8CD/sai.profile new file mode 100755 index 000000000000..06a5d9778660 --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs8400-r0/TCS8400-24CC8CD/sai.profile @@ -0,0 +1 @@ +SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/TCS8400-24CC8CD.yml diff --git a/device/tencent/x86_64-tencent_tcs8400-r0/config_db.TCS8400-24CC8CD.json b/device/tencent/x86_64-tencent_tcs8400-r0/config_db.TCS8400-24CC8CD.json new file mode 100755 index 000000000000..98586cb35c6b --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs8400-r0/config_db.TCS8400-24CC8CD.json @@ -0,0 +1,268 @@ +{ + "DEVICE_METADATA": { + "localhost": { + "hwsku": "TCS8400-24CC8CD", + "platform": "x86_64-tencent_tcs8400-r0", + "mac": "58:69:6c:f1:23:12", + "hostname": "sonic" + } + }, + "PORT": { + "Ethernet1": { + "lanes": "25,26,27,28", + "alias": "Eth200GE0/1", + "index": "1", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet2": { + "lanes": "29,30,31,32", + "alias": "Eth200GE0/2", + "index": "2", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet3": { + "lanes": "41,42,43,44", + "alias": "Eth200GE0/3", + "index": "3", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet4": { + "lanes": "45,46,47,48", + "alias": "Eth200GE0/4", + "index": "4", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet5": { + "lanes": "49,50,51,52", + "alias": "Eth200GE0/5", + "index": "5", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet6": { + "lanes": "53,54,55,56", + "alias": "Eth200GE0/6", + "index": "6", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet7": { + "lanes": "57,58,59,60", + "alias": "Eth200GE0/7", + "index": "7", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet8": { + "lanes": "61,62,63,64", + "alias": "Eth200GE0/8", + "index": "8", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet9": { + "lanes": "9,10,11,12", + "alias": "Eth200GE0/9", + "index": "9", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet10": { + "lanes": "13,14,15,16", + "alias": "Eth200GE0/10", + "index": "10", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet11": { + "lanes": "17,18,19,20", + "alias": "Eth200GE0/11", + "index": "11", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet12": { + "lanes": "21,22,23,24", + "alias": "Eth200GE0/12", + "index": "12", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet13": { + "lanes": "81,82,83,84", + "alias": "Eth200GE0/13", + "index": "13", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet14": { + "lanes": "85,86,87,88", + "alias": "Eth200GE0/14", + "index": "14", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet15": { + "lanes": "89,90,91,92", + "alias": "Eth200GE0/15", + "index": "15", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet16": { + "lanes": "93,94,95,96", + "alias": "Eth200GE0/16", + "index": "16", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet17": { + "lanes": "97,98,99,100", + "alias": "Eth200GE0/17", + "index": "17", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet18": { + "lanes": "101,102,103,104", + "alias": "Eth200GE0/18", + "index": "18", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet19": { + "lanes": "137,138,139,140", + "alias": "Eth200GE0/19", + "index": "19", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet20": { + "lanes": "141,142,143,144", + "alias": "Eth200GE0/20", + "index": "20", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet21": { + "lanes": "145,146,147,148", + "alias": "Eth200GE0/21", + "index": "21", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet22": { + "lanes": "149,150,151,152", + "alias": "Eth200GE0/22", + "index": "22", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet23": { + "lanes": "153,154,155,156", + "alias": "Eth200GE0/23", + "index": "23", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet24": { + "lanes": "157,158,159,160", + "alias": "Eth200GE0/24", + "index": "24", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet25": { + "lanes": "1,2,3,4,5,6,7,8", + "alias": "Eth400GE0/25", + "index": "25", + "speed": "400000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet26": { + "lanes": "33,34,35,36,37,38,39,40", + "alias": "Eth400GE0/26", + "index": "26", + "speed": "400000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet27": { + "lanes": "65,66,67,68,69,70,71,72", + "alias": "Eth400GE0/27", + "index": "27", + "speed": "400000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet28": { + "lanes": "73,74,75,76,77,78,79,80", + "alias": "Eth400GE0/28", + "index": "28", + "speed": "400000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet29": { + "lanes": "105,106,107,108,109,110,111,112", + "alias": "Eth400GE0/29", + "index": "29", + "speed": "400000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet30": { + "lanes": "113,114,115,116,117,118,119,120", + "alias": "Eth400GE0/30", + "index": "30", + "speed": "400000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet31": { + "lanes": "121,122,123,124,125,126,127,128", + "alias": "Eth400GE0/31", + "index": "31", + "speed": "400000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet32": { + "lanes": "129,130,131,132,133,134,135,136", + "alias": "Eth400GE0/32", + "index": "32", + "speed": "400000", + "admin_status": "up", + "mtu": "9100" + } + } +} diff --git a/device/tencent/x86_64-tencent_tcs8400-r0/cpu.cint b/device/tencent/x86_64-tencent_tcs8400-r0/cpu.cint new file mode 100755 index 000000000000..e286d3cf42a6 --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs8400-r0/cpu.cint @@ -0,0 +1,85 @@ +cint_reset(); + +int cint_field_group_create(int unit, bcm_field_group_t grp) +{ + int rv; + + bcm_field_qset_t qset; + bcm_field_aset_t aset; + + BCM_FIELD_QSET_INIT(qset); + BCM_FIELD_QSET_ADD(qset,bcmFieldQualifyDstMac); + BCM_FIELD_QSET_ADD(qset, bcmFieldQualifyStageIngress); + + BCM_FIELD_ASET_INIT(aset); + BCM_FIELD_ASET_ADD(aset, bcmFieldActionCopyToCpu); + + rv = bcm_field_group_create_mode_id(unit, qset, 103, bcmFieldGroupModeAuto, grp); + if (rv != BCM_E_NONE) { + printf("bcm_field_group_create_mode_id failed, rv = %d\r\n", rv); + return -1; + } + printf("cint_field_group_create success!!!, rv = %d\r\n", rv); + + bcm_field_group_dump(unit,grp); + return 0; +} + +int cint_field_entry_create1(int unit, bcm_field_group_t grp,bcm_field_entry_t entry) +{ + int rv; + bcm_mac_t dst_mac = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + bcm_mac_t mac_mask = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + + rv = bcm_field_entry_create_id(unit, grp, entry); + if (rv != BCM_E_NONE) { + printf("bcm_field_entry_create_id failed, rv = %d\r\n", rv); + return -1; + } + + + rv =bcm_field_qualify_DstMac(unit, entry, dst_mac, mac_mask); + if (rv != BCM_E_NONE) { + printf("bcm_field_qualify_DstMac failed,ret = %d\r\n", rv); + bcm_field_entry_destroy(unit, entry); + return -1; + } + + rv = bcm_field_action_add(unit, entry, bcmFieldActionCopyToCpu, 1, 0); + if (rv != BCM_E_NONE) { + printf("bcm_field_action_add failed, rv = %d \r\n", rv); + bcm_field_entry_destroy(unit, entry); + return -1; + } + + rv = bcm_field_action_add(unit, entry, bcmFieldActionDrop, 1, 0); + if (rv != BCM_E_NONE) { + printf("bcm_field_action_add failed, rv = %d \r\n", rv); + bcm_field_entry_destroy(unit, entry); + return -1; + } + + rv = bcm_field_entry_install(unit, entry); + if (rv != BCM_E_NONE) { + printf("bcm_field_entry_install failed,ret = %d\r\n", rv); + bcm_field_entry_destroy(unit, entry); + return -1; + } + + printf("********************* BEGIN ****************************\r\n"); + bcm_field_entry_dump(unit, entry); + printf("*********************** END ****************************\r\n"); + + return 0; +} + +cint_field_group_create(0,5); +cint_field_entry_create1(0,5,2048); + +//bcm_field_entry_destroy(0, 2048); +//bcm_field_group_destroy(0, 5); + + + + + diff --git a/device/tencent/x86_64-tencent_tcs8400-r0/custom_led.bin b/device/tencent/x86_64-tencent_tcs8400-r0/custom_led.bin new file mode 100755 index 000000000000..00dfde29fa27 Binary files /dev/null and b/device/tencent/x86_64-tencent_tcs8400-r0/custom_led.bin differ diff --git a/device/tencent/x86_64-tencent_tcs8400-r0/default_sku b/device/tencent/x86_64-tencent_tcs8400-r0/default_sku new file mode 100755 index 000000000000..8689e789a088 --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs8400-r0/default_sku @@ -0,0 +1 @@ +TCS8400-24CC8CD t1 diff --git a/device/tencent/x86_64-tencent_tcs8400-r0/dev.xml b/device/tencent/x86_64-tencent_tcs8400-r0/dev.xml new file mode 100755 index 000000000000..be6880fd9416 --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs8400-r0/dev.xml @@ -0,0 +1,349 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/device/tencent/x86_64-tencent_tcs8400-r0/dev_0x407b.xml b/device/tencent/x86_64-tencent_tcs8400-r0/dev_0x407b.xml new file mode 100755 index 000000000000..82433485f8db --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs8400-r0/dev_0x407b.xml @@ -0,0 +1,349 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/device/tencent/x86_64-tencent_tcs8400-r0/fru.py b/device/tencent/x86_64-tencent_tcs8400-r0/fru.py new file mode 100755 index 000000000000..2ccfba01dea2 --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs8400-r0/fru.py @@ -0,0 +1,953 @@ +#!/usr/bin/python3 +import collections +from bitarray import bitarray +from datetime import datetime, timedelta + + +__DEBUG__ = "N" + + +class FruException(Exception): + def __init__(self, message='fruerror', code=-100): + err = 'errcode: {0} message:{1}'.format(code, message) + Exception.__init__(self, err) + self.code = code + self.message = message + + +def e_print(err): + print("ERROR: " + err) + + +def d_print(debug_info): + if(__DEBUG__ == "Y"): + print(debug_info) + + +class FruUtil(): + @staticmethod + def decodeLength(value): + a = bitarray(8) + a.setall(True) + a[0:1] = 0 + a[1:2] = 0 + x = ord(a.tobytes()) + return x & ord(value) + + @staticmethod + def minToData(): + starttime = datetime(1996, 1, 1, 0, 0, 0) + endtime = datetime.now() + seconds = (endtime - starttime).total_seconds() + mins = seconds // 60 + m = int(round(mins)) + return m + + @staticmethod + def getTimeFormat(): + return datetime.now().strftime('%Y-%m-%d') + + @staticmethod + def getTypeLength(value): + if value is None or len(value) == 0: + return 0 + a = bitarray(8) + a.setall(False) + a[0:1] = 1 + a[1:2] = 1 + x = ord(a.tobytes()) + return x | len(value) + + @staticmethod + def checksum(b): + result = 0 + for i in range(len(b)): + result += ord(b[i]) + return (0x100 - (result & 0xff)) & 0xff + + +class BaseArea(object): + SUGGESTED_SIZE_COMMON_HEADER = 8 + SUGGESTED_SIZE_INTERNAL_USE_AREA = 72 + SUGGESTED_SIZE_CHASSIS_INFO_AREA = 32 + SUGGESTED_SIZE_BOARD_INFO_AREA = 80 + SUGGESTED_SIZE_PRODUCT_INFO_AREA = 80 + + INITVALUE = b'\x00' + resultvalue = INITVALUE * 256 + COMMON_HEAD_VERSION = b'\x01' + __childList = None + + def __init__(self, name="", size=0, offset=0): + self.__childList = [] + self._offset = offset + self.name = name + self._size = size + self._isPresent = False + self._data = b'\x00' * size + self.__dataoffset = 0 + + @property + def childList(self): + return self.__childList + + @childList.setter + def childList(self, value): + self.__childList = value + + @property + def offset(self): + return self._offset + + @offset.setter + def offset(self, value): + self._offset = value + + @property + def size(self): + return self._size + + @size.setter + def size(self, value): + self._size = value + + @property + def data(self): + return self._data + + @data.setter + def data(self, value): + self._data = value + + @property + def isPresent(self): + return self._isPresent + + @isPresent.setter + def isPresent(self, value): + self._isPresent = value + + +class InternalUseArea(BaseArea): + pass + + +class ChassisInfoArea(BaseArea): + pass + + +class BoardInfoArea(BaseArea): + _boardTime = None + _fields = None + _mfg_date = None + + def __str__(self): + formatstr = "version : %x\n" \ + "length : %d \n" \ + "language : %x \n" \ + "mfg_date : %s \n" \ + "boardManufacturer : %s \n" \ + "boardProductName : %s \n" \ + "boardSerialNumber : %s \n" \ + "boardPartNumber : %s \n" \ + "fruFileId : %s \n" + + tmpstr = formatstr % (ord(self.boardversion), self.size, + self.language, self.getMfgRealData(), + self.boardManufacturer, self.boardProductName, + self.boardSerialNumber, self.boardPartNumber, + self.fruFileId) + for i in range(1, 11): + valtmp = "boardextra%d" % i + if hasattr(self, valtmp): + valtmpval = getattr(self, valtmp) + tmpstr += "boardextra%d : %s \n" % (i, valtmpval) + else: + break + + return tmpstr + + def todict(self): + dic = collections.OrderedDict() + dic["boardversion"] = ord(self.boardversion) + dic["boardlength"] = self.size + dic["boardlanguage"] = self.language + dic["boardmfg_date"] = self.getMfgRealData() + dic["boardManufacturer"] = self.boardManufacturer + dic["boardProductName"] = self.boardProductName + dic["boardSerialNumber"] = self.boardSerialNumber + dic["boardPartNumber"] = self.boardPartNumber + dic["boardfruFileId"] = self.fruFileId + for i in range(1, 11): + valtmp = "boardextra%d" % i + if hasattr(self, valtmp): + valtmpval = getattr(self, valtmp) + dic[valtmp] = valtmpval + else: + break + return dic + + def decodedata(self): + index = 0 + self.areaversion = self.data[index] + index += 1 + d_print("decode length :%d class size:%d" % + ((ord(self.data[index]) * 8), self.size)) + index += 2 + + timetmp = self.data[index: index + 3] + self.mfg_date = ord(timetmp[0]) | ( + ord(timetmp[1]) << 8) | (ord(timetmp[2]) << 16) + d_print("decode getMfgRealData :%s" % self.getMfgRealData()) + index += 3 + + templen = FruUtil.decodeLength(self.data[index]) + self.boardManufacturer = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode boardManufacturer:%s" % self.boardManufacturer) + + templen = FruUtil.decodeLength(self.data[index]) + self.boardProductName = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode boardProductName:%s" % self.boardProductName) + + templen = FruUtil.decodeLength(self.data[index]) + self.boardSerialNumber = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode boardSerialNumber:%s" % self.boardSerialNumber) + + templen = FruUtil.decodeLength(self.data[index]) + self.boardPartNumber = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode boardPartNumber:%s" % self.boardPartNumber) + + templen = FruUtil.decodeLength(self.data[index]) + self.fruFileId = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode fruFileId:%s" % self.fruFileId) + + for i in range(1, 11): + valtmp = "boardextra%d" % i + if self.data[index] != chr(0xc1): + templen = FruUtil.decodeLength(self.data[index]) + tmpval = self.data[index + 1: index + templen + 1] + setattr(self, valtmp, tmpval) + index += templen + 1 + d_print("decode boardextra%d:%s" % (i, tmpval)) + else: + break + return + + def recalcute(self): + d_print("boardInfoArea version:%x" % ord(self.boardversion)) + d_print("boardInfoArea length:%d" % self.size) + d_print("boardInfoArea language:%x" % self.language) + self.mfg_date = FruUtil.minToData() + d_print("boardInfoArea mfg_date:%x" % self.mfg_date) + + self.data = chr(ord(self.boardversion)) + \ + chr(self.size // 8) + chr(self.language) + + self.data += chr(self.mfg_date & 0xFF) + self.data += chr((self.mfg_date >> 8) & 0xFF) + self.data += chr((self.mfg_date >> 16) & 0xFF) + + d_print("boardInfoArea boardManufacturer:%s" % self.boardManufacturer) + typelength = FruUtil.getTypeLength(self.boardManufacturer) + self.data += chr(typelength) + self.data += self.boardManufacturer + + d_print("boardInfoArea boardProductName:%s" % self.boardProductName) + self.data += chr(FruUtil.getTypeLength(self.boardProductName)) + self.data += self.boardProductName + + d_print("boardInfoArea boardSerialNumber:%s" % self.boardSerialNumber) + self.data += chr(FruUtil.getTypeLength(self.boardSerialNumber)) + self.data += self.boardSerialNumber + + d_print("boardInfoArea boardPartNumber:%s" % self.boardPartNumber) + self.data += chr(FruUtil.getTypeLength(self.boardPartNumber)) + self.data += self.boardPartNumber + + d_print("boardInfoArea fruFileId:%s" % self.fruFileId) + self.data += chr(FruUtil.getTypeLength(self.fruFileId)) + self.data += self.fruFileId + + for i in range(1, 11): + valtmp = "boardextra%d" % i + if hasattr(self, valtmp): + valtmpval = getattr(self, valtmp) + d_print("boardInfoArea boardextra%d:%s" % (i, valtmpval)) + self.data += chr(FruUtil.getTypeLength(valtmpval)) + if valtmpval is None: + pass + else: + self.data += valtmpval + else: + break + + self.data += chr(0xc1) + + if len(self.data) > (self.size - 1): + incr = (len(self.data) - self.size) // 8 + 1 + self.size += incr * 8 + + self.data = self.data[0:1] + chr(self.size // 8) + self.data[2:] + d_print("self data:%d" % len(self.data)) + d_print("self size:%d" % self.size) + d_print("adjust size:%d" % (self.size - len(self.data) - 1)) + self.data = self.data.ljust((self.size - 1), chr(self.INITVALUE[0])) + + # checksum + checksum = FruUtil.checksum(self.data) + d_print("board info checksum:%x" % checksum) + self.data += chr(checksum) + + def getMfgRealData(self): + starttime = datetime(1996, 1, 1, 0, 0, 0) + mactime = starttime + timedelta(minutes=self.mfg_date) + return mactime + + @property + def language(self): + self._language = 25 + return self._language + + @property + def mfg_date(self): + return self._mfg_date + + @mfg_date.setter + def mfg_date(self, val): + self._mfg_date = val + + @property + def boardversion(self): + self._boardversion = self.COMMON_HEAD_VERSION + return self._boardversion + + @property + def fruFileId(self): + return self._FRUFileID + + @fruFileId.setter + def fruFileId(self, val): + self._FRUFileID = val + + @property + def boardPartNumber(self): + return self._boardPartNumber + + @boardPartNumber.setter + def boardPartNumber(self, val): + self._boardPartNumber = val + + @property + def boardSerialNumber(self): + return self._boardSerialNumber + + @boardSerialNumber.setter + def boardSerialNumber(self, val): + self._boardSerialNumber = val + + @property + def boardProductName(self): + return self._boradProductName + + @boardProductName.setter + def boardProductName(self, val): + self._boradProductName = val + + @property + def boardManufacturer(self): + return self._boardManufacturer + + @boardManufacturer.setter + def boardManufacturer(self, val): + self._boardManufacturer = val + + @property + def boardTime(self): + return self._boardTime + + @boardTime.setter + def boardTime(self, val): + self._boardTime = val + + @property + def fields(self): + return self._fields + + @fields.setter + def fields(self, val): + self._fields = val + + +class ProductInfoArea(BaseArea): + _productManufacturer = None + _productAssetTag = None + _FRUFileID = None + + def __str__(self): + formatstr = "version : %x\n" \ + "length : %d \n" \ + "language : %x \n" \ + "productManufacturer : %s \n" \ + "productName : %s \n" \ + "productPartModelName: %s \n" \ + "productVersion : %s \n" \ + "productSerialNumber : %s \n" \ + "productAssetTag : %s \n" \ + "fruFileId : %s \n" + + tmpstr = formatstr % (ord(self.areaversion), self.size, + self.language, self.productManufacturer, + self.productName, self.productPartModelName, + self.productVersion, self.productSerialNumber, + self.productAssetTag, self.fruFileId) + + for i in range(1, 11): + valtmp = "productextra%d" % i + if hasattr(self, valtmp): + valtmpval = getattr(self, valtmp) + tmpstr += "productextra%d : %s \n" % (i, valtmpval) + else: + break + + return tmpstr + + def todict(self): + dic = collections.OrderedDict() + dic["productversion"] = ord(self.areaversion) + dic["productlength"] = self.size + dic["productlanguage"] = self.language + dic["productManufacturer"] = self.productManufacturer + dic["productName"] = self.productName + dic["productPartModelName"] = self.productPartModelName + dic["productVersion"] = int(self.productVersion, 16) + dic["productSerialNumber"] = self.productSerialNumber + dic["productAssetTag"] = self.productAssetTag + dic["productfruFileId"] = self.fruFileId + for i in range(1, 11): + valtmp = "productextra%d" % i + if hasattr(self, valtmp): + valtmpval = getattr(self, valtmp) + dic[valtmp] = valtmpval + else: + break + return dic + + def decodedata(self): + index = 0 + self.areaversion = self.data[index] # 0 + index += 1 + d_print("decode length %d" % (ord(self.data[index]) * 8)) + d_print("class size %d" % self.size) + index += 2 + + templen = FruUtil.decodeLength(self.data[index]) + self.productManufacturer = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode productManufacturer:%s" % self.productManufacturer) + + templen = FruUtil.decodeLength(self.data[index]) + self.productName = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode productName:%s" % self.productName) + + templen = FruUtil.decodeLength(self.data[index]) + self.productPartModelName = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode productPartModelName:%s" % self.productPartModelName) + + templen = FruUtil.decodeLength(self.data[index]) + self.productVersion = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode productVersion:%s" % self.productVersion) + + templen = FruUtil.decodeLength(self.data[index]) + self.productSerialNumber = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode productSerialNumber:%s" % self.productSerialNumber) + + templen = FruUtil.decodeLength(self.data[index]) + self.productAssetTag = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode productAssetTag:%s" % self.productAssetTag) + + templen = FruUtil.decodeLength(self.data[index]) + self.fruFileId = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode fruFileId:%s" % self.fruFileId) + + for i in range(1, 11): + valtmp = "productextra%d" % i + if self.data[index] != chr(0xc1) and index < self.size - 1: + templen = FruUtil.decodeLength(self.data[index]) + if templen == 0: + break + tmpval = self.data[index + 1: index + templen + 1] + d_print("decode boardextra%d:%s" % (i, tmpval)) + setattr(self, valtmp, tmpval) + index += templen + 1 + else: + break + + @property + def productVersion(self): + return self._productVersion + + @productVersion.setter + def productVersion(self, name): + self._productVersion = name + + @property + def areaversion(self): + self._areaversion = self.COMMON_HEAD_VERSION + return self._areaversion + + @areaversion.setter + def areaversion(self, name): + self._areaversion = name + + @property + def language(self): + self._language = 25 + return self._language + + @property + def productManufacturer(self): + return self._productManufacturer + + @productManufacturer.setter + def productManufacturer(self, name): + self._productManufacturer = name + + @property + def productName(self): + return self._productName + + @productName.setter + def productName(self, name): + self._productName = name + + @property + def productPartModelName(self): + return self._productPartModelName + + @productPartModelName.setter + def productPartModelName(self, name): + self._productPartModelName = name + + @property + def productSerialNumber(self): + return self._productSerialNumber + + @productSerialNumber.setter + def productSerialNumber(self, name): + self._productSerialNumber = name + + @property + def productAssetTag(self): + return self._productAssetTag + + @productAssetTag.setter + def productAssetTag(self, name): + self._productAssetTag = name + + @property + def fruFileId(self): + return self._FRUFileID + + @fruFileId.setter + def fruFileId(self, name): + self._FRUFileID = name + + def recalcute(self): + d_print("product version:%x" % ord(self.areaversion)) + d_print("product length:%d" % self.size) + d_print("product language:%x" % self.language) + self.data = chr(ord(self.areaversion)) + \ + chr(self.size // 8) + chr(self.language) + + typelength = FruUtil.getTypeLength(self.productManufacturer) + self.data += chr(typelength) + self.data += self.productManufacturer + + self.data += chr(FruUtil.getTypeLength(self.productName)) + self.data += self.productName + + self.data += chr(FruUtil.getTypeLength(self.productPartModelName)) + self.data += self.productPartModelName + + self.data += chr(FruUtil.getTypeLength(self.productVersion)) + self.data += self.productVersion + + self.data += chr(FruUtil.getTypeLength(self.productSerialNumber)) + self.data += self.productSerialNumber + + self.data += chr(FruUtil.getTypeLength(self.productAssetTag)) + if self.productAssetTag is not None: + self.data += self.productAssetTag + + self.data += chr(FruUtil.getTypeLength(self.fruFileId)) + self.data += self.fruFileId + + for i in range(1, 11): + valtmp = "productextra%d" % i + if hasattr(self, valtmp): + valtmpval = getattr(self, valtmp) + d_print("boardInfoArea productextra%d:%s" % (i, valtmpval)) + self.data += chr(FruUtil.getTypeLength(valtmpval)) + if valtmpval is None: + pass + else: + self.data += valtmpval + else: + break + + self.data += chr(0xc1) + if len(self.data) > (self.size - 1): + incr = (len(self.data) - self.size) // 8 + 1 + self.size += incr * 8 + d_print("self.data:%d" % len(self.data)) + d_print("self.size:%d" % self.size) + + self.data = self.data[0:1] + chr(self.size // 8) + self.data[2:] + self.data = self.data.ljust((self.size - 1), chr(self.INITVALUE[0])) + checksum = FruUtil.checksum(self.data) + d_print("board info checksum:%x" % checksum) + self.data += chr(checksum) + + +class MultiRecordArea(BaseArea): + pass + + +class Field(object): + + def __init__(self, fieldType="ASCII", fieldData=""): + self.fieldData = fieldData + self.fieldType = fieldType + + @property + def data(self): + return self._data + + @property + def fieldType(self): + return self._fieldType + + @property + def fieldData(self): + return self._fieldData + + +class ipmifru(BaseArea): + _BoardInfoArea = None + _ProductInfoArea = None + _InternalUseArea = None + _ChassisInfoArea = None + _multiRecordArea = None + _productinfoAreaOffset = BaseArea.INITVALUE + _boardInfoAreaOffset = BaseArea.INITVALUE + _internalUserAreaOffset = BaseArea.INITVALUE + _chassicInfoAreaOffset = BaseArea.INITVALUE + _multiRecordAreaOffset = BaseArea.INITVALUE + _bindata = None + _bodybin = None + _version = BaseArea.COMMON_HEAD_VERSION + _zeroCheckSum = None + _frusize = 256 + + def __str__(self): + tmpstr = "" + if self.boardInfoArea.isPresent: + tmpstr += "\nboardinfoarea: \n" + tmpstr += self.boardInfoArea.__str__() + if self.productInfoArea.isPresent: + tmpstr += "\nproductinfoarea: \n" + tmpstr += self.productInfoArea.__str__() + return tmpstr + + def decodeBin(self, eeprom): + commonHead = eeprom[0:8] + d_print("decode version %x" % ord(commonHead[0])) + if ord(self.COMMON_HEAD_VERSION) != ord(commonHead[0]): + raise FruException("HEAD VERSION error,not Fru format!", -10) + if FruUtil.checksum(commonHead[0:7]) != ord(commonHead[7]): + strtemp = "check header checksum error [cal:%02x data:%02x]" % ( + FruUtil.checksum(commonHead[0:7]), ord(commonHead[7])) + raise FruException(strtemp, -3) + if ord(commonHead[1]) != ord(self.INITVALUE): + d_print("Internal Use Area is present") + self.internalUseArea = InternalUseArea( + name="Internal Use Area", size=self.SUGGESTED_SIZE_INTERNAL_USE_AREA) + self.internalUseArea.isPresent = True + self.internalUserAreaOffset = ord(commonHead[1]) + self.internalUseArea.data = eeprom[self.internalUserAreaOffset * 8: ( + self.internalUserAreaOffset * 8 + self.internalUseArea.size)] + if ord(commonHead[2]) != ord(self.INITVALUE): + d_print("Chassis Info Area is present") + self.chassisInfoArea = ChassisInfoArea( + name="Chassis Info Area", size=self.SUGGESTED_SIZE_CHASSIS_INFO_AREA) + self.chassisInfoArea.isPresent = True + self.chassicInfoAreaOffset = ord(commonHead[2]) + self.chassisInfoArea.data = eeprom[self.chassicInfoAreaOffset * 8: ( + self.chassicInfoAreaOffset * 8 + self.chassisInfoArea.size)] + if ord(commonHead[3]) != ord(self.INITVALUE): + self.boardInfoArea = BoardInfoArea( + name="Board Info Area", size=self.SUGGESTED_SIZE_BOARD_INFO_AREA) + self.boardInfoArea.isPresent = True + self.boardInfoAreaOffset = ord(commonHead[3]) + self.boardInfoArea.size = ord( + eeprom[self.boardInfoAreaOffset * 8 + 1]) * 8 + d_print("Board Info Area is present size:%d" % + (self.boardInfoArea.size)) + self.boardInfoArea.data = eeprom[self.boardInfoAreaOffset * 8: ( + self.boardInfoAreaOffset * 8 + self.boardInfoArea.size)] + if FruUtil.checksum(self.boardInfoArea.data[:-1]) != ord(self.boardInfoArea.data[-1:]): + strtmp = "check boardInfoArea checksum error[cal:%02x data:%02x]" % \ + (FruUtil.checksum( + self.boardInfoArea.data[:-1]), ord(self.boardInfoArea.data[-1:])) + raise FruException(strtmp, -3) + self.boardInfoArea.decodedata() + if ord(commonHead[4]) != ord(self.INITVALUE): + d_print("Product Info Area is present") + self.productInfoArea = ProductInfoArea( + name="Product Info Area ", size=self.SUGGESTED_SIZE_PRODUCT_INFO_AREA) + self.productInfoArea.isPresent = True + self.productinfoAreaOffset = ord(commonHead[4]) + d_print("length offset value: %02x" % + ord(eeprom[self.productinfoAreaOffset * 8 + 1])) + self.productInfoArea.size = ord( + eeprom[self.productinfoAreaOffset * 8 + 1]) * 8 + d_print("Product Info Area is present size:%d" % + (self.productInfoArea.size)) + + self.productInfoArea.data = eeprom[self.productinfoAreaOffset * 8: ( + self.productinfoAreaOffset * 8 + self.productInfoArea.size)] + if FruUtil.checksum(self.productInfoArea.data[:-1]) != ord(self.productInfoArea.data[-1:]): + strtmp = "check productInfoArea checksum error [cal:%02x data:%02x]" % ( + FruUtil.checksum(self.productInfoArea.data[:-1]), ord(self.productInfoArea.data[-1:])) + raise FruException(strtmp, -3) + self.productInfoArea.decodedata() + if ord(commonHead[5]) != ord(self.INITVALUE): + self.multiRecordArea = MultiRecordArea( + name="MultiRecord record Area ") + d_print("MultiRecord record present") + self.multiRecordArea.isPresent = True + self.multiRecordAreaOffset = ord(commonHead[5]) + self.multiRecordArea.data = eeprom[self.multiRecordAreaOffset * 8: ( + self.multiRecordAreaOffset * 8 + self.multiRecordArea.size)] + + def initDefault(self): + self.version = self.COMMON_HEAD_VERSION + self.internalUserAreaOffset = self.INITVALUE + self.chassicInfoAreaOffset = self.INITVALUE + self.boardInfoAreaOffset = self.INITVALUE + self.productinfoAreaOffset = self.INITVALUE + self.multiRecordAreaOffset = self.INITVALUE + self.PAD = self.INITVALUE + self.zeroCheckSum = self.INITVALUE + self.offset = self.SUGGESTED_SIZE_COMMON_HEADER + self.productInfoArea = None + self.internalUseArea = None + self.boardInfoArea = None + self.chassisInfoArea = None + self.multiRecordArea = None + # self.recalcute() + + @property + def version(self): + return self._version + + @version.setter + def version(self, name): + self._version = name + + @property + def internalUserAreaOffset(self): + return self._internalUserAreaOffset + + @internalUserAreaOffset.setter + def internalUserAreaOffset(self, obj): + self._internalUserAreaOffset = obj + + @property + def chassicInfoAreaOffset(self): + return self._chassicInfoAreaOffset + + @chassicInfoAreaOffset.setter + def chassicInfoAreaOffset(self, obj): + self._chassicInfoAreaOffset = obj + + @property + def productinfoAreaOffset(self): + return self._productinfoAreaOffset + + @productinfoAreaOffset.setter + def productinfoAreaOffset(self, obj): + self._productinfoAreaOffset = obj + + @property + def boardInfoAreaOffset(self): + return self._boardInfoAreaOffset + + @boardInfoAreaOffset.setter + def boardInfoAreaOffset(self, obj): + self._boardInfoAreaOffset = obj + + @property + def multiRecordAreaOffset(self): + return self._multiRecordAreaOffset + + @multiRecordAreaOffset.setter + def multiRecordAreaOffset(self, obj): + self._multiRecordAreaOffset = obj + + @property + def zeroCheckSum(self): + return self._zeroCheckSum + + @zeroCheckSum.setter + def zeroCheckSum(self, obj): + self._zeroCheckSum = obj + + @property + def productInfoArea(self): + return self._ProductInfoArea + + @productInfoArea.setter + def productInfoArea(self, obj): + self._ProductInfoArea = obj + + @property + def internalUseArea(self): + return self._InternalUseArea + + @internalUseArea.setter + def internalUseArea(self, obj): + self.internalUseArea = obj + + @property + def boardInfoArea(self): + return self._BoardInfoArea + + @boardInfoArea.setter + def boardInfoArea(self, obj): + self._BoardInfoArea = obj + + @property + def chassisInfoArea(self): + return self._ChassisInfoArea + + @chassisInfoArea.setter + def chassisInfoArea(self, obj): + self._ChassisInfoArea = obj + + @property + def multiRecordArea(self): + return self._multiRecordArea + + @multiRecordArea.setter + def multiRecordArea(self, obj): + self._multiRecordArea = obj + + @property + def bindata(self): + return self._bindata + + @bindata.setter + def bindata(self, obj): + self._bindata = obj + + @property + def bodybin(self): + return self._bodybin + + @bodybin.setter + def bodybin(self, obj): + self._bodybin = obj + + def recalcuteCommonHead(self): + self.bindata = "" + self.offset = self.SUGGESTED_SIZE_COMMON_HEADER + d_print("common Header %d" % self.offset) + d_print("fru eeprom size %d" % self._frusize) + if self.internalUseArea is not None and self.internalUseArea.isPresent: + self.internalUserAreaOffset = self.offset // 8 + self.offset += self.internalUseArea.size + d_print("internalUseArea is present offset:%d" % self.offset) + + if self.chassisInfoArea is not None and self.chassisInfoArea.isPresent: + self.chassicInfoAreaOffset = self.offset // 8 + self.offset += self.chassisInfoArea.size + d_print("chassisInfoArea is present offset:%d" % self.offset) + + if self.boardInfoArea is not None and self.boardInfoArea.isPresent: + self.boardInfoAreaOffset = self.offset // 8 + self.offset += self.boardInfoArea.size + d_print("boardInfoArea is present offset:%d" % self.offset) + d_print("boardInfoArea is present size:%d" % + self.boardInfoArea.size) + + if self.productInfoArea is not None and self.productInfoArea.isPresent: + self.productinfoAreaOffset = self.offset // 8 + self.offset += self.productInfoArea.size + d_print("productInfoArea is present offset:%d" % self.offset) + + if self.multiRecordArea is not None and self.multiRecordArea.isPresent: + self.multiRecordAreaOffset = self.offset // 8 + d_print("multiRecordArea is present offset:%d" % self.offset) + + if self.internalUserAreaOffset == self.INITVALUE: + self.internalUserAreaOffset = 0 + if self.productinfoAreaOffset == self.INITVALUE: + self.productinfoAreaOffset = 0 + if self.chassicInfoAreaOffset == self.INITVALUE: + self.chassicInfoAreaOffset = 0 + if self.boardInfoAreaOffset == self.INITVALUE: + self.boardInfoAreaOffset = 0 + if self.multiRecordAreaOffset == self.INITVALUE: + self.multiRecordAreaOffset = 0 + + self.zeroCheckSum = (0x100 - ord(self.version) - self.internalUserAreaOffset - self.chassicInfoAreaOffset - self.productinfoAreaOffset + - self.boardInfoAreaOffset - self.multiRecordAreaOffset) & 0xff + d_print("zerochecksum:%x" % self.zeroCheckSum) + self.data = "" + self.data += chr(self.version[0]) + chr(self.internalUserAreaOffset) + chr(self.chassicInfoAreaOffset) + chr( + self.boardInfoAreaOffset) + chr(self.productinfoAreaOffset) + chr(self.multiRecordAreaOffset) + chr(self.INITVALUE[0]) + chr(self.zeroCheckSum) + + self.bindata = self.data + self.bodybin + totallen = len(self.bindata) + d_print("totallen %d" % totallen) + if (totallen < self._frusize): + self.bindata = self.bindata.ljust(self._frusize, chr(self.INITVALUE[0])) + else: + raise FruException('bin data more than %d' % self._frusize, -2) + + def recalcutebin(self): + self.bodybin = "" + if self.internalUseArea is not None and self.internalUseArea.isPresent: + d_print("internalUseArea present") + self.bodybin += self.internalUseArea.data + if self.chassisInfoArea is not None and self.chassisInfoArea.isPresent: + d_print("chassisInfoArea present") + self.bodybin += self.chassisInfoArea.data + if self.boardInfoArea is not None and self.boardInfoArea.isPresent: + d_print("boardInfoArea present") + self.boardInfoArea.recalcute() + self.bodybin += self.boardInfoArea.data + if self.productInfoArea is not None and self.productInfoArea.isPresent: + d_print("productInfoAreapresent") + self.productInfoArea.recalcute() + self.bodybin += self.productInfoArea.data + if self.multiRecordArea is not None and self.multiRecordArea.isPresent: + d_print("multiRecordArea present") + self.bodybin += self.productInfoArea.data + + def recalcute(self, fru_eeprom_size=256): + self._frusize = fru_eeprom_size + self.recalcutebin() + self.recalcuteCommonHead() diff --git a/device/tencent/x86_64-tencent_tcs8400-r0/installer.conf b/device/tencent/x86_64-tencent_tcs8400-r0/installer.conf new file mode 100755 index 000000000000..5e62742c11bf --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs8400-r0/installer.conf @@ -0,0 +1 @@ +CONSOLE_SPEED=115200 diff --git a/device/tencent/x86_64-tencent_tcs8400-r0/led_proc_init.soc b/device/tencent/x86_64-tencent_tcs8400-r0/led_proc_init.soc new file mode 100755 index 000000000000..2f79a8febf86 --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs8400-r0/led_proc_init.soc @@ -0,0 +1,6 @@ + +led auto on + +led start + +linkscan SwPortBitMap=all diff --git a/device/tencent/x86_64-tencent_tcs8400-r0/monitor.py b/device/tencent/x86_64-tencent_tcs8400-r0/monitor.py new file mode 100755 index 000000000000..acaf9b4a8c65 --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs8400-r0/monitor.py @@ -0,0 +1,431 @@ +#!/usr/bin/python3 +# * onboard temperature sensors +# * FAN trays +# * PSU +# +import os +import xml.etree.ElementTree as ET +import glob +from fru import ipmifru +from decimal import Decimal + + +MAILBOX_DIR = "/sys/bus/i2c/devices/" +BOARD_ID_PATH = "/sys/module/ruijie_common/parameters/dfd_my_type" + +CONFIG_NAME = "dev.xml" + +def byteTostr(val): + strtmp = '' + for i in range(len(val)): + strtmp += chr(val[i]) + return strtmp + + +def typeTostr(val): + if isinstance(val, bytes): + strtmp = byteTostr(val) + return strtmp + return val + + +def get_board_id(): + if not os.path.exists(BOARD_ID_PATH): + return "NA" + with open(BOARD_ID_PATH) as fd: + id_str = fd.read().strip() + return "0x%x" % (int(id_str, 10)) + + +def dev_file_read(path, offset, read_len): + retval = "ERR" + val_list = [] + msg = "" + ret = "" + fd = -1 + + if not os.path.exists(path): + return False, "%s %s not found" % (retval, path) + + try: + fd = os.open(path, os.O_RDONLY) + os.lseek(fd, offset, os.SEEK_SET) + ret = os.read(fd, read_len) + for item in ret: + val_list.append(item) + except Exception as e: + msg = str(e) + return False, "%s %s" % (retval, msg) + finally: + if fd > 0: + os.close(fd) + return True, val_list + + +def getPMCreg(location): + retval = 'ERR' + if (not os.path.isfile(location)): + return "%s %s notfound"% (retval , location) + try: + with open(location, 'r') as fd: + retval = fd.read() + except Exception as error: + return "ERR %s" % str(error) + + retval = retval.rstrip('\r\n') + retval = retval.lstrip(" ") + return retval + + +# Get a mailbox register +def get_pmc_register(reg_name): + retval = 'ERR' + mb_reg_file = reg_name + filepath = glob.glob(mb_reg_file) + if(len(filepath) == 0): + return "%s %s notfound"% (retval , mb_reg_file) + mb_reg_file = filepath[0] + if (not os.path.isfile(mb_reg_file)): + #print mb_reg_file, 'not found !' + return "%s %s notfound"% (retval , mb_reg_file) + try: + with open(mb_reg_file, 'rb') as fd: + retval = fd.read() + retval = typeTostr(retval) + except Exception as error: + retval = "%s %s read failed, msg: %s" % (retval, mb_reg_file, str(error)) + + retval = retval.rstrip('\r\n') + retval = retval.lstrip(" ") + return retval + + +class checktype(): + def __init__(self, test1): + self.test1 = test1 + + @staticmethod + def check(name,location, bit, value, tips , err1): + psu_status = int(get_pmc_register(location),16) + val = (psu_status & (1<< bit)) >> bit + if (val != value): + err1["errmsg"] = tips + err1["code"] = -1 + return -1 + else: + err1["errmsg"] = "none" + err1["code"] = 0 + return 0 + + @staticmethod + def getValue(location, bit , type, coefficient = 1, addend = 0): + try: + value_t = get_pmc_register(location) + if value_t.startswith("ERR") : + return value_t + if (type == 1): + return float('%.1f' % ((float(value_t)/1000) + addend)) + elif (type == 2): + return float('%.1f' % (float(value_t)/100)) + elif (type == 3): + psu_status = int(value_t,16) + return (psu_status & (1<< bit)) >> bit + elif (type == 4): + return int(value_t,10) + elif (type == 5): + return float('%.1f' % (float(value_t)/1000/1000)) + elif (type == 6): + return Decimal(float(value_t)*coefficient/1000).quantize(Decimal('0.000')) + else: + return value_t + except Exception as e: + value_t = "ERR %s" % str(e) + return value_t + + #######temp + @staticmethod + def getTemp(self, name, location , ret_t): + ret2 = self.getValue(location + "temp1_input" ," " ,1); + ret3 = self.getValue(location + "temp1_max" ," ", 1); + ret4 = self.getValue(location + "temp1_max_hyst" ," ", 1); + ret_t["temp1_input"] = ret2 + ret_t["temp1_max"] = ret3 + ret_t["temp1_max_hyst"] = ret4 + + @staticmethod + def getLM75(name, location, result): + c1=checktype + r1={} + c1.getTemp(c1, name, location, r1) + result[name] = r1 + + ##########fanFRU + @staticmethod + def decodeBinByValue(retval): + fru = ipmifru() + fru.decodeBin(retval) + return fru + + @staticmethod + def printbinvalue(b): + index = 0 + print(" ",) + for width in range(16): + print("%02x " % width,) + print("") + for i in range(0, len(b)): + if index % 16 == 0: + print(" ") + print(" %02x " % i,) + print("%02x " % ord(b[i]),) + index += 1 + print("") + + @staticmethod + def getfruValue(prob_t, root, val): + try: + ret, binval_bytes = dev_file_read(val, 0, 256) + if ret == False: + return binval_bytes + binval = byteTostr(binval_bytes) + fanpro = {} + ret = checktype.decodeBinByValue(binval) + fanpro['fan_type'] = ret.productInfoArea.productName + fanpro['hw_version'] = ret.productInfoArea.productVersion + fanpro['sn'] = ret.productInfoArea.productSerialNumber + fanpro['fanid'] = ret.productInfoArea.productextra2 + fan_display_name_dict = status.getDecodValue(root, "fan_display_name") + fan_name = fanpro['fan_type'].strip() + if len(fan_display_name_dict) == 0: + return fanpro + if fan_name not in fan_display_name_dict.keys(): + prob_t['errcode']= -1 + prob_t['errmsg'] = '%s'% ("ERR fan name: %s not support" % fan_name) + else: + fanpro['fan_type'] = fan_display_name_dict[fan_name] + return fanpro + except Exception as error: + return "ERR " + str(error) + + @staticmethod + def getslotfruValue(val): + try: + binval = checktype.getValue(val, 0 , 0) + if binval.startswith("ERR"): + return binval + slotpro = {} + ret = checktype.decodeBinByValue(binval) + slotpro['slot_type'] = ret.boardInfoArea.boardProductName + slotpro['hw_version'] = ret.boardInfoArea.boardextra1 + slotpro['sn'] = ret.boardInfoArea.boardSerialNumber + return slotpro + except Exception as error: + return "ERR " + str(error) + + @staticmethod + def getpsufruValue(prob_t, root, val): + try: + psu_match = False + binval = checktype.getValue(val, 0 , 0) + if binval.startswith("ERR"): + return binval + psupro = {} + ret = checktype.decodeBinByValue(binval) + psupro['type1'] = ret.productInfoArea.productPartModelName + psupro['sn'] = ret.productInfoArea.productSerialNumber + psupro['hw_version'] = ret.productInfoArea.productVersion + psu_dict = status.getDecodValue(root, "psutype") + psupro['type1'] = psupro['type1'].strip() + if len(psu_dict) == 0: + return psupro + for psu_name in psu_dict.keys(): + if psu_name in psupro['type1']: + psupro['type1'] = psu_dict[psu_name] + psu_match = True + break + if psu_match is not True: + prob_t['errcode']= -1 + prob_t['errmsg'] = '%s'% ("ERR psu name: %s not support" % psupro['type1']) + return psupro + except Exception as error: + return "ERR " + str(error) + +class status(): + def __init__(self, productname): + self.productname = productname + + @staticmethod + def getETroot(filename): + tree = ET.parse(filename) + root = tree.getroot() + return root; + + @staticmethod + def getDecodValue(collection, decode): + decodes = collection.find('decode') + testdecode = decodes.find(decode) + test={} + if testdecode is None: + return test + for neighbor in testdecode.iter('code'): + test[neighbor.attrib["key"]]=neighbor.attrib["value"] + return test + + @staticmethod + def getfileValue(location): + return checktype.getValue(location," "," ") + + @staticmethod + def getETValue(a, filename, tagname): + root = status.getETroot(filename) + for neighbor in root.iter(tagname): + prob_t = {} + prob_t = neighbor.attrib + prob_t['errcode']= 0 + prob_t['errmsg'] = '' + for pros in neighbor.iter("property"): + ret = dict(list(neighbor.attrib.items()) + list(pros.attrib.items())) + if ret.get('e2type') == 'fru' and ret.get("name") == "fru": + fruval = checktype.getfruValue(prob_t, root, ret["location"]) + if isinstance(fruval, str) and fruval.startswith("ERR"): + prob_t['errcode']= -1 + prob_t['errmsg']= fruval + break + else: + prob_t.update(fruval) + continue + + if ret.get("name") == "psu" and ret.get('e2type') == 'fru': + psuval = checktype.getpsufruValue(prob_t, root, ret["location"]) + if isinstance(psuval, str) and psuval.startswith("ERR"): + prob_t['errcode']= -1 + prob_t['errmsg']= psuval + break + else: + prob_t.update(psuval) + continue + + if ret.get("gettype") == "config": + prob_t[ret["name"]] = ret["value"] + continue + + if ('type' not in ret.keys()): + val = "0"; + else: + val = ret["type"] + if ('bit' not in ret.keys()): + bit = "0"; + else: + bit = ret["bit"] + if ('coefficient' not in ret.keys()): + coefficient = 1; + else: + coefficient = float(ret["coefficient"]) + if ('addend' not in ret.keys()): + addend = 0; + else: + addend = float(ret["addend"]) + + s = checktype.getValue(ret["location"], int(bit),int(val), coefficient, addend) + if isinstance(s, str) and s.startswith("ERR"): + prob_t['errcode']= -1 + prob_t['errmsg']= s + break + if ('default' in ret.keys()): + rt = status.getDecodValue(root,ret['decode']) + prob_t['errmsg']= rt[str(s)] + if str(s) != ret["default"]: + prob_t['errcode']= -1 + break + else: + if ('decode' in ret.keys()): + rt = status.getDecodValue(root,ret['decode']) + if(ret['decode'] == "psutype" and s.replace("\x00","").rstrip() not in rt.keys()): + prob_t['errcode']= -1 + prob_t['errmsg'] = '%s' % ("ERR psu name: %s not support" % (s.replace("\x00","").rstrip())) + else: + s = rt[str(s).replace("\x00","").rstrip()] + name = ret["name"] + prob_t[name]=str(s) + a.append(prob_t) + + @staticmethod + def getCPUValue(a, filename, tagname): + root = status.getETroot(filename) + for neighbor in root.iter(tagname): + location = neighbor.attrib["location"] + L=[] + for dirpath, dirnames, filenames in os.walk(location): + for file in filenames : + if file.endswith("input"): + L.append(os.path.join(dirpath, file)) + L =sorted(L,reverse=False) + for i in range(len(L)): + prob_t = {} + prob_t["name"] = getPMCreg("%s/temp%d_label"%(location,i+1)) + prob_t["temp"] = float(getPMCreg("%s/temp%d_input"%(location,i+1)))/1000 + prob_t["alarm"] = float(getPMCreg("%s/temp%d_crit_alarm"%(location,i+1)))/1000 + prob_t["crit"] = float(getPMCreg("%s/temp%d_crit"%(location,i+1)))/1000 + prob_t["max"] = float(getPMCreg("%s/temp%d_max"%(location,i+1)))/1000 + a.append(prob_t) + + @staticmethod + def getFileName(): + fpath = os.path.dirname(os.path.realpath(__file__)) + board_id = get_board_id() + dev_id_xml = fpath + "/" + "dev_%s.xml" % board_id + if os.path.exists(dev_id_xml): + return dev_id_xml + return fpath + "/"+ CONFIG_NAME + + @staticmethod + def getFan(ret): + _filename = status.getFileName() + _tagname = "fan" + status.getvalue(ret, _filename, _tagname) + + + @staticmethod + def checkFan(ret): + _filename = status.getFileName() + # _filename = "/usr/local/bin/" + status.getFileName() + _tagname = "fan" + status.getETValue(ret, _filename, _tagname) + + @staticmethod + def getTemp(ret): + _filename = status.getFileName() + #_filename = "/usr/local/bin/" + status.getFileName() + _tagname = "temp" + status.getETValue(ret, _filename, _tagname) + + @staticmethod + def getPsu(ret): + _filename = status.getFileName() + # _filename = "/usr/local/bin/" + status.getFileName() + _tagname = "psu" + status.getETValue(ret, _filename, _tagname) + + @staticmethod + def getcputemp(ret): + _filename = status.getFileName() + _tagname = "cpus" + status.getCPUValue(ret, _filename, _tagname) + + @staticmethod + def getDcdc(ret): + _filename = status.getFileName() + _tagname = "dcdc" + status.getETValue(ret, _filename, _tagname) + + @staticmethod + def getmactemp(ret): + _filename = status.getFileName() + _tagname = "mactemp" + status.getETValue(ret, _filename, _tagname) + + @staticmethod + def getmacpower(ret): + _filename = status.getFileName() + _tagname = "macpower" + status.getETValue(ret, _filename, _tagname) diff --git a/device/tencent/x86_64-tencent_tcs8400-r0/platform_asic b/device/tencent/x86_64-tencent_tcs8400-r0/platform_asic new file mode 100755 index 000000000000..960467652765 --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs8400-r0/platform_asic @@ -0,0 +1 @@ +broadcom diff --git a/device/tencent/x86_64-tencent_tcs8400-r0/platform_env.conf b/device/tencent/x86_64-tencent_tcs8400-r0/platform_env.conf new file mode 100644 index 000000000000..74e9293b382e --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs8400-r0/platform_env.conf @@ -0,0 +1,2 @@ +SYNCD_SHM_SIZE=1g +is_ltsw_chip=1 \ No newline at end of file diff --git a/device/tencent/x86_64-tencent_tcs8400-r0/prbs.cint b/device/tencent/x86_64-tencent_tcs8400-r0/prbs.cint new file mode 100755 index 000000000000..dbc0d93094f6 --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs8400-r0/prbs.cint @@ -0,0 +1,17 @@ +void set_port_prbs(int unit_port, int enable){ + int status; + bcm_port_control_set(0, unit_port, bcmPortControlPrbsPolynomial, 6); + bcm_port_control_set(0, unit_port, bcmPortControlPrbsRxEnable, 0); + bcm_port_control_set(0, unit_port, bcmPortControlPrbsTxEnable, 0); + if(enable == 1){ + bcm_port_control_set(0, unit_port, bcmPortControlPrbsRxEnable, 1); + bcm_port_control_set(0, unit_port, bcmPortControlPrbsTxEnable, 1); + bcm_port_control_get(0, unit_port, bcmPortControlPrbsRxStatus, &status); + } +} + +int get_port_prbs_result(int unit_port){ + int status; + bcm_port_control_get(0, unit_port, bcmPortControlPrbsRxStatus, &status); + return status; +} \ No newline at end of file diff --git a/device/tencent/x86_64-tencent_tcs9400-r0/TCS9400-128CC/TCS9400-128CC.yml b/device/tencent/x86_64-tencent_tcs9400-r0/TCS9400-128CC/TCS9400-128CC.yml new file mode 100755 index 000000000000..4f5d6c2c2188 --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs9400-r0/TCS9400-128CC/TCS9400-128CC.yml @@ -0,0 +1,1783 @@ +# +# BCM56990 128x200g port configuration. +# +# configuration yaml file +# device: +# : +#
: +# ? +# : +# : +# ... +# : +# : +# : +# : +# ... +# : +# +# $Copyright: (c) 2019 Broadcom. +# Broadcom Proprietary and Confidential. All rights reserved.$ +# + +--- +device: + 0: + PORT_CONFIG: + PORT_SYSTEM_PROFILE_OPERMODE_PIPEUNIQUE: 1 + PC_PM_CORE: + ? + PC_PM_ID: 1 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x51043627 + TX_POLARITY_FLIP: 0xB6 + RX_LANE_MAP: 0x51406273 + RX_POLARITY_FLIP: 0x9A + + ? + PC_PM_ID: 2 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x62370514 + TX_POLARITY_FLIP: 0x49 + RX_LANE_MAP: 0x15042637 + RX_POLARITY_FLIP: 0x9A + + ? + PC_PM_ID: 3 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x37260451 + TX_POLARITY_FLIP: 0xE9 + RX_LANE_MAP: 0x73624501 + RX_POLARITY_FLIP: 0xAF + + ? + PC_PM_ID: 4 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x40517326 + TX_POLARITY_FLIP: 0x16 + RX_LANE_MAP: 0x04153276 + RX_POLARITY_FLIP: 0x50 + + ? + PC_PM_ID: 5 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x05724361 + TX_POLARITY_FLIP: 0x23 + RX_LANE_MAP: 0x27143605 + RX_POLARITY_FLIP: 0xED + + ? + PC_PM_ID: 6 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x43602517 + TX_POLARITY_FLIP: 0x62 + RX_LANE_MAP: 0x05361247 + RX_POLARITY_FLIP: 0x36 + + ? + PC_PM_ID: 7 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x25714063 + TX_POLARITY_FLIP: 0xEA + RX_LANE_MAP: 0x27143605 + RX_POLARITY_FLIP: 0x74 + + ? + PC_PM_ID: 8 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x43607125 + TX_POLARITY_FLIP: 0xE9 + RX_LANE_MAP: 0x05361247 + RX_POLARITY_FLIP: 0x74 + + ? + PC_PM_ID: 9 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x42605371 + TX_POLARITY_FLIP: 0xBB + RX_LANE_MAP: 0x34561027 + RX_POLARITY_FLIP: 0x8E + + ? + PC_PM_ID: 10 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x52713064 + TX_POLARITY_FLIP: 0xA9 + RX_LANE_MAP: 0x36054712 + RX_POLARITY_FLIP: 0x22 + + ? + PC_PM_ID: 11 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x21753064 + TX_POLARITY_FLIP: 0x6C + RX_LANE_MAP: 0x27413605 + RX_POLARITY_FLIP: 0xBB + + ? + PC_PM_ID: 12 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x52714360 + TX_POLARITY_FLIP: 0xBB + RX_LANE_MAP: 0x27153604 + RX_POLARITY_FLIP: 0xAA + + ? + PC_PM_ID: 13 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x71526430 + TX_POLARITY_FLIP: 0x53 + RX_LANE_MAP: 0x15273046 + RX_POLARITY_FLIP: 0x7B + + ? + PC_PM_ID: 14 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x70156423 + TX_POLARITY_FLIP: 0x17 + RX_LANE_MAP: 0x12573046 + RX_POLARITY_FLIP: 0x41 + ? + PC_PM_ID: 15 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x64307521 + TX_POLARITY_FLIP: 0x22 + RX_LANE_MAP: 0x30462517 + RX_POLARITY_FLIP: 0x65 + + ? + PC_PM_ID: 16 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x71436520 + TX_POLARITY_FLIP: 0x53 + RX_LANE_MAP: 0x05362417 + RX_POLARITY_FLIP: 0x77 + + ? + PC_PM_ID: 17 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x16340725 + TX_POLARITY_FLIP: 0x22 + RX_LANE_MAP: 0x50734162 + RX_POLARITY_FLIP: 0xBB + + ? + PC_PM_ID: 18 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x16347520 + TX_POLARITY_FLIP: 0xA3 + RX_LANE_MAP: 0x30574162 + RX_POLARITY_FLIP: 0x6A + + ? + PC_PM_ID: 19 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x16340725 + TX_POLARITY_FLIP: 0xBB + RX_LANE_MAP: 0x50634172 + RX_POLARITY_FLIP: 0x22 + + ? + PC_PM_ID: 20 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x64317520 + TX_POLARITY_FLIP: 0x22 + RX_LANE_MAP: 0x53264071 + RX_POLARITY_FLIP: 0xAA + + ? + PC_PM_ID: 21 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x34162507 + TX_POLARITY_FLIP: 0x55 + RX_LANE_MAP: 0x72416350 + RX_POLARITY_FLIP: 0x55 + + ? + PC_PM_ID: 22 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x61437520 + TX_POLARITY_FLIP: 0x7F + RX_LANE_MAP: 0x12473056 + RX_POLARITY_FLIP: 0x11 + + ? + PC_PM_ID: 23 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x25071436 + TX_POLARITY_FLIP: 0x7D + RX_LANE_MAP: 0x72416350 + RX_POLARITY_FLIP: 0x11 + + ? + PC_PM_ID: 24 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x64712035 + TX_POLARITY_FLIP: 0x1B + RX_LANE_MAP: 0x47215630 + RX_POLARITY_FLIP: 0x33 + + ? + PC_PM_ID: 25 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x70251436 + TX_POLARITY_FLIP: 0xFE + RX_LANE_MAP: 0x41725063 + RX_POLARITY_FLIP: 0x74 + + ? + PC_PM_ID: 26 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x16347052 + TX_POLARITY_FLIP: 0xF4 + RX_LANE_MAP: 0x63507421 + RX_POLARITY_FLIP: 0x74 + + ? + PC_PM_ID: 27 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x70251436 + TX_POLARITY_FLIP: 0xEA + RX_LANE_MAP: 0x41725063 + RX_POLARITY_FLIP: 0xFC + + ? + PC_PM_ID: 28 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x26041573 + TX_POLARITY_FLIP: 0xC1 + RX_LANE_MAP: 0x63507412 + RX_POLARITY_FLIP: 0x12 + + ? + PC_PM_ID: 29 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x15047362 + TX_POLARITY_FLIP: 0x19 + RX_LANE_MAP: 0x40516723 + RX_POLARITY_FLIP: 0x50 + + ? + PC_PM_ID: 30 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x62735104 + TX_POLARITY_FLIP: 0xE9 + RX_LANE_MAP: 0x37261054 + RX_POLARITY_FLIP: 0xAF + + ? + PC_PM_ID: 31 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x37625041 + TX_POLARITY_FLIP: 0x49 + RX_LANE_MAP: 0x40516273 + RX_POLARITY_FLIP: 0x9A + + ? + PC_PM_ID: 32 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x04516372 + TX_POLARITY_FLIP: 0xB6 + RX_LANE_MAP: 0x04152637 + RX_POLARITY_FLIP: 0x9A + ? + PC_PM_ID: 33 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x40157362 + TX_POLARITY_FLIP: 0xBE + RX_LANE_MAP: 0x51407362 + RX_POLARITY_FLIP: 0x9A + + ? + PC_PM_ID: 34 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x73264051 + TX_POLARITY_FLIP: 0x41 + RX_LANE_MAP: 0x15043726 + RX_POLARITY_FLIP: 0x9A + + ? + PC_PM_ID: 35 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x26374051 + TX_POLARITY_FLIP: 0xE6 + RX_LANE_MAP: 0x62734501 + RX_POLARITY_FLIP: 0xAF + + ? + PC_PM_ID: 36 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x51406237 + TX_POLARITY_FLIP: 0x16 + RX_LANE_MAP: 0x15043276 + RX_POLARITY_FLIP: 0x50 + + ? + PC_PM_ID: 37 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x40621537 + TX_POLARITY_FLIP: 0xAE + RX_LANE_MAP: 0x05362147 + RX_POLARITY_FLIP: 0x74 + + ? + PC_PM_ID: 38 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x25701634 + TX_POLARITY_FLIP: 0xE7 + RX_LANE_MAP: 0x27143605 + RX_POLARITY_FLIP: 0xFC + + ? + PC_PM_ID: 39 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x43617025 + TX_POLARITY_FLIP: 0x68 + RX_LANE_MAP: 0x05361247 + RX_POLARITY_FLIP: 0x12 + + ? + PC_PM_ID: 40 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x25701634 + TX_POLARITY_FLIP: 0xA6 + RX_LANE_MAP: 0x27143605 + RX_POLARITY_FLIP: 0xED + + ? + PC_PM_ID: 41 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x64310725 + TX_POLARITY_FLIP: 0x3A + RX_LANE_MAP: 0x30562147 + RX_POLARITY_FLIP: 0x33 + + ? + PC_PM_ID: 42 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x20576413 + TX_POLARITY_FLIP: 0xD2 + RX_LANE_MAP: 0x50634172 + RX_POLARITY_FLIP: 0xBF + + ? + PC_PM_ID: 43 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x16340725 + TX_POLARITY_FLIP: 0xBB + RX_LANE_MAP: 0x12473056 + RX_POLARITY_FLIP: 0x11 + + ? + PC_PM_ID: 44 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x64317520 + TX_POLARITY_FLIP: 0x93 + RX_LANE_MAP: 0x41725063 + RX_POLARITY_FLIP: 0xAA + + ? + PC_PM_ID: 45 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x31642075 + TX_POLARITY_FLIP: 0x77 + RX_LANE_MAP: 0x26534710 + RX_POLARITY_FLIP: 0x53 + + ? + PC_PM_ID: 46 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x34162507 + TX_POLARITY_FLIP: 0x11 + RX_LANE_MAP: 0x63504721 + RX_POLARITY_FLIP: 0x7B + + ? + PC_PM_ID: 47 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x34162075 + TX_POLARITY_FLIP: 0x53 + RX_LANE_MAP: 0x57304621 + RX_POLARITY_FLIP: 0x63 + + ? + PC_PM_ID: 48 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x34162507 + TX_POLARITY_FLIP: 0x77 + RX_LANE_MAP: 0x74503621 + RX_POLARITY_FLIP: 0x11 + + ? + PC_PM_ID: 49 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x43715260 + TX_POLARITY_FLIP: 0xAA + RX_LANE_MAP: 0x36051724 + RX_POLARITY_FLIP: 0x22 + + ? + PC_PM_ID: 50 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x30642175 + TX_POLARITY_FLIP: 0x77 + RX_LANE_MAP: 0x46305712 + RX_POLARITY_FLIP: 0x63 + + ? + PC_PM_ID: 51 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x23641570 + TX_POLARITY_FLIP: 0x2B + RX_LANE_MAP: 0x46305712 + RX_POLARITY_FLIP: 0xEB + + ? + PC_PM_ID: 52 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x43602175 + TX_POLARITY_FLIP: 0xA3 + RX_LANE_MAP: 0x46302715 + RX_POLARITY_FLIP: 0x12 + + ? + PC_PM_ID: 53 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x60437152 + TX_POLARITY_FLIP: 0x11 + RX_LANE_MAP: 0x05362147 + RX_POLARITY_FLIP: 0x53 + + ? + PC_PM_ID: 54 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x64307521 + TX_POLARITY_FLIP: 0x6C + RX_LANE_MAP: 0x12473056 + RX_POLARITY_FLIP: 0x11 + + ? + PC_PM_ID: 55 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x64307521 + TX_POLARITY_FLIP: 0x39 + RX_LANE_MAP: 0x05364127 + RX_POLARITY_FLIP: 0x7B + + ? + PC_PM_ID: 56 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x60437152 + TX_POLARITY_FLIP: 0x11 + RX_LANE_MAP: 0x37042651 + RX_POLARITY_FLIP: 0x56 + + ? + PC_PM_ID: 57 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x06347152 + TX_POLARITY_FLIP: 0xE6 + RX_LANE_MAP: 0x63507421 + RX_POLARITY_FLIP: 0x12 + + ? + PC_PM_ID: 58 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x71254360 + TX_POLARITY_FLIP: 0xE7 + RX_LANE_MAP: 0x41725063 + RX_POLARITY_FLIP: 0xED + + ? + PC_PM_ID: 59 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x06342571 + TX_POLARITY_FLIP: 0xFD + RX_LANE_MAP: 0x63507421 + RX_POLARITY_FLIP: 0x36 + + ? + PC_PM_ID: 60 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x72054163 + TX_POLARITY_FLIP: 0xDB + RX_LANE_MAP: 0x41725063 + RX_POLARITY_FLIP: 0x74 + + ? + PC_PM_ID: 61 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x41507362 + TX_POLARITY_FLIP: 0x99 + RX_LANE_MAP: 0x15047632 + RX_POLARITY_FLIP: 0x50 + + ? + PC_PM_ID: 62 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x36275104 + TX_POLARITY_FLIP: 0x69 + RX_LANE_MAP: 0x62730145 + RX_POLARITY_FLIP: 0xAF + + ? + PC_PM_ID: 63 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x37260415 + TX_POLARITY_FLIP: 0x55 + RX_LANE_MAP: 0x51402367 + RX_POLARITY_FLIP: 0x93 + + ? + PC_PM_ID: 64 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x04513726 + TX_POLARITY_FLIP: 0xBE + RX_LANE_MAP: 0x15046723 + RX_POLARITY_FLIP: 0x93 + + ? + PC_PM_ID: 65 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x3012 + TX_POLARITY_FLIP: 0 + RX_LANE_MAP: 0x3012 + RX_POLARITY_FLIP: 0 +... + +--- +device: + 0: + PC_PORT_PHYS_MAP: + ? + PORT_ID: 0 + : + PC_PHYS_PORT_ID: 0 + ? + PORT_ID: 33 + : + PC_PHYS_PORT_ID: 259 + ? + PORT_ID: 67 + : + PC_PHYS_PORT_ID: 260 + ? + PORT_ID: 101 + : + PC_PHYS_PORT_ID: 261 + ? + PORT_ID: 135 + : + PC_PHYS_PORT_ID: 262 + ? + PORT_ID: 169 + : + PC_PHYS_PORT_ID: 263 + ? + PORT_ID: 203 + : + PC_PHYS_PORT_ID: 264 + ? + PORT_ID: 237 + : + PC_PHYS_PORT_ID: 265 + ? + PORT_ID: 271 + : + PC_PHYS_PORT_ID: 266 + ? + PORT_ID: 1 + : + PC_PHYS_PORT_ID: 1 + ? + PORT_ID: 3 + : + PC_PHYS_PORT_ID: 3 + ? + PORT_ID: 5 + : + PC_PHYS_PORT_ID: 5 + ? + PORT_ID: 7 + : + PC_PHYS_PORT_ID: 7 + ? + PORT_ID: 9 + : + PC_PHYS_PORT_ID: 9 + ? + PORT_ID: 11 + : + PC_PHYS_PORT_ID: 11 + ? + PORT_ID: 13 + : + PC_PHYS_PORT_ID: 13 + ? + PORT_ID: 15 + : + PC_PHYS_PORT_ID: 15 + ? + PORT_ID: 17 + : + PC_PHYS_PORT_ID: 17 + ? + PORT_ID: 19 + : + PC_PHYS_PORT_ID: 19 + ? + PORT_ID: 21 + : + PC_PHYS_PORT_ID: 21 + ? + PORT_ID: 23 + : + PC_PHYS_PORT_ID: 23 + ? + PORT_ID: 25 + : + PC_PHYS_PORT_ID: 25 + ? + PORT_ID: 27 + : + PC_PHYS_PORT_ID: 27 + ? + PORT_ID: 29 + : + PC_PHYS_PORT_ID: 29 + ? + PORT_ID: 31 + : + PC_PHYS_PORT_ID: 31 + ? + PORT_ID: 34 + : + PC_PHYS_PORT_ID: 33 + ? + PORT_ID: 36 + : + PC_PHYS_PORT_ID: 35 + ? + PORT_ID: 38 + : + PC_PHYS_PORT_ID: 37 + ? + PORT_ID: 40 + : + PC_PHYS_PORT_ID: 39 + ? + PORT_ID: 42 + : + PC_PHYS_PORT_ID: 41 + ? + PORT_ID: 44 + : + PC_PHYS_PORT_ID: 43 + ? + PORT_ID: 46 + : + PC_PHYS_PORT_ID: 45 + ? + PORT_ID: 48 + : + PC_PHYS_PORT_ID: 47 + ? + PORT_ID: 51 + : + PC_PHYS_PORT_ID: 49 + ? + PORT_ID: 53 + : + PC_PHYS_PORT_ID: 51 + ? + PORT_ID: 55 + : + PC_PHYS_PORT_ID: 53 + ? + PORT_ID: 57 + : + PC_PHYS_PORT_ID: 55 + ? + PORT_ID: 59 + : + PC_PHYS_PORT_ID: 57 + ? + PORT_ID: 61 + : + PC_PHYS_PORT_ID: 59 + ? + PORT_ID: 63 + : + PC_PHYS_PORT_ID: 61 + ? + PORT_ID: 65 + : + PC_PHYS_PORT_ID: 63 + ? + PORT_ID: 68 + : + PC_PHYS_PORT_ID: 65 + ? + PORT_ID: 70 + : + PC_PHYS_PORT_ID: 67 + ? + PORT_ID: 72 + : + PC_PHYS_PORT_ID: 69 + ? + PORT_ID: 74 + : + PC_PHYS_PORT_ID: 71 + ? + PORT_ID: 76 + : + PC_PHYS_PORT_ID: 73 + ? + PORT_ID: 78 + : + PC_PHYS_PORT_ID: 75 + ? + PORT_ID: 80 + : + PC_PHYS_PORT_ID: 77 + ? + PORT_ID: 82 + : + PC_PHYS_PORT_ID: 79 + ? + PORT_ID: 85 + : + PC_PHYS_PORT_ID: 81 + ? + PORT_ID: 87 + : + PC_PHYS_PORT_ID: 83 + ? + PORT_ID: 89 + : + PC_PHYS_PORT_ID: 85 + ? + PORT_ID: 91 + : + PC_PHYS_PORT_ID: 87 + ? + PORT_ID: 93 + : + PC_PHYS_PORT_ID: 89 + ? + PORT_ID: 95 + : + PC_PHYS_PORT_ID: 91 + ? + PORT_ID: 97 + : + PC_PHYS_PORT_ID: 93 + ? + PORT_ID: 99 + : + PC_PHYS_PORT_ID: 95 + ? + PORT_ID: 102 + : + PC_PHYS_PORT_ID: 97 + ? + PORT_ID: 104 + : + PC_PHYS_PORT_ID: 99 + ? + PORT_ID: 106 + : + PC_PHYS_PORT_ID: 101 + ? + PORT_ID: 108 + : + PC_PHYS_PORT_ID: 103 + ? + PORT_ID: 110 + : + PC_PHYS_PORT_ID: 105 + ? + PORT_ID: 112 + : + PC_PHYS_PORT_ID: 107 + ? + PORT_ID: 114 + : + PC_PHYS_PORT_ID: 109 + ? + PORT_ID: 116 + : + PC_PHYS_PORT_ID: 111 + ? + PORT_ID: 119 + : + PC_PHYS_PORT_ID: 113 + ? + PORT_ID: 121 + : + PC_PHYS_PORT_ID: 115 + ? + PORT_ID: 123 + : + PC_PHYS_PORT_ID: 117 + ? + PORT_ID: 125 + : + PC_PHYS_PORT_ID: 119 + ? + PORT_ID: 127 + : + PC_PHYS_PORT_ID: 121 + ? + PORT_ID: 129 + : + PC_PHYS_PORT_ID: 123 + ? + PORT_ID: 131 + : + PC_PHYS_PORT_ID: 125 + ? + PORT_ID: 133 + : + PC_PHYS_PORT_ID: 127 + ? + PORT_ID: 136 + : + PC_PHYS_PORT_ID: 129 + ? + PORT_ID: 138 + : + PC_PHYS_PORT_ID: 131 + ? + PORT_ID: 140 + : + PC_PHYS_PORT_ID: 133 + ? + PORT_ID: 142 + : + PC_PHYS_PORT_ID: 135 + ? + PORT_ID: 144 + : + PC_PHYS_PORT_ID: 137 + ? + PORT_ID: 146 + : + PC_PHYS_PORT_ID: 139 + ? + PORT_ID: 148 + : + PC_PHYS_PORT_ID: 141 + ? + PORT_ID: 150 + : + PC_PHYS_PORT_ID: 143 + ? + PORT_ID: 153 + : + PC_PHYS_PORT_ID: 145 + ? + PORT_ID: 155 + : + PC_PHYS_PORT_ID: 147 + ? + PORT_ID: 157 + : + PC_PHYS_PORT_ID: 149 + ? + PORT_ID: 159 + : + PC_PHYS_PORT_ID: 151 + ? + PORT_ID: 161 + : + PC_PHYS_PORT_ID: 153 + ? + PORT_ID: 163 + : + PC_PHYS_PORT_ID: 155 + ? + PORT_ID: 165 + : + PC_PHYS_PORT_ID: 157 + ? + PORT_ID: 167 + : + PC_PHYS_PORT_ID: 159 + ? + PORT_ID: 170 + : + PC_PHYS_PORT_ID: 161 + ? + PORT_ID: 172 + : + PC_PHYS_PORT_ID: 163 + ? + PORT_ID: 174 + : + PC_PHYS_PORT_ID: 165 + ? + PORT_ID: 176 + : + PC_PHYS_PORT_ID: 167 + ? + PORT_ID: 178 + : + PC_PHYS_PORT_ID: 169 + ? + PORT_ID: 180 + : + PC_PHYS_PORT_ID: 171 + ? + PORT_ID: 182 + : + PC_PHYS_PORT_ID: 173 + ? + PORT_ID: 184 + : + PC_PHYS_PORT_ID: 175 + ? + PORT_ID: 187 + : + PC_PHYS_PORT_ID: 177 + ? + PORT_ID: 189 + : + PC_PHYS_PORT_ID: 179 + ? + PORT_ID: 191 + : + PC_PHYS_PORT_ID: 181 + ? + PORT_ID: 193 + : + PC_PHYS_PORT_ID: 183 + ? + PORT_ID: 195 + : + PC_PHYS_PORT_ID: 185 + ? + PORT_ID: 197 + : + PC_PHYS_PORT_ID: 187 + ? + PORT_ID: 199 + : + PC_PHYS_PORT_ID: 189 + ? + PORT_ID: 201 + : + PC_PHYS_PORT_ID: 191 + ? + PORT_ID: 204 + : + PC_PHYS_PORT_ID: 193 + ? + PORT_ID: 206 + : + PC_PHYS_PORT_ID: 195 + ? + PORT_ID: 208 + : + PC_PHYS_PORT_ID: 197 + ? + PORT_ID: 210 + : + PC_PHYS_PORT_ID: 199 + ? + PORT_ID: 212 + : + PC_PHYS_PORT_ID: 201 + ? + PORT_ID: 214 + : + PC_PHYS_PORT_ID: 203 + ? + PORT_ID: 216 + : + PC_PHYS_PORT_ID: 205 + ? + PORT_ID: 218 + : + PC_PHYS_PORT_ID: 207 + ? + PORT_ID: 221 + : + PC_PHYS_PORT_ID: 209 + ? + PORT_ID: 223 + : + PC_PHYS_PORT_ID: 211 + ? + PORT_ID: 225 + : + PC_PHYS_PORT_ID: 213 + ? + PORT_ID: 227 + : + PC_PHYS_PORT_ID: 215 + ? + PORT_ID: 229 + : + PC_PHYS_PORT_ID: 217 + ? + PORT_ID: 231 + : + PC_PHYS_PORT_ID: 219 + ? + PORT_ID: 233 + : + PC_PHYS_PORT_ID: 221 + ? + PORT_ID: 235 + : + PC_PHYS_PORT_ID: 223 + ? + PORT_ID: 238 + : + PC_PHYS_PORT_ID: 225 + ? + PORT_ID: 240 + : + PC_PHYS_PORT_ID: 227 + ? + PORT_ID: 242 + : + PC_PHYS_PORT_ID: 229 + ? + PORT_ID: 244 + : + PC_PHYS_PORT_ID: 231 + ? + PORT_ID: 246 + : + PC_PHYS_PORT_ID: 233 + ? + PORT_ID: 248 + : + PC_PHYS_PORT_ID: 235 + ? + PORT_ID: 250 + : + PC_PHYS_PORT_ID: 237 + ? + PORT_ID: 252 + : + PC_PHYS_PORT_ID: 239 + ? + PORT_ID: 255 + : + PC_PHYS_PORT_ID: 241 + ? + PORT_ID: 257 + : + PC_PHYS_PORT_ID: 243 + ? + PORT_ID: 259 + : + PC_PHYS_PORT_ID: 245 + ? + PORT_ID: 261 + : + PC_PHYS_PORT_ID: 247 + ? + PORT_ID: 263 + : + PC_PHYS_PORT_ID: 249 + ? + PORT_ID: 265 + : + PC_PHYS_PORT_ID: 251 + ? + PORT_ID: 267 + : + PC_PHYS_PORT_ID: 253 + ? + PORT_ID: 269 + : + PC_PHYS_PORT_ID: 255 +... + +--- +device: + 0: + PC_PORT: + ? + PORT_ID: [0] + : + ENABLE: 0 + SPEED: 10000 + NUM_LANES: 1 + ? + PORT_ID: [1, 3, 5, 7, 9, 11, 13, 15, + 17, 19, 21, 23, 25, 27, 29, 31, + 34, 36, 38, 40, 42, 44, 46, 48, + 51, 53, 55, 57, 59, 61, 63, 65, + 68, 70, 72, 74, 76, 78, 80, 82, + 85, 87, 89, 91, 93, 95, 97, 99, + 102, 104, 106, 108, 110, 112, 114, 116, + 119, 121, 123, 125, 127, 129, 131, 133, + 136, 138, 140, 142, 144, 146, 148, 150, + 153, 155, 157, 159, 161, 163, 165, 167, + 170, 172, 174, 176, 178, 180, 182, 184, + 187, 189, 191, 193, 195, 197, 199, 201, + 204, 206, 208, 210, 212, 214, 216, 218, + 221, 223, 225, 227, 229, 231, 233, 235, + 238, 240, 242, 244, 246, 248, 250, 252, + 255, 257, 259, 261, 263, 265, 267, 269] + : + ENABLE: 0 + SPEED: 200000 + NUM_LANES: 4 + FEC_MODE: PC_FEC_RS544_2XN + MAX_FRAME_SIZE: 9416 + LINK_TRAINING: 0 +... + +--- +device: + 0: + TM_SCHEDULER_CONFIG: + NUM_MC_Q: NUM_MC_Q_4 +... + +--- +device: + 0: + PC_PMD_FIRMWARE: + ? + PORT_ID: [1, 3, 5, 7, 9, 11, 13, 15, + 17, 19, 21, 23, 25, 27, 29, 31, + 34, 36, 38, 40, 42, 44, 46, 48, + 51, 53, 55, 57, 59, 61, 63, 65, + 68, 70, 72, 74, 76, 78, 80, 82, + 85, 87, 89, 91, 93, 95, 97, 99, + 102, 104, 106, 108, 110, 112, 114, 116, + 119, 121, 123, 125, 127, 129, 131, 133, + 136, 138, 140, 142, 144, 146, 148, 150, + 153, 155, 157, 159, 161, 163, 165, 167, + 170, 172, 174, 176, 178, 180, 182, 184, + 187, 189, 191, 193, 195, 197, 199, 201, + 204, 206, 208, 210, 212, 214, 216, 218, + 221, 223, 225, 227, 229, 231, 233, 235, + 238, 240, 242, 244, 246, 248, 250, 252, + 255, 257, 259, 261, 263, 265, 267, 269] + : + MEDIUM_TYPE_AUTO: 0 + MEDIUM_TYPE: PC_PHY_MEDIUM_COPPER +... + +--- +device: + 0: + FP_CONFIG: + FP_ING_OPERMODE: GLOBAL_PIPE_AWARE +... + +--- +bcm_device: + 0: + global: + bcm_tunnel_term_compatible_mode: 1 + vlan_flooding_l2mc_num_reserved: 2048 + l3_alpm_template: 1 + l3_alpm2_bnk_threshold: 100 + uft_mode: 1 + l3_enable: 1 + l2_hitbit_enable: 0 + pktio_mode: 1 + riot_overlay_l3_intf_mem_size: 4096 + riot_overlay_l3_egress_mem_size: 8192 + l3_ecmp_member_first_lkup_mem_size: 8192 +... + +--- +bcm_device: + 0: + port: + "*": + encap_mode: IEEE + dport_map_enable: 1 + 85: + dport_map_port: 1 + 87: + dport_map_port: 2 + 93: + dport_map_port: 3 + 95: + dport_map_port: 4 + 97: + dport_map_port: 5 + 99: + dport_map_port: 6 + 89: + dport_map_port: 7 + 91: + dport_map_port: 8 + 42: + dport_map_port: 9 + 44: + dport_map_port: 10 + 38: + dport_map_port: 11 + 40: + dport_map_port: 12 + 46: + dport_map_port: 13 + 48: + dport_map_port: 14 + 34: + dport_map_port: 15 + 36: + dport_map_port: 16 + 233: + dport_map_port: 17 + 235: + dport_map_port: 18 + 221: + dport_map_port: 19 + 223: + dport_map_port: 20 + 229: + dport_map_port: 21 + 231: + dport_map_port: 22 + 225: + dport_map_port: 23 + 227: + dport_map_port: 24 + 174: + dport_map_port: 25 + 176: + dport_map_port: 26 + 182: + dport_map_port: 27 + 184: + dport_map_port: 28 + 170: + dport_map_port: 29 + 172: + dport_map_port: 30 + 178: + dport_map_port: 31 + 180: + dport_map_port: 32 + 9: + dport_map_port: 33 + 11: + dport_map_port: 34 + 13: + dport_map_port: 35 + 15: + dport_map_port: 36 + 21: + dport_map_port: 37 + 23: + dport_map_port: 38 + 29: + dport_map_port: 39 + 31: + dport_map_port: 40 + 106: + dport_map_port: 41 + 108: + dport_map_port: 42 + 114: + dport_map_port: 43 + 116: + dport_map_port: 44 + 119: + dport_map_port: 45 + 121: + dport_map_port: 46 + 123: + dport_map_port: 47 + 125: + dport_map_port: 48 + 144: + dport_map_port: 49 + 146: + dport_map_port: 50 + 148: + dport_map_port: 51 + 150: + dport_map_port: 52 + 153: + dport_map_port: 53 + 155: + dport_map_port: 54 + 161: + dport_map_port: 55 + 163: + dport_map_port: 56 + 238: + dport_map_port: 57 + 240: + dport_map_port: 58 + 246: + dport_map_port: 59 + 248: + dport_map_port: 60 + 255: + dport_map_port: 61 + 257: + dport_map_port: 62 + 259: + dport_map_port: 63 + 261: + dport_map_port: 64 + 5: + dport_map_port: 65 + 7: + dport_map_port: 66 + 1: + dport_map_port: 67 + 3: + dport_map_port: 68 + 17: + dport_map_port: 69 + 19: + dport_map_port: 70 + 25: + dport_map_port: 71 + 27: + dport_map_port: 72 + 102: + dport_map_port: 73 + 104: + dport_map_port: 74 + 110: + dport_map_port: 75 + 112: + dport_map_port: 76 + 131: + dport_map_port: 77 + 133: + dport_map_port: 78 + 127: + dport_map_port: 79 + 129: + dport_map_port: 80 + 140: + dport_map_port: 81 + 142: + dport_map_port: 82 + 136: + dport_map_port: 83 + 138: + dport_map_port: 84 + 157: + dport_map_port: 85 + 159: + dport_map_port: 86 + 165: + dport_map_port: 87 + 167: + dport_map_port: 88 + 242: + dport_map_port: 89 + 244: + dport_map_port: 90 + 250: + dport_map_port: 91 + 252: + dport_map_port: 92 + 267: + dport_map_port: 93 + 269: + dport_map_port: 94 + 263: + dport_map_port: 95 + 265: + dport_map_port: 96 + 68: + dport_map_port: 97 + 70: + dport_map_port: 98 + 76: + dport_map_port: 99 + 78: + dport_map_port: 100 + 72: + dport_map_port: 101 + 74: + dport_map_port: 102 + 80: + dport_map_port: 103 + 82: + dport_map_port: 104 + 59: + dport_map_port: 105 + 61: + dport_map_port: 106 + 55: + dport_map_port: 107 + 57: + dport_map_port: 108 + 63: + dport_map_port: 109 + 65: + dport_map_port: 110 + 51: + dport_map_port: 111 + 53: + dport_map_port: 112 + 216: + dport_map_port: 113 + 218: + dport_map_port: 114 + 204: + dport_map_port: 115 + 206: + dport_map_port: 116 + 212: + dport_map_port: 117 + 214: + dport_map_port: 118 + 208: + dport_map_port: 119 + 210: + dport_map_port: 120 + 187: + dport_map_port: 121 + 189: + dport_map_port: 122 + 195: + dport_map_port: 123 + 197: + dport_map_port: 124 + 191: + dport_map_port: 125 + 193: + dport_map_port: 126 + 199: + dport_map_port: 127 + 201: + dport_map_port: 128 +... diff --git a/device/tencent/x86_64-tencent_tcs9400-r0/TCS9400-128CC/port_config.ini b/device/tencent/x86_64-tencent_tcs9400-r0/TCS9400-128CC/port_config.ini new file mode 100755 index 000000000000..e1ec63f3cc53 --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs9400-r0/TCS9400-128CC/port_config.ini @@ -0,0 +1,128 @@ +# name lanes alias index speed +Ethernet1 81,82,83,84 Eth200GE0/1 1 200000 +Ethernet2 83,84,85,86 Eth200GE0/2 2 200000 +Ethernet3 89,90,91,92 Eth200GE0/3 3 200000 +Ethernet4 91,92,93,94 Eth200GE0/4 4 200000 +Ethernet5 93,94,95,96 Eth200GE0/5 5 200000 +Ethernet6 95,96,97,98 Eth200GE0/6 6 200000 +Ethernet7 85,86,87,88 Eth200GE0/7 7 200000 +Ethernet8 87,88,89,90 Eth200GE0/8 8 200000 +Ethernet9 41,42,43,44 Eth200GE0/9 9 200000 +Ethernet10 43,44,45,46 Eth200GE0/10 10 200000 +Ethernet11 37,38,39,40 Eth200GE0/11 11 200000 +Ethernet12 39,40,41,42 Eth200GE0/12 12 200000 +Ethernet13 45,46,47,48 Eth200GE0/13 13 200000 +Ethernet14 47,48,49,50 Eth200GE0/14 14 200000 +Ethernet15 33,34,35,36 Eth200GE0/15 15 200000 +Ethernet16 35,36,37,38 Eth200GE0/16 16 200000 +Ethernet17 221,222,223,224 Eth200GE0/17 17 200000 +Ethernet18 223,224,225,226 Eth200GE0/18 18 200000 +Ethernet19 209,210,211,212 Eth200GE0/19 19 200000 +Ethernet20 211,212,213,214 Eth200GE0/20 20 200000 +Ethernet21 217,218,219,220 Eth200GE0/21 21 200000 +Ethernet22 219,220,221,222 Eth200GE0/22 22 200000 +Ethernet23 213,214,215,216 Eth200GE0/23 23 200000 +Ethernet24 215,216,217,218 Eth200GE0/24 24 200000 +Ethernet25 165,166,167,168 Eth200GE0/25 25 200000 +Ethernet26 167,168,169,170 Eth200GE0/26 26 200000 +Ethernet27 173,174,175,176 Eth200GE0/27 27 200000 +Ethernet28 175,176,177,178 Eth200GE0/28 28 200000 +Ethernet29 161,162,163,164 Eth200GE0/29 29 200000 +Ethernet30 163,164,165,166 Eth200GE0/30 30 200000 +Ethernet31 169,170,171,172 Eth200GE0/31 31 200000 +Ethernet32 171,172,173,174 Eth200GE0/32 32 200000 +Ethernet33 9,10,11,12 Eth200GE0/33 33 200000 +Ethernet34 11,12,13,14 Eth200GE0/34 34 200000 +Ethernet35 13,14,15,16 Eth200GE0/35 35 200000 +Ethernet36 15,16,17,18 Eth200GE0/36 36 200000 +Ethernet37 21,22,23,24 Eth200GE0/37 37 200000 +Ethernet38 23,24,25,26 Eth200GE0/38 38 200000 +Ethernet39 29,30,31,32 Eth200GE0/39 39 200000 +Ethernet40 31,32,33,34 Eth200GE0/40 40 200000 +Ethernet41 101,102,103,104 Eth200GE0/41 41 200000 +Ethernet42 103,104,105,106 Eth200GE0/42 42 200000 +Ethernet43 109,110,111,112 Eth200GE0/43 43 200000 +Ethernet44 111,112,113,114 Eth200GE0/44 44 200000 +Ethernet45 113,114,115,116 Eth200GE0/45 45 200000 +Ethernet46 115,116,117,118 Eth200GE0/46 46 200000 +Ethernet47 117,118,119,120 Eth200GE0/47 47 200000 +Ethernet48 119,120,121,122 Eth200GE0/48 48 200000 +Ethernet49 137,138,139,140 Eth200GE0/49 49 200000 +Ethernet50 139,140,141,142 Eth200GE0/50 50 200000 +Ethernet51 141,142,143,144 Eth200GE0/51 51 200000 +Ethernet52 143,144,145,146 Eth200GE0/52 52 200000 +Ethernet53 145,146,147,148 Eth200GE0/53 53 200000 +Ethernet54 147,148,149,150 Eth200GE0/54 54 200000 +Ethernet55 153,154,155,156 Eth200GE0/55 55 200000 +Ethernet56 155,156,157,158 Eth200GE0/56 56 200000 +Ethernet57 225,226,227,228 Eth200GE0/57 57 200000 +Ethernet58 227,228,229,230 Eth200GE0/58 58 200000 +Ethernet59 233,234,235,236 Eth200GE0/59 59 200000 +Ethernet60 235,236,237,238 Eth200GE0/60 60 200000 +Ethernet61 241,242,243,244 Eth200GE0/61 61 200000 +Ethernet62 243,244,245,246 Eth200GE0/62 62 200000 +Ethernet63 245,246,247,248 Eth200GE0/63 63 200000 +Ethernet64 247,248,249,250 Eth200GE0/64 64 200000 +Ethernet65 5,6,7,8 Eth200GE0/65 65 200000 +Ethernet66 7,8,9,10 Eth200GE0/66 66 200000 +Ethernet67 1,2,3,4 Eth200GE0/67 67 200000 +Ethernet68 3,4,5,6 Eth200GE0/68 68 200000 +Ethernet69 17,18,19,20 Eth200GE0/69 69 200000 +Ethernet70 19,20,21,22 Eth200GE0/70 70 200000 +Ethernet71 25,26,27,28 Eth200GE0/71 71 200000 +Ethernet72 27,28,29,30 Eth200GE0/72 72 200000 +Ethernet73 97,98,99,100 Eth200GE0/73 73 200000 +Ethernet74 99,100,101,102 Eth200GE0/74 74 200000 +Ethernet75 105,106,107,108 Eth200GE0/75 75 200000 +Ethernet76 107,108,109,110 Eth200GE0/76 76 200000 +Ethernet77 125,126,127,128 Eth200GE0/77 77 200000 +Ethernet78 127,128,129,130 Eth200GE0/78 78 200000 +Ethernet79 121,122,123,124 Eth200GE0/79 79 200000 +Ethernet80 123,124,125,126 Eth200GE0/80 80 200000 +Ethernet81 133,134,135,136 Eth200GE0/81 81 200000 +Ethernet82 135,136,137,138 Eth200GE0/82 82 200000 +Ethernet83 129,130,131,132 Eth200GE0/83 83 200000 +Ethernet84 131,132,133,134 Eth200GE0/84 84 200000 +Ethernet85 149,150,151,152 Eth200GE0/85 85 200000 +Ethernet86 151,152,153,154 Eth200GE0/86 86 200000 +Ethernet87 157,158,159,160 Eth200GE0/87 87 200000 +Ethernet88 159,160,161,162 Eth200GE0/88 88 200000 +Ethernet89 229,230,231,232 Eth200GE0/89 89 200000 +Ethernet90 231,232,233,234 Eth200GE0/90 90 200000 +Ethernet91 237,238,239,240 Eth200GE0/91 91 200000 +Ethernet92 239,240,241,242 Eth200GE0/92 92 200000 +Ethernet93 253,254,255,256 Eth200GE0/93 93 200000 +Ethernet94 255,256,257,258 Eth200GE0/94 94 200000 +Ethernet95 249,250,251,252 Eth200GE0/95 95 200000 +Ethernet96 251,252,253,254 Eth200GE0/96 96 200000 +Ethernet97 65,66,67,68 Eth200GE0/97 97 200000 +Ethernet98 67,68,69,70 Eth200GE0/98 98 200000 +Ethernet99 73,74,75,76 Eth200GE0/99 99 200000 +Ethernet100 75,76,77,78 Eth200GE0/100 100 200000 +Ethernet101 69,70,71,72 Eth200GE0/101 101 200000 +Ethernet102 71,72,73,74 Eth200GE0/102 102 200000 +Ethernet103 77,78,79,80 Eth200GE0/103 103 200000 +Ethernet104 79,80,81,82 Eth200GE0/104 104 200000 +Ethernet105 57,58,59,60 Eth200GE0/105 105 200000 +Ethernet106 59,60,61,62 Eth200GE0/106 106 200000 +Ethernet107 53,54,55,56 Eth200GE0/107 107 200000 +Ethernet108 55,56,57,58 Eth200GE0/108 108 200000 +Ethernet109 61,62,63,64 Eth200GE0/109 109 200000 +Ethernet110 63,64,65,66 Eth200GE0/110 110 200000 +Ethernet111 49,50,51,52 Eth200GE0/111 111 200000 +Ethernet112 51,52,53,54 Eth200GE0/112 112 200000 +Ethernet113 205,206,207,208 Eth200GE0/113 113 200000 +Ethernet114 207,208,209,210 Eth200GE0/114 114 200000 +Ethernet115 193,194,195,196 Eth200GE0/115 115 200000 +Ethernet116 195,196,197,198 Eth200GE0/116 116 200000 +Ethernet117 201,202,203,204 Eth200GE0/117 117 200000 +Ethernet118 203,204,205,206 Eth200GE0/118 118 200000 +Ethernet119 197,198,199,200 Eth200GE0/119 119 200000 +Ethernet120 199,200,201,202 Eth200GE0/120 120 200000 +Ethernet121 177,178,179,180 Eth200GE0/121 121 200000 +Ethernet122 179,180,181,182 Eth200GE0/122 122 200000 +Ethernet123 185,186,187,188 Eth200GE0/123 123 200000 +Ethernet124 187,188,189,190 Eth200GE0/124 124 200000 +Ethernet125 181,182,183,184 Eth200GE0/125 125 200000 +Ethernet126 183,184,185,186 Eth200GE0/126 126 200000 +Ethernet127 189,190,191,192 Eth200GE0/127 127 200000 diff --git a/device/tencent/x86_64-tencent_tcs9400-r0/TCS9400-128CC/sai.profile b/device/tencent/x86_64-tencent_tcs9400-r0/TCS9400-128CC/sai.profile new file mode 100755 index 000000000000..a4c4be63faf2 --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs9400-r0/TCS9400-128CC/sai.profile @@ -0,0 +1 @@ +SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/TCS9400-128CC.yml diff --git a/device/tencent/x86_64-tencent_tcs9400-r0/config_db.TCS9400-128CC.json b/device/tencent/x86_64-tencent_tcs9400-r0/config_db.TCS9400-128CC.json new file mode 100755 index 000000000000..f2e9673954b7 --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs9400-r0/config_db.TCS9400-128CC.json @@ -0,0 +1,1028 @@ +{ + "DEVICE_METADATA": { + "localhost": { + "hwsku": "TCS9400-128CC", + "platform": "x86_64-tencent_tcs9400-r0", + "mac": "c0:b8:e6:ff:89:9a", + "hostname": "sonic" + } + }, + "PORT": { + "Ethernet1": { + "lanes": "81,82,83,84", + "alias": "Eth200GE0/1", + "index": "1", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet2": { + "lanes": "83,84,85,86", + "alias": "Eth200GE0/2", + "index": "2", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet3": { + "lanes": "89,90,91,92", + "alias": "Eth200GE0/3", + "index": "3", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet4": { + "lanes": "91,92,93,94", + "alias": "Eth200GE0/4", + "index": "4", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet5": { + "lanes": "93,94,95,96", + "alias": "Eth200GE0/5", + "index": "5", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet6": { + "lanes": "95,96,97,98", + "alias": "Eth200GE0/6", + "index": "6", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet7": { + "lanes": "85,86,87,88", + "alias": "Eth200GE0/7", + "index": "7", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet8": { + "lanes": "87,88,89,90", + "alias": "Eth200GE0/8", + "index": "8", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet9": { + "lanes": "41,42,43,44", + "alias": "Eth200GE0/9", + "index": "9", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet10": { + "lanes": "43,44,45,46", + "alias": "Eth200GE0/10", + "index": "10", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet11": { + "lanes": "37,38,39,40", + "alias": "Eth200GE0/11", + "index": "11", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet12": { + "lanes": "39,40,41,42", + "alias": "Eth200GE0/12", + "index": "12", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet13": { + "lanes": "45,46,47,48", + "alias": "Eth200GE0/13", + "index": "13", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet14": { + "lanes": "47,48,49,50", + "alias": "Eth200GE0/14", + "index": "14", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet15": { + "lanes": "33,34,35,36", + "alias": "Eth200GE0/15", + "index": "15", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet16": { + "lanes": "35,36,37,38", + "alias": "Eth200GE0/16", + "index": "16", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet17": { + "lanes": "221,222,223,224", + "alias": "Eth200GE0/17", + "index": "17", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet18": { + "lanes": "223,224,225,226", + "alias": "Eth200GE0/18", + "index": "18", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet19": { + "lanes": "209,210,211,212", + "alias": "Eth200GE0/19", + "index": "19", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet20": { + "lanes": "211,212,213,214", + "alias": "Eth200GE0/20", + "index": "20", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet21": { + "lanes": "217,218,219,220", + "alias": "Eth200GE0/21", + "index": "21", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet22": { + "lanes": "219,220,221,222", + "alias": "Eth200GE0/22", + "index": "22", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet23": { + "lanes": "213,214,215,216", + "alias": "Eth200GE0/23", + "index": "23", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet24": { + "lanes": "215,216,217,218", + "alias": "Eth200GE0/24", + "index": "24", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet25": { + "lanes": "165,166,167,168", + "alias": "Eth200GE0/25", + "index": "25", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet26": { + "lanes": "167,168,169,170", + "alias": "Eth200GE0/26", + "index": "26", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet27": { + "lanes": "173,174,175,176", + "alias": "Eth200GE0/27", + "index": "27", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet28": { + "lanes": "175,176,177,178", + "alias": "Eth200GE0/28", + "index": "28", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet29": { + "lanes": "161,162,163,164", + "alias": "Eth200GE0/29", + "index": "29", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet30": { + "lanes": "163,164,165,166", + "alias": "Eth200GE0/30", + "index": "30", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet31": { + "lanes": "169,170,171,172", + "alias": "Eth200GE0/31", + "index": "31", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet32": { + "lanes": "171,172,173,174", + "alias": "Eth200GE0/32", + "index": "32", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet33": { + "lanes": "9,10,11,12", + "alias": "Eth200GE0/33", + "index": "33", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet34": { + "lanes": "11,12,13,14", + "alias": "Eth200GE0/34", + "index": "34", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet35": { + "lanes": "13,14,15,16", + "alias": "Eth200GE0/35", + "index": "35", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet36": { + "lanes": "15,16,17,18", + "alias": "Eth200GE0/36", + "index": "36", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet37": { + "lanes": "21,22,23,24", + "alias": "Eth200GE0/37", + "index": "37", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet38": { + "lanes": "23,24,25,26", + "alias": "Eth200GE0/38", + "index": "38", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet39": { + "lanes": "29,30,31,32", + "alias": "Eth200GE0/39", + "index": "39", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet40": { + "lanes": "31,32,33,34", + "alias": "Eth200GE0/40", + "index": "40", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet41": { + "lanes": "101,102,103,104", + "alias": "Eth200GE0/41", + "index": "41", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet42": { + "lanes": "103,104,105,106", + "alias": "Eth200GE0/42", + "index": "42", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet43": { + "lanes": "109,110,111,112", + "alias": "Eth200GE0/43", + "index": "43", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet44": { + "lanes": "111,112,113,114", + "alias": "Eth200GE0/44", + "index": "44", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet45": { + "lanes": "113,114,115,116", + "alias": "Eth200GE0/45", + "index": "45", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet46": { + "lanes": "115,116,117,118", + "alias": "Eth200GE0/46", + "index": "46", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet47": { + "lanes": "117,118,119,120", + "alias": "Eth200GE0/47", + "index": "47", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet48": { + "lanes": "119,120,121,122", + "alias": "Eth200GE0/48", + "index": "48", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet49": { + "lanes": "137,138,139,140", + "alias": "Eth200GE0/49", + "index": "49", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet50": { + "lanes": "139,140,141,142", + "alias": "Eth200GE0/50", + "index": "50", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet51": { + "lanes": "141,142,143,144", + "alias": "Eth200GE0/51", + "index": "51", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet52": { + "lanes": "143,144,145,146", + "alias": "Eth200GE0/52", + "index": "52", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet53": { + "lanes": "145,146,147,148", + "alias": "Eth200GE0/53", + "index": "53", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet54": { + "lanes": "147,148,149,150", + "alias": "Eth200GE0/54", + "index": "54", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet55": { + "lanes": "153,154,155,156", + "alias": "Eth200GE0/55", + "index": "55", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet56": { + "lanes": "155,156,157,158", + "alias": "Eth200GE0/56", + "index": "56", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet57": { + "lanes": "225,226,227,228", + "alias": "Eth200GE0/57", + "index": "57", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet58": { + "lanes": "227,228,229,230", + "alias": "Eth200GE0/58", + "index": "58", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet59": { + "lanes": "233,234,235,236", + "alias": "Eth200GE0/59", + "index": "59", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet60": { + "lanes": "235,236,237,238", + "alias": "Eth200GE0/60", + "index": "60", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet61": { + "lanes": "241,242,243,244", + "alias": "Eth200GE0/61", + "index": "61", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet62": { + "lanes": "243,244,245,246", + "alias": "Eth200GE0/62", + "index": "62", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet63": { + "lanes": "245,246,247,248", + "alias": "Eth200GE0/63", + "index": "63", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet64": { + "lanes": "247,248,249,250", + "alias": "Eth200GE0/64", + "index": "64", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet65": { + "lanes": "5,6,7,8", + "alias": "Eth200GE0/65", + "index": "65", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet66": { + "lanes": "7,8,9,10", + "alias": "Eth200GE0/66", + "index": "66", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet67": { + "lanes": "1,2,3,4", + "alias": "Eth200GE0/67", + "index": "67", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet68": { + "lanes": "3,4,5,6", + "alias": "Eth200GE0/68", + "index": "68", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet69": { + "lanes": "17,18,19,20", + "alias": "Eth200GE0/69", + "index": "69", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet70": { + "lanes": "19,20,21,22", + "alias": "Eth200GE0/70", + "index": "70", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet71": { + "lanes": "25,26,27,28", + "alias": "Eth200GE0/71", + "index": "71", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet72": { + "lanes": "27,28,29,30", + "alias": "Eth200GE0/72", + "index": "72", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet73": { + "lanes": "97,98,99,100", + "alias": "Eth200GE0/73", + "index": "73", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet74": { + "lanes": "99,100,101,102", + "alias": "Eth200GE0/74", + "index": "74", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet75": { + "lanes": "105,106,107,108", + "alias": "Eth200GE0/75", + "index": "75", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet76": { + "lanes": "107,108,109,110", + "alias": "Eth200GE0/76", + "index": "76", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet77": { + "lanes": "125,126,127,128", + "alias": "Eth200GE0/77", + "index": "77", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet78": { + "lanes": "127,128,129,130", + "alias": "Eth200GE0/78", + "index": "78", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet79": { + "lanes": "121,122,123,124", + "alias": "Eth200GE0/79", + "index": "79", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet80": { + "lanes": "123,124,125,126", + "alias": "Eth200GE0/80", + "index": "80", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet81": { + "lanes": "133,134,135,136", + "alias": "Eth200GE0/81", + "index": "81", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet82": { + "lanes": "135,136,137,138", + "alias": "Eth200GE0/82", + "index": "82", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet83": { + "lanes": "129,130,131,132", + "alias": "Eth200GE0/83", + "index": "83", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet84": { + "lanes": "131,132,133,134", + "alias": "Eth200GE0/84", + "index": "84", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet85": { + "lanes": "149,150,151,152", + "alias": "Eth200GE0/85", + "index": "85", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet86": { + "lanes": "151,152,153,154", + "alias": "Eth200GE0/86", + "index": "86", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet87": { + "lanes": "157,158,159,160", + "alias": "Eth200GE0/87", + "index": "87", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet88": { + "lanes": "159,160,161,162", + "alias": "Eth200GE0/88", + "index": "88", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet89": { + "lanes": "229,230,231,232", + "alias": "Eth200GE0/89", + "index": "89", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet90": { + "lanes": "231,232,233,234", + "alias": "Eth200GE0/90", + "index": "90", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet91": { + "lanes": "237,238,239,240", + "alias": "Eth200GE0/91", + "index": "91", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet92": { + "lanes": "239,240,241,242", + "alias": "Eth200GE0/92", + "index": "92", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet93": { + "lanes": "253,254,255,256", + "alias": "Eth200GE0/93", + "index": "93", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet94": { + "lanes": "255,256,257,258", + "alias": "Eth200GE0/94", + "index": "94", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet95": { + "lanes": "249,250,251,252", + "alias": "Eth200GE0/95", + "index": "95", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet96": { + "lanes": "251,252,253,254", + "alias": "Eth200GE0/96", + "index": "96", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet97": { + "lanes": "65,66,67,68", + "alias": "Eth200GE0/97", + "index": "97", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet98": { + "lanes": "67,68,69,70", + "alias": "Eth200GE0/98", + "index": "98", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet99": { + "lanes": "73,74,75,76", + "alias": "Eth200GE0/99", + "index": "99", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet100": { + "lanes": "75,76,77,78", + "alias": "Eth200GE0/100", + "index": "100", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet101": { + "lanes": "69,70,71,72", + "alias": "Eth200GE0/101", + "index": "101", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet102": { + "lanes": "71,72,73,74", + "alias": "Eth200GE0/102", + "index": "102", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet103": { + "lanes": "77,78,79,80", + "alias": "Eth200GE0/103", + "index": "103", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet104": { + "lanes": "79,80,81,82", + "alias": "Eth200GE0/104", + "index": "104", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet105": { + "lanes": "57,58,59,60", + "alias": "Eth200GE0/105", + "index": "105", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet106": { + "lanes": "59,60,61,62", + "alias": "Eth200GE0/106", + "index": "106", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet107": { + "lanes": "53,54,55,56", + "alias": "Eth200GE0/107", + "index": "107", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet108": { + "lanes": "55,56,57,58", + "alias": "Eth200GE0/108", + "index": "108", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet109": { + "lanes": "61,62,63,64", + "alias": "Eth200GE0/109", + "index": "109", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet110": { + "lanes": "63,64,65,66", + "alias": "Eth200GE0/110", + "index": "110", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet111": { + "lanes": "49,50,51,52", + "alias": "Eth200GE0/111", + "index": "111", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet112": { + "lanes": "51,52,53,54", + "alias": "Eth200GE0/112", + "index": "112", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet113": { + "lanes": "205,206,207,208", + "alias": "Eth200GE0/113", + "index": "113", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet114": { + "lanes": "207,208,209,210", + "alias": "Eth200GE0/114", + "index": "114", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet115": { + "lanes": "193,194,195,196", + "alias": "Eth200GE0/115", + "index": "115", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet116": { + "lanes": "195,196,197,198", + "alias": "Eth200GE0/116", + "index": "116", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet117": { + "lanes": "201,202,203,204", + "alias": "Eth200GE0/117", + "index": "117", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet118": { + "lanes": "203,204,205,206", + "alias": "Eth200GE0/118", + "index": "118", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet119": { + "lanes": "197,198,199,200", + "alias": "Eth200GE0/119", + "index": "119", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet120": { + "lanes": "199,200,201,202", + "alias": "Eth200GE0/120", + "index": "120", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet121": { + "lanes": "177,178,179,180", + "alias": "Eth200GE0/121", + "index": "121", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet122": { + "lanes": "179,180,181,182", + "alias": "Eth200GE0/122", + "index": "122", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet123": { + "lanes": "185,186,187,188", + "alias": "Eth200GE0/123", + "index": "123", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet124": { + "lanes": "187,188,189,190", + "alias": "Eth200GE0/124", + "index": "124", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet125": { + "lanes": "181,182,183,184", + "alias": "Eth200GE0/125", + "index": "125", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet126": { + "lanes": "183,184,185,186", + "alias": "Eth200GE0/126", + "index": "126", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet127": { + "lanes": "189,190,191,192", + "alias": "Eth200GE0/127", + "index": "127", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + } + } +} diff --git a/device/tencent/x86_64-tencent_tcs9400-r0/custom_led.bin b/device/tencent/x86_64-tencent_tcs9400-r0/custom_led.bin new file mode 100755 index 000000000000..3c68fea140d2 Binary files /dev/null and b/device/tencent/x86_64-tencent_tcs9400-r0/custom_led.bin differ diff --git a/device/tencent/x86_64-tencent_tcs9400-r0/default_sku b/device/tencent/x86_64-tencent_tcs9400-r0/default_sku new file mode 100755 index 000000000000..2ef40b6e379b --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs9400-r0/default_sku @@ -0,0 +1 @@ +TCS9400-128CC t1 diff --git a/device/tencent/x86_64-tencent_tcs9400-r0/dev.xml b/device/tencent/x86_64-tencent_tcs9400-r0/dev.xml new file mode 100755 index 000000000000..7b1f77ffa396 --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs9400-r0/dev.xml @@ -0,0 +1,572 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/device/tencent/x86_64-tencent_tcs9400-r0/dev_0x407c.xml b/device/tencent/x86_64-tencent_tcs9400-r0/dev_0x407c.xml new file mode 100755 index 000000000000..ca1661ea5092 --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs9400-r0/dev_0x407c.xml @@ -0,0 +1,572 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/device/tencent/x86_64-tencent_tcs9400-r0/fru.py b/device/tencent/x86_64-tencent_tcs9400-r0/fru.py new file mode 100755 index 000000000000..2ccfba01dea2 --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs9400-r0/fru.py @@ -0,0 +1,953 @@ +#!/usr/bin/python3 +import collections +from bitarray import bitarray +from datetime import datetime, timedelta + + +__DEBUG__ = "N" + + +class FruException(Exception): + def __init__(self, message='fruerror', code=-100): + err = 'errcode: {0} message:{1}'.format(code, message) + Exception.__init__(self, err) + self.code = code + self.message = message + + +def e_print(err): + print("ERROR: " + err) + + +def d_print(debug_info): + if(__DEBUG__ == "Y"): + print(debug_info) + + +class FruUtil(): + @staticmethod + def decodeLength(value): + a = bitarray(8) + a.setall(True) + a[0:1] = 0 + a[1:2] = 0 + x = ord(a.tobytes()) + return x & ord(value) + + @staticmethod + def minToData(): + starttime = datetime(1996, 1, 1, 0, 0, 0) + endtime = datetime.now() + seconds = (endtime - starttime).total_seconds() + mins = seconds // 60 + m = int(round(mins)) + return m + + @staticmethod + def getTimeFormat(): + return datetime.now().strftime('%Y-%m-%d') + + @staticmethod + def getTypeLength(value): + if value is None or len(value) == 0: + return 0 + a = bitarray(8) + a.setall(False) + a[0:1] = 1 + a[1:2] = 1 + x = ord(a.tobytes()) + return x | len(value) + + @staticmethod + def checksum(b): + result = 0 + for i in range(len(b)): + result += ord(b[i]) + return (0x100 - (result & 0xff)) & 0xff + + +class BaseArea(object): + SUGGESTED_SIZE_COMMON_HEADER = 8 + SUGGESTED_SIZE_INTERNAL_USE_AREA = 72 + SUGGESTED_SIZE_CHASSIS_INFO_AREA = 32 + SUGGESTED_SIZE_BOARD_INFO_AREA = 80 + SUGGESTED_SIZE_PRODUCT_INFO_AREA = 80 + + INITVALUE = b'\x00' + resultvalue = INITVALUE * 256 + COMMON_HEAD_VERSION = b'\x01' + __childList = None + + def __init__(self, name="", size=0, offset=0): + self.__childList = [] + self._offset = offset + self.name = name + self._size = size + self._isPresent = False + self._data = b'\x00' * size + self.__dataoffset = 0 + + @property + def childList(self): + return self.__childList + + @childList.setter + def childList(self, value): + self.__childList = value + + @property + def offset(self): + return self._offset + + @offset.setter + def offset(self, value): + self._offset = value + + @property + def size(self): + return self._size + + @size.setter + def size(self, value): + self._size = value + + @property + def data(self): + return self._data + + @data.setter + def data(self, value): + self._data = value + + @property + def isPresent(self): + return self._isPresent + + @isPresent.setter + def isPresent(self, value): + self._isPresent = value + + +class InternalUseArea(BaseArea): + pass + + +class ChassisInfoArea(BaseArea): + pass + + +class BoardInfoArea(BaseArea): + _boardTime = None + _fields = None + _mfg_date = None + + def __str__(self): + formatstr = "version : %x\n" \ + "length : %d \n" \ + "language : %x \n" \ + "mfg_date : %s \n" \ + "boardManufacturer : %s \n" \ + "boardProductName : %s \n" \ + "boardSerialNumber : %s \n" \ + "boardPartNumber : %s \n" \ + "fruFileId : %s \n" + + tmpstr = formatstr % (ord(self.boardversion), self.size, + self.language, self.getMfgRealData(), + self.boardManufacturer, self.boardProductName, + self.boardSerialNumber, self.boardPartNumber, + self.fruFileId) + for i in range(1, 11): + valtmp = "boardextra%d" % i + if hasattr(self, valtmp): + valtmpval = getattr(self, valtmp) + tmpstr += "boardextra%d : %s \n" % (i, valtmpval) + else: + break + + return tmpstr + + def todict(self): + dic = collections.OrderedDict() + dic["boardversion"] = ord(self.boardversion) + dic["boardlength"] = self.size + dic["boardlanguage"] = self.language + dic["boardmfg_date"] = self.getMfgRealData() + dic["boardManufacturer"] = self.boardManufacturer + dic["boardProductName"] = self.boardProductName + dic["boardSerialNumber"] = self.boardSerialNumber + dic["boardPartNumber"] = self.boardPartNumber + dic["boardfruFileId"] = self.fruFileId + for i in range(1, 11): + valtmp = "boardextra%d" % i + if hasattr(self, valtmp): + valtmpval = getattr(self, valtmp) + dic[valtmp] = valtmpval + else: + break + return dic + + def decodedata(self): + index = 0 + self.areaversion = self.data[index] + index += 1 + d_print("decode length :%d class size:%d" % + ((ord(self.data[index]) * 8), self.size)) + index += 2 + + timetmp = self.data[index: index + 3] + self.mfg_date = ord(timetmp[0]) | ( + ord(timetmp[1]) << 8) | (ord(timetmp[2]) << 16) + d_print("decode getMfgRealData :%s" % self.getMfgRealData()) + index += 3 + + templen = FruUtil.decodeLength(self.data[index]) + self.boardManufacturer = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode boardManufacturer:%s" % self.boardManufacturer) + + templen = FruUtil.decodeLength(self.data[index]) + self.boardProductName = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode boardProductName:%s" % self.boardProductName) + + templen = FruUtil.decodeLength(self.data[index]) + self.boardSerialNumber = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode boardSerialNumber:%s" % self.boardSerialNumber) + + templen = FruUtil.decodeLength(self.data[index]) + self.boardPartNumber = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode boardPartNumber:%s" % self.boardPartNumber) + + templen = FruUtil.decodeLength(self.data[index]) + self.fruFileId = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode fruFileId:%s" % self.fruFileId) + + for i in range(1, 11): + valtmp = "boardextra%d" % i + if self.data[index] != chr(0xc1): + templen = FruUtil.decodeLength(self.data[index]) + tmpval = self.data[index + 1: index + templen + 1] + setattr(self, valtmp, tmpval) + index += templen + 1 + d_print("decode boardextra%d:%s" % (i, tmpval)) + else: + break + return + + def recalcute(self): + d_print("boardInfoArea version:%x" % ord(self.boardversion)) + d_print("boardInfoArea length:%d" % self.size) + d_print("boardInfoArea language:%x" % self.language) + self.mfg_date = FruUtil.minToData() + d_print("boardInfoArea mfg_date:%x" % self.mfg_date) + + self.data = chr(ord(self.boardversion)) + \ + chr(self.size // 8) + chr(self.language) + + self.data += chr(self.mfg_date & 0xFF) + self.data += chr((self.mfg_date >> 8) & 0xFF) + self.data += chr((self.mfg_date >> 16) & 0xFF) + + d_print("boardInfoArea boardManufacturer:%s" % self.boardManufacturer) + typelength = FruUtil.getTypeLength(self.boardManufacturer) + self.data += chr(typelength) + self.data += self.boardManufacturer + + d_print("boardInfoArea boardProductName:%s" % self.boardProductName) + self.data += chr(FruUtil.getTypeLength(self.boardProductName)) + self.data += self.boardProductName + + d_print("boardInfoArea boardSerialNumber:%s" % self.boardSerialNumber) + self.data += chr(FruUtil.getTypeLength(self.boardSerialNumber)) + self.data += self.boardSerialNumber + + d_print("boardInfoArea boardPartNumber:%s" % self.boardPartNumber) + self.data += chr(FruUtil.getTypeLength(self.boardPartNumber)) + self.data += self.boardPartNumber + + d_print("boardInfoArea fruFileId:%s" % self.fruFileId) + self.data += chr(FruUtil.getTypeLength(self.fruFileId)) + self.data += self.fruFileId + + for i in range(1, 11): + valtmp = "boardextra%d" % i + if hasattr(self, valtmp): + valtmpval = getattr(self, valtmp) + d_print("boardInfoArea boardextra%d:%s" % (i, valtmpval)) + self.data += chr(FruUtil.getTypeLength(valtmpval)) + if valtmpval is None: + pass + else: + self.data += valtmpval + else: + break + + self.data += chr(0xc1) + + if len(self.data) > (self.size - 1): + incr = (len(self.data) - self.size) // 8 + 1 + self.size += incr * 8 + + self.data = self.data[0:1] + chr(self.size // 8) + self.data[2:] + d_print("self data:%d" % len(self.data)) + d_print("self size:%d" % self.size) + d_print("adjust size:%d" % (self.size - len(self.data) - 1)) + self.data = self.data.ljust((self.size - 1), chr(self.INITVALUE[0])) + + # checksum + checksum = FruUtil.checksum(self.data) + d_print("board info checksum:%x" % checksum) + self.data += chr(checksum) + + def getMfgRealData(self): + starttime = datetime(1996, 1, 1, 0, 0, 0) + mactime = starttime + timedelta(minutes=self.mfg_date) + return mactime + + @property + def language(self): + self._language = 25 + return self._language + + @property + def mfg_date(self): + return self._mfg_date + + @mfg_date.setter + def mfg_date(self, val): + self._mfg_date = val + + @property + def boardversion(self): + self._boardversion = self.COMMON_HEAD_VERSION + return self._boardversion + + @property + def fruFileId(self): + return self._FRUFileID + + @fruFileId.setter + def fruFileId(self, val): + self._FRUFileID = val + + @property + def boardPartNumber(self): + return self._boardPartNumber + + @boardPartNumber.setter + def boardPartNumber(self, val): + self._boardPartNumber = val + + @property + def boardSerialNumber(self): + return self._boardSerialNumber + + @boardSerialNumber.setter + def boardSerialNumber(self, val): + self._boardSerialNumber = val + + @property + def boardProductName(self): + return self._boradProductName + + @boardProductName.setter + def boardProductName(self, val): + self._boradProductName = val + + @property + def boardManufacturer(self): + return self._boardManufacturer + + @boardManufacturer.setter + def boardManufacturer(self, val): + self._boardManufacturer = val + + @property + def boardTime(self): + return self._boardTime + + @boardTime.setter + def boardTime(self, val): + self._boardTime = val + + @property + def fields(self): + return self._fields + + @fields.setter + def fields(self, val): + self._fields = val + + +class ProductInfoArea(BaseArea): + _productManufacturer = None + _productAssetTag = None + _FRUFileID = None + + def __str__(self): + formatstr = "version : %x\n" \ + "length : %d \n" \ + "language : %x \n" \ + "productManufacturer : %s \n" \ + "productName : %s \n" \ + "productPartModelName: %s \n" \ + "productVersion : %s \n" \ + "productSerialNumber : %s \n" \ + "productAssetTag : %s \n" \ + "fruFileId : %s \n" + + tmpstr = formatstr % (ord(self.areaversion), self.size, + self.language, self.productManufacturer, + self.productName, self.productPartModelName, + self.productVersion, self.productSerialNumber, + self.productAssetTag, self.fruFileId) + + for i in range(1, 11): + valtmp = "productextra%d" % i + if hasattr(self, valtmp): + valtmpval = getattr(self, valtmp) + tmpstr += "productextra%d : %s \n" % (i, valtmpval) + else: + break + + return tmpstr + + def todict(self): + dic = collections.OrderedDict() + dic["productversion"] = ord(self.areaversion) + dic["productlength"] = self.size + dic["productlanguage"] = self.language + dic["productManufacturer"] = self.productManufacturer + dic["productName"] = self.productName + dic["productPartModelName"] = self.productPartModelName + dic["productVersion"] = int(self.productVersion, 16) + dic["productSerialNumber"] = self.productSerialNumber + dic["productAssetTag"] = self.productAssetTag + dic["productfruFileId"] = self.fruFileId + for i in range(1, 11): + valtmp = "productextra%d" % i + if hasattr(self, valtmp): + valtmpval = getattr(self, valtmp) + dic[valtmp] = valtmpval + else: + break + return dic + + def decodedata(self): + index = 0 + self.areaversion = self.data[index] # 0 + index += 1 + d_print("decode length %d" % (ord(self.data[index]) * 8)) + d_print("class size %d" % self.size) + index += 2 + + templen = FruUtil.decodeLength(self.data[index]) + self.productManufacturer = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode productManufacturer:%s" % self.productManufacturer) + + templen = FruUtil.decodeLength(self.data[index]) + self.productName = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode productName:%s" % self.productName) + + templen = FruUtil.decodeLength(self.data[index]) + self.productPartModelName = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode productPartModelName:%s" % self.productPartModelName) + + templen = FruUtil.decodeLength(self.data[index]) + self.productVersion = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode productVersion:%s" % self.productVersion) + + templen = FruUtil.decodeLength(self.data[index]) + self.productSerialNumber = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode productSerialNumber:%s" % self.productSerialNumber) + + templen = FruUtil.decodeLength(self.data[index]) + self.productAssetTag = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode productAssetTag:%s" % self.productAssetTag) + + templen = FruUtil.decodeLength(self.data[index]) + self.fruFileId = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode fruFileId:%s" % self.fruFileId) + + for i in range(1, 11): + valtmp = "productextra%d" % i + if self.data[index] != chr(0xc1) and index < self.size - 1: + templen = FruUtil.decodeLength(self.data[index]) + if templen == 0: + break + tmpval = self.data[index + 1: index + templen + 1] + d_print("decode boardextra%d:%s" % (i, tmpval)) + setattr(self, valtmp, tmpval) + index += templen + 1 + else: + break + + @property + def productVersion(self): + return self._productVersion + + @productVersion.setter + def productVersion(self, name): + self._productVersion = name + + @property + def areaversion(self): + self._areaversion = self.COMMON_HEAD_VERSION + return self._areaversion + + @areaversion.setter + def areaversion(self, name): + self._areaversion = name + + @property + def language(self): + self._language = 25 + return self._language + + @property + def productManufacturer(self): + return self._productManufacturer + + @productManufacturer.setter + def productManufacturer(self, name): + self._productManufacturer = name + + @property + def productName(self): + return self._productName + + @productName.setter + def productName(self, name): + self._productName = name + + @property + def productPartModelName(self): + return self._productPartModelName + + @productPartModelName.setter + def productPartModelName(self, name): + self._productPartModelName = name + + @property + def productSerialNumber(self): + return self._productSerialNumber + + @productSerialNumber.setter + def productSerialNumber(self, name): + self._productSerialNumber = name + + @property + def productAssetTag(self): + return self._productAssetTag + + @productAssetTag.setter + def productAssetTag(self, name): + self._productAssetTag = name + + @property + def fruFileId(self): + return self._FRUFileID + + @fruFileId.setter + def fruFileId(self, name): + self._FRUFileID = name + + def recalcute(self): + d_print("product version:%x" % ord(self.areaversion)) + d_print("product length:%d" % self.size) + d_print("product language:%x" % self.language) + self.data = chr(ord(self.areaversion)) + \ + chr(self.size // 8) + chr(self.language) + + typelength = FruUtil.getTypeLength(self.productManufacturer) + self.data += chr(typelength) + self.data += self.productManufacturer + + self.data += chr(FruUtil.getTypeLength(self.productName)) + self.data += self.productName + + self.data += chr(FruUtil.getTypeLength(self.productPartModelName)) + self.data += self.productPartModelName + + self.data += chr(FruUtil.getTypeLength(self.productVersion)) + self.data += self.productVersion + + self.data += chr(FruUtil.getTypeLength(self.productSerialNumber)) + self.data += self.productSerialNumber + + self.data += chr(FruUtil.getTypeLength(self.productAssetTag)) + if self.productAssetTag is not None: + self.data += self.productAssetTag + + self.data += chr(FruUtil.getTypeLength(self.fruFileId)) + self.data += self.fruFileId + + for i in range(1, 11): + valtmp = "productextra%d" % i + if hasattr(self, valtmp): + valtmpval = getattr(self, valtmp) + d_print("boardInfoArea productextra%d:%s" % (i, valtmpval)) + self.data += chr(FruUtil.getTypeLength(valtmpval)) + if valtmpval is None: + pass + else: + self.data += valtmpval + else: + break + + self.data += chr(0xc1) + if len(self.data) > (self.size - 1): + incr = (len(self.data) - self.size) // 8 + 1 + self.size += incr * 8 + d_print("self.data:%d" % len(self.data)) + d_print("self.size:%d" % self.size) + + self.data = self.data[0:1] + chr(self.size // 8) + self.data[2:] + self.data = self.data.ljust((self.size - 1), chr(self.INITVALUE[0])) + checksum = FruUtil.checksum(self.data) + d_print("board info checksum:%x" % checksum) + self.data += chr(checksum) + + +class MultiRecordArea(BaseArea): + pass + + +class Field(object): + + def __init__(self, fieldType="ASCII", fieldData=""): + self.fieldData = fieldData + self.fieldType = fieldType + + @property + def data(self): + return self._data + + @property + def fieldType(self): + return self._fieldType + + @property + def fieldData(self): + return self._fieldData + + +class ipmifru(BaseArea): + _BoardInfoArea = None + _ProductInfoArea = None + _InternalUseArea = None + _ChassisInfoArea = None + _multiRecordArea = None + _productinfoAreaOffset = BaseArea.INITVALUE + _boardInfoAreaOffset = BaseArea.INITVALUE + _internalUserAreaOffset = BaseArea.INITVALUE + _chassicInfoAreaOffset = BaseArea.INITVALUE + _multiRecordAreaOffset = BaseArea.INITVALUE + _bindata = None + _bodybin = None + _version = BaseArea.COMMON_HEAD_VERSION + _zeroCheckSum = None + _frusize = 256 + + def __str__(self): + tmpstr = "" + if self.boardInfoArea.isPresent: + tmpstr += "\nboardinfoarea: \n" + tmpstr += self.boardInfoArea.__str__() + if self.productInfoArea.isPresent: + tmpstr += "\nproductinfoarea: \n" + tmpstr += self.productInfoArea.__str__() + return tmpstr + + def decodeBin(self, eeprom): + commonHead = eeprom[0:8] + d_print("decode version %x" % ord(commonHead[0])) + if ord(self.COMMON_HEAD_VERSION) != ord(commonHead[0]): + raise FruException("HEAD VERSION error,not Fru format!", -10) + if FruUtil.checksum(commonHead[0:7]) != ord(commonHead[7]): + strtemp = "check header checksum error [cal:%02x data:%02x]" % ( + FruUtil.checksum(commonHead[0:7]), ord(commonHead[7])) + raise FruException(strtemp, -3) + if ord(commonHead[1]) != ord(self.INITVALUE): + d_print("Internal Use Area is present") + self.internalUseArea = InternalUseArea( + name="Internal Use Area", size=self.SUGGESTED_SIZE_INTERNAL_USE_AREA) + self.internalUseArea.isPresent = True + self.internalUserAreaOffset = ord(commonHead[1]) + self.internalUseArea.data = eeprom[self.internalUserAreaOffset * 8: ( + self.internalUserAreaOffset * 8 + self.internalUseArea.size)] + if ord(commonHead[2]) != ord(self.INITVALUE): + d_print("Chassis Info Area is present") + self.chassisInfoArea = ChassisInfoArea( + name="Chassis Info Area", size=self.SUGGESTED_SIZE_CHASSIS_INFO_AREA) + self.chassisInfoArea.isPresent = True + self.chassicInfoAreaOffset = ord(commonHead[2]) + self.chassisInfoArea.data = eeprom[self.chassicInfoAreaOffset * 8: ( + self.chassicInfoAreaOffset * 8 + self.chassisInfoArea.size)] + if ord(commonHead[3]) != ord(self.INITVALUE): + self.boardInfoArea = BoardInfoArea( + name="Board Info Area", size=self.SUGGESTED_SIZE_BOARD_INFO_AREA) + self.boardInfoArea.isPresent = True + self.boardInfoAreaOffset = ord(commonHead[3]) + self.boardInfoArea.size = ord( + eeprom[self.boardInfoAreaOffset * 8 + 1]) * 8 + d_print("Board Info Area is present size:%d" % + (self.boardInfoArea.size)) + self.boardInfoArea.data = eeprom[self.boardInfoAreaOffset * 8: ( + self.boardInfoAreaOffset * 8 + self.boardInfoArea.size)] + if FruUtil.checksum(self.boardInfoArea.data[:-1]) != ord(self.boardInfoArea.data[-1:]): + strtmp = "check boardInfoArea checksum error[cal:%02x data:%02x]" % \ + (FruUtil.checksum( + self.boardInfoArea.data[:-1]), ord(self.boardInfoArea.data[-1:])) + raise FruException(strtmp, -3) + self.boardInfoArea.decodedata() + if ord(commonHead[4]) != ord(self.INITVALUE): + d_print("Product Info Area is present") + self.productInfoArea = ProductInfoArea( + name="Product Info Area ", size=self.SUGGESTED_SIZE_PRODUCT_INFO_AREA) + self.productInfoArea.isPresent = True + self.productinfoAreaOffset = ord(commonHead[4]) + d_print("length offset value: %02x" % + ord(eeprom[self.productinfoAreaOffset * 8 + 1])) + self.productInfoArea.size = ord( + eeprom[self.productinfoAreaOffset * 8 + 1]) * 8 + d_print("Product Info Area is present size:%d" % + (self.productInfoArea.size)) + + self.productInfoArea.data = eeprom[self.productinfoAreaOffset * 8: ( + self.productinfoAreaOffset * 8 + self.productInfoArea.size)] + if FruUtil.checksum(self.productInfoArea.data[:-1]) != ord(self.productInfoArea.data[-1:]): + strtmp = "check productInfoArea checksum error [cal:%02x data:%02x]" % ( + FruUtil.checksum(self.productInfoArea.data[:-1]), ord(self.productInfoArea.data[-1:])) + raise FruException(strtmp, -3) + self.productInfoArea.decodedata() + if ord(commonHead[5]) != ord(self.INITVALUE): + self.multiRecordArea = MultiRecordArea( + name="MultiRecord record Area ") + d_print("MultiRecord record present") + self.multiRecordArea.isPresent = True + self.multiRecordAreaOffset = ord(commonHead[5]) + self.multiRecordArea.data = eeprom[self.multiRecordAreaOffset * 8: ( + self.multiRecordAreaOffset * 8 + self.multiRecordArea.size)] + + def initDefault(self): + self.version = self.COMMON_HEAD_VERSION + self.internalUserAreaOffset = self.INITVALUE + self.chassicInfoAreaOffset = self.INITVALUE + self.boardInfoAreaOffset = self.INITVALUE + self.productinfoAreaOffset = self.INITVALUE + self.multiRecordAreaOffset = self.INITVALUE + self.PAD = self.INITVALUE + self.zeroCheckSum = self.INITVALUE + self.offset = self.SUGGESTED_SIZE_COMMON_HEADER + self.productInfoArea = None + self.internalUseArea = None + self.boardInfoArea = None + self.chassisInfoArea = None + self.multiRecordArea = None + # self.recalcute() + + @property + def version(self): + return self._version + + @version.setter + def version(self, name): + self._version = name + + @property + def internalUserAreaOffset(self): + return self._internalUserAreaOffset + + @internalUserAreaOffset.setter + def internalUserAreaOffset(self, obj): + self._internalUserAreaOffset = obj + + @property + def chassicInfoAreaOffset(self): + return self._chassicInfoAreaOffset + + @chassicInfoAreaOffset.setter + def chassicInfoAreaOffset(self, obj): + self._chassicInfoAreaOffset = obj + + @property + def productinfoAreaOffset(self): + return self._productinfoAreaOffset + + @productinfoAreaOffset.setter + def productinfoAreaOffset(self, obj): + self._productinfoAreaOffset = obj + + @property + def boardInfoAreaOffset(self): + return self._boardInfoAreaOffset + + @boardInfoAreaOffset.setter + def boardInfoAreaOffset(self, obj): + self._boardInfoAreaOffset = obj + + @property + def multiRecordAreaOffset(self): + return self._multiRecordAreaOffset + + @multiRecordAreaOffset.setter + def multiRecordAreaOffset(self, obj): + self._multiRecordAreaOffset = obj + + @property + def zeroCheckSum(self): + return self._zeroCheckSum + + @zeroCheckSum.setter + def zeroCheckSum(self, obj): + self._zeroCheckSum = obj + + @property + def productInfoArea(self): + return self._ProductInfoArea + + @productInfoArea.setter + def productInfoArea(self, obj): + self._ProductInfoArea = obj + + @property + def internalUseArea(self): + return self._InternalUseArea + + @internalUseArea.setter + def internalUseArea(self, obj): + self.internalUseArea = obj + + @property + def boardInfoArea(self): + return self._BoardInfoArea + + @boardInfoArea.setter + def boardInfoArea(self, obj): + self._BoardInfoArea = obj + + @property + def chassisInfoArea(self): + return self._ChassisInfoArea + + @chassisInfoArea.setter + def chassisInfoArea(self, obj): + self._ChassisInfoArea = obj + + @property + def multiRecordArea(self): + return self._multiRecordArea + + @multiRecordArea.setter + def multiRecordArea(self, obj): + self._multiRecordArea = obj + + @property + def bindata(self): + return self._bindata + + @bindata.setter + def bindata(self, obj): + self._bindata = obj + + @property + def bodybin(self): + return self._bodybin + + @bodybin.setter + def bodybin(self, obj): + self._bodybin = obj + + def recalcuteCommonHead(self): + self.bindata = "" + self.offset = self.SUGGESTED_SIZE_COMMON_HEADER + d_print("common Header %d" % self.offset) + d_print("fru eeprom size %d" % self._frusize) + if self.internalUseArea is not None and self.internalUseArea.isPresent: + self.internalUserAreaOffset = self.offset // 8 + self.offset += self.internalUseArea.size + d_print("internalUseArea is present offset:%d" % self.offset) + + if self.chassisInfoArea is not None and self.chassisInfoArea.isPresent: + self.chassicInfoAreaOffset = self.offset // 8 + self.offset += self.chassisInfoArea.size + d_print("chassisInfoArea is present offset:%d" % self.offset) + + if self.boardInfoArea is not None and self.boardInfoArea.isPresent: + self.boardInfoAreaOffset = self.offset // 8 + self.offset += self.boardInfoArea.size + d_print("boardInfoArea is present offset:%d" % self.offset) + d_print("boardInfoArea is present size:%d" % + self.boardInfoArea.size) + + if self.productInfoArea is not None and self.productInfoArea.isPresent: + self.productinfoAreaOffset = self.offset // 8 + self.offset += self.productInfoArea.size + d_print("productInfoArea is present offset:%d" % self.offset) + + if self.multiRecordArea is not None and self.multiRecordArea.isPresent: + self.multiRecordAreaOffset = self.offset // 8 + d_print("multiRecordArea is present offset:%d" % self.offset) + + if self.internalUserAreaOffset == self.INITVALUE: + self.internalUserAreaOffset = 0 + if self.productinfoAreaOffset == self.INITVALUE: + self.productinfoAreaOffset = 0 + if self.chassicInfoAreaOffset == self.INITVALUE: + self.chassicInfoAreaOffset = 0 + if self.boardInfoAreaOffset == self.INITVALUE: + self.boardInfoAreaOffset = 0 + if self.multiRecordAreaOffset == self.INITVALUE: + self.multiRecordAreaOffset = 0 + + self.zeroCheckSum = (0x100 - ord(self.version) - self.internalUserAreaOffset - self.chassicInfoAreaOffset - self.productinfoAreaOffset + - self.boardInfoAreaOffset - self.multiRecordAreaOffset) & 0xff + d_print("zerochecksum:%x" % self.zeroCheckSum) + self.data = "" + self.data += chr(self.version[0]) + chr(self.internalUserAreaOffset) + chr(self.chassicInfoAreaOffset) + chr( + self.boardInfoAreaOffset) + chr(self.productinfoAreaOffset) + chr(self.multiRecordAreaOffset) + chr(self.INITVALUE[0]) + chr(self.zeroCheckSum) + + self.bindata = self.data + self.bodybin + totallen = len(self.bindata) + d_print("totallen %d" % totallen) + if (totallen < self._frusize): + self.bindata = self.bindata.ljust(self._frusize, chr(self.INITVALUE[0])) + else: + raise FruException('bin data more than %d' % self._frusize, -2) + + def recalcutebin(self): + self.bodybin = "" + if self.internalUseArea is not None and self.internalUseArea.isPresent: + d_print("internalUseArea present") + self.bodybin += self.internalUseArea.data + if self.chassisInfoArea is not None and self.chassisInfoArea.isPresent: + d_print("chassisInfoArea present") + self.bodybin += self.chassisInfoArea.data + if self.boardInfoArea is not None and self.boardInfoArea.isPresent: + d_print("boardInfoArea present") + self.boardInfoArea.recalcute() + self.bodybin += self.boardInfoArea.data + if self.productInfoArea is not None and self.productInfoArea.isPresent: + d_print("productInfoAreapresent") + self.productInfoArea.recalcute() + self.bodybin += self.productInfoArea.data + if self.multiRecordArea is not None and self.multiRecordArea.isPresent: + d_print("multiRecordArea present") + self.bodybin += self.productInfoArea.data + + def recalcute(self, fru_eeprom_size=256): + self._frusize = fru_eeprom_size + self.recalcutebin() + self.recalcuteCommonHead() diff --git a/device/tencent/x86_64-tencent_tcs9400-r0/installer.conf b/device/tencent/x86_64-tencent_tcs9400-r0/installer.conf new file mode 100755 index 000000000000..5e62742c11bf --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs9400-r0/installer.conf @@ -0,0 +1 @@ +CONSOLE_SPEED=115200 diff --git a/device/tencent/x86_64-tencent_tcs9400-r0/led_proc_init.soc b/device/tencent/x86_64-tencent_tcs9400-r0/led_proc_init.soc new file mode 100755 index 000000000000..2f79a8febf86 --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs9400-r0/led_proc_init.soc @@ -0,0 +1,6 @@ + +led auto on + +led start + +linkscan SwPortBitMap=all diff --git a/device/tencent/x86_64-tencent_tcs9400-r0/monitor.py b/device/tencent/x86_64-tencent_tcs9400-r0/monitor.py new file mode 100755 index 000000000000..acaf9b4a8c65 --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs9400-r0/monitor.py @@ -0,0 +1,431 @@ +#!/usr/bin/python3 +# * onboard temperature sensors +# * FAN trays +# * PSU +# +import os +import xml.etree.ElementTree as ET +import glob +from fru import ipmifru +from decimal import Decimal + + +MAILBOX_DIR = "/sys/bus/i2c/devices/" +BOARD_ID_PATH = "/sys/module/ruijie_common/parameters/dfd_my_type" + +CONFIG_NAME = "dev.xml" + +def byteTostr(val): + strtmp = '' + for i in range(len(val)): + strtmp += chr(val[i]) + return strtmp + + +def typeTostr(val): + if isinstance(val, bytes): + strtmp = byteTostr(val) + return strtmp + return val + + +def get_board_id(): + if not os.path.exists(BOARD_ID_PATH): + return "NA" + with open(BOARD_ID_PATH) as fd: + id_str = fd.read().strip() + return "0x%x" % (int(id_str, 10)) + + +def dev_file_read(path, offset, read_len): + retval = "ERR" + val_list = [] + msg = "" + ret = "" + fd = -1 + + if not os.path.exists(path): + return False, "%s %s not found" % (retval, path) + + try: + fd = os.open(path, os.O_RDONLY) + os.lseek(fd, offset, os.SEEK_SET) + ret = os.read(fd, read_len) + for item in ret: + val_list.append(item) + except Exception as e: + msg = str(e) + return False, "%s %s" % (retval, msg) + finally: + if fd > 0: + os.close(fd) + return True, val_list + + +def getPMCreg(location): + retval = 'ERR' + if (not os.path.isfile(location)): + return "%s %s notfound"% (retval , location) + try: + with open(location, 'r') as fd: + retval = fd.read() + except Exception as error: + return "ERR %s" % str(error) + + retval = retval.rstrip('\r\n') + retval = retval.lstrip(" ") + return retval + + +# Get a mailbox register +def get_pmc_register(reg_name): + retval = 'ERR' + mb_reg_file = reg_name + filepath = glob.glob(mb_reg_file) + if(len(filepath) == 0): + return "%s %s notfound"% (retval , mb_reg_file) + mb_reg_file = filepath[0] + if (not os.path.isfile(mb_reg_file)): + #print mb_reg_file, 'not found !' + return "%s %s notfound"% (retval , mb_reg_file) + try: + with open(mb_reg_file, 'rb') as fd: + retval = fd.read() + retval = typeTostr(retval) + except Exception as error: + retval = "%s %s read failed, msg: %s" % (retval, mb_reg_file, str(error)) + + retval = retval.rstrip('\r\n') + retval = retval.lstrip(" ") + return retval + + +class checktype(): + def __init__(self, test1): + self.test1 = test1 + + @staticmethod + def check(name,location, bit, value, tips , err1): + psu_status = int(get_pmc_register(location),16) + val = (psu_status & (1<< bit)) >> bit + if (val != value): + err1["errmsg"] = tips + err1["code"] = -1 + return -1 + else: + err1["errmsg"] = "none" + err1["code"] = 0 + return 0 + + @staticmethod + def getValue(location, bit , type, coefficient = 1, addend = 0): + try: + value_t = get_pmc_register(location) + if value_t.startswith("ERR") : + return value_t + if (type == 1): + return float('%.1f' % ((float(value_t)/1000) + addend)) + elif (type == 2): + return float('%.1f' % (float(value_t)/100)) + elif (type == 3): + psu_status = int(value_t,16) + return (psu_status & (1<< bit)) >> bit + elif (type == 4): + return int(value_t,10) + elif (type == 5): + return float('%.1f' % (float(value_t)/1000/1000)) + elif (type == 6): + return Decimal(float(value_t)*coefficient/1000).quantize(Decimal('0.000')) + else: + return value_t + except Exception as e: + value_t = "ERR %s" % str(e) + return value_t + + #######temp + @staticmethod + def getTemp(self, name, location , ret_t): + ret2 = self.getValue(location + "temp1_input" ," " ,1); + ret3 = self.getValue(location + "temp1_max" ," ", 1); + ret4 = self.getValue(location + "temp1_max_hyst" ," ", 1); + ret_t["temp1_input"] = ret2 + ret_t["temp1_max"] = ret3 + ret_t["temp1_max_hyst"] = ret4 + + @staticmethod + def getLM75(name, location, result): + c1=checktype + r1={} + c1.getTemp(c1, name, location, r1) + result[name] = r1 + + ##########fanFRU + @staticmethod + def decodeBinByValue(retval): + fru = ipmifru() + fru.decodeBin(retval) + return fru + + @staticmethod + def printbinvalue(b): + index = 0 + print(" ",) + for width in range(16): + print("%02x " % width,) + print("") + for i in range(0, len(b)): + if index % 16 == 0: + print(" ") + print(" %02x " % i,) + print("%02x " % ord(b[i]),) + index += 1 + print("") + + @staticmethod + def getfruValue(prob_t, root, val): + try: + ret, binval_bytes = dev_file_read(val, 0, 256) + if ret == False: + return binval_bytes + binval = byteTostr(binval_bytes) + fanpro = {} + ret = checktype.decodeBinByValue(binval) + fanpro['fan_type'] = ret.productInfoArea.productName + fanpro['hw_version'] = ret.productInfoArea.productVersion + fanpro['sn'] = ret.productInfoArea.productSerialNumber + fanpro['fanid'] = ret.productInfoArea.productextra2 + fan_display_name_dict = status.getDecodValue(root, "fan_display_name") + fan_name = fanpro['fan_type'].strip() + if len(fan_display_name_dict) == 0: + return fanpro + if fan_name not in fan_display_name_dict.keys(): + prob_t['errcode']= -1 + prob_t['errmsg'] = '%s'% ("ERR fan name: %s not support" % fan_name) + else: + fanpro['fan_type'] = fan_display_name_dict[fan_name] + return fanpro + except Exception as error: + return "ERR " + str(error) + + @staticmethod + def getslotfruValue(val): + try: + binval = checktype.getValue(val, 0 , 0) + if binval.startswith("ERR"): + return binval + slotpro = {} + ret = checktype.decodeBinByValue(binval) + slotpro['slot_type'] = ret.boardInfoArea.boardProductName + slotpro['hw_version'] = ret.boardInfoArea.boardextra1 + slotpro['sn'] = ret.boardInfoArea.boardSerialNumber + return slotpro + except Exception as error: + return "ERR " + str(error) + + @staticmethod + def getpsufruValue(prob_t, root, val): + try: + psu_match = False + binval = checktype.getValue(val, 0 , 0) + if binval.startswith("ERR"): + return binval + psupro = {} + ret = checktype.decodeBinByValue(binval) + psupro['type1'] = ret.productInfoArea.productPartModelName + psupro['sn'] = ret.productInfoArea.productSerialNumber + psupro['hw_version'] = ret.productInfoArea.productVersion + psu_dict = status.getDecodValue(root, "psutype") + psupro['type1'] = psupro['type1'].strip() + if len(psu_dict) == 0: + return psupro + for psu_name in psu_dict.keys(): + if psu_name in psupro['type1']: + psupro['type1'] = psu_dict[psu_name] + psu_match = True + break + if psu_match is not True: + prob_t['errcode']= -1 + prob_t['errmsg'] = '%s'% ("ERR psu name: %s not support" % psupro['type1']) + return psupro + except Exception as error: + return "ERR " + str(error) + +class status(): + def __init__(self, productname): + self.productname = productname + + @staticmethod + def getETroot(filename): + tree = ET.parse(filename) + root = tree.getroot() + return root; + + @staticmethod + def getDecodValue(collection, decode): + decodes = collection.find('decode') + testdecode = decodes.find(decode) + test={} + if testdecode is None: + return test + for neighbor in testdecode.iter('code'): + test[neighbor.attrib["key"]]=neighbor.attrib["value"] + return test + + @staticmethod + def getfileValue(location): + return checktype.getValue(location," "," ") + + @staticmethod + def getETValue(a, filename, tagname): + root = status.getETroot(filename) + for neighbor in root.iter(tagname): + prob_t = {} + prob_t = neighbor.attrib + prob_t['errcode']= 0 + prob_t['errmsg'] = '' + for pros in neighbor.iter("property"): + ret = dict(list(neighbor.attrib.items()) + list(pros.attrib.items())) + if ret.get('e2type') == 'fru' and ret.get("name") == "fru": + fruval = checktype.getfruValue(prob_t, root, ret["location"]) + if isinstance(fruval, str) and fruval.startswith("ERR"): + prob_t['errcode']= -1 + prob_t['errmsg']= fruval + break + else: + prob_t.update(fruval) + continue + + if ret.get("name") == "psu" and ret.get('e2type') == 'fru': + psuval = checktype.getpsufruValue(prob_t, root, ret["location"]) + if isinstance(psuval, str) and psuval.startswith("ERR"): + prob_t['errcode']= -1 + prob_t['errmsg']= psuval + break + else: + prob_t.update(psuval) + continue + + if ret.get("gettype") == "config": + prob_t[ret["name"]] = ret["value"] + continue + + if ('type' not in ret.keys()): + val = "0"; + else: + val = ret["type"] + if ('bit' not in ret.keys()): + bit = "0"; + else: + bit = ret["bit"] + if ('coefficient' not in ret.keys()): + coefficient = 1; + else: + coefficient = float(ret["coefficient"]) + if ('addend' not in ret.keys()): + addend = 0; + else: + addend = float(ret["addend"]) + + s = checktype.getValue(ret["location"], int(bit),int(val), coefficient, addend) + if isinstance(s, str) and s.startswith("ERR"): + prob_t['errcode']= -1 + prob_t['errmsg']= s + break + if ('default' in ret.keys()): + rt = status.getDecodValue(root,ret['decode']) + prob_t['errmsg']= rt[str(s)] + if str(s) != ret["default"]: + prob_t['errcode']= -1 + break + else: + if ('decode' in ret.keys()): + rt = status.getDecodValue(root,ret['decode']) + if(ret['decode'] == "psutype" and s.replace("\x00","").rstrip() not in rt.keys()): + prob_t['errcode']= -1 + prob_t['errmsg'] = '%s' % ("ERR psu name: %s not support" % (s.replace("\x00","").rstrip())) + else: + s = rt[str(s).replace("\x00","").rstrip()] + name = ret["name"] + prob_t[name]=str(s) + a.append(prob_t) + + @staticmethod + def getCPUValue(a, filename, tagname): + root = status.getETroot(filename) + for neighbor in root.iter(tagname): + location = neighbor.attrib["location"] + L=[] + for dirpath, dirnames, filenames in os.walk(location): + for file in filenames : + if file.endswith("input"): + L.append(os.path.join(dirpath, file)) + L =sorted(L,reverse=False) + for i in range(len(L)): + prob_t = {} + prob_t["name"] = getPMCreg("%s/temp%d_label"%(location,i+1)) + prob_t["temp"] = float(getPMCreg("%s/temp%d_input"%(location,i+1)))/1000 + prob_t["alarm"] = float(getPMCreg("%s/temp%d_crit_alarm"%(location,i+1)))/1000 + prob_t["crit"] = float(getPMCreg("%s/temp%d_crit"%(location,i+1)))/1000 + prob_t["max"] = float(getPMCreg("%s/temp%d_max"%(location,i+1)))/1000 + a.append(prob_t) + + @staticmethod + def getFileName(): + fpath = os.path.dirname(os.path.realpath(__file__)) + board_id = get_board_id() + dev_id_xml = fpath + "/" + "dev_%s.xml" % board_id + if os.path.exists(dev_id_xml): + return dev_id_xml + return fpath + "/"+ CONFIG_NAME + + @staticmethod + def getFan(ret): + _filename = status.getFileName() + _tagname = "fan" + status.getvalue(ret, _filename, _tagname) + + + @staticmethod + def checkFan(ret): + _filename = status.getFileName() + # _filename = "/usr/local/bin/" + status.getFileName() + _tagname = "fan" + status.getETValue(ret, _filename, _tagname) + + @staticmethod + def getTemp(ret): + _filename = status.getFileName() + #_filename = "/usr/local/bin/" + status.getFileName() + _tagname = "temp" + status.getETValue(ret, _filename, _tagname) + + @staticmethod + def getPsu(ret): + _filename = status.getFileName() + # _filename = "/usr/local/bin/" + status.getFileName() + _tagname = "psu" + status.getETValue(ret, _filename, _tagname) + + @staticmethod + def getcputemp(ret): + _filename = status.getFileName() + _tagname = "cpus" + status.getCPUValue(ret, _filename, _tagname) + + @staticmethod + def getDcdc(ret): + _filename = status.getFileName() + _tagname = "dcdc" + status.getETValue(ret, _filename, _tagname) + + @staticmethod + def getmactemp(ret): + _filename = status.getFileName() + _tagname = "mactemp" + status.getETValue(ret, _filename, _tagname) + + @staticmethod + def getmacpower(ret): + _filename = status.getFileName() + _tagname = "macpower" + status.getETValue(ret, _filename, _tagname) diff --git a/device/tencent/x86_64-tencent_tcs9400-r0/platform_asic b/device/tencent/x86_64-tencent_tcs9400-r0/platform_asic new file mode 100755 index 000000000000..960467652765 --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs9400-r0/platform_asic @@ -0,0 +1 @@ +broadcom diff --git a/device/tencent/x86_64-tencent_tcs9400-r0/platform_env.conf b/device/tencent/x86_64-tencent_tcs9400-r0/platform_env.conf new file mode 100644 index 000000000000..74e9293b382e --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs9400-r0/platform_env.conf @@ -0,0 +1,2 @@ +SYNCD_SHM_SIZE=1g +is_ltsw_chip=1 \ No newline at end of file diff --git a/dockers/docker-base-bullseye/Dockerfile.j2 b/dockers/docker-base-bullseye/Dockerfile.j2 index c237015500df..bbf86034687b 100644 --- a/dockers/docker-base-bullseye/Dockerfile.j2 +++ b/dockers/docker-base-bullseye/Dockerfile.j2 @@ -30,6 +30,7 @@ COPY ["dpkg_01_drop", "/etc/dpkg/dpkg.cfg.d/01_drop"] COPY ["sources.list.{{ CONFIGURED_ARCH }}", "/etc/apt/sources.list"] COPY ["no_install_recommend_suggest", "/etc/apt/apt.conf.d"] COPY ["no-check-valid-until", "/etc/apt/apt.conf.d"] +COPY ["apt-multiple-retries", "/etc/apt/apt.conf.d"] # Update apt cache and # pre-install fundamental packages @@ -80,7 +81,7 @@ RUN pip3 install supervisor==4.2.1 # Add support for supervisord to handle startup dependencies RUN pip3 install supervisord-dependent-startup==1.4.0 -RUN mkdir -p /etc/supervisor /var/log/supervisor +RUN mkdir -p /var/log/supervisor /etc/supervisor/conf.d RUN apt-get -y purge \ exim4 \ @@ -103,10 +104,10 @@ RUN apt-get clean -y && \ apt-get autoremove -y && \ rm -rf /var/lib/apt/lists/* /tmp/* ~/.cache -COPY ["etc/rsyslog.conf", "/etc/rsyslog.conf"] COPY ["etc/rsyslog.d/*", "/etc/rsyslog.d/"] COPY ["root/.vimrc", "/root/.vimrc"] RUN ln /usr/bin/vim.tiny /usr/bin/vim COPY ["etc/supervisor/supervisord.conf", "/etc/supervisor/"] +COPY ["etc/supervisor/containercfgd.conf", "/etc/supervisor/conf.d/"] diff --git a/dockers/docker-base-bullseye/apt-multiple-retries b/dockers/docker-base-bullseye/apt-multiple-retries new file mode 100644 index 000000000000..c4c638252f92 --- /dev/null +++ b/dockers/docker-base-bullseye/apt-multiple-retries @@ -0,0 +1,4 @@ +# Instruct apt to retry downloads on failures +# This is required only for bullseye. + +Acquire::Retries "3"; diff --git a/dockers/docker-base-bullseye/etc/supervisor/containercfgd.conf b/dockers/docker-base-bullseye/etc/supervisor/containercfgd.conf new file mode 100644 index 000000000000..704b5490c3fb --- /dev/null +++ b/dockers/docker-base-bullseye/etc/supervisor/containercfgd.conf @@ -0,0 +1,9 @@ +[program:containercfgd] +command=python3 /usr/local/bin/containercfgd +priority=99 +autostart=false +autorestart=unexpected +stdout_logfile=syslog +stderr_logfile=syslog +dependent_startup=true +dependent_startup_wait_for=rsyslogd:running diff --git a/dockers/docker-base-buster/Dockerfile.j2 b/dockers/docker-base-buster/Dockerfile.j2 index 6977b44d3412..3b76ef691718 100644 --- a/dockers/docker-base-buster/Dockerfile.j2 +++ b/dockers/docker-base-buster/Dockerfile.j2 @@ -94,7 +94,7 @@ RUN pip3 install supervisor==4.2.1 # Add support for supervisord to handle startup dependencies RUN pip3 install supervisord-dependent-startup==1.4.0 -RUN mkdir -p /etc/supervisor /var/log/supervisor +RUN mkdir -p /var/log/supervisor /etc/supervisor/conf.d RUN apt-get -y purge \ exim4 \ @@ -117,10 +117,10 @@ RUN apt-get clean -y && \ apt-get autoremove -y && \ rm -rf /var/lib/apt/lists/* /tmp/* ~/.cache/ -COPY ["etc/rsyslog.conf", "/etc/rsyslog.conf"] COPY ["etc/rsyslog.d/*", "/etc/rsyslog.d/"] COPY ["root/.vimrc", "/root/.vimrc"] RUN ln /usr/bin/vim.tiny /usr/bin/vim COPY ["etc/supervisor/supervisord.conf", "/etc/supervisor/"] +COPY ["etc/supervisor/containercfgd.conf", "/etc/supervisor/conf.d/"] diff --git a/dockers/docker-base-buster/etc/rsyslog.conf b/dockers/docker-base-buster/etc/rsyslog.conf deleted file mode 100644 index ef249229ab1e..000000000000 --- a/dockers/docker-base-buster/etc/rsyslog.conf +++ /dev/null @@ -1,76 +0,0 @@ -# -# /etc/rsyslog.conf Configuration file for rsyslog. -# -# For more information see -# /usr/share/doc/rsyslog-doc/html/rsyslog_conf.html - - -################# -#### MODULES #### -################# - -$ModLoad imuxsock # provides support for local system logging - -# -# Set a rate limit on messages from the container -# -$SystemLogRateLimitInterval 300 -$SystemLogRateLimitBurst 20000 - -#$ModLoad imklog # provides kernel logging support -#$ModLoad immark # provides --MARK-- message capability - -# provides UDP syslog reception -#$ModLoad imudp -#$UDPServerRun 514 - -# provides TCP syslog reception -#$ModLoad imtcp -#$InputTCPServerRun 514 - - -########################### -#### GLOBAL DIRECTIVES #### -########################### - -# Set remote syslog server -template (name="ForwardFormatInContainer" type="string" string="<%PRI%>%TIMESTAMP:::date-rfc3339% %HOSTNAME% %syslogtag%%msg:::sp-if-no-1st-sp%%msg%") -*.* action(type="omfwd" target="127.0.0.1" port="514" protocol="udp" Template="ForwardFormatInContainer") - -# -# Use traditional timestamp format. -# To enable high precision timestamps, comment out the following line. -# -#$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat - -# Define a custom template -$template SONiCFileFormat,"%TIMESTAMP%.%timestamp:::date-subseconds% %HOSTNAME% %syslogseverity-text:::uppercase% %syslogtag%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n" -$ActionFileDefaultTemplate SONiCFileFormat - -# -# Set the default permissions for all log files. -# -$FileOwner root -$FileGroup adm -$FileCreateMode 0640 -$DirCreateMode 0755 -$Umask 0022 - -# -# Where to place spool and state files -# -$WorkDirectory /var/spool/rsyslog - -# -# Include all config files in /etc/rsyslog.d/ -# -$IncludeConfig /etc/rsyslog.d/*.conf - -# -# Suppress duplicate messages and report "message repeated n times" -# -$RepeatedMsgReduction on - -############### -#### RULES #### -############### diff --git a/dockers/docker-base-buster/etc/supervisor/containercfgd.conf b/dockers/docker-base-buster/etc/supervisor/containercfgd.conf new file mode 100644 index 000000000000..704b5490c3fb --- /dev/null +++ b/dockers/docker-base-buster/etc/supervisor/containercfgd.conf @@ -0,0 +1,9 @@ +[program:containercfgd] +command=python3 /usr/local/bin/containercfgd +priority=99 +autostart=false +autorestart=unexpected +stdout_logfile=syslog +stderr_logfile=syslog +dependent_startup=true +dependent_startup_wait_for=rsyslogd:running diff --git a/dockers/docker-base-stretch/Dockerfile.j2 b/dockers/docker-base-stretch/Dockerfile.j2 index 9e11c4ea35f0..5db96e37ba0b 100644 --- a/dockers/docker-base-stretch/Dockerfile.j2 +++ b/dockers/docker-base-stretch/Dockerfile.j2 @@ -90,7 +90,7 @@ RUN pip install supervisor>=3.4.0 # Add support for supervisord to handle startup dependencies RUN pip install supervisord-dependent-startup==1.4.0 -RUN mkdir -p /etc/supervisor /var/log/supervisor +RUN mkdir -p /var/log/supervisor /etc/supervisor/conf.d RUN apt-get -y purge \ exim4 \ @@ -113,10 +113,10 @@ RUN apt-get clean -y && \ apt-get autoremove -y && \ rm -rf /var/lib/apt/lists/* /tmp/* -COPY ["etc/rsyslog.conf", "/etc/rsyslog.conf"] COPY ["etc/rsyslog.d/*", "/etc/rsyslog.d/"] COPY ["root/.vimrc", "/root/.vimrc"] RUN ln /usr/bin/vim.tiny /usr/bin/vim COPY ["etc/supervisor/supervisord.conf", "/etc/supervisor/"] +COPY ["etc/supervisor/containercfgd.conf", "/etc/supervisor/conf.d/"] diff --git a/dockers/docker-base-stretch/etc/rsyslog.conf b/dockers/docker-base-stretch/etc/rsyslog.conf deleted file mode 100644 index ef249229ab1e..000000000000 --- a/dockers/docker-base-stretch/etc/rsyslog.conf +++ /dev/null @@ -1,76 +0,0 @@ -# -# /etc/rsyslog.conf Configuration file for rsyslog. -# -# For more information see -# /usr/share/doc/rsyslog-doc/html/rsyslog_conf.html - - -################# -#### MODULES #### -################# - -$ModLoad imuxsock # provides support for local system logging - -# -# Set a rate limit on messages from the container -# -$SystemLogRateLimitInterval 300 -$SystemLogRateLimitBurst 20000 - -#$ModLoad imklog # provides kernel logging support -#$ModLoad immark # provides --MARK-- message capability - -# provides UDP syslog reception -#$ModLoad imudp -#$UDPServerRun 514 - -# provides TCP syslog reception -#$ModLoad imtcp -#$InputTCPServerRun 514 - - -########################### -#### GLOBAL DIRECTIVES #### -########################### - -# Set remote syslog server -template (name="ForwardFormatInContainer" type="string" string="<%PRI%>%TIMESTAMP:::date-rfc3339% %HOSTNAME% %syslogtag%%msg:::sp-if-no-1st-sp%%msg%") -*.* action(type="omfwd" target="127.0.0.1" port="514" protocol="udp" Template="ForwardFormatInContainer") - -# -# Use traditional timestamp format. -# To enable high precision timestamps, comment out the following line. -# -#$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat - -# Define a custom template -$template SONiCFileFormat,"%TIMESTAMP%.%timestamp:::date-subseconds% %HOSTNAME% %syslogseverity-text:::uppercase% %syslogtag%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n" -$ActionFileDefaultTemplate SONiCFileFormat - -# -# Set the default permissions for all log files. -# -$FileOwner root -$FileGroup adm -$FileCreateMode 0640 -$DirCreateMode 0755 -$Umask 0022 - -# -# Where to place spool and state files -# -$WorkDirectory /var/spool/rsyslog - -# -# Include all config files in /etc/rsyslog.d/ -# -$IncludeConfig /etc/rsyslog.d/*.conf - -# -# Suppress duplicate messages and report "message repeated n times" -# -$RepeatedMsgReduction on - -############### -#### RULES #### -############### diff --git a/dockers/docker-base-stretch/etc/supervisor/containercfgd.conf b/dockers/docker-base-stretch/etc/supervisor/containercfgd.conf new file mode 100644 index 000000000000..8d938e6f0ff3 --- /dev/null +++ b/dockers/docker-base-stretch/etc/supervisor/containercfgd.conf @@ -0,0 +1,9 @@ +[program:containercfgd] +command=python /usr/local/bin/containercfgd +priority=99 +autostart=false +autorestart=unexpected +stdout_logfile=syslog +stderr_logfile=syslog +dependent_startup=true +dependent_startup_wait_for=rsyslogd:running diff --git a/dockers/docker-base/Dockerfile.j2 b/dockers/docker-base/Dockerfile.j2 index 15df3fe8a754..cd839e6075e0 100644 --- a/dockers/docker-base/Dockerfile.j2 +++ b/dockers/docker-base/Dockerfile.j2 @@ -49,7 +49,6 @@ RUN apt-get -y install \ rsyslog \ less -COPY ["etc/rsyslog.conf", "/etc/rsyslog.conf"] COPY ["etc/rsyslog.d/*", "/etc/rsyslog.d/"] COPY ["root/.vimrc", "/root/.vimrc"] @@ -64,10 +63,11 @@ RUN pip install wheel # Install supervisor RUN pip install supervisor>=3.4.0 -RUN mkdir -p /etc/supervisor +RUN mkdir -p /etc/supervisor/conf.d RUN mkdir -p /var/log/supervisor COPY ["etc/supervisor/supervisord.conf", "/etc/supervisor/"] +COPY ["etc/supervisor/containercfgd.conf", "/etc/supervisor/conf.d/"] RUN apt-get -y purge \ exim4 \ diff --git a/dockers/docker-base/etc/rsyslog.conf b/dockers/docker-base/etc/rsyslog.conf deleted file mode 100644 index 4851ac784475..000000000000 --- a/dockers/docker-base/etc/rsyslog.conf +++ /dev/null @@ -1,80 +0,0 @@ -############################################################################### -# Managed by Ansible -# file: ansible/roles/acs/templates/rsyslog.conf.j2 -############################################################################### -# -# /etc/rsyslog.conf Configuration file for rsyslog. -# -# For more information see -# /usr/share/doc/rsyslog-doc/html/rsyslog_conf.html - - -################# -#### MODULES #### -################# - -$ModLoad imuxsock # provides support for local system logging - -# -# Set a rate limit on messages from the container -# -$SystemLogRateLimitInterval 300 -$SystemLogRateLimitBurst 20000 - -#$ModLoad imklog # provides kernel logging support -#$ModLoad immark # provides --MARK-- message capability - -# provides UDP syslog reception -#$ModLoad imudp -#$UDPServerRun 514 - -# provides TCP syslog reception -#$ModLoad imtcp -#$InputTCPServerRun 514 - - -########################### -#### GLOBAL DIRECTIVES #### -########################### - -# Set remote syslog server -template (name="ForwardFormatInContainer" type="string" string="<%PRI%>%TIMESTAMP:::date-rfc3339% %HOSTNAME% %syslogtag%%msg:::sp-if-no-1st-sp%%msg%") -*.* action(type="omfwd" target="127.0.0.1" port="514" protocol="udp" Template="ForwardFormatInContainer") - -# -# Use traditional timestamp format. -# To enable high precision timestamps, comment out the following line. -# -#$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat - -# Define a custom template -$template SONiCFileFormat,"%TIMESTAMP%.%timestamp:::date-subseconds% %HOSTNAME% %syslogseverity-text:::uppercase% %syslogtag%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n" -$ActionFileDefaultTemplate SONiCFileFormat - -# -# Set the default permissions for all log files. -# -$FileOwner root -$FileGroup adm -$FileCreateMode 0640 -$DirCreateMode 0755 -$Umask 0022 - -# -# Where to place spool and state files -# -$WorkDirectory /var/spool/rsyslog - -# -# Include all config files in /etc/rsyslog.d/ -# -$IncludeConfig /etc/rsyslog.d/*.conf - -# -# Suppress duplicate messages and report "message repeated n times" -# -$RepeatedMsgReduction on - -############### -#### RULES #### -############### diff --git a/dockers/docker-base/etc/supervisor/containercfgd.conf b/dockers/docker-base/etc/supervisor/containercfgd.conf new file mode 100644 index 000000000000..8d938e6f0ff3 --- /dev/null +++ b/dockers/docker-base/etc/supervisor/containercfgd.conf @@ -0,0 +1,9 @@ +[program:containercfgd] +command=python /usr/local/bin/containercfgd +priority=99 +autostart=false +autorestart=unexpected +stdout_logfile=syslog +stderr_logfile=syslog +dependent_startup=true +dependent_startup_wait_for=rsyslogd:running diff --git a/dockers/docker-database/Dockerfile.j2 b/dockers/docker-database/Dockerfile.j2 index 899c111da41b..f5a8ec083675 100644 --- a/dockers/docker-database/Dockerfile.j2 +++ b/dockers/docker-database/Dockerfile.j2 @@ -2,7 +2,6 @@ FROM docker-config-engine-bullseye-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} ARG docker_container_name -RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf # Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive @@ -37,12 +36,12 @@ RUN apt-get clean -y && \ ' /etc/redis/redis.conf COPY ["supervisord.conf.j2", "/usr/share/sonic/templates/"] +COPY ["critical_processes.j2", "/usr/share/sonic/templates/"] COPY ["docker-database-init.sh", "/usr/local/bin/"] COPY ["database_config.json.j2", "/usr/share/sonic/templates/"] COPY ["database_global.json.j2", "/usr/share/sonic/templates/"] COPY ["files/supervisor-proc-exit-listener", "/usr/bin"] COPY ["files/sysctl-net.conf", "/etc/sysctl.d/"] -COPY ["critical_processes", "/etc/supervisor"] COPY ["files/update_chassisdb_config", "/usr/local/bin/"] COPY ["flush_unused_database", "/usr/local/bin/"] diff --git a/dockers/docker-database/critical_processes b/dockers/docker-database/critical_processes deleted file mode 100644 index 53a45931dfc9..000000000000 --- a/dockers/docker-database/critical_processes +++ /dev/null @@ -1 +0,0 @@ -program:redis diff --git a/dockers/docker-database/critical_processes.j2 b/dockers/docker-database/critical_processes.j2 new file mode 100644 index 000000000000..1f524132e938 --- /dev/null +++ b/dockers/docker-database/critical_processes.j2 @@ -0,0 +1,5 @@ +{% if INSTANCES %} +{% for redis_inst, redis_items in INSTANCES.items() %} +program:{{ redis_inst }} +{%- endfor %} +{%- endif %} diff --git a/dockers/docker-database/docker-database-init.sh b/dockers/docker-database/docker-database-init.sh index 9b92b5890c2d..e2c3fcb727d2 100755 --- a/dockers/docker-database/docker-database-init.sh +++ b/dockers/docker-database/docker-database-init.sh @@ -52,6 +52,7 @@ if [[ $DATABASE_TYPE == "chassisdb" ]]; then update_chassisdb_config -j $db_cfg_file_tmp -k -p $chassis_db_port # generate all redis server supervisord configuration file sonic-cfggen -j $db_cfg_file_tmp -t /usr/share/sonic/templates/supervisord.conf.j2 > /etc/supervisor/conf.d/supervisord.conf + sonic-cfggen -j $db_cfg_file_tmp -t /usr/share/sonic/templates/critical_processes.j2 > /etc/supervisor/critical_processes rm $db_cfg_file_tmp exec /usr/local/bin/supervisord exit 0 @@ -69,6 +70,7 @@ fi # delete chassisdb config to generate supervisord config update_chassisdb_config -j $db_cfg_file_tmp -d sonic-cfggen -j $db_cfg_file_tmp -t /usr/share/sonic/templates/supervisord.conf.j2 > /etc/supervisor/conf.d/supervisord.conf +sonic-cfggen -j $db_cfg_file_tmp -t /usr/share/sonic/templates/critical_processes.j2 > /etc/supervisor/critical_processes if [[ "$start_chassis_db" != "1" ]] && [[ -z "$chassis_db_address" ]]; then cp $db_cfg_file_tmp $db_cfg_file diff --git a/dockers/docker-database/supervisord.conf.j2 b/dockers/docker-database/supervisord.conf.j2 index b063016eb68a..c73c6e783e81 100644 --- a/dockers/docker-database/supervisord.conf.j2 +++ b/dockers/docker-database/supervisord.conf.j2 @@ -3,6 +3,15 @@ logfile_maxbytes=1MB logfile_backups=2 nodaemon=true +[eventlistener:dependent-startup] +command=python3 -m supervisord_dependent_startup +autostart=true +autorestart=unexpected +startretries=0 +exitcodes=0,3 +events=PROCESS_STATE +buffer_size=1024 + [eventlistener:supervisor-proc-exit-listener] command=/usr/bin/supervisor-proc-exit-listener --container-name database events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING @@ -13,14 +22,15 @@ buffer_size=1024 [program:rsyslogd] command=/usr/sbin/rsyslogd -n -iNONE priority=1 -autostart=true +autostart=false autorestart=false stdout_logfile=syslog stderr_logfile=syslog +dependent_startup=true {% if INSTANCES %} {% for redis_inst, redis_items in INSTANCES.items() %} -[program: {{ redis_inst }}] +[program:{{ redis_inst }}] {% if redis_items['hostname'] != '127.0.0.1' and redis_inst != 'redis_chassis' %} {%- set LOOPBACK_IP = '127.0.0.1' -%} {%- else -%} @@ -28,17 +38,21 @@ stderr_logfile=syslog {%- endif -%} command=/bin/bash -c "{ [[ -s /var/lib/{{ redis_inst }}/dump.rdb ]] || rm -f /var/lib/{{ redis_inst }}/dump.rdb; } && mkdir -p /var/lib/{{ redis_inst }} && exec /usr/bin/redis-server /etc/redis/redis.conf --bind {{ LOOPBACK_IP }} {{ redis_items['hostname'] }} --port {{ redis_items['port'] }} --unixsocket {{ redis_items['unix_socket_path'] }} --pidfile /var/run/redis/{{ redis_inst }}.pid --dir /var/lib/{{ redis_inst }}" priority=2 -autostart=true +autostart=false autorestart=false stdout_logfile=syslog stderr_logfile=syslog +dependent_startup=true +dependent_startup_wait_for=rsyslogd:running {% endfor %} {% endif %} [program:flushdb] command=/bin/bash -c "sleep 300 && /usr/local/bin/flush_unused_database" priority=3 -autostart=true +autostart=false autorestart=false stdout_logfile=syslog stderr_logfile=syslog +dependent_startup=true +dependent_startup_wait_for=rsyslogd:running diff --git a/dockers/docker-dhcp-relay/Dockerfile.j2 b/dockers/docker-dhcp-relay/Dockerfile.j2 index 1cddd11b61dc..b09da75705c9 100644 --- a/dockers/docker-dhcp-relay/Dockerfile.j2 +++ b/dockers/docker-dhcp-relay/Dockerfile.j2 @@ -3,7 +3,6 @@ FROM docker-config-engine-bullseye-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} ARG docker_container_name ARG image_version -RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf # Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive diff --git a/dockers/docker-dhcp-relay/cli-plugin-tests/conftest.py b/dockers/docker-dhcp-relay/cli-plugin-tests/conftest.py index 4eb79edd0b60..5f0b981ccaee 100644 --- a/dockers/docker-dhcp-relay/cli-plugin-tests/conftest.py +++ b/dockers/docker-dhcp-relay/cli-plugin-tests/conftest.py @@ -10,18 +10,32 @@ def mock_cfgdb(): 'Vlan1000': { 'dhcp_servers': ['192.0.0.1'] } + }, + 'DHCP_RELAY': { + 'Vlan1000': { + 'dhcpv6_servers': ['fc02:2000::1'] + } } } def get_entry(table, key): + if table not in CONFIG or key not in CONFIG[table]: + return {} return CONFIG[table][key] def set_entry(table, key, data): CONFIG[table].setdefault(key, {}) - CONFIG[table][key] = data + + if data is None: + CONFIG[table].pop(key) + else: + CONFIG[table][key] = data + + def get_keys(table): + return CONFIG[table].keys() cfgdb.get_entry = mock.Mock(side_effect=get_entry) cfgdb.set_entry = mock.Mock(side_effect=set_entry) + cfgdb.get_keys = mock.Mock(side_effect=get_keys) yield cfgdb - diff --git a/dockers/docker-dhcp-relay/cli-plugin-tests/mock_config.py b/dockers/docker-dhcp-relay/cli-plugin-tests/mock_config.py index ed04367fbba7..1549e1937e09 100644 --- a/dockers/docker-dhcp-relay/cli-plugin-tests/mock_config.py +++ b/dockers/docker-dhcp-relay/cli-plugin-tests/mock_config.py @@ -1,6 +1,6 @@ -TEST_DATA = [ +COMMON_TEST_DATA = [ [ - "DHCPv6_Helpers", + "ipv6_with_header", { "config_db": { "DHCP_RELAY": { @@ -12,7 +12,123 @@ "dhcpv6_option|rfc6939_support": "true" } } - }, + } }, ], + [ + "ipv6_without_header", + { + "config_db": { + "DHCP_RELAY": { + "Vlan1000": { + "dhcpv6_servers": [ + "fc02:2000::1", + "fc02:2000::2" + ], + "dhcpv6_option|rfc6939_support": "true" + } + } + } + }, + ], + [ + "ipv4_with_header", + { + "config_db": { + "VLAN": { + "Vlan1000": { + "dhcp_servers": [ + "192.0.0.1", + "192.0.0.2" + ] + } + } + } + } + ] +] + +NEW_ADDED_TEST_DATA = [ + [ + "ipv6", + { + "config_db": { + "DHCP_RELAY": { + "Vlan1000": { + "dhcpv6_servers": [ + "fc02:2000::1", + "fc02:2000::2" + ], + "dhcpv6_option|rfc6939_support": "true" + } + } + } + }, + ], + [ + "ipv4", + { + "config_db": { + "VLAN": { + "Vlan1000": { + "dhcp_servers": [ + "192.0.0.1", + "192.0.0.2" + ] + }, + "Vlan1001": { + "vlanid": "1001" + } + } + } + } + ] +] + +MULTI_TEST_DATA = [ + [ + "ipv6", + { + "config_db": { + "DHCP_RELAY": { + "Vlan1000": { + "dhcpv6_servers": [ + "fc02:2000::1", + "fc02:2000::2" + ], + "dhcpv6_option|rfc6939_support": "true" + }, + "Vlan1001": { + "dhcpv6_servers": [ + "fc02:2000::3", + "fc02:2000::4" + ], + "dhcpv6_option|rfc6939_support": "true" + } + } + } + }, + ], + [ + "ipv4", + { + "config_db": { + "VLAN": { + "Vlan1000": { + "dhcp_servers": [ + "192.0.0.1", + "192.0.0.2" + ] + }, + "Vlan1001": { + "vlanid": "1001", + "dhcp_servers": [ + "192.0.0.3", + "192.0.0.4" + ] + } + } + } + } + ] ] diff --git a/dockers/docker-dhcp-relay/cli-plugin-tests/test_config_dhcp_relay.py b/dockers/docker-dhcp-relay/cli-plugin-tests/test_config_dhcp_relay.py index 46acda358b8f..a42d5cce7a8a 100644 --- a/dockers/docker-dhcp-relay/cli-plugin-tests/test_config_dhcp_relay.py +++ b/dockers/docker-dhcp-relay/cli-plugin-tests/test_config_dhcp_relay.py @@ -1,229 +1,302 @@ -import os import sys -import traceback +from utilities_common.db import Db from unittest import mock - from click.testing import CliRunner -from utilities_common.db import Db - import pytest - -sys.path.append('../cli/config/plugins/') +sys.path.append("../cli/config/plugins/") import dhcp_relay -config_vlan_add_dhcp_relay_output="""\ -Added DHCP relay destination addresses ['192.0.0.100'] to Vlan1000 -Restarting DHCP relay service... -""" - -config_vlan_add_dhcpv6_relay_output="""\ -Added DHCP relay destination addresses ['fc02:2000::1'] to Vlan1000 +config_dhcp_relay_add_output = """\ +Added DHCP relay address [{}] to Vlan1000 Restarting DHCP relay service... """ - -config_vlan_add_multiple_dhcpv6_relay_output="""\ -Added DHCP relay destination addresses ['fc02:2000::1', 'fc02:2000::2', 'fc02:2000::3'] to Vlan1000 +config_dhcp_relay_del_output = """\ +Removed DHCP relay address [{}] from Vlan1000 Restarting DHCP relay service... """ - -config_vlan_del_dhcp_relay_output="""\ -Removed DHCP relay destination addresses ('192.0.0.100',) from Vlan1000 -Restarting DHCP relay service... -""" - -config_vlan_del_dhcpv6_relay_output="""\ -Removed DHCP relay destination addresses ('fc02:2000::1',) from Vlan1000 -Restarting DHCP relay service... -""" - -config_vlan_del_multiple_dhcpv6_relay_output="""\ -Removed DHCP relay destination addresses ('fc02:2000::1', 'fc02:2000::2', 'fc02:2000::3') from Vlan1000 -Restarting DHCP relay service... -""" - -class TestConfigVlanDhcpRelay(object): +expected_dhcp_relay_add_config_db_output = { + "ipv4": { + "dhcp_servers": [ + "192.0.0.1", "192.0.0.3"] + }, + "ipv6": { + "dhcpv6_servers": [ + "fc02:2000::1", "fc02:2000::3"] + } +} +expected_dhcp_relay_del_config_db_output = { + "ipv4": { + "dhcp_servers": [ + "192.0.0.1" + ] + }, + "ipv6": { + "dhcpv6_servers": [ + "fc02:2000::1" + ] + } +} +expected_dhcp_relay_add_multi_config_db_output = { + "ipv4": { + "dhcp_servers": [ + "192.0.0.1", "192.0.0.3", "192.0.0.4", "192.0.0.5" + ] + }, + "ipv6": { + "dhcpv6_servers": [ + "fc02:2000::1", "fc02:2000::3", "fc02:2000::4", "fc02:2000::5" + ] + } +} + +IP_VER_TEST_PARAM_MAP = { + "ipv4": { + "command": "helper", + "ips": [ + "192.0.0.3", + "192.0.0.4", + "192.0.0.5" + ], + "exist_ip": "192.0.0.1", + "nonexist_ip": "192.0.0.2", + "invalid_ip": "192.0.0", + "table": "VLAN" + }, + "ipv6": { + "command": "destination", + "ips": [ + "fc02:2000::3", + "fc02:2000::4", + "fc02:2000::5" + ], + "exist_ip": "fc02:2000::1", + "nonexist_ip": "fc02:2000::2", + "invalid_ip": "fc02:2000:", + "table": "DHCP_RELAY" + } +} + + +@pytest.fixture(scope="module", params=["ipv4", "ipv6"]) +def ip_version(request): + """ + Parametrize Ip version + + Args: + request: pytest request object + + Returns: + Ip version needed for test case + """ + return request.param + + +@pytest.fixture(scope="module", params=["add", "del"]) +def op(request): + """ + Parametrize operate tpye + + Args: + request: pytest request object + + Returns: + Operate tpye + """ + return request.param + + +class TestConfigDhcpRelay(object): def test_plugin_registration(self): cli = mock.MagicMock() dhcp_relay.register(cli) - cli.commands['vlan'].add_command.assert_called_once_with(dhcp_relay.vlan_dhcp_relay) - def test_config_vlan_add_dhcp_relay_with_nonexist_vlanid(self): + def test_config_dhcp_relay_add_del_with_nonexist_vlanid_ipv4(self, op): runner = CliRunner() - with mock.patch('utilities_common.cli.run_command') as mock_run_command: - result = runner.invoke(dhcp_relay.vlan_dhcp_relay.commands["add"], - ["1001", "192.0.0.100"]) + ip_version = "ipv4" + with mock.patch("utilities_common.cli.run_command") as mock_run_command: + result = runner.invoke(dhcp_relay.dhcp_relay.commands[ip_version] + .commands[IP_VER_TEST_PARAM_MAP[ip_version]["command"]] + .commands[op], ["1001", IP_VER_TEST_PARAM_MAP[ip_version]["ips"][0]]) print(result.exit_code) - print(result.output) - # traceback.print_tb(result.exc_info[2]) + print(result.stdout) assert result.exit_code != 0 assert "Error: Vlan1001 doesn't exist" in result.output assert mock_run_command.call_count == 0 - def test_config_vlan_add_dhcp_relay_with_invalid_vlanid(self): + def test_config_dhcp_relay_del_with_nonexist_vlanid_ipv6(self): runner = CliRunner() - with mock.patch('utilities_common.cli.run_command') as mock_run_command: - result = runner.invoke(dhcp_relay.vlan_dhcp_relay.commands["add"], - ["4096", "192.0.0.100"]) + op = "del" + ip_version = "ipv6" + with mock.patch("utilities_common.cli.run_command") as mock_run_command: + result = runner.invoke(dhcp_relay.dhcp_relay.commands[ip_version] + .commands[IP_VER_TEST_PARAM_MAP[ip_version]["command"]] + .commands[op], ["1001", IP_VER_TEST_PARAM_MAP[ip_version]["ips"][0]]) print(result.exit_code) - print(result.output) - # traceback.print_tb(result.exc_info[2]) + print(result.stdout) assert result.exit_code != 0 - assert "Error: Vlan4096 doesn't exist" in result.output + assert "Error: Vlan1001 doesn't exist" in result.output assert mock_run_command.call_count == 0 - def test_config_vlan_add_dhcp_relay_with_invalid_ip(self, mock_cfgdb): + def test_config_add_del_dhcp_relay_with_invalid_ip(self, ip_version, op): runner = CliRunner() - db = Db() - db.cfgdb = mock_cfgdb - - with mock.patch('utilities_common.cli.run_command') as mock_run_command: - result = runner.invoke(dhcp_relay.vlan_dhcp_relay.commands["add"], - ["1000", "192.0.0.1000"], obj=db) - print(result.exit_code) - print(result.output) - # traceback.print_tb(result.exc_info[2]) - assert result.exit_code != 0 - assert "Error: 192.0.0.1000 is invalid IP address" in result.output - assert mock_run_command.call_count == 0 + invalid_ip = IP_VER_TEST_PARAM_MAP[ip_version]["invalid_ip"] - result = runner.invoke(dhcp_relay.vlan_dhcp_relay.commands["add"], - ["1000", "192.0.0."], obj=db) + with mock.patch("utilities_common.cli.run_command") as mock_run_command: + result = runner.invoke(dhcp_relay.dhcp_relay.commands[ip_version] + .commands[IP_VER_TEST_PARAM_MAP[ip_version]["command"]] + .commands[op], ["1000", invalid_ip]) print(result.exit_code) print(result.output) assert result.exit_code != 0 - assert "Error: 192.0.0. is invalid IP address" in result.output + assert "Error: {} is invalid IP address".format(invalid_ip) in result.output assert mock_run_command.call_count == 0 - def test_config_vlan_add_dhcp_relay_with_exist_ip(self, mock_cfgdb): + def test_config_add_dhcp_with_exist_ip(self, mock_cfgdb, ip_version): runner = CliRunner() db = Db() db.cfgdb = mock_cfgdb + exist_ip = IP_VER_TEST_PARAM_MAP[ip_version]["exist_ip"] - with mock.patch('utilities_common.cli.run_command') as mock_run_command: - result = runner.invoke(dhcp_relay.vlan_dhcp_relay.commands["add"], - ["1000", "192.0.0.1"], obj=db) + with mock.patch("utilities_common.cli.run_command") as mock_run_command: + result = runner.invoke(dhcp_relay.dhcp_relay.commands[ip_version] + .commands[IP_VER_TEST_PARAM_MAP[ip_version]["command"]] + .commands["add"], ["1000", exist_ip], obj=db) print(result.exit_code) print(result.output) assert result.exit_code == 0 - assert "192.0.0.1 is already a DHCP relay destination for Vlan1000" in result.output + assert "{} is already a DHCP relay for Vlan1000".format(exist_ip) in result.output assert mock_run_command.call_count == 0 - def test_config_vlan_add_del_dhcp_relay_dest(self, mock_cfgdb): + def test_config_del_nonexist_dhcp_relay(self, mock_cfgdb, ip_version): runner = CliRunner() db = Db() db.cfgdb = mock_cfgdb + nonexist_ip = IP_VER_TEST_PARAM_MAP[ip_version]["nonexist_ip"] - # add new relay dest - with mock.patch("utilities_common.cli.run_command") as mock_run_command: - result = runner.invoke(dhcp_relay.vlan_dhcp_relay.commands["add"], - ["1000", "192.0.0.100"], obj=db) - print(result.exit_code) - print(result.output) - assert result.exit_code == 0 - assert result.output == config_vlan_add_dhcp_relay_output - assert mock_run_command.call_count == 3 - db.cfgdb.set_entry.assert_called_once_with('VLAN', 'Vlan1000', {'dhcp_servers': ['192.0.0.1', '192.0.0.100']}) - - db.cfgdb.set_entry.reset_mock() - - # del relay dest with mock.patch("utilities_common.cli.run_command") as mock_run_command: - result = runner.invoke(dhcp_relay.vlan_dhcp_relay.commands["del"], - ["1000", "192.0.0.100"], obj=db) + result = runner.invoke(dhcp_relay.dhcp_relay.commands[ip_version] + .commands[IP_VER_TEST_PARAM_MAP[ip_version]["command"]] + .commands["del"], ["1000", nonexist_ip], obj=db) print(result.exit_code) print(result.output) - assert result.exit_code == 0 - assert result.output == config_vlan_del_dhcp_relay_output - assert mock_run_command.call_count == 3 - db.cfgdb.set_entry.assert_called_once_with('VLAN', 'Vlan1000', {'dhcp_servers': ['192.0.0.1']}) + assert result.exit_code != 0 + assert "Error: {} is not a DHCP relay for Vlan1000".format(nonexist_ip) in result.output + assert mock_run_command.call_count == 0 - def test_config_vlan_add_del_dhcpv6_relay_dest(self, mock_cfgdb): + def test_config_add_del_dhcp_relay(self, mock_cfgdb, ip_version): runner = CliRunner() db = Db() db.cfgdb = mock_cfgdb + test_ip = IP_VER_TEST_PARAM_MAP[ip_version]["ips"][0] + config_db_table = IP_VER_TEST_PARAM_MAP[ip_version]["table"] - # add new relay dest with mock.patch("utilities_common.cli.run_command") as mock_run_command: - result = runner.invoke(dhcp_relay.vlan_dhcp_relay.commands["add"], - ["1000", "fc02:2000::1"], obj=db) + # add new dhcp relay + result = runner.invoke(dhcp_relay.dhcp_relay.commands[ip_version] + .commands[IP_VER_TEST_PARAM_MAP[ip_version]["command"]] + .commands["add"], ["1000", test_ip], obj=db) print(result.exit_code) print(result.output) assert result.exit_code == 0 - assert result.output == config_vlan_add_dhcpv6_relay_output + assert result.output == config_dhcp_relay_add_output.format(test_ip) + assert db.cfgdb.get_entry(config_db_table, "Vlan1000") \ + == expected_dhcp_relay_add_config_db_output[ip_version] assert mock_run_command.call_count == 3 - db.cfgdb.set_entry.assert_called_once_with('VLAN', 'Vlan1000', {'dhcp_servers': ['192.0.0.1'], 'dhcpv6_servers': ['fc02:2000::1']}) + db.cfgdb.set_entry.assert_called_once_with(config_db_table, "Vlan1000", + expected_dhcp_relay_add_config_db_output[ip_version]) db.cfgdb.set_entry.reset_mock() - - # del relay dest + # del dhcp relay with mock.patch("utilities_common.cli.run_command") as mock_run_command: - result = runner.invoke(dhcp_relay.vlan_dhcp_relay.commands["del"], - ["1000", "fc02:2000::1"], obj=db) + result = runner.invoke(dhcp_relay.dhcp_relay.commands[ip_version] + .commands[IP_VER_TEST_PARAM_MAP[ip_version]["command"]] + .commands["del"], ["1000", test_ip], obj=db) print(result.exit_code) print(result.output) assert result.exit_code == 0 - assert result.output == config_vlan_del_dhcpv6_relay_output + assert result.output == config_dhcp_relay_del_output.format(test_ip) assert mock_run_command.call_count == 3 - db.cfgdb.set_entry.assert_called_once_with('VLAN', 'Vlan1000', {'dhcp_servers': ['192.0.0.1']}) + assert db.cfgdb.get_entry(config_db_table, "Vlan1000") \ + == expected_dhcp_relay_del_config_db_output[ip_version] + db.cfgdb.set_entry.assert_called_once_with(config_db_table, "Vlan1000", + expected_dhcp_relay_del_config_db_output[ip_version]) - def test_config_vlan_add_del_multiple_dhcpv6_relay_dest(self, mock_cfgdb): + def test_config_add_del_multiple_dhcp_relay(self, mock_cfgdb, ip_version): runner = CliRunner() db = Db() db.cfgdb = mock_cfgdb + test_ips = IP_VER_TEST_PARAM_MAP[ip_version]["ips"] + config_db_table = IP_VER_TEST_PARAM_MAP[ip_version]["table"] - # add new relay dest with mock.patch("utilities_common.cli.run_command") as mock_run_command: - result = runner.invoke(dhcp_relay.vlan_dhcp_relay.commands["add"], - ["1000", "fc02:2000::1", "fc02:2000::2", "fc02:2000::3"], obj=db) + # add new dhcp relay + result = runner.invoke(dhcp_relay.dhcp_relay.commands[ip_version] + .commands[IP_VER_TEST_PARAM_MAP[ip_version]["command"]] + .commands["add"], ["1000"] + test_ips, obj=db) print(result.exit_code) print(result.output) assert result.exit_code == 0 - assert result.output == config_vlan_add_multiple_dhcpv6_relay_output + assert result.output == config_dhcp_relay_add_output.format(",".join(test_ips)) + assert db.cfgdb.get_entry(config_db_table, "Vlan1000") \ + == expected_dhcp_relay_add_multi_config_db_output[ip_version] assert mock_run_command.call_count == 3 - db.cfgdb.set_entry.assert_called_once_with('VLAN', 'Vlan1000', {'dhcp_servers': ['192.0.0.1'], 'dhcpv6_servers': ['fc02:2000::1', 'fc02:2000::2', 'fc02:2000::3']}) + db.cfgdb.set_entry.assert_called_once_with(config_db_table, "Vlan1000", + expected_dhcp_relay_add_multi_config_db_output[ip_version]) db.cfgdb.set_entry.reset_mock() - - # del relay dest + # del dhcp relay with mock.patch("utilities_common.cli.run_command") as mock_run_command: - result = runner.invoke(dhcp_relay.vlan_dhcp_relay.commands["del"], - ["1000", "fc02:2000::1", "fc02:2000::2", "fc02:2000::3"], obj=db) + result = runner.invoke(dhcp_relay.dhcp_relay.commands[ip_version] + .commands[IP_VER_TEST_PARAM_MAP[ip_version]["command"]] + .commands["del"], ["1000"] + test_ips, obj=db) print(result.exit_code) print(result.output) assert result.exit_code == 0 - assert result.output == config_vlan_del_multiple_dhcpv6_relay_output + assert result.output == config_dhcp_relay_del_output.format(",".join(test_ips)) assert mock_run_command.call_count == 3 - db.cfgdb.set_entry.assert_called_once_with('VLAN', 'Vlan1000', {'dhcp_servers': ['192.0.0.1']}) + assert db.cfgdb.get_entry(config_db_table, "Vlan1000") \ + == expected_dhcp_relay_del_config_db_output[ip_version] + db.cfgdb.set_entry.assert_called_once_with(config_db_table, "Vlan1000", + expected_dhcp_relay_del_config_db_output[ip_version]) - def test_config_vlan_remove_nonexist_dhcp_relay_dest(self, mock_cfgdb): + def test_config_add_del_duplicate_dhcp_relay(self, mock_cfgdb, ip_version, op): runner = CliRunner() db = Db() db.cfgdb = mock_cfgdb + test_ip = IP_VER_TEST_PARAM_MAP[ip_version]["ips"][0] if op == "add" \ + else IP_VER_TEST_PARAM_MAP[ip_version]["exist_ip"] - with mock.patch('utilities_common.cli.run_command') as mock_run_command: - result = runner.invoke(dhcp_relay.vlan_dhcp_relay.commands["del"], - ["1000", "192.0.0.100"], obj=db) + with mock.patch("utilities_common.cli.run_command") as mock_run_command: + result = runner.invoke(dhcp_relay.dhcp_relay.commands[ip_version] + .commands[IP_VER_TEST_PARAM_MAP[ip_version]["command"]] + .commands[op], ["1000", test_ip, test_ip], obj=db) print(result.exit_code) print(result.output) - # traceback.print_tb(result.exc_info[2]) assert result.exit_code != 0 - assert "Error: 192.0.0.100 is not a DHCP relay destination for Vlan1000" in result.output + assert "Error: Find duplicate DHCP relay ip {} in {} list".format(test_ip, op) in result.output assert mock_run_command.call_count == 0 - def test_config_vlan_remove_dhcp_relay_dest_with_nonexist_vlanid(self, mock_cfgdb): + def test_config_add_dhcp_relay_ipv6_with_non_entry(self, mock_cfgdb): + op = "add" + ip_version = "ipv6" + test_ip = IP_VER_TEST_PARAM_MAP[ip_version]["ips"][0] runner = CliRunner() db = Db() db.cfgdb = mock_cfgdb + table = IP_VER_TEST_PARAM_MAP[ip_version]["table"] + db.cfgdb.set_entry(table, "Vlan1000", None) + assert db.cfgdb.get_entry(table, "Vlan1000") == {} + assert len(db.cfgdb.get_keys(table)) == 0 - with mock.patch('utilities_common.cli.run_command') as mock_run_command: - result = runner.invoke(dhcp_relay.vlan_dhcp_relay.commands["del"], - ["1001", "192.0.0.1"], obj=Db) + with mock.patch("utilities_common.cli.run_command") as mock_run_command: + result = runner.invoke(dhcp_relay.dhcp_relay.commands[ip_version] + .commands[IP_VER_TEST_PARAM_MAP[ip_version]["command"]] + .commands[op], ["1000", test_ip], obj=db) print(result.exit_code) print(result.output) - # traceback.print_tb(result.exc_info[2]) - assert result.exit_code != 0 - assert "Error: Vlan1001 doesn't exist" in result.output - assert mock_run_command.call_count == 0 + assert result.exit_code == 0 + assert db.cfgdb.get_entry(table, "Vlan1000") == {"dhcpv6_servers": [test_ip]} + assert mock_run_command.call_count == 3 diff --git a/dockers/docker-dhcp-relay/cli-plugin-tests/test_config_vlan_dhcp_relay.py b/dockers/docker-dhcp-relay/cli-plugin-tests/test_config_vlan_dhcp_relay.py new file mode 100644 index 000000000000..46acda358b8f --- /dev/null +++ b/dockers/docker-dhcp-relay/cli-plugin-tests/test_config_vlan_dhcp_relay.py @@ -0,0 +1,229 @@ +import os +import sys +import traceback +from unittest import mock + +from click.testing import CliRunner + +from utilities_common.db import Db + +import pytest + +sys.path.append('../cli/config/plugins/') +import dhcp_relay + +config_vlan_add_dhcp_relay_output="""\ +Added DHCP relay destination addresses ['192.0.0.100'] to Vlan1000 +Restarting DHCP relay service... +""" + +config_vlan_add_dhcpv6_relay_output="""\ +Added DHCP relay destination addresses ['fc02:2000::1'] to Vlan1000 +Restarting DHCP relay service... +""" + +config_vlan_add_multiple_dhcpv6_relay_output="""\ +Added DHCP relay destination addresses ['fc02:2000::1', 'fc02:2000::2', 'fc02:2000::3'] to Vlan1000 +Restarting DHCP relay service... +""" + +config_vlan_del_dhcp_relay_output="""\ +Removed DHCP relay destination addresses ('192.0.0.100',) from Vlan1000 +Restarting DHCP relay service... +""" + +config_vlan_del_dhcpv6_relay_output="""\ +Removed DHCP relay destination addresses ('fc02:2000::1',) from Vlan1000 +Restarting DHCP relay service... +""" + +config_vlan_del_multiple_dhcpv6_relay_output="""\ +Removed DHCP relay destination addresses ('fc02:2000::1', 'fc02:2000::2', 'fc02:2000::3') from Vlan1000 +Restarting DHCP relay service... +""" + +class TestConfigVlanDhcpRelay(object): + def test_plugin_registration(self): + cli = mock.MagicMock() + dhcp_relay.register(cli) + cli.commands['vlan'].add_command.assert_called_once_with(dhcp_relay.vlan_dhcp_relay) + + def test_config_vlan_add_dhcp_relay_with_nonexist_vlanid(self): + runner = CliRunner() + + with mock.patch('utilities_common.cli.run_command') as mock_run_command: + result = runner.invoke(dhcp_relay.vlan_dhcp_relay.commands["add"], + ["1001", "192.0.0.100"]) + print(result.exit_code) + print(result.output) + # traceback.print_tb(result.exc_info[2]) + assert result.exit_code != 0 + assert "Error: Vlan1001 doesn't exist" in result.output + assert mock_run_command.call_count == 0 + + def test_config_vlan_add_dhcp_relay_with_invalid_vlanid(self): + runner = CliRunner() + + with mock.patch('utilities_common.cli.run_command') as mock_run_command: + result = runner.invoke(dhcp_relay.vlan_dhcp_relay.commands["add"], + ["4096", "192.0.0.100"]) + print(result.exit_code) + print(result.output) + # traceback.print_tb(result.exc_info[2]) + assert result.exit_code != 0 + assert "Error: Vlan4096 doesn't exist" in result.output + assert mock_run_command.call_count == 0 + + def test_config_vlan_add_dhcp_relay_with_invalid_ip(self, mock_cfgdb): + runner = CliRunner() + db = Db() + db.cfgdb = mock_cfgdb + + with mock.patch('utilities_common.cli.run_command') as mock_run_command: + result = runner.invoke(dhcp_relay.vlan_dhcp_relay.commands["add"], + ["1000", "192.0.0.1000"], obj=db) + print(result.exit_code) + print(result.output) + # traceback.print_tb(result.exc_info[2]) + assert result.exit_code != 0 + assert "Error: 192.0.0.1000 is invalid IP address" in result.output + assert mock_run_command.call_count == 0 + + result = runner.invoke(dhcp_relay.vlan_dhcp_relay.commands["add"], + ["1000", "192.0.0."], obj=db) + print(result.exit_code) + print(result.output) + assert result.exit_code != 0 + assert "Error: 192.0.0. is invalid IP address" in result.output + assert mock_run_command.call_count == 0 + + def test_config_vlan_add_dhcp_relay_with_exist_ip(self, mock_cfgdb): + runner = CliRunner() + db = Db() + db.cfgdb = mock_cfgdb + + with mock.patch('utilities_common.cli.run_command') as mock_run_command: + result = runner.invoke(dhcp_relay.vlan_dhcp_relay.commands["add"], + ["1000", "192.0.0.1"], obj=db) + print(result.exit_code) + print(result.output) + assert result.exit_code == 0 + assert "192.0.0.1 is already a DHCP relay destination for Vlan1000" in result.output + assert mock_run_command.call_count == 0 + + def test_config_vlan_add_del_dhcp_relay_dest(self, mock_cfgdb): + runner = CliRunner() + db = Db() + db.cfgdb = mock_cfgdb + + # add new relay dest + with mock.patch("utilities_common.cli.run_command") as mock_run_command: + result = runner.invoke(dhcp_relay.vlan_dhcp_relay.commands["add"], + ["1000", "192.0.0.100"], obj=db) + print(result.exit_code) + print(result.output) + assert result.exit_code == 0 + assert result.output == config_vlan_add_dhcp_relay_output + assert mock_run_command.call_count == 3 + db.cfgdb.set_entry.assert_called_once_with('VLAN', 'Vlan1000', {'dhcp_servers': ['192.0.0.1', '192.0.0.100']}) + + db.cfgdb.set_entry.reset_mock() + + # del relay dest + with mock.patch("utilities_common.cli.run_command") as mock_run_command: + result = runner.invoke(dhcp_relay.vlan_dhcp_relay.commands["del"], + ["1000", "192.0.0.100"], obj=db) + print(result.exit_code) + print(result.output) + assert result.exit_code == 0 + assert result.output == config_vlan_del_dhcp_relay_output + assert mock_run_command.call_count == 3 + db.cfgdb.set_entry.assert_called_once_with('VLAN', 'Vlan1000', {'dhcp_servers': ['192.0.0.1']}) + + def test_config_vlan_add_del_dhcpv6_relay_dest(self, mock_cfgdb): + runner = CliRunner() + db = Db() + db.cfgdb = mock_cfgdb + + # add new relay dest + with mock.patch("utilities_common.cli.run_command") as mock_run_command: + result = runner.invoke(dhcp_relay.vlan_dhcp_relay.commands["add"], + ["1000", "fc02:2000::1"], obj=db) + print(result.exit_code) + print(result.output) + assert result.exit_code == 0 + assert result.output == config_vlan_add_dhcpv6_relay_output + assert mock_run_command.call_count == 3 + db.cfgdb.set_entry.assert_called_once_with('VLAN', 'Vlan1000', {'dhcp_servers': ['192.0.0.1'], 'dhcpv6_servers': ['fc02:2000::1']}) + + db.cfgdb.set_entry.reset_mock() + + # del relay dest + with mock.patch("utilities_common.cli.run_command") as mock_run_command: + result = runner.invoke(dhcp_relay.vlan_dhcp_relay.commands["del"], + ["1000", "fc02:2000::1"], obj=db) + print(result.exit_code) + print(result.output) + assert result.exit_code == 0 + assert result.output == config_vlan_del_dhcpv6_relay_output + assert mock_run_command.call_count == 3 + db.cfgdb.set_entry.assert_called_once_with('VLAN', 'Vlan1000', {'dhcp_servers': ['192.0.0.1']}) + + def test_config_vlan_add_del_multiple_dhcpv6_relay_dest(self, mock_cfgdb): + runner = CliRunner() + db = Db() + db.cfgdb = mock_cfgdb + + # add new relay dest + with mock.patch("utilities_common.cli.run_command") as mock_run_command: + result = runner.invoke(dhcp_relay.vlan_dhcp_relay.commands["add"], + ["1000", "fc02:2000::1", "fc02:2000::2", "fc02:2000::3"], obj=db) + print(result.exit_code) + print(result.output) + assert result.exit_code == 0 + assert result.output == config_vlan_add_multiple_dhcpv6_relay_output + assert mock_run_command.call_count == 3 + db.cfgdb.set_entry.assert_called_once_with('VLAN', 'Vlan1000', {'dhcp_servers': ['192.0.0.1'], 'dhcpv6_servers': ['fc02:2000::1', 'fc02:2000::2', 'fc02:2000::3']}) + + db.cfgdb.set_entry.reset_mock() + + # del relay dest + with mock.patch("utilities_common.cli.run_command") as mock_run_command: + result = runner.invoke(dhcp_relay.vlan_dhcp_relay.commands["del"], + ["1000", "fc02:2000::1", "fc02:2000::2", "fc02:2000::3"], obj=db) + print(result.exit_code) + print(result.output) + assert result.exit_code == 0 + assert result.output == config_vlan_del_multiple_dhcpv6_relay_output + assert mock_run_command.call_count == 3 + db.cfgdb.set_entry.assert_called_once_with('VLAN', 'Vlan1000', {'dhcp_servers': ['192.0.0.1']}) + + def test_config_vlan_remove_nonexist_dhcp_relay_dest(self, mock_cfgdb): + runner = CliRunner() + db = Db() + db.cfgdb = mock_cfgdb + + with mock.patch('utilities_common.cli.run_command') as mock_run_command: + result = runner.invoke(dhcp_relay.vlan_dhcp_relay.commands["del"], + ["1000", "192.0.0.100"], obj=db) + print(result.exit_code) + print(result.output) + # traceback.print_tb(result.exc_info[2]) + assert result.exit_code != 0 + assert "Error: 192.0.0.100 is not a DHCP relay destination for Vlan1000" in result.output + assert mock_run_command.call_count == 0 + + def test_config_vlan_remove_dhcp_relay_dest_with_nonexist_vlanid(self, mock_cfgdb): + runner = CliRunner() + db = Db() + db.cfgdb = mock_cfgdb + + with mock.patch('utilities_common.cli.run_command') as mock_run_command: + result = runner.invoke(dhcp_relay.vlan_dhcp_relay.commands["del"], + ["1001", "192.0.0.1"], obj=Db) + print(result.exit_code) + print(result.output) + # traceback.print_tb(result.exc_info[2]) + assert result.exit_code != 0 + assert "Error: Vlan1001 doesn't exist" in result.output + assert mock_run_command.call_count == 0 diff --git a/dockers/docker-dhcp-relay/cli-plugin-tests/test_show_dhcp_relay.py b/dockers/docker-dhcp-relay/cli-plugin-tests/test_show_dhcp_relay.py index b8219fcc6ad3..de679972665f 100644 --- a/dockers/docker-dhcp-relay/cli-plugin-tests/test_show_dhcp_relay.py +++ b/dockers/docker-dhcp-relay/cli-plugin-tests/test_show_dhcp_relay.py @@ -1,28 +1,155 @@ -import os +import pytest import sys -import traceback +import os +sys.path.append('../cli/show/plugins/') +import show_dhcp_relay as show +import show.vlan as vlan +from swsscommon import swsscommon +from mock_config import COMMON_TEST_DATA, NEW_ADDED_TEST_DATA, MULTI_TEST_DATA +from parameterized import parameterized +from pyfakefs.fake_filesystem_unittest import patchfs from unittest import mock -from click.testing import CliRunner +try: + sys.path.insert(0, '../../../src/sonic-host-services/tests/common') + from mock_configdb import MockConfigDb + swsscommon.ConfigDBConnector = MockConfigDb +except KeyError: + pass + +expected_ipv6_table_with_header = """\ ++-------------+----------------------+ +| Interface | DHCP Relay Address | ++=============+======================+ +| Vlan1000 | fc02:2000::1 | +| | fc02:2000::2 | ++-------------+----------------------+ +""" + +expected_ipv4_table_with_header = """\ ++-------------+----------------------+ +| Interface | DHCP Relay Address | ++=============+======================+ +| Vlan1000 | 192.0.0.1 | +| | 192.0.0.2 | ++-------------+----------------------+ +""" + +expected_ipv6_table_without_header = """\ +-------- ------------ +Vlan1000 fc02:2000::1 + fc02:2000::2 +-------- ------------ +""" + +expected_ipv6_table_multi_with_header = """\ ++-------------+----------------------+ +| Interface | DHCP Relay Address | ++=============+======================+ +| Vlan1000 | fc02:2000::1 | +| | fc02:2000::2 | ++-------------+----------------------+ +| Vlan1001 | fc02:2000::3 | +| | fc02:2000::4 | ++-------------+----------------------+ +""" + +expected_ipv4_table_multi_with_header = """\ ++-------------+----------------------+ +| Interface | DHCP Relay Address | ++=============+======================+ +| Vlan1000 | 192.0.0.1 | +| | 192.0.0.2 | ++-------------+----------------------+ +| Vlan1001 | 192.0.0.3 | +| | 192.0.0.4 | ++-------------+----------------------+ +""" + +DBCONFIG_PATH = '/var/run/redis/sonic-db/database_config.json' + +IP_VER_TEST_PARAM_MAP = { + "ipv4": { + "entry": "dhcp_servers", + "table": "VLAN" + }, + "ipv6": { + "entry": "dhcpv6_servers", + "table": "DHCP_RELAY" + } +} + + +def test_plugin_registration(): + cli = mock.MagicMock() + show.register(cli) + assert 'DHCP Helper Address' in dict(vlan.VlanBrief.COLUMNS) + + +def test_dhcp_relay_column_output(): + ctx = ( + ({'Vlan1001': {'dhcp_servers': ['192.0.0.1', '192.168.0.2']}}, {}, {}), + (), + ) + assert show.get_dhcp_helper_address(ctx, 'Vlan1001') == '192.0.0.1\n192.168.0.2' -import show.vlan as vlan -from utilities_common.db import Db -sys.path.insert(0, '../cli/show/plugins/') -import show_dhcp_relay +@parameterized.expand(COMMON_TEST_DATA) +@patchfs +def test_show_dhcp_relay(test_name, test_data, fs): + if not os.path.exists(DBCONFIG_PATH): + fs.create_file(DBCONFIG_PATH) + MockConfigDb.set_config_db(test_data["config_db"]) + config_db = MockConfigDb() + ip_version = "ipv4" if "ipv4" in test_name else "ipv6" + table = config_db.get_table(IP_VER_TEST_PARAM_MAP[ip_version]["table"]) + if test_name == "ipv4_with_header": + result = show.get_dhcp_relay_data_with_header(table, IP_VER_TEST_PARAM_MAP[ip_version]["entry"]) + expected_output = expected_ipv4_table_with_header + elif test_name == "ipv6_with_header": + result = show.get_dhcp_relay_data_with_header(table, IP_VER_TEST_PARAM_MAP[ip_version]["entry"]) + expected_output = expected_ipv6_table_with_header + elif test_name == "ipv6_without_header": + result = show.get_data(table, "Vlan1000") + expected_output = expected_ipv6_table_without_header + assert result == expected_output -class TestVlanDhcpRelay(object): - def test_plugin_registration(self): - cli = mock.MagicMock() - show_dhcp_relay.register(cli) - assert 'DHCP Helper Address' in dict(vlan.VlanBrief.COLUMNS) +@parameterized.expand(NEW_ADDED_TEST_DATA) +@patchfs +def test_show_new_added_dhcp_relay(test_name, test_data, fs): + if not os.path.exists(DBCONFIG_PATH): + fs.create_file(DBCONFIG_PATH) + MockConfigDb.set_config_db(test_data["config_db"]) + config_db = MockConfigDb() + ip_version = test_name + table = config_db.get_table(IP_VER_TEST_PARAM_MAP[ip_version]["table"]) + if ip_version == "ipv4": + result = show.get_dhcp_relay_data_with_header(table, IP_VER_TEST_PARAM_MAP[ip_version]["entry"]) + expected_output = expected_ipv4_table_with_header + assert result == expected_output + else: + result = show.get_dhcp_relay_data_with_header(table, IP_VER_TEST_PARAM_MAP[ip_version]["entry"]) + expected_output = expected_ipv6_table_with_header + assert result == expected_output - def test_dhcp_relay_column_output(self): - ctx = ( - ({'Vlan100': {'dhcp_servers': ['192.0.0.1', '192.168.0.2']}}, {}, {}), - (), - ) - assert show_dhcp_relay.get_dhcp_helper_address(ctx, 'Vlan100') == '192.0.0.1\n192.168.0.2' + result = show.get_data(table, "Vlan1001") + expected_output = "" + assert result == expected_output +@parameterized.expand(MULTI_TEST_DATA) +@patchfs +def test_show_multi_dhcp_relay(test_name, test_data, fs): + if not os.path.exists(DBCONFIG_PATH): + fs.create_file(DBCONFIG_PATH) + MockConfigDb.set_config_db(test_data["config_db"]) + config_db = MockConfigDb() + ip_version = test_name + table = config_db.get_table(IP_VER_TEST_PARAM_MAP[ip_version]["table"]) + result = show.get_dhcp_relay_data_with_header(table, IP_VER_TEST_PARAM_MAP[ip_version]["entry"]) + if ip_version == "ipv4": + expected_output = expected_ipv4_table_multi_with_header + else: + expected_output = expected_ipv6_table_multi_with_header + assert result == expected_output diff --git a/dockers/docker-dhcp-relay/cli-plugin-tests/test_show_dhcpv6_helper.py b/dockers/docker-dhcp-relay/cli-plugin-tests/test_show_dhcpv6_helper.py deleted file mode 100644 index fcb15b98082d..000000000000 --- a/dockers/docker-dhcp-relay/cli-plugin-tests/test_show_dhcpv6_helper.py +++ /dev/null @@ -1,41 +0,0 @@ -import pytest -import sys -import os -sys.path.append('../cli/show/plugins/') -import show_dhcp_relay as show -from click.testing import CliRunner -from swsscommon import swsscommon -from mock_config import TEST_DATA -from parameterized import parameterized -from pyfakefs.fake_filesystem_unittest import patchfs - -try: - sys.path.insert(0, '../../../src/sonic-host-services/tests/common') - from mock_configdb import MockConfigDb - swsscommon.ConfigDBConnector = MockConfigDb -except KeyError: - pass - -expected_table = """\ --------- ------------ -Vlan1000 fc02:2000::1 - fc02:2000::2 --------- ------------ -""" - -DBCONFIG_PATH = '/var/run/redis/sonic-db/database_config.json' - -class TestDhcpRelayHelper(object): - - @parameterized.expand(TEST_DATA) - @patchfs - def test_show_dhcpv6_helper(self, test_name, test_data, fs): - if not os.path.exists(DBCONFIG_PATH): - fs.create_file(DBCONFIG_PATH) - MockConfigDb.set_config_db(test_data["config_db"]) - runner = CliRunner() - config_db = MockConfigDb() - table = config_db.get_table("DHCP_RELAY") - result = show.get_data(table, "Vlan1000") - assert result == expected_table - diff --git a/dockers/docker-dhcp-relay/cli/clear/plugins/clear_dhcp6relay_counter.py b/dockers/docker-dhcp-relay/cli/clear/plugins/clear_dhcp6relay_counter.py index 048a83901574..bfa5af45ae77 100644 --- a/dockers/docker-dhcp-relay/cli/clear/plugins/clear_dhcp6relay_counter.py +++ b/dockers/docker-dhcp-relay/cli/clear/plugins/clear_dhcp6relay_counter.py @@ -1,32 +1,56 @@ -import sys import click import importlib -importlib.import_module('show.plugins.dhcp-relay') +dhcp6_relay = importlib.import_module('show.plugins.dhcp-relay') import utilities_common.cli as clicommon +def clear_dhcp_relay_ipv6_counter(interface): + counter = dhcp6_relay.DHCPv6_Counter() + counter_intf = counter.get_interface() + + if interface: + counter.clear_table(interface) + else: + for intf in counter_intf: + counter.clear_table(intf) + + # sonic-clear dhcp6relay_counters @click.group(cls=clicommon.AliasedGroup) def dhcp6relay_clear(): pass + @dhcp6relay_clear.command('dhcp6relay_counters') @click.option('-i', '--interface', required=False) def dhcp6relay_clear_counters(interface): """ Clear dhcp6relay message counts """ + clear_dhcp_relay_ipv6_counter(interface) - counter = DHCPv6_Counter() - counter_intf = counter.get_interface() - if interface: - counter.clear_table(interface) - else: - for intf in counter_intf: - counter.clear_table(intf) +@click.group(cls=clicommon.AliasedGroup, name="dhcp_relay") +def dhcp_relay(): + pass + + +@dhcp_relay.group(cls=clicommon.AliasedGroup, name="ipv6") +def dhcp_relay_ipv6(): + pass + + +@dhcp_relay_ipv6.command('counters') +@click.option('-i', '--interface', required=False) +def clear_dhcp_relay_ipv6_counters(interface): + """ Clear dhcp_relay ipv6 message counts """ + clear_dhcp_relay_ipv6_counter(interface) + def register(cli): cli.add_command(dhcp6relay_clear_counters) + cli.add_command(dhcp_relay) + if __name__ == '__main__': dhcp6relay_clear_counters() + dhcp_relay() diff --git a/dockers/docker-dhcp-relay/cli/config/plugins/dhcp_relay.py b/dockers/docker-dhcp-relay/cli/config/plugins/dhcp_relay.py index 33a798fc8778..aea8e491f05b 100644 --- a/dockers/docker-dhcp-relay/cli/config/plugins/dhcp_relay.py +++ b/dockers/docker-dhcp-relay/cli/config/plugins/dhcp_relay.py @@ -1,11 +1,185 @@ import click -import utilities_common.cli as clicommon import ipaddress +import utilities_common.cli as clicommon + +DHCP_RELAY_TABLE = "DHCP_RELAY" +DHCPV6_SERVERS = "dhcpv6_servers" +IPV6 = 6 + +VLAN_TABLE = "VLAN" +DHCPV4_SERVERS = "dhcp_servers" +IPV4 = 4 + + +def validate_ips(ctx, ips, ip_version): + for ip in ips: + try: + ip_address = ipaddress.ip_address(ip) + except Exception: + ctx.fail("{} is invalid IP address".format(ip)) + + if ip_address.version != ip_version: + ctx.fail("{} is not IPv{} address".format(ip, ip_version)) + + +def get_dhcp_servers(db, vlan_name, ctx, table_name, dhcp_servers_str, check_is_exist=True): + if check_is_exist: + keys = db.cfgdb.get_keys(table_name) + if vlan_name not in keys: + ctx.fail("{} doesn't exist".format(vlan_name)) + + table = db.cfgdb.get_entry(table_name, vlan_name) + dhcp_servers = table.get(dhcp_servers_str, []) + + return dhcp_servers, table + + +def restart_dhcp_relay_service(): + """ + Restart dhcp_relay service + """ + click.echo("Restarting DHCP relay service...") + clicommon.run_command("systemctl stop dhcp_relay", display_cmd=False) + clicommon.run_command("systemctl reset-failed dhcp_relay", display_cmd=False) + clicommon.run_command("systemctl start dhcp_relay", display_cmd=False) + + +def add_dhcp_relay(vid, dhcp_relay_ips, db, ip_version): + table_name = DHCP_RELAY_TABLE if ip_version == 6 else VLAN_TABLE + dhcp_servers_str = DHCPV6_SERVERS if ip_version == 6 else DHCPV4_SERVERS + vlan_name = "Vlan{}".format(vid) + ctx = click.get_current_context() + # Verify ip addresses are valid + validate_ips(ctx, dhcp_relay_ips, ip_version) + + # It's unnecessary for DHCPv6 Relay to verify entry exist + check_config_exist = True if ip_version == 4 else False + dhcp_servers, table = get_dhcp_servers(db, vlan_name, ctx, table_name, dhcp_servers_str, check_config_exist) + added_ips = [] + + for dhcp_relay_ip in dhcp_relay_ips: + # Verify ip addresses not duplicate in add list + if dhcp_relay_ip in added_ips: + ctx.fail("Error: Find duplicate DHCP relay ip {} in add list".format(dhcp_relay_ip)) + # Verify ip addresses not exist in DB + if dhcp_relay_ip in dhcp_servers: + click.echo("{} is already a DHCP relay for {}".format(dhcp_relay_ip, vlan_name)) + return + + dhcp_servers.append(dhcp_relay_ip) + added_ips.append(dhcp_relay_ip) + + table[dhcp_servers_str] = dhcp_servers + + db.cfgdb.set_entry(table_name, vlan_name, table) + click.echo("Added DHCP relay address [{}] to {}".format(",".join(dhcp_relay_ips), vlan_name)) + try: + restart_dhcp_relay_service() + except SystemExit as e: + ctx.fail("Restart service dhcp_relay failed with error {}".format(e)) + + +def del_dhcp_relay(vid, dhcp_relay_ips, db, ip_version): + table_name = DHCP_RELAY_TABLE if ip_version == 6 else VLAN_TABLE + dhcp_servers_str = DHCPV6_SERVERS if ip_version == 6 else DHCPV4_SERVERS + vlan_name = "Vlan{}".format(vid) + ctx = click.get_current_context() + # Verify ip addresses are valid + validate_ips(ctx, dhcp_relay_ips, ip_version) + dhcp_servers, table = get_dhcp_servers(db, vlan_name, ctx, table_name, dhcp_servers_str) + removed_ips = [] + + for dhcp_relay_ip in dhcp_relay_ips: + # Verify ip addresses not duplicate in del list + if dhcp_relay_ip in removed_ips: + ctx.fail("Error: Find duplicate DHCP relay ip {} in del list".format(dhcp_relay_ip)) + # Remove dhcp servers if they exist in the DB + if dhcp_relay_ip not in dhcp_servers: + ctx.fail("{} is not a DHCP relay for {}".format(dhcp_relay_ip, vlan_name)) + + dhcp_servers.remove(dhcp_relay_ip) + removed_ips.append(dhcp_relay_ip) + + if len(dhcp_servers) == 0: + del table[dhcp_servers_str] + else: + table[dhcp_servers_str] = dhcp_servers + + if ip_version == 6 and len(table.keys()) == 0: + table = None + db.cfgdb.set_entry(table_name, vlan_name, table) + click.echo("Removed DHCP relay address [{}] from {}".format(",".join(dhcp_relay_ips), vlan_name)) + try: + restart_dhcp_relay_service() + except SystemExit as e: + ctx.fail("Restart service dhcp_relay failed with error {}".format(e)) + + +@click.group(cls=clicommon.AbbreviationGroup, name="dhcp_relay") +def dhcp_relay(): + """config DHCP_Relay information""" + pass + + +@dhcp_relay.group(cls=clicommon.AbbreviationGroup, name="ipv6") +def dhcp_relay_ipv6(): + pass + + +@dhcp_relay_ipv6.group(cls=clicommon.AbbreviationGroup, name="destination") +def dhcp_relay_ipv6_destination(): + pass + + +@dhcp_relay_ipv6_destination.command("add") +@click.argument("vid", metavar="", required=True, type=int) +@click.argument("dhcp_relay_destinations", nargs=-1, required=True) +@clicommon.pass_db +def add_dhcp_relay_ipv6_destination(db, vid, dhcp_relay_destinations): + add_dhcp_relay(vid, dhcp_relay_destinations, db, IPV6) + + +@dhcp_relay_ipv6_destination.command("del") +@click.argument("vid", metavar="", required=True, type=int) +@click.argument("dhcp_relay_destinations", nargs=-1, required=True) +@clicommon.pass_db +def del_dhcp_relay_ipv6_destination(db, vid, dhcp_relay_destinations): + del_dhcp_relay(vid, dhcp_relay_destinations, db, IPV6) + + +@dhcp_relay.group(cls=clicommon.AbbreviationGroup, name="ipv4") +def dhcp_relay_ipv4(): + pass + + +@dhcp_relay_ipv4.group(cls=clicommon.AbbreviationGroup, name="helper") +def dhcp_relay_ipv4_helper(): + pass + + +@dhcp_relay_ipv4_helper.command("add") +@click.argument("vid", metavar="", required=True, type=int) +@click.argument("dhcp_relay_helpers", nargs=-1, required=True) +@clicommon.pass_db +def add_dhcp_relay_ipv4_helper(db, vid, dhcp_relay_helpers): + add_dhcp_relay(vid, dhcp_relay_helpers, db, IPV4) + + +@dhcp_relay_ipv4_helper.command("del") +@click.argument("vid", metavar="", required=True, type=int) +@click.argument("dhcp_relay_helpers", nargs=-1, required=True) +@clicommon.pass_db +def del_dhcp_relay_ipv4_helper(db, vid, dhcp_relay_helpers): + del_dhcp_relay(vid, dhcp_relay_helpers, db, IPV4) + + +# subcommand of vlan @click.group(cls=clicommon.AbbreviationGroup, name='dhcp_relay') def vlan_dhcp_relay(): pass + @vlan_dhcp_relay.command('add') @click.argument('vid', metavar='', required=True, type=int) @click.argument('dhcp_relay_destination_ips', nargs=-1, required=True) @@ -30,8 +204,8 @@ def add_vlan_dhcp_relay_destination(db, vid, dhcp_relay_destination_ips): try: ipaddress.ip_address(ip_addr) if (ip_addr in dhcp_servers) or (ip_addr in dhcpv6_servers): - click.echo("{} is already a DHCP relay destination for {}".format(ip_addr, vlan_name)) - continue + click.echo("{} is already a DHCP relay destination for {}".format(ip_addr, vlan_name)) + continue if clicommon.ipaddress_type(ip_addr) == 4: dhcp_servers.append(ip_addr) else: @@ -51,13 +225,11 @@ def add_vlan_dhcp_relay_destination(db, vid, dhcp_relay_destination_ips): if len(added_servers): click.echo("Added DHCP relay destination addresses {} to {}".format(added_servers, vlan_name)) try: - click.echo("Restarting DHCP relay service...") - clicommon.run_command("systemctl stop dhcp_relay", display_cmd=False) - clicommon.run_command("systemctl reset-failed dhcp_relay", display_cmd=False) - clicommon.run_command("systemctl start dhcp_relay", display_cmd=False) + restart_dhcp_relay_service() except SystemExit as e: ctx.fail("Restart service dhcp_relay failed with error {}".format(e)) + @vlan_dhcp_relay.command('del') @click.argument('vid', metavar='', required=True, type=int) @click.argument('dhcp_relay_destination_ips', nargs=-1, required=True) @@ -79,9 +251,9 @@ def del_vlan_dhcp_relay_destination(db, vid, dhcp_relay_destination_ips): for ip_addr in dhcp_relay_destination_ips: if (ip_addr not in dhcp_servers) and (ip_addr not in dhcpv6_servers): - ctx.fail("{} is not a DHCP relay destination for {}".format(ip_addr, vlan_name)) + ctx.fail("{} is not a DHCP relay destination for {}".format(ip_addr, vlan_name)) if clicommon.ipaddress_type(ip_addr) == 4: - dhcp_servers.remove(ip_addr) + dhcp_servers.remove(ip_addr) else: dhcpv6_servers.remove(ip_addr) @@ -101,17 +273,16 @@ def del_vlan_dhcp_relay_destination(db, vid, dhcp_relay_destination_ips): db.cfgdb.set_entry('VLAN', vlan_name, vlan) click.echo("Removed DHCP relay destination addresses {} from {}".format(dhcp_relay_destination_ips, vlan_name)) try: - click.echo("Restarting DHCP relay service...") - clicommon.run_command("systemctl stop dhcp_relay", display_cmd=False) - clicommon.run_command("systemctl reset-failed dhcp_relay", display_cmd=False) - clicommon.run_command("systemctl start dhcp_relay", display_cmd=False) + restart_dhcp_relay_service() except SystemExit as e: ctx.fail("Restart service dhcp_relay failed with error {}".format(e)) def register(cli): + cli.add_command(dhcp_relay) cli.commands['vlan'].add_command(vlan_dhcp_relay) if __name__ == '__main__': + dhcp_relay() vlan_dhcp_relay() diff --git a/dockers/docker-dhcp-relay/cli/show/plugins/show_dhcp_relay.py b/dockers/docker-dhcp-relay/cli/show/plugins/show_dhcp_relay.py index 4178915fe0b2..d76d5f6fa6b8 100644 --- a/dockers/docker-dhcp-relay/cli/show/plugins/show_dhcp_relay.py +++ b/dockers/docker-dhcp-relay/cli/show/plugins/show_dhcp_relay.py @@ -1,7 +1,7 @@ import click from natsort import natsorted from tabulate import tabulate -import show.vlan as vlan +import show.vlan as show_vlan import utilities_common.cli as clicommon from swsscommon.swsscommon import ConfigDBConnector @@ -12,12 +12,17 @@ DHCPv6_COUNTER_TABLE = 'DHCPv6_COUNTER_TABLE' # DHCPv6 Counter Messages -messages = ["Unknown", "Solicit", "Advertise", "Request", "Confirm", "Renew", "Rebind", "Reply", "Release", "Decline", "Reconfigure", "Information-Request", "Relay-Forward", "Relay-Reply", "Malformed"] +messages = ["Unknown", "Solicit", "Advertise", "Request", "Confirm", "Renew", "Rebind", "Reply", "Release", "Decline", + "Reconfigure", "Information-Request", "Relay-Forward", "Relay-Reply", "Malformed"] # DHCP_RELAY Config Table DHCP_RELAY = 'DHCP_RELAY' +VLAN = "VLAN" +DHCPV6_SERVERS = "dhcpv6_servers" +DHCPV4_SERVERS = "dhcp_servers" config_db = ConfigDBConnector() + def get_dhcp_helper_address(ctx, vlan): cfg, _ = ctx vlan_dhcp_helper_data, _, _ = cfg @@ -30,7 +35,7 @@ def get_dhcp_helper_address(ctx, vlan): return '\n'.join(natsorted(dhcp_helpers)) -vlan.VlanBrief.register_column('DHCP Helper Address', get_dhcp_helper_address) +show_vlan.VlanBrief.register_column('DHCP Helper Address', get_dhcp_helper_address) class DHCPv6_Counter(object): @@ -39,7 +44,6 @@ def __init__(self): self.db.connect(self.db.STATE_DB) self.table_name = DHCPv6_COUNTER_TABLE + self.db.get_db_separator(self.db.STATE_DB) - def get_interface(self): """ Get all names of all interfaces in DHCPv6_COUNTER_TABLE """ vlans = [] @@ -47,7 +51,6 @@ def get_interface(self): if DHCPv6_COUNTER_TABLE in key: vlans.append(key[21:]) return vlans - def get_dhcp6relay_msg_count(self, interface, msg): """ Get count of a dhcp6relay message """ @@ -55,18 +58,18 @@ def get_dhcp6relay_msg_count(self, interface, msg): data = [str(msg), count] return data - def clear_table(self, interface): """ Reset all message counts to 0 """ for msg in messages: - self.db.set(self.db.STATE_DB, self.table_name + str(interface), str(msg), '0') + self.db.set(self.db.STATE_DB, self.table_name + str(interface), str(msg), '0') + def print_count(counter, intf): """Print count of each message""" data = [] for i in messages: data.append(counter.get_dhcp6relay_msg_count(intf, i)) - print(tabulate(data, headers = ["Message Type", intf], tablefmt='simple', stralign='right') + "\n") + print(tabulate(data, headers=["Message Type", intf], tablefmt='simple', stralign='right') + "\n") # @@ -80,13 +83,7 @@ def dhcp6relay_counters(): pass -# 'counts' subcommand ("show dhcp6relay_counters counts") -@dhcp6relay_counters.command('counts') -@click.option('-i', '--interface', required=False) -@click.option('--verbose', is_flag=True, help="Enable verbose output") -def counts(interface, verbose): - """Show dhcp6relay message counts""" - +def ipv6_counters(interface): counter = DHCPv6_Counter() counter_intf = counter.get_interface() @@ -94,38 +91,114 @@ def counts(interface, verbose): print_count(counter, interface) else: for intf in counter_intf: - print_count(counter, intf) + print_count(counter, intf) +# 'counts' subcommand ("show dhcp6relay_counters counts") +@dhcp6relay_counters.command('counts') +@click.option('-i', '--interface', required=False) +@click.option('--verbose', is_flag=True, help="Enable verbose output") +def counts(interface, verbose): + """Show dhcp6relay message counts""" + + ipv6_counters(interface) + @click.group(cls=clicommon.AliasedGroup, name="dhcprelay_helper") def dhcp_relay_helper(): """Show DHCP_Relay helper information""" pass + +def get_dhcp_relay_data_with_header(table_data, entry_name): + vlan_relay = {} + vlans = table_data.keys() + for vlan in vlans: + vlan_data = table_data.get(vlan) + dhcp_relay_data = vlan_data.get(entry_name) + if dhcp_relay_data is None or len(dhcp_relay_data) == 0: + continue + + vlan_relay[vlan] = [] + for address in dhcp_relay_data: + vlan_relay[vlan].append(address) + + dhcp_relay_vlan_keys = vlan_relay.keys() + relay_address_list = ["\n".join(vlan_relay[key]) for key in dhcp_relay_vlan_keys] + data = {"Interface": dhcp_relay_vlan_keys, "DHCP Relay Address": relay_address_list} + return tabulate(data, tablefmt='grid', stralign='right', headers='keys') + '\n' + + +def get_dhcp_relay(table_name, entry_name, with_header): + if config_db is None: + return + + config_db.connect() + table_data = config_db.get_table(table_name) + if table_data is None: + return + + if with_header: + output = get_dhcp_relay_data_with_header(table_data, entry_name) + print(output) + else: + vlans = config_db.get_keys(table_name) + for vlan in vlans: + output = get_data(table_data, vlan) + print(output) + + @dhcp_relay_helper.command('ipv6') def get_dhcpv6_helper_address(): """Parse through DHCP_RELAY table for each interface in config_db.json and print dhcpv6 helpers in table format""" - if config_db is not None: - config_db.connect() - table_data = config_db.get_table(DHCP_RELAY) - if table_data is not None: - vlans = config_db.get_keys(DHCP_RELAY) - for vlan in vlans: - output = get_data(table_data, vlan) - print(output) - + get_dhcp_relay(DHCP_RELAY, DHCPV6_SERVERS, with_header=False) + def get_data(table_data, vlan): - vlan_data = table_data.get(vlan) + vlan_data = table_data.get(vlan, {}) helpers_data = vlan_data.get('dhcpv6_servers') + addr = {vlan:[]} + output = '' if helpers_data is not None: - addr = {vlan:[]} for ip in helpers_data: addr[vlan].append(ip) - output = tabulate({'Interface':[vlan], vlan:addr.get(vlan)}, tablefmt='simple', stralign='right') + '\n' + output = tabulate({'Interface':[vlan], vlan:addr.get(vlan)}, tablefmt='simple', stralign='right') + '\n' return output + +@click.group(cls=clicommon.AliasedGroup, name="dhcp_relay") +def dhcp_relay(): + """show DHCP_Relay information""" + pass + + +@dhcp_relay.group(cls=clicommon.AliasedGroup, name="ipv6") +def dhcp_relay_ipv6(): + pass + + +@dhcp_relay.group(cls=clicommon.AliasedGroup, name="ipv4") +def dhcp_relay_ipv4(): + pass + + +@dhcp_relay_ipv4.command("helper") +def dhcp_relay_ipv4_destination(): + get_dhcp_relay(VLAN, DHCPV4_SERVERS, with_header=True) + + +@dhcp_relay_ipv6.command("destination") +def dhcp_relay_ipv6_destination(): + get_dhcp_relay(DHCP_RELAY, DHCPV6_SERVERS, with_header=True) + + +@dhcp_relay_ipv6.command("counters") +@click.option('-i', '--interface', required=False) +def dhcp_relay_ip6counters(interface): + ipv6_counters(interface) + + def register(cli): cli.add_command(dhcp6relay_counters) cli.add_command(dhcp_relay_helper) + cli.add_command(dhcp_relay) diff --git a/dockers/docker-dhcp-relay/dhcp-relay.monitors.j2 b/dockers/docker-dhcp-relay/dhcp-relay.monitors.j2 index 0928bac22d4d..d81573fd86f2 100644 --- a/dockers/docker-dhcp-relay/dhcp-relay.monitors.j2 +++ b/dockers/docker-dhcp-relay/dhcp-relay.monitors.j2 @@ -32,7 +32,7 @@ dhcpmon-{{ vlan_name }} {% endif %} {# Check DHCPv6 agents #} {% if DHCP_RELAY and vlan_name in DHCP_RELAY and DHCP_RELAY[vlan_name]['dhcpv6_servers']|length > 0 %} -{% for dhcpv6_server in VLAN[vlan_name]['dhcpv6_servers'] %} +{% for dhcpv6_server in DHCP_RELAY[vlan_name]['dhcpv6_servers'] %} {% if dhcpv6_server | ipv6 %} {% set _dummy = relay_for_ipv6.update({'flag': True}) %} {% endif %} diff --git a/dockers/docker-fpm-frr/Dockerfile.j2 b/dockers/docker-fpm-frr/Dockerfile.j2 index c42f001b830f..d15fc1846232 100644 --- a/dockers/docker-fpm-frr/Dockerfile.j2 +++ b/dockers/docker-fpm-frr/Dockerfile.j2 @@ -5,7 +5,6 @@ ARG docker_container_name ARG frr_user_uid ARG frr_user_gid -RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf # Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive diff --git a/dockers/docker-fpm-frr/bgp_regex.json b/dockers/docker-fpm-frr/bgp_regex.json index f02ae53ed26f..c657aa89dc66 100644 --- a/dockers/docker-fpm-frr/bgp_regex.json +++ b/dockers/docker-fpm-frr/bgp_regex.json @@ -12,7 +12,7 @@ { "tag": "notification", "regex": "NOTIFICATION: (received|sent) (?:to|from) neighbor ([0-9a-f:.]*[0-9a-f+]*)\\s*.* (\\d*)\/(\\d*)", - "params": [ "is-sent", "ip", "major-code", "minor-code" ] + "params": [ "is_sent", "ip", "major_code", "minor_code" ] } ] diff --git a/dockers/docker-fpm-frr/frr/bgpd/bgpd.main.conf.j2 b/dockers/docker-fpm-frr/frr/bgpd/bgpd.main.conf.j2 index 4cee01ac973d..15faf4d48332 100644 --- a/dockers/docker-fpm-frr/frr/bgpd/bgpd.main.conf.j2 +++ b/dockers/docker-fpm-frr/frr/bgpd/bgpd.main.conf.j2 @@ -68,6 +68,9 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }} bgp log-neighbor-changes no bgp default ipv4-unicast no bgp ebgp-requires-policy +{% if (DEVICE_METADATA is defined) and ('localhost' in DEVICE_METADATA) and ('subtype' in DEVICE_METADATA['localhost']) and (DEVICE_METADATA['localhost']['subtype'].lower() == 'dualtor') %} + coalesce-time 10000 +{% endif %} ! {% if constants.bgp.multipath_relax.enabled is defined and constants.bgp.multipath_relax.enabled %} bgp bestpath as-path multipath-relax diff --git a/dockers/docker-fpm-frr/frr/bgpd/templates/voq_chassis/peer-group.conf.j2 b/dockers/docker-fpm-frr/frr/bgpd/templates/voq_chassis/peer-group.conf.j2 index ec563b380cc6..44a49587d039 100644 --- a/dockers/docker-fpm-frr/frr/bgpd/templates/voq_chassis/peer-group.conf.j2 +++ b/dockers/docker-fpm-frr/frr/bgpd/templates/voq_chassis/peer-group.conf.j2 @@ -20,8 +20,8 @@ neighbor VOQ_CHASSIS_V6_PEER activate neighbor VOQ_CHASSIS_V6_PEER addpath-tx-all-paths neighbor VOQ_CHASSIS_V6_PEER soft-reconfiguration inbound - neighbor VOQ_CHASSIS_V4_PEER route-map FROM_VOQ_CHASSIS_V6_PEER in - neighbor VOQ_CHASSIS_V4_PEER route-map TO_VOQ_CHASSIS_V6_PEER out + neighbor VOQ_CHASSIS_V6_PEER route-map FROM_VOQ_CHASSIS_V6_PEER in + neighbor VOQ_CHASSIS_V6_PEER route-map TO_VOQ_CHASSIS_V6_PEER out exit-address-family ! ! end of template: bgpd/templates/voq_chassis/peer-group.conf.j2 diff --git a/dockers/docker-iccpd/Dockerfile.j2 b/dockers/docker-iccpd/Dockerfile.j2 index bdb0a9fbf367..42a73b4cd305 100644 --- a/dockers/docker-iccpd/Dockerfile.j2 +++ b/dockers/docker-iccpd/Dockerfile.j2 @@ -2,7 +2,6 @@ FROM docker-config-engine-bullseye-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} ARG docker_container_name -RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf ## Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive diff --git a/dockers/docker-lldp/Dockerfile.j2 b/dockers/docker-lldp/Dockerfile.j2 index d7e38e663be8..9bc6418524cb 100644 --- a/dockers/docker-lldp/Dockerfile.j2 +++ b/dockers/docker-lldp/Dockerfile.j2 @@ -3,7 +3,6 @@ FROM docker-config-engine-bullseye-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} ARG docker_container_name ARG image_version -RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf # Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive diff --git a/dockers/docker-lldp/lldpmgrd b/dockers/docker-lldp/lldpmgrd index 331fedfb4ca3..6d8540bf2613 100755 --- a/dockers/docker-lldp/lldpmgrd +++ b/dockers/docker-lldp/lldpmgrd @@ -260,7 +260,7 @@ class LldpManager(daemon_base.DaemonBase): self.pending_cmds.pop(key, None) elif op == "DEL": self.pending_cmds.pop(key, None) - else: + elif op: self.log_error("unknown operation '{}'".format(op)) elif key == "PortInitDone": self.port_init_done = True diff --git a/dockers/docker-macsec/Dockerfile.j2 b/dockers/docker-macsec/Dockerfile.j2 index 2e7a412466a5..3ec18b13728d 100644 --- a/dockers/docker-macsec/Dockerfile.j2 +++ b/dockers/docker-macsec/Dockerfile.j2 @@ -2,7 +2,6 @@ FROM docker-config-engine-bullseye-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} ARG docker_container_name -RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf ## Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive diff --git a/dockers/docker-mux/Dockerfile.j2 b/dockers/docker-mux/Dockerfile.j2 index 06e89c3ecf2d..5908c432e6d7 100755 --- a/dockers/docker-mux/Dockerfile.j2 +++ b/dockers/docker-mux/Dockerfile.j2 @@ -2,7 +2,6 @@ FROM docker-config-engine-bullseye-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} ARG docker_container_name -RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf ## Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive diff --git a/dockers/docker-nat/Dockerfile.j2 b/dockers/docker-nat/Dockerfile.j2 index 04b2883551c3..0c0e6089a8d3 100644 --- a/dockers/docker-nat/Dockerfile.j2 +++ b/dockers/docker-nat/Dockerfile.j2 @@ -2,7 +2,6 @@ FROM docker-swss-layer-buster-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} ARG docker_container_name -RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf RUN echo diff --git a/dockers/docker-orchagent/Dockerfile.j2 b/dockers/docker-orchagent/Dockerfile.j2 index 22adec2b5959..b8b95a9133c2 100755 --- a/dockers/docker-orchagent/Dockerfile.j2 +++ b/dockers/docker-orchagent/Dockerfile.j2 @@ -2,7 +2,6 @@ FROM docker-swss-layer-bullseye-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} ARG docker_container_name -RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf # Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive diff --git a/dockers/docker-pde/Dockerfile.j2 b/dockers/docker-pde/Dockerfile.j2 index 0ddbfd59ce1e..6a0b21154d9c 100644 --- a/dockers/docker-pde/Dockerfile.j2 +++ b/dockers/docker-pde/Dockerfile.j2 @@ -3,7 +3,6 @@ FROM docker-config-engine-bullseye-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} ARG docker_container_name ENV PYTHONPATH=/usr/share/sonic/platform -RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf # Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive diff --git a/dockers/docker-platform-monitor/Dockerfile.j2 b/dockers/docker-platform-monitor/Dockerfile.j2 index 79265ec9cb73..6dbb36932003 100755 --- a/dockers/docker-platform-monitor/Dockerfile.j2 +++ b/dockers/docker-platform-monitor/Dockerfile.j2 @@ -3,7 +3,6 @@ FROM docker-config-engine-bullseye-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} ARG docker_container_name ARG image_version -RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf # Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive diff --git a/dockers/docker-ptf/Dockerfile.j2 b/dockers/docker-ptf/Dockerfile.j2 index 35c85fd1eac4..081b1d7d506d 100644 --- a/dockers/docker-ptf/Dockerfile.j2 +++ b/dockers/docker-ptf/Dockerfile.j2 @@ -14,14 +14,15 @@ WORKDIR /root MAINTAINER Pavel Shirshov -RUN echo "deb [arch=amd64] http://debian-archive.trafficmanager.net/debian buster-backports main" >> /etc/apt/sources.list +COPY ["sources.list.{{ CONFIGURED_ARCH }}", "/etc/apt/sources.list"] +COPY ["no-check-valid-until", "/etc/apt/apt.conf.d"] + ## Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive ## Set the apt source, update package cache and install necessary packages ## TODO: Clean up this step -RUN sed --in-place 's/httpredir.debian.org/debian-archive.trafficmanager.net/' /etc/apt/sources.list \ - && apt-get update \ +RUN apt-get update \ && apt-get upgrade -y \ && apt-get dist-upgrade -y \ && apt-get install -y \ diff --git a/dockers/docker-ptf/no-check-valid-until b/dockers/docker-ptf/no-check-valid-until new file mode 100644 index 000000000000..c7c25d017f7f --- /dev/null +++ b/dockers/docker-ptf/no-check-valid-until @@ -0,0 +1,4 @@ +# Instruct apt-get to NOT check the "Valid Until" date in Release files +# Once the Debian team archives a repo, they stop updating this date + +Acquire::Check-Valid-Until "false"; diff --git a/dockers/docker-sflow/Dockerfile.j2 b/dockers/docker-sflow/Dockerfile.j2 index eb97f5708bf7..162c4eee961a 100644 --- a/dockers/docker-sflow/Dockerfile.j2 +++ b/dockers/docker-sflow/Dockerfile.j2 @@ -2,7 +2,6 @@ FROM docker-swss-layer-buster-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} ARG docker_container_name -RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf ## Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive diff --git a/dockers/docker-snmp/Dockerfile.j2 b/dockers/docker-snmp/Dockerfile.j2 index 1eb4ec4b7c8b..8465e4fb94fd 100644 --- a/dockers/docker-snmp/Dockerfile.j2 +++ b/dockers/docker-snmp/Dockerfile.j2 @@ -3,7 +3,6 @@ FROM docker-config-engine-bullseye-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} ARG docker_container_name ARG image_version -RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf # Enable -O for all Python calls ENV PYTHONOPTIMIZE 1 diff --git a/dockers/docker-sonic-mgmt-framework/Dockerfile.j2 b/dockers/docker-sonic-mgmt-framework/Dockerfile.j2 index 823a2c7ff4bf..5c36da43286c 100644 --- a/dockers/docker-sonic-mgmt-framework/Dockerfile.j2 +++ b/dockers/docker-sonic-mgmt-framework/Dockerfile.j2 @@ -1,7 +1,6 @@ FROM docker-config-engine-buster-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} ARG docker_container_name -RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf ## Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive diff --git a/dockers/docker-sonic-restapi/Dockerfile.j2 b/dockers/docker-sonic-restapi/Dockerfile.j2 index 029f5ec813d7..ca1a80580ba7 100644 --- a/dockers/docker-sonic-restapi/Dockerfile.j2 +++ b/dockers/docker-sonic-restapi/Dockerfile.j2 @@ -2,7 +2,6 @@ FROM docker-config-engine-bullseye-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} ARG docker_container_name -RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf ## Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive diff --git a/dockers/docker-sonic-sdk/Dockerfile.j2 b/dockers/docker-sonic-sdk/Dockerfile.j2 index dc28822cfd26..0c5c76549121 100755 --- a/dockers/docker-sonic-sdk/Dockerfile.j2 +++ b/dockers/docker-sonic-sdk/Dockerfile.j2 @@ -1,5 +1,5 @@ {% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %} -FROM docker-config-engine-buster-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} +FROM docker-config-engine-bullseye-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} # Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive diff --git a/dockers/docker-sonic-telemetry/Dockerfile.j2 b/dockers/docker-sonic-telemetry/Dockerfile.j2 index e9b01f751b85..64d679d40c46 100644 --- a/dockers/docker-sonic-telemetry/Dockerfile.j2 +++ b/dockers/docker-sonic-telemetry/Dockerfile.j2 @@ -3,7 +3,6 @@ FROM docker-config-engine-bullseye-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} ARG docker_container_name ARG image_version -RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf ## Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive diff --git a/dockers/docker-sonic-telemetry/critical_processes b/dockers/docker-sonic-telemetry/critical_processes index 612a94d9edac..3baf6e268907 100644 --- a/dockers/docker-sonic-telemetry/critical_processes +++ b/dockers/docker-sonic-telemetry/critical_processes @@ -1,2 +1 @@ program:telemetry -program:dialout diff --git a/dockers/docker-teamd/Dockerfile.j2 b/dockers/docker-teamd/Dockerfile.j2 index be5e6984dda9..33cb3af92494 100644 --- a/dockers/docker-teamd/Dockerfile.j2 +++ b/dockers/docker-teamd/Dockerfile.j2 @@ -2,7 +2,6 @@ FROM docker-swss-layer-bullseye-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} ARG docker_container_name -RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf ## Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive diff --git a/files/Aboot/boot0.j2 b/files/Aboot/boot0.j2 index cf09536a5e29..58a1513cc4a3 100644 --- a/files/Aboot/boot0.j2 +++ b/files/Aboot/boot0.j2 @@ -469,8 +469,7 @@ write_platform_specific_cmdline() { local platform="$(cmdline_get platform)" local sid="$(cmdline_get sid | sed 's/Ssd$//')" - # set varlog size to 100MB - local varlog_size=100 + local varlog_size=0 # sonic_mode is set to fixed by default. sonic_mode="fixed" @@ -503,6 +502,7 @@ write_platform_specific_cmdline() { if [ "$sid" = "Gardena" ] || [ "$sid" = "GardenaE" ]; then aboot_machine=arista_7260cx3_64 flash_size=28000 + cmdline_add logs_inram=on fi if [ "$sid" = "Alhambra" ]; then aboot_machine=arista_7170_64c @@ -525,6 +525,8 @@ write_platform_specific_cmdline() { fi if [ "$sid" = "Lodoga" ]; then aboot_machine=arista_7050cx3_32s + cmdline_add logs_inram=on + cmdline_add libata.force=2.00:noncq fi if [ "$sid" = "Marysville" ]; then aboot_machine=arista_7050sx3_48yc8 @@ -544,6 +546,7 @@ write_platform_specific_cmdline() { fi if in_array "$sid" "PikeIslandZ" "PikeIslandZ-F" "PikeIslandZ-2F" "PikeIslandZ-R" "PikeIslandZ-2R"; then aboot_machine=arista_720dt_48s + varlog_size=2048 fi if [ "$sid" = "BlackhawkT4O" ]; then aboot_machine=arista_7050px4_32s @@ -621,9 +624,14 @@ write_platform_specific_cmdline() { cmdline_add intel_idle.max_cstate=0 read_system_eeprom fi + if in_array "$platform" "rook"; then + # Currently applies to Alhambra, Blackhawk, Gardena and Mineral + cmdline_add libata.force=1.00:noncq + fi if in_array "$platform" "crow" "magpie"; then cmdline_add amd_iommu=off cmdline_add modprobe.blacklist=snd_hda_intel,hdaudio + cmdline_add sdhci.append_quirks2=0x40 read_system_eeprom fi if in_array "$platform" "woodpecker"; then @@ -639,22 +647,23 @@ write_platform_specific_cmdline() { read_system_eeprom fi - if [ $flash_size -ge 28000 ]; then - varlog_size=4096 - elif [ $flash_size -gt 4000 ]; then - varlog_size=400 - else - varlog_size=256 - cmdline_add logs_inram=on - if [ $flash_size -le 2000 ]; then - # enable docker_inram for switches with less than 2G of flash - varlog_size=128 - cmdline_add docker_inram=on - fi + if [ $varlog_size -eq 0 ]; then + if [ $flash_size -ge 28000 ]; then + varlog_size=4096 + elif [ $flash_size -gt 4000 ]; then + varlog_size=400 + else + varlog_size=256 + cmdline_add logs_inram=on + if [ $flash_size -le 2000 ]; then + # enable docker_inram for switches with less than 2G of flash + varlog_size=128 + cmdline_add docker_inram=on + fi + fi fi cmdline_add "varlog_size=$varlog_size" - cmdline_add "sonic.mode=$sonic_mode" } @@ -672,6 +681,9 @@ write_image_specific_cmdline() { # disable unified cgroup hierarchy to workaround dockerd limitation cmdline_add systemd.unified_cgroup_hierarchy=0 + # increase kernel log buffer size + cmdline_add log_buf_len=1M + # verbosity cmdline_add quiet # Start showing systemd information from the first failing unit if any. diff --git a/files/apt/apt.conf.d/apt-multiple-retries b/files/apt/apt.conf.d/apt-multiple-retries new file mode 100644 index 000000000000..c4c638252f92 --- /dev/null +++ b/files/apt/apt.conf.d/apt-multiple-retries @@ -0,0 +1,4 @@ +# Instruct apt to retry downloads on failures +# This is required only for bullseye. + +Acquire::Retries "3"; diff --git a/files/build/versions/build/build-sonic-slave-bullseye/versions-deb-bullseye b/files/build/versions/build/build-sonic-slave-bullseye/versions-deb-bullseye new file mode 100644 index 000000000000..3cbc13126aa2 --- /dev/null +++ b/files/build/versions/build/build-sonic-slave-bullseye/versions-deb-bullseye @@ -0,0 +1,77 @@ +applibs==1.mlnx.4.5.4206 +applibs-dev==1.mlnx.4.5.4206 +bfnplatform==1.0.0 +iproute2-dev==1.mlnx.4.5.4206 +isc-dhcp-relay==4.4.1-2.3+deb11u1 +kernel-mft-dkms==4.22.1-15 +libhiredis-dev==0.14.0-3~bpo9+1 +libhiredis0.14==0.14.0-3~bpo9+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-dev==3.5.0-1 +libsaibcm==8.4.0.2 +libsaibcm-dev==8.4.0.2 +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 +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.14.1 +libthrift0==0.14.1 +libyang==1.0.73 +libyang-cpp==1.0.73 +libyang-dev==1.0.73 +linux-headers-5.10.0-18-2-amd64==5.10.140-1 +linux-headers-5.10.0-18-2-common==5.10.140-1 +lldpd==1.0.4-1 +lm-sensors==1:3.6.0-7 +mft==4.22.1-15 +mlnx-sai==1.mlnx.SAIBuild2211.23.1.0 +net-tools==1.60+git20181103.0eebece-1 +python-thrift==0.11.0-4 +python3-swsscommon==1.0.0 +python3-thrift==0.14.1 +python3-yang==1.0.73 +sonic-dhcp6relay==1.0.0-0 +sonic-dhcpmon==1.0.0-0 +sonic-eventd==1.0.0-0 +sonic-linkmgrd==1.0.0-1 +sonic-mgmt-common==1.0.0 +sonic-mgmt-common-codegen==1.0.0 +sonic-platform-pddf==1.1 +sonic-platform-pddf-sym==1.1 +swss==1.0.0 +sx-acl-helper==1.mlnx.4.5.4206 +sx-acl-helper-dev==1.mlnx.4.5.4206 +sx-complib==1.mlnx.4.5.4206 +sx-complib-dev==1.mlnx.4.5.4206 +sx-examples==1.mlnx.4.5.4206 +sx-examples-dev==1.mlnx.4.5.4206 +sx-gen-utils==1.mlnx.4.5.4206 +sx-gen-utils-dev==1.mlnx.4.5.4206 +sx-hash-calc==1.mlnx.4.5.4206 +sx-scew==1.mlnx.4.5.4206 +sx-scew-dev==1.mlnx.4.5.4206 +sxd-libs==1.mlnx.4.5.4206 +sxd-libs-dev==1.mlnx.4.5.4206 +syncd==1.0.0 +syncd-vs==1.0.0 +thrift-compiler==0.14.1 +wjh-libs==1.mlnx.4.5.4206 +wjh-libs-dev==1.mlnx.4.5.4206 +wpasupplicant==2:2.9.0-14 \ No newline at end of file diff --git a/files/build/versions/build/build-sonic-slave-bullseye/versions-deb-bullseye-arm64 b/files/build/versions/build/build-sonic-slave-bullseye/versions-deb-bullseye-arm64 new file mode 100644 index 000000000000..3f9e16d7fe7d --- /dev/null +++ b/files/build/versions/build/build-sonic-slave-bullseye/versions-deb-bullseye-arm64 @@ -0,0 +1,3 @@ +libnl-3-200==3.5.0-1 +libnl-route-3-200==3.5.0-1 +linux-headers-5.10.0-18-2-arm64==5.10.140-1 \ No newline at end of file diff --git a/files/build/versions/build/build-sonic-slave-bullseye/versions-deb-bullseye-armhf b/files/build/versions/build/build-sonic-slave-bullseye/versions-deb-bullseye-armhf new file mode 100644 index 000000000000..0aa295c26174 --- /dev/null +++ b/files/build/versions/build/build-sonic-slave-bullseye/versions-deb-bullseye-armhf @@ -0,0 +1,3 @@ +libnl-3-200==3.5.0-1 +libnl-route-3-200==3.5.0-1 +linux-headers-5.10.0-18-2-armmp==5.10.140-1 \ No newline at end of file diff --git a/files/build/versions/build/build-sonic-slave-bullseye/versions-py3 b/files/build/versions/build/build-sonic-slave-bullseye/versions-py3 new file mode 100644 index 000000000000..89476acaf3c1 --- /dev/null +++ b/files/build/versions/build/build-sonic-slave-bullseye/versions-py3 @@ -0,0 +1,33 @@ +blessed==1.20.0 +charset-normalizer==3.1.0 +click-log==0.4.0 +colorful==0.5.5 +docker==6.0.1 +docker-image-py==0.1.12 +enlighten==1.11.2 +filelock==3.12.0 +ijson==2.6.1 +ipaddress==1.0.23 +jsondiff==2.0.0 +jsonpatch==1.32 +jsonpointer==2.3 +jsonschema==2.6.0 +natsort==6.2.1 +netaddr==0.8.0 +netifaces==0.11.0 +pddf-platform==1.0 +prefixed==0.7.0 +prettyprinter==0.18.0 +psutil==5.9.5 +pycairo==1.23.0 +pyroute2==0.5.19 +python-arptable==0.0.2 +semantic-version==2.10.0 +systemd-python==235 +tabulate==0.8.2 +thrift==0.14.1 +toposort==1.6 +wcwidth==0.2.6 +websocket-client==1.5.1 +www-authenticate==0.9.2 +xmltodict==0.12.0 \ No newline at end of file diff --git a/files/build/versions/build/build-sonic-slave-bullseye/versions-py3-all-arm64 b/files/build/versions/build/build-sonic-slave-bullseye/versions-py3-all-arm64 new file mode 100644 index 000000000000..52555db915bc --- /dev/null +++ b/files/build/versions/build/build-sonic-slave-bullseye/versions-py3-all-arm64 @@ -0,0 +1,5 @@ +bitarray==1.5.3 +click==7.0 +redis==3.5.3 +requests==2.28.2 +zipp==1.2.0 \ No newline at end of file diff --git a/files/build/versions/build/build-sonic-slave-bullseye/versions-py3-all-armhf b/files/build/versions/build/build-sonic-slave-bullseye/versions-py3-all-armhf new file mode 100644 index 000000000000..52555db915bc --- /dev/null +++ b/files/build/versions/build/build-sonic-slave-bullseye/versions-py3-all-armhf @@ -0,0 +1,5 @@ +bitarray==1.5.3 +click==7.0 +redis==3.5.3 +requests==2.28.2 +zipp==1.2.0 \ No newline at end of file diff --git a/files/build/versions/build/build-sonic-slave-bullseye/versions-web b/files/build/versions/build/build-sonic-slave-bullseye/versions-web new file mode 100644 index 000000000000..d3991fd05e4e --- /dev/null +++ b/files/build/versions/build/build-sonic-slave-bullseye/versions-web @@ -0,0 +1 @@ +https://deb.nodesource.com/setup_14.x==6c6544a971533fb0e3c6ef55b15e0c54 \ No newline at end of file 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..56e9f61b69dc --- /dev/null +++ b/files/build/versions/build/build-sonic-slave-buster/versions-deb-buster @@ -0,0 +1,36 @@ +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 +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 +libsaivs-dev==1.0.0 +libswsscommon==1.0.0 +libswsscommon-dev==1.0.0 +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 +libthrift0==0.14.1 +libyang==1.0.73 +libyang-cpp==1.0.73 +libyang-dev==1.0.73 +python-swsscommon==1.0.0 +python-thrift==0.11.0-4 +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 +swss==1.0.0 +syncd==1.0.0 +syncd-vs==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-buster/versions-deb-buster-arm64 b/files/build/versions/build/build-sonic-slave-buster/versions-deb-buster-arm64 new file mode 100644 index 000000000000..42cf30171591 --- /dev/null +++ b/files/build/versions/build/build-sonic-slave-buster/versions-deb-buster-arm64 @@ -0,0 +1,6 @@ +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-route-3-200==3.5.0-1 +libnl-route-3-dev==3.5.0-1 \ No newline at end of file diff --git a/files/build/versions/build/build-sonic-slave-buster/versions-deb-buster-armhf b/files/build/versions/build/build-sonic-slave-buster/versions-deb-buster-armhf new file mode 100644 index 000000000000..42cf30171591 --- /dev/null +++ b/files/build/versions/build/build-sonic-slave-buster/versions-deb-buster-armhf @@ -0,0 +1,6 @@ +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-route-3-200==3.5.0-1 +libnl-route-3-dev==3.5.0-1 \ 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..a21fc8345ac2 --- /dev/null +++ b/files/build/versions/build/build-sonic-slave-buster/versions-py2 @@ -0,0 +1,11 @@ +bitarray==1.5.3 +contextlib2==0.6.0.post1 +future==0.18.3 +importlib-resources==3.3.1 +natsort==6.2.1 +netaddr==0.8.0 +pyang==2.5.3 +pyangbind==0.6.0 +redis==3.5.3 +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-py2-all-arm64 b/files/build/versions/build/build-sonic-slave-buster/versions-py2-all-arm64 new file mode 100644 index 000000000000..5d5fdc227c5c --- /dev/null +++ b/files/build/versions/build/build-sonic-slave-buster/versions-py2-all-arm64 @@ -0,0 +1 @@ +ipaddress==1.0.23 \ No newline at end of file diff --git a/files/build/versions/build/build-sonic-slave-buster/versions-py2-all-armhf b/files/build/versions/build/build-sonic-slave-buster/versions-py2-all-armhf new file mode 100644 index 000000000000..5d5fdc227c5c --- /dev/null +++ b/files/build/versions/build/build-sonic-slave-buster/versions-py2-all-armhf @@ -0,0 +1 @@ +ipaddress==1.0.23 \ 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..b0503c54e8ef --- /dev/null +++ b/files/build/versions/build/build-sonic-slave-buster/versions-py3 @@ -0,0 +1,31 @@ +blessed==1.20.0 +charset-normalizer==3.1.0 +click==7.0 +click-log==0.4.0 +colorful==0.5.5 +dbus-python==1.3.2 +docker==6.0.1 +docker-image-py==0.1.12 +enlighten==1.11.2 +filelock==3.12.0 +ijson==2.6.1 +ipaddress==1.0.23 +jsondiff==2.0.0 +jsonpatch==1.32 +jsonpointer==2.3 +lazy-object-proxy==1.9.0 +natsort==6.2.1 +netaddr==0.8.0 +netifaces==0.11.0 +prefixed==0.7.0 +prettyprinter==0.18.0 +pycairo==1.23.0 +pyroute2==0.5.19 +semantic-version==2.10.0 +systemd-python==235 +tabulate==0.8.2 +toposort==1.6 +wcwidth==0.2.6 +websocket-client==1.5.1 +www-authenticate==0.9.2 +xmltodict==0.12.0 \ No newline at end of file diff --git a/files/build/versions/build/build-sonic-slave-buster/versions-py3-all-arm64 b/files/build/versions/build/build-sonic-slave-buster/versions-py3-all-arm64 new file mode 100644 index 000000000000..90c3699131cc --- /dev/null +++ b/files/build/versions/build/build-sonic-slave-buster/versions-py3-all-arm64 @@ -0,0 +1,2 @@ +bitarray==1.5.3 +redis==3.5.3 \ No newline at end of file diff --git a/files/build/versions/build/build-sonic-slave-buster/versions-py3-all-armhf b/files/build/versions/build/build-sonic-slave-buster/versions-py3-all-armhf new file mode 100644 index 000000000000..90c3699131cc --- /dev/null +++ b/files/build/versions/build/build-sonic-slave-buster/versions-py3-all-armhf @@ -0,0 +1,2 @@ +bitarray==1.5.3 +redis==3.5.3 \ No newline at end of file diff --git a/files/build/versions/default/versions-docker b/files/build/versions/default/versions-docker new file mode 100644 index 000000000000..98dc91f03235 --- /dev/null +++ b/files/build/versions/default/versions-docker @@ -0,0 +1,15 @@ +amd64:amd64/debian:bullseye==sha256:4effa16ae79ab36347d55ebb6bb4aad411077b72ad735054e684b3eeba373a35 +amd64:amd64/debian:buster==sha256:2803ab27dfe4f2e23b58d351e80e8d433942b6fb830225e6d034098ed450a169 +amd64:debian:bullseye==sha256:0a78ed641b76252739e28ebbbe8cdbd80dc367fba4502565ca839e5803cfd86e +amd64:debian:buster==sha256:173f0b19d2ac5ee17194dbe9a888a4a617dbf905ee666c9e780afad55eaf1d8c +amd64:debian:stretch==sha256:c5c5200ff1e9c73ffbf188b4a67eb1c91531b644856b4aefe86a58d2f0cb05be +arm64:arm64v8/debian:bullseye==sha256:c0f6422141bb031238126fbd535c0df24db4252a2d9876216a94082df74c8fda +arm64:arm64v8/debian:buster==sha256:55cd39723a057f730e9c33487fea9fe151bbe86dce51e92a73ccfd12206a1f43 +arm64:debian:bullseye==sha256:0a78ed641b76252739e28ebbbe8cdbd80dc367fba4502565ca839e5803cfd86e +arm64:debian:buster==sha256:173f0b19d2ac5ee17194dbe9a888a4a617dbf905ee666c9e780afad55eaf1d8c +arm64:debian:stretch==sha256:c5c5200ff1e9c73ffbf188b4a67eb1c91531b644856b4aefe86a58d2f0cb05be +armhf:arm32v7/debian:bullseye==sha256:ab0ce510343d33415fc4eaea0102da2d24cb720b185aaee0b411c48a07abb0de +armhf:arm32v7/debian:buster==sha256:3e45d273ad15d7b648212c8faa5e236f6fdc694af7272b8c4bd25a5d90c27fe1 +armhf:debian:bullseye==sha256:0a78ed641b76252739e28ebbbe8cdbd80dc367fba4502565ca839e5803cfd86e +armhf:debian:buster==sha256:173f0b19d2ac5ee17194dbe9a888a4a617dbf905ee666c9e780afad55eaf1d8c +armhf:debian:stretch==sha256:c5c5200ff1e9c73ffbf188b4a67eb1c91531b644856b4aefe86a58d2f0cb05be \ No newline at end of file diff --git a/files/build/versions/default/versions-git b/files/build/versions/default/versions-git new file mode 100644 index 000000000000..27e768b58178 --- /dev/null +++ b/files/build/versions/default/versions-git @@ -0,0 +1,2 @@ +https://chromium.googlesource.com/chromium/tools/depot_tools.git==9e36ef60d0b3b3da1d79cf388275697281d27f21 +https://github.com/aristanetworks/swi-tools.git==b5f087e4774168bf536360d43c9c509c8f14ad9f \ No newline at end of file diff --git a/files/build/versions/default/versions-mirror b/files/build/versions/default/versions-mirror new file mode 100644 index 000000000000..fe13c1762b41 --- /dev/null +++ b/files/build/versions/default/versions-mirror @@ -0,0 +1,20 @@ +deb.nodesource.com_node%5f10.x_dists_stretch==2021-04-06T21:05:39Z +deb.nodesource.com_node%5f14.x_dists_bullseye==2023-02-17T00:35:28Z +deb.nodesource.com_node%5f14.x_dists_buster==2023-02-17T00:35:28Z +debian==20230418T000224Z +debian-security==20230418T000228Z +download.docker.com_linux_debian_dists_bullseye==2023-04-17T19:08:09Z +download.docker.com_linux_debian_dists_buster==2023-04-17T19:08:10Z +download.docker.com_linux_debian_dists_stretch==2021-02-01T21:46:06Z +packages.microsoft.com_repos_sonic-dev_dists_jessie==2022-10-31T19:34:29Z +packages.trafficmanager.net_snapshot_debian-security_20230418T000228Z_dists_bullseye-security==2023-04-17T21:55:39Z +packages.trafficmanager.net_snapshot_debian-security_20230418T000228Z_dists_buster_updates==2023-04-17T21:55:38Z +packages.trafficmanager.net_snapshot_debian-security_20230418T000228Z_dists_stretch_updates==2023-02-18T04:22:44Z +packages.trafficmanager.net_snapshot_debian_20230418T000224Z_dists_bullseye==2022-12-17T10:14:37Z +packages.trafficmanager.net_snapshot_debian_20230418T000224Z_dists_bullseye-backports==2023-04-17T20:10:42Z +packages.trafficmanager.net_snapshot_debian_20230418T000224Z_dists_bullseye-updates==2023-04-17T20:10:42Z +packages.trafficmanager.net_snapshot_debian_20230418T000224Z_dists_buster==2022-09-10T11:30:54Z +packages.trafficmanager.net_snapshot_debian_20230418T000224Z_dists_buster-backports==2023-04-17T20:10:42Z +packages.trafficmanager.net_snapshot_debian_20230418T000224Z_dists_buster-updates==2023-04-17T20:10:42Z +packages.trafficmanager.net_snapshot_debian_20230418T000224Z_dists_stretch-backports==2023-03-30T14:20:42Z +packages.trafficmanager.net_snapshot_debian_20230418T000224Z_dists_stretch-updates==2021-08-14T07:47:11Z \ 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..c84863aad6c6 --- /dev/null +++ b/files/build/versions/default/versions-web @@ -0,0 +1,20 @@ +https://deb.nodesource.com/gpgkey/nodesource.gpg.key==003b51a89a133b5db4cca98b2dea3117 +https://deb.nodesource.com/node_10.x/dists/stretch/Release==22738118af583db3bfad39d6fcb4fa5a +https://deb.nodesource.com/node_14.x/dists/bullseye/Release==6b7d50c433d129d4c6fd95bdf56070fa +https://deb.nodesource.com/node_14.x/dists/buster/Release==42875141604382f0abb4d047f645dfe1 +https://deb.nodesource.com/setup_10.x==6742c0148159980e8f6e886df1f8bbe1 +https://deb.nodesource.com/setup_14.x==6c6544a971533fb0e3c6ef55b15e0c54 +https://download.docker.com/linux/debian/gpg==1afae06b34a13c1b3d9cb61a26285a15 +https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-amd64==abe26a71ce14950f94d858c317da94d1 +https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-arm64==2b326ca77b64a5cf7df04e80b4fdbca0 +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/cmake/cmake_3.13.2-1_bpo9%2B1_arm64.deb?st=2020-03-27T02%3A28%3A38Z&se=2100-03-26T19%3A00%3A00Z&sp=rl&sv=2018-03-28&sr=b&sig=rrHMkLi29aI8yH6s52ILCY8VcEbNFrzYT2DmC5RwOgs%3D==9bcc989e6ed168717f67c07e79177d4a +https://sonicstorage.blob.core.windows.net/packages/cmake/cmake_3.13.2-1_bpo9%2B1_armhf.deb?st=2020-03-27T02%3A29%3A41Z&se=2100-03-26T19%3A00%3A00Z&sp=rl&sv=2018-03-28&sr=b&sig=sWt7kxrFumn020d2GeutGJ716cuQsFwmAmgU%2BJ0kqnk%3D==b5625da7ac620a2ae869653b9e5318ed +https://sonicstorage.blob.core.windows.net/public/fips/bullseye/0.1/amd64/golang-1.15-go_1.15.15-1~deb11u4%2Bfips_amd64.deb==b60f6db62805696b47ab422ab798fe56 +https://sonicstorage.blob.core.windows.net/public/fips/bullseye/0.1/amd64/golang-1.15-src_1.15.15-1~deb11u4%2Bfips_amd64.deb==1c920937aa49b602a1bfec3c49747131 +https://sonicstorage.blob.core.windows.net/public/fips/bullseye/0.1/arm64/golang-1.15-go_1.15.15-1~deb11u4%2Bfips_arm64.deb==0b70c104b907db13ff2fe5d52b3d0008 +https://sonicstorage.blob.core.windows.net/public/fips/bullseye/0.1/arm64/golang-1.15-src_1.15.15-1~deb11u4%2Bfips_arm64.deb==1d06900f03424fa5ce34a782605983fe +https://storage.googleapis.com/golang/go1.14.2.linux-amd64.tar.gz==856d248e3ea8a287d13e5f6afd086282 +https://storage.googleapis.com/golang/go1.14.2.linux-arm64.tar.gz==e5f79b403701e00f20d13f0ea561b064 +https://storage.googleapis.com/golang/go1.14.2.linux-armv6l.tar.gz==04467414e783b18de4278e9f24baf4be \ No newline at end of file diff --git a/files/build/versions/dockers/docker-base-bullseye/versions-deb-bullseye b/files/build/versions/dockers/docker-base-bullseye/versions-deb-bullseye new file mode 100644 index 000000000000..b380a3007600 --- /dev/null +++ b/files/build/versions/dockers/docker-base-bullseye/versions-deb-bullseye @@ -0,0 +1,84 @@ +ca-certificates==20210119 +curl==7.74.0-1.3+deb11u7 +iproute2==5.10.0-4 +jq==1.6-2.1 +less==551-2 +libatomic1==10.2.1-6 +libbpf0==1:0.3-2 +libbrotli1==1.0.9-2+b2 +libbsd0==0.11.3-1 +libcap2==1:2.44-1 +libcap2-bin==1:2.44-1 +libcurl4==7.74.0-1.3+deb11u7 +libdaemon0==0.14-7.1 +libdbus-1-3==1.12.24-0+deb11u1 +libelf1==0.183-1 +libestr0==0.1.10-2.1+b1 +libexpat1==2.2.10-2+deb11u5 +libfastjson4==0.99.9-1 +libgdbm-compat4==1.19-2 +libgdbm6==1.19-2 +libjansson4==2.13.1-1.1 +libjemalloc2==5.2.1-3 +libjq1==1.6-2.1 +libldap-2.4-2==2.4.57+dfsg-3+deb11u1 +liblognorm5==2.0.5-1.1 +liblua5.1-0==5.1.5-8.1+b3 +liblzf1==3.6-3 +libmd0==1.0.3-3 +libmnl0==1.0.4-3 +libmpdec3==2.5.1-1 +libncurses6==6.2+20201114-2 +libncursesw6==6.2+20201114-2 +libnghttp2-14==1.43.0-1 +libnorm1==1.5.9+dfsg-2 +libonig5==6.9.6-1.1 +libperl5.32==5.32.1-4+deb11u2 +libpgm-5.3-0==5.3.128~dfsg-2 +libpopt0==1.18-2 +libprocps8==2:3.3.17-5 +libpsl5==0.21.0-1.2 +libpython3-stdlib==3.9.2-3 +libpython3.9-minimal==3.9.2-1 +libpython3.9-stdlib==3.9.2-1 +libreadline8==8.1-1 +librtmp1==2.4+20151223.gitfa8646d.1-2+b2 +libsasl2-2==2.1.27+dfsg-2.1+deb11u1 +libsasl2-modules-db==2.1.27+dfsg-2.1+deb11u1 +libsodium23==1.0.18-1 +libsqlite3-0==3.34.1-3 +libssh2-1==1.9.0-2 +libssl-dev==1.1.1n-0+deb11u4+fips +libssl1.1==1.1.1n-0+deb11u4+fips +libwrap0==7.6.q-31 +libxtables12==1.8.7-1 +libzmq5==4.3.4-1 +lua-bitop==1.0.2-5 +lua-cjson==2.1.0+dfsg-2.1 +media-types==4.0.0 +net-tools==1.60+git20181103.0eebece-1 +openssl==1.1.1n-0+deb11u4+fips +perl==5.32.1-4+deb11u2 +perl-modules-5.32==5.32.1-4+deb11u2 +procps==2:3.3.17-5 +python-is-python3==3.9.2-1 +python-pip-whl==20.3.4-4+deb11u1 +python3==3.9.2-3 +python3-distutils==3.9.2-1 +python3-lib2to3==3.9.2-1 +python3-minimal==3.9.2-3 +python3-pip==20.3.4-4+deb11u1 +python3-pkg-resources==52.0.0-4 +python3-setuptools==52.0.0-4 +python3-wheel==0.34.2-1 +python3.9==3.9.2-1 +python3.9-minimal==3.9.2-1 +readline-common==8.1-1 +redis-tools==5:6.0.16-1+deb11u2 +rsync==3.2.3-4+deb11u1 +rsyslog==8.2302.0-1~bpo11+1 +socat==1.7.4.1-3 +symcrypt-openssl==0.1 +vim-common==2:8.2.2434-3+deb11u1 +vim-tiny==2:8.2.2434-3+deb11u1 +xxd==2:8.2.2434-3+deb11u1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-base-bullseye/versions-deb-bullseye-armhf b/files/build/versions/dockers/docker-base-bullseye/versions-deb-bullseye-armhf new file mode 100644 index 000000000000..ecfd4bb3bb3d --- /dev/null +++ b/files/build/versions/dockers/docker-base-bullseye/versions-deb-bullseye-armhf @@ -0,0 +1 @@ +openssl==1.1.1n-0+deb11u4 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-base-bullseye/versions-py3 b/files/build/versions/dockers/docker-base-bullseye/versions-py3 new file mode 100644 index 000000000000..cf6bd999d21e --- /dev/null +++ b/files/build/versions/dockers/docker-base-bullseye/versions-py3 @@ -0,0 +1,6 @@ +j2cli==0.3.10 +jinja2==3.1.2 +markupsafe==2.1.2 +supervisor==4.2.1 +supervisord-dependent-startup==1.4.0 +toposort==1.10 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-base-buster/versions-deb-buster b/files/build/versions/dockers/docker-base-buster/versions-deb-buster new file mode 100644 index 000000000000..2051b9ef5b8e --- /dev/null +++ b/files/build/versions/dockers/docker-base-buster/versions-deb-buster @@ -0,0 +1,73 @@ +ca-certificates==20200601~deb10u2 +curl==7.64.0-4+deb10u5 +jq==1.5+dfsg-2+b1 +less==487-0.1+b1 +libatomic1==8.3.0-6 +libcurl4==7.64.0-4+deb10u5 +libdaemon0==0.14-7 +libdbus-1-3==1.12.24-0+deb10u1 +libestr0==0.1.10-2.1 +libexpat1==2.2.6-2+deb10u6 +libfastjson4==0.99.8-2 +libgdbm-compat4==1.18.1-4 +libgdbm6==1.18.1-4 +libgssapi-krb5-2==1.17-3+deb10u5 +libjansson4==2.12-1 +libjemalloc2==5.1.0-3 +libjq1==1.5+dfsg-2+b1 +libk5crypto3==1.17-3+deb10u5 +libkeyutils1==1.6-6 +libkrb5-3==1.17-3+deb10u5 +libkrb5support0==1.17-3+deb10u5 +libldap-2.4-2==2.4.47+dfsg-3+deb10u7 +libldap-common==2.4.47+dfsg-3+deb10u7 +liblognorm5==2.0.5-1 +liblua5.1-0==5.1.5-8.1+b2 +libmpdec2==2.4.2-2 +libncurses6==6.1+20181013-2+deb10u3 +libnghttp2-14==1.36.0-2+deb10u1 +libnorm1==1.5.8+dfsg2-1 +libonig5==6.9.1-1 +libperl5.28==5.28.1-6+deb10u1 +libpgm-5.2-0==5.2.122~dfsg-3 +libpopt0==1.16-12 +libprocps7==2:3.3.15-2 +libpsl5==0.20.2-2 +libpython3-stdlib==3.7.3-1 +libpython3.7-minimal==3.7.3-2+deb10u4 +libpython3.7-stdlib==3.7.3-2+deb10u4 +libreadline7==7.0-5 +librtmp1==2.4+20151223.gitfa8646d.1-2 +libsasl2-2==2.1.27+dfsg-1+deb10u2 +libsasl2-modules-db==2.1.27+dfsg-1+deb10u2 +libsodium23==1.0.17-1 +libsqlite3-0==3.27.2-3+deb10u2 +libssh2-1==1.8.0-2.1 +libssl1.1==1.1.1n-0+deb10u4 +libwrap0==7.6.q-28 +libzmq5==4.3.1-4+deb10u2 +lsb-base==10.2019051400 +lua-bitop==1.0.2-5 +lua-cjson==2.1.0+dfsg-2.1 +mime-support==3.62 +net-tools==1.60+git20180626.aebd88e-1 +openssl==1.1.1n-0+deb10u4 +perl==5.28.1-6+deb10u1 +perl-modules-5.28==5.28.1-6+deb10u1 +procps==2:3.3.15-2 +python-pip-whl==18.1-5 +python3==3.7.3-1 +python3-distutils==3.7.3-1 +python3-lib2to3==3.7.3-1 +python3-minimal==3.7.3-1 +python3-pip==18.1-5 +python3.7==3.7.3-2+deb10u4 +python3.7-minimal==3.7.3-2+deb10u4 +readline-common==7.0-5 +redis-tools==5:6.0.6-1~bpo10+1 +rsync==3.1.3-6 +rsyslog==8.1901.0-1+deb10u2 +socat==1.7.4.1-3 +vim-common==2:8.1.0875-5+deb10u4 +vim-tiny==2:8.1.0875-5+deb10u4 +xxd==2:8.1.0875-5+deb10u4 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-base-buster/versions-py3 b/files/build/versions/dockers/docker-base-buster/versions-py3 new file mode 100644 index 000000000000..cf6bd999d21e --- /dev/null +++ b/files/build/versions/dockers/docker-base-buster/versions-py3 @@ -0,0 +1,6 @@ +j2cli==0.3.10 +jinja2==3.1.2 +markupsafe==2.1.2 +supervisor==4.2.1 +supervisord-dependent-startup==1.4.0 +toposort==1.10 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-config-engine-bullseye/versions-deb-bullseye b/files/build/versions/dockers/docker-config-engine-bullseye/versions-deb-bullseye new file mode 100644 index 000000000000..f612b1f13c03 --- /dev/null +++ b/files/build/versions/dockers/docker-config-engine-bullseye/versions-deb-bullseye @@ -0,0 +1,63 @@ +apt-utils==2.2.4 +binutils==2.35.2-2 +binutils-common==2.35.2-2 +binutils-x86-64-linux-gnu==2.35.2-2 +build-essential==12.9 +bzip2==1.0.8-4 +cpp==4:10.2.1-1 +cpp-10==10.2.1-6 +dpkg-dev==1.20.12 +g++==4:10.2.1-1 +g++-10==10.2.1-6 +gcc==4:10.2.1-1 +gcc-10==10.2.1-6 +libasan6==10.2.1-6 +libbinutils==2.35.2-2 +libboost-serialization1.74.0==1.74.0-9 +libc-dev-bin==2.31-13+deb11u5 +libc6-dev==2.31-13+deb11u5 +libcc1-0==10.2.1-6 +libcrypt-dev==1:4.4.18-4 +libctf-nobfd0==2.35.2-2 +libctf0==2.35.2-2 +libdpkg-perl==1.20.12 +libexpat1-dev==2.2.10-2+deb11u5 +libgcc-10-dev==10.2.1-6 +libgomp1==10.2.1-6 +libhiredis0.14==0.14.0-3~bpo9+1 +libisl23==0.23-1 +libitm1==10.2.1-6 +libjs-jquery==3.5.1+dfsg+~3.5.5-7 +libjs-sphinxdoc==3.4.3-2 +libjs-underscore==1.9.1~dfsg-3 +liblsan0==10.2.1-6 +libmpc3==1.2.0-1 +libmpfr6==4.1.0-3 +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 +libnsl-dev==1.3.0-2 +libpython3-dev==3.9.2-3 +libpython3.9==3.9.2-1 +libpython3.9-dev==3.9.2-1 +libquadmath0==10.2.1-6 +libstdc++-10-dev==10.2.1-6 +libswsscommon==1.0.0 +libtirpc-dev==1.3.1-1+deb11u1 +libtsan0==10.2.1-6 +libubsan1==10.2.1-6 +libyang==1.0.73 +libyang-cpp==1.0.73 +linux-libc-dev==5.10.162-1 +make==4.3-4.1 +patch==2.7.6-7 +python3-dev==3.9.2-3 +python3-swsscommon==1.0.0 +python3-yang==1.0.73 +python3.9-dev==3.9.2-1 +sonic-db-cli==1.0.0 +sonic-eventd==1.0.0-0 +xz-utils==5.2.5-2.1~deb11u1 +zlib1g-dev==1:1.2.11.dfsg-2+deb11u2 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-config-engine-bullseye/versions-deb-bullseye-arm64 b/files/build/versions/dockers/docker-config-engine-bullseye/versions-deb-bullseye-arm64 new file mode 100644 index 000000000000..304462fd3b28 --- /dev/null +++ b/files/build/versions/dockers/docker-config-engine-bullseye/versions-deb-bullseye-arm64 @@ -0,0 +1,8 @@ +binutils-aarch64-linux-gnu==2.35.2-2 +icu-devtools==67.1-7 +libicu-dev==67.1-7 +libicu67==67.1-7 +libxml2==2.9.10+dfsg-6.7+deb11u3 +libxml2-dev==2.9.10+dfsg-6.7+deb11u3 +libxslt1-dev==1.1.34-4+deb11u1 +libxslt1.1==1.1.34-4+deb11u1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-config-engine-bullseye/versions-deb-bullseye-armhf b/files/build/versions/dockers/docker-config-engine-bullseye/versions-deb-bullseye-armhf new file mode 100644 index 000000000000..166eee84b72c --- /dev/null +++ b/files/build/versions/dockers/docker-config-engine-bullseye/versions-deb-bullseye-armhf @@ -0,0 +1,8 @@ +binutils-arm-linux-gnueabihf==2.35.2-2 +icu-devtools==67.1-7 +libicu-dev==67.1-7 +libicu67==67.1-7 +libxml2==2.9.10+dfsg-6.7+deb11u3 +libxml2-dev==2.9.10+dfsg-6.7+deb11u3 +libxslt1-dev==1.1.34-4+deb11u1 +libxslt1.1==1.1.34-4+deb11u1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-config-engine-bullseye/versions-py3 b/files/build/versions/dockers/docker-config-engine-bullseye/versions-py3 new file mode 100644 index 000000000000..2b67ea89010f --- /dev/null +++ b/files/build/versions/dockers/docker-config-engine-bullseye/versions-py3 @@ -0,0 +1,17 @@ +async-timeout==4.0.2 +bitarray==1.5.3 +ijson==2.6.1 +ipaddress==1.0.23 +jsondiff==2.0.0 +lxml==4.9.1 +natsort==6.2.1 +netaddr==0.8.0 +pyang==2.5.3 +pyangbind==0.8.1 +pyyaml==5.4.1 +redis==4.5.4 +redis-dump-load==1.1 +regex==2023.3.23 +six==1.16.0 +tabulate==0.8.2 +xmltodict==0.12.0 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-config-engine-buster/versions-deb-buster b/files/build/versions/dockers/docker-config-engine-buster/versions-deb-buster new file mode 100644 index 000000000000..a3a05ab0e702 --- /dev/null +++ b/files/build/versions/dockers/docker-config-engine-buster/versions-deb-buster @@ -0,0 +1,56 @@ +apt-utils==1.8.2.3 +binutils==2.31.1-16 +binutils-common==2.31.1-16 +binutils-x86-64-linux-gnu==2.31.1-16 +build-essential==12.6 +bzip2==1.0.6-9.2~deb10u2 +cpp==4:8.3.0-1 +cpp-8==8.3.0-6 +dh-python==3.20190308 +dpkg-dev==1.19.8 +g++==4:8.3.0-1 +g++-8==8.3.0-6 +gcc==4:8.3.0-1 +gcc-8==8.3.0-6 +libapt-inst2.0==1.8.2.3 +libasan5==8.3.0-6 +libbinutils==2.31.1-16 +libboost-serialization1.71.0==1.71.0-6~bpo10+1 +libc-dev-bin==2.28-10+deb10u2 +libc6-dev==2.28-10+deb10u2 +libcc1-0==8.3.0-6 +libdpkg-perl==1.19.8 +libexpat1-dev==2.2.6-2+deb10u6 +libgcc-8-dev==8.3.0-6 +libgomp1==8.3.0-6 +libhiredis0.14==0.14.0-3~bpo9+1 +libisl19==0.20-2 +libitm1==8.3.0-6 +liblsan0==8.3.0-6 +libmpc3==1.1.0-1 +libmpfr6==4.0.2-1 +libmpx2==8.3.0-6 +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 +libpython3-dev==3.7.3-1 +libpython3.7==3.7.3-2+deb10u4 +libpython3.7-dev==3.7.3-2+deb10u4 +libquadmath0==8.3.0-6 +libstdc++-8-dev==8.3.0-6 +libswsscommon==1.0.0 +libtsan0==8.3.0-6 +libubsan1==8.3.0-6 +libyang==1.0.73 +libyang-cpp==1.0.73 +linux-libc-dev==4.19.269-1 +make==4.2.1-1.2 +patch==2.7.6-3+deb10u1 +python3-dev==3.7.3-1 +python3-swsscommon==1.0.0 +python3-yang==1.0.73 +python3.7-dev==3.7.3-2+deb10u4 +sonic-db-cli==1.0.0 +xz-utils==5.2.4-1+deb10u1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-config-engine-buster/versions-deb-buster-arm64 b/files/build/versions/dockers/docker-config-engine-buster/versions-deb-buster-arm64 new file mode 100644 index 000000000000..cebc4572f178 --- /dev/null +++ b/files/build/versions/dockers/docker-config-engine-buster/versions-deb-buster-arm64 @@ -0,0 +1,11 @@ +binutils-aarch64-linux-gnu==2.31.1-16 +icu-devtools==63.1-6+deb10u3 +libglib2.0-0==2.58.3-2+deb10u4 +libicu-dev==63.1-6+deb10u3 +libicu63==63.1-6+deb10u3 +libxml2==2.9.4+dfsg1-7+deb10u5 +libxml2-dev==2.9.4+dfsg1-7+deb10u5 +libxslt1-dev==1.1.32-2.2~deb10u2 +libxslt1.1==1.1.32-2.2~deb10u2 +pkg-config==0.29-6 +zlib1g-dev==1:1.2.11.dfsg-1+deb10u2 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-config-engine-buster/versions-deb-buster-armhf b/files/build/versions/dockers/docker-config-engine-buster/versions-deb-buster-armhf new file mode 100644 index 000000000000..094a0ed6f29b --- /dev/null +++ b/files/build/versions/dockers/docker-config-engine-buster/versions-deb-buster-armhf @@ -0,0 +1,11 @@ +binutils-arm-linux-gnueabihf==2.31.1-16 +icu-devtools==63.1-6+deb10u3 +libglib2.0-0==2.58.3-2+deb10u4 +libicu-dev==63.1-6+deb10u3 +libicu63==63.1-6+deb10u3 +libxml2==2.9.4+dfsg1-7+deb10u5 +libxml2-dev==2.9.4+dfsg1-7+deb10u5 +libxslt1-dev==1.1.32-2.2~deb10u2 +libxslt1.1==1.1.32-2.2~deb10u2 +pkg-config==0.29-6 +zlib1g-dev==1:1.2.11.dfsg-1+deb10u2 \ 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..cdfc0130afa7 --- /dev/null +++ b/files/build/versions/dockers/docker-config-engine-buster/versions-py3 @@ -0,0 +1,20 @@ +async-timeout==4.0.2 +bitarray==1.5.3 +ijson==2.6.1 +importlib-metadata==6.5.0 +ipaddress==1.0.23 +jsondiff==2.0.0 +lxml==4.9.1 +natsort==6.2.1 +netaddr==0.8.0 +pyang==2.5.3 +pyangbind==0.8.1 +pyyaml==5.4.1 +redis==4.5.4 +redis-dump-load==1.1 +regex==2022.10.31 +six==1.16.0 +tabulate==0.8.2 +typing_extensions==4.5.0 +xmltodict==0.12.0 +zipp==3.15.0 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-database-dbg-sonic/versions-deb-bullseye b/files/build/versions/dockers/docker-database-dbg-sonic/versions-deb-bullseye new file mode 100644 index 000000000000..8659cd1e0964 --- /dev/null +++ b/files/build/versions/dockers/docker-database-dbg-sonic/versions-deb-bullseye @@ -0,0 +1,25 @@ +gdb==10.1-1.7 +gdbserver==10.1-1.7 +libbabeltrace1==1.5.8-1+b3 +libboost-regex1.74.0==1.74.0-9 +libcbor0==0.5.0+dfsg-2 +libcurl3-gnutls==7.74.0-1.3+deb11u3 +libdebuginfod1==0.183-1 +libdw1==0.183-1 +libedit2==3.1-20191231-2+b1 +libfido2-1==1.6.0-2 +libglib2.0-0==2.66.8-1 +libgpm2==1.20.7-8 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libicu67==67.1-7 +libipt2==2.0.3-1 +libmpfr6==4.1.0-3 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libswsscommon-dbg==1.0.0 +libunwind8==1.3.2-2 +openssh-client==1:8.4p1-5+deb11u1 +sshpass==1.09-1+b1 +strace==5.10-1 +vim==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-database/versions-deb-bullseye b/files/build/versions/dockers/docker-database/versions-deb-bullseye new file mode 100644 index 000000000000..2e7379318da8 --- /dev/null +++ b/files/build/versions/dockers/docker-database/versions-deb-bullseye @@ -0,0 +1,26 @@ +gdb==10.1-1.7 +gdbserver==10.1-1.7 +libbabeltrace1==1.5.8-1+b3 +libboost-regex1.74.0==1.74.0-9 +libcbor0==0.5.0+dfsg-2 +libcurl3-gnutls==7.74.0-1.3+deb11u7 +libdebuginfod1==0.183-1 +libdw1==0.183-1 +libedit2==3.1-20191231-2+b1 +libfido2-1==1.6.0-2 +libglib2.0-0==2.66.8-1 +libgpm2==1.20.7-8 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libicu67==67.1-7 +libipt2==2.0.3-1 +libmpfr6==4.1.0-3 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libswsscommon-dbgsym==1.0.0 +libunwind8==1.3.2-2 +openssh-client==1:8.4p1-5+deb11u1 +redis-server==5:6.0.16-1+deb11u2 +sshpass==1.09-1+b1 +strace==5.10-1 +vim==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-dhcp-relay-dbg-sonic/versions-deb-bullseye b/files/build/versions/dockers/docker-dhcp-relay-dbg-sonic/versions-deb-bullseye new file mode 100644 index 000000000000..cc9ac6929152 --- /dev/null +++ b/files/build/versions/dockers/docker-dhcp-relay-dbg-sonic/versions-deb-bullseye @@ -0,0 +1,28 @@ +gdb==10.1-1.7 +gdbserver==10.1-1.7 +isc-dhcp-relay-dbgsym==4.4.1-2.3 +libbabeltrace1==1.5.8-1+b3 +libboost-regex1.74.0==1.74.0-9 +libcbor0==0.5.0+dfsg-2 +libcurl3-gnutls==7.74.0-1.3+deb11u3 +libdebuginfod1==0.183-1 +libdw1==0.183-1 +libedit2==3.1-20191231-2+b1 +libfido2-1==1.6.0-2 +libglib2.0-0==2.66.8-1 +libgpm2==1.20.7-8 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libicu67==67.1-7 +libipt2==2.0.3-1 +libmpfr6==4.1.0-3 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libswsscommon-dbg==1.0.0 +libunwind8==1.3.2-2 +openssh-client==1:8.4p1-5+deb11u1 +sonic-dhcp6relay-dbgsym==1.0.0-0 +sonic-dhcpmon-dbgsym==1.0.0-0 +sshpass==1.09-1+b1 +strace==5.10-1 +vim==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-dhcp-relay/versions-deb-bullseye b/files/build/versions/dockers/docker-dhcp-relay/versions-deb-bullseye new file mode 100644 index 000000000000..462107ed08a0 --- /dev/null +++ b/files/build/versions/dockers/docker-dhcp-relay/versions-deb-bullseye @@ -0,0 +1,40 @@ +gdb==10.1-1.7 +gdbserver==10.1-1.7 +isc-dhcp-relay==4.4.1-2.3+deb11u1 +isc-dhcp-relay-dbgsym==4.4.1-2.3+deb11u1 +libbabeltrace1==1.5.8-1+b3 +libboost-regex1.74.0==1.74.0-9 +libboost-thread1.74.0==1.74.0-9 +libcbor0==0.5.0+dfsg-2 +libcurl3-gnutls==7.74.0-1.3+deb11u7 +libdebuginfod1==0.183-1 +libdns-export1110==1:9.11.19+dfsg-2.1 +libdw1==0.183-1 +libedit2==3.1-20191231-2+b1 +libevent-2.1-7==2.1.12-stable-1 +libexplain51==1.4.D001-11 +libfido2-1==1.6.0-2 +libglib2.0-0==2.66.8-1 +libgpm2==1.20.7-8 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libicu67==67.1-7 +libipt2==2.0.3-1 +libirs-export161==1:9.11.19+dfsg-2.1 +libisc-export1105==1:9.11.19+dfsg-2.1 +libisccfg-export163==1:9.11.19+dfsg-2.1 +libmpfr6==4.1.0-3 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libswsscommon-dbgsym==1.0.0 +libunwind8==1.3.2-2 +lsof==4.93.2+dfsg-1.1 +openssh-client==1:8.4p1-5+deb11u1 +sonic-dhcp6relay==1.0.0-0 +sonic-dhcp6relay-dbgsym==1.0.0-0 +sonic-dhcpmon==1.0.0-0 +sonic-dhcpmon-dbgsym==1.0.0-0 +sonic-rsyslog-plugin==1.0.0-0 +sshpass==1.09-1+b1 +strace==5.10-1 +vim==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-eventd-dbg-sonic/versions-deb-bullseye b/files/build/versions/dockers/docker-eventd-dbg-sonic/versions-deb-bullseye new file mode 100644 index 000000000000..f440ce5c43f7 --- /dev/null +++ b/files/build/versions/dockers/docker-eventd-dbg-sonic/versions-deb-bullseye @@ -0,0 +1,26 @@ +gdb==10.1-1.7 +gdbserver==10.1-1.7 +libbabeltrace1==1.5.8-1+b3 +libboost-regex1.74.0==1.74.0-9 +libcbor0==0.5.0+dfsg-2 +libcurl3-gnutls==7.74.0-1.3+deb11u3 +libdebuginfod1==0.183-1 +libdw1==0.183-1 +libedit2==3.1-20191231-2+b1 +libfido2-1==1.6.0-2 +libglib2.0-0==2.66.8-1 +libgpm2==1.20.7-8 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libicu67==67.1-7 +libipt2==2.0.3-1 +libmpfr6==4.1.0-3 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libswsscommon-dbg==1.0.0 +libunwind8==1.3.2-2 +openssh-client==1:8.4p1-5+deb11u1 +sonic-eventd-dbgsym==1.0.0-0 +sshpass==1.09-1+b1 +strace==5.10-1 +vim==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-eventd/versions-deb-bullseye b/files/build/versions/dockers/docker-eventd/versions-deb-bullseye new file mode 100644 index 000000000000..f63c4ea8ca23 --- /dev/null +++ b/files/build/versions/dockers/docker-eventd/versions-deb-bullseye @@ -0,0 +1,26 @@ +gdb==10.1-1.7 +gdbserver==10.1-1.7 +libbabeltrace1==1.5.8-1+b3 +libboost-regex1.74.0==1.74.0-9 +libcbor0==0.5.0+dfsg-2 +libcurl3-gnutls==7.74.0-1.3+deb11u7 +libdebuginfod1==0.183-1 +libdw1==0.183-1 +libedit2==3.1-20191231-2+b1 +libfido2-1==1.6.0-2 +libglib2.0-0==2.66.8-1 +libgpm2==1.20.7-8 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libicu67==67.1-7 +libipt2==2.0.3-1 +libmpfr6==4.1.0-3 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libswsscommon-dbgsym==1.0.0 +libunwind8==1.3.2-2 +openssh-client==1:8.4p1-5+deb11u1 +sonic-eventd-dbgsym==1.0.0-0 +sshpass==1.09-1+b1 +strace==5.10-1 +vim==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-fpm-frr-dbg-sonic/versions-deb-bullseye b/files/build/versions/dockers/docker-fpm-frr-dbg-sonic/versions-deb-bullseye new file mode 100644 index 000000000000..22584751c5b5 --- /dev/null +++ b/files/build/versions/dockers/docker-fpm-frr-dbg-sonic/versions-deb-bullseye @@ -0,0 +1,28 @@ +frr-dbgsym==8.2.2-sonic-0 +frr-snmp-dbgsym==8.2.2-sonic-0 +gdb==10.1-1.7 +gdbserver==10.1-1.7 +libbabeltrace1==1.5.8-1+b3 +libboost-regex1.74.0==1.74.0-9 +libcbor0==0.5.0+dfsg-2 +libcurl3-gnutls==7.74.0-1.3+deb11u3 +libdebuginfod1==0.183-1 +libdw1==0.183-1 +libedit2==3.1-20191231-2+b1 +libfido2-1==1.6.0-2 +libglib2.0-0==2.66.8-1 +libgpm2==1.20.7-8 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libicu67==67.1-7 +libipt2==2.0.3-1 +libmpfr6==4.1.0-3 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libswsscommon-dbg==1.0.0 +libyang2-dbgsym==2.0.112-6 +openssh-client==1:8.4p1-5+deb11u1 +sshpass==1.09-1+b1 +strace==5.10-1 +swss-dbg==1.0.0 +vim==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-fpm-frr/versions-deb-bullseye b/files/build/versions/dockers/docker-fpm-frr/versions-deb-bullseye new file mode 100644 index 000000000000..97fcb9f3e24b --- /dev/null +++ b/files/build/versions/dockers/docker-fpm-frr/versions-deb-bullseye @@ -0,0 +1,45 @@ +cron==3.0pl1-137 +frr==8.2.2-sonic-0 +frr-dbgsym==8.2.2-sonic-0 +frr-snmp==8.2.2-sonic-0 +frr-snmp-dbgsym==8.2.2-sonic-0 +gdb==10.1-1.7 +gdbserver==10.1-1.7 +libbabeltrace1==1.5.8-1+b3 +libboost-regex1.74.0==1.74.0-9 +libc-ares2==1.17.1-1+deb11u1 +libcbor0==0.5.0+dfsg-2 +libcurl3-gnutls==7.74.0-1.3+deb11u7 +libdebuginfod1==0.183-1 +libdw1==0.183-1 +libedit2==3.1-20191231-2+b1 +libfido2-1==1.6.0-2 +libglib2.0-0==2.66.8-1 +libgpm2==1.20.7-8 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libicu67==67.1-7 +libipt2==2.0.3-1 +libjson-c5==0.15-2 +libmpfr6==4.1.0-3 +libpci3==1:3.7.0-5 +libsensors-config==1:3.6.0-7 +libsensors5==1:3.6.0-7 +libsnmp-base==5.9+dfsg-4+deb11u1 +libsnmp40==5.9+dfsg-4+deb11u1 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libswsscommon-dbgsym==1.0.0 +libunwind8==1.3.2-2 +libyang2==2.0.112-6 +libyang2-dbgsym==2.0.112-6 +logrotate==3.18.0-2+deb11u1 +lsof==4.93.2+dfsg-1.1 +openssh-client==1:8.4p1-5+deb11u1 +pci.ids==0.0~2021.02.08-1 +sensible-utils==0.0.14 +sonic-rsyslog-plugin==1.0.0-0 +sshpass==1.09-1+b1 +strace==5.10-1 +swss-dbg==1.0.0 +vim==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 \ 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-broncos-dbg-sonic/versions-deb-bullseye b/files/build/versions/dockers/docker-gbsyncd-broncos-dbg-sonic/versions-deb-bullseye new file mode 100644 index 000000000000..8659cd1e0964 --- /dev/null +++ b/files/build/versions/dockers/docker-gbsyncd-broncos-dbg-sonic/versions-deb-bullseye @@ -0,0 +1,25 @@ +gdb==10.1-1.7 +gdbserver==10.1-1.7 +libbabeltrace1==1.5.8-1+b3 +libboost-regex1.74.0==1.74.0-9 +libcbor0==0.5.0+dfsg-2 +libcurl3-gnutls==7.74.0-1.3+deb11u3 +libdebuginfod1==0.183-1 +libdw1==0.183-1 +libedit2==3.1-20191231-2+b1 +libfido2-1==1.6.0-2 +libglib2.0-0==2.66.8-1 +libgpm2==1.20.7-8 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libicu67==67.1-7 +libipt2==2.0.3-1 +libmpfr6==4.1.0-3 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libswsscommon-dbg==1.0.0 +libunwind8==1.3.2-2 +openssh-client==1:8.4p1-5+deb11u1 +sshpass==1.09-1+b1 +strace==5.10-1 +vim==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-gbsyncd-broncos/versions-deb-bullseye b/files/build/versions/dockers/docker-gbsyncd-broncos/versions-deb-bullseye new file mode 100644 index 000000000000..11871bc77364 --- /dev/null +++ b/files/build/versions/dockers/docker-gbsyncd-broncos/versions-deb-bullseye @@ -0,0 +1,39 @@ +gdb==10.1-1.7 +gdbserver==10.1-1.7 +libbabeltrace1==1.5.8-1+b3 +libboost-regex1.74.0==1.74.0-9 +libc-dev-bin==2.31-13+deb11u5 +libc6-dev==2.31-13+deb11u5 +libcbor0==0.5.0+dfsg-2 +libcrypt-dev==1:4.4.18-4 +libcurl3-gnutls==7.74.0-1.3+deb11u7 +libdebuginfod1==0.183-1 +libdw1==0.183-1 +libedit2==3.1-20191231-2+b1 +libfido2-1==1.6.0-2 +libglib2.0-0==2.66.8-1 +libgpm2==1.20.7-8 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libicu67==67.1-7 +libipt2==2.0.3-1 +libmpfr6==4.1.0-3 +libnsl-dev==1.3.0-2 +libprotobuf-dev==3.12.4-1 +libprotobuf-lite23==3.12.4-1 +libprotobuf23==3.12.4-1 +libsaibroncos==3.8 +libsaimetadata==1.0.0 +libsairedis==1.0.0 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libswsscommon-dbgsym==1.0.0 +libtirpc-dev==1.3.1-1+deb11u1 +libunwind8==1.3.2-2 +linux-libc-dev==5.10.162-1 +openssh-client==1:8.4p1-5+deb11u1 +sshpass==1.09-1+b1 +strace==5.10-1 +syncd==1.0.0 +vim==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 +zlib1g-dev==1:1.2.11.dfsg-2+deb11u2 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-gbsyncd-credo-dbg-sonic/versions-deb-bullseye b/files/build/versions/dockers/docker-gbsyncd-credo-dbg-sonic/versions-deb-bullseye new file mode 100644 index 000000000000..8659cd1e0964 --- /dev/null +++ b/files/build/versions/dockers/docker-gbsyncd-credo-dbg-sonic/versions-deb-bullseye @@ -0,0 +1,25 @@ +gdb==10.1-1.7 +gdbserver==10.1-1.7 +libbabeltrace1==1.5.8-1+b3 +libboost-regex1.74.0==1.74.0-9 +libcbor0==0.5.0+dfsg-2 +libcurl3-gnutls==7.74.0-1.3+deb11u3 +libdebuginfod1==0.183-1 +libdw1==0.183-1 +libedit2==3.1-20191231-2+b1 +libfido2-1==1.6.0-2 +libglib2.0-0==2.66.8-1 +libgpm2==1.20.7-8 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libicu67==67.1-7 +libipt2==2.0.3-1 +libmpfr6==4.1.0-3 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libswsscommon-dbg==1.0.0 +libunwind8==1.3.2-2 +openssh-client==1:8.4p1-5+deb11u1 +sshpass==1.09-1+b1 +strace==5.10-1 +vim==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-gbsyncd-credo/versions-deb-bullseye b/files/build/versions/dockers/docker-gbsyncd-credo/versions-deb-bullseye new file mode 100644 index 000000000000..50bbb06d9dc4 --- /dev/null +++ b/files/build/versions/dockers/docker-gbsyncd-credo/versions-deb-bullseye @@ -0,0 +1,30 @@ +gdb==10.1-1.7 +gdbserver==10.1-1.7 +libbabeltrace1==1.5.8-1+b3 +libboost-regex1.74.0==1.74.0-9 +libcbor0==0.5.0+dfsg-2 +libcurl3-gnutls==7.74.0-1.3+deb11u7 +libdebuginfod1==0.183-1 +libdw1==0.183-1 +libedit2==3.1-20191231-2+b1 +libfido2-1==1.6.0-2 +libglib2.0-0==2.66.8-1 +libgpm2==1.20.7-8 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libicu67==67.1-7 +libipt2==2.0.3-1 +libmpfr6==4.1.0-3 +libsaicredo==0.9.0 +libsaicredo-owl==0.9.0 +libsaimetadata==1.0.0 +libsairedis==1.0.0 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libswsscommon-dbgsym==1.0.0 +libunwind8==1.3.2-2 +openssh-client==1:8.4p1-5+deb11u1 +sshpass==1.09-1+b1 +strace==5.10-1 +syncd==1.0.0 +vim==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-gbsyncd-vs-dbg-sonic/versions-deb-bullseye b/files/build/versions/dockers/docker-gbsyncd-vs-dbg-sonic/versions-deb-bullseye new file mode 100644 index 000000000000..95b5dc0410f7 --- /dev/null +++ b/files/build/versions/dockers/docker-gbsyncd-vs-dbg-sonic/versions-deb-bullseye @@ -0,0 +1,29 @@ +gdb==10.1-1.7 +gdbserver==10.1-1.7 +libbabeltrace1==1.5.8-1+b3 +libboost-regex1.74.0==1.74.0-9 +libcbor0==0.5.0+dfsg-2 +libcurl3-gnutls==7.74.0-1.3+deb11u3 +libdebuginfod1==0.183-1 +libdw1==0.183-1 +libedit2==3.1-20191231-2+b1 +libfido2-1==1.6.0-2 +libglib2.0-0==2.66.8-1 +libgpm2==1.20.7-8 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libicu67==67.1-7 +libipt2==2.0.3-1 +libmpfr6==4.1.0-3 +libsaimetadata-dbg==1.0.0 +libsairedis-dbg==1.0.0 +libsaivs-dbg==1.0.0 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libswsscommon-dbg==1.0.0 +libunwind8==1.3.2-2 +openssh-client==1:8.4p1-5+deb11u1 +sshpass==1.09-1+b1 +strace==5.10-1 +syncd-vs-dbg==1.0.0 +vim==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-gbsyncd-vs/versions-deb-bullseye b/files/build/versions/dockers/docker-gbsyncd-vs/versions-deb-bullseye new file mode 100644 index 000000000000..597f07e60f6d --- /dev/null +++ b/files/build/versions/dockers/docker-gbsyncd-vs/versions-deb-bullseye @@ -0,0 +1,34 @@ +gdb==10.1-1.7 +gdbserver==10.1-1.7 +libbabeltrace1==1.5.8-1+b3 +libboost-regex1.74.0==1.74.0-9 +libcbor0==0.5.0+dfsg-2 +libcurl3-gnutls==7.74.0-1.3+deb11u7 +libdebuginfod1==0.183-1 +libdw1==0.183-1 +libedit2==3.1-20191231-2+b1 +libfido2-1==1.6.0-2 +libglib2.0-0==2.66.8-1 +libgpm2==1.20.7-8 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libicu67==67.1-7 +libipt2==2.0.3-1 +libmpfr6==4.1.0-3 +libsaimetadata==1.0.0 +libsaimetadata-dbg==1.0.0 +libsairedis==1.0.0 +libsairedis-dbg==1.0.0 +libsaivs==1.0.0 +libsaivs-dbg==1.0.0 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libswsscommon-dbg==1.0.0 +libswsscommon-dbgsym==1.0.0 +libunwind8==1.3.2-2 +openssh-client==1:8.4p1-5+deb11u1 +sshpass==1.09-1+b1 +strace==5.10-1 +syncd-vs==1.0.0 +syncd-vs-dbg==1.0.0 +vim==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-lldp-dbg-sonic/versions-deb-bullseye b/files/build/versions/dockers/docker-lldp-dbg-sonic/versions-deb-bullseye new file mode 100644 index 000000000000..1e79891a8df8 --- /dev/null +++ b/files/build/versions/dockers/docker-lldp-dbg-sonic/versions-deb-bullseye @@ -0,0 +1,25 @@ +gdb==10.1-1.7 +gdbserver==10.1-1.7 +libbabeltrace1==1.5.8-1+b3 +libboost-regex1.74.0==1.74.0-9 +libcbor0==0.5.0+dfsg-2 +libcurl3-gnutls==7.74.0-1.3+deb11u3 +libdebuginfod1==0.183-1 +libdw1==0.183-1 +libedit2==3.1-20191231-2+b1 +libfido2-1==1.6.0-2 +libglib2.0-0==2.66.8-1 +libgpm2==1.20.7-8 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libipt2==2.0.3-1 +libmpfr6==4.1.0-3 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libswsscommon-dbg==1.0.0 +libunwind8==1.3.2-2 +lldpd-dbgsym==1.0.4-1 +openssh-client==1:8.4p1-5+deb11u1 +sshpass==1.09-1+b1 +strace==5.10-1 +vim==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-lldp/versions-deb-bullseye b/files/build/versions/dockers/docker-lldp/versions-deb-bullseye new file mode 100644 index 000000000000..0f418b558861 --- /dev/null +++ b/files/build/versions/dockers/docker-lldp/versions-deb-bullseye @@ -0,0 +1,35 @@ +gdb==10.1-1.7 +gdbserver==10.1-1.7 +libbabeltrace1==1.5.8-1+b3 +libboost-regex1.74.0==1.74.0-9 +libcbor0==0.5.0+dfsg-2 +libcurl3-gnutls==7.74.0-1.3+deb11u7 +libdebuginfod1==0.183-1 +libdw1==0.183-1 +libedit2==3.1-20191231-2+b1 +libevent-2.1-7==2.1.12-stable-1 +libfido2-1==1.6.0-2 +libglib2.0-0==2.66.8-1 +libgpm2==1.20.7-8 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libicu67==67.1-7 +libipt2==2.0.3-1 +libmpfr6==4.1.0-3 +libpci3==1:3.7.0-5 +libsensors-config==1:3.6.0-7 +libsensors5==1:3.6.0-7 +libsnmp-base==5.9+dfsg-4+deb11u1 +libsnmp40==5.9+dfsg-4+deb11u1 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libswsscommon-dbgsym==1.0.0 +libunwind8==1.3.2-2 +libxml2==2.9.10+dfsg-6.7+deb11u3 +lldpd==1.0.4-1 +lldpd-dbgsym==1.0.4-1 +openssh-client==1:8.4p1-5+deb11u1 +pci.ids==0.0~2021.02.08-1 +sshpass==1.09-1+b1 +strace==5.10-1 +vim==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-macsec-dbg-sonic/versions-deb-bullseye b/files/build/versions/dockers/docker-macsec-dbg-sonic/versions-deb-bullseye new file mode 100644 index 000000000000..6e485d10def1 --- /dev/null +++ b/files/build/versions/dockers/docker-macsec-dbg-sonic/versions-deb-bullseye @@ -0,0 +1,27 @@ +gdb==10.1-1.7 +gdbserver==10.1-1.7 +libbabeltrace1==1.5.8-1+b3 +libboost-regex1.74.0==1.74.0-9 +libcbor0==0.5.0+dfsg-2 +libcurl3-gnutls==7.74.0-1.3+deb11u3 +libdebuginfod1==0.183-1 +libdw1==0.183-1 +libedit2==3.1-20191231-2+b1 +libfido2-1==1.6.0-2 +libglib2.0-0==2.66.8-1 +libgpm2==1.20.7-8 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libicu67==67.1-7 +libipt2==2.0.3-1 +libmpfr6==4.1.0-3 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libswsscommon-dbg==1.0.0 +libunwind8==1.3.2-2 +openssh-client==1:8.4p1-5+deb11u1 +sshpass==1.09-1+b1 +strace==5.10-1 +swss-dbg==1.0.0 +vim==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 +wpasupplicant-dbgsym==2:2.9.0-14 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-macsec/versions-deb-bullseye b/files/build/versions/dockers/docker-macsec/versions-deb-bullseye new file mode 100644 index 000000000000..433e9d5d0311 --- /dev/null +++ b/files/build/versions/dockers/docker-macsec/versions-deb-bullseye @@ -0,0 +1,34 @@ +gdb==10.1-1.7 +gdbserver==10.1-1.7 +libbabeltrace1==1.5.8-1+b3 +libboost-regex1.74.0==1.74.0-9 +libcbor0==0.5.0+dfsg-2 +libcurl3-gnutls==7.74.0-1.3+deb11u7 +libdebuginfod1==0.183-1 +libdw1==0.183-1 +libedit2==3.1-20191231-2+b1 +libfido2-1==1.6.0-2 +libglib2.0-0==2.66.8-1 +libgpm2==1.20.7-8 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libicu67==67.1-7 +libipt2==2.0.3-1 +libmpfr6==4.1.0-3 +libpcsclite1==1.9.1-1 +libsaimetadata==1.0.0 +libsairedis==1.0.0 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libswsscommon-dbgsym==1.0.0 +libteam5==1.30-1 +libteamdctl0==1.30-1 +libunwind8==1.3.2-2 +openssh-client==1:8.4p1-5+deb11u1 +sshpass==1.09-1+b1 +strace==5.10-1 +swss==1.0.0 +swss-dbg==1.0.0 +vim==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 +wpasupplicant==2:2.9.0-14 +wpasupplicant-dbgsym==2:2.9.0-14 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-mux-dbg-sonic/versions-deb-bullseye b/files/build/versions/dockers/docker-mux-dbg-sonic/versions-deb-bullseye new file mode 100644 index 000000000000..428810f99a7f --- /dev/null +++ b/files/build/versions/dockers/docker-mux-dbg-sonic/versions-deb-bullseye @@ -0,0 +1,24 @@ +gdb==10.1-1.7 +gdbserver==10.1-1.7 +libbabeltrace1==1.5.8-1+b3 +libcbor0==0.5.0+dfsg-2 +libcurl3-gnutls==7.74.0-1.3+deb11u3 +libdebuginfod1==0.183-1 +libdw1==0.183-1 +libedit2==3.1-20191231-2+b1 +libfido2-1==1.6.0-2 +libglib2.0-0==2.66.8-1 +libgpm2==1.20.7-8 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libipt2==2.0.3-1 +libmpfr6==4.1.0-3 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libswsscommon-dbg==1.0.0 +libunwind8==1.3.2-2 +openssh-client==1:8.4p1-5+deb11u1 +sonic-linkmgrd-dbgsym==1.0.0-1 +sshpass==1.09-1+b1 +strace==5.10-1 +vim==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-mux/versions-deb-bullseye b/files/build/versions/dockers/docker-mux/versions-deb-bullseye new file mode 100644 index 000000000000..d2fb85eba4f3 --- /dev/null +++ b/files/build/versions/dockers/docker-mux/versions-deb-bullseye @@ -0,0 +1,31 @@ +gdb==10.1-1.7 +gdbserver==10.1-1.7 +libbabeltrace1==1.5.8-1+b3 +libboost-filesystem1.74.0==1.74.0-9 +libboost-log1.74.0==1.74.0-9 +libboost-program-options1.74.0==1.74.0-9 +libboost-regex1.74.0==1.74.0-9 +libboost-thread1.74.0==1.74.0-9 +libcbor0==0.5.0+dfsg-2 +libcurl3-gnutls==7.74.0-1.3+deb11u7 +libdebuginfod1==0.183-1 +libdw1==0.183-1 +libedit2==3.1-20191231-2+b1 +libfido2-1==1.6.0-2 +libglib2.0-0==2.66.8-1 +libgpm2==1.20.7-8 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libicu67==67.1-7 +libipt2==2.0.3-1 +libmpfr6==4.1.0-3 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libswsscommon-dbgsym==1.0.0 +libunwind8==1.3.2-2 +openssh-client==1:8.4p1-5+deb11u1 +sonic-linkmgrd==1.0.0-1 +sonic-linkmgrd-dbgsym==1.0.0-1 +sshpass==1.09-1+b1 +strace==5.10-1 +vim==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-nat-dbg-sonic/versions-deb-buster b/files/build/versions/dockers/docker-nat-dbg-sonic/versions-deb-buster new file mode 100644 index 000000000000..8228892e2982 --- /dev/null +++ b/files/build/versions/dockers/docker-nat-dbg-sonic/versions-deb-buster @@ -0,0 +1,19 @@ +gdb==8.2.1-2+b3 +gdbserver==8.2.1-2+b3 +libbabeltrace1==1.5.6-2+deb10u1 +libbsd0==0.9.1-2+deb10u1 +libdw1==0.176-1.1 +libedit2==3.1-20181209-1 +libglib2.0-0==2.58.3-2+deb10u4 +libgpm2==1.20.7-5 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libipt2==2.0-2 +libpopt0==1.16-12 +libswsscommon-dbg==1.0.0 +libunwind8==1.2.1-10~deb10u1 +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+deb10u3 +vim-runtime==2:8.1.0875-5+deb10u3 \ 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..a651fcb4c3b7 --- /dev/null +++ b/files/build/versions/dockers/docker-nat/versions-deb-buster @@ -0,0 +1,27 @@ +bridge-utils==1.6-2 +conntrack==1:1.4.5-2 +gdb==8.2.1-2+b3 +gdbserver==8.2.1-2+b3 +iptables==1.8.2-4 +libbabeltrace1==1.5.6-2+deb10u1 +libbsd0==0.9.1-2+deb10u1 +libdw1==0.176-1.1 +libedit2==3.1-20181209-1 +libglib2.0-0==2.58.3-2+deb10u4 +libgpm2==1.20.7-5 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libip4tc0==1.8.2-4 +libip6tc0==1.8.2-4 +libipt2==2.0-2 +libiptc0==1.8.2-4 +libnetfilter-conntrack3==1.0.7-1 +libnfnetlink0==1.0.1-3+b1 +libnftnl11==1.1.2-2 +libswsscommon-dbgsym==1.0.0 +libunwind8==1.2.1-10~deb10u1 +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+deb10u4 +vim-runtime==2:8.1.0875-5+deb10u4 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-orchagent-dbg-sonic/versions-deb-bullseye b/files/build/versions/dockers/docker-orchagent-dbg-sonic/versions-deb-bullseye new file mode 100644 index 000000000000..ae3b9016c9f6 --- /dev/null +++ b/files/build/versions/dockers/docker-orchagent-dbg-sonic/versions-deb-bullseye @@ -0,0 +1,27 @@ +gdb==10.1-1.7 +gdbserver==10.1-1.7 +libbabeltrace1==1.5.8-1+b3 +libboost-regex1.74.0==1.74.0-9 +libcbor0==0.5.0+dfsg-2 +libcurl3-gnutls==7.74.0-1.3+deb11u3 +libdebuginfod1==0.183-1 +libdw1==0.183-1 +libedit2==3.1-20191231-2+b1 +libfido2-1==1.6.0-2 +libglib2.0-0==2.66.8-1 +libgpm2==1.20.7-8 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libicu67==67.1-7 +libipt2==2.0.3-1 +libmpfr6==4.1.0-3 +libsairedis-dbg==1.0.0 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libswsscommon-dbg==1.0.0 +libunwind8==1.3.2-2 +openssh-client==1:8.4p1-5+deb11u1 +sshpass==1.09-1+b1 +strace==5.10-1 +swss-dbg==1.0.0 +vim==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-orchagent/versions-deb-bullseye b/files/build/versions/dockers/docker-orchagent/versions-deb-bullseye new file mode 100644 index 000000000000..a87b9d6fadbf --- /dev/null +++ b/files/build/versions/dockers/docker-orchagent/versions-deb-bullseye @@ -0,0 +1,87 @@ +arping==2.21-2 +binutils==2.35.2-2 +binutils-common==2.35.2-2 +binutils-x86-64-linux-gnu==2.35.2-2 +bridge-utils==1.7-1 +build-essential==12.9 +bzip2==1.0.8-4 +conntrack==1:1.4.6-2 +cpp==4:10.2.1-1 +cpp-10==10.2.1-6 +g++==4:10.2.1-1 +g++-10==10.2.1-6 +gcc==4:10.2.1-1 +gcc-10==10.2.1-6 +gdb==10.1-1.7 +gdbserver==10.1-1.7 +ifupdown==0.8.36 +libasan6==10.2.1-6 +libbabeltrace1==1.5.8-1+b3 +libbinutils==2.35.2-2 +libboost-regex1.74.0==1.74.0-9 +libc-dev-bin==2.31-13+deb11u5 +libc6-dev==2.31-13+deb11u5 +libcbor0==0.5.0+dfsg-2 +libcc1-0==10.2.1-6 +libcrypt-dev==1:4.4.18-4 +libctf-nobfd0==2.35.2-2 +libctf0==2.35.2-2 +libcurl3-gnutls==7.74.0-1.3+deb11u7 +libdebuginfod1==0.183-1 +libdpkg-perl==1.20.12 +libdw1==0.183-1 +libedit2==3.1-20191231-2+b1 +libexpat1-dev==2.2.10-2+deb11u5 +libfido2-1==1.6.0-2 +libgcc-10-dev==10.2.1-6 +libglib2.0-0==2.66.8-1 +libgomp1==10.2.1-6 +libgpm2==1.20.7-8 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libicu67==67.1-7 +libipt2==2.0.3-1 +libisl23==0.23-1 +libitm1==10.2.1-6 +libjs-sphinxdoc==3.4.3-2 +libjs-underscore==1.9.1~dfsg-3 +libkmod2==28-1 +liblsan0==10.2.1-6 +libmpc3==1.2.0-1 +libmpfr6==4.1.0-3 +libnet1==1.1.6+dfsg-3.1 +libnetfilter-conntrack3==1.0.8-3 +libnfnetlink0==1.0.1-3+b1 +libnsl-dev==1.3.0-2 +libpcap0.8==1.10.0-2 +libpci3==1:3.7.0-5 +libpython3-dev==3.9.2-3 +libpython3.9-dev==3.9.2-1 +libquadmath0==10.2.1-6 +libsairedis-dbg==1.0.0 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libstdc++-10-dev==10.2.1-6 +libswsscommon-dbgsym==1.0.0 +libtirpc-dev==1.3.1-1+deb11u1 +libtsan0==10.2.1-6 +libubsan1==10.2.1-6 +libunwind8==1.3.2-2 +linux-libc-dev==5.10.162-1 +make==4.3-4.1 +ndisc6==1.0.4-2 +ndppd==0.2.5-6 +openssh-client==1:8.4p1-5+deb11u1 +patch==2.7.6-7 +pci.ids==0.0~2021.02.08-1 +pciutils==1:3.7.0-5 +python3-dev==3.9.2-3 +python3.9-dev==3.9.2-1 +sonic-rsyslog-plugin==1.0.0-0 +sshpass==1.09-1+b1 +strace==5.10-1 +swss-dbg==1.0.0 +tcpdump==4.99.0-2+deb11u1 +vim==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 +xz-utils==5.2.5-2.1~deb11u1 +zlib1g-dev==1:1.2.11.dfsg-2+deb11u2 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-orchagent/versions-deb-bullseye-arm64 b/files/build/versions/dockers/docker-orchagent/versions-deb-bullseye-arm64 new file mode 100644 index 000000000000..8774e0ea85bd --- /dev/null +++ b/files/build/versions/dockers/docker-orchagent/versions-deb-bullseye-arm64 @@ -0,0 +1 @@ +binutils-aarch64-linux-gnu==2.35.2-2 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-orchagent/versions-deb-bullseye-armhf b/files/build/versions/dockers/docker-orchagent/versions-deb-bullseye-armhf new file mode 100644 index 000000000000..6571b460660f --- /dev/null +++ b/files/build/versions/dockers/docker-orchagent/versions-deb-bullseye-armhf @@ -0,0 +1 @@ +binutils-arm-linux-gnueabihf==2.35.2-2 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-orchagent/versions-py3 b/files/build/versions/dockers/docker-orchagent/versions-py3 new file mode 100644 index 000000000000..aa6d42d04fba --- /dev/null +++ b/files/build/versions/dockers/docker-orchagent/versions-py3 @@ -0,0 +1,2 @@ +netifaces==0.10.9 +pyroute2==0.5.14 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-platform-monitor-dbg-sonic/versions-deb-bullseye b/files/build/versions/dockers/docker-platform-monitor-dbg-sonic/versions-deb-bullseye new file mode 100644 index 000000000000..8b5f79989e47 --- /dev/null +++ b/files/build/versions/dockers/docker-platform-monitor-dbg-sonic/versions-deb-bullseye @@ -0,0 +1,26 @@ +gdb==10.1-1.7 +gdbserver==10.1-1.7 +libbabeltrace1==1.5.8-1+b3 +libboost-regex1.74.0==1.74.0-9 +libcbor0==0.5.0+dfsg-2 +libcurl3-gnutls==7.74.0-1.3+deb11u3 +libdebuginfod1==0.183-1 +libdw1==0.183-1 +libedit2==3.1-20191231-2+b1 +libfido2-1==1.6.0-2 +libgpm2==1.20.7-8 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libipt2==2.0.3-1 +libmpfr6==4.1.0-3 +libsensors5-dbgsym==1:3.6.0-7 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libswsscommon-dbg==1.0.0 +libunwind8==1.3.2-2 +lm-sensors-dbgsym==1:3.6.0-7 +openssh-client==1:8.4p1-5+deb11u1 +sensord-dbgsym==1:3.6.0-7 +sshpass==1.09-1+b1 +strace==5.10-1 +vim==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-platform-monitor/versions-deb-bullseye b/files/build/versions/dockers/docker-platform-monitor/versions-deb-bullseye new file mode 100644 index 000000000000..9b1d7e9e78bc --- /dev/null +++ b/files/build/versions/dockers/docker-platform-monitor/versions-deb-bullseye @@ -0,0 +1,145 @@ +applibs==1.mlnx.4.5.4206 +applibs-dev==1.mlnx.4.5.4206 +binutils==2.35.2-2 +binutils-common==2.35.2-2 +binutils-x86-64-linux-gnu==2.35.2-2 +build-essential==12.9 +bzip2==1.0.8-4 +cpp==4:10.2.1-1 +cpp-10==10.2.1-6 +dmidecode==3.3-2 +ethtool==1:5.9-1 +fancontrol==1:3.6.0-7 +fontconfig==2.13.1-4.2 +fontconfig-config==2.13.1-4.2 +fonts-dejavu-core==2.37-2 +freeipmi-common==1.6.6-4+deb11u1 +g++==4:10.2.1-1 +g++-10==10.2.1-6 +gcc==4:10.2.1-1 +gcc-10==10.2.1-6 +gdb==10.1-1.7 +gdbserver==10.1-1.7 +i2c-tools==4.2-1+b1 +ipmitool==1.8.18-10.1 +iputils-ping==3:20210202-1 +libasan6==10.2.1-6 +libbabeltrace1==1.5.8-1+b3 +libbinutils==2.35.2-2 +libboost-regex1.74.0==1.74.0-9 +libc-dev-bin==2.31-13+deb11u5 +libc6-dev==2.31-13+deb11u5 +libcairo2==1.16.0-5 +libcbor0==0.5.0+dfsg-2 +libcc1-0==10.2.1-6 +libcrypt-dev==1:4.4.18-4 +libctf-nobfd0==2.35.2-2 +libctf0==2.35.2-2 +libcurl3-gnutls==7.74.0-1.3+deb11u7 +libdatrie1==0.2.13-1 +libdbi1==0.9.0-6 +libdebuginfod1==0.183-1 +libdpkg-perl==1.20.12 +libdw1==0.183-1 +libedit2==3.1-20191231-2+b1 +libexpat1-dev==2.2.10-2+deb11u5 +libfido2-1==1.6.0-2 +libfontconfig1==2.13.1-4.2 +libfreeipmi17==1.6.6-4+deb11u1 +libfreetype6==2.10.4+dfsg-1+deb11u1 +libfribidi0==1.0.8-2+deb11u1 +libgcc-10-dev==10.2.1-6 +libglib2.0-0==2.66.8-1 +libgomp1==10.2.1-6 +libgpm2==1.20.7-8 +libgraphite2-3==1.3.14-1 +libharfbuzz0b==2.7.4-1 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libi2c0==4.2-1+b1 +libicu67==67.1-7 +libipt2==2.0.3-1 +libisl23==0.23-1 +libitm1==10.2.1-6 +libjs-sphinxdoc==3.4.3-2 +libjs-underscore==1.9.1~dfsg-3 +libkmod2==28-1 +liblsan0==10.2.1-6 +libmpc3==1.2.0-1 +libmpfr6==4.1.0-3 +libnsl-dev==1.3.0-2 +libpango-1.0-0==1.46.2-3 +libpangocairo-1.0-0==1.46.2-3 +libpangoft2-1.0-0==1.46.2-3 +libpci3==1:3.7.0-5 +libpixman-1-0==0.40.0-1.1~deb11u1 +libpng16-16==1.6.37-3 +libpython3-dev==3.9.2-3 +libpython3.9-dev==3.9.2-1 +libquadmath0==10.2.1-6 +librrd-dev==1.7.2-3+b7 +librrd8==1.7.2-3+b7 +libsensors-config==1:3.6.0-7 +libsensors5==1:3.6.0-7 +libsensors5-dbgsym==1:3.6.0-7 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libstdc++-10-dev==10.2.1-6 +libswsscommon-dbgsym==1.0.0 +libthai-data==0.1.28-3 +libthai0==0.1.28-3 +libtirpc-dev==1.3.1-1+deb11u1 +libtsan0==10.2.1-6 +libubsan1==10.2.1-6 +libunwind8==1.3.2-2 +libx11-6==2:1.7.2-1 +libx11-data==2:1.7.2-1 +libxau6==1:1.0.9-1 +libxcb-render0==1.14-3 +libxcb-shm0==1.14-3 +libxcb1==1.14-3 +libxdmcp6==1:1.1.2-3 +libxext6==2:1.3.3-1.1 +libxml2==2.9.10+dfsg-6.7+deb11u3 +libxrender1==1:0.9.10-1 +linux-libc-dev==5.10.162-1 +lm-sensors==1:3.6.0-7 +lm-sensors-dbgsym==1:3.6.0-7 +make==4.3-4.1 +mft==4.22.1-15 +openssh-client==1:8.4p1-5+deb11u1 +patch==2.7.6-7 +pci.ids==0.0~2021.02.08-1 +pciutils==1:3.7.0-5 +psmisc==23.4-2 +python-sdk-api==1.mlnx.4.5.4206 +python3-attr==20.3.0-1 +python3-dev==3.9.2-3 +python3-importlib-metadata==1.6.0-2 +python3-jsonschema==3.2.0-3 +python3-more-itertools==4.2.0-3 +python3-pkg-resources==52.0.0-4 +python3-pyrsistent==0.15.5-1+b3 +python3-setuptools==52.0.0-4 +python3-six==1.16.0-2 +python3-smbus==4.2-1+b1 +python3-zipp==1.0.0-3 +python3.9-dev==3.9.2-1 +rrdtool==1.7.2-3+b7 +sensible-utils==0.0.14 +sensord==1:3.6.0-7 +sensord-dbgsym==1:3.6.0-7 +smartmontools==7.2-1 +sshpass==1.09-1+b1 +strace==5.10-1 +sx-complib==1.mlnx.4.5.4206 +sx-complib-dev==1.mlnx.4.5.4206 +sx-gen-utils==1.mlnx.4.5.4206 +sx-gen-utils-dev==1.mlnx.4.5.4206 +sxd-libs==1.mlnx.4.5.4206 +sxd-libs-dev==1.mlnx.4.5.4206 +ucf==3.0043 +udev==247.3-7+deb11u1 +vim==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 +xz-utils==5.2.5-2.1~deb11u1 +zlib1g-dev==1:1.2.11.dfsg-2+deb11u2 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-platform-monitor/versions-deb-bullseye-arm64 b/files/build/versions/dockers/docker-platform-monitor/versions-deb-bullseye-arm64 new file mode 100644 index 000000000000..8774e0ea85bd --- /dev/null +++ b/files/build/versions/dockers/docker-platform-monitor/versions-deb-bullseye-arm64 @@ -0,0 +1 @@ +binutils-aarch64-linux-gnu==2.35.2-2 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-platform-monitor/versions-deb-bullseye-armhf b/files/build/versions/dockers/docker-platform-monitor/versions-deb-bullseye-armhf new file mode 100644 index 000000000000..6571b460660f --- /dev/null +++ b/files/build/versions/dockers/docker-platform-monitor/versions-deb-bullseye-armhf @@ -0,0 +1 @@ +binutils-arm-linux-gnueabihf==2.35.2-2 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-platform-monitor/versions-py3 b/files/build/versions/dockers/docker-platform-monitor/versions-py3 new file mode 100644 index 000000000000..6a14c2ba453f --- /dev/null +++ b/files/build/versions/dockers/docker-platform-monitor/versions-py3 @@ -0,0 +1,13 @@ +attrs==20.3.0 +grpcio==1.39.0 +grpcio-tools==1.39.0 +guacamole==0.9.2 +importlib-metadata==1.6.0 +jsonschema==2.6.0 +libpci==0.2 +more-itertools==4.2.0 +protobuf==3.20.3 +pyrsistent==0.15.5 +python_sdk_api==4.5.4206 +thrift==0.13.0 +zipp==1.0.0 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-ptf-sai/versions-deb-buster b/files/build/versions/dockers/docker-ptf-sai/versions-deb-buster new file mode 100644 index 000000000000..b2a62d369462 --- /dev/null +++ b/files/build/versions/dockers/docker-ptf-sai/versions-deb-buster @@ -0,0 +1,3 @@ +libboost-atomic1.67.0==1.67.0-13+deb10u1 +libthrift0==0.14.1 +python3-thrift==0.14.1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-ptf-sai/versions-py3 b/files/build/versions/dockers/docker-ptf-sai/versions-py3 new file mode 100644 index 000000000000..7526bed7d562 --- /dev/null +++ b/files/build/versions/dockers/docker-ptf-sai/versions-py3 @@ -0,0 +1,12 @@ +crc16==0.1.1 +getmac==0.9.3 +netifaces==0.11.0 +packet-helper==0.0.1 +psutil==5.9.5 +ptf==0.9.3 +pyperclip==1.8.2 +pysubnettree==0.35 +scapy-helper==0.14.8 +tabulate==0.8.10 +thrift==0.14.1 +xmlrunner==1.7.7 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-ptf/versions-deb-buster b/files/build/versions/dockers/docker-ptf/versions-deb-buster new file mode 100644 index 000000000000..f316f1bd7ae6 --- /dev/null +++ b/files/build/versions/dockers/docker-ptf/versions-deb-buster @@ -0,0 +1,496 @@ +arping==2.19-6 +autoconf==2.69-11 +automake==1:1.16.1-4 +autotools-dev==20180224.1 +binutils==2.31.1-16 +binutils-common==2.31.1-16 +binutils-x86-64-linux-gnu==2.31.1-16 +blt==2.5.3+dfsg-4 +bridge-utils==1.6-2 +bsd-mailx==8.1.2-0.20180807cvs-1 +build-essential==12.6 +bzip2==1.0.6-9.2~deb10u2 +ca-certificates==20200601~deb10u2 +cmake==3.13.4-1 +cmake-data==3.13.4-1 +cpp==4:8.3.0-1 +cpp-8==8.3.0-6 +cron==3.0pl1-134+deb10u1 +curl==7.64.0-4+deb10u5 +dbus==1.12.24-0+deb10u1 +dh-python==3.20190308 +dirmngr==2.2.12-1+deb10u2 +dmsetup==2:1.02.155-3 +dpkg-dev==1.19.8 +ethtool==1:4.19-1 +exim4-base==4.92-8+deb10u7 +exim4-config==4.92-8+deb10u7 +exim4-daemon-light==4.92-8+deb10u7 +fakeroot==1.23-1 +file==1:5.35-4+deb10u2 +fontconfig==2.13.1-2 +fontconfig-config==2.13.1-2 +fonts-droid-fallback==1:6.0.1r16-1.1 +fonts-liberation==1:1.07.4-9 +fonts-lmodern==2.004.5-6 +fonts-lyx==2.3.2-1 +fonts-noto-mono==20181227-1 +g++==4:8.3.0-1 +g++-8==8.3.0-6 +gcc==4:8.3.0-1 +gcc-8==8.3.0-6 +gdb==8.2.1-2+b3 +gir1.2-glib-2.0==1.58.3-2 +git==1:2.20.1-2+deb10u8 +git-man==1:2.20.1-2+deb10u8 +gnupg==2.2.12-1+deb10u2 +gnupg-l10n==2.2.12-1+deb10u2 +gnupg-utils==2.2.12-1+deb10u2 +gpg==2.2.12-1+deb10u2 +gpg-agent==2.2.12-1+deb10u2 +gpg-wks-client==2.2.12-1+deb10u2 +gpg-wks-server==2.2.12-1+deb10u2 +gpgconf==2.2.12-1+deb10u2 +gpgsm==2.2.12-1+deb10u2 +graphviz==2.40.1-6+deb10u1 +hping3==3.a2.ds2-7 +ipython3==5.8.0-1+deb10u1 +javascript-common==11 +krb5-locales==1.17-3+deb10u5 +less==487-0.1+b1 +libalgorithm-diff-perl==1.19.03-2 +libalgorithm-diff-xs-perl==0.04-5+b1 +libalgorithm-merge-perl==0.08-3 +libapparmor1==2.13.2-10 +libarchive13==3.3.3-4+deb10u3 +libargon2-1==0~20171227-0.2 +libasan5==8.3.0-6 +libassuan0==2.5.2-1 +libatomic1==8.3.0-6 +libauthen-sasl-perl==2.1600-1 +libavahi-client3==0.7-4+deb10u1 +libavahi-common-data==0.7-4+deb10u1 +libavahi-common3==0.7-4+deb10u1 +libbabeltrace1==1.5.6-2+deb10u1 +libbinutils==2.31.1-16 +libblas3==3.8.0-2 +libboost-atomic1.71.0==1.71.0-6~bpo10+1 +libbrotli1==1.0.7-2+deb10u1 +libbsd0==0.9.1-2+deb10u1 +libc-dev-bin==2.28-10+deb10u2 +libc6-dbg==2.28-10+deb10u2 +libc6-dev==2.28-10+deb10u2 +libcairo2==1.16.0-4+deb10u1 +libcc1-0==8.3.0-6 +libcdt5==2.40.1-6+deb10u1 +libcgraph6==2.40.1-6+deb10u1 +libcryptsetup12==2:2.1.0-5+deb10u2 +libcups2==2.2.10-6+deb10u6 +libcupsfilters1==1.21.6-5 +libcupsimage2==2.2.10-6+deb10u6 +libcurl3-gnutls==7.64.0-4+deb10u5 +libcurl4==7.64.0-4+deb10u5 +libdaemon0==0.14-7 +libdata-dump-perl==1.23-1 +libdatrie1==0.2.12-2 +libdbus-1-3==1.12.24-0+deb10u1 +libdevmapper1.02.1==2:1.02.155-3 +libdouble-conversion1==3.1.0-3 +libdpkg-perl==1.19.8 +libdrm-amdgpu1==2.4.97-1 +libdrm-common==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 +libdw1==0.176-1.1 +libedit2==3.1-20181209-1 +libencode-locale-perl==1.05-1 +liberror-perl==0.17027-2 +libestr0==0.1.10-2.1 +libevent-2.1-6==2.1.8-stable-4 +libevent-core-2.1-6==2.1.8-stable-4 +libevent-pthreads-2.1-6==2.1.8-stable-4 +libexpat1==2.2.6-2+deb10u6 +libexpat1-dev==2.2.6-2+deb10u6 +libfakeroot==1.23-1 +libfastjson4==0.99.8-2 +libffi-dev==3.2.1-9 +libfile-basedir-perl==0.08-1 +libfile-desktopentry-perl==0.22-1 +libfile-fcntllock-perl==0.22-3+b5 +libfile-listing-perl==6.04-1 +libfile-mimeinfo-perl==0.29-1 +libfont-afm-perl==1.20-2 +libfontconfig1==2.13.1-2 +libfontenc1==1:1.1.3-1+b2 +libfreetype6==2.9.1-3+deb10u3 +libfribidi0==1.0.5-3.1+deb10u2 +libgcc-8-dev==8.3.0-6 +libgd3==2.2.5-5.2 +libgdbm-compat4==1.18.1-4 +libgdbm6==1.18.1-4 +libgfortran5==8.3.0-6 +libgirepository-1.0-1==1.58.3-2 +libgl1==1.1.0-1 +libgl1-mesa-dri==18.3.6-2+deb10u1 +libglapi-mesa==18.3.6-2+deb10u1 +libglib2.0-0==2.58.3-2+deb10u4 +libglib2.0-data==2.58.3-2+deb10u4 +libglvnd0==1.1.0-1 +libglx-mesa0==18.3.6-2+deb10u1 +libglx0==1.1.0-1 +libgnutls-dane0==3.6.7-4+deb10u10 +libgnutls30==3.6.7-4+deb10u10 +libgomp1==8.3.0-6 +libgpm2==1.20.7-5 +libgraphite2-3==1.3.13-7 +libgs9==9.27~dfsg-2+deb10u7 +libgs9-common==9.27~dfsg-2+deb10u7 +libgssapi-krb5-2==1.17-3+deb10u5 +libgts-0.7-5==0.7.6+darcs121130-4 +libgts-bin==0.7.6+darcs121130-4 +libgvc6==2.40.1-6+deb10u1 +libgvpr2==2.40.1-6+deb10u1 +libharfbuzz-icu0==2.3.1-1 +libharfbuzz0b==2.3.1-1 +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+deb10u1 +libhttp-date-perl==6.02-1 +libhttp-message-perl==6.18-1 +libhttp-negotiate-perl==6.01-1 +libice6==2:1.0.9-2 +libicu63==63.1-6+deb10u3 +libidn11==1.33-2.2 +libijs-0.35==0.35-14 +libimagequant0==2.12.2-1.1 +libio-html-perl==1.001-1 +libio-socket-ssl-perl==2.060-3 +libio-stringy-perl==2.111-3 +libip4tc0==1.8.2-4 +libipc-system-simple-perl==1.25-4 +libipt2==2.0-2 +libisl19==0.20-2 +libitm1==8.3.0-6 +libjansson4==2.12-1 +libjbig0==2.1-3.1+b2 +libjbig2dec0==0.16-1+deb10u1 +libjpeg62-turbo==1:1.5.2-2+deb10u1 +libjs-jquery==3.3.1~dfsg-3+deb10u1 +libjs-jquery-ui==1.12.1+dfsg-5+deb10u1 +libjson-c3==0.12.1+ds-2+deb10u1 +libjsoncpp1==1.7.4-3 +libk5crypto3==1.17-3+deb10u5 +libkeyutils1==1.6-6 +libkmod2==26-1 +libkpathsea6==2018.20181218.49446-1 +libkrb5-3==1.17-3+deb10u5 +libkrb5support0==1.17-3+deb10u5 +libksba8==1.3.5-2+deb10u2 +liblab-gamut1==2.40.1-6+deb10u1 +liblapack3==3.8.0-2 +liblcms2-2==2.9-3 +libldap-2.4-2==2.4.47+dfsg-3+deb10u7 +libldap-common==2.4.47+dfsg-3+deb10u7 +libllvm7==1:7.0.1-8+deb10u2 +liblocale-gettext-perl==1.07-3+b4 +liblockfile-bin==1.14-1.1 +liblockfile1==1.14-1.1 +liblognorm5==2.0.5-1 +liblsan0==8.3.0-6 +libltdl7==2.4.6-9 +liblwp-mediatypes-perl==6.02-1 +liblwp-protocol-https-perl==6.07-2 +libmagic-mgc==1:5.35-4+deb10u2 +libmagic1==1:5.35-4+deb10u2 +libmailtools-perl==2.18-1 +libmpc3==1.1.0-1 +libmpdec2==2.4.2-2 +libmpfr6==4.0.2-1 +libmpx2==8.3.0-6 +libncurses6==6.1+20181013-2+deb10u3 +libnet-dbus-perl==1.1.0-5+b1 +libnet-http-perl==6.18-1 +libnet-smtp-ssl-perl==1.04-1 +libnet-ssleay-perl==1.85-2+deb10u1 +libnet1==1.1.6+dfsg-3.1 +libnghttp2-14==1.36.0-2+deb10u1 +libnl-3-200==3.4.0-1 +libnl-cli-3-200==3.4.0-1 +libnl-genl-3-200==3.4.0-1 +libnl-nf-3-200==3.4.0-1 +libnl-route-3-200==3.4.0-1 +libnpth0==1.6-1 +libnss-systemd==241-7~deb10u9 +libopenjp2-7==2.3.0-2+deb10u2 +libopts25==1:5.18.12-4 +libpam-systemd==241-7~deb10u9 +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 +libpathplan4==2.40.1-6+deb10u1 +libpcap-dev==1.8.1-6+deb10u1 +libpcap0.8==1.8.1-6+deb10u1 +libpcap0.8-dev==1.8.1-6+deb10u1 +libpciaccess0==0.14-1 +libpcre2-16-0==10.32-5+deb10u1 +libpcre2-8-0==10.32-5+deb10u1 +libperl5.28==5.28.1-6+deb10u1 +libpixman-1-0==0.36.0-1+deb10u1 +libpng16-16==1.6.36-6 +libpopt0==1.16-12 +libpotrace0==1.15-1 +libprocps7==2:3.3.15-2 +libpsl5==0.20.2-2 +libptexenc1==2018.20181218.49446-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-dev==3.7.3-1 +libpython3-stdlib==3.7.3-1 +libpython3.7==3.7.3-2+deb10u4 +libpython3.7-dev==3.7.3-2+deb10u4 +libpython3.7-minimal==3.7.3-2+deb10u4 +libpython3.7-stdlib==3.7.3-2+deb10u4 +libqt5core5a==5.11.3+dfsg1-1+deb10u5 +libqt5dbus5==5.11.3+dfsg1-1+deb10u5 +libqt5network5==5.11.3+dfsg1-1+deb10u5 +libquadmath0==8.3.0-6 +libreadline7==7.0-5 +librhash0==1.3.8-1 +librtmp1==2.4+20151223.gitfa8646d.1-2 +libsasl2-2==2.1.27+dfsg-1+deb10u2 +libsasl2-modules==2.1.27+dfsg-1+deb10u2 +libsasl2-modules-db==2.1.27+dfsg-1+deb10u2 +libsensors-config==1:3.5.0-3 +libsensors5==1:3.5.0-3 +libsigsegv2==2.12-2 +libsm6==2:1.2.3-1 +libsqlite3-0==3.27.2-3+deb10u2 +libssh2-1==1.8.0-2.1 +libssl-dev==1.1.1n-0+deb10u4 +libssl1.1==1.1.1n-0+deb10u4 +libstdc++-8-dev==8.3.0-6 +libsynctex2==2018.20181218.49446-1 +libsystemd0==241-7~deb10u9 +libtacacs+1==4.0.4.27a-3 +libtasn1-6==4.13-3+deb10u1 +libtcl8.6==8.6.9+dfsg-2 +libteam-utils==1.28-1 +libteam5==1.28-1 +libteamdctl0==1.28-1 +libteckit0==2.5.8+ds2-5 +libtexlua52==2018.20181218.49446-1 +libtexlua53==2018.20181218.49446-1 +libtexluajit2==2018.20181218.49446-1 +libtext-iconv-perl==1.7-5+b7 +libthai-data==0.1.28-2 +libthai0==0.1.28-2 +libthrift-0.11.0==0.11.0-4 +libtie-ixhash-perl==1.23-2 +libtiff5==4.1.0+git191117-2~deb10u7 +libtimedate-perl==2.3000-2+deb10u1 +libtk8.6==8.6.9-2 +libtry-tiny-perl==0.30-1 +libtsan0==8.3.0-6 +libubsan1==8.3.0-6 +libudev1==241-7~deb10u9 +libunbound8==1.9.0-2+deb10u3 +liburi-perl==1.76-1 +libutempter0==1.1.6-3 +libuv1==1.24.1-1+deb10u1 +libwebp6==0.6.1-2+deb10u1 +libwebpdemux2==0.6.1-2+deb10u1 +libwebpmux3==0.6.1-2+deb10u1 +libwoff1==1.0.2-1 +libwrap0==7.6.q-28 +libwww-perl==6.36-2 +libwww-robotrules-perl==6.02-1 +libx11-6==2:1.6.7-1+deb10u2 +libx11-data==2:1.6.7-1+deb10u2 +libx11-protocol-perl==0.56-7 +libx11-xcb1==2:1.6.7-1+deb10u2 +libxau6==1:1.0.8-1+b2 +libxaw7==2:1.0.13-1+b2 +libxcb-dri2-0==1.13.1-2 +libxcb-dri3-0==1.13.1-2 +libxcb-glx0==1.13.1-2 +libxcb-present0==1.13.1-2 +libxcb-render0==1.13.1-2 +libxcb-shape0==1.13.1-2 +libxcb-shm0==1.13.1-2 +libxcb-sync1==1.13.1-2 +libxcb1==1.13.1-2 +libxcomposite1==1:0.4.4-2 +libxcursor1==1:1.1.15-2 +libxdamage1==1:1.1.4-3+b3 +libxdmcp6==1:1.1.2-3 +libxdot4==2.40.1-6+deb10u1 +libxext6==2:1.3.3-1+b2 +libxfixes3==1:5.0.3-1 +libxft2==2.3.2-2 +libxi6==2:1.7.9-1 +libxinerama1==2:1.1.4-2 +libxml-parser-perl==2.44-4 +libxml-twig-perl==1:3.50-1.1 +libxml-xpathengine-perl==0.14-1 +libxml2==2.9.4+dfsg1-7+deb10u5 +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 +libxshmfence1==1.3-1 +libxss1==1:1.2.3-1 +libxt6==1:1.1.5-1+b3 +libxtst6==2:1.2.3-1 +libxv1==2:1.0.11-1 +libxxf86dga1==2:1.1.4-1+b3 +libxxf86vm1==1:1.1.4-1+b2 +libxxhash0==0.6.5-2 +libzzip-0-13==0.13.62-3.2+deb10u1 +linux-libc-dev==4.19.269-1 +lmodern==2.004.5-6 +logrotate==3.14.0-4 +lsb-base==10.2019051400 +lsof==4.91+dfsg-1 +m4==1.4.18-2 +make==4.2.1-1.2 +manpages==4.16-2 +manpages-dev==4.16-2 +mime-support==3.62 +ncurses-term==6.1+20181013-2+deb10u3 +net-tools==1.60+git20180626.aebd88e-1 +netbase==5.6 +ntp==1:4.2.8p12+dfsg-4 +ntpdate==1:4.2.8p12+dfsg-4 +ntpstat==0.0.0.1-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.1n-0+deb10u4 +patch==2.7.6-3+deb10u1 +perl==5.28.1-6+deb10u1 +perl-modules-5.28==5.28.1-6+deb10u1 +perl-openssl-defaults==3 +pinentry-curses==1.1.0-2 +pkg-config==0.29-6 +poppler-data==0.4.9-2 +procps==2:3.3.15-2 +psmisc==23.2-1+deb10u1 +publicsuffix==20220811.1734-0+deb10u1 +python==2.7.16-1 +python-dev==2.7.16-1 +python-libpcap==0.6.4-1 +python-matplotlib-data==3.0.2-2 +python-minimal==2.7.16-1 +python-pip-whl==18.1-5 +python-ptf==0.9-1 +python-saithrift==0.9.4 +python-scapy==2.4.0-2 +python-six==1.12.0-1 +python-thrift==0.11.0-4 +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-asn1crypto==0.24.0-1 +python3-cffi-backend==1.12.2-1 +python3-crypto==2.6.1-9+b1 +python3-cryptography==2.6.1-3+deb10u4 +python3-cycler==0.10.0-1 +python3-dateutil==2.7.3-3 +python3-dbus==1.2.8-3 +python3-decorator==4.3.0-1.1 +python3-dev==3.7.3-1 +python3-distutils==3.7.3-1 +python3-entrypoints==0.3-1 +python3-gi==3.30.4-1 +python3-ipython==5.8.0-1+deb10u1 +python3-ipython-genutils==0.2.0-1 +python3-keyring==17.1.1-1 +python3-keyrings.alt==3.1.1-1 +python3-kiwisolver==1.0.1-2+b1 +python3-lib2to3==3.7.3-1 +python3-matplotlib==3.0.2-2 +python3-minimal==3.7.3-1 +python3-numpy==1:1.16.2-1 +python3-olefile==0.46-1 +python3-pexpect==4.6.0-1 +python3-pickleshare==0.7.5-1 +python3-pil==5.4.1-2+deb10u3 +python3-pip==18.1-5 +python3-pkg-resources==40.8.0-1 +python3-prompt-toolkit==1.0.15-1 +python3-ptyprocess==0.6.0-1 +python3-pygments==2.3.1+dfsg-1+deb10u2 +python3-pyparsing==2.2.0+dfsg1-2 +python3-pyx==0.14.1-9 +python3-scapy==2.4.0-2 +python3-secretstorage==2.3.1-2 +python3-setuptools==40.8.0-1 +python3-simplegeneric==0.8.1-2 +python3-six==1.12.0-1 +python3-tk==3.7.3-1 +python3-traitlets==4.3.2-1 +python3-venv==3.7.3-1 +python3-wcwidth==0.1.7+dfsg1-3 +python3-wheel==0.32.3-2 +python3-xdg==0.25-5 +python3.7==3.7.3-2+deb10u4 +python3.7-dev==3.7.3-2+deb10u4 +python3.7-minimal==3.7.3-2+deb10u4 +python3.7-venv==3.7.3-2+deb10u4 +qttranslations5-l10n==5.11.3-2 +readline-common==7.0-5 +rsync==3.1.3-6 +rsyslog==8.1901.0-1+deb10u2 +sensible-utils==0.0.12 +shared-mime-info==1.10-1 +sntp==1:4.2.8p12+dfsg-4 +systemd==241-7~deb10u9 +systemd-sysv==241-7~deb10u9 +t1utils==1.41-3 +tacacs+==4.0.4.27a-3 +tcpdump==4.9.3-1~deb10u2 +telnet==0.17-41.2 +tex-common==6.11 +texlive-base==2018.20190227-2 +texlive-binaries==2018.20181218.49446-1 +texlive-latex-base==2018.20190227-2 +tk8.6-blt2.5==2.5.3+dfsg-4 +tmux==2.8-3+deb10u1 +traceroute==1:2.1.0-2 +ttf-bitstream-vera==1.10-8 +tzdata==2021a-0+deb10u10 +ucf==3.0038+nmu1 +unzip==6.0-23+deb10u3 +vim==2:8.1.0875-5+deb10u4 +vim-common==2:8.1.0875-5+deb10u4 +vim-runtime==2:8.1.0875-5+deb10u4 +wget==1.20.1-1.1 +x11-common==1:7.7+19 +x11-utils==7.7+4 +x11-xserver-utils==7.7+8 +xauth==1:1.0.10-1 +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 +xxd==2:8.1.0875-5+deb10u4 +xz-utils==5.2.4-1+deb10u1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-ptf/versions-py2 b/files/build/versions/dockers/docker-ptf/versions-py2 new file mode 100644 index 000000000000..641047569664 --- /dev/null +++ b/files/build/versions/dockers/docker-ptf/versions-py2 @@ -0,0 +1,69 @@ +backports.functools-lru-cache==1.6.4 +backports.shutil-get-terminal-size==1.0.0 +bcrypt==3.1.7 +cffi==1.15.1 +click==7.1.2 +contextlib2==0.6.0.post1 +cryptography==3.3.2 +decorator==4.4.2 +dpkt==1.9.8 +enum34==1.1.6 +exabgp==3.4.17 +flask==1.0 +flask-httpauth==2.5.0 +future==0.18.3 +futures==3.2.0 +grpcio==1.18.0 +grpcio-tools==1.15.0 +importlib-resources==3.3.1 +ipaddress==1.0.23 +ipython==5.4.1 +ipython-genutils==0.2.0 +itsdangerous==1.1.0 +jinja2==2.11.3 +markupsafe==1.1.1 +netaddr==0.8.0 +nnpy==1.4.2 +oslo.config==2.1.0 +paramiko==2.12.0 +pathlib2==2.3.7.post1 +pbr==2.0.0 +pexpect==4.8.0 +pickleshare==0.7.5 +plumbum==1.7.2 +prompt-toolkit==1.0.18 +protobuf==3.6.1 +ptf==0.9.1 +ptyprocess==0.7.0 +pyaml==21.10.1 +pybrctl==0.1.4 +pycparser==2.21 +pygments==2.5.2 +pylibpcap==0.6.4 +pynacl==1.4.0 +pyrasite==2.0 +pyro4==4.82 +pysubnettree==0.26 +pyyaml==5.4.1 +retrying==1.3.4 +rpyc==4.1.5 +saithrift==0.9 +scandir==1.10.0 +scapy==2.2.0.dev0 +selectors34==1.2 +serpent==1.28 +simplegeneric==0.8.1 +singledispatch==3.7.0 +six==1.12.0 +stevedore==1.32.0 +supervisor==4.2.5 +thrift==0.11.0 +traitlets==4.3.3 +twisted==16.0.0 +typing==3.10.0.0 +unittest-xml-reporting==2.5.2 +wcwidth==0.2.6 +werkzeug==1.0.1 +yabgp==0.8.2 +zipp==1.2.0 +zope.interface==5.5.2 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-ptf/versions-py3 b/files/build/versions/dockers/docker-ptf/versions-py3 new file mode 100644 index 000000000000..68ff645ebbd6 --- /dev/null +++ b/files/build/versions/dockers/docker-ptf/versions-py3 @@ -0,0 +1,30 @@ +asn1crypto==0.24.0 +cryptography==2.6.1 +cycler==0.10.0 +decorator==4.3.0 +entrypoints==0.3 +ipython==5.8.0 +ipython-genutils==0.2.0 +keyring==17.1.1 +keyrings.alt==3.1.1 +kiwisolver==1.0.1 +matplotlib==3.0.2 +numpy==1.16.2 +olefile==0.46 +pexpect==4.6.0 +pickleshare==0.7.5 +pillow==5.4.1 +prompt-toolkit==1.0.15 +pycrypto==2.6.1 +pygments==2.3.1 +pygobject==3.30.4 +pyparsing==2.2.0 +python-dateutil==2.7.3 +pyx==0.14.1 +pyxdg==0.25 +scapy==2.4.0 +secretstorage==2.3.1 +simplegeneric==0.8.1 +six==1.12.0 +traitlets==4.3.2 +wcwidth==0.1.7 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-router-advertiser-dbg-sonic/versions-deb-bullseye b/files/build/versions/dockers/docker-router-advertiser-dbg-sonic/versions-deb-bullseye new file mode 100644 index 000000000000..8659cd1e0964 --- /dev/null +++ b/files/build/versions/dockers/docker-router-advertiser-dbg-sonic/versions-deb-bullseye @@ -0,0 +1,25 @@ +gdb==10.1-1.7 +gdbserver==10.1-1.7 +libbabeltrace1==1.5.8-1+b3 +libboost-regex1.74.0==1.74.0-9 +libcbor0==0.5.0+dfsg-2 +libcurl3-gnutls==7.74.0-1.3+deb11u3 +libdebuginfod1==0.183-1 +libdw1==0.183-1 +libedit2==3.1-20191231-2+b1 +libfido2-1==1.6.0-2 +libglib2.0-0==2.66.8-1 +libgpm2==1.20.7-8 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libicu67==67.1-7 +libipt2==2.0.3-1 +libmpfr6==4.1.0-3 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libswsscommon-dbg==1.0.0 +libunwind8==1.3.2-2 +openssh-client==1:8.4p1-5+deb11u1 +sshpass==1.09-1+b1 +strace==5.10-1 +vim==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-router-advertiser/versions-deb-bullseye b/files/build/versions/dockers/docker-router-advertiser/versions-deb-bullseye new file mode 100644 index 000000000000..1740ef17a275 --- /dev/null +++ b/files/build/versions/dockers/docker-router-advertiser/versions-deb-bullseye @@ -0,0 +1,26 @@ +gdb==10.1-1.7 +gdbserver==10.1-1.7 +libbabeltrace1==1.5.8-1+b3 +libboost-regex1.74.0==1.74.0-9 +libcbor0==0.5.0+dfsg-2 +libcurl3-gnutls==7.74.0-1.3+deb11u7 +libdebuginfod1==0.183-1 +libdw1==0.183-1 +libedit2==3.1-20191231-2+b1 +libfido2-1==1.6.0-2 +libglib2.0-0==2.66.8-1 +libgpm2==1.20.7-8 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libicu67==67.1-7 +libipt2==2.0.3-1 +libmpfr6==4.1.0-3 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libswsscommon-dbgsym==1.0.0 +libunwind8==1.3.2-2 +openssh-client==1:8.4p1-5+deb11u1 +radvd==1:2.18-3 +sshpass==1.09-1+b1 +strace==5.10-1 +vim==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-saiserverv2-brcm/versions-deb-bullseye b/files/build/versions/dockers/docker-saiserverv2-brcm/versions-deb-bullseye new file mode 100644 index 000000000000..607501d21217 --- /dev/null +++ b/files/build/versions/dockers/docker-saiserverv2-brcm/versions-deb-bullseye @@ -0,0 +1,20 @@ +gdb==10.1-1.7 +kmod==28-1 +libbabeltrace1==1.5.8-1+b3 +libboost-atomic1.74.0==1.74.0-9 +libboost-regex1.74.0==1.74.0-9 +libcurl3-gnutls==7.74.0-1.3+deb11u7 +libdebuginfod1==0.183-1 +libdw1==0.183-1 +libglib2.0-0==2.66.8-1 +libicu67==67.1-7 +libipt2==2.0.3-1 +libkmod2==28-1 +libmpfr6==4.1.0-3 +libsaibcm==8.4.0.2 +libsaithrift-dev==0.9.4 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libthrift0==0.14.1 +libyaml-0-2==0.2.2-1 +saiserver==0.9.4 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-sflow-dbg-sonic/versions-deb-buster b/files/build/versions/dockers/docker-sflow-dbg-sonic/versions-deb-buster new file mode 100644 index 000000000000..c054305298d7 --- /dev/null +++ b/files/build/versions/dockers/docker-sflow-dbg-sonic/versions-deb-buster @@ -0,0 +1,18 @@ +gdb==8.2.1-2+b3 +gdbserver==8.2.1-2+b3 +libbabeltrace1==1.5.6-2+deb10u1 +libbsd0==0.9.1-2+deb10u1 +libdw1==0.176-1.1 +libedit2==3.1-20181209-1 +libglib2.0-0==2.58.3-2+deb10u4 +libgpm2==1.20.7-5 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libipt2==2.0-2 +libpopt0==1.16-12 +libswsscommon-dbg==1.0.0 +libunwind8==1.2.1-10~deb10u1 +openssh-client==1:7.9p1-10+deb10u2 +sshpass==1.06-1 +strace==4.26-0.2 +vim==2:8.1.0875-5+deb10u3 +vim-runtime==2:8.1.0875-5+deb10u3 \ 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..e6a82106fd32 --- /dev/null +++ b/files/build/versions/dockers/docker-sflow/versions-deb-buster @@ -0,0 +1,21 @@ +dmidecode==3.2-1 +gdb==8.2.1-2+b3 +gdbserver==8.2.1-2+b3 +hsflowd==2.0.35-1 +libbabeltrace1==1.5.6-2+deb10u1 +libbsd0==0.9.1-2+deb10u1 +libdw1==0.176-1.1 +libedit2==3.1-20181209-1 +libglib2.0-0==2.58.3-2+deb10u4 +libgpm2==1.20.7-5 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libipt2==2.0-2 +libswsscommon-dbgsym==1.0.0 +libunwind8==1.2.1-10~deb10u1 +openssh-client==1:7.9p1-10+deb10u2 +psample==1.1-1 +sflowtool==5.04 +sshpass==1.06-1 +strace==4.26-0.2 +vim==2:8.1.0875-5+deb10u4 +vim-runtime==2:8.1.0875-5+deb10u4 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-snmp-dbg-sonic/versions-deb-bullseye b/files/build/versions/dockers/docker-snmp-dbg-sonic/versions-deb-bullseye new file mode 100644 index 000000000000..bd8332e01017 --- /dev/null +++ b/files/build/versions/dockers/docker-snmp-dbg-sonic/versions-deb-bullseye @@ -0,0 +1,28 @@ +gdb==10.1-1.7 +gdbserver==10.1-1.7 +libbabeltrace1==1.5.8-1+b3 +libboost-regex1.74.0==1.74.0-9 +libcbor0==0.5.0+dfsg-2 +libcurl3-gnutls==7.74.0-1.3+deb11u3 +libdebuginfod1==0.183-1 +libdw1==0.183-1 +libedit2==3.1-20191231-2+b1 +libfido2-1==1.6.0-2 +libglib2.0-0==2.66.8-1 +libgpm2==1.20.7-8 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libicu67==67.1-7 +libipt2==2.0.3-1 +libmpfr6==4.1.0-3 +libsnmp40-dbgsym==5.9+dfsg-4+deb11u1 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libswsscommon-dbg==1.0.0 +libunwind8==1.3.2-2 +openssh-client==1:8.4p1-5+deb11u1 +snmp-dbgsym==5.9+dfsg-4+deb11u1 +snmpd-dbgsym==5.9+dfsg-4+deb11u1 +sshpass==1.09-1+b1 +strace==5.10-1 +vim==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-snmp/versions-deb-bullseye b/files/build/versions/dockers/docker-snmp/versions-deb-bullseye new file mode 100644 index 000000000000..44b375fa23c9 --- /dev/null +++ b/files/build/versions/dockers/docker-snmp/versions-deb-bullseye @@ -0,0 +1,77 @@ +binutils==2.35.2-2 +binutils-common==2.35.2-2 +binutils-x86-64-linux-gnu==2.35.2-2 +cpp==4:10.2.1-1 +cpp-10==10.2.1-6 +freeipmi-common==1.6.6-4+deb11u1 +gcc==4:10.2.1-1 +gcc-10==10.2.1-6 +gdb==10.1-1.7 +gdbserver==10.1-1.7 +ipmitool==1.8.18-10.1 +libasan6==10.2.1-6 +libbabeltrace1==1.5.8-1+b3 +libbinutils==2.35.2-2 +libboost-regex1.74.0==1.74.0-9 +libc-dev-bin==2.31-13+deb11u5 +libc-l10n==2.31-13+deb11u5 +libc6-dev==2.31-13+deb11u5 +libcbor0==0.5.0+dfsg-2 +libcc1-0==10.2.1-6 +libcrypt-dev==1:4.4.18-4 +libctf-nobfd0==2.35.2-2 +libctf0==2.35.2-2 +libcurl3-gnutls==7.74.0-1.3+deb11u7 +libdebuginfod1==0.183-1 +libdw1==0.183-1 +libedit2==3.1-20191231-2+b1 +libexpat1-dev==2.2.10-2+deb11u5 +libfido2-1==1.6.0-2 +libfreeipmi17==1.6.6-4+deb11u1 +libgcc-10-dev==10.2.1-6 +libglib2.0-0==2.66.8-1 +libgomp1==10.2.1-6 +libgpm2==1.20.7-8 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libicu67==67.1-7 +libipt2==2.0.3-1 +libisl23==0.23-1 +libitm1==10.2.1-6 +libjs-sphinxdoc==3.4.3-2 +libjs-underscore==1.9.1~dfsg-3 +liblsan0==10.2.1-6 +libmpc3==1.2.0-1 +libmpfr6==4.1.0-3 +libnsl-dev==1.3.0-2 +libpci3==1:3.7.0-5 +libpython3-dev==3.9.2-3 +libpython3.9-dev==3.9.2-1 +libquadmath0==10.2.1-6 +libsensors-config==1:3.6.0-7 +libsensors5==1:3.6.0-7 +libsnmp-base==5.9+dfsg-4+deb11u1 +libsnmp40==5.9+dfsg-4+deb11u1 +libsnmp40-dbgsym==5.9+dfsg-4+deb11u1 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libswsscommon-dbgsym==1.0.0 +libtirpc-dev==1.3.1-1+deb11u1 +libtsan0==10.2.1-6 +libubsan1==10.2.1-6 +libunwind8==1.3.2-2 +linux-libc-dev==5.10.162-1 +locales==2.31-13+deb11u5 +make==4.3-4.1 +openssh-client==1:8.4p1-5+deb11u1 +pci.ids==0.0~2021.02.08-1 +python3-dev==3.9.2-3 +python3.9-dev==3.9.2-1 +snmp==5.9+dfsg-4+deb11u1 +snmp-dbgsym==5.9+dfsg-4+deb11u1 +snmpd==5.9+dfsg-4+deb11u1 +snmpd-dbgsym==5.9+dfsg-4+deb11u1 +sshpass==1.09-1+b1 +strace==5.10-1 +vim==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 +zlib1g-dev==1:1.2.11.dfsg-2+deb11u2 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-snmp/versions-deb-bullseye-arm64 b/files/build/versions/dockers/docker-snmp/versions-deb-bullseye-arm64 new file mode 100644 index 000000000000..8774e0ea85bd --- /dev/null +++ b/files/build/versions/dockers/docker-snmp/versions-deb-bullseye-arm64 @@ -0,0 +1 @@ +binutils-aarch64-linux-gnu==2.35.2-2 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-snmp/versions-deb-bullseye-armhf b/files/build/versions/dockers/docker-snmp/versions-deb-bullseye-armhf new file mode 100644 index 000000000000..6571b460660f --- /dev/null +++ b/files/build/versions/dockers/docker-snmp/versions-deb-bullseye-armhf @@ -0,0 +1 @@ +binutils-arm-linux-gnueabihf==2.35.2-2 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-snmp/versions-py3 b/files/build/versions/dockers/docker-snmp/versions-py3 new file mode 100644 index 000000000000..a85e55c6c8d9 --- /dev/null +++ b/files/build/versions/dockers/docker-snmp/versions-py3 @@ -0,0 +1,4 @@ +hiredis==2.2.2 +psutil==5.9.5 +python-arptable==0.0.2 +smbus==1.1.post2 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-sonic-mgmt-framework-dbg-sonic/versions-deb-buster b/files/build/versions/dockers/docker-sonic-mgmt-framework-dbg-sonic/versions-deb-buster new file mode 100644 index 000000000000..7ebfa38083e6 --- /dev/null +++ b/files/build/versions/dockers/docker-sonic-mgmt-framework-dbg-sonic/versions-deb-buster @@ -0,0 +1,19 @@ +gdb==8.2.1-2+b3 +gdbserver==8.2.1-2+b3 +libbabeltrace1==1.5.6-2+deb10u1 +libbsd0==0.9.1-2+deb10u1 +libdw1==0.176-1.1 +libedit2==3.1-20181209-1 +libglib2.0-0==2.58.3-2+deb10u4 +libgpm2==1.20.7-5 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libipt2==2.0-2 +libpopt0==1.16-12 +libswsscommon-dbg==1.0.0 +libunwind8==1.2.1-10~deb10u1 +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+deb10u3 +vim-runtime==2:8.1.0875-5+deb10u3 \ 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..dc5100449b34 --- /dev/null +++ b/files/build/versions/dockers/docker-sonic-mgmt-framework/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 +cpp==4:8.3.0-1 +cpp-8==8.3.0-6 +dh-python==3.20190308 +g++==4:8.3.0-1 +g++-8==8.3.0-6 +gcc==4:8.3.0-1 +gcc-8==8.3.0-6 +gdb==8.2.1-2+b3 +gdbserver==8.2.1-2+b3 +libasan5==8.3.0-6 +libbabeltrace1==1.5.6-2+deb10u1 +libbinutils==2.31.1-16 +libbsd0==0.9.1-2+deb10u1 +libc-dev-bin==2.28-10+deb10u2 +libc6-dev==2.28-10+deb10u2 +libcc1-0==8.3.0-6 +libcjson-dev==1.7.10-1.1+deb10u1 +libcjson1==1.7.10-1.1+deb10u1 +libcurl3-gnutls==7.64.0-4+deb10u5 +libdw1==0.176-1.1 +libedit2==3.1-20181209-1 +libexpat1-dev==2.2.6-2+deb10u6 +libgcc-8-dev==8.3.0-6 +libglib2.0-0==2.58.3-2+deb10u4 +libgomp1==8.3.0-6 +libgpm2==1.20.7-5 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libicu63==63.1-6+deb10u3 +libipt2==2.0-2 +libisl19==0.20-2 +libitm1==8.3.0-6 +liblsan0==8.3.0-6 +libmpc3==1.1.0-1 +libmpfr6==4.0.2-1 +libmpx2==8.3.0-6 +libpython3-dev==3.7.3-1 +libpython3.7-dev==3.7.3-2+deb10u4 +libquadmath0==8.3.0-6 +libstdc++-8-dev==8.3.0-6 +libswsscommon-dbgsym==1.0.0 +libtsan0==8.3.0-6 +libubsan1==8.3.0-6 +libunwind8==1.2.1-10~deb10u1 +libxml2==2.9.4+dfsg1-7+deb10u5 +linux-libc-dev==4.19.269-1 +openssh-client==1:7.9p1-10+deb10u2 +python3-dev==3.7.3-1 +python3.7-dev==3.7.3-2+deb10u4 +sonic-mgmt-common==1.0.0 +sonic-mgmt-framework==1.0-01 +sonic-mgmt-framework-dbg==1.0-01 +sshpass==1.06-1 +strace==4.26-0.2 +vim==2:8.1.0875-5+deb10u4 +vim-runtime==2:8.1.0875-5+deb10u4 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-sonic-mgmt-framework/versions-deb-buster-arm64 b/files/build/versions/dockers/docker-sonic-mgmt-framework/versions-deb-buster-arm64 new file mode 100644 index 000000000000..76a3c3a88288 --- /dev/null +++ b/files/build/versions/dockers/docker-sonic-mgmt-framework/versions-deb-buster-arm64 @@ -0,0 +1 @@ +binutils-aarch64-linux-gnu==2.31.1-16 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-sonic-mgmt-framework/versions-deb-buster-armhf b/files/build/versions/dockers/docker-sonic-mgmt-framework/versions-deb-buster-armhf new file mode 100644 index 000000000000..568b8b43bc13 --- /dev/null +++ b/files/build/versions/dockers/docker-sonic-mgmt-framework/versions-deb-buster-armhf @@ -0,0 +1 @@ +binutils-arm-linux-gnueabihf==2.31.1-16 \ 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..aa7dd414b283 --- /dev/null +++ b/files/build/versions/dockers/docker-sonic-mgmt-framework/versions-py3 @@ -0,0 +1,28 @@ +attrs==23.1.0 +certifi==2017.4.17 +charset-normalizer==3.1.0 +click==8.1.3 +clickclick==20.10.2 +connexion==2.7.0 +flask==2.2.3 +grpcio==1.54.0 +grpcio-tools==1.20.0 +idna==3.4 +importlib-resources==5.12.0 +inflection==0.5.1 +itsdangerous==2.1.2 +jsonschema==4.17.3 +jsonschema-spec==0.1.4 +lazy-object-proxy==1.9.0 +openapi-schema-validator==0.4.4 +openapi-spec-validator==0.5.6 +pathable==0.4.3 +pkgutil_resolve_name==1.3.10 +protobuf==4.22.3 +pyrsistent==0.19.3 +python-dateutil==2.6.0 +requests==2.28.2 +rfc3339-validator==0.1.4 +six==1.11.0 +urllib3==1.26.5 +werkzeug==2.2.3 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-sonic-p4rt/versions-deb-bullseye b/files/build/versions/dockers/docker-sonic-p4rt/versions-deb-bullseye new file mode 100644 index 000000000000..d86dddab2e3a --- /dev/null +++ b/files/build/versions/dockers/docker-sonic-p4rt/versions-deb-bullseye @@ -0,0 +1,2 @@ +libgmpxx4ldbl==2:6.2.1+dfsg-1+deb11u1 +sonic-p4rt==0.0.1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-sonic-telemetry-dbg-sonic/versions-deb-bullseye b/files/build/versions/dockers/docker-sonic-telemetry-dbg-sonic/versions-deb-bullseye new file mode 100644 index 000000000000..8659cd1e0964 --- /dev/null +++ b/files/build/versions/dockers/docker-sonic-telemetry-dbg-sonic/versions-deb-bullseye @@ -0,0 +1,25 @@ +gdb==10.1-1.7 +gdbserver==10.1-1.7 +libbabeltrace1==1.5.8-1+b3 +libboost-regex1.74.0==1.74.0-9 +libcbor0==0.5.0+dfsg-2 +libcurl3-gnutls==7.74.0-1.3+deb11u3 +libdebuginfod1==0.183-1 +libdw1==0.183-1 +libedit2==3.1-20191231-2+b1 +libfido2-1==1.6.0-2 +libglib2.0-0==2.66.8-1 +libgpm2==1.20.7-8 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libicu67==67.1-7 +libipt2==2.0.3-1 +libmpfr6==4.1.0-3 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libswsscommon-dbg==1.0.0 +libunwind8==1.3.2-2 +openssh-client==1:8.4p1-5+deb11u1 +sshpass==1.09-1+b1 +strace==5.10-1 +vim==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-sonic-telemetry/versions-deb-bullseye b/files/build/versions/dockers/docker-sonic-telemetry/versions-deb-bullseye new file mode 100644 index 000000000000..fe2afde05d12 --- /dev/null +++ b/files/build/versions/dockers/docker-sonic-telemetry/versions-deb-bullseye @@ -0,0 +1,45 @@ +gdb==10.1-1.7 +gdbserver==10.1-1.7 +libasan6==10.2.1-6 +libbabeltrace1==1.5.8-1+b3 +libboost-dev==1.74.0.3 +libboost-regex1.74.0==1.74.0-9 +libboost1.74-dev==1.74.0-9 +libc-dev-bin==2.31-13+deb11u5 +libc6-dev==2.31-13+deb11u5 +libcbor0==0.5.0+dfsg-2 +libcrypt-dev==1:4.4.18-4 +libcurl3-gnutls==7.74.0-1.3+deb11u7 +libdebuginfod1==0.183-1 +libdw1==0.183-1 +libedit2==3.1-20191231-2+b1 +libfido2-1==1.6.0-2 +libgcc-10-dev==10.2.1-6 +libglib2.0-0==2.66.8-1 +libgomp1==10.2.1-6 +libgpm2==1.20.7-8 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libicu67==67.1-7 +libipt2==2.0.3-1 +libitm1==10.2.1-6 +liblsan0==10.2.1-6 +libmpfr6==4.1.0-3 +libnsl-dev==1.3.0-2 +libquadmath0==10.2.1-6 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libstdc++-10-dev==10.2.1-6 +libswsscommon-dbgsym==1.0.0 +libswsscommon-dev==1.0.0 +libtirpc-dev==1.3.1-1+deb11u1 +libtsan0==10.2.1-6 +libubsan1==10.2.1-6 +libunwind8==1.3.2-2 +linux-libc-dev==5.10.162-1 +openssh-client==1:8.4p1-5+deb11u1 +sonic-gnmi==0.1 +sonic-mgmt-common==1.0.0 +sshpass==1.09-1+b1 +strace==5.10-1 +vim==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-sonic-vs/versions-deb-buster b/files/build/versions/dockers/docker-sonic-vs/versions-deb-buster new file mode 100644 index 000000000000..f662bae66074 --- /dev/null +++ b/files/build/versions/dockers/docker-sonic-vs/versions-deb-buster @@ -0,0 +1,229 @@ +arping==2.19-6 +bash-completion==1:2.8-6 +binutils==2.31.1-16 +binutils-common==2.31.1-16 +binutils-x86-64-linux-gnu==2.31.1-16 +bridge-utils==1.6-2 +build-essential==12.6 +comerr-dev==2.1-1.44.5-1+deb10u3 +conntrack==1:1.4.5-2 +cpp==4:8.3.0-1 +cpp-8==8.3.0-6 +cron==3.0pl1-134+deb10u1 +dbus==1.12.24-0+deb10u1 +dh-python==3.20190308 +dirmngr==2.2.12-1+deb10u2 +dmsetup==2:1.02.155-3 +ethtool==1:4.19-1 +fontconfig-config==2.13.1-2 +fonts-dejavu-core==2.37-1 +frr==8.2.2-sonic-0 +g++==4:8.3.0-1 +g++-8==8.3.0-6 +gcc==4:8.3.0-1 +gcc-8==8.3.0-6 +gettext-base==0.19.8.1-9 +gir1.2-freedesktop==1.58.3-2 +gir1.2-glib-2.0==1.58.3-2 +gnupg==2.2.12-1+deb10u2 +gnupg-l10n==2.2.12-1+deb10u2 +gnupg-utils==2.2.12-1+deb10u2 +gobject-introspection==1.58.3-2 +gpg==2.2.12-1+deb10u2 +gpg-agent==2.2.12-1+deb10u2 +gpg-wks-client==2.2.12-1+deb10u2 +gpg-wks-server==2.2.12-1+deb10u2 +gpgconf==2.2.12-1+deb10u2 +gpgsm==2.2.12-1+deb10u2 +grub-common==2.06-3~deb10u3 +grub2-common==2.06-3~deb10u3 +ifupdown==0.8.35 +iproute2==5.10.0-4~bpo10+1 +iptables==1.8.2-4 +krb5-multidev==1.17-3+deb10u5 +libapparmor1==2.13.2-10 +libasan5==8.3.0-6 +libassuan0==2.5.2-1 +libbinutils==2.31.1-16 +libblkid-dev==2.33.1-0.1 +libboost-atomic1.71.0==1.71.0-6~bpo10+1 +libboost-program-options1.71.0==1.71.0-6~bpo10+1 +libboost-system1.71.0==1.71.0-6~bpo10+1 +libboost-thread1.71.0==1.71.0-6~bpo10+1 +libbpf0==1:0.3-2~bpo10+1 +libbsd0==0.9.1-2+deb10u1 +libc-ares2==1.14.0-1+deb10u2 +libc-dev-bin==2.28-10+deb10u2 +libc6-dev==2.28-10+deb10u2 +libcairo-gobject2==1.16.0-4+deb10u1 +libcairo-script-interpreter2==1.16.0-4+deb10u1 +libcairo2==1.16.0-4+deb10u1 +libcairo2-dev==1.16.0-4+deb10u1 +libcc1-0==8.3.0-6 +libdbus-1-dev==1.12.24-0+deb10u1 +libdevmapper1.02.1==2:1.02.155-3 +libdouble-conversion1==3.1.0-3 +libdpkg-perl==1.19.8 +libedit2==3.1-20181209-1 +libefiboot1==37-2+deb10u1 +libefivar1==37-2+deb10u1 +libexpat1-dev==2.2.6-2+deb10u6 +libffi-dev==3.2.1-9 +libfontconfig1==2.13.1-2 +libfontconfig1-dev==2.13.1-2 +libfreetype6==2.9.1-3+deb10u3 +libfreetype6-dev==2.9.1-3+deb10u3 +libfuse2==2.9.9-1+deb10u1 +libgcc-8-dev==8.3.0-6 +libgirepository-1.0-1==1.58.3-2 +libgirepository1.0-dev==1.58.3-2 +libglib2.0-0==2.58.3-2+deb10u4 +libglib2.0-bin==2.58.3-2+deb10u4 +libglib2.0-data==2.58.3-2+deb10u4 +libglib2.0-dev==2.58.3-2+deb10u4 +libglib2.0-dev-bin==2.58.3-2+deb10u4 +libgomp1==8.3.0-6 +libgssrpc4==1.17-3+deb10u5 +libice-dev==2:1.0.9-2 +libice6==2:1.0.9-2 +libicu63==63.1-6+deb10u3 +libip4tc0==1.8.2-4 +libip6tc0==1.8.2-4 +libiptc0==1.8.2-4 +libisl19==0.20-2 +libitm1==8.3.0-6 +libjson-c3==0.12.1+ds-2+deb10u1 +libjudydebian1==1.0.5-5 +libkadm5clnt-mit11==1.17-3+deb10u5 +libkadm5srv-mit11==1.17-3+deb10u5 +libkdb5-9==1.17-3+deb10u5 +libkrb5-dev==1.17-3+deb10u5 +libksba8==1.3.5-2+deb10u2 +liblsan0==8.3.0-6 +liblzo2-2==2.10-0.1 +libmount-dev==2.33.1-0.1 +libmpc3==1.1.0-1 +libmpfr6==4.0.2-1 +libmpx2==8.3.0-6 +libnet1==1.1.6+dfsg-3.1 +libnetfilter-conntrack3==1.0.7-1 +libnfnetlink0==1.0.1-3+b1 +libnftnl11==1.1.2-2 +libnorm-dev==1.5.8+dfsg2-1 +libnpth0==1.6-1 +libpcap0.8==1.8.1-6+deb10u1 +libpcre16-3==2:8.39-12 +libpcre2-16-0==10.32-5+deb10u1 +libpcre2-8-0==10.32-5+deb10u1 +libpcre3-dev==2:8.39-12 +libpcre32-3==2:8.39-12 +libpcrecpp0v5==2:8.39-12 +libpgm-dev==5.2.122~dfsg-3 +libpixman-1-0==0.36.0-1+deb10u1 +libpixman-1-dev==0.36.0-1+deb10u1 +libpng-dev==1.6.36-6 +libpng16-16==1.6.36-6 +libpopt0==1.16-12 +libpthread-stubs0-dev==0.4-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-dev==3.7.3-1 +libpython3.7-dev==3.7.3-2+deb10u4 +libqt5core5a==5.11.3+dfsg1-1+deb10u5 +libqt5dbus5==5.11.3+dfsg1-1+deb10u5 +libqt5network5==5.11.3+dfsg1-1+deb10u5 +libquadmath0==8.3.0-6 +libsaimetadata==1.0.0 +libsairedis==1.0.0 +libsaivs==1.0.0 +libselinux1-dev==2.8-1+b1 +libsepol1-dev==2.8-1 +libsm-dev==2:1.2.3-1 +libsm6==2:1.2.3-1 +libsodium-dev==1.0.17-1 +libssl-dev==1.1.1n-0+deb10u4 +libstdc++-8-dev==8.3.0-6 +libsystemd-dev==241-7~deb10u9 +libsystemd0==241-7~deb10u9 +libteam-utils==1.30-1 +libteam5==1.30-1 +libteamdctl0==1.30-1 +libtsan0==8.3.0-6 +libubsan1==8.3.0-6 +libunwind8==1.2.1-10~deb10u1 +libx11-6==2:1.6.7-1+deb10u2 +libx11-data==2:1.6.7-1+deb10u2 +libx11-dev==2:1.6.7-1+deb10u2 +libxau-dev==1:1.0.8-1+b2 +libxau6==1:1.0.8-1+b2 +libxcb-render0==1.13.1-2 +libxcb-render0-dev==1.13.1-2 +libxcb-shm0==1.13.1-2 +libxcb-shm0-dev==1.13.1-2 +libxcb1==1.13.1-2 +libxcb1-dev==1.13.1-2 +libxdmcp-dev==1:1.1.2-3 +libxdmcp6==1:1.1.2-3 +libxext-dev==2:1.3.3-1+b2 +libxext6==2:1.3.3-1+b2 +libxrender-dev==1:0.9.10-1 +libxrender1==1:0.9.10-1 +libyang2==2.0.112-6 +libzmq3-dev==4.3.1-4+deb10u2 +linux-libc-dev==4.19.269-1 +logrotate==3.14.0-4 +lsof==4.91+dfsg-1 +make==4.2.1-1.2 +ndisc6==1.0.4-1 +openssh-client==1:7.9p1-10+deb10u2 +openssh-server==1:7.9p1-10+deb10u2 +openssh-sftp-server==1:7.9p1-10+deb10u2 +patch==2.7.6-3+deb10u1 +pinentry-curses==1.1.0-2 +pkg-config==0.29-6 +psmisc==23.2-1+deb10u1 +python==2.7.16-1 +python-dev==2.7.16-1 +python-minimal==2.7.16-1 +python-pip==18.1-5 +python-pip-whl==18.1-5 +python-ply==3.11-3 +python-scapy==2.4.0-2 +python-swsscommon==1.0.0 +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-dev==3.7.3-1 +python3-mako==1.0.7+ds1-1+deb10u1 +python3-markdown==3.0.1-3 +python3-markupsafe==1.1.0-1 +python3-pkg-resources==40.8.0-1 +python3.7-dev==3.7.3-2+deb10u4 +redis-server==5:6.0.6-1~bpo10+1 +sensible-utils==0.0.12 +sonic-device-data==1.0-1 +sonic-host-services-data==1.0-1 +sonic-utilities-data==1.0-1 +swig==3.0.12-2 +swig3.0==3.0.12-2 +swss==1.0.0 +syncd-vs==1.0.0 +tcpdump==4.9.3-1~deb10u2 +ucf==3.0038+nmu1 +uuid-dev==2.33.1-0.1 +x11-common==1:7.7+19 +x11proto-core-dev==2018.4-4 +x11proto-dev==2018.4-4 +x11proto-xext-dev==2018.4-4 +xorg-sgml-doctools==1:1.11-1 +xtrans-dev==1.3.5-1 +zlib1g-dev==1:1.2.11.dfsg-1+deb10u2 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-sonic-vs/versions-py2 b/files/build/versions/dockers/docker-sonic-vs/versions-py2 new file mode 100644 index 000000000000..1202ed030d5c --- /dev/null +++ b/files/build/versions/dockers/docker-sonic-vs/versions-py2 @@ -0,0 +1,13 @@ +certifi==2021.10.8 +chardet==4.0.0 +crontab==1.0.1 +idna==2.10 +monotonic==1.5 +netifaces==0.10.7 +ply==3.11 +py2-ipaddress==3.4.2 +pyroute2==0.5.3 +requests==2.27.1 +scapy==2.4.0 +six==1.16.0 +urllib3==1.26.15 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-sonic-vs/versions-py3 b/files/build/versions/dockers/docker-sonic-vs/versions-py3 new file mode 100644 index 000000000000..f5b5e5c8f23b --- /dev/null +++ b/files/build/versions/dockers/docker-sonic-vs/versions-py3 @@ -0,0 +1,43 @@ +async-timeout==4.0.2 +blessed==1.20.0 +certifi==2022.12.7 +charset-normalizer==3.1.0 +click==7.0 +click-log==0.4.0 +colorful==0.5.5 +dbus-python==1.3.2 +deprecated==1.2.13 +docker==6.0.1 +docker-image-py==0.1.12 +enlighten==1.11.2 +filelock==3.12.0 +idna==3.4 +importlib-metadata==6.1.0 +jsonpatch==1.32 +jsonpointer==2.3 +lazy-object-proxy==1.9.0 +m2crypto==0.38.0 +netifaces==0.10.9 +packaging==23.1 +pexpect==4.8.0 +prefixed==0.7.0 +prettyprinter==0.18.0 +ptyprocess==0.7.0 +pycairo==1.23.0 +pygments==2.15.1 +pygobject==3.44.1 +pyparsing==3.0.9 +pyroute2==0.5.14 +redis==4.5.2 +requests==2.28.2 +scapy==2.4.4 +semantic-version==2.10.0 +systemd-python==235 +toposort==1.6 +typing_extensions==4.5.0 +urllib3==1.26.15 +wcwidth==0.2.6 +websocket-client==1.5.1 +wrapt==1.14.1 +www-authenticate==0.9.2 +zipp==3.15.0 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-swss-layer-bullseye/versions-deb-bullseye b/files/build/versions/dockers/docker-swss-layer-bullseye/versions-deb-bullseye new file mode 100644 index 000000000000..2bbf607b7222 --- /dev/null +++ b/files/build/versions/dockers/docker-swss-layer-bullseye/versions-deb-bullseye @@ -0,0 +1,6 @@ +iputils-ping==3:20210202-1 +libsaimetadata==1.0.0 +libsairedis==1.0.0 +libteam5==1.30-1 +libteamdctl0==1.30-1 +swss==1.0.0 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-swss-layer-buster/versions-deb-buster b/files/build/versions/dockers/docker-swss-layer-buster/versions-deb-buster new file mode 100644 index 000000000000..5690a145b7a2 --- /dev/null +++ b/files/build/versions/dockers/docker-swss-layer-buster/versions-deb-buster @@ -0,0 +1,5 @@ +libsaimetadata==1.0.0 +libsairedis==1.0.0 +libteam5==1.30-1 +libteamdctl0==1.30-1 +swss==1.0.0 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-syncd-bfn-rpc/versions-deb-bullseye b/files/build/versions/dockers/docker-syncd-bfn-rpc/versions-deb-bullseye new file mode 100644 index 000000000000..a5d86e3cdd28 --- /dev/null +++ b/files/build/versions/dockers/docker-syncd-bfn-rpc/versions-deb-bullseye @@ -0,0 +1,23 @@ +cmake==3.18.4-2+deb11u1 +cmake-data==3.18.4-2+deb11u1 +libarchive13==3.4.3-2+deb11u1 +libboost-atomic1.74.0==1.74.0-9 +libdouble-conversion3==3.1.5-6.1 +libjsoncpp24==1.9.4-4 +libpcre2-16-0==10.36-2+deb11u1 +libqt5core5a==5.15.2+dfsg-9 +libqt5dbus5==5.15.2+dfsg-9 +libqt5network5==5.15.2+dfsg-9 +librhash0==1.4.1-2 +libthrift0==0.14.1 +libuv1==1.40.0-2 +mailcap==3.69 +mime-support==3.66 +python-pip-whl==20.3.4-4+deb11u1 +python3-pip==20.3.4-4+deb11u1 +python3-pkg-resources==52.0.0-4 +python3-setuptools==52.0.0-4 +python3-wheel==0.34.2-1 +shared-mime-info==2.0-1 +syncd-rpc==1.0.0 +wget==1.21-1+deb11u1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-syncd-bfn/versions-deb-bullseye b/files/build/versions/dockers/docker-syncd-bfn/versions-deb-bullseye new file mode 100644 index 000000000000..aa54e806637c --- /dev/null +++ b/files/build/versions/dockers/docker-syncd-bfn/versions-deb-bullseye @@ -0,0 +1,29 @@ +bfnplatform==1.0.0 +bfnsdk==1.0.0 +libc-ares2==1.17.1-1+deb11u1 +libc-dev-bin==2.31-13+deb11u5 +libc6-dev==2.31-13+deb11u5 +libcrypt-dev==1:4.4.18-4 +libcurl3-gnutls==7.74.0-1.3+deb11u7 +libdbus-1-dev==1.12.24-0+deb11u1 +libdpkg-perl==1.20.12 +libedit2==3.1-20191231-2+b1 +libglib2.0-0==2.66.8-1 +libgoogle-perftools4==2.8.1-1 +libicu67==67.1-7 +liblzma-dev==5.2.5-2.1~deb11u1 +libnsl-dev==1.3.0-2 +libpcap-dev==1.10.0-2 +libpcap0.8==1.10.0-2 +libpcap0.8-dev==1.10.0-2 +libsaimetadata==1.0.0 +libsairedis==1.0.0 +libtcmalloc-minimal4==2.8.1-1 +libtirpc-dev==1.3.1-1+deb11u1 +libunwind-dev==1.3.2-2 +libunwind8==1.3.2-2 +libusb-1.0-0==2:1.0.24-3 +libxml2==2.9.10+dfsg-6.7+deb11u3 +linux-libc-dev==5.10.162-1 +pkg-config==0.29.2-1 +syncd==1.0.0 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-syncd-brcm-dbg-sonic/versions-deb-bullseye b/files/build/versions/dockers/docker-syncd-brcm-dbg-sonic/versions-deb-bullseye new file mode 100644 index 000000000000..285826727955 --- /dev/null +++ b/files/build/versions/dockers/docker-syncd-brcm-dbg-sonic/versions-deb-bullseye @@ -0,0 +1,28 @@ +gdb==10.1-1.7 +gdbserver==10.1-1.7 +libbabeltrace1==1.5.8-1+b3 +libboost-regex1.74.0==1.74.0-9 +libcbor0==0.5.0+dfsg-2 +libcurl3-gnutls==7.74.0-1.3+deb11u3 +libdebuginfod1==0.183-1 +libdw1==0.183-1 +libedit2==3.1-20191231-2+b1 +libfido2-1==1.6.0-2 +libglib2.0-0==2.66.8-1 +libgpm2==1.20.7-8 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libicu67==67.1-7 +libipt2==2.0.3-1 +libmpfr6==4.1.0-3 +libsaimetadata-dbg==1.0.0 +libsairedis-dbg==1.0.0 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libswsscommon-dbg==1.0.0 +libunwind8==1.3.2-2 +openssh-client==1:8.4p1-5+deb11u1 +sshpass==1.09-1+b1 +strace==5.10-1 +syncd-dbg==1.0.0 +vim==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-syncd-brcm-dnx-dbg-sonic/versions-deb-bullseye b/files/build/versions/dockers/docker-syncd-brcm-dnx-dbg-sonic/versions-deb-bullseye new file mode 100644 index 000000000000..285826727955 --- /dev/null +++ b/files/build/versions/dockers/docker-syncd-brcm-dnx-dbg-sonic/versions-deb-bullseye @@ -0,0 +1,28 @@ +gdb==10.1-1.7 +gdbserver==10.1-1.7 +libbabeltrace1==1.5.8-1+b3 +libboost-regex1.74.0==1.74.0-9 +libcbor0==0.5.0+dfsg-2 +libcurl3-gnutls==7.74.0-1.3+deb11u3 +libdebuginfod1==0.183-1 +libdw1==0.183-1 +libedit2==3.1-20191231-2+b1 +libfido2-1==1.6.0-2 +libglib2.0-0==2.66.8-1 +libgpm2==1.20.7-8 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libicu67==67.1-7 +libipt2==2.0.3-1 +libmpfr6==4.1.0-3 +libsaimetadata-dbg==1.0.0 +libsairedis-dbg==1.0.0 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libswsscommon-dbg==1.0.0 +libunwind8==1.3.2-2 +openssh-client==1:8.4p1-5+deb11u1 +sshpass==1.09-1+b1 +strace==5.10-1 +syncd-dbg==1.0.0 +vim==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-syncd-brcm-dnx-rpc/versions-deb-bullseye b/files/build/versions/dockers/docker-syncd-brcm-dnx-rpc/versions-deb-bullseye new file mode 100644 index 000000000000..27520ca175c4 --- /dev/null +++ b/files/build/versions/dockers/docker-syncd-brcm-dnx-rpc/versions-deb-bullseye @@ -0,0 +1,81 @@ +binutils==2.35.2-2 +binutils-common==2.35.2-2 +binutils-x86-64-linux-gnu==2.35.2-2 +build-essential==12.9 +bzip2==1.0.8-4 +cmake==3.18.4-2+deb11u1 +cmake-data==3.18.4-2+deb11u1 +cpp==4:10.2.1-1 +cpp-10==10.2.1-6 +g++==4:10.2.1-1 +g++-10==10.2.1-6 +gcc==4:10.2.1-1 +gcc-10==10.2.1-6 +libarchive13==3.4.3-2+deb11u1 +libasan6==10.2.1-6 +libbinutils==2.35.2-2 +libboost-atomic1.74.0==1.74.0-9 +libc-dev-bin==2.31-13+deb11u5 +libc6-dev==2.31-13+deb11u5 +libcc1-0==10.2.1-6 +libcrypt-dev==1:4.4.18-4 +libctf-nobfd0==2.35.2-2 +libctf0==2.35.2-2 +libdouble-conversion3==3.1.5-6.1 +libdpkg-perl==1.20.12 +libexpat1-dev==2.2.10-2+deb11u5 +libffi-dev==3.3-6 +libgcc-10-dev==10.2.1-6 +libglib2.0-0==2.66.8-1 +libgomp1==10.2.1-6 +libicu67==67.1-7 +libisl23==0.23-1 +libitm1==10.2.1-6 +libjsoncpp24==1.9.4-4 +liblsan0==10.2.1-6 +libmpc3==1.2.0-1 +libmpfr6==4.1.0-3 +libnsl-dev==1.3.0-2 +libpcre2-16-0==10.36-2+deb11u1 +libpython2-dev==2.7.18-3 +libpython2-stdlib==2.7.18-3 +libpython2.7==2.7.18-8 +libpython2.7-dev==2.7.18-8 +libpython2.7-minimal==2.7.18-8 +libpython2.7-stdlib==2.7.18-8 +libqt5core5a==5.15.2+dfsg-9 +libqt5dbus5==5.15.2+dfsg-9 +libqt5network5==5.15.2+dfsg-9 +libquadmath0==10.2.1-6 +librhash0==1.4.1-2 +libstdc++-10-dev==10.2.1-6 +libthrift-0.11.0==0.11.0-4 +libtirpc-dev==1.3.1-1+deb11u1 +libtsan0==10.2.1-6 +libubsan1==10.2.1-6 +libuv1==1.40.0-2 +libxml2==2.9.10+dfsg-6.7+deb11u3 +linux-libc-dev==5.10.162-1 +mailcap==3.69 +make==4.3-4.1 +mime-support==3.66 +patch==2.7.6-7 +python-dev-is-python2==2.7.18-9 +python-is-python2==2.7.18-9 +python-pip-whl==20.3.4-4+deb11u1 +python-pkg-resources==44.1.1-1 +python-setuptools==44.1.1-1 +python2==2.7.18-3 +python2-dev==2.7.18-3 +python2-minimal==2.7.18-3 +python2.7==2.7.18-8 +python2.7-dev==2.7.18-8 +python2.7-minimal==2.7.18-8 +python3-pip==20.3.4-4+deb11u1 +python3-pkg-resources==52.0.0-4 +python3-setuptools==52.0.0-4 +python3-wheel==0.34.2-1 +shared-mime-info==2.0-1 +syncd-rpc==1.0.0 +wget==1.21-1+deb11u1 +xz-utils==5.2.5-2.1~deb11u1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-syncd-brcm-dnx/versions-deb-bullseye b/files/build/versions/dockers/docker-syncd-brcm-dnx/versions-deb-bullseye new file mode 100644 index 000000000000..d3c6fce40d2e --- /dev/null +++ b/files/build/versions/dockers/docker-syncd-brcm-dnx/versions-deb-bullseye @@ -0,0 +1,35 @@ +ethtool==1:5.9-1 +gdb==10.1-1.7 +gdbserver==10.1-1.7 +kmod==28-1 +libbabeltrace1==1.5.8-1+b3 +libboost-regex1.74.0==1.74.0-9 +libcbor0==0.5.0+dfsg-2 +libcurl3-gnutls==7.74.0-1.3+deb11u7 +libdebuginfod1==0.183-1 +libdw1==0.183-1 +libedit2==3.1-20191231-2+b1 +libfido2-1==1.6.0-2 +libglib2.0-0==2.66.8-1 +libgpm2==1.20.7-8 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libicu67==67.1-7 +libipt2==2.0.3-1 +libkmod2==28-1 +libmpfr6==4.1.0-3 +libsaibcm==7.1.111.1 +libsaimetadata==1.0.0 +libsaimetadata-dbg==1.0.0 +libsairedis==1.0.0 +libsairedis-dbg==1.0.0 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libswsscommon-dbgsym==1.0.0 +libunwind8==1.3.2-2 +openssh-client==1:8.4p1-5+deb11u1 +sshpass==1.09-1+b1 +strace==5.10-1 +syncd==1.0.0 +syncd-dbg==1.0.0 +vim==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-syncd-brcm-rpc/versions-deb-bullseye b/files/build/versions/dockers/docker-syncd-brcm-rpc/versions-deb-bullseye new file mode 100644 index 000000000000..27520ca175c4 --- /dev/null +++ b/files/build/versions/dockers/docker-syncd-brcm-rpc/versions-deb-bullseye @@ -0,0 +1,81 @@ +binutils==2.35.2-2 +binutils-common==2.35.2-2 +binutils-x86-64-linux-gnu==2.35.2-2 +build-essential==12.9 +bzip2==1.0.8-4 +cmake==3.18.4-2+deb11u1 +cmake-data==3.18.4-2+deb11u1 +cpp==4:10.2.1-1 +cpp-10==10.2.1-6 +g++==4:10.2.1-1 +g++-10==10.2.1-6 +gcc==4:10.2.1-1 +gcc-10==10.2.1-6 +libarchive13==3.4.3-2+deb11u1 +libasan6==10.2.1-6 +libbinutils==2.35.2-2 +libboost-atomic1.74.0==1.74.0-9 +libc-dev-bin==2.31-13+deb11u5 +libc6-dev==2.31-13+deb11u5 +libcc1-0==10.2.1-6 +libcrypt-dev==1:4.4.18-4 +libctf-nobfd0==2.35.2-2 +libctf0==2.35.2-2 +libdouble-conversion3==3.1.5-6.1 +libdpkg-perl==1.20.12 +libexpat1-dev==2.2.10-2+deb11u5 +libffi-dev==3.3-6 +libgcc-10-dev==10.2.1-6 +libglib2.0-0==2.66.8-1 +libgomp1==10.2.1-6 +libicu67==67.1-7 +libisl23==0.23-1 +libitm1==10.2.1-6 +libjsoncpp24==1.9.4-4 +liblsan0==10.2.1-6 +libmpc3==1.2.0-1 +libmpfr6==4.1.0-3 +libnsl-dev==1.3.0-2 +libpcre2-16-0==10.36-2+deb11u1 +libpython2-dev==2.7.18-3 +libpython2-stdlib==2.7.18-3 +libpython2.7==2.7.18-8 +libpython2.7-dev==2.7.18-8 +libpython2.7-minimal==2.7.18-8 +libpython2.7-stdlib==2.7.18-8 +libqt5core5a==5.15.2+dfsg-9 +libqt5dbus5==5.15.2+dfsg-9 +libqt5network5==5.15.2+dfsg-9 +libquadmath0==10.2.1-6 +librhash0==1.4.1-2 +libstdc++-10-dev==10.2.1-6 +libthrift-0.11.0==0.11.0-4 +libtirpc-dev==1.3.1-1+deb11u1 +libtsan0==10.2.1-6 +libubsan1==10.2.1-6 +libuv1==1.40.0-2 +libxml2==2.9.10+dfsg-6.7+deb11u3 +linux-libc-dev==5.10.162-1 +mailcap==3.69 +make==4.3-4.1 +mime-support==3.66 +patch==2.7.6-7 +python-dev-is-python2==2.7.18-9 +python-is-python2==2.7.18-9 +python-pip-whl==20.3.4-4+deb11u1 +python-pkg-resources==44.1.1-1 +python-setuptools==44.1.1-1 +python2==2.7.18-3 +python2-dev==2.7.18-3 +python2-minimal==2.7.18-3 +python2.7==2.7.18-8 +python2.7-dev==2.7.18-8 +python2.7-minimal==2.7.18-8 +python3-pip==20.3.4-4+deb11u1 +python3-pkg-resources==52.0.0-4 +python3-setuptools==52.0.0-4 +python3-wheel==0.34.2-1 +shared-mime-info==2.0-1 +syncd-rpc==1.0.0 +wget==1.21-1+deb11u1 +xz-utils==5.2.5-2.1~deb11u1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-syncd-brcm/versions-deb-bullseye b/files/build/versions/dockers/docker-syncd-brcm/versions-deb-bullseye new file mode 100644 index 000000000000..f47753814191 --- /dev/null +++ b/files/build/versions/dockers/docker-syncd-brcm/versions-deb-bullseye @@ -0,0 +1,36 @@ +ethtool==1:5.9-1 +gdb==10.1-1.7 +gdbserver==10.1-1.7 +kmod==28-1 +libbabeltrace1==1.5.8-1+b3 +libboost-regex1.74.0==1.74.0-9 +libcbor0==0.5.0+dfsg-2 +libcurl3-gnutls==7.74.0-1.3+deb11u7 +libdebuginfod1==0.183-1 +libdw1==0.183-1 +libedit2==3.1-20191231-2+b1 +libfido2-1==1.6.0-2 +libglib2.0-0==2.66.8-1 +libgpm2==1.20.7-8 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libicu67==67.1-7 +libipt2==2.0.3-1 +libkmod2==28-1 +libmpfr6==4.1.0-3 +libsaibcm==8.4.0.2 +libsaimetadata==1.0.0 +libsaimetadata-dbg==1.0.0 +libsairedis==1.0.0 +libsairedis-dbg==1.0.0 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libswsscommon-dbgsym==1.0.0 +libunwind8==1.3.2-2 +libyaml-0-2==0.2.2-1 +openssh-client==1:8.4p1-5+deb11u1 +sshpass==1.09-1+b1 +strace==5.10-1 +syncd==1.0.0 +syncd-dbg==1.0.0 +vim==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-syncd-centec-dbg-sonic/versions-deb-buster b/files/build/versions/dockers/docker-syncd-centec-dbg-sonic/versions-deb-buster new file mode 100644 index 000000000000..c054305298d7 --- /dev/null +++ b/files/build/versions/dockers/docker-syncd-centec-dbg-sonic/versions-deb-buster @@ -0,0 +1,18 @@ +gdb==8.2.1-2+b3 +gdbserver==8.2.1-2+b3 +libbabeltrace1==1.5.6-2+deb10u1 +libbsd0==0.9.1-2+deb10u1 +libdw1==0.176-1.1 +libedit2==3.1-20181209-1 +libglib2.0-0==2.58.3-2+deb10u4 +libgpm2==1.20.7-5 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libipt2==2.0-2 +libpopt0==1.16-12 +libswsscommon-dbg==1.0.0 +libunwind8==1.2.1-10~deb10u1 +openssh-client==1:7.9p1-10+deb10u2 +sshpass==1.06-1 +strace==4.26-0.2 +vim==2:8.1.0875-5+deb10u3 +vim-runtime==2:8.1.0875-5+deb10u3 \ 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..7b55d8b98d22 --- /dev/null +++ b/files/build/versions/dockers/docker-syncd-centec-rpc/versions-deb-buster @@ -0,0 +1,78 @@ +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+deb10u3 +libasan5==8.3.0-6 +libbinutils==2.31.1-16 +libboost-atomic1.71-dev==1.71.0-6~bpo10+1 +libboost-atomic1.71.0==1.71.0-6~bpo10+1 +libboost1.71-dev==1.71.0-6~bpo10+1 +libc-dev-bin==2.28-10+deb10u2 +libc6-dev==2.28-10+deb10u2 +libcc1-0==8.3.0-6 +libdouble-conversion1==3.1.0-3 +libdpkg-perl==1.19.8 +libexpat1-dev==2.2.6-2+deb10u6 +libffi-dev==3.2.1-9 +libgcc-8-dev==8.3.0-6 +libglib2.0-0==2.58.3-2+deb10u4 +libgomp1==8.3.0-6 +libicu63==63.1-6+deb10u3 +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+deb10u1 +libpcre2-8-0==10.32-5+deb10u1 +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 +libqt5core5a==5.11.3+dfsg1-1+deb10u5 +libqt5dbus5==5.11.3+dfsg1-1+deb10u5 +libqt5network5==5.11.3+dfsg1-1+deb10u5 +libquadmath0==8.3.0-6 +librhash0==1.3.8-1 +libssl-dev==1.1.1n-0+deb10u4 +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+deb10u1 +libxml2==2.9.4+dfsg1-7+deb10u5 +linux-libc-dev==4.19.269-1 +make==4.2.1-1.2 +patch==2.7.6-3+deb10u1 +python==2.7.16-1 +python-dev==2.7.16-1 +python-minimal==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==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 +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..60b9f31f8e4a --- /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.21 +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..d5e393cd5753 --- /dev/null +++ b/files/build/versions/dockers/docker-syncd-centec/versions-deb-buster @@ -0,0 +1,25 @@ +gdb==8.2.1-2+b3 +gdbserver==8.2.1-2+b3 +kmod==26-1 +libbabeltrace1==1.5.6-2+deb10u1 +libbsd0==0.9.1-2+deb10u1 +libdw1==0.176-1.1 +libedit2==3.1-20181209-1 +libglib2.0-0==2.58.3-2+deb10u4 +libgpm2==1.20.7-5 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libipt2==2.0-2 +libkmod2==26-1 +libpopt0==1.16-12 +libsai==1.11.0-1 +libsaimetadata==1.0.0 +libsairedis==1.0.0 +libswsscommon-dbg==1.0.0 +libswsscommon-dbgsym==1.0.0 +libunwind8==1.2.1-10~deb10u1 +openssh-client==1:7.9p1-10+deb10u2 +sshpass==1.06-1 +strace==4.26-0.2 +syncd==1.0.0 +vim==2:8.1.0875-5+deb10u4 +vim-runtime==2:8.1.0875-5+deb10u4 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-syncd-centec/versions-deb-buster-arm64 b/files/build/versions/dockers/docker-syncd-centec/versions-deb-buster-arm64 new file mode 100644 index 000000000000..ccab4a1c7a72 --- /dev/null +++ b/files/build/versions/dockers/docker-syncd-centec/versions-deb-buster-arm64 @@ -0,0 +1,37 @@ +dmsetup==2:1.02.155-3 +keyutils==1.6-6 +libdevmapper1.02.1==2:1.02.155-3 +libevent-2.1-6==2.1.8-stable-4 +libexpat1-dev==2.2.6-2+deb10u6 +libnfsidmap2==0.25-5.1 +libpcap-dev==1.8.1-6+deb10u1 +libpcap0.8==1.8.1-6+deb10u1 +libpcap0.8-dev==1.8.1-6+deb10u1 +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 +libsensors-config==1:3.5.0-3 +libsensors4-dev==1:3.5.0-3 +libsensors5==1:3.5.0-3 +libtirpc-common==1.1.4-0.4+deb10u1 +libtirpc3==1.1.4-0.4+deb10u1 +nfs-common==1:1.3.4-2.5+deb10u1 +python==2.7.16-1 +python-dev==2.7.16-1 +python-minimal==2.7.16-1 +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 +rpcbind==1.2.5-0.3+deb10u1 +sensible-utils==0.0.12 +swig==3.0.12-2 +swig3.0==3.0.12-2 +ucf==3.0038+nmu1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-syncd-mlnx-dbg-sonic/versions-deb-bullseye b/files/build/versions/dockers/docker-syncd-mlnx-dbg-sonic/versions-deb-bullseye new file mode 100644 index 000000000000..8d2f548703a6 --- /dev/null +++ b/files/build/versions/dockers/docker-syncd-mlnx-dbg-sonic/versions-deb-bullseye @@ -0,0 +1,28 @@ +gdb==10.1-1.7 +gdbserver==10.1-1.7 +libbabeltrace1==1.5.8-1+b3 +libboost-regex1.74.0==1.74.0-9 +libcbor0==0.5.0+dfsg-2 +libcurl3-gnutls==7.74.0-1.3+deb11u3 +libdebuginfod1==0.183-1 +libdw1==0.183-1 +libedit2==3.1-20191231-2+b1 +libelf1==0.183-1 +libfido2-1==1.6.0-2 +libglib2.0-0==2.66.8-1 +libgpm2==1.20.7-8 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libipt2==2.0.3-1 +libmpfr6==4.1.0-3 +libsaimetadata-dbg==1.0.0 +libsairedis-dbg==1.0.0 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libswsscommon-dbg==1.0.0 +libunwind8==1.3.2-2 +openssh-client==1:8.4p1-5+deb11u1 +sshpass==1.09-1+b1 +strace==5.10-1 +syncd-dbg==1.0.0 +vim==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-syncd-mlnx-rpc/versions-deb-bullseye b/files/build/versions/dockers/docker-syncd-mlnx-rpc/versions-deb-bullseye new file mode 100644 index 000000000000..888353c9c191 --- /dev/null +++ b/files/build/versions/dockers/docker-syncd-mlnx-rpc/versions-deb-bullseye @@ -0,0 +1,69 @@ +binutils==2.35.2-2 +binutils-common==2.35.2-2 +binutils-x86-64-linux-gnu==2.35.2-2 +build-essential==12.9 +bzip2==1.0.8-4 +cmake==3.18.4-2+deb11u1 +cmake-data==3.18.4-2+deb11u1 +cpp==4:10.2.1-1 +cpp-10==10.2.1-6 +g++==4:10.2.1-1 +g++-10==10.2.1-6 +gcc==4:10.2.1-1 +gcc-10==10.2.1-6 +libarchive13==3.4.3-2+deb11u1 +libasan6==10.2.1-6 +libbinutils==2.35.2-2 +libboost-atomic1.74.0==1.74.0-9 +libcc1-0==10.2.1-6 +libctf-nobfd0==2.35.2-2 +libctf0==2.35.2-2 +libdouble-conversion3==3.1.5-6.1 +libdpkg-perl==1.20.12 +libffi-dev==3.3-6 +libgcc-10-dev==10.2.1-6 +libglib2.0-0==2.66.8-1 +libgomp1==10.2.1-6 +libisl23==0.23-1 +libitm1==10.2.1-6 +libjsoncpp24==1.9.4-4 +liblsan0==10.2.1-6 +libmpc3==1.2.0-1 +libmpfr6==4.1.0-3 +libpcre2-16-0==10.36-2+deb11u1 +libpython2-dev==2.7.18-3 +libpython2-stdlib==2.7.18-3 +libpython2.7==2.7.18-8 +libpython2.7-dev==2.7.18-8 +libpython2.7-minimal==2.7.18-8 +libpython2.7-stdlib==2.7.18-8 +libqt5core5a==5.15.2+dfsg-9 +libqt5dbus5==5.15.2+dfsg-9 +libqt5network5==5.15.2+dfsg-9 +libquadmath0==10.2.1-6 +librhash0==1.4.1-2 +libstdc++-10-dev==10.2.1-6 +libthrift-0.11.0==0.11.0-4 +libtsan0==10.2.1-6 +libubsan1==10.2.1-6 +libuv1==1.40.0-2 +mailcap==3.69 +make==4.3-4.1 +mime-support==3.66 +patch==2.7.6-7 +python-dev-is-python2==2.7.18-9 +python-is-python2==2.7.18-9 +python-pkg-resources==44.1.1-1 +python-ptf==0.9-1 +python-scapy==2.4.0-2 +python-setuptools==44.1.1-1 +python2==2.7.18-3 +python2-dev==2.7.18-3 +python2-minimal==2.7.18-3 +python2.7==2.7.18-8 +python2.7-dev==2.7.18-8 +python2.7-minimal==2.7.18-8 +shared-mime-info==2.0-1 +syncd-rpc==1.0.0 +wget==1.21-1+deb11u1 +xz-utils==5.2.5-2.1~deb11u1 \ 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..76868ff7cc95 --- /dev/null +++ b/files/build/versions/dockers/docker-syncd-mlnx-rpc/versions-py2 @@ -0,0 +1,6 @@ +cffi==1.7.0 +nnpy==1.4.2 +ptf==0.9.1 +pycparser==2.21 +python-sdk-api==4.5.4206 +scapy==2.4.0 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-syncd-mlnx/versions-deb-bullseye b/files/build/versions/dockers/docker-syncd-mlnx/versions-deb-bullseye new file mode 100644 index 000000000000..4dc20af1b53d --- /dev/null +++ b/files/build/versions/dockers/docker-syncd-mlnx/versions-deb-bullseye @@ -0,0 +1,81 @@ +applibs==1.mlnx.4.5.4206 +applibs-dev==1.mlnx.4.5.4206 +gdb==10.1-1.7 +gdbserver==10.1-1.7 +iproute2-dev==1.mlnx.4.5.4206 +libbabeltrace1==1.5.8-1+b3 +libboost-regex1.74.0==1.74.0-9 +libc-dev-bin==2.31-13+deb11u5 +libc6-dev==2.31-13+deb11u5 +libcbor0==0.5.0+dfsg-2 +libcrypt-dev==1:4.4.18-4 +libcurl3-gnutls==7.74.0-1.3+deb11u7 +libdebuginfod1==0.183-1 +libdw1==0.183-1 +libedit2==3.1-20191231-2+b1 +libelf1==0.183-1 +libexpat1-dev==2.2.10-2+deb11u5 +libfido2-1==1.6.0-2 +libglib2.0-0==2.66.8-1 +libgpm2==1.20.7-8 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libicu67==67.1-7 +libipt2==2.0.3-1 +libjs-sphinxdoc==3.4.3-2 +libjs-underscore==1.9.1~dfsg-3 +libmpfr6==4.1.0-3 +libnsl-dev==1.3.0-2 +libpython3-dev==3.9.2-3 +libpython3.9-dev==3.9.2-1 +libsaimetadata==1.0.0 +libsaimetadata-dbg==1.0.0 +libsairedis==1.0.0 +libsairedis-dbg==1.0.0 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libswsscommon-dbg==1.0.0 +libswsscommon-dbgsym==1.0.0 +libtirpc-dev==1.3.1-1+deb11u1 +libunwind8==1.3.2-2 +libxml2==2.9.10+dfsg-6.7+deb11u3 +linux-libc-dev==5.10.162-1 +mft==4.22.1-15 +mlnx-sai==1.mlnx.SAIBuild2211.23.1.0 +openssh-client==1:8.4p1-5+deb11u1 +python-pip-whl==20.3.4-4+deb11u1 +python-sdk-api==1.mlnx.4.5.4206 +python3-attr==20.3.0-1 +python3-dev==3.9.2-3 +python3-importlib-metadata==1.6.0-2 +python3-jsonschema==3.2.0-3 +python3-more-itertools==4.2.0-3 +python3-pip==20.3.4-4+deb11u1 +python3-pkg-resources==52.0.0-4 +python3-pyrsistent==0.15.5-1+b3 +python3-setuptools==52.0.0-4 +python3-six==1.16.0-2 +python3-wheel==0.34.2-1 +python3-zipp==1.0.0-3 +python3.9-dev==3.9.2-1 +sshpass==1.09-1+b1 +strace==5.10-1 +sx-acl-helper==1.mlnx.4.5.4206 +sx-acl-helper-dev==1.mlnx.4.5.4206 +sx-complib==1.mlnx.4.5.4206 +sx-complib-dev==1.mlnx.4.5.4206 +sx-examples==1.mlnx.4.5.4206 +sx-examples-dev==1.mlnx.4.5.4206 +sx-gen-utils==1.mlnx.4.5.4206 +sx-gen-utils-dev==1.mlnx.4.5.4206 +sx-hash-calc==1.mlnx.4.5.4206 +sx-scew==1.mlnx.4.5.4206 +sx-scew-dev==1.mlnx.4.5.4206 +sxd-libs==1.mlnx.4.5.4206 +sxd-libs-dev==1.mlnx.4.5.4206 +syncd==1.0.0 +syncd-dbg==1.0.0 +vim==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 +wjh-libs==1.mlnx.4.5.4206 +wjh-libs-dev==1.mlnx.4.5.4206 +zlib1g-dev==1:1.2.11.dfsg-2+deb11u2 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-syncd-mlnx/versions-py3 b/files/build/versions/dockers/docker-syncd-mlnx/versions-py3 new file mode 100644 index 000000000000..320cc0aa4ae7 --- /dev/null +++ b/files/build/versions/dockers/docker-syncd-mlnx/versions-py3 @@ -0,0 +1,7 @@ +attrs==20.3.0 +importlib-metadata==1.6.0 +jsonschema==3.2.0 +more-itertools==4.2.0 +pyrsistent==0.15.5 +python_sdk_api==4.5.4206 +zipp==1.0.0 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-syncd-mrvl/versions-deb-bullseye-armhf b/files/build/versions/dockers/docker-syncd-mrvl/versions-deb-bullseye-armhf new file mode 100644 index 000000000000..21ef4c471559 --- /dev/null +++ b/files/build/versions/dockers/docker-syncd-mrvl/versions-deb-bullseye-armhf @@ -0,0 +1,44 @@ +dmsetup==2:1.02.175-2.1 +iputils-ping==3:20210202-1 +keyutils==1.6.1-2 +libdbus-1-dev==1.12.24-0+deb11u1 +libdevmapper1.02.1==2:1.02.175-2.1 +libdpkg-perl==1.20.12 +libevent-2.1-7==2.1.12-stable-1 +libexpat1-dev==2.2.10-2+deb11u5 +libglib2.0-0==2.66.8-1 +libnfsidmap2==0.25-6 +libpcap-dev==1.10.0-2 +libpcap0.8==1.10.0-2 +libpcap0.8-dev==1.10.0-2 +libpython2-dev==2.7.18-3 +libpython2-stdlib==2.7.18-3 +libpython2.7==2.7.18-8 +libpython2.7-dev==2.7.18-8 +libpython2.7-minimal==2.7.18-8 +libpython2.7-stdlib==2.7.18-8 +libsaimetadata==1.0.0 +libsairedis==1.0.0 +libsensors-config==1:3.6.0-7 +libsensors-dev==1:3.6.0-7 +libsensors4-dev==1:3.6.0-7 +libsensors5==1:3.6.0-7 +mailcap==3.69 +mime-support==3.66 +mrvllibsai==1.10.2-1 +nfs-common==1:1.3.4-6 +pkg-config==0.29.2-1 +python-dev-is-python2==2.7.18-9 +python-is-python2==2.7.18-9 +python2==2.7.18-3 +python2-dev==2.7.18-3 +python2-minimal==2.7.18-3 +python2.7==2.7.18-8 +python2.7-dev==2.7.18-8 +python2.7-minimal==2.7.18-8 +rpcbind==1.2.5-9 +sensible-utils==0.0.14 +swig==4.0.2-1 +swig4.0==4.0.2-1 +syncd==1.0.0 +ucf==3.0043 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-syncd-vs-dbg-sonic/versions-deb-buster b/files/build/versions/dockers/docker-syncd-vs-dbg-sonic/versions-deb-buster new file mode 100644 index 000000000000..51e97a4fd6a2 --- /dev/null +++ b/files/build/versions/dockers/docker-syncd-vs-dbg-sonic/versions-deb-buster @@ -0,0 +1,21 @@ +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 +libglib2.0-0==2.58.3-2+deb10u4 +libgpm2==1.20.7-5 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libipt2==2.0-2 +libpopt0==1.16-12 +libsaimetadata-dbg==1.0.0 +libsairedis-dbg==1.0.0 +libsaivs-dbg==1.0.0 +libswsscommon-dbg==1.0.0 +libunwind8==1.2.1-10~deb10u1 +openssh-client==1:7.9p1-10+deb10u2 +sshpass==1.06-1 +strace==4.26-0.2 +syncd-vs-dbg==1.0.0 +vim==2:8.1.0875-5+deb10u3 +vim-runtime==2:8.1.0875-5+deb10u3 \ 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..69991139fbab --- /dev/null +++ b/files/build/versions/dockers/docker-syncd-vs/versions-deb-buster @@ -0,0 +1,29 @@ +gdb==8.2.1-2+b3 +gdbserver==8.2.1-2+b3 +iproute2==5.10.0-4~bpo10+1 +libbabeltrace1==1.5.6-2+deb10u1 +libbpf0==1:0.3-2~bpo10+1 +libbsd0==0.9.1-2+deb10u1 +libdw1==0.176-1.1 +libedit2==3.1-20181209-1 +libglib2.0-0==2.58.3-2+deb10u4 +libgpm2==1.20.7-5 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libipt2==2.0-2 +libpopt0==1.16-12 +libsaimetadata==1.0.0 +libsaimetadata-dbg==1.0.0 +libsairedis==1.0.0 +libsairedis-dbg==1.0.0 +libsaivs==1.0.0 +libsaivs-dbg==1.0.0 +libswsscommon-dbg==1.0.0 +libswsscommon-dbgsym==1.0.0 +libunwind8==1.2.1-10~deb10u1 +openssh-client==1:7.9p1-10+deb10u2 +sshpass==1.06-1 +strace==4.26-0.2 +syncd-vs==1.0.0 +syncd-vs-dbg==1.0.0 +vim==2:8.1.0875-5+deb10u4 +vim-runtime==2:8.1.0875-5+deb10u4 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-teamd-dbg-sonic/versions-deb-bullseye b/files/build/versions/dockers/docker-teamd-dbg-sonic/versions-deb-bullseye new file mode 100644 index 000000000000..786df9c9a692 --- /dev/null +++ b/files/build/versions/dockers/docker-teamd-dbg-sonic/versions-deb-bullseye @@ -0,0 +1,28 @@ +gdb==10.1-1.7 +gdbserver==10.1-1.7 +libbabeltrace1==1.5.8-1+b3 +libboost-regex1.74.0==1.74.0-9 +libcbor0==0.5.0+dfsg-2 +libcurl3-gnutls==7.74.0-1.3+deb11u3 +libdebuginfod1==0.183-1 +libdw1==0.183-1 +libedit2==3.1-20191231-2+b1 +libfido2-1==1.6.0-2 +libglib2.0-0==2.66.8-1 +libgpm2==1.20.7-8 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libicu67==67.1-7 +libipt2==2.0.3-1 +libmpfr6==4.1.0-3 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libswsscommon-dbg==1.0.0 +libteam-utils-dbgsym==1.30-1 +libteamdctl0-dbgsym==1.30-1 +libunwind8==1.3.2-2 +openssh-client==1:8.4p1-5+deb11u1 +sshpass==1.09-1+b1 +strace==5.10-1 +swss-dbg==1.0.0 +vim==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-teamd/versions-deb-bullseye b/files/build/versions/dockers/docker-teamd/versions-deb-bullseye new file mode 100644 index 000000000000..6d8a7109877c --- /dev/null +++ b/files/build/versions/dockers/docker-teamd/versions-deb-bullseye @@ -0,0 +1,29 @@ +gdb==10.1-1.7 +gdbserver==10.1-1.7 +libbabeltrace1==1.5.8-1+b3 +libboost-regex1.74.0==1.74.0-9 +libcbor0==0.5.0+dfsg-2 +libcurl3-gnutls==7.74.0-1.3+deb11u7 +libdebuginfod1==0.183-1 +libdw1==0.183-1 +libedit2==3.1-20191231-2+b1 +libfido2-1==1.6.0-2 +libglib2.0-0==2.66.8-1 +libgpm2==1.20.7-8 +libhiredis0.14-dbgsym==0.14.0-3~bpo9+1 +libicu67==67.1-7 +libipt2==2.0.3-1 +libmpfr6==4.1.0-3 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libswsscommon-dbgsym==1.0.0 +libteam-utils==1.30-1 +libteam-utils-dbgsym==1.30-1 +libteamdctl0-dbgsym==1.30-1 +libunwind8==1.3.2-2 +openssh-client==1:8.4p1-5+deb11u1 +sshpass==1.09-1+b1 +strace==5.10-1 +swss-dbg==1.0.0 +vim==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 \ No newline at end of file diff --git a/files/build/versions/dockers/sonic-slave-bullseye/versions-deb-bullseye b/files/build/versions/dockers/sonic-slave-bullseye/versions-deb-bullseye new file mode 100644 index 000000000000..c324b3bb7989 --- /dev/null +++ b/files/build/versions/dockers/sonic-slave-bullseye/versions-deb-bullseye @@ -0,0 +1,1739 @@ +adwaita-icon-theme==3.38.0-1 +alsa-topology-conf==1.2.4-1 +alsa-ucm-conf==1.2.4-2 +ant==1.10.9-4 +ant-optional==1.10.9-4 +apparmor==2.13.6-10 +apt-file==3.2.2 +apt-transport-https==2.2.4 +apt-utils==2.2.4 +arch-test==0.17-1 +asciidoctor==2.0.12-2 +aspell==0.60.8-3 +aspell-en==2018.04.16-0-1 +at-spi2-core==2.38.0-4 +auditd==1:3.0-2 +augeas-lenses==1.12.0-2 +augeas-tools==1.12.0-2 +autoconf==2.69-14 +autoconf-archive==20190106-2.1 +autogen==1:5.18.16-4 +autogen-doc==1:5.18.16-4 +automake==1:1.16.3-2 +autopoint==0.21-4 +autotools-dev==20180224.1+nmu1 +bash-completion==1:2.11-2 +bc==1.07.1-2+b2 +bind9-dnsutils==1:9.16.37-1~deb11u1 +bind9-host==1:9.16.37-1~deb11u1 +bind9-libs==1:9.16.37-1~deb11u1 +binfmt-support==2.2.1-1+deb11u1 +binutils==2.35.2-2 +binutils-common==2.35.2-2 +binutils-x86-64-linux-gnu==2.35.2-2 +bison==2:3.7.5+dfsg-1 +blt==2.5.3+dfsg-4.1 +bsdextrautils==2.36.1-8+deb11u1 +build-essential==12.9 +byacc==20140715-1+b1 +bzip2==1.0.8-4 +bzip2-doc==1.0.8-4 +ca-certificates==20210119 +ca-certificates-java==20190909 +cdbs==0.4.163 +check==0.15.2-2 +chrpath==0.16-2+b1 +clang==1:11.0-51+nmu5 +clang-11==1:11.0.1-2 +cm-super-minimal==0.3.4-15 +cmake==3.18.4-2+deb11u1 +cmake-data==3.18.4-2+deb11u1 +cmocka-doc==1.1.5-2 +comerr-dev==2.1-1.46.2-2 +containerd.io==1.5.11-1 +cowbuilder==0.89 +cowdancer==0.89 +cpio==2.13+dfsg-4 +cpp==4:10.2.1-1 +cpp-10==10.2.1-6 +cppcheck==2.3-1 +cron==3.0pl1-137 +curl==7.74.0-1.3+deb11u7 +dbus==1.12.24-0+deb11u1 +dbus-user-session==1.12.24-0+deb11u1 +dconf-gsettings-backend==0.38.0-2 +dconf-service==0.38.0-2 +dctrl-tools==2.24-3+b1 +debhelper==13.3.4 +debian-keyring==2021.07.26 +debootstrap==1.0.123+deb11u1 +default-jdk-headless==2:1.11-72 +default-jre==2:1.11-72 +default-jre-headless==2:1.11-72 +default-libmysqlclient-dev==1.0.7 +device-tree-compiler==1.6.0-1 +devscripts==2.21.3+deb11u1 +dh-apparmor==2.13.6-10 +dh-autoreconf==20 +dh-exec==0.23.2 +dh-make==2.202003 +dh-python==4.20201102+nmu1 +dh-runit==2.10.3 +dh-strip-nondeterminism==1.12.0-1 +dictionaries-common==1.28.4 +diffstat==1.64-1 +dirmngr==2.2.27-2+deb11u2 +distro-info-data==0.51+deb11u3 +dkms==2.8.4-3 +dmeventd==2:1.02.175-2.1 +dmsetup==2:1.02.175-2.1 +dnsutils==1:9.16.37-1~deb11u1 +docbook==4.5-6 +docbook-dsssl==1.79-9.2 +docbook-to-man==1:2.0.0-45 +docbook-utils==0.6.14-3.4 +docbook-xml==4.5-9 +docker-ce==5:20.10.14~3-0~debian-bullseye +docker-ce-cli==5:20.10.14~3-0~debian-bullseye +docker-ce-rootless-extras==5:23.0.4-1~debian.11~bullseye +docker-scan-plugin==0.23.0~debian-bullseye +docutils-common==0.16+dfsg-4 +dosfstools==4.2-1 +doxygen==1.9.1-1 +dpatch==2.0.41 +dpkg-dev==1.20.12 +dput==1.1.0 +dvipng==1.15-1.1+b1 +dvisvgm==2.11.1-1 +dwarves==1.20-1 +dwz==0.13+20210201-1 +eatmydata==105-9 +ed==1.17-1 +emacsen-common==3.0.4 +equivs==2.3.1 +exim4-base==4.94.2-7 +exim4-config==4.94.2-7 +exim4-daemon-light==4.94.2-7 +expat==2.2.10-2+deb11u5 +fakeroot==1.25.3-1.1 +file==1:5.39-3 +flex==2.6.4-8 +fontconfig==2.13.1-4.2 +fontconfig-config==2.13.1-4.2 +fonts-dejavu-core==2.37-2 +fonts-dejavu-extra==2.37-2 +fonts-droid-fallback==1:6.0.1r16-1.1 +fonts-font-awesome==5.0.10+really4.7.0~dfsg-4.1 +fonts-lato==2.0-2.1 +fonts-liberation==1:1.07.4-11 +fonts-lmodern==2.004.5-6.1 +fonts-noto-mono==20201225-1 +fonts-texgyre==20180621-3.1 +fonts-urw-base35==20200910-1 +g++==4:10.2.1-1 +g++-10==10.2.1-6 +gawk==1:5.1.0-1 +gcc==4:10.2.1-1 +gcc-10==10.2.1-6 +gcc-10-multilib==10.2.1-6 +gcc-multilib==4:10.2.1-1 +gcovr==4.2-1 +gdb==10.1-1.7 +gem2deb==1.4 +gem2deb-test-runner==1.4 +gettext==0.21-4 +gettext-base==0.21-4 +ghostscript==9.53.3~dfsg-7+deb11u4 +gir1.2-atk-1.0==2.36.0-2 +gir1.2-atspi-2.0==2.38.0-4 +gir1.2-freedesktop==1.66.1-1+b1 +gir1.2-gdkpixbuf-2.0==2.42.2+dfsg-1+deb11u1 +gir1.2-glib-2.0==1.66.1-1+b1 +gir1.2-gtk-3.0==3.24.24-4+deb11u2 +gir1.2-harfbuzz-0.0==2.7.4-1 +gir1.2-packagekitglib-1.0==1.2.2-2 +gir1.2-pango-1.0==1.46.2-3 +git==1:2.30.2-1+deb11u2 +git-buildpackage==0.9.22 +git-man==1:2.30.2-1+deb11u2 +glib-networking==2.66.0-2 +glib-networking-common==2.66.0-2 +glib-networking-services==2.66.0-2 +gnupg==2.2.27-2+deb11u2 +gnupg-l10n==2.2.27-2+deb11u2 +gnupg-utils==2.2.27-2+deb11u2 +gnupg2==2.2.27-2+deb11u2 +gobject-introspection==1.66.1-1+b1 +golang-1.15==1.15.15-1~deb11u4 +golang-1.15-doc==1.15.15-1~deb11u4 +golang-1.15-go==1.15.15-1~deb11u4+fips +golang-1.15-src==1.15.15-1~deb11u4+fips +googletest==1.10.0.20201025-1.1 +gpg==2.2.27-2+deb11u2 +gpg-agent==2.2.27-2+deb11u2 +gpg-wks-client==2.2.27-2+deb11u2 +gpg-wks-server==2.2.27-2+deb11u2 +gpgconf==2.2.27-2+deb11u2 +gpgsm==2.2.27-2+deb11u2 +graphviz==2.42.2-5 +groff==1.22.4-6 +groff-base==1.22.4-6 +gsasl-common==1.10.0-4+deb11u1 +gsettings-desktop-schemas==3.38.0-2 +gsfonts==1:8.11+urwcyr1.0.7~pre44-4.5 +gstreamer1.0-libav==1.18.4-3 +gstreamer1.0-plugins-base==1.18.4-2 +gstreamer1.0-plugins-good==1.18.4-2+deb11u1 +gstreamer1.0-x==1.18.4-2 +gtk-update-icon-cache==3.24.24-4+deb11u2 +guile-2.2-libs==2.2.7+1-6 +hicolor-icon-theme==0.17-2 +i965-va-driver==2.4.1+dfsg1-1 +ibverbs-providers==33.2-1 +icc-profiles-free==2.0.1+dfsg-1.1 +icu-devtools==67.1-7 +imagemagick==8:6.9.11.60+dfsg-1.3+deb11u1 +imagemagick-6-common==8:6.9.11.60+dfsg-1.3+deb11u1 +imagemagick-6.q16==8:6.9.11.60+dfsg-1.3+deb11u1 +install-info==6.7.0.dfsg.2-6 +intel-media-va-driver==21.1.1+dfsg1-1 +intltool-debian==0.35.0+20060710.5 +iproute2==5.10.0-4 +iptables==1.8.7-1 +ipxe-qemu==1.0.0+git-20190125.36a4c85-5.1 +iso-codes==4.6.0-1 +java-common==0.72 +java-wrappers==0.3 +javahelper==0.78 +javascript-common==11+nmu1 +jq==1.6-2.1 +junit5==5.3.2-4 +kernel-wedge==2.104 +kmod==28-1 +krb5-multidev==1.18.3-6+deb11u3 +lcov==1.14-2 +less==551-2 +lib32asan6==10.2.1-6 +lib32atomic1==10.2.1-6 +lib32gcc-10-dev==10.2.1-6 +lib32gcc-s1==10.2.1-6 +lib32gomp1==10.2.1-6 +lib32itm1==10.2.1-6 +lib32quadmath0==10.2.1-6 +lib32stdc++6==10.2.1-6 +lib32ubsan1==10.2.1-6 +libaa1==1.4p5-48 +libaacs0==0.9.0-2 +libabsl-dev==0~20200923.3-2 +libabsl20200923==0~20200923.3-2 +libacl1-dev==2.2.53-10 +libaio1==0.3.112-9 +libalgorithm-c3-perl==0.11-1 +libalgorithm-diff-perl==1.201-1 +libalgorithm-diff-xs-perl==0.04-6+b1 +libalgorithm-merge-perl==0.08-3 +libaliased-perl==0.34-1.1 +libann0==1.1.2+doc-7 +libaom0==1.0.0.errata1-3 +libaopalliance-java==20070526-6 +libapache-pom-java==18-1 +libapiguardian-java==1.1.0-2 +libapparmor1==2.13.6-10 +libappconfig-perl==1.71-2.1 +libappstream4==0.14.4-1 +libapt-pkg-perl==0.1.39 +libarchive-cpio-perl==0.10-1.1 +libarchive-zip-perl==1.68-1 +libarchive13==3.4.3-2+deb11u1 +libargon2-1==0~20171227-0.2 +libarray-intspan-perl==2.004-1 +libasan6==10.2.1-6 +libasm-java==9.1-1 +libasound2==1.2.4-1.1 +libasound2-data==1.2.4-1.1 +libaspell15==0.60.8-3 +libass9==1:0.15.0-2 +libassuan0==2.5.3-7.1 +libasyncns0==0.8-6+b2 +libatinject-jsr330-api-java==1.0+ds1-5 +libatk-bridge2.0-0==2.38.0-1 +libatk-bridge2.0-dev==2.38.0-1 +libatk-wrapper-java==0.38.0-2+deb11u1 +libatk-wrapper-java-jni==0.38.0-2+deb11u1 +libatk1.0-0==2.36.0-2 +libatk1.0-data==2.36.0-2 +libatk1.0-dev==2.36.0-2 +libatm1==1:2.5.1-4 +libatm1-dev==1:2.5.1-4 +libatomic1==10.2.1-6 +libatspi2.0-0==2.38.0-4 +libatspi2.0-dev==2.38.0-4 +libattr1-dev==1:2.4.48-6 +libaudit-dev==1:3.0-2 +libaugeas0==1.12.0-2 +libauparse-dev==1:3.0-2 +libauparse0==1:3.0-2 +libauthen-sasl-perl==2.1600-1.1 +libavahi-client3==0.8-5+deb11u1 +libavahi-common-data==0.8-5+deb11u1 +libavahi-common3==0.8-5+deb11u1 +libavc1394-0==0.5.4-5 +libavcodec58==7:4.3.5-0+deb11u1 +libavfilter7==7:4.3.5-0+deb11u1 +libavformat58==7:4.3.5-0+deb11u1 +libavutil56==7:4.3.5-0+deb11u1 +libb-hooks-endofscope-perl==0.24-1.1 +libb-hooks-op-check-perl==0.22-1+b3 +libbabeltrace-dev==1.5.8-1+b3 +libbabeltrace1==1.5.8-1+b3 +libbatik-java==1.12-4+deb11u1 +libbdplus0==0.1.2-3 +libbind-export-dev==1:9.11.19+dfsg-2.1 +libbinutils==2.35.2-2 +libbit-vector-perl==7.4-1+b7 +libblas3==3.9.0-3 +libblkid-dev==2.36.1-8+deb11u1 +libbluray2==1:1.2.1-4+deb11u2 +libboost-atomic-dev==1.74.0.3 +libboost-atomic1.74-dev==1.74.0-9 +libboost-atomic1.74.0==1.74.0-9 +libboost-chrono-dev==1.74.0.3 +libboost-chrono1.74-dev==1.74.0-9 +libboost-chrono1.74.0==1.74.0-9 +libboost-container-dev==1.74.0.3 +libboost-container1.74-dev==1.74.0-9 +libboost-container1.74.0==1.74.0-9 +libboost-context-dev==1.74.0.3 +libboost-context1.74-dev==1.74.0-9 +libboost-context1.74.0==1.74.0-9 +libboost-contract-dev==1.74.0.3 +libboost-contract1.74-dev==1.74.0-9 +libboost-contract1.74.0==1.74.0-9 +libboost-coroutine-dev==1.74.0.3 +libboost-coroutine1.74-dev==1.74.0-9 +libboost-coroutine1.74.0==1.74.0-9 +libboost-date-time-dev==1.74.0.3 +libboost-date-time1.74-dev==1.74.0-9 +libboost-date-time1.74.0==1.74.0-9 +libboost-dev==1.74.0.3 +libboost-fiber-dev==1.74.0.3 +libboost-fiber1.74-dev==1.74.0-9 +libboost-fiber1.74.0==1.74.0-9 +libboost-filesystem-dev==1.74.0.3 +libboost-filesystem1.74-dev==1.74.0-9 +libboost-filesystem1.74.0==1.74.0-9 +libboost-graph-parallel-dev==1.74.0.3 +libboost-graph-parallel1.74-dev==1.74.0-9 +libboost-graph-parallel1.74.0==1.74.0-9 +libboost-log-dev==1.74.0.3 +libboost-log1.74-dev==1.74.0-9 +libboost-log1.74.0==1.74.0-9 +libboost-mpi1.74.0==1.74.0-9 +libboost-program-options-dev==1.74.0.3 +libboost-program-options1.74-dev==1.74.0-9 +libboost-program-options1.74.0==1.74.0-9 +libboost-regex-dev==1.74.0.3 +libboost-regex1.74-dev==1.74.0-9 +libboost-regex1.74.0==1.74.0-9 +libboost-serialization1.74-dev==1.74.0-9 +libboost-serialization1.74.0==1.74.0-9 +libboost-system-dev==1.74.0.3 +libboost-system1.74-dev==1.74.0-9 +libboost-system1.74.0==1.74.0-9 +libboost-test1.74-dev==1.74.0-9 +libboost-test1.74.0==1.74.0-9 +libboost-thread-dev==1.74.0.3 +libboost-thread1.74-dev==1.74.0-9 +libboost-thread1.74.0==1.74.0-9 +libboost1.74-dev==1.74.0-9 +libbpf0==1:0.3-2 +libbrlapi0.8==6.3+dfsg-1+deb11u1 +libbrotli-dev==1.0.9-2+b2 +libbrotli1==1.0.9-2+b2 +libbs2b0==3.1.0+dfsg-2.2+b1 +libbsd-dev==0.11.3-1 +libbsd0==0.11.3-1 +libbsh-java==2.0b4-20 +libbz2-dev==1.0.8-4 +libc-ares-dev==1.17.1-1+deb11u1 +libc-ares2==1.17.1-1+deb11u1 +libc-dev-bin==2.31-13+deb11u5 +libc-devtools==2.31-13+deb11u5 +libc-l10n==2.31-13+deb11u5 +libc6-dbg==2.31-13+deb11u5 +libc6-dev==2.31-13+deb11u5 +libc6-dev-i386==2.31-13+deb11u5 +libc6-dev-x32==2.31-13+deb11u5 +libc6-i386==2.31-13+deb11u5 +libc6-x32==2.31-13+deb11u5 +libcaca0==0.99.beta19-2.2 +libcacard0==1:2.8.0-3 +libcairo-gobject2==1.16.0-5 +libcairo-script-interpreter2==1.16.0-5 +libcairo2==1.16.0-5 +libcairo2-dev==1.16.0-5 +libcap-dev==1:2.44-1 +libcap-ng-dev==0.7.9-2.2+b1 +libcap2==1:2.44-1 +libcap2-bin==1:2.44-1 +libcapstone4==4.0.2-3 +libcapture-tiny-perl==0.48-1 +libcarp-clan-perl==6.08-1 +libcbor0==0.5.0+dfsg-2 +libcc1-0==10.2.1-6 +libcdi-api-java==1.2-3 +libcdparanoia0==3.10.2+debian-13.1 +libcdt5==2.42.2-5 +libcgraph6==2.42.2-5 +libchromaprint1==1.5.0-2 +libcjson-dev==1.7.14-1 +libcjson1==1.7.14-1 +libclang-common-11-dev==1:11.0.1-2 +libclang-cpp11==1:11.0.1-2 +libclang1-11==1:11.0.1-2 +libclass-accessor-perl==0.51-1 +libclass-c3-perl==0.35-1 +libclass-c3-xs-perl==0.15-1+b1 +libclass-data-inheritable-perl==0.08-3 +libclass-inspector-perl==1.36-1 +libclass-load-perl==0.25-1 +libclass-load-xs-perl==0.10-1+b5 +libclass-method-modifiers-perl==2.13-1 +libclass-tiny-perl==1.008-1 +libclass-xsaccessor-perl==1.19-3+b7 +libclone-perl==0.45-1+b1 +libcmocka-dev==1.1.5-2 +libcmocka0==1.1.5-2 +libcodec2-0.9==0.9.2-4 +libcolord2==1.4.5-3 +libcommon-sense-perl==3.75-1+b4 +libcommons-beanutils-java==1.9.4-1 +libcommons-cli-java==1.4-2 +libcommons-codec-java==1.15-1 +libcommons-collections3-java==3.2.2-2 +libcommons-compress-java==1.20-1 +libcommons-configuration-java==1.10-5 +libcommons-digester-java==1.8.1-5 +libcommons-io-java==2.8.0-1 +libcommons-lang-java==2.6-9 +libcommons-lang3-java==3.11-1 +libcommons-logging-java==1.2-2 +libcommons-parent-java==43-1 +libcommons-validator-java==1:1.6-2 +libconfig-tiny-perl==2.26-1 +libconst-fast-perl==0.014-1.1 +libcontextual-return-perl==0.004014-2 +libconvert-binhex-perl==1.125-1 +libcpanel-json-xs-perl==4.25-1+b1 +libcrypt-dev==1:4.4.18-4 +libcryptsetup12==2:2.3.7-1+deb11u1 +libctf-nobfd0==2.35.2-2 +libctf0==2.35.2-2 +libcunit1==2.1-3-dfsg-2.3 +libcunit1-dev==2.1-3-dfsg-2.3 +libcups2==2.3.3op2-3+deb11u2 +libcurl3-gnutls==7.74.0-1.3+deb11u7 +libcurl3-nss==7.74.0-1.3+deb11u7 +libcurl4==7.74.0-1.3+deb11u7 +libcurl4-nss-dev==7.74.0-1.3+deb11u7 +libdaemon-dev==0.14-7.1 +libdaemon0==0.14-7.1 +libdata-dpath-perl==0.58-1 +libdata-dump-perl==1.23-1.1 +libdata-messagepack-perl==1.00-4+b1 +libdata-optlist-perl==0.110-1.1 +libdata-validate-domain-perl==0.10-1.1 +libdatrie-dev==0.2.13-1 +libdatrie1==0.2.13-1 +libdav1d4==0.7.1-3 +libdaxctl1==71.1-1 +libdb-dev==5.3.1+nmu1 +libdb5.3-dev==5.3.28+dfsg1-0.8 +libdbi1==0.9.0-6 +libdbus-1-3==1.12.24-0+deb11u1 +libdbus-1-dev==1.12.24-0+deb11u1 +libdbus-glib-1-2==0.110-6 +libdbus-glib-1-dev==0.110-6 +libdbus-glib-1-dev-bin==0.110-6 +libdconf1==0.38.0-2 +libde265-0==1.0.11-0+deb11u1 +libdebhelper-perl==13.3.4 +libdebuginfod1==0.183-1 +libdeflate0==1.7-1 +libdevel-callchecker-perl==0.008-1+b2 +libdevel-caller-perl==2.06-2+b3 +libdevel-globaldestruction-perl==0.14-1.1 +libdevel-lexalias-perl==0.05-2+b3 +libdevel-overloadinfo-perl==0.005-1 +libdevel-partialdump-perl==0.20-1 +libdevel-size-perl==0.83-1+b2 +libdevel-stacktrace-perl==2.0400-1 +libdevmapper-event1.02.1==2:1.02.175-2.1 +libdevmapper1.02.1==2:1.02.175-2.1 +libdist-checkconflicts-perl==0.11-1.1 +libdistro-info-perl==1.0 +libdjvulibre-text==3.5.28-2 +libdjvulibre21==3.5.28-2 +libdns-export1110==1:9.11.19+dfsg-2.1 +libdom4j-java==2.1.3-1 +libdouble-conversion3==3.1.5-6.1 +libdoxia-core-java==1.7-2 +libdoxia-java==1.7-2 +libdoxia-sitetools-java==1.7.5-2 +libdpkg-perl==1.20.12 +libdrm-amdgpu1==2.4.104-1 +libdrm-common==2.4.104-1 +libdrm-intel1==2.4.104-1 +libdrm-nouveau2==2.4.104-1 +libdrm-radeon1==2.4.104-1 +libdrm2==2.4.104-1 +libdv4==1.0.0-13 +libdw-dev==0.183-1 +libdw1==0.183-1 +libdynaloader-functions-perl==0.003-1.1 +libeatmydata1==105-9 +libedit-dev==3.1-20191231-2+b1 +libedit2==3.1-20191231-2+b1 +libegl-dev==1.3.2-1 +libegl-mesa0==20.3.5-1 +libegl1==1.3.2-1 +libegl1-mesa-dev==20.3.5-1 +libel-api-java==3.0.0-3 +libelf-dev==0.183-1 +libelf1==0.183-1 +libemail-address-xs-perl==1.04-1+b3 +libencode-locale-perl==1.05-1.1 +libepoxy-dev==1.5.5-1 +libepoxy0==1.5.5-1 +liberror-perl==0.17029-1 +libestr0==0.1.10-2.1+b1 +libeval-closure-perl==0.14-1 +libevdev2==1.11.0+dfsg-1 +libevent-2.1-7==2.1.12-stable-1 +libevent-core-2.1-7==2.1.12-stable-1 +libevent-dev==2.1.12-stable-1 +libevent-extra-2.1-7==2.1.12-stable-1 +libevent-openssl-2.1-7==2.1.12-stable-1 +libevent-pthreads-2.1-7==2.1.12-stable-1 +libexception-class-perl==1.44-1 +libexecs0==1.3-1 +libexpat1==2.2.10-2+deb11u5 +libexpat1-dev==2.2.10-2+deb11u5 +libexplain-dev==1.4.D001-11 +libexplain51==1.4.D001-11 +libexporter-tiny-perl==1.002002-1 +libfabric1==1.11.0-2 +libfakeroot==1.25.3-1.1 +libfastjson4==0.99.9-1 +libfcgi-bin==2.4.2-2 +libfcgi-perl==0.79+ds-2 +libfcgi0ldbl==2.4.2-2 +libfdt1==1.6.0-1 +libffi-dev==3.3-6 +libfftw3-double3==3.3.8-2 +libfido2-1==1.6.0-2 +libfido2-dev==1.6.0-2 +libfile-basedir-perl==0.08-1 +libfile-chdir-perl==0.1008-1.1 +libfile-copy-recursive-perl==0.45-1 +libfile-desktopentry-perl==0.22-2 +libfile-dirlist-perl==0.05-2 +libfile-fcntllock-perl==0.22-3+b7 +libfile-find-rule-perl==0.34-1 +libfile-homedir-perl==1.006-1 +libfile-listing-perl==6.14-1 +libfile-mimeinfo-perl==0.30-1 +libfile-slurp-perl==9999.32-1 +libfile-stripnondeterminism-perl==1.12.0-1 +libfile-touch-perl==0.11-1 +libfile-which-perl==1.23-1 +libfl-dev==2.6.4-8 +libfl2==2.6.4-8 +libflac8==1.3.3-2+deb11u1 +libflite1==2.2-2 +libfont-afm-perl==1.20-3 +libfont-ttf-perl==1.06-1.1 +libfontbox-java==1:1.8.16-2 +libfontbox2-java==2.0.23-1 +libfontconfig-dev==2.13.1-4.2 +libfontconfig1==2.13.1-4.2 +libfontconfig1-dev==2.13.1-4.2 +libfontenc1==1:1.1.4-1 +libfop-java==1:2.5-3 +libfreetype-dev==2.10.4+dfsg-1+deb11u1 +libfreetype6==2.10.4+dfsg-1+deb11u1 +libfreetype6-dev==2.10.4+dfsg-1+deb11u1 +libfribidi-dev==1.0.8-2+deb11u1 +libfribidi0==1.0.8-2+deb11u1 +libfstrm0==0.6.0-1+b1 +libgbm1==20.3.5-1 +libgc1==1:8.0.4-3 +libgcc-10-dev==10.2.1-6 +libgd-perl==2.73-1+b1 +libgd3==2.3.0-2 +libgdbm-compat4==1.19-2 +libgdbm6==1.19-2 +libgdk-pixbuf-2.0-0==2.42.2+dfsg-1+deb11u1 +libgdk-pixbuf-2.0-dev==2.42.2+dfsg-1+deb11u1 +libgdk-pixbuf2.0-bin==2.42.2+dfsg-1+deb11u1 +libgdk-pixbuf2.0-common==2.42.2+dfsg-1+deb11u1 +libgeronimo-annotation-1.3-spec-java==1.3-1 +libgeronimo-interceptor-3.0-spec-java==1.0.1-4 +libgetopt-long-descriptive-perl==0.105-1 +libgfortran5==10.2.1-6 +libgif7==5.1.9-2 +libgirepository-1.0-1==1.66.1-1+b1 +libgirepository1.0-dev==1.66.1-1+b1 +libgit-wrapper-perl==0.048-1 +libgitlab-api-v4-perl==0.26-1 +libgl-dev==1.3.2-1 +libgl1==1.3.2-1 +libgl1-mesa-dri==20.3.5-1 +libglapi-mesa==20.3.5-1 +libgles-dev==1.3.2-1 +libgles1==1.3.2-1 +libgles2==1.3.2-1 +libglib2.0-0==2.66.8-1 +libglib2.0-bin==2.66.8-1 +libglib2.0-data==2.66.8-1 +libglib2.0-dev==2.66.8-1 +libglib2.0-dev-bin==2.66.8-1 +libglu1-mesa==9.0.1-1 +libglu1-mesa-dev==9.0.1-1 +libglvnd-dev==1.3.2-1 +libglvnd0==1.3.2-1 +libglx-dev==1.3.2-1 +libglx-mesa0==20.3.5-1 +libglx0==1.3.2-1 +libgme0==0.6.3-2 +libgmock-dev==1.10.0.20201025-1.1 +libgmp-dev==2:6.2.1+dfsg-1+deb11u1 +libgmpxx4ldbl==2:6.2.1+dfsg-1+deb11u1 +libgnutls-dane0==3.7.1-5+deb11u3 +libgomp1==10.2.1-6 +libgoogle-perftools4==2.8.1-1 +libgpgme11==1.14.0-1+b2 +libgpm2==1.20.7-8 +libgraphite2-3==1.3.14-1 +libgraphite2-dev==1.3.14-1 +libgrpc++1==1.30.2-3 +libgrpc10==1.30.2-3 +libgs9==9.53.3~dfsg-7+deb11u4 +libgs9-common==9.53.3~dfsg-7+deb11u4 +libgsasl7==1.10.0-4+deb11u1 +libgsm1==1.0.18-2 +libgssrpc4==1.18.3-6+deb11u3 +libgstreamer-plugins-base1.0-0==1.18.4-2 +libgstreamer1.0-0==1.18.4-2.1 +libgtest-dev==1.10.0.20201025-1.1 +libgtk-3-0==3.24.24-4+deb11u2 +libgtk-3-bin==3.24.24-4+deb11u2 +libgtk-3-common==3.24.24-4+deb11u2 +libgtk-3-dev==3.24.24-4+deb11u2 +libgts-0.7-5==0.7.6+darcs121130-4+b1 +libgts-bin==0.7.6+darcs121130-4+b1 +libguava-java==29.0-6 +libgudev-1.0-0==234-1 +libguice-java==4.2.3-2 +libgvc6==2.42.2-5 +libgvpr2==2.42.2-5 +libharfbuzz-dev==2.7.4-1 +libharfbuzz-gobject0==2.7.4-1 +libharfbuzz-icu0==2.7.4-1 +libharfbuzz0b==2.7.4-1 +libhash-fieldhash-perl==0.15-1+b3 +libhawtjni-runtime-java==1.17-1 +libheif1==1.11.0-1 +libhtml-form-perl==6.07-1 +libhtml-format-perl==2.12-1.1 +libhtml-html5-entities-perl==0.004-1.1 +libhtml-parser-perl==3.75-1+b1 +libhtml-tagset-perl==3.20-4 +libhtml-tree-perl==5.07-2 +libhttp-cookies-perl==6.10-1 +libhttp-daemon-perl==6.12-1+deb11u1 +libhttp-date-perl==6.05-1 +libhttp-message-perl==6.28-1 +libhttp-negotiate-perl==6.01-1 +libhttp-tiny-multipart-perl==0.08-1.1 +libhttpclient-java==4.5.13-2 +libhttpcore-java==4.4.14-1 +libhwloc-plugins==2.4.1+dfsg-1 +libhwloc15==2.4.1+dfsg-1 +libiberty-dev==20210106-1 +libibverbs1==33.2-1 +libice-dev==2:1.0.10-1 +libice6==2:1.0.10-1 +libicu-dev==67.1-7 +libicu67==67.1-7 +libidn11==1.33-3 +libiec61883-0==1.2.0-4 +libigdgmm11==20.4.1+ds1-1 +libijs-0.35==0.35-15 +libilmbase25==2.5.4-1 +libimagequant0==2.12.2-1.1 +libimport-into-perl==1.002005-1 +libinput-bin==1.16.4-3 +libinput10==1.16.4-3 +libio-html-perl==1.004-2 +libio-prompter-perl==0.004015-1 +libio-pty-perl==1:1.15-2 +libio-sessiondata-perl==1.03-1.1 +libio-socket-ssl-perl==2.069-1 +libio-string-perl==1.08-3.1 +libio-stringy-perl==2.111-3 +libip4tc-dev==1.8.7-1 +libip4tc2==1.8.7-1 +libip6tc-dev==1.8.7-1 +libip6tc2==1.8.7-1 +libipc-run-perl==20200505.0-1 +libipc-run3-perl==0.048-2 +libipc-system-simple-perl==1.30-1 +libipt2==2.0.3-1 +libiptc-dev==1.8.7-1 +libirs-export161==1:9.11.19+dfsg-2.1 +libisc-export1105==1:9.11.19+dfsg-2.1 +libisccc-export161==1:9.11.19+dfsg-2.1 +libisccfg-export163==1:9.11.19+dfsg-2.1 +libisl23==0.23-1 +libiterator-perl==0.03+ds1-1.1 +libiterator-util-perl==0.02+ds1-1.1 +libitext1-java==1.4-7 +libitm1==10.2.1-6 +libjack-jackd2-0==1.9.17~dfsg-1 +libjansi-java==1.18-1 +libjansi-native-java==1.8-1 +libjansson-dev==2.13.1-1.1 +libjansson4==2.13.1-1.1 +libjaxen-java==1.1.6-4 +libjaxp1.3-java==1.3.05-6 +libjbig0==2.1-3.1+b2 +libjbig2dec0==0.19-2 +libjemalloc-dev==5.2.1-3 +libjemalloc2==5.2.1-3 +libjetty9-java==9.4.39-3+deb11u1 +libjpeg62-turbo==1:2.0.6-4 +libjq1==1.6-2.1 +libjs-bootstrap4==4.5.2+dfsg1-8~deb11u1 +libjs-d3==3.5.17-4 +libjs-jquery==3.5.1+dfsg+~3.5.5-7 +libjs-jquery-hotkeys==0~20130707+git2d51e3a9+dfsg-2.1 +libjs-jquery-isonscreen==1.2.0-1.1 +libjs-jquery-metadata==12-3 +libjs-jquery-tablesorter==1:2.31.3+dfsg1-1 +libjs-jquery-throttle-debounce==1.1+dfsg.1-1.1 +libjs-popper.js==1.16.1+ds-3 +libjs-sizzle==2.3.5+ds-2 +libjs-sphinxdoc==3.4.3-2 +libjs-underscore==1.9.1~dfsg-3 +libjson-c-dev==0.15-2 +libjson-c5==0.15-2 +libjson-glib-1.0-0==1.6.2-1 +libjson-glib-1.0-common==1.6.2-1 +libjson-maybexs-perl==1.004003-1 +libjson-perl==4.03000-1 +libjson-xs-perl==4.030-1+b1 +libjsoncpp24==1.9.4-4 +libjsp-api-java==2.3.4-3 +libjsr305-java==0.1~+svn49-11 +libjtidy-java==7+svn20110807-5 +libjudy-dev==1.0.5-5+b2 +libjudydebian1==1.0.5-5+b2 +libjxr-tools==1.1-6+b1 +libjxr0==1.1-6+b1 +libkadm5clnt-mit12==1.18.3-6+deb11u3 +libkadm5srv-mit12==1.18.3-6+deb11u3 +libkdb5-10==1.18.3-6+deb11u3 +libkmod2==28-1 +libkpathsea6==2020.20200327.54578-7 +libkrb5-dev==1.18.3-6+deb11u3 +libksba8==1.5.0-3+deb11u2 +liblab-gamut1==2.42.2-5 +liblapack3==3.9.0-3 +liblcms2-2==2.12~rc1-2 +libldap-2.4-2==2.4.57+dfsg-3+deb11u1 +libldap-common==2.4.57+dfsg-3+deb11u1 +libldap2-dev==2.4.57+dfsg-3+deb11u1 +liblilv-0-0==0.24.12-2 +liblist-compare-perl==0.55-1 +liblist-moreutils-perl==0.430-2 +liblist-moreutils-xs-perl==0.430-2 +liblist-someutils-perl==0.58-1 +liblist-someutils-xs-perl==0.58-2+b1 +liblist-utilsby-perl==0.11-1 +libllvm11==1:11.0.1-2 +liblmdb0==0.9.24-1 +liblocale-gettext-perl==1.07-4+b1 +liblog-any-adapter-screen-perl==0.140-1 +liblog-any-perl==1.709-1 +liblog4j1.2-java==1.2.17-10+deb11u1 +liblognorm5==2.0.5-1.1 +liblqr-1-0==0.4.2-2.1 +liblsan0==10.2.1-6 +libltdl-dev==2.4.6-15 +libltdl7==2.4.6-15 +liblua5.1-0==5.1.5-8.1+b3 +liblua5.1-0-dev==5.1.5-8.1+b3 +liblua5.3-0==5.3.3-1.1+b1 +liblvm2cmd2.03==2.03.11-2.1 +liblwp-mediatypes-perl==6.04-1 +liblwp-protocol-https-perl==6.10-1 +liblzma-dev==5.2.5-2.1~deb11u1 +liblzo2-2==2.10-2 +liblzo2-dev==2.10-2 +libmagic-mgc==1:5.39-3 +libmagic1==1:5.39-3 +libmagickcore-6.q16-6==8:6.9.11.60+dfsg-1.3+deb11u1 +libmagickcore-6.q16-6-extra==8:6.9.11.60+dfsg-1.3+deb11u1 +libmagickwand-6.q16-6==8:6.9.11.60+dfsg-1.3+deb11u1 +libmail-sendmail-perl==0.80-1.1 +libmailtools-perl==2.21-1 +libmailutils7==1:3.10-3+b1 +libmariadb-dev==1:10.5.18-0+deb11u1 +libmariadb-dev-compat==1:10.5.18-0+deb11u1 +libmariadb3==1:10.5.18-0+deb11u1 +libmarkdown2==2.2.6-1 +libmaven-archiver-java==3.2.0-2.1 +libmaven-clean-plugin-java==3.1.0-1 +libmaven-common-artifact-filters-java==3.1.1-1 +libmaven-compiler-plugin-java==3.8.1-4 +libmaven-file-management-java==3.0.0-1 +libmaven-filtering-java==3.1.1-1 +libmaven-jar-plugin-java==3.1.2-1 +libmaven-parent-java==31-2 +libmaven-plugin-tools-java==3.6.0-1 +libmaven-reporting-api-java==3.0-1.1 +libmaven-reporting-exec-java==1.4-3 +libmaven-reporting-impl-java==3.0.0-2 +libmaven-resolver-java==1.4.2-3 +libmaven-resources-plugin-java==3.1.0-1 +libmaven-shared-incremental-java==1.1-3 +libmaven-shared-io-java==3.0.0-3 +libmaven-shared-utils-java==3.3.0-1+deb11u1 +libmaven-site-plugin-java==3.6-4 +libmaven3-core-java==3.6.3-5 +libmaxminddb0==1.5.2-1 +libmd-dev==1.0.3-3 +libmd0==1.0.3-3 +libmd4c0==0.4.7-2 +libmfx1==21.1.0-1 +libmime-tools-perl==5.509-1 +libmnl-dev==1.0.4-3 +libmnl0==1.0.4-3 +libmodule-implementation-perl==0.09-1.1 +libmodule-runtime-conflicts-perl==0.003-1.1 +libmodule-runtime-perl==0.016-1 +libmoo-perl==2.004004-1 +libmoose-perl==2.2014-2 +libmoosex-aliases-perl==0.11-1.1 +libmoox-aliases-perl==0.001006-1.1 +libmoox-struct-perl==0.020-1 +libmount-dev==2.36.1-8+deb11u1 +libmouse-perl==2.5.10-1+b1 +libmp3lame0==3.100-3 +libmpc3==1.2.0-1 +libmpdec3==2.5.1-1 +libmpfr6==4.1.0-3 +libmpg123-0==1.26.4-1 +libmro-compat-perl==0.13-1 +libmtdev1==1.1.6-1 +libmysofa1==1.2~dfsg0-1 +libnamespace-autoclean-perl==0.29-1 +libnamespace-clean-perl==0.27-1 +libnanomsg-dev==1.1.5+dfsg-1+b2 +libnanomsg5==1.1.5+dfsg-1+b2 +libncurses-dev==6.2+20201114-2 +libncurses5-dev==6.2+20201114-2 +libncurses6==6.2+20201114-2 +libncursesw6==6.2+20201114-2 +libndctl6==71.1-1 +libnet-dbus-perl==1.2.0-1+b1 +libnet-domain-tld-perl==1.75-1.1 +libnet-http-perl==6.20-1 +libnet-smtp-ssl-perl==1.04-1 +libnet-ssleay-perl==1.88-3+b1 +libnetfilter-conntrack-dev==1.0.8-3 +libnetfilter-conntrack3==1.0.8-3 +libnetpbm10==2:10.0-15.4 +libnetsnmptrapd40==5.9+dfsg-4+deb11u1 +libnewt-dev==0.52.21-4+b3 +libnewt0.52==0.52.21-4+b3 +libnfnetlink-dev==1.0.1-3+b1 +libnfnetlink0==1.0.1-3+b1 +libnftables1==0.9.8-3.1+deb11u1 +libnftnl-dev==1.1.9-1 +libnftnl11==1.1.9-1 +libnghttp2-14==1.43.0-1 +libnl-3-200==3.4.0-1+b1 +libnl-route-3-200==3.4.0-1+b1 +libnorm-dev==1.5.9+dfsg-2 +libnorm1==1.5.9+dfsg-2 +libnpth0==1.6-3 +libnsl-dev==1.3.0-2 +libnspr4==2:4.29-1 +libnss-systemd==247.3-7+deb11u1 +libnss3==2:3.61-1+deb11u3 +libntlm0==1.6-3 +libnuma-dev==2.0.12-1+b1 +libnuma1==2.0.12-1+b1 +libnumber-compare-perl==0.03-1.1 +libnumber-range-perl==0.12-1.1 +libobjc-10-dev==10.2.1-6 +libobjc4==10.2.1-6 +libobject-id-perl==0.1.2-2.1 +libogg0==1.3.4-0.1 +libomp-11-dev==1:11.0.1-2 +libomp5-11==1:11.0.1-2 +libonig5==6.9.6-1.1 +libopencsd-dev==0.14.4-1 +libopencsd0==0.14.4-1 +libopenexr25==2.5.4-2+deb11u1 +libopengl-dev==1.3.2-1 +libopengl0==1.3.2-1 +libopenjp2-7==2.4.0-3 +libopenmpi3==4.1.0-10 +libopenmpt0==0.4.11-1 +libopentest4j-java==1.2.0-2 +libopts25==1:5.18.16-4 +libopts25-dev==1:5.18.16-4 +libopus0==1.3.1-0.1 +liborc-0.4-0==1:0.4.32-1 +liboro-java==2.0.8a-14 +libosp5==1.5.2-13+b2 +libossp-uuid-perl==1.6.2-1.5+b9 +libossp-uuid16==1.6.2-1.5+b9 +libostyle1c2==1.4devel1-22 +libpackage-deprecationmanager-perl==0.17-1.1 +libpackage-stash-perl==0.39-1 +libpackage-stash-xs-perl==0.29-1+b2 +libpackagekit-glib2-18==1.2.2-2 +libpadwalker-perl==2.5-1+b1 +libpam-cap==1:2.44-1 +libpam-systemd==247.3-7+deb11u1 +libpam0g-dev==1.4.0-9+deb11u1 +libpango-1.0-0==1.46.2-3 +libpango1.0-dev==1.46.2-3 +libpangocairo-1.0-0==1.46.2-3 +libpangoft2-1.0-0==1.46.2-3 +libpangoxft-1.0-0==1.46.2-3 +libpaper-utils==1.1.28+b1 +libpaper1==1.1.28+b1 +libparams-classify-perl==0.015-1+b3 +libparams-util-perl==1.102-1+b1 +libparams-validate-perl==1.30-1+b1 +libparboiled-java==1.1.7-2.1 +libpath-iterator-rule-perl==1.014-1 +libpath-tiny-perl==0.118-1 +libpathplan4==2.42.2-5 +libpcap-dev==1.10.0-2 +libpcap0.8==1.10.0-2 +libpcap0.8-dev==1.10.0-2 +libpci-dev==1:3.7.0-5 +libpci3==1:3.7.0-5 +libpciaccess0==0.16-1 +libpcre16-3==2:8.39-13 +libpcre2-16-0==10.36-2+deb11u1 +libpcre2-32-0==10.36-2+deb11u1 +libpcre2-dev==10.36-2+deb11u1 +libpcre2-posix2==10.36-2+deb11u1 +libpcre3-dev==2:8.39-13 +libpcre32-3==2:8.39-13 +libpcrecpp0v5==2:8.39-13 +libpcsclite-dev==1.9.1-1 +libpcsclite1==1.9.1-1 +libpdfbox-java==1:1.8.16-2 +libpegdown-java==1.6.0-1.1 +libperl-dev==5.32.1-4+deb11u2 +libperl5.32==5.32.1-4+deb11u2 +libperlio-gzip-perl==0.19-1+b7 +libpfm4==4.11.1+git32-gd0b85fb-1 +libpgm-5.3-0==5.3.128~dfsg-2 +libpgm-dev==5.3.128~dfsg-2 +libpipeline1==1.5.3-1 +libpixman-1-0==0.40.0-1.1~deb11u1 +libpixman-1-dev==0.40.0-1.1~deb11u1 +libplexus-ant-factory-java==1.0~alpha2.1-4 +libplexus-archiver-java==3.6.0-2 +libplexus-bsh-factory-java==1.0~alpha7-4.1 +libplexus-build-api-java==0.0.7-4 +libplexus-cipher-java==1.8-2 +libplexus-classworlds-java==2.6.0-1 +libplexus-compiler-java==2.8.8-2 +libplexus-component-annotations-java==2.1.0-1 +libplexus-container-default-java==2.1.0-1 +libplexus-container-default1.5-java==2.1.0-1 +libplexus-i18n-java==1.0-beta-10-5 +libplexus-interpolation-java==1.26-1 +libplexus-io-java==3.2.0-1.1 +libplexus-languages-java==0.9.10-2 +libplexus-sec-dispatcher-java==1.4-4 +libplexus-utils2-java==3.3.0-1 +libplexus-velocity-java==1.2-3.1 +libpmem1==1.10-2+deb11u1 +libpmix2==4.0.0-4.1 +libpng-dev==1.6.37-3 +libpng-tools==1.6.37-3 +libpng16-16==1.6.37-3 +libpocketsphinx3==0.8+5prealpha+1-13 +libpod-constants-perl==0.19-2 +libpod-parser-perl==1.63-2 +libpolkit-agent-1-0==0.105-31+deb11u1 +libpolkit-gobject-1-0==0.105-31+deb11u1 +libpopt0==1.18-2 +libpostproc55==7:4.3.5-0+deb11u1 +libproc-processtable-perl==0.59-2+b1 +libprocps8==2:3.3.17-5 +libprotobuf-c1==1.3.3-1+b2 +libprotobuf-dev==3.12.4-1 +libprotobuf-lite23==3.12.4-1 +libprotobuf23==3.12.4-1 +libprotoc23==3.12.4-1 +libproxy1v5==0.4.17-1 +libpsl5==0.21.0-1.2 +libpsm-infinipath1==3.3+20.604758e7-6.1 +libpsm2-2==11.2.185-1 +libptexenc1==2020.20200327.54578-7 +libpthread-stubs0-dev==0.4-1 +libpulse0==14.2-2 +libpython2-dev==2.7.18-3 +libpython2-stdlib==2.7.18-3 +libpython2.7==2.7.18-8 +libpython2.7-dev==2.7.18-8 +libpython2.7-minimal==2.7.18-8 +libpython2.7-stdlib==2.7.18-8 +libpython3-all-dbg==3.9.2-3 +libpython3-all-dev==3.9.2-3 +libpython3-dbg==3.9.2-3 +libpython3-dev==3.9.2-3 +libpython3-stdlib==3.9.2-3 +libpython3.9==3.9.2-1 +libpython3.9-dbg==3.9.2-1 +libpython3.9-dev==3.9.2-1 +libpython3.9-minimal==3.9.2-1 +libpython3.9-stdlib==3.9.2-1 +libqdox-java==1.12.1-3 +libqdox2-java==2.0.0-1 +libqt5concurrent5==5.15.2+dfsg-9 +libqt5core5a==5.15.2+dfsg-9 +libqt5dbus5==5.15.2+dfsg-9 +libqt5gui5==5.15.2+dfsg-9 +libqt5network5==5.15.2+dfsg-9 +libqt5opengl5==5.15.2+dfsg-9 +libqt5opengl5-dev==5.15.2+dfsg-9 +libqt5printsupport5==5.15.2+dfsg-9 +libqt5sql5==5.15.2+dfsg-9 +libqt5sql5-sqlite==5.15.2+dfsg-9 +libqt5svg5==5.15.2-3 +libqt5test5==5.15.2+dfsg-9 +libqt5widgets5==5.15.2+dfsg-9 +libqt5xml5==5.15.2+dfsg-9 +libquadmath0==10.2.1-6 +librabbitmq4==0.10.0-1 +libraw1394-11==2.1.2-2 +librdmacm1==33.2-1 +libre-engine-re2-perl==0.14-1 +libre2-9==20210201+dfsg-1 +libreadline-dev==8.1-1 +libreadline8==8.1-1 +libreadonly-perl==2.050-3 +libref-util-perl==0.204-1 +libref-util-xs-perl==0.117-1+b3 +libregexp-assemble-perl==0.36-1.1 +libregexp-pattern-license-perl==3.4.0-1 +libregexp-pattern-perl==0.2.14-1 +librest-0.7-0==0.8.1-1.1 +librhash0==1.4.1-2 +librole-tiny-perl==2.002004-1 +librrd-dev==1.7.2-3+b7 +librrd8==1.7.2-3+b7 +librsvg2-2==2.50.3+dfsg-1 +librsvg2-common==2.50.3+dfsg-1 +librtmp1==2.4+20151223.gitfa8646d.1-2+b2 +librubberband2==1.9.0-1 +libruby2.7==2.7.4-1+deb11u1 +libsamplerate0==0.2.1+ds0-1 +libsasl2-2==2.1.27+dfsg-2.1+deb11u1 +libsasl2-modules==2.1.27+dfsg-2.1+deb11u1 +libsasl2-modules-db==2.1.27+dfsg-2.1+deb11u1 +libsaxon-java==1:6.5.5-12 +libselinux1-dev==3.1-3 +libsensors-config==1:3.6.0-7 +libsensors-dev==1:3.6.0-7 +libsensors4-dev==1:3.6.0-7 +libsensors5==1:3.6.0-7 +libsepol1-dev==3.1-1 +libserd-0-0==0.30.10-2 +libsereal-decoder-perl==4.018+ds-1+b1 +libsereal-encoder-perl==4.018+ds-1+b1 +libservlet-api-java==4.0.1-2 +libservlet3.1-java==1:4.0.1-2 +libsgmls-perl==1.03ii-36 +libshine3==3.1.1-2 +libshout3==2.4.5-1+b1 +libsigsegv2==2.13-1 +libsisu-inject-java==0.3.4-2 +libsisu-plexus-java==0.3.4-3 +libslang2==2.3.2-5 +libslang2-dev==2.3.2-5 +libslf4j-java==1.7.30-1 +libslirp0==4.4.0-1+deb11u2 +libsm-dev==2:1.2.3-1 +libsm6==2:1.2.3-1 +libsnappy-java==1.1.8.3-1 +libsnappy-jni==1.1.8.3-1 +libsnappy1v5==1.1.8-1 +libsndfile1==1.0.31-2 +libsnmp-base==5.9+dfsg-4+deb11u1 +libsnmp-dev==5.9+dfsg-4+deb11u1 +libsnmp40==5.9+dfsg-4+deb11u1 +libsoap-lite-perl==1.27-1 +libsodium-dev==1.0.18-1 +libsodium23==1.0.18-1 +libsord-0-0==0.16.8-2 +libsort-key-perl==1.33-2+b3 +libsort-versions-perl==1.62-1 +libsoup-gnome2.4-1==2.72.0-2 +libsoup2.4-1==2.72.0-2 +libsource-highlight-common==3.1.9-3 +libsource-highlight4v5==3.1.9-3+b1 +libsoxr0==0.1.3-4 +libspeex1==1.2~rc1.2-1.1 +libsphinxbase3==0.8+5prealpha+1-12 +libspice-server1==0.14.3-2.1 +libsqlite3-0==3.34.1-3 +libsratom-0-0==0.6.8-1 +libsrt1.4-gnutls==1.4.2-1.3 +libssh-gcrypt-4==0.9.5-1+deb11u1 +libssh2-1==1.9.0-2 +libssl-dev==1.1.1n-0+deb11u4 +libstdc++-10-dev==10.2.1-6 +libstemmer0d==2.1.0-1 +libstrictures-perl==2.000006-1 +libstring-copyright-perl==0.003006-1 +libstring-escape-perl==2010.002-2 +libstring-shellquote-perl==1.04-1 +libsub-exporter-perl==0.987-1 +libsub-exporter-progressive-perl==0.001013-1 +libsub-identify-perl==0.14-1+b3 +libsub-install-perl==0.928-1.1 +libsub-name-perl==0.26-1+b1 +libsub-override-perl==0.09-2 +libsub-quote-perl==2.006006-1 +libsubunit-dev==1.4.0-3 +libsubunit0==1.4.0-3 +libsurefire-java==2.22.3-1 +libswitch-perl==2.17-2.1 +libswresample3==7:4.3.5-0+deb11u1 +libswscale5==7:4.3.5-0+deb11u1 +libsynctex2==2020.20200327.54578-7 +libsys-cpuaffinity-perl==1.13~03-1 +libsys-hostname-long-perl==1.5-2 +libsystemd-dev==247.3-7+deb11u1 +libtag1v5==1.11.1+dfsg.1-3 +libtag1v5-vanilla==1.11.1+dfsg.1-3 +libtask-weaken-perl==1.06-1 +libtcl8.6==8.6.11+dfsg-1 +libtcmalloc-minimal4==2.8.1-1 +libteckit0==2.5.10+ds1-3 +libtemplate-perl==2.27-1+b3 +libterm-readkey-perl==2.38-1+b2 +libtexlua53==2020.20200327.54578-7 +libtexluajit2==2020.20200327.54578-7 +libtext-charwidth-perl==0.04-10+b1 +libtext-glob-perl==0.11-1 +libtext-hogan-perl==2.03-1 +libtext-iconv-perl==1.7-7+b1 +libtext-levenshteinxs-perl==0.03-4+b8 +libtext-markdown-discount-perl==0.12-1+b1 +libtext-trim-perl==1.04-1 +libtext-unidecode-perl==1.30-1 +libtext-wrapi18n-perl==0.06-9 +libtext-xslate-perl==3.5.8-1+b1 +libthai-data==0.1.28-3 +libthai-dev==0.1.28-3 +libthai0==0.1.28-3 +libtheora0==1.1.1+dfsg.1-15 +libtie-ixhash-perl==1.23-2.1 +libtiff5==4.2.0-1+deb11u4 +libtime-duration-perl==1.21-1 +libtime-moment-perl==0.44-1+b3 +libtimedate-perl==2.3300-2 +libtinyxml2-8==8.0.0+dfsg-2 +libtinyxml2-dev==8.0.0+dfsg-2 +libtirpc-dev==1.3.1-1+deb11u1 +libtk8.6==8.6.11-2 +libtool==2.4.6-15 +libtool-bin==2.4.6-15 +libtry-tiny-perl==0.30-1 +libtsan0==10.2.1-6 +libtwolame0==0.4.0-2 +libtype-tiny-perl==1.012001-2 +libtype-tiny-xs-perl==0.022-1 +libtypes-serialiser-perl==1.01-1 +libubsan1==10.2.1-6 +libuchardet0==0.0.7-1 +libucx0==1.10.1~rc1+really.1.10.0-1 +libudev-dev==247.3-7+deb11u1 +libudfread0==1.1.1-1 +libunbound8==1.13.1-1 +libunicode-utf8-perl==0.62-1+b2 +libunivocity-parsers-java==2.8.3-2 +libunwind-dev==1.3.2-2 +libunwind8==1.3.2-2 +liburi-perl==5.08-1 +liburing1==0.7-3 +libusb-0.1-4==2:0.1.12-32 +libusb-1.0-0==2:1.0.24-3 +libusb-1.0-0-dev==2:1.0.24-3 +libusb-1.0-doc==2:1.0.24-3 +libusb-dev==2:0.1.12-32 +libusbredirparser1==0.8.0-1+b1 +libuv1==1.40.0-2 +libv4l-0==1.20.0-2 +libv4lconvert0==1.20.0-2 +libva-drm2==2.10.0-1 +libva-x11-2==2.10.0-1 +libva2==2.10.0-1 +libvariable-magic-perl==0.62-1+b3 +libvdeplug2==4.0.1-2 +libvdpau-va-gl1==0.4.2-1+b1 +libvdpau1==1.4-3 +libvelocity-tools-java==2.0-8 +libvidstab1.1==1.1.0-2+b1 +libvirglrenderer1==0.8.2-5+deb11u1 +libvirt-clients==7.0.0-3 +libvirt0==7.0.0-3 +libvisual-0.4-0==0.4.0-17 +libvorbis0a==1.3.7-1 +libvorbisenc2==1.3.7-1 +libvorbisfile3==1.3.7-1 +libvpx6==1.9.0-1 +libvte-2.91-0==0.62.3-1 +libvte-2.91-common==0.62.3-1 +libvulkan-dev==1.2.162.0-1 +libvulkan1==1.2.162.0-1 +libwacom-bin==1.8-2 +libwacom-common==1.8-2 +libwacom2==1.8-2 +libwagon-file-java==3.3.4-1 +libwagon-http-shaded-java==3.3.4-1 +libwagon-provider-api-java==3.3.4-1 +libwant-perl==0.29-1+b6 +libwavpack1==5.4.0-1 +libwayland-bin==1.18.0-2~exp1.1 +libwayland-client0==1.18.0-2~exp1.1 +libwayland-cursor0==1.18.0-2~exp1.1 +libwayland-dev==1.18.0-2~exp1.1 +libwayland-egl1==1.18.0-2~exp1.1 +libwayland-server0==1.18.0-2~exp1.1 +libwebp6==0.6.1-2.1 +libwebpdemux2==0.6.1-2.1 +libwebpmux3==0.6.1-2.1 +libwebsocket-api-java==1.1-2 +libwmf0.2-7==0.2.8.4-17 +libwoff1==1.0.2-1+b1 +libwrap0==7.6.q-31 +libwrap0-dev==7.6.q-31 +libwww-perl==6.52-1 +libwww-robotrules-perl==6.02-1 +libx11-6==2:1.7.2-1 +libx11-data==2:1.7.2-1 +libx11-dev==2:1.7.2-1 +libx11-protocol-perl==0.56-7.1 +libx11-xcb1==2:1.7.2-1 +libx264-160==2:0.160.3011+gitcde9a93-2.1 +libx265-192==3.4-2 +libx32asan6==10.2.1-6 +libx32atomic1==10.2.1-6 +libx32gcc-10-dev==10.2.1-6 +libx32gcc-s1==10.2.1-6 +libx32gomp1==10.2.1-6 +libx32itm1==10.2.1-6 +libx32quadmath0==10.2.1-6 +libx32stdc++6==10.2.1-6 +libx32ubsan1==10.2.1-6 +libxalan2-java==2.7.2-4 +libxapian30==1.4.18-3 +libxau-dev==1:1.0.9-1 +libxau6==1:1.0.9-1 +libxaw7==2:1.0.13-1.1 +libxbean-reflect-java==4.5-8 +libxcb-dri2-0==1.14-3 +libxcb-dri3-0==1.14-3 +libxcb-glx0==1.14-3 +libxcb-icccm4==0.4.1-1.1 +libxcb-image0==0.4.0-1+b3 +libxcb-keysyms1==0.4.0-1+b2 +libxcb-present0==1.14-3 +libxcb-randr0==1.14-3 +libxcb-render-util0==0.3.9-1+b1 +libxcb-render0==1.14-3 +libxcb-render0-dev==1.14-3 +libxcb-shape0==1.14-3 +libxcb-shm0==1.14-3 +libxcb-shm0-dev==1.14-3 +libxcb-sync1==1.14-3 +libxcb-util1==0.4.0-1+b1 +libxcb-xfixes0==1.14-3 +libxcb-xinerama0==1.14-3 +libxcb-xinput0==1.14-3 +libxcb-xkb1==1.14-3 +libxcb1==1.14-3 +libxcb1-dev==1.14-3 +libxcomposite-dev==1:0.4.5-1 +libxcomposite1==1:0.4.5-1 +libxcursor-dev==1:1.2.0-2 +libxcursor1==1:1.2.0-2 +libxdamage-dev==1:1.1.5-2 +libxdamage1==1:1.1.5-2 +libxdelta2==1.1.3-9.3 +libxdmcp-dev==1:1.1.2-3 +libxdmcp6==1:1.1.2-3 +libxencall1==4.14.5+94-ge49571868d-1 +libxendevicemodel1==4.14.5+94-ge49571868d-1 +libxenevtchn1==4.14.5+94-ge49571868d-1 +libxenforeignmemory1==4.14.5+94-ge49571868d-1 +libxengnttab1==4.14.5+94-ge49571868d-1 +libxenhypfs1==4.14.5+94-ge49571868d-1 +libxenmisc4.14==4.14.5+94-ge49571868d-1 +libxenstore3.0==4.14.5+94-ge49571868d-1 +libxentoolcore1==4.14.5+94-ge49571868d-1 +libxentoollog1==4.14.5+94-ge49571868d-1 +libxerces2-java==2.12.1-1 +libxext-dev==2:1.3.3-1.1 +libxext6==2:1.3.3-1.1 +libxfixes-dev==1:5.0.3-2 +libxfixes3==1:5.0.3-2 +libxft-dev==2.3.2-2 +libxft2==2.3.2-2 +libxi-dev==2:1.7.10-1 +libxi6==2:1.7.10-1 +libxinerama-dev==2:1.1.4-2 +libxinerama1==2:1.1.4-2 +libxkbcommon-dev==1.0.3-2 +libxkbcommon-x11-0==1.0.3-2 +libxkbcommon0==1.0.3-2 +libxkbfile1==1:1.1.0-1 +libxml-commons-external-java==1.4.01-5 +libxml-commons-resolver1.1-java==1.2-11 +libxml-libxml-perl==2.0134+dfsg-2+b1 +libxml-namespacesupport-perl==1.12-1.1 +libxml-parser-perl==2.46-2 +libxml-sax-base-perl==1.09-1.1 +libxml-sax-expat-perl==0.51-1 +libxml-sax-perl==1.02+dfsg-1 +libxml-simple-perl==2.25-1 +libxml-twig-perl==1:3.52-1 +libxml-xpathengine-perl==0.14-1 +libxml2==2.9.10+dfsg-6.7+deb11u3 +libxml2-dev==2.9.10+dfsg-6.7+deb11u3 +libxml2-utils==2.9.10+dfsg-6.7+deb11u3 +libxmlgraphics-commons-java==2.4-2~deb11u1 +libxmlrpc-lite-perl==0.717-4 +libxmu6==2:1.1.2-2+b3 +libxmuu1==2:1.1.2-2+b3 +libxnvctrl0==470.141.03-1~deb11u1 +libxpm4==1:3.5.12-1 +libxrandr-dev==2:1.5.1-1 +libxrandr2==2:1.5.1-1 +libxrender-dev==1:0.9.10-1 +libxrender1==1:0.9.10-1 +libxshmfence1==1.3-1 +libxslt1.1==1.1.34-4+deb11u1 +libxss1==1:1.2.3-1 +libxt-dev==1:1.2.0-1 +libxt6==1:1.2.0-1 +libxtables-dev==1.8.7-1 +libxtables12==1.8.7-1 +libxtst-dev==2:1.2.3-1 +libxtst6==2:1.2.3-1 +libxv1==2:1.0.11-1 +libxvidcore4==2:1.3.7-1 +libxxf86dga1==2:1.1.4-1+b3 +libxxf86vm1==1:1.1.4-1+b2 +libxz-java==1.8-2 +libyajl2==2.1.0-3 +libyaml-0-2==0.2.2-1 +libyaml-dev==0.2.2-1 +libyaml-libyaml-perl==0.82+repack-1+b1 +libz3-4==4.8.10-1 +libz3-dev==4.8.10-1 +libzmq3-dev==4.3.4-1 +libzmq5==4.3.4-1 +libzvbi-common==0.2.35-18 +libzvbi0==0.2.35-18 +libzzip-0-13==0.13.62-3.3+deb11u1 +licensecheck==3.1.1-2 +lintian==2.104.0 +linux-compiler-gcc-10-x86==5.10.162-1 +linux-headers-5.10.0-21-amd64==5.10.162-1 +linux-headers-5.10.0-21-common==5.10.162-1 +linux-headers-amd64==5.10.162-1 +linux-kbuild-5.10==5.10.162-1 +linux-libc-dev==5.10.162-1 +linuxdoc-tools==0.9.82-1 +llvm-11==1:11.0.1-2 +llvm-11-dev==1:11.0.1-2 +llvm-11-runtime==1:11.0.1-2 +llvm-11-tools==1:11.0.1-2 +lmodern==2.004.5-6.1 +locales==2.31-13+deb11u5 +logrotate==3.18.0-2+deb11u1 +lsb-release==11.1.0 +lsof==4.93.2+dfsg-1.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.11-2.1 +lynx==2.9.0dev.6-3~deb11u1 +lynx-common==2.9.0dev.6-3~deb11u1 +lz4==1.9.3-2 +lzip==1.22-3 +lzop==1.04-2 +m4==1.4.18-5 +mailcap==3.69 +mailutils==1:3.10-3+b1 +mailutils-common==1:3.10-3 +make==4.3-4.1 +man-db==2.9.4-2 +man2html-base==1.6g-14 +manpages==5.10-1 +manpages-dev==5.10-1 +mariadb-common==1:10.5.18-0+deb11u1 +maven==3.6.3-5 +maven-debian-helper==2.6 +maven-repo-helper==1.10 +media-types==4.0.0 +mesa-va-drivers==20.3.5-1 +mesa-vdpau-drivers==20.3.5-1 +mesa-vulkan-drivers==20.3.5-1 +mime-support==3.66 +module-assistant==0.11.10 +mysql-common==5.8+1.0.7 +ncurses-term==6.2+20201114-2 +netbase==6.3 +netpbm==2:10.0-15.4 +nftables==0.9.8-3.1+deb11u1 +node-jquery==3.5.1+dfsg+~3.5.5-7 +ocl-icd-libopencl1==2.2.14-2 +openjade==1.4devel1-22 +openjdk-11-jdk==11.0.18+10-1~deb11u1 +openjdk-11-jdk-headless==11.0.18+10-1~deb11u1 +openjdk-11-jre==11.0.18+10-1~deb11u1 +openjdk-11-jre-headless==11.0.18+10-1~deb11u1 +opensp==1.5.2-13+b2 +openssh-client==1:8.4p1-5+deb11u1 +openssh-server==1:8.4p1-5+deb11u1 +openssh-sftp-server==1:8.4p1-5+deb11u1 +openssl==1.1.1n-0+deb11u4 +ovmf==2020.11-2+deb11u1 +packagekit==1.2.2-2 +packagekit-tools==1.2.2-2 +pango1.0-tools==1.46.2-3 +patch==2.7.6-7 +patchutils==0.4.2-1 +pbuilder==0.231 +pbzip2==1.1.13-1 +pci.ids==0.0~2021.02.08-1 +perl==5.32.1-4+deb11u2 +perl-modules-5.32==5.32.1-4+deb11u2 +perl-openssl-defaults==5 +php-cli==2:7.4+76 +php-codecoverage==9.2.5+dfsg-3 +php-common==2:76 +php-deepcopy==1.10.2-3 +php-doctrine-instantiator==1.4.0-1 +php-file-iterator==3.0.5-2 +php-invoker==3.1.1-2 +php-mbstring==2:7.4+76 +php-parser==4.10.4-1 +php-pear==1:1.10.12+submodules+notgz+20210212-1 +php-phar-io-manifest==2.0.1-2 +php-phar-io-version==3.0.4-1 +php-phpdocumentor-reflection-common==2.2.0-1 +php-phpdocumentor-reflection-docblock==5.2.2-1 +php-phpdocumentor-type-resolver==1.4.0-2 +php-phpspec-prophecy==1.12.2-1 +php-text-template==2.0.4-1 +php-timer==5.0.3-2 +php-tokenizer==1.2.0-1 +php-webmozart-assert==1.9.1-2 +php-xml==2:7.4+76 +php7.4-cli==7.4.33-1+deb11u3 +php7.4-common==7.4.33-1+deb11u3 +php7.4-json==7.4.33-1+deb11u3 +php7.4-mbstring==7.4.33-1+deb11u3 +php7.4-opcache==7.4.33-1+deb11u3 +php7.4-readline==7.4.33-1+deb11u3 +php7.4-xml==7.4.33-1+deb11u3 +phpunit==9.5.2-1 +phpunit-cli-parser==1.0.1-1 +phpunit-code-unit==1.0.8-1 +phpunit-code-unit-reverse-lookup==2.0.3-2 +phpunit-comparator==4.0.6-1 +phpunit-complexity==2.0.2-1 +phpunit-diff==4.0.4-1 +phpunit-environment==5.1.3-2 +phpunit-exporter==4.0.3-2 +phpunit-global-state==5.0.2-1 +phpunit-lines-of-code==1.0.3-1 +phpunit-object-enumerator==4.0.4-1 +phpunit-object-reflector==2.0.4-1 +phpunit-recursion-context==4.0.4-1 +phpunit-resource-operations==3.0.3-2 +phpunit-type==2.3.1-1 +phpunit-version==3.0.2-2 +pigz==2.6-1 +pinentry-curses==1.1.0-4 +pixz==1.0.7-1 +pkg-config==0.29.2-1 +pkg-php-tools==1.40 +po-debconf==1.0.21+nmu1 +pocketsphinx-en-us==0.8+5prealpha+1-13 +policykit-1==0.105-31+deb11u1 +poppler-data==0.4.10-1 +pps-tools==1.0.2-2 +preview-latex-style==12.2-1 +pristine-tar==1.49 +procmail==3.22-26+deb11u1 +procps==2:3.3.17-5 +protobuf-compiler==3.12.4-1 +psmisc==23.4-2 +psutils==1.17.dfsg-4 +publicsuffix==20220811.1734-0+deb11u1 +pylint==2.7.2-3 +python-all==2.7.18-3 +python-apt-common==2.2.1 +python-babel-localedata==2.8.0+dfsg.1-7 +python-is-python3==3.9.2-1 +python-pip-whl==20.3.4-4+deb11u1 +python-pkg-resources==44.1.1-1 +python-setuptools==44.1.1-1 +python2==2.7.18-3 +python2-dev==2.7.18-3 +python2-minimal==2.7.18-3 +python2.7==2.7.18-8 +python2.7-dev==2.7.18-8 +python2.7-minimal==2.7.18-8 +python3==3.9.2-3 +python3-alabaster==0.7.8-1.1 +python3-all==3.9.2-3 +python3-all-dbg==3.9.2-3 +python3-all-dev==3.9.2-3 +python3-apt==2.2.1 +python3-astroid==2.5.1-1 +python3-attr==20.3.0-1 +python3-automat==20.2.0-1 +python3-babel==2.8.0+dfsg.1-7 +python3-bcrypt==3.1.7-4 +python3-bs4==4.9.3-1 +python3-certifi==2020.6.20-1 +python3-cffi-backend==1.14.5-1 +python3-chardet==4.0.0-1 +python3-click==7.1.2-1 +python3-colorama==0.4.4-1 +python3-constantly==15.1.0-2 +python3-cov-core==1.15.0-3 +python3-coverage==5.1+dfsg.1-2+b2 +python3-cryptography==3.3.2-1 +python3-dateutil==2.8.1-6 +python3-dbg==3.9.2-3 +python3-dbus==1.2.16-5 +python3-debian==0.1.39 +python3-dev==3.9.2-3 +python3-distro-info==1.0 +python3-distutils==3.9.2-1 +python3-docutils==0.16+dfsg-4 +python3-gi==3.38.0-2 +python3-gpg==1.14.0-1+b2 +python3-hamcrest==1.9.0-3 +python3-html5lib==1.1-3 +python3-hyperlink==19.0.0-2 +python3-idna==2.10-1 +python3-imagesize==1.2.0-2 +python3-importlib-metadata==1.6.0-2 +python3-incremental==17.5.0-1 +python3-iniconfig==1.1.1-1 +python3-ipaddr==2.2.0-4 +python3-isort==5.6.4-1 +python3-jinja2==2.11.3-1 +python3-lazy-object-proxy==1.5.2-1 +python3-lib2to3==3.9.2-1 +python3-logilab-common==1.8.1-1 +python3-lxml==4.6.3+dfsg-0.1+deb11u1 +python3-magic==2:0.4.20-3 +python3-mako==1.1.3+ds1-2 +python3-markdown==3.3.4-1 +python3-markupsafe==1.1.1-1+b3 +python3-mccabe==0.6.1-3 +python3-minimal==3.9.2-3 +python3-more-itertools==4.2.0-3 +python3-mypy-extensions==0.4.3-2 +python3-nose2==0.9.2-1 +python3-olefile==0.46-3 +python3-openssl==20.0.1-1 +python3-packaging==20.9-2 +python3-parse==1.6.6-0.2 +python3-pil==8.1.2+dfsg-0.3+deb11u1 +python3-pip==20.3.4-4+deb11u1 +python3-pkg-resources==52.0.0-4 +python3-pluggy==0.13.0-6 +python3-py==1.10.0-1 +python3-pyasn1==0.4.8-1 +python3-pyasn1-modules==0.2.1-1 +python3-pycurl==7.43.0.6-5 +python3-pygments==2.7.1+dfsg-2.1 +python3-pyparsing==2.4.7-1 +python3-pytest==6.0.2-2 +python3-pytest-cov==2.10.1-1 +python3-requests==2.25.1+dfsg-2 +python3-roman==2.0.0-5 +python3-service-identity==18.1.0-6 +python3-setuptools==52.0.0-4 +python3-six==1.16.0-2 +python3-snowballstemmer==2.1.0-1 +python3-software-properties==0.96.20.2-2.1 +python3-soupsieve==2.2.1-1 +python3-sphinx==3.4.3-2 +python3-sphinx-rtd-theme==0.5.1+dfsg-1 +python3-stdeb==0.10.0-1 +python3-tk==3.9.2-1 +python3-toml==0.10.1-1 +python3-twisted==20.3.0-7+deb11u1 +python3-twisted-bin==20.3.0-7+deb11u1 +python3-typing-extensions==3.7.4.3-1 +python3-tz==2021.1-1 +python3-unidiff==0.5.5-2 +python3-urllib3==1.26.5-1~exp1 +python3-venv==3.9.2-3 +python3-webencodings==0.5.1-2 +python3-wheel==0.34.2-1 +python3-wrapt==1.12.1-4+b1 +python3-xdg==0.27-2 +python3-yaml==5.3.1-5 +python3-zipp==1.0.0-3 +python3-zope.interface==5.2.0-1 +python3.9==3.9.2-1 +python3.9-dbg==3.9.2-1 +python3.9-dev==3.9.2-1 +python3.9-minimal==3.9.2-1 +python3.9-venv==3.9.2-1 +qemu-system-common==1:5.2+dfsg-11+deb11u2 +qemu-system-data==1:5.2+dfsg-11+deb11u2 +qemu-system-gui==1:5.2+dfsg-11+deb11u2 +qemu-system-x86==1:5.2+dfsg-11+deb11u2 +qemu-utils==1:5.2+dfsg-11+deb11u2 +qt5-gtk-platformtheme==5.15.2+dfsg-9 +qt5-qmake==5.15.2+dfsg-9 +qt5-qmake-bin==5.15.2+dfsg-9 +qtbase5-dev==5.15.2+dfsg-9 +qtbase5-dev-tools==5.15.2+dfsg-9 +qtchooser==66-2 +qttranslations5-l10n==5.15.2-2 +quilt==0.66-2.1 +rake==13.0.3-1 +readline-common==8.1-1 +rrdtool==1.7.2-3+b7 +rsync==3.2.3-4+deb11u1 +rsyslog==8.2102.0-2+deb11u1 +ruby==1:2.7+2 +ruby-all-dev==1:2.7+2 +ruby-asciidoctor==2.0.12-2 +ruby-minitest==5.13.0-1 +ruby-net-telnet==0.1.1-2 +ruby-power-assert==1.1.7-2 +ruby-rubygems==3.2.5-2 +ruby-test-unit==3.3.9-1 +ruby-xmlrpc==0.3.0-2 +ruby2.7==2.7.4-1+deb11u1 +ruby2.7-dev==2.7.4-1+deb11u1 +ruby2.7-doc==2.7.4-1+deb11u1 +rubygems-integration==1.18 +runit-helper==2.10.3 +sbsigntool==0.9.2-2 +seabios==1.14.0-2 +sensible-utils==0.0.14 +sgml-base==1.30 +sgml-data==2.0.11+nmu1 +sgmlspl==1.03ii-36 +shared-mime-info==2.0-1 +sharutils==1:4.15.2-5 +shellcheck==0.7.1-1+deb11u1 +slirp4netns==1.0.1-2 +software-properties-common==0.96.20.2-2.1 +sphinx-common==3.4.3-2 +sphinx-rtd-theme-common==0.5.1+dfsg-1 +squashfs-tools==1:4.4-2+deb11u2 +stgit==0.19-1 +strace==5.10-1 +sudo==1.9.5p2-3+deb11u1 +swig==4.0.2-1 +swig4.0==4.0.2-1 +systemd==247.3-7+deb11u1 +systemd-sysv==247.3-7+deb11u1 +systemd-timesyncd==247.3-7+deb11u1 +t1utils==1.41-4 +tcl==8.6.11+1 +tcl8.6==8.6.11+dfsg-1 +teckit==2.5.10+ds1-3 +telnet==0.17-42 +termit==3.1-1 +tex-common==6.16 +tex-gyre==20180621-3.1 +texi2html==1.82+dfsg1-6 +texinfo==6.7.0.dfsg.2-6 +texlive-base==2020.20210202-3 +texlive-binaries==2020.20200327.54578-7 +texlive-fonts-recommended==2020.20210202-3 +texlive-formats-extra==2020.20210202-3 +texlive-latex-base==2020.20210202-3 +texlive-latex-extra==2020.20210202-3 +texlive-latex-recommended==2020.20210202-3 +texlive-pictures==2020.20210202-3 +texlive-plain-generic==2020.20210202-3 +texlive-xetex==2020.20210202-3 +thin-provisioning-tools==0.9.0-1 +time==1.9-0.1 +tipa==2:1.3-20.1 +tk==8.6.11+1 +tk8.6==8.6.11-2 +tk8.6-blt2.5==2.5.3+dfsg-4.1 +ucf==3.0043 +unattended-upgrades==2.8 +unzip==6.0-26+deb11u1 +uuid-dev==2.36.1-8+deb11u1 +va-driver-all==2.10.0-1 +vdpau-driver-all==1.4-3 +velocity==1.7-6 +vim==2:8.2.2434-3+deb11u1 +vim-common==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 +wayland-protocols==1.20-1 +wdiff==1.2.2-2+b1 +wget==1.21-1+deb11u1 +x11-common==1:7.7+22 +x11-utils==7.7+5 +x11-xserver-utils==7.7+8 +x11proto-dev==2020.1-1 +x11proto-input-dev==2020.1-1 +x11proto-randr-dev==2020.1-1 +x11proto-record-dev==2020.1-1 +x11proto-xext-dev==2020.1-1 +x11proto-xinerama-dev==2020.1-1 +xauth==1:1.1-1 +xdelta==1.1.3-9.3 +xdelta3==3.0.11-dfsg-1+b1 +xdg-user-dirs==0.17-2 +xdg-utils==1.1.3-4.1 +xfonts-encodings==1:1.0.4-2.1 +xfonts-utils==1:7.7+6 +xkb-data==2.29-2 +xml-core==0.18+nmu1 +xorg-sgml-doctools==1:1.11-1.1 +xsltproc==1.1.34-4+deb11u1 +xtrans-dev==1.4.0-1 +xxd==2:8.2.2434-3+deb11u1 +xz-utils==5.2.5-2.1~deb11u1 +zip==3.0-12 +zlib1g-dev==1:1.2.11.dfsg-2+deb11u2 \ No newline at end of file diff --git a/files/build/versions/dockers/sonic-slave-bullseye/versions-deb-bullseye-arm64 b/files/build/versions/dockers/sonic-slave-bullseye/versions-deb-bullseye-arm64 new file mode 100644 index 000000000000..2b165604932b --- /dev/null +++ b/files/build/versions/dockers/sonic-slave-bullseye/versions-deb-bullseye-arm64 @@ -0,0 +1,22 @@ +binutils-aarch64-linux-gnu==2.35.2-2 +binutils-arm-linux-gnueabihf==2.35.2-2 +cpp-10-arm-linux-gnueabihf==10.2.1-6cross1 +cpp-arm-linux-gnueabihf==4:10.2.1-1 +dctrl-tools==2.24-3 +dvipng==1.15-1.1 +gcc-10-arm-linux-gnueabihf==10.2.1-6cross1 +gcc-10-arm-linux-gnueabihf-base==10.2.1-6cross1 +gcc-10-cross-base==10.2.1-6cross1 +gcc-arm-linux-gnueabihf==4:10.2.1-1 +libasan6-armhf-cross==10.2.1-6cross1 +libatomic1-armhf-cross==10.2.1-6cross1 +libc6-armhf-cross==2.31-9cross4 +libgcc-10-dev-armhf-cross==10.2.1-6cross1 +libgcc-s1-armhf-cross==10.2.1-6cross1 +libgomp1-armhf-cross==10.2.1-6cross1 +libstdc++6-armhf-cross==10.2.1-6cross1 +libubsan1-armhf-cross==10.2.1-6cross1 +libxslt1-dev==1.1.34-4+deb11u1 +linux-headers-5.10.0-21-arm64==5.10.162-1 +linux-headers-arm64==5.10.162-1 +nodejs==14.21.3-deb-1nodesource1 \ No newline at end of file diff --git a/files/build/versions/dockers/sonic-slave-bullseye/versions-deb-bullseye-armhf b/files/build/versions/dockers/sonic-slave-bullseye/versions-deb-bullseye-armhf new file mode 100644 index 000000000000..ce59f50e9a83 --- /dev/null +++ b/files/build/versions/dockers/sonic-slave-bullseye/versions-deb-bullseye-armhf @@ -0,0 +1,13 @@ +binutils-arm-linux-gnueabihf==2.35.2-2 +dctrl-tools==2.24-3 +dvipng==1.15-1.1 +golang-1.15-go==1.15.15-1~deb11u4 +golang-1.15-src==1.15.15-1~deb11u4 +libjpeg-dev==1:2.0.6-4 +libjpeg62-turbo-dev==1:2.0.6-4 +libxslt1-dev==1.1.34-4+deb11u1 +linux-compiler-gcc-10-arm==5.10.162-1 +linux-headers-5.10.0-21-armmp==5.10.162-1 +linux-headers-armmp==5.10.162-1 +nasm==2.15.05-1 +nodejs==14.21.3-deb-1nodesource1 \ No newline at end of file diff --git a/files/build/versions/dockers/sonic-slave-bullseye/versions-py3 b/files/build/versions/dockers/sonic-slave-bullseye/versions-py3 new file mode 100644 index 000000000000..488cf2e439ff --- /dev/null +++ b/files/build/versions/dockers/sonic-slave-bullseye/versions-py3 @@ -0,0 +1,110 @@ +alabaster==0.7.8 +astroid==2.5.1 +async-timeout==4.0.2 +attrs==20.3.0 +automat==20.2.0 +babel==2.8.0 +bcrypt==3.1.7 +beautifulsoup4==4.9.3 +bitarray==2.7.3 +certifi==2020.6.20 +chardet==4.0.0 +click==7.1.2 +colorama==0.4.4 +constantly==15.1.0 +cov-core==1.15.0 +coverage==5.1 +crc16==0.1.1 +cryptography==3.3.2 +ctypesgen==1.0.2 +dbus-python==1.2.16 +deepdiff==6.2.2 +devscripts==2.21.3+deb11u1 +distro-info==1.0 +docutils==0.16 +fastentrypoints==0.12 +gbp==0.9.22 +gcovr==4.2 +gpg===1.14.0-unknown +html5lib==1.1 +hyperlink==19.0.0 +idna==2.10 +imagesize==1.2.0 +importlib-metadata==1.6.0 +incremental==17.5.0 +iniconfig==0.0.0 +ipaddr==2.2.0 +isort==5.6.4 +j2cli==0.3.10 +jinja2==2.11.3 +lazy-object-proxy==0.0.0 +logilab-common==1.8.1 +lxml==4.9.1 +m2crypto==0.36.0 +mako==1.1.3 +markdown==3.3.4 +markupsafe==1.1.1 +mccabe==0.6.1 +mmh3==2.5.1 +mock==5.0.2 +mockredispy==2.9.3 +more-itertools==4.2.0 +mypy-extensions==0.4.3 +nose==1.3.7 +nose2==0.9.2 +olefile==0.46 +ordered-set==4.1.0 +packaging==20.9 +parameterized==0.8.1 +parse==1.6.6 +pexpect==4.8.0 +pillow==9.4.0 +pluggy==0.13.0 +ptyprocess==0.7.0 +py==1.10.0 +pyang==2.4.0 +pyangbind==0.8.1 +pyasn1==0.4.8 +pyasn1-modules==0.2.1 +pycurl==7.43.0.6 +pyfakefs==5.2.2 +pygments==2.7.1 +pygobject==3.38.0 +pyhamcrest==1.9.0 +pylint==2.7.2 +pympler==0.8 +pyopenssl==20.0.1 +pyparsing==2.4.7 +pytest==6.0.2 +pytest-cov==2.10.1 +pytest-runner==5.2 +python-apt==2.2.1 +python-dateutil==2.8.1 +python-debian==0.1.39 +python-magic==0.4.20 +pytz==2021.1 +pyxdg==0.27 +pyyaml==5.4.1 +redis==4.5.4 +regex==2023.3.23 +requests==2.25.1 +roman==2.0.0 +service-identity==18.1.0 +six==1.16.0 +snowballstemmer==2.1.0 +soupsieve==2.2.1 +sphinx==3.4.3 +sphinx-rtd-theme==0.5.1 +stdeb==0.10.0 +stgit==0.19 +toml==0.10.1 +twisted==20.3.0 +typing-extensions==3.7.4.3 +unattended-upgrades==0.1 +unidiff==0.5.5 +urllib3==1.26.5 +webencodings==0.5.1 +wrapt==1.12.1 +xdg==5 +zipp==1.0.0 +zope.interface==5.2.0 \ 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..fc61bbaf25c0 --- /dev/null +++ b/files/build/versions/dockers/sonic-slave-buster/versions-deb-buster @@ -0,0 +1,1783 @@ +adwaita-icon-theme==3.30.1-1 +ant==1.10.5-2 +ant-optional==1.10.5-2 +apparmor==2.13.2-10 +apt-file==3.2.2 +apt-transport-https==1.8.2.3 +apt-utils==1.8.2.3 +arch-test==0.15-2+deb10u1 +asciidoctor==1.5.8-1 +aspell==0.60.7~20110707-6+deb10u1 +aspell-en==2018.04.16-0-1 +at==3.1.23-1 +at-spi2-core==2.30.0-7 +auditd==1:2.8.4-3 +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 +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+deb10u8 +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~deb10u2 +bzip2-doc==1.0.6-9.2~deb10u2 +ca-certificates==20200601~deb10u2 +ca-certificates-java==20190405 +cdbs==0.4.159 +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.6.20-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+deb10u5 +dbus==1.12.24-0+deb10u1 +dbus-user-session==1.12.24-0+deb10u1 +dconf-gsettings-backend==0.30.1-2 +dconf-service==0.30.1-2 +dctrl-tools==2.24-3 +debhelper==13.3.3~bpo10+1 +debian-keyring==2019.02.25 +debootstrap==1.0.114+deb10u1 +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+deb10u2 +distro-info-data==0.41+deb10u6 +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+deb10u8 +docbook==4.5-6 +docbook-dsssl==1.79-9.1 +docbook-to-man==1:2.0.0-42 +docbook-utils==0.6.14-3.3 +docbook-xml==4.5-8 +docker-ce==5:20.10.21~3-0~debian-buster +docker-ce-cli==5:20.10.21~3-0~debian-buster +docker-ce-rootless-extras==5:23.0.4-1~debian.10~buster +docker-scan-plugin==0.23.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.8 +dput==1.0.3 +dvipng==1.15-1.1 +dwz==0.13-5~bpo10+1 +eatmydata==105-7 +emacsen-common==3.0.4 +equivs==2.2.0 +exim4-base==4.92-8+deb10u7 +exim4-config==4.92-8+deb10u7 +exim4-daemon-light==4.92-8+deb10u7 +expat==2.2.6-2+deb10u6 +exuberant-ctags==1:5.9~svn20110310-12+deb10u1 +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+deb10u7 +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-glib-2.0==1.58.3-2 +gir1.2-gtk-3.0==3.24.5-1 +gir1.2-harfbuzz-0.0==2.3.1-1 +gir1.2-packagekitglib-1.0==1.1.12-5 +gir1.2-pango-1.0==1.42.4-8~deb10u1 +git==1:2.20.1-2+deb10u8 +git-buildpackage==0.9.14 +git-man==1:2.20.1-2+deb10u8 +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+deb10u2 +gnupg-l10n==2.2.12-1+deb10u2 +gnupg-utils==2.2.12-1+deb10u2 +gnupg2==2.2.12-1+deb10u2 +gobject-introspection==1.58.3-2 +googletest==1.8.1-3 +gpg==2.2.12-1+deb10u2 +gpg-agent==2.2.12-1+deb10u2 +gpg-wks-client==2.2.12-1+deb10u2 +gpg-wks-server==2.2.12-1+deb10u2 +gpgconf==2.2.12-1+deb10u2 +gpgsm==2.2.12-1+deb10u2 +graphviz==2.40.1-6+deb10u1 +groff==1.22.4-3+deb10u1 +groff-base==1.22.4-3+deb10u1 +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+deb10u1 +gstreamer1.0-plugins-base==1.14.4-2+deb10u1 +gstreamer1.0-plugins-good==1.14.4-1+deb10u2 +gstreamer1.0-plugins-ugly==1.14.4-1+deb10u1 +gstreamer1.0-x==1.14.4-2+deb10u1 +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+deb10u3 +imagemagick==8:6.9.10.23+dfsg-2.1+deb10u4 +imagemagick-6-common==8:6.9.10.23+dfsg-2.1+deb10u4 +imagemagick-6.q16==8:6.9.10.23+dfsg-2.1+deb10u4 +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 +jq==1.5+dfsg-2+b1 +kernel-wedge==2.99 +kmod==26-1 +krb5-locales==1.17-3+deb10u5 +krb5-multidev==1.17-3+deb10u5 +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 +libabsl-dev==0~20200225.2-3~bpo10+1 +libabsl20200225==0~20200225.2-3~bpo10+1 +libaio1==0.3.112-3 +libalgorithm-c3-perl==0.10-1 +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 +libappconfig-perl==1.71-2 +libappstream4==0.12.5-1 +libapt-inst2.0==1.8.2.3 +libapt-pkg-perl==0.1.34+b1 +libarchive-cpio-perl==0.10-1 +libarchive-zip-perl==1.64-1 +libarchive13==3.3.3-4+deb10u3 +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+deb10u1 +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-bridge2.0-dev==2.30.0-5 +libatk-wrapper-java==0.33.3-22+deb10u1 +libatk-wrapper-java-jni==0.33.3-22+deb10u1 +libatk1.0-0==2.30.0-2 +libatk1.0-data==2.30.0-2 +libatk1.0-dev==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 +libatspi2.0-dev==2.30.0-7 +libaudio2==1.9.4-6 +libaudit-dev==1:2.8.4-3 +libaugeas0==1.11.0-3 +libauparse-dev==1:2.8.4-3 +libauparse0==1:2.8.4-3 +libauthen-sasl-perl==2.1600-1 +libavahi-client3==0.7-4+deb10u1 +libavahi-common-data==0.7-4+deb10u1 +libavahi-common3==0.7-4+deb10u1 +libavalon-framework-java==4.2.0-10 +libavc1394-0==0.5.4-5 +libavcodec58==7:4.1.10-0+deb10u1 +libavfilter7==7:4.1.10-0+deb10u1 +libavformat58==7:4.1.10-0+deb10u1 +libavutil56==7:4.1.10-0+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+deb10u2 +libbdplus0==0.1.2-3 +libbind-export-dev==1:9.11.5.P4+dfsg-5.1+deb10u8 +libbind9-161==1:9.11.5.P4+dfsg-5.1+deb10u8 +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~deb10u3 +libbluray2==1:1.1.0-1+deb10u1 +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 +libbpf-dev==1:0.3-2~bpo10+1 +libbpf0==1:0.3-2~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+deb10u1 +libbsd0==0.9.1-2+deb10u1 +libbsh-java==2.0b4-19 +libbz2-dev==1.0.6-9.2~deb10u2 +libc-ares-dev==1.14.0-1+deb10u2 +libc-ares2==1.14.0-1+deb10u2 +libc-dev-bin==2.28-10+deb10u2 +libc-l10n==2.28-10+deb10u2 +libc6-dbg==2.28-10+deb10u2 +libc6-dev==2.28-10+deb10u2 +libc6-dev-i386==2.28-10+deb10u2 +libc6-dev-x32==2.28-10+deb10u2 +libc6-i386==2.28-10+deb10u2 +libc6-x32==2.28-10+deb10u2 +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 +libcairo-script-interpreter2==1.16.0-4+deb10u1 +libcairo2==1.16.0-4+deb10u1 +libcairo2-dev==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+deb10u1 +libcgi-fast-perl==1:2.13-1 +libcgi-pm-perl==4.40-1 +libcglib-java==3.2.10-1 +libcgraph6==2.40.1-6+deb10u1 +libchromaprint1==1.4.3-3 +libcjson-dev==1.7.10-1.1+deb10u1 +libcjson1==1.7.10-1.1+deb10u1 +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-c3-perl==0.34-1 +libclass-c3-xs-perl==0.14-1+b3 +libclass-inspector-perl==1.32-1 +libclass-load-perl==0.25-1 +libclass-load-xs-perl==0.10-1+b3 +libclass-method-modifiers-perl==2.12-1 +libclass-tiny-perl==1.006-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+deb10u1 +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 +libcunit1==2.1-3-dfsg-2+b12 +libcunit1-dev==2.1-3-dfsg-2+b12 +libcups2==2.2.10-6+deb10u6 +libcupsfilters1==1.21.6-5 +libcupsimage2==2.2.10-6+deb10u6 +libcurl3-gnutls==7.64.0-4+deb10u5 +libcurl3-nss==7.64.0-4+deb10u5 +libcurl4==7.64.0-4+deb10u5 +libcurl4-nss-dev==7.64.0-4+deb10u5 +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.24-0+deb10u1 +libdbus-1-dev==1.12.24-0+deb10u1 +libdbus-glib-1-2==0.110-4 +libdbus-glib-1-dev==0.110-4 +libdbus-glib-1-dev-bin==0.110-4 +libdconf1==0.30.1-2 +libde265-0==1.0.11-0+deb10u4 +libdebhelper-perl==13.3.3~bpo10+1 +libdevel-callchecker-perl==0.008-1 +libdevel-caller-perl==2.06-2+b1 +libdevel-globaldestruction-perl==0.14-1 +libdevel-lexalias-perl==0.05-2+b1 +libdevel-overloadinfo-perl==0.005-1 +libdevel-partialdump-perl==0.20-1 +libdevel-stacktrace-perl==2.0300-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 +libdist-checkconflicts-perl==0.11-1 +libdistro-info-perl==0.21 +libdjvulibre-text==3.5.27.1-10+deb10u1 +libdjvulibre21==3.5.27.1-10+deb10u1 +libdns-export1104==1:9.11.5.P4+dfsg-5.1+deb10u8 +libdns1104==1:9.11.5.P4+dfsg-5.1+deb10u8 +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.8 +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 +libegl1-mesa-dev==18.3.6-2+deb10u1 +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 +libepoxy-dev==1.5.3-0.1 +libepoxy0==1.5.3-0.1 +liberror-perl==0.17027-2 +libestr0==0.1.10-2.1 +libeval-closure-perl==0.14-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+deb10u6 +libexpat1-dev==2.2.6-2+deb10u6 +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+deb10u2 +libflite1==2.1-release-3 +libfont-afm-perl==1.20-2 +libfontbox2-java==2.0.13-2 +libfontconfig1==2.13.1-2 +libfontconfig1-dev==2.13.1-2 +libfontenc1==1:1.1.3-1+b2 +libfop-java==1:2.3-2 +libfreetype6==2.9.1-3+deb10u3 +libfreetype6-dev==2.9.1-3+deb10u3 +libfribidi-dev==1.0.5-3.1+deb10u2 +libfribidi0==1.0.5-3.1+deb10u2 +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 +libgdk-pixbuf2.0-dev==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+deb10u1 +libgirepository-1.0-1==1.58.3-2 +libgirepository1.0-dev==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+deb10u4 +libglib2.0-bin==2.58.3-2+deb10u4 +libglib2.0-data==2.58.3-2+deb10u4 +libglib2.0-dev==2.58.3-2+deb10u4 +libglib2.0-dev-bin==2.58.3-2+deb10u4 +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 +libgmock-dev==1.8.1-3 +libgmp-dev==2:6.1.2+dfsg-4+deb10u1 +libgmpxx4ldbl==2:6.1.2+dfsg-4+deb10u1 +libgnutls-dane0==3.6.7-4+deb10u10 +libgnutls-openssl27==3.6.7-4+deb10u10 +libgnutls28-dev==3.6.7-4+deb10u10 +libgnutlsxx28==3.6.7-4+deb10u10 +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 +libgraphite2-dev==1.3.13-7 +libgrpc++1==1.16.1-1 +libgrpc6==1.16.1-1 +libgs9==9.27~dfsg-2+deb10u7 +libgs9-common==9.27~dfsg-2+deb10u7 +libgsm1==1.0.18-2 +libgssapi-krb5-2==1.17-3+deb10u5 +libgssrpc4==1.17-3+deb10u5 +libgstreamer-plugins-base1.0-0==1.14.4-2+deb10u1 +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 +libgtk-3-dev==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+deb10u1 +libgvpr2==2.40.1-6+deb10u1 +libharfbuzz-dev==2.3.1-1 +libharfbuzz-gobject0==2.3.1-1 +libharfbuzz-icu0==2.3.1-1 +libharfbuzz0b==2.3.1-1 +libhawtjni-runtime-java==1.16-1 +libheif1==1.3.2-2~deb10u1 +libhiredis-dev==0.14.0-3 +libhiredis0.14==0.14.0-3 +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+deb10u1 +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+deb10u3 +libicu63==63.1-6+deb10u3 +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+deb10u8 +libirs161==1:9.11.5.P4+dfsg-5.1+deb10u8 +libisc-export1100==1:9.11.5.P4+dfsg-5.1+deb10u8 +libisc1100==1:9.11.5.P4+dfsg-5.1+deb10u8 +libisccc-export161==1:9.11.5.P4+dfsg-5.1+deb10u8 +libisccc161==1:9.11.5.P4+dfsg-5.1+deb10u8 +libisccfg-export163==1:9.11.5.P4+dfsg-5.1+deb10u8 +libisccfg163==1:9.11.5.P4+dfsg-5.1+deb10u8 +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+deb10u1 +libjemalloc-dev==5.1.0-3 +libjemalloc2==5.1.0-3 +libjetty9-java==9.4.16-0+deb10u2 +libjpeg62-turbo==1:1.5.2-2+deb10u1 +libjq1==1.5+dfsg-2+b1 +libjs-bootstrap==3.4.1+dfsg-1 +libjs-jquery==3.3.1~dfsg-3+deb10u1 +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+deb10u1 +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+deb10u5 +libkadm5clnt-mit11==1.17-3+deb10u5 +libkadm5srv-mit11==1.17-3+deb10u5 +libkdb5-9==1.17-3+deb10u5 +libkeyutils1==1.6-6 +libkmod2==26-1 +libkpathsea6==2018.20181218.49446-1 +libkrb5-3==1.17-3+deb10u5 +libkrb5-dev==1.17-3+deb10u5 +libkrb5support0==1.17-3+deb10u5 +libksba8==1.3.5-2+deb10u2 +liblab-gamut1==2.40.1-6+deb10u1 +liblcms2-2==2.9-3 +libldap-2.4-2==2.4.47+dfsg-3+deb10u7 +libldap-common==2.4.47+dfsg-3+deb10u7 +libldap2-dev==2.4.47+dfsg-3+deb10u7 +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+deb10u2 +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+deb10u8 +liblzma-dev==5.2.4-1+deb10u1 +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+deb10u4 +libmagickcore-6.q16-6-extra==8:6.9.10.23+dfsg-2.1+deb10u4 +libmagickwand-6.q16-6==8:6.9.10.23+dfsg-2.1+deb10u4 +libmail-sendmail-perl==0.80-1 +libmailtools-perl==2.18-1 +libmariadb-dev==1:10.3.38-0+deb10u1 +libmariadb-dev-compat==1:10.3.38-0+deb10u1 +libmariadb3==1:10.3.38-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+deb10u1 +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-conflicts-perl==0.003-1 +libmodule-runtime-perl==0.016-1 +libmoo-perl==2.003004-2 +libmoose-perl==2.2011-1+b1 +libmoosex-aliases-perl==0.11-1 +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 +libmro-compat-perl==0.13-1 +libmtdev1==1.1.5-1+b1 +libmysofa0==0.6~dfsg0-3+deb10u1 +libnamespace-autoclean-perl==0.28-1 +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+deb10u3 +libncurses5-dev==6.1+20181013-2+deb10u3 +libncurses6==6.1+20181013-2+deb10u3 +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+deb10u1 +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~deb10u9 +libnss3==2:3.42.1-1+deb10u6 +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 +libonig5==6.9.1-1 +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+deb10u2 +libopengl0==1.1.0-1 +libopenjp2-7==2.3.0-2+deb10u2 +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 +libostyle1c2==1.4devel1-21.3+b1 +libp11-kit-dev==0.23.15-2+deb10u1 +libpackage-deprecationmanager-perl==0.17-1 +libpackage-stash-perl==0.38-1 +libpackage-stash-xs-perl==0.29-1 +libpackagekit-glib2-18==1.1.12-5 +libpadwalker-perl==2.3-1+b1 +libpam-systemd==241-7~deb10u9 +libpam0g-dev==1.3.1-5 +libpango-1.0-0==1.42.4-8~deb10u1 +libpango1.0-dev==1.42.4-8~deb10u1 +libpangocairo-1.0-0==1.42.4-8~deb10u1 +libpangoft2-1.0-0==1.42.4-8~deb10u1 +libpangoxft-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+deb10u1 +libpcap-dev==1.8.1-6+deb10u1 +libpcap0.8==1.8.1-6+deb10u1 +libpcap0.8-dev==1.8.1-6+deb10u1 +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+deb10u1 +libpcre2-32-0==10.32-5+deb10u1 +libpcre2-8-0==10.32-5+deb10u1 +libpcre2-dev==10.32-5+deb10u1 +libpcre2-posix0==10.32-5+deb10u1 +libpcre3-dev==2:8.39-12 +libpcre32-3==2:8.39-12 +libpcrecpp0v5==2:8.39-12 +libpcsclite-dev==1.8.24-1 +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+deb10u1 +libpixman-1-dev==0.36.0-1+deb10u1 +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 +libpng-tools==1.6.36-6 +libpng16-16==1.6.36-6 +libpod-constants-perl==0.19-1 +libpolkit-agent-1-0==0.105-25+deb10u1 +libpolkit-backend-1-0==0.105-25+deb10u1 +libpolkit-gobject-1-0==0.105-25+deb10u1 +libpopt0==1.16-12 +libpostproc55==7:4.1.10-0+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+deb10u4 +libpython3.7-dbg==3.7.3-2+deb10u4 +libpython3.7-dev==3.7.3-2+deb10u4 +libpython3.7-minimal==3.7.3-2+deb10u4 +libpython3.7-stdlib==3.7.3-2+deb10u4 +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+deb10u5 +libqt5core5a==5.11.3+dfsg1-1+deb10u5 +libqt5dbus5==5.11.3+dfsg1-1+deb10u5 +libqt5gui5==5.11.3+dfsg1-1+deb10u5 +libqt5network5==5.11.3+dfsg1-1+deb10u5 +libqt5opengl5==5.11.3+dfsg1-1+deb10u5 +libqt5opengl5-dev==5.11.3+dfsg1-1+deb10u5 +libqt5printsupport5==5.11.3+dfsg1-1+deb10u5 +libqt5sql5==5.11.3+dfsg1-1+deb10u5 +libqt5sql5-sqlite==5.11.3+dfsg1-1+deb10u5 +libqt5svg5==5.11.3-2 +libqt5test5==5.11.3+dfsg1-1+deb10u5 +libqt5widgets5==5.11.3+dfsg1-1+deb10u5 +libqt5xml5==5.11.3+dfsg1-1+deb10u5 +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+deb10u3 +librsvg2-common==2.44.10-2.1+deb10u3 +librtmp1==2.4+20151223.gitfa8646d.1-2 +librubberband2==1.8.1-7 +libruby2.5==2.5.5-3+deb10u4 +libsamplerate0==0.1.9-2 +libsasl2-2==2.1.27+dfsg-1+deb10u2 +libsasl2-modules==2.1.27+dfsg-1+deb10u2 +libsasl2-modules-db==2.1.27+dfsg-1+deb10u2 +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 +libsgmls-perl==1.03ii-36 +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+deb10u2 +libsnmp-base==5.7.3+dfsg-5+deb10u4 +libsnmp-dev==5.7.3+dfsg-5+deb10u4 +libsnmp30==5.7.3+dfsg-5+deb10u4 +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+deb10u2 +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.1n-0+deb10u4 +libssl1.1==1.1.1n-0+deb10u4 +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.10-0+deb10u1 +libswscale5==7:4.1.10-0+deb10u1 +libsynctex2==2018.20181218.49446-1 +libsys-hostname-long-perl==1.5-1 +libsystemd-dev==241-7~deb10u9 +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+deb10u1 +libtasn1-doc==4.13-3+deb10u1 +libtcl8.6==8.6.9+dfsg-2 +libtcmalloc-minimal4==2.7-1 +libteckit0==2.5.8+ds2-5 +libtemplate-perl==2.27-1+b1 +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~deb10u7 +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~deb10u9 +libunbound8==1.9.0-2+deb10u3 +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+deb10u1 +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+deb10u1 +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+deb10u1 +libwayland-bin==1.16.0-1 +libwayland-client0==1.16.0-1 +libwayland-cursor0==1.16.0-1 +libwayland-dev==1.16.0-1 +libwayland-egl1==1.16.0-1 +libwayland-server0==1.16.0-1 +libwebp6==0.6.1-2+deb10u1 +libwebpdemux2==0.6.1-2+deb10u1 +libwebpmux3==0.6.1-2+deb10u1 +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+deb10u2 +libx11-data==2:1.6.7-1+deb10u2 +libx11-dev==2:1.6.7-1+deb10u2 +libx11-protocol-perl==0.56-7 +libx11-xcb-dev==2:1.6.7-1+deb10u2 +libx11-xcb1==2:1.6.7-1+deb10u2 +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+deb10u1 +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-shm0-dev==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 +libxcomposite-dev==1:0.4.4-2 +libxcomposite1==1:0.4.4-2 +libxcursor-dev==1:1.1.15-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+deb10u1 +libxencall1==4.11.4+107-gef32c7afa2-1 +libxendevicemodel1==4.11.4+107-gef32c7afa2-1 +libxenevtchn1==4.11.4+107-gef32c7afa2-1 +libxenforeignmemory1==4.11.4+107-gef32c7afa2-1 +libxengnttab1==4.11.4+107-gef32c7afa2-1 +libxenmisc4.11==4.11.4+107-gef32c7afa2-1 +libxenstore3.0==4.11.4+107-gef32c7afa2-1 +libxentoolcore1==4.11.4+107-gef32c7afa2-1 +libxentoollog1==4.11.4+107-gef32c7afa2-1 +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 +libxft-dev==2.3.2-2 +libxft2==2.3.2-2 +libxi-dev==2:1.7.9-1 +libxi6==2:1.7.9-1 +libxinerama-dev==2:1.1.4-2 +libxinerama1==2:1.1.4-2 +libxkbcommon-dev==0.8.2-1 +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+deb10u5 +libxml2-dev==2.9.4+dfsg1-7+deb10u5 +libxml2-utils==2.9.4+dfsg1-7+deb10u5 +libxmlgraphics-commons-java==2.3-1+deb10u1 +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 +libxrandr-dev==2:1.5.1-1 +libxrandr2==2:1.5.1-1 +libxrender-dev==1:0.9.10-1 +libxrender1==1:0.9.10-1 +libxshmfence-dev==1.3-1 +libxshmfence1==1.3-1 +libxslt1.1==1.1.32-2.2~deb10u2 +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 +libxtst-dev==2:1.2.3-1 +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+deb10u1 +licensecheck==3.0.31-3 +lintian==2.15.0 +linux-compiler-gcc-8-x86==4.19.269-1 +linux-headers-4.19.0-23-amd64==4.19.269-1 +linux-headers-4.19.0-23-common==4.19.269-1 +linux-headers-amd64==4.19+105+deb10u18 +linux-kbuild-4.19==4.19.269-1 +linux-libc-dev==4.19.269-1 +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 +locales==2.28-10+deb10u2 +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+deb10u1 +lynx-common==2.8.9rel.1-3+deb10u1 +m4==1.4.18-2 +make==4.2.1-1.2 +man-db==2.8.5-2 +man2html-base==1.6g-11 +manpages==4.16-2 +manpages-dev==4.16-2 +mariadb-common==1:10.3.38-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+deb10u3 +netbase==5.6 +netpbm==2:10.0-15.3+b2 +nettle-dev==3.4.1-1+deb10u1 +nftables==0.9.0-2 +ocl-icd-libopencl1==2.2.12-2 +openjade==1.4devel1-21.3+b1 +openjdk-11-jdk==11.0.18+10-1~deb10u1 +openjdk-11-jdk-headless==11.0.18+10-1~deb10u1 +openjdk-11-jre==11.0.18+10-1~deb10u1 +openjdk-11-jre-headless==11.0.18+10-1~deb10u1 +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.1n-0+deb10u4 +ovmf==0~20181115.85588389-3+deb10u3 +packagekit==1.1.12-5 +packagekit-tools==1.1.12-5 +pango1.0-tools==1.42.4-8~deb10u1 +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+deb10u2 +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.31-1~deb10u3 +php7.3-common==7.3.31-1~deb10u3 +php7.3-json==7.3.31-1~deb10u3 +php7.3-mbstring==7.3.31-1~deb10u3 +php7.3-opcache==7.3.31-1~deb10u3 +php7.3-readline==7.3.31-1~deb10u3 +php7.3-xml==7.3.31-1~deb10u3 +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+deb10u1 +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+deb10u1 +procps==2:3.3.15-2 +protobuf-compiler==3.6.1.3-2 +psmisc==23.2-1+deb10u1 +psutils==1.17.dfsg-4 +publicsuffix==20220811.1734-0+deb10u1 +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+deb10u1 +python-babel-localedata==2.6.0+dfsg.1-1+deb10u1 +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+deb10u4 +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+deb10u4 +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+deb10u3 +python-pip==18.1-5 +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+deb10u2 +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+deb10u2 +python-twisted-bin==18.9.0-3+deb10u2 +python-twisted-core==18.9.0-3+deb10u2 +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+deb10u1 +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+deb10u4 +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-mako==1.0.7+ds1-1+deb10u1 +python3-markdown==3.0.1-3 +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+deb10u3 +python3-pip==18.1-5 +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+deb10u2 +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-yaml==3.13-2 +python3.7==3.7.3-2+deb10u4 +python3.7-dbg==3.7.3-2+deb10u4 +python3.7-dev==3.7.3-2+deb10u4 +python3.7-minimal==3.7.3-2+deb10u4 +qdbus==4:4.8.7+dfsg-18+deb10u1 +qemu-kvm==1:3.1+dfsg-8+deb10u10 +qemu-system-common==1:3.1+dfsg-8+deb10u10 +qemu-system-data==1:3.1+dfsg-8+deb10u10 +qemu-system-gui==1:3.1+dfsg-8+deb10u10 +qemu-system-x86==1:3.1+dfsg-8+deb10u10 +qemu-utils==1:3.1+dfsg-8+deb10u10 +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+deb10u5 +qt5-gtk-platformtheme==5.11.3+dfsg1-1+deb10u5 +qt5-qmake==5.11.3+dfsg1-1+deb10u5 +qt5-qmake-bin==5.11.3+dfsg1-1+deb10u5 +qtbase5-dev==5.11.3+dfsg1-1+deb10u5 +qtbase5-dev-tools==5.11.3+dfsg1-1+deb10u5 +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+deb10u2 +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+deb10u4 +ruby2.5-dev==2.5.5-3+deb10u4 +ruby2.5-doc==2.5.5-3+deb10u4 +rubygems-integration==1.11+deb10u1 +sbsigntool==0.9.2-2 +seabios==1.12.0-1 +sensible-utils==0.0.12 +sgml-base==1.29 +sgml-data==2.0.11 +sgmlspl==1.03ii-36 +shared-mime-info==1.10-1 +sharutils==1:4.15.2-4 +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+deb10u2 +stgit==0.18-1 +strace==4.26-0.2 +sudo==1.8.27-1+deb10u5 +swig==3.0.12-2 +swig3.0==3.0.12-2 +systemd==241-7~deb10u9 +systemd-sysv==241-7~deb10u9 +t1utils==1.41-3 +tcl==8.6.9+1 +tcl8.6==8.6.9+dfsg-2 +teckit==2.5.8+ds2-5 +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-formats-extra==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 +texlive-xetex==2018.20190227-2 +thin-provisioning-tools==0.7.6-2.1 +time==1.7-25.1+b1 +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+deb10u3 +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+deb10u1 +vim==2:8.1.0875-5+deb10u4 +vim-common==2:8.1.0875-5+deb10u4 +vim-runtime==2:8.1.0875-5+deb10u4 +wayland-protocols==1.17-1 +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-composite-dev==1:2018.4-4 +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-input-dev==2018.4-4 +x11proto-randr-dev==2018.4-4 +x11proto-record-dev==2018.4-4 +x11proto-xext-dev==2018.4-4 +x11proto-xf86vidmode-dev==2018.4-4 +x11proto-xinerama-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~deb10u2 +xterm==344-1+deb10u2 +xtrans-dev==1.3.5-1 +xxd==2:8.1.0875-5+deb10u4 +xz-utils==5.2.4-1+deb10u1 +zip==3.0-11+b1 +zlib1g-dev==1:1.2.11.dfsg-1+deb10u2 \ No newline at end of file diff --git a/files/build/versions/dockers/sonic-slave-buster/versions-deb-buster-arm64 b/files/build/versions/dockers/sonic-slave-buster/versions-deb-buster-arm64 new file mode 100644 index 000000000000..a92f5c1f4cff --- /dev/null +++ b/files/build/versions/dockers/sonic-slave-buster/versions-deb-buster-arm64 @@ -0,0 +1,7 @@ +binutils-aarch64-linux-gnu==2.31.1-16 +libdrm-etnaviv1==2.4.97-1 +libdrm-freedreno1==2.4.97-1 +libdrm-tegra0==2.4.97-1 +libtext-iconv-perl==1.7-5+b6 +libxslt1-dev==1.1.32-2.2~deb10u2 +nodejs==14.21.3-deb-1nodesource1 \ No newline at end of file diff --git a/files/build/versions/dockers/sonic-slave-buster/versions-deb-buster-armhf b/files/build/versions/dockers/sonic-slave-buster/versions-deb-buster-armhf new file mode 100644 index 000000000000..7b62524f535c --- /dev/null +++ b/files/build/versions/dockers/sonic-slave-buster/versions-deb-buster-armhf @@ -0,0 +1,13 @@ +binutils-arm-linux-gnueabihf==2.31.1-16 +libdrm-etnaviv1==2.4.97-1 +libdrm-exynos1==2.4.97-1 +libdrm-freedreno1==2.4.97-1 +libdrm-omap1==2.4.97-1 +libdrm-tegra0==2.4.97-1 +libgles2-mesa-dev==18.3.6-2+deb10u1 +libjpeg-dev==1:1.5.2-2+deb10u1 +libjpeg62-turbo-dev==1:1.5.2-2+deb10u1 +libxslt1-dev==1.1.32-2.2~deb10u2 +linux-compiler-gcc-8-arm==4.19.269-1 +nasm==2.14-1 +nodejs==14.21.3-deb-1nodesource1 \ 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..fc08fb4cf161 --- /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.9.1 +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 +nose==1.3.7 +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 +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..a2fe8af99d4e --- /dev/null +++ b/files/build/versions/dockers/sonic-slave-buster/versions-py3 @@ -0,0 +1,78 @@ +alabaster==0.7.8 +asn1crypto==0.24.0 +async-timeout==4.0.2 +atomicwrites==1.1.5 +attrs==18.2.0 +babel==2.6.0 +bitarray==2.7.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 +importlib-metadata==6.5.0 +jinja2==3.0.3 +keyring==17.1.1 +keyrings.alt==3.1.1 +lxml==4.9.1 +m2crypto==0.38.0 +mako==1.0.7 +markdown==3.0.1 +markupsafe==2.0.1 +mmh3==2.5.1 +mock==2.0.0 +mockredispy==2.9.3 +more-itertools==4.2.0 +nose==1.3.7 +nose2==0.8.0 +olefile==0.46 +packaging==19.0 +parameterized==0.8.1 +pbr==4.2.0 +pexpect==4.8.0 +pillow==9.4.0 +pluggy==0.8.0 +ptyprocess==0.7.0 +py==1.7.0 +pyang==2.4.0 +pyangbind==0.8.1 +pycrypto==2.6.1 +pycurl==7.43.0.2 +pyfakefs==5.2.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==4.5.4 +regex==2022.10.31 +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 +typing_extensions==4.5.0 +unattended-upgrades==0.1 +unidiff==0.5.4 +urllib3==1.24.1 +zipp==3.15.0 \ 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..110a22492181 --- /dev/null +++ b/files/build/versions/dockers/sonic-slave-stretch/versions-deb-stretch @@ -0,0 +1,1500 @@ +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+deb9u1 +aspell-en==2016.11.20-0-0.1 +at==3.1.20-3 +at-spi2-core==2.22.0-6+deb9u1 +auditd==1:2.6.7-2 +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 +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+deb9u12 +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~deb9u2 +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+deb9u2 +curl==7.52.1-5+deb9u16 +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==10.2.5 +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==14 +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+deb9u12 +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 +dpkg-dev==1.18.26 +dput==0.12.1 +eatmydata==105-5 +emacsen-common==2.0.8 +equivs==2.0.9+nmu1 +exim4==4.89-2+deb9u8 +exim4-base==4.89-2+deb9u8 +exim4-config==4.89-2+deb9u8 +exim4-daemon-light==4.89-2+deb9u8 +expat==2.2.0-2+deb9u5 +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+deb9u9 +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-10~bpo9+1 +graphviz==2.38.0-17+deb9u1 +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+deb9u5 +imagemagick==8:6.9.7.4+dfsg-11+deb9u14 +imagemagick-6-common==8:6.9.7.4+dfsg-11+deb9u14 +imagemagick-6.q16==8:6.9.7.4+dfsg-11+deb9u14 +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 +jq==1.5+dfsg-1.3 +junit==3.8.2-8 +junit4==4.12-4+deb9u1 +kernel-wedge==2.96 +kmod==23-2 +krb5-locales==1.15-1+deb9u3 +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+deb9u3 +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+deb9u1 +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 +libauparse-dev==1:2.6.7-2 +libauparse0==1:2.6.7-2 +libauthen-sasl-perl==2.1600-1 +libavahi-client3==0.6.32-2+deb9u1 +libavahi-common-data==0.6.32-2+deb9u1 +libavahi-common3==0.6.32-2+deb9u1 +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+deb9u12 +libbind9-140==1:9.10.3.dfsg.P4-12.3+deb9u12 +libbison-dev==2:3.0.4.dfsg-1+b1 +libbit-vector-perl==7.4-1+b2 +libbluetooth3==5.43-2+deb9u5 +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+deb9u2 +libc-ares2==1.12.0-1+deb9u2 +libc-dev-bin==2.24-11+deb9u4 +libc-l10n==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~deb9u2 +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+deb9u1 +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+deb9u1 +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+deb9u1 +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 +libcunit1==2.1-3-dfsg-2 +libcunit1-dev==2.1-3-dfsg-2 +libcups2==2.2.1-8+deb9u8 +libcupsfilters1==1.11.6-3+deb9u1 +libcupsimage2==2.2.1-8+deb9u8 +libcurl3==7.52.1-5+deb9u16 +libcurl3-gnutls==7.52.1-5+deb9u16 +libcurl3-nss==7.52.1-5+deb9u16 +libcurl4-nss-dev==7.52.1-5+deb9u16 +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+deb9u2 +libdjvulibre21==3.5.27.1-7+deb9u2 +libdns-export162==1:9.10.3.dfsg.P4-12.3+deb9u12 +libdns162==1:9.10.3.dfsg.P4-12.3+deb9u12 +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.26 +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+deb9u1 +libdw1==0.168-1+deb9u1 +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+deb9u1 +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+deb9u5 +libexpat1-dev==2.2.0-2+deb9u5 +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+deb9u2 +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+deb9u2 +libgail-common==2.24.31-2 +libgail18==2.24.31-2 +libgbm1==13.0.6-1+b2 +libgc1c2==1:7.4.2-8+deb9u1 +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+deb9u3 +libglib2.0-bin==2.50.3-2+deb9u3 +libglib2.0-data==2.50.3-2+deb9u3 +libglib2.0-dev==2.50.3-2+deb9u3 +libglu1-mesa==9.0.0-2.1 +libglu1-mesa-dev==9.0.0-2.1 +libgmock-dev==1.8.0-10~bpo9+1 +libgmp-dev==2:6.1.2+dfsg-1+deb9u1 +libgmp10==2:6.1.2+dfsg-1+deb9u1 +libgmpxx4ldbl==2:6.1.2+dfsg-1+deb9u1 +libgnutls30==3.5.8-5+deb9u6 +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+deb9u9 +libgs9-common==9.26a~dfsg-0+deb9u9 +libgsasl7==1.8.0-8+b2 +libgssapi-krb5-2==1.15-1+deb9u3 +libgstreamer1.0-0==1.10.4-1 +libgtest-dev==1.8.0-10~bpo9+1 +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+deb9u1 +libgvpr2==2.38.0-17+deb9u1 +libhamcrest-java==1.3-6 +libharfbuzz-icu0==1.4.2-1 +libharfbuzz0b==1.4.2-1 +libhogweed4==3.3-1+deb9u1 +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+deb9u5 +libicu57==57.1-6+deb9u5 +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+deb9u12 +libisc-export160==1:9.10.3.dfsg.P4-12.3+deb9u12 +libisc160==1:9.10.3.dfsg.P4-12.3+deb9u12 +libisccc-export140==1:9.10.3.dfsg.P4-12.3+deb9u12 +libisccc140==1:9.10.3.dfsg.P4-12.3+deb9u12 +libisccfg-export140==1:9.10.3.dfsg.P4-12.3+deb9u12 +libisccfg140==1:9.10.3.dfsg.P4-12.3+deb9u12 +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+deb9u1 +libjdom1-java==1.1.3-1+deb9u1 +libjemalloc-dev==3.6.0-9.1 +libjemalloc1==3.6.0-9.1 +libjetty9-java==9.2.30-0+deb9u2 +libjline-java==1.0-2 +libjpeg62-turbo==1:1.5.1-2+deb9u2 +libjq1==1.5+dfsg-1.3 +libjs-bootstrap==3.3.7+dfsg-2+deb9u2 +libjs-jquery==3.1.1-2+deb9u2 +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+deb9u1 +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+deb9u3 +libkeyutils1==1.5.9-9 +libkmod2==23-2 +libkpathsea6==2016.20160513.41080.dfsg-2+deb9u1 +libkrb5-3==1.15-1+deb9u3 +libkrb5support0==1.15-1+deb9u3 +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+deb9u9 +libldap-common==2.4.44+dfsg-5+deb9u9 +libldap2-dev==2.4.44+dfsg-5+deb9u9 +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+deb9u2 +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+deb9u12 +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+deb9u14 +libmagickcore-6.q16-3-extra==8:6.9.7.4+dfsg-11+deb9u14 +libmagickwand-6.q16-3==8:6.9.7.4+dfsg-11+deb9u14 +libmail-sendmail-perl==0.79.16-2 +libmailtools-perl==2.18-1 +libmailutils5==1:3.1.1-1 +libmariadbclient-dev==10.1.48-0+deb9u2 +libmariadbclient-dev-compat==10.1.48-0+deb9u2 +libmariadbclient18==10.1.48-0+deb9u2 +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+deb9u1 +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+deb9u2 +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+deb9u5 +libntlm0==1.4-8+deb9u1 +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 +libonig4==6.1.3-2+deb9u2 +libopenexr22==2.2.0-11+deb9u4 +libopenjp2-7==2.1.2-1.1+deb9u7 +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+deb9u14 +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+deb9u1 +libpcap-dev==1.8.1-3+deb9u1 +libpcap0.8==1.8.1-3+deb9u1 +libpcap0.8-dev==1.8.1-3+deb9u1 +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+deb9u2 +libpolkit-backend-1-0==0.105-18+deb9u2 +libpolkit-gobject-1-0==0.105-18+deb9u2 +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+deb9u6 +libpython2.7-dev==2.7.13-2+deb9u6 +libpython2.7-minimal==2.7.13-2+deb9u6 +libpython2.7-stdlib==2.7.13-2+deb9u6 +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+deb9u5 +libpython3.5-dbg==3.5.3-1+deb9u5 +libpython3.5-dev==3.5.3-1+deb9u5 +libpython3.5-minimal==3.5.3-1+deb9u5 +libpython3.5-stdlib==3.5.3-1+deb9u5 +libqdox-java==1.12.1-2 +libqdox2-java==2.0~M3-3 +libqt4-dbus==4:4.8.7+dfsg-11+deb9u3 +libqt4-declarative==4:4.8.7+dfsg-11+deb9u3 +libqt4-designer==4:4.8.7+dfsg-11+deb9u3 +libqt4-dev==4:4.8.7+dfsg-11+deb9u3 +libqt4-dev-bin==4:4.8.7+dfsg-11+deb9u3 +libqt4-help==4:4.8.7+dfsg-11+deb9u3 +libqt4-network==4:4.8.7+dfsg-11+deb9u3 +libqt4-opengl==4:4.8.7+dfsg-11+deb9u3 +libqt4-opengl-dev==4:4.8.7+dfsg-11+deb9u3 +libqt4-qt3support==4:4.8.7+dfsg-11+deb9u3 +libqt4-script==4:4.8.7+dfsg-11+deb9u3 +libqt4-scripttools==4:4.8.7+dfsg-11+deb9u3 +libqt4-sql==4:4.8.7+dfsg-11+deb9u3 +libqt4-sql-mysql==4:4.8.7+dfsg-11+deb9u3 +libqt4-svg==4:4.8.7+dfsg-11+deb9u3 +libqt4-test==4:4.8.7+dfsg-11+deb9u3 +libqt4-xml==4:4.8.7+dfsg-11+deb9u3 +libqt4-xmlpatterns==4:4.8.7+dfsg-11+deb9u3 +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+deb9u1 +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+deb9u3 +libqtdbus4==4:4.8.7+dfsg-11+deb9u3 +libqtgui4==4:4.8.7+dfsg-11+deb9u3 +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+deb9u11 +libsasl2-2==2.1.27~101-g0780600+dfsg-3+deb9u2 +libsasl2-modules==2.1.27~101-g0780600+dfsg-3+deb9u2 +libsasl2-modules-db==2.1.27~101-g0780600+dfsg-3+deb9u2 +libsaxon-java==1:6.5.5-10 +libscalar-list-utils-perl==1:1.47-1 +libsdl1.2debian==1.2.15+dfsg1-4+deb9u1 +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+deb9u8 +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+deb9u3 +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+deb9u2 +libssl-dev==1.1.0l-1~deb9u6 +libssl1.0.2==1.0.2u-1~deb9u7 +libssl1.1==1.1.0l-1~deb9u6 +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+deb9u14 +libsystemd0==232-25+deb9u14 +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+deb9u8 +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+deb9u14 +libudev1==232-25+deb9u14 +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+deb9u1 +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+deb9u3 +libvorbisenc2==1.3.5-4+deb9u3 +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+deb9u1 +libwebpdemux2==0.5.2-1+deb9u1 +libwebpmux2==0.5.2-1+deb9u1 +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+deb9u4 +libx11-data==2:1.6.4-3+deb9u4 +libx11-dev==2:1.6.4-3+deb9u4 +libx11-doc==2:1.6.4-3+deb9u4 +libx11-protocol-perl==0.56-7 +libx11-xcb-dev==2:1.6.4-3+deb9u4 +libx11-xcb1==2:1.6.4-3+deb9u4 +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+deb9u1 +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+deb9u7 +libxml2-dev==2.9.4+dfsg1-2.2+deb9u7 +libxml2-utils==2.9.4+dfsg1-2.2+deb9u7 +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+deb9u4 +libzmq5==4.2.1-4+deb9u4 +libzzip-0-13==0.13.62-3.2~deb9u2 +licensecheck==3.0.29-1 +lintian==2.5.50.4 +linux-compiler-gcc-6-x86==4.9.320-2 +linux-headers-4.9.0-19-amd64==4.9.320-2 +linux-headers-4.9.0-19-common==4.9.320-2 +linux-headers-amd64==4.9+80+deb9u17 +linux-kbuild-4.9==4.9.320-2 +linux-libc-dev==4.9.320-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 +locales==2.24-11+deb9u4 +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+deb9u1 +lynx-common==2.8.9dev11-1+deb9u1 +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 +man2html-base==1.6g-9 +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==8u332-ga-1~deb9u1 +openjdk-8-jdk-headless==8u332-ga-1~deb9u1 +openjdk-8-jre==8u332-ga-1~deb9u1 +openjdk-8-jre-headless==8u332-ga-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~deb9u6 +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+deb9u3 +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+deb9u12 +php7.0-common==7.0.33-0+deb9u12 +php7.0-json==7.0.33-0+deb9u12 +php7.0-opcache==7.0.33-0+deb9u12 +php7.0-readline==7.0.33-0+deb9u12 +php7.0-xml==7.0.33-0+deb9u12 +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+deb9u2 +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+deb9u1 +python-babel-localedata==2.3.4+dfsg.1-2+deb9u1 +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+deb9u5 +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+deb9u4 +python-pip==9.0.1-2+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+deb9u2 +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+deb9u3 +python-twisted-bin==16.6.0-2+deb9u3 +python-twisted-core==16.6.0-2+deb9u3 +python-tz==2016.7-0.3 +python-urllib3==1.19.1-1+deb9u1 +python-webencodings==0.5-2 +python-wheel==0.29.0-2 +python-wrapt==1.9.0-2 +python-xdg==0.25-4+deb9u1 +python-zope.interface==4.3.2-1 +python2.7==2.7.13-2+deb9u6 +python2.7-dev==2.7.13-2+deb9u6 +python2.7-minimal==2.7.13-2+deb9u6 +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+deb9u1 +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+deb9u4 +python3-pip==9.0.1-2+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+deb9u2 +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+deb9u1 +python3.5==3.5.3-1+deb9u5 +python3.5-dbg==3.5.3-1+deb9u5 +python3.5-dev==3.5.3-1+deb9u5 +python3.5-minimal==3.5.3-1+deb9u5 +qdbus==4:4.8.7+dfsg-11+deb9u3 +qemu-kvm==1:2.8+dfsg-6+deb9u17 +qemu-system-common==1:2.8+dfsg-6+deb9u17 +qemu-system-x86==1:2.8+dfsg-6+deb9u17 +qemu-utils==1:2.8+dfsg-6+deb9u17 +qt-at-spi==0.4.0-5 +qt4-linguist-tools==4:4.8.7+dfsg-11+deb9u3 +qt4-qmake==4:4.8.7+dfsg-11+deb9u3 +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+deb9u3 +qttranslations5-l10n==5.7.1~20161021-1 +quilt==0.63-8 +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+deb9u3 +rsyslog==8.24.0-1+deb9u3 +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+deb9u11 +ruby2.3-dev==2.3.3-1+deb9u11 +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 +sharutils==1:4.15.2-2+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+deb9u3 +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+deb9u14 +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 +time==1.7-25.1+b1 +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+deb9u1 +vim==2:8.0.0197-4+deb9u7 +vim-common==2:8.0.0197-4+deb9u7 +vim-runtime==2:8.0.0197-4+deb9u7 +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+deb9u3 +xtrans-dev==1.3.5-1 +xxd==2:8.0.0197-4+deb9u7 +xz-utils==5.2.2-1.2+deb9u1 +zip==3.0-11+b1 +zlib1g-dev==1:1.2.8.dfsg-5+deb9u1 \ No newline at end of file diff --git a/files/build/versions/dockers/sonic-slave-stretch/versions-deb-stretch-arm64 b/files/build/versions/dockers/sonic-slave-stretch/versions-deb-stretch-arm64 new file mode 100644 index 000000000000..00f894c2df08 --- /dev/null +++ b/files/build/versions/dockers/sonic-slave-stretch/versions-deb-stretch-arm64 @@ -0,0 +1,8 @@ +docker-ce==18.06.3~ce~3-0~debian +libdrm-freedreno1==2.4.74-1 +libdrm-tegra0==2.4.74-1 +libtext-charwidth-perl==0.04-7+b3 +libtext-iconv-perl==1.7-5+b3 +libunicode-utf8-perl==0.60-1+b2 +libxslt1-dev==1.1.29-2.1+deb9u2 +nodejs==10.24.1-1nodesource1 \ No newline at end of file diff --git a/files/build/versions/dockers/sonic-slave-stretch/versions-deb-stretch-armhf b/files/build/versions/dockers/sonic-slave-stretch/versions-deb-stretch-armhf new file mode 100644 index 000000000000..598d015aab3d --- /dev/null +++ b/files/build/versions/dockers/sonic-slave-stretch/versions-deb-stretch-armhf @@ -0,0 +1,14 @@ +docker-ce==18.06.3~ce~3-0~debian +libdrm-exynos1==2.4.74-1 +libdrm-freedreno1==2.4.74-1 +libdrm-omap1==2.4.74-1 +libdrm-tegra0==2.4.74-1 +libegl1-mesa-dev==13.0.6-1+b2 +libgles2-mesa==13.0.6-1+b2 +libgles2-mesa-dev==13.0.6-1+b2 +libtext-charwidth-perl==0.04-7+b6 +libwayland-bin==1.12.0-1+deb9u1 +libwayland-dev==1.12.0-1+deb9u1 +libxslt1-dev==1.1.29-2.1+deb9u2 +linux-compiler-gcc-6-arm==4.9.320-2 +nodejs==10.24.1-1nodesource1 \ 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..893bd43f7171 --- /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.9.1 +m2crypto==0.36.0 +markupsafe==1.1.1 +mmh3==2.5.1 +mockredispy==2.9.3 +nose==1.3.7 +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 +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.10.0.0 +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..cdd2e93f7a1b --- /dev/null +++ b/files/build/versions/dockers/sonic-slave-stretch/versions-py3 @@ -0,0 +1,39 @@ +alabaster==0.7.8 +babel==2.3.4 +bitarray==2.7.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.9.1 +markupsafe==0.23 +mockredispy==2.9.3 +nose==1.3.7 +parameterized==0.8.1 +pillow==4.0.0 +pyang==2.4.0 +pyangbind==0.8.1 +pyasn1==0.1.9 +pycrypto==2.6.1 +pycurl==7.43.0 +pyfakefs==4.5.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==2022.1.18 +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-bullseye b/files/build/versions/host-base-image/versions-deb-bullseye new file mode 100644 index 000000000000..ac0f59561db9 --- /dev/null +++ b/files/build/versions/host-base-image/versions-deb-bullseye @@ -0,0 +1,96 @@ +adduser==3.118 +apt==2.2.4 +base-files==11.1+deb11u6 +base-passwd==3.5.51 +bash==5.1-2+deb11u1 +bsdutils==1:2.36.1-8+deb11u1 +coreutils==8.32-4+b1 +dash==0.5.11+git20200708+dd9ef66-5 +debconf==1.5.77 +debian-archive-keyring==2021.1.1 +debianutils==4.11.2 +diffutils==1:3.7-5 +dpkg==1.20.12 +e2fsprogs==1.46.2-2 +findutils==4.8.0-1 +gcc-10-base==10.2.1-6 +gcc-9-base==9.3.0-22 +gpgv==2.2.27-2+deb11u2 +grep==3.6-1 +gzip==1.10-4+deb11u1 +hostname==3.23 +init-system-helpers==1.60 +libacl1==2.2.53-10 +libapt-pkg6.0==2.2.4 +libattr1==1:2.4.48-6 +libaudit-common==1:3.0-2 +libaudit1==1:3.0-2 +libblkid1==2.36.1-8+deb11u1 +libbz2-1.0==1.0.8-4 +libc-bin==2.31-13+deb11u5 +libc6==2.31-13+deb11u5 +libcap-ng0==0.7.9-2.2+b1 +libcom-err2==1.46.2-2 +libcrypt1==1:4.4.18-4 +libdb5.3==5.3.28+dfsg1-0.8 +libdebconfclient0==0.260 +libext2fs2==1.46.2-2 +libffi7==3.3-6 +libgcc-s1==10.2.1-6 +libgcrypt20==1.8.7-6 +libgmp10==2:6.2.1+dfsg-1+deb11u1 +libgnutls30==3.7.1-5+deb11u2 +libgpg-error0==1.38-2 +libgssapi-krb5-2==1.18.3-6+deb11u3 +libhogweed6==3.7.3-1 +libidn2-0==2.3.0-5 +libk5crypto3==1.18.3-6+deb11u3 +libkeyutils1==1.6.1-2 +libkrb5-3==1.18.3-6+deb11u3 +libkrb5support0==1.18.3-6+deb11u3 +liblz4-1==1.9.3-2 +liblzma5==5.2.5-2.1~deb11u1 +libmount1==2.36.1-8+deb11u1 +libnettle8==3.7.3-1 +libnsl2==1.3.0-2 +libp11-kit0==0.23.22-1 +libpam-modules==1.4.0-9+deb11u1 +libpam-modules-bin==1.4.0-9+deb11u1 +libpam-runtime==1.4.0-9+deb11u1 +libpam0g==1.4.0-9+deb11u1 +libpcre2-8-0==10.36-2+deb11u1 +libpcre3==2:8.39-13 +libseccomp2==2.5.1-1+deb11u1 +libselinux1==3.1-3 +libsemanage-common==3.1-1 +libsemanage1==3.1-1+b2 +libsepol1==3.1-1 +libsmartcols1==2.36.1-8+deb11u1 +libss2==1.46.2-2 +libssl1.1==1.1.1n-0+deb11u3 +libstdc++6==10.2.1-6 +libsystemd0==247.3-7+deb11u1 +libtasn1-6==4.16.0-2+deb11u1 +libtinfo6==6.2+20201114-2 +libtirpc-common==1.3.1-1+deb11u1 +libtirpc3==1.3.1-1+deb11u1 +libudev1==247.3-7+deb11u1 +libunistring2==0.9.10-4 +libuuid1==2.36.1-8+deb11u1 +libxxhash0==0.8.0-2 +libzstd1==1.4.8+dfsg-2.1 +login==1:4.8.1-1 +logsave==1.46.2-2 +lsb-base==11.1.0 +mawk==1.3.4.20200120-2 +mount==2.36.1-8+deb11u1 +ncurses-base==6.2+20201114-2 +ncurses-bin==6.2+20201114-2 +passwd==1:4.8.1-1 +perl-base==5.32.1-4+deb11u2 +sed==4.7-1 +sysvinit-utils==2.96-7+deb11u1 +tar==1.34+dfsg-1 +tzdata==2021a-1+deb11u8 +util-linux==2.36.1-8+deb11u1 +zlib1g==1:1.2.11.dfsg-2+deb11u2 \ No newline at end of file diff --git a/files/build/versions/host-base-image/versions-deb-bullseye-arm64 b/files/build/versions/host-base-image/versions-deb-bullseye-arm64 new file mode 100644 index 000000000000..dad0cf19bbc9 --- /dev/null +++ b/files/build/versions/host-base-image/versions-deb-bullseye-arm64 @@ -0,0 +1 @@ +coreutils==8.32-4 \ No newline at end of file diff --git a/files/build/versions/host-base-image/versions-deb-bullseye-armhf b/files/build/versions/host-base-image/versions-deb-bullseye-armhf new file mode 100644 index 000000000000..dad0cf19bbc9 --- /dev/null +++ b/files/build/versions/host-base-image/versions-deb-bullseye-armhf @@ -0,0 +1 @@ +coreutils==8.32-4 \ No newline at end of file diff --git a/files/build/versions/host-image/versions-deb-bullseye b/files/build/versions/host-image/versions-deb-bullseye new file mode 100644 index 000000000000..c3e09ed42e74 --- /dev/null +++ b/files/build/versions/host-image/versions-deb-bullseye @@ -0,0 +1,428 @@ +acl==2.2.53-10 +apparmor==2.13.6-10 +apt-transport-https==2.2.4 +arping==2.21-2 +audisp-tacplus==1.0.2 +auditd==1:3.0-2 +bash-completion==1:2.11-2 +bash-tacplus==1.0.0 +bfn-modules==1.0 +binutils==2.35.2-2 +binutils-common==2.35.2-2 +binutils-x86-64-linux-gnu==2.35.2-2 +bridge-utils==1.7-1 +bsdextrautils==2.36.1-8+deb11u1 +bsdmainutils==12.1.7+nmu3 +build-essential==12.9 +busybox==1:1.30.1-6+b3 +bzip2==1.0.8-4 +ca-certificates==20210119 +cgroup-tools==0.41-11 +conntrack==1:1.4.6-2 +containerd.io==1.5.11-1 +cpio==2.13+dfsg-4 +cpp==4:10.2.1-1 +cpp-10==10.2.1-6 +cracklib-runtime==2.9.6-3.4 +cron==3.0pl1-137 +curl==7.74.0-1.3+deb11u7 +dbus==1.12.24-0+deb11u1 +device-tree-compiler==1.6.0-1 +dirmngr==2.2.27-2+deb11u2 +distro-info-data==0.51+deb11u3 +dmidecode==3.3-2 +dmsetup==2:1.02.175-2.1 +docker-ce==5:20.10.14~3-0~debian-bullseye +docker-ce-cli==5:20.10.14~3-0~debian-bullseye +dpkg-dev==1.20.12 +eatmydata==105-9 +ebtables==2.0.11-4+b1 +efibootmgr==17-1 +fdisk==2.36.1-8+deb11u1 +file==1:5.39-3 +firmware-amd-graphics==20210315-3 +firmware-linux-nonfree==20210315-3 +firmware-misc-nonfree==20210315-3 +flashrom==0.9.7 +fontconfig-config==2.13.1-4.2 +fonts-dejavu-core==2.37-2 +freeipmi-common==1.6.6-4+deb11u1 +g++==4:10.2.1-1 +g++-10==10.2.1-6 +gcc==4:10.2.1-1 +gcc-10==10.2.1-6 +gdisk==1.0.6-1.1 +gettext-base==0.21-4 +gir1.2-freedesktop==1.66.1-1+b1 +gir1.2-glib-2.0==1.66.1-1+b1 +gir1.2-packagekitglib-1.0==1.2.2-2 +gnupg==2.2.27-2+deb11u2 +gnupg-l10n==2.2.27-2+deb11u2 +gnupg-utils==2.2.27-2+deb11u2 +gnupg2==2.2.27-2+deb11u2 +gobject-introspection==1.66.1-1+b1 +gpg==2.2.27-2+deb11u2 +gpg-agent==2.2.27-2+deb11u2 +gpg-wks-client==2.2.27-2+deb11u2 +gpg-wks-server==2.2.27-2+deb11u2 +gpgconf==2.2.27-2+deb11u2 +gpgsm==2.2.27-2+deb11u2 +grub-common==2.06-3~deb11u5 +grub2-common==2.06-3~deb11u5 +haveged==1.9.14-1 +hdparm==9.60+ds-1 +hping3==3.a2.ds2-10 +hw-management==1.mlnx.7.0020.4104 +i2c-tools==4.2-1+b1 +ifmetric==0.3-5 +ifupdown2==3.0.0-1 +initramfs-tools==0.140 +initramfs-tools-core==0.140 +ipmitool==1.8.18-10.1 +iproute2==5.10.0-4 +iptables==1.8.7-1 +iptables-persistent==1.0.15 +iputils-ping==3:20210202-1 +isc-dhcp-client==4.4.1-2.3+deb11u1 +iso-codes==4.6.0-1 +jq==1.6-2.1 +kdump-tools==1:1.6.8.4 +kernel-mft-dkms-modules-5.10.0-18-2-amd64==4.22.1 +kexec-tools==1:2.0.20-2.1 +klibc-utils==2.0.8-6.1 +kmod==28-1 +less==551-2 +libabsl20200923==0~20200923.3-2 +libapparmor1==2.13.6-10 +libargon2-1==0~20171227-0.2 +libasan6==10.2.1-6 +libassuan0==2.5.3-7.1 +libatomic1==10.2.1-6 +libauparse0==1:3.0-2 +libbabeltrace1==1.5.8-1+b3 +libbinutils==2.35.2-2 +libblkid-dev==2.36.1-8+deb11u1 +libboost-serialization1.74.0==1.74.0-9 +libbpf0==1:0.3-2 +libbrotli-dev==1.0.9-2+b2 +libbrotli1==1.0.9-2+b2 +libbsd0==0.11.3-1 +libc-ares2==1.17.1-1+deb11u1 +libc-dev-bin==2.31-13+deb11u5 +libc-l10n==2.31-13+deb11u5 +libc6-dev==2.31-13+deb11u5 +libcairo-gobject2==1.16.0-5 +libcairo-script-interpreter2==1.16.0-5 +libcairo2==1.16.0-5 +libcairo2-dev==1.16.0-5 +libcap2==1:2.44-1 +libcap2-bin==1:2.44-1 +libcbor0==0.5.0+dfsg-2 +libcc1-0==10.2.1-6 +libcgroup1==0.41-11 +libcrack2==2.9.6-3.4 +libcrypt-dev==1:4.4.18-4 +libcryptsetup12==2:2.3.7-1+deb11u1 +libctf-nobfd0==2.35.2-2 +libctf0==2.35.2-2 +libcurl3-gnutls==7.74.0-1.3+deb11u7 +libcurl4==7.74.0-1.3+deb11u7 +libdbd-sqlite3-perl==1.66-1+b1 +libdbi-perl==1.643-3+b1 +libdbus-1-3==1.12.24-0+deb11u1 +libdbus-1-dev==1.12.24-0+deb11u1 +libdevmapper1.02.1==2:1.02.175-2.1 +libdns-export1110==1:9.11.19+dfsg-2.1 +libdpkg-perl==1.20.12 +libdw1==0.183-1 +libeatmydata1==105-9 +libedit2==3.1-20191231-2+b1 +libefiboot1==37-6 +libefivar1==37-6 +libelf1==0.183-1 +libestr0==0.1.10-2.1+b1 +libexpat1==2.2.10-2+deb11u5 +libexpat1-dev==2.2.10-2+deb11u5 +libfastjson4==0.99.9-1 +libfdisk1==2.36.1-8+deb11u1 +libfdt1==1.6.0-1 +libffi-dev==3.3-6 +libfido2-1==1.6.0-2 +libfontconfig-dev==2.13.1-4.2 +libfontconfig1==2.13.1-4.2 +libfontconfig1-dev==2.13.1-4.2 +libfreeipmi17==1.6.6-4+deb11u1 +libfreetype-dev==2.10.4+dfsg-1+deb11u1 +libfreetype6==2.10.4+dfsg-1+deb11u1 +libfreetype6-dev==2.10.4+dfsg-1+deb11u1 +libfuse2==2.9.9-5 +libgcc-10-dev==10.2.1-6 +libgdbm-compat4==1.19-2 +libgdbm6==1.19-2 +libgirepository-1.0-1==1.66.1-1+b1 +libgirepository1.0-dev==1.66.1-1+b1 +libglib2.0-0==2.66.8-1 +libglib2.0-bin==2.66.8-1 +libglib2.0-data==2.66.8-1 +libglib2.0-dev==2.66.8-1 +libglib2.0-dev-bin==2.66.8-1 +libgnutls30==3.7.1-5+deb11u3 +libgomp1==10.2.1-6 +libgpm2==1.20.7-8 +libgrpc++1==1.30.2-3 +libgrpc10==1.30.2-3 +libhavege2==1.9.14-1 +libhiredis0.14==0.14.0-3~bpo9+1 +libi2c0==4.2-1+b1 +libice-dev==2:1.0.10-1 +libice6==2:1.0.10-1 +libiniparser1==4.1-4 +libip4tc2==1.8.7-1 +libip6tc2==1.8.7-1 +libisc-export1105==1:9.11.19+dfsg-2.1 +libisl23==0.23-1 +libitm1==10.2.1-6 +libjansson4==2.13.1-1.1 +libjq1==1.6-2.1 +libjs-jquery==3.5.1+dfsg+~3.5.5-7 +libjs-sphinxdoc==3.4.3-2 +libjs-underscore==1.9.1~dfsg-3 +libjson-c5==0.15-2 +libklibc==2.0.8-6.1 +libkmod2==28-1 +libksba8==1.5.0-3+deb11u2 +libldap-2.4-2==2.4.57+dfsg-3+deb11u1 +liblognorm5==2.0.5-1.1 +liblsan0==10.2.1-6 +liblua5.1-0==5.1.5-8.1+b3 +liblzo2-2==2.10-2 +libmagic-mgc==1:5.39-3 +libmagic1==1:5.39-3 +libmd0==1.0.3-3 +libmnl0==1.0.4-3 +libmount-dev==2.36.1-8+deb11u1 +libmpc3==1.2.0-1 +libmpdec3==2.5.1-1 +libmpfr6==4.1.0-3 +libncurses6==6.2+20201114-2 +libncursesw6==6.2+20201114-2 +libnet1==1.1.6+dfsg-3.1 +libnetfilter-conntrack3==1.0.8-3 +libnfnetlink0==1.0.1-3+b1 +libnftnl11==1.1.9-1 +libnghttp2-14==1.43.0-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 +libnorm1==1.5.9+dfsg-2 +libnpth0==1.6-3 +libnsl-dev==1.3.0-2 +libnss-radius==1.0.1-1 +libnss-tacplus==1.0.4-1 +libnuma1==2.0.12-1+b1 +libonig5==6.9.6-1.1 +libopencsd0==0.14.4-1 +libopts25==1:5.18.16-4 +libpackagekit-glib2-18==1.2.2-2 +libpam-cracklib==1.4.0-9+deb11u1 +libpam-radius-auth==1.4.1-1 +libpam-tacplus==1.4.1-1 +libpcap0.8==1.10.0-2 +libpci3==1:3.7.0-5 +libpcre16-3==2:8.39-13 +libpcre2-16-0==10.36-2+deb11u1 +libpcre2-32-0==10.36-2+deb11u1 +libpcre2-dev==10.36-2+deb11u1 +libpcre2-posix2==10.36-2+deb11u1 +libpcre3-dev==2:8.39-13 +libpcre32-3==2:8.39-13 +libpcrecpp0v5==2:8.39-13 +libperl5.32==5.32.1-4+deb11u2 +libpgm-5.3-0==5.3.128~dfsg-2 +libpixman-1-0==0.40.0-1.1~deb11u1 +libpixman-1-dev==0.40.0-1.1~deb11u1 +libpng-dev==1.6.37-3 +libpng16-16==1.6.37-3 +libpopt0==1.18-2 +libprocps8==2:3.3.17-5 +libprotobuf23==3.12.4-1 +libpsl5==0.21.0-1.2 +libpthread-stubs0-dev==0.4-1 +libpython3-dev==3.9.2-3 +libpython3-stdlib==3.9.2-3 +libpython3.9==3.9.2-1 +libpython3.9-dev==3.9.2-1 +libpython3.9-minimal==3.9.2-1 +libpython3.9-stdlib==3.9.2-1 +libquadmath0==10.2.1-6 +libreadline8==8.1-1 +librtmp1==2.4+20151223.gitfa8646d.1-2+b2 +libsasl2-2==2.1.27+dfsg-2.1+deb11u1 +libsasl2-modules-db==2.1.27+dfsg-2.1+deb11u1 +libselinux1-dev==3.1-3 +libsensors-config==1:3.6.0-7 +libsensors5==1:3.6.0-7 +libsepol1-dev==3.1-1 +libslang2==2.3.2-5 +libsm-dev==2:1.2.3-1 +libsm6==2:1.2.3-1 +libsodium23==1.0.18-1 +libsqlite3-0==3.34.1-3 +libssh2-1==1.9.0-2 +libssl-dev==1.1.1n-0+deb11u4+fips +libssl1.1==1.1.1n-0+deb11u4+fips +libstdc++-10-dev==10.2.1-6 +libswsscommon==1.0.0 +libsysfs2==2.1.0+repack-7 +libsystemd-dev==247.3-7+deb11u1 +libtac2==1.4.1-1 +libtcl8.6==8.6.11+dfsg-1 +libtirpc-dev==1.3.1-1+deb11u1 +libtsan0==10.2.1-6 +libubootenv-tool==0.3.2-0.1 +libubootenv0.1==0.3.2-0.1 +libubsan1==10.2.1-6 +libunwind8==1.3.2-2 +libusb-1.0-0==2:1.0.24-3 +libutempter0==1.2.1-2 +libwrap0==7.6.q-31 +libx11-6==2:1.7.2-1 +libx11-data==2:1.7.2-1 +libx11-dev==2:1.7.2-1 +libxau-dev==1:1.0.9-1 +libxau6==1:1.0.9-1 +libxcb-render0==1.14-3 +libxcb-render0-dev==1.14-3 +libxcb-shm0==1.14-3 +libxcb-shm0-dev==1.14-3 +libxcb1==1.14-3 +libxcb1-dev==1.14-3 +libxdmcp-dev==1:1.1.2-3 +libxdmcp6==1:1.1.2-3 +libxext-dev==2:1.3.3-1.1 +libxext6==2:1.3.3-1.1 +libxrender-dev==1:0.9.10-1 +libxrender1==1:0.9.10-1 +libxtables12==1.8.7-1 +libyaml-0-2==0.2.2-1 +libyang==1.0.73 +libyang-cpp==1.0.73 +libzmq5==4.3.4-1 +linux-base==4.6 +linux-image-5.10.0-18-2-amd64-unsigned==5.10.140-1 +linux-libc-dev==5.10.162-1 +linux-perf==5.10.162-1 +linux-perf-5.10==5.10.162-1 +locales==2.31-13+deb11u5 +logrotate==3.18.0-2+deb11u1 +lsb-release==11.1.0 +lsof==4.93.2+dfsg-1.1 +make==4.3-4.1 +makedev==2.3.1-94.1 +makedumpfile==1:1.6.8-4 +media-types==4.0.0 +mft==4.22.1-15 +mft-oem==4.22.1-15 +monit==1:5.20.0-6 +mtd-utils==1:2.1.2-2 +mtr-tiny==0.94-1+deb11u1 +ncal==12.1.7+nmu3 +ndisc6==1.0.4-2 +net-tools==1.60+git20181103.0eebece-1 +netbase==6.3 +netfilter-persistent==1.0.15 +ntp==1:4.2.8p15+dfsg-1+deb10u2 +ntpstat==0.0.0.1-2+b1 +opennsl-modules==7.1.0.0 +openssh-client==1:8.4p1-5+deb11u1+fips +openssh-server==1:8.4p1-5+deb11u1+fips +openssh-sftp-server==1:8.4p1-5+deb11u1+fips +openssl==1.1.1n-0+deb11u4+fips +patch==2.7.6-7 +pci.ids==0.0~2021.02.08-1 +pciutils==1:3.7.0-5 +perl==5.32.1-4+deb11u2 +perl-modules-5.32==5.32.1-4+deb11u2 +picocom==3.1-2+b1 +pinentry-curses==1.1.0-4 +pkg-config==0.29.2-1 +procps==2:3.3.17-5 +psmisc==23.4-2 +python-apt-common==2.2.1 +python-is-python3==3.9.2-1 +python-pip-whl==20.3.4-4+deb11u1 +python3==3.9.2-3 +python3-apt==2.2.1 +python3-dbus==1.2.16-5 +python3-dev==3.9.2-3 +python3-distutils==3.9.2-1 +python3-gi==3.38.0-2 +python3-lib2to3==3.9.2-1 +python3-mako==1.1.3+ds1-2 +python3-markdown==3.3.4-1 +python3-markupsafe==1.1.1-1+b3 +python3-minimal==3.9.2-3 +python3-pip==20.3.4-4+deb11u1 +python3-pkg-resources==52.0.0-4 +python3-pycurl==7.43.0.6-5 +python3-setuptools==52.0.0-4 +python3-software-properties==0.96.20.2-2.1 +python3-swsscommon==1.0.0 +python3-wheel==0.34.2-1 +python3-yang==1.0.73 +python3.9==3.9.2-1 +python3.9-dev==3.9.2-1 +python3.9-minimal==3.9.2-1 +rasdaemon==0.6.6-2 +readline-common==8.1-1 +resolvconf==1.87 +rsync==3.2.3-4+deb11u1 +rsyslog==8.2302.0-1~bpo11+1 +runit-helper==2.10.3 +screen==4.8.0-6 +sensible-utils==0.0.14 +smartmontools==7.2-1 +software-properties-common==0.96.20.2-2.1 +sonic-db-cli==1.0.0 +sonic-device-data==1.0-1 +sonic-host-services-data==1.0-1 +sonic-platform-pddf==1.1 +sonic-rsyslog-plugin==1.0.0-0 +sonic-utilities-data==1.0-1 +sqlite3==3.34.1-3 +squashfs-tools==1:4.4-2+deb11u2 +sudo==1.9.5p2-3+deb11u1 +swig==4.0.2-1 +swig4.0==4.0.2-1 +sx-kernel==1.mlnx.4.5.4206 +symcrypt-openssl==0.1 +sysfsutils==2.1.0+repack-7 +sysstat==12.5.2-2 +systemd==247.3-7+deb11u1 +systemd-bootchart==234-1 +systemd-sonic-generator==1.0.0 +systemd-sysv==247.3-7+deb11u1 +tcpdump==4.99.0-2+deb11u1 +tcptraceroute==1.5beta7+debian-4.1+b1 +traceroute==1:2.1.0-2+b1 +tzdata==2021a-1+deb11u9 +u-boot-tools==2021.01+dfsg-5 +ucf==3.0043 +udev==247.3-7+deb11u1 +unzip==6.0-26+deb11u1 +usbutils==1:013-3 +uuid-dev==2.36.1-8+deb11u1 +vim==2:8.2.2434-3+deb11u1 +vim-common==2:8.2.2434-3+deb11u1 +vim-runtime==2:8.2.2434-3+deb11u1 +wamerican==2019.10.06-1 +x11-common==1:7.7+22 +x11proto-dev==2020.1-1 +x11proto-xext-dev==2020.1-1 +xorg-sgml-doctools==1:1.11-1.1 +xtrans-dev==1.4.0-1 +xxd==2:8.2.2434-3+deb11u1 +xz-utils==5.2.5-2.1~deb11u1 +zlib1g-dev==1:1.2.11.dfsg-2+deb11u2 \ No newline at end of file diff --git a/files/build/versions/host-image/versions-deb-bullseye-arm64 b/files/build/versions/host-image/versions-deb-bullseye-arm64 new file mode 100644 index 000000000000..b60fc1dd7aa8 --- /dev/null +++ b/files/build/versions/host-image/versions-deb-bullseye-arm64 @@ -0,0 +1,14 @@ +binutils-aarch64-linux-gnu==2.35.2-2 +ebtables==2.0.11-4 +icu-devtools==67.1-7 +libicu-dev==67.1-7 +libicu67==67.1-7 +libxml2==2.9.10+dfsg-6.7+deb11u3 +libxml2-dev==2.9.10+dfsg-6.7+deb11u3 +libxslt1-dev==1.1.34-4+deb11u1 +libxslt1.1==1.1.34-4+deb11u1 +linux-image-5.10.0-18-2-arm64-unsigned==5.10.140-1 +ntpstat==0.0.0.1-2 +picocom==3.1-2 +traceroute==1:2.1.0-2 +tsingma-bsp==1.0 \ No newline at end of file diff --git a/files/build/versions/host-image/versions-deb-bullseye-armhf b/files/build/versions/host-image/versions-deb-bullseye-armhf new file mode 100644 index 000000000000..5eb240a792fa --- /dev/null +++ b/files/build/versions/host-image/versions-deb-bullseye-armhf @@ -0,0 +1,20 @@ +binutils-arm-linux-gnueabihf==2.35.2-2 +ebtables==2.0.11-4 +icu-devtools==67.1-7 +libicu-dev==67.1-7 +libicu67==67.1-7 +libssl-dev==1.1.1n-0+deb11u4 +libssl1.1==1.1.1n-0+deb11u4 +libxml2==2.9.10+dfsg-6.7+deb11u3 +libxml2-dev==2.9.10+dfsg-6.7+deb11u3 +libxslt1-dev==1.1.34-4+deb11u1 +libxslt1.1==1.1.34-4+deb11u1 +linux-image-5.10.0-18-2-armmp==5.10.140-1 +mrvlprestera==1.0 +ntpstat==0.0.0.1-2 +openssh-client==1:8.4p1-5+deb11u1 +openssh-server==1:8.4p1-5+deb11u1 +openssh-sftp-server==1:8.4p1-5+deb11u1 +openssl==1.1.1n-0+deb11u4 +picocom==3.1-2 +traceroute==1:2.1.0-2 \ 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..0f531ed4ac96 --- /dev/null +++ b/files/build/versions/host-image/versions-py3 @@ -0,0 +1,71 @@ +azure-common==1.1.28 +azure-nspkg==3.0.2 +azure-storage==0.36.0 +bitarray==1.5.3 +blessed==1.20.0 +certifi==2022.12.7 +cffi==1.15.1 +charset-normalizer==3.1.0 +click==7.0 +click-log==0.4.0 +colorful==0.5.5 +cryptography==40.0.2 +dbus-python==1.2.16 +docker==5.0.3 +docker-image-py==0.1.12 +enlighten==1.11.2 +filelock==3.12.0 +grpcio==1.39.0 +grpcio-tools==1.39.0 +idna==3.4 +ijson==2.6.1 +ipaddr==2.2.0 +ipaddress==1.0.23 +j2cli==0.3.10 +jinja2==3.1.2 +jsondiff==2.0.0 +jsonpatch==1.32 +jsonpointer==2.3 +jsonschema==2.6.0 +lazy-object-proxy==1.9.0 +lxml==4.9.1 +m2crypto==0.38.0 +markupsafe==2.1.2 +natsort==6.2.1 +netaddr==0.8.0 +netifaces==0.11.0 +pathtools==0.1.2 +pddf-platform==1.0 +pexpect==4.8.0 +prefixed==0.7.0 +prettyprinter==0.18.0 +protobuf==3.20.3 +psutil==5.9.5 +ptyprocess==0.7.0 +pyang==2.5.3 +pyangbind==0.8.1 +pycairo==1.23.0 +pycparser==2.21 +pycurl==7.43.0.6 +pygments==2.15.1 +pygobject==3.44.1 +pyroute2==0.5.19 +python-apt==2.2.1 +python-dateutil==2.8.2 +pyyaml==5.4.1 +redis==3.5.3 +regex==2023.3.23 +requests==2.28.2 +scapy==2.4.4 +semantic-version==2.10.0 +six==1.16.0 +systemd-python==235 +tabulate==0.8.2 +thrift==0.13.0 +toposort==1.6 +urllib3==1.26.15 +watchdog==0.10.3 +wcwidth==0.2.6 +websocket-client==1.5.1 +www-authenticate==0.9.2 +xmltodict==0.12.0 \ No newline at end of file diff --git a/files/build/versions/host-image/versions-py3-all-armhf b/files/build/versions/host-image/versions-py3-all-armhf new file mode 100644 index 000000000000..431dc5a43838 --- /dev/null +++ b/files/build/versions/host-image/versions-py3-all-armhf @@ -0,0 +1 @@ +cryptography==3.3.1 \ No newline at end of file diff --git a/files/build_scripts/mask_disabled_services.py b/files/build_scripts/mask_disabled_services.py index 5c1a3695802f..291b8d7e0748 100755 --- a/files/build_scripts/mask_disabled_services.py +++ b/files/build_scripts/mask_disabled_services.py @@ -4,10 +4,20 @@ import subprocess INIT_CFG_FILE_PATH = '/etc/sonic/init_cfg.json' +WARM_OR_FAST_BOOT_DATAPLANE_NEEDED_SERVICES = ['database', 'swss', 'syncd', 'teamd', 'bgp'] with open(INIT_CFG_FILE_PATH) as init_cfg_file: init_cfg = json.load(init_cfg_file) if 'FEATURE' in init_cfg: for feature_name, feature_props in init_cfg['FEATURE'].items(): - if 'state' in feature_props and feature_props['state'] != 'enabled' and feature_props['state'] != 'always_enabled': - subprocess.run(['systemctl', 'mask', '{}.service'.format(feature_name)]) + # For warm/fast boot we want to have all crtical dataplane needed service + # to start immediately before hostcfgd can render `state` field unless the `state` field is marked disabled + # explicitly during build time rendering of init_cfg.json + if feature_name in WARM_OR_FAST_BOOT_DATAPLANE_NEEDED_SERVICES: + if 'state' in feature_props and (feature_props['state'] == 'disabled' or feature_props['state'] == 'always_disabled'): + subprocess.run(['systemctl', 'mask', '{}.service'.format(feature_name)]) + # For other services by default mask out the service if not enable explicitly. This service can get enable later on when + # hostcfgd render the state as enable. This should not cause dataplane impact. + else: + if 'state' in feature_props and feature_props['state'] != 'enabled' and feature_props['state'] != 'always_enabled': + subprocess.run(['systemctl', 'mask', '{}.service'.format(feature_name)]) diff --git a/files/build_templates/arp_update_vars.j2 b/files/build_templates/arp_update_vars.j2 index 91992e781ac0..d17f17ac8847 100644 --- a/files/build_templates/arp_update_vars.j2 +++ b/files/build_templates/arp_update_vars.j2 @@ -4,5 +4,6 @@ "pc_interface" : "{% for (name, prefix) in PORTCHANNEL_INTERFACE|pfx_filter %}{% if prefix|ipv6 %}{{ name }} {% endif %}{% endfor %}", "vlan_sub_interface": "{% for (name, prefix) in VLAN_SUB_INTERFACE|pfx_filter %}{% if prefix|ipv6 %}{{ name }} {% endif %}{% endfor %}", "vlan" : "{% if VLAN %}{{ VLAN.keys() | join(' ') }}{% endif %}", - "static_route_nexthops": "{% if STATIC_ROUTE %}{% for static_route_prefix, static_route_attr in STATIC_ROUTE.items() %}{%- if static_route_prefix -%}{{ static_route_attr['nexthop'].split(',') | join(' ') | lower + " " }}{%- endif -%}{% endfor %}{% endif %}" + "static_route_nexthops": "{% if STATIC_ROUTE %}{% for static_route_prefix, static_route_attr in STATIC_ROUTE.items() %}{%- if static_route_prefix -%}{{ static_route_attr['nexthop'].split(',') | join(' ') | lower + " " }}{%- endif -%}{% endfor %}{% endif %}", + "static_route_ifnames": "{% if STATIC_ROUTE %}{% for static_route_prefix, static_route_attr in STATIC_ROUTE.items() %}{%- if static_route_prefix and 'ifname' in static_route_attr -%}{{ static_route_attr['ifname'].split(',') | join(' ') + " " }}{%- endif -%}{% endfor %}{% endif %}" } diff --git a/files/build_templates/buffers_config.j2 b/files/build_templates/buffers_config.j2 index f15e54b55136..444458a05479 100644 --- a/files/build_templates/buffers_config.j2 +++ b/files/build_templates/buffers_config.j2 @@ -47,6 +47,9 @@ def {%- if DEVICE_NEIGHBOR_METADATA is defined and DEVICE_NEIGHBOR_METADATA[DEVICE_NEIGHBOR[local_port].name] %} {%- set neighbor = DEVICE_NEIGHBOR_METADATA[DEVICE_NEIGHBOR[local_port].name] %} {%- set neighbor_role = neighbor.type %} + {%- if 'edgezoneaggregator' == neighbor_role | lower %} + {%- set neighbor_role = 'LeafRouter' %} + {%- endif %} {%- if 'asic' == neighbor_role | lower %} {%- set roles1 = 'internal' %} {%- if 'internal' not in ports2cable %} diff --git a/files/build_templates/build_docker_cache.j2 b/files/build_templates/build_docker_cache.j2 new file mode 100644 index 000000000000..9f1d0eebf77f --- /dev/null +++ b/files/build_templates/build_docker_cache.j2 @@ -0,0 +1,11 @@ +# Base docker build +FROM {{IMAGENAME}} + +# Copy the cache data to host +From scratch as output +COPY --from={{IMAGENAME}} /cache.tgz cache.tgz + +# Clean up the cache data +FROM {{IMAGENAME}} as final +RUN rm /cache.tgz + diff --git a/files/build_templates/docker_image_ctl.j2 b/files/build_templates/docker_image_ctl.j2 index ace39df4e546..ec94fd420303 100644 --- a/files/build_templates/docker_image_ctl.j2 +++ b/files/build_templates/docker_image_ctl.j2 @@ -34,16 +34,27 @@ function updateSyslogConf() # Also update the container name if [[ ($NUM_ASIC -gt 1) ]]; then TARGET_IP=$(docker network inspect bridge --format={{ "'{{(index .IPAM.Config 0).Gateway}}'" }}) - CONTAINER_NAME="$DOCKERNAME" - TMP_FILE="/tmp/rsyslog.$CONTAINER_NAME.conf" - {%- if docker_container_name == "database" %} - python -c "import jinja2, os; paths=['/usr/share/sonic/templates']; loader = jinja2.FileSystemLoader(paths); env = jinja2.Environment(loader=loader, trim_blocks=True); template_file='/usr/share/sonic/templates/rsyslog-container.conf.j2'; template = env.get_template(os.path.basename(template_file)); data=template.render({\"target_ip\":\"$TARGET_IP\",\"container_name\":\"$CONTAINER_NAME\"}); print(data)" > $TMP_FILE - {%- else %} - sonic-cfggen -t /usr/share/sonic/templates/rsyslog-container.conf.j2 -a "{\"target_ip\": \"$TARGET_IP\", \"container_name\": \"$CONTAINER_NAME\" }" > $TMP_FILE - {%- endif %} - docker cp $TMP_FILE ${DOCKERNAME}:/etc/rsyslog.conf - rm -rf $TMP_FILE + else + if [ "$CONTAINER_EXISTS" = "yes" ]; then + # database configuration has been synced to /etc/rsyslog.conf + # no need generate it to save boot time + return + fi + TARGET_IP="127.0.0.1" + fi + CONTAINER_NAME="$DOCKERNAME" + TMP_FILE="/tmp/rsyslog.$CONTAINER_NAME.conf" + {%- if docker_container_name == "database" %} + python -c "import jinja2, os; paths=['/usr/share/sonic/templates']; loader = jinja2.FileSystemLoader(paths); env = jinja2.Environment(loader=loader, trim_blocks=True); template_file='/usr/share/sonic/templates/rsyslog-container.conf.j2'; template = env.get_template(os.path.basename(template_file)); data=template.render({\"target_ip\":\"$TARGET_IP\",\"container_name\":\"$CONTAINER_NAME\"}); print(data)" > $TMP_FILE + {%- else %} + sonic-cfggen -d -t /usr/share/sonic/templates/rsyslog-container.conf.j2 -a "{\"target_ip\": \"$TARGET_IP\", \"container_name\": \"$CONTAINER_NAME\" }" > $TMP_FILE + if [ $? -ne 0 ]; then + echo "Error: Execute sonic-cfggen -d failed. Execute without '-d'." + sonic-cfggen -t /usr/share/sonic/templates/rsyslog-container.conf.j2 -a "{\"target_ip\": \"$TARGET_IP\", \"container_name\": \"$CONTAINER_NAME\" }" > $TMP_FILE fi + {%- endif %} + docker cp $TMP_FILE ${DOCKERNAME}:/etc/rsyslog.conf + rm -rf $TMP_FILE } function ebtables_config() { @@ -308,6 +319,29 @@ start() { source $PLATFORM_ENV_CONF fi + {%- if sonic_asic_platform == "broadcom" %} + {%- if docker_container_name == "syncd" %} + # Set the SYNCD_SHM_SIZE if this variable not defined + BRCM_PLATFORM_COMMON_DIR=/usr/share/sonic/device/x86_64-broadcom_common + SYNCD_SHM_INI=$BRCM_PLATFORM_COMMON_DIR/syncd_shm.ini + + readline=$(grep '0x14e4' /proc/linux-kernel-bde) + bcm_chip_id=${readline#*0x14e4:0x} + bcm_chip_id=${bcm_chip_id::3} + + if [ -z "$SYNCD_SHM_SIZE" ]; then + if [ -z "$bcm_chip_id" ]; then + echo "Cannot get Broadcom Chip Id. Skip set SYNCD_SHM_SIZE." + elif [ -f "$SYNCD_SHM_INI" ] && [ "$(grep -m1 "^${bcm_chip_id}=" $SYNCD_SHM_INI)" ]; then + SYNCD_SHM_SIZE=`grep -m1 "^${bcm_chip_id}=" $SYNCD_SHM_INI | awk -F= '{print $2}'` + else + echo "Cannot get SYNCD_SHM_SIZE for chip: [${bcm_chip_id}] in $SYNCD_SHM_INI. Skip set SYNCD_SHM_SIZE." + fi + + fi + {%- endif %} + {%- endif %} + {%- if docker_container_name == "gbsyncd" %} GBSYNCD_CONF=/usr/share/sonic/device/$PLATFORM/gbsyncd.ini GBSYNCD_PLATFORM=gbsyncd-vs @@ -342,6 +376,7 @@ start() { DOCKERMOUNT=`getMountPoint "$DOCKERCHECK"` {%- endif %} if [ x"$DOCKERMOUNT" == x"$MOUNTPATH" ]; then + CONTAINER_EXISTS="yes" preStartAction {%- if docker_container_name == "database" %} echo "Starting existing ${DOCKERNAME} container" @@ -495,6 +530,7 @@ start() { -v mlnx_sdk_socket:/var/run/sx_sdk \ -v mlnx_sdk_ready:/tmp \ -v /dev/shm:/dev/shm:rw \ + -v /var/log/sai_failure_dump:/var/log/sai_failure_dump:rw \ -e SX_API_SOCKET_FILE=/var/run/sx_sdk/sx_api.sock \ {%- elif docker_container_name == "pmon" %} -v /var/run/hw-management:/var/run/hw-management:rw \ @@ -536,6 +572,7 @@ start() { {%- endif %} $REDIS_MNT \ -v /usr/share/sonic/device/$PLATFORM:/usr/share/sonic/platform:ro \ + -v /usr/share/sonic/templates/rsyslog-container.conf.j2:/usr/share/sonic/templates/rsyslog-container.conf.j2:ro \ {%- if sonic_asic_platform != "mellanox" %} {%- if mount_default_tmpfs|default("n") == "y" %} --tmpfs /tmp \ @@ -547,6 +584,7 @@ start() { --env "NAMESPACE_ID"="$DEV" \ --env "NAMESPACE_PREFIX"="$NAMESPACE_PREFIX" \ --env "NAMESPACE_COUNT"=$NUM_ASIC \ + --env "CONTAINER_NAME"=$DOCKERNAME \ --name=$DOCKERNAME \ {%- if docker_container_name == "gbsyncd" %} -v /var/run/docker-syncd$DEV:/var/run/sswsyncd \ @@ -617,6 +655,7 @@ fi {%- endif %} NAMESPACE_PREFIX="asic" DOCKERNAME=$DOCKERNAME$DEV +CONTAINER_EXISTS="no" if [ "$DEV" ]; then NET_NS="$NAMESPACE_PREFIX$DEV" #name of the network namespace @@ -639,4 +678,4 @@ case "$1" in echo "Usage: $0 {start namespace(optional)|wait namespace(optional)|stop namespace(optional)}" exit 1 ;; -esac +esac \ No newline at end of file diff --git a/files/build_templates/init_cfg.json.j2 b/files/build_templates/init_cfg.json.j2 index c0fc08e86e2e..39e180a1179d 100644 --- a/files/build_templates/init_cfg.json.j2 +++ b/files/build_templates/init_cfg.json.j2 @@ -37,12 +37,12 @@ ("lldp", "enabled", true, "enabled"), ("pmon", "enabled", true, "enabled"), ("pmon", "enabled", false, "enabled"), - ("radv", "enabled", false, "enabled"), ("snmp", "enabled", true, "enabled"), ("eventd", "enabled", false, "enabled"), ("swss", "enabled", false, "enabled"), - ("syncd", "enabled", false, "enabled"), - ("teamd", "{% if not DEVICE_RUNTIME_METADATA['ETHERNET_PORTS_PRESENT'] %}disabled{% else %}enabled{% endif %}", false, "enabled")] %} + ("syncd", "enabled", false, "enabled")] %} +{%- if include_router_advertiser == "y" %}{% do features.append(("radv", "enabled", false, "enabled")) %}{% endif %} +{%- if include_teamd == "y" %}{% do features.append(("teamd", "{% if not DEVICE_RUNTIME_METADATA['ETHERNET_PORTS_PRESENT'] %}disabled{% else %}enabled{% endif %}", false, "enabled")) %}{% endif %} {% do features.append(("dhcp_relay", "{% if not (DEVICE_METADATA is defined and DEVICE_METADATA['localhost'] is defined and DEVICE_METADATA['localhost']['type'] is defined and DEVICE_METADATA['localhost']['type'] is not in ['ToRRouter', 'EPMS', 'MgmtTsToR', 'MgmtToRRouter', 'BmcMgmtToRRouter']) %}enabled{% else %}disabled{% endif %}", false, "enabled")) %} {%- if sonic_asic_platform == "vs" %}{% do features.append(("gbsyncd", "enabled", false, "enabled")) %}{% endif %} {%- if include_iccpd == "y" %}{% do features.append(("iccpd", "disabled", false, "enabled")) %}{% endif %} @@ -67,6 +67,7 @@ "has_per_asic_scope": {% if feature + '@.service' in installer_services.split(' ') %}"True"{% else %}"False"{% endif %}, {%- endif %} "auto_restart": "{{autorestart}}", + "support_syslog_rate_limit" : "true", {# Set check_up_status to true here when app readiness will be marked in state db #} {# For now, to support the infrastrucure, setting the check_up_status to false for bgp,swss,pmon #} {# Once apps like bgp,synd supports app readiness, then bgp,syncd can set check_up_status to true #} @@ -103,6 +104,20 @@ "rate_limit_interval" : "600", "available_mem_threshold": "10.0" }{%if not loop.last %},{% endif -%} +{% endfor %} + }, + "SYSLOG_CONFIG": { + "GLOBAL": { + "rate_limit_interval" : "0", + "rate_limit_burst" : "0" + } + }, + "SYSLOG_CONFIG_FEATURE": { +{%- for feature, _, _, _ in features %} + "{{feature}}": { + "rate_limit_interval" : "300", + "rate_limit_burst": "20000" + }{%if not loop.last %},{% endif -%} {% endfor %} }, "PASSW_HARDENING": { @@ -118,5 +133,16 @@ "digits_class": "true", "special_class": "true" } + }, + "SYSTEM_DEFAULTS" : { +{%- if include_mux == "y" %} + "mux_tunnel_egress_acl": { +{%- if sonic_asic_platform == "mellanox" %} + "status": "enabled" +{% else %} + "status": "disabled" +{% endif %} + } +{% endif %} } } diff --git a/files/build_templates/manifest.json.j2 b/files/build_templates/manifest.json.j2 index dff92ac21634..3deac2285e9c 100644 --- a/files/build_templates/manifest.json.j2 +++ b/files/build_templates/manifest.json.j2 @@ -28,6 +28,9 @@ "fast-shutdown": { "after": {{ fast_shutdown_after.split()|json if fast_shutdown_after is defined else [] }}, "before": {{ fast_shutdown_before.split()|json if fast_shutdown_before is defined else [] }} + }, + "syslog": { + "support-rate-limit": {{ support_rate_limit if support_rate_limit else 'true' }} } }, "container": { diff --git a/files/build_templates/per_namespace/swss.service.j2 b/files/build_templates/per_namespace/swss.service.j2 index 765bee8a7ac0..58bca6a219a6 100644 --- a/files/build_templates/per_namespace/swss.service.j2 +++ b/files/build_templates/per_namespace/swss.service.j2 @@ -11,7 +11,6 @@ Requires=opennsl-modules.service {% endif %} Requires=updategraph.service After=updategraph.service -After=interfaces-config.service BindsTo=sonic.target After=sonic.target Before=ntp-config.service diff --git a/files/build_templates/per_namespace/syncd.service.j2 b/files/build_templates/per_namespace/syncd.service.j2 index 9acf97c29fd4..b509e7732cfd 100644 --- a/files/build_templates/per_namespace/syncd.service.j2 +++ b/files/build_templates/per_namespace/syncd.service.j2 @@ -16,7 +16,6 @@ After=nps-modules.service {% endif %} Requires=updategraph.service After=updategraph.service -After=interfaces-config.service BindsTo=sonic.target After=sonic.target Before=ntp-config.service diff --git a/files/build_templates/qos_config.j2 b/files/build_templates/qos_config.j2 index aeba03f595cf..4695b51459cc 100644 --- a/files/build_templates/qos_config.j2 +++ b/files/build_templates/qos_config.j2 @@ -240,13 +240,25 @@ {% if 'type' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['type'] in backend_device_types and 'storage_device' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['storage_device'] == 'true' %} "dot1p_to_tc_map" : "AZURE", {% else %} -{% if different_dscp_to_tc_map and port not in port_names_list_extra_queues and tunnel_qos_remap_enable %} +{# Apply separated DSCP_TO_TC_MAP to uplink ports on ToR and Leaf #} +{% if different_dscp_to_tc_map and tunnel_qos_remap_enable %} +{% if ('type' in DEVICE_METADATA['localhost']) and (DEVICE_METADATA['localhost']['type'] == 'LeafRouter') and (port not in port_names_list_extra_queues) %} "dscp_to_tc_map" : "AZURE_UPLINK", +{% elif ('subtype' in DEVICE_METADATA['localhost']) and (DEVICE_METADATA['localhost']['subtype'] == 'DualToR') and (port in port_names_list_extra_queues) %} + "dscp_to_tc_map" : "AZURE_UPLINK", +{% else %} + "dscp_to_tc_map" : "AZURE", +{% endif %} {% else %} "dscp_to_tc_map" : "AZURE", {% endif %} {% endif %} +{# Apply separated TC_TO_QUEUE_MAP to uplink ports on ToR #} +{% if different_tc_to_queue_map and tunnel_qos_remap_enable and port in port_names_list_extra_queues %} + "tc_to_queue_map" : "AZURE_UPLINK", +{% else %} "tc_to_queue_map" : "AZURE", +{% endif %} "tc_to_pg_map" : "AZURE", "pfc_to_queue_map": "AZURE", {% if asic_type in pfc_to_pg_map_supported_asics %} diff --git a/files/build_templates/sonic_debian_extension.j2 b/files/build_templates/sonic_debian_extension.j2 index 85eb73c11675..25cc6f2e91dd 100644 --- a/files/build_templates/sonic_debian_extension.j2 +++ b/files/build_templates/sonic_debian_extension.j2 @@ -398,6 +398,8 @@ sudo cp -f $IMAGE_CONFIGS/logrotate/logrotate.d/* $FILESYSTEM_ROOT/etc/logrotate sudo cp $IMAGE_CONFIGS/logrotate/rsyslog.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/ sudo cp $IMAGE_CONFIGS/logrotate/logrotate-config.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM sudo cp $IMAGE_CONFIGS/logrotate/logrotate-config.sh $FILESYSTEM_ROOT/usr/bin/ +sudo mkdir -p $FILESYSTEM_ROOT/etc/systemd/system/logrotate.timer.d +sudo cp $IMAGE_CONFIGS/logrotate/timerOverride.conf $FILESYSTEM_ROOT/etc/systemd/system/logrotate.timer.d/ echo "logrotate-config.service" | sudo tee -a $GENERATED_SERVICE_FILE # Copy systemd-journald configuration files @@ -598,6 +600,11 @@ sudo cp $IMAGE_CONFIGS/config-chassisdb/config-chassisdb $FILESYSTEM_ROOT/usr/bi echo "config-chassisdb.service" | sudo tee -a $GENERATED_SERVICE_FILE sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable config-chassisdb.service +# Copy backend-acl script and service file +sudo cp $IMAGE_CONFIGS/backend_acl/backend-acl.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM/backend-acl.service +sudo cp $IMAGE_CONFIGS/backend_acl/backend_acl.py $FILESYSTEM_ROOT/usr/bin/backend_acl.py +echo "backend-acl.service" | sudo tee -a $GENERATED_SERVICE_FILE + # Copy SNMP configuration files sudo cp $IMAGE_CONFIGS/snmp/snmp.yml $FILESYSTEM_ROOT/etc/sonic/ @@ -921,10 +928,18 @@ sudo cp {{src}} $FILESYSTEM_ROOT/{{dst}} {% endfor -%} {% if sonic_asic_platform == "mellanox" %} -sudo mkdir -p $FILESYSTEM_ROOT/etc/mlnx/ -sudo cp $files_path/$MLNX_SPC_FW_FILE $FILESYSTEM_ROOT/etc/mlnx/fw-SPC.mfa -sudo cp $files_path/$MLNX_SPC2_FW_FILE $FILESYSTEM_ROOT/etc/mlnx/fw-SPC2.mfa -sudo cp $files_path/$MLNX_SPC3_FW_FILE $FILESYSTEM_ROOT/etc/mlnx/fw-SPC3.mfa +declare -rA FW_FILE_MAP=( \ + [$MLNX_SPC_FW_FILE]="fw-SPC.mfa" \ + [$MLNX_SPC2_FW_FILE]="fw-SPC2.mfa" \ + [$MLNX_SPC3_FW_FILE]="fw-SPC3.mfa" \ +) +sudo mkdir -p $FILESYSTEM_ROOT/$PLATFORM_DIR/fw/asic/ +sudo mkdir -p $FILESYSTEM_ROOT_ETC/mlnx/ +for fw_file_name in ${!FW_FILE_MAP[@]}; do + sudo cp $files_path/$fw_file_name $FILESYSTEM_ROOT/$PLATFORM_DIR/fw/asic/${FW_FILE_MAP[$fw_file_name]} + # Link old FW location to not break existing automation/scripts + sudo ln -s /host/image-$SONIC_IMAGE_VERSION/$PLATFORM_DIR/fw/asic/${FW_FILE_MAP[$fw_file_name]} $FILESYSTEM_ROOT/etc/mlnx/${FW_FILE_MAP[$fw_file_name]} +done sudo cp $files_path/$ISSU_VERSION_FILE $FILESYSTEM_ROOT/etc/mlnx/issu-version sudo cp $files_path/$MLNX_FFB_SCRIPT $FILESYSTEM_ROOT/usr/bin/mlnx-ffb.sh sudo cp $files_path/$MLNX_ONIE_FW_UPDATE $FILESYSTEM_ROOT/usr/bin/$MLNX_ONIE_FW_UPDATE diff --git a/files/build_templates/sonic_version.yml.j2 b/files/build_templates/sonic_version.yml.j2 index bc6fb54189d4..8b829feeed00 100644 --- a/files/build_templates/sonic_version.yml.j2 +++ b/files/build_templates/sonic_version.yml.j2 @@ -29,3 +29,4 @@ built_by: {{ built_by }} {% if ENABLE_ASAN == "y" -%} asan: 'yes' {% endif -%} +sonic_os_version: {{ sonic_os_version }} diff --git a/files/build_templates/swss_vars.j2 b/files/build_templates/swss_vars.j2 index 1cd95d16a6d6..f35d0fc080ad 100644 --- a/files/build_templates/swss_vars.j2 +++ b/files/build_templates/swss_vars.j2 @@ -6,5 +6,7 @@ "asic_id": "{{ DEVICE_METADATA.localhost.asic_id }}", "mac": "{{ DEVICE_METADATA.localhost.mac }}", "resource_type": "{{ DEVICE_METADATA.localhost.resource_type }}", - "synchronous_mode": {% if DEVICE_METADATA.localhost.synchronous_mode == "disable" %}"disable"{% else %}"enable"{% endif %} + "synchronous_mode": {% if DEVICE_METADATA.localhost.synchronous_mode == "disable" %}"disable"{% else %}"enable"{% endif %}, + "dual_tor": {% if DEVICE_METADATA.localhost.type == "ToRRouter" and DEVICE_METADATA.localhost.subtype == "DualToR" %}"enable"{% else %}"disable"{% endif %}, + "dscp_remapping": {% if SYSTEM_DEFAULTS is defined and SYSTEM_DEFAULTS.tunnel_qos_remap is defined and SYSTEM_DEFAULTS.tunnel_qos_remap.status == "enabled" %}"enable"{% else %}"disable"{% endif %} } diff --git a/files/docker/docker.service.conf b/files/docker/docker.service.conf index 7debd85a50ac..73d953ecfdd5 100644 --- a/files/docker/docker.service.conf +++ b/files/docker/docker.service.conf @@ -1,3 +1,4 @@ [Service] +Environment=GODEBUG=netdns=cgo ExecStart= ExecStart=/usr/bin/dockerd -H unix:// --storage-driver=overlay2 --bip=240.127.1.1/24 --iptables=false --ipv6=true --fixed-cidr-v6=fd00::/80 diff --git a/files/image_config/backend_acl/backend-acl.service b/files/image_config/backend_acl/backend-acl.service new file mode 100644 index 000000000000..0ad24231ee4b --- /dev/null +++ b/files/image_config/backend_acl/backend-acl.service @@ -0,0 +1,12 @@ +[Unit] +Description=Enable backend acl on storage backend ToRs +After=swss.service +BindsTo=sonic.target +After=sonic.target + +[Service] +Type=oneshot +ExecStart=/usr/bin/backend_acl.py + +[Install] +WantedBy=sonic.target diff --git a/files/image_config/backend_acl/backend_acl.py b/files/image_config/backend_acl/backend_acl.py new file mode 100755 index 000000000000..bb22a60880ab --- /dev/null +++ b/files/image_config/backend_acl/backend_acl.py @@ -0,0 +1,94 @@ +#!/usr/bin/env python + +import os +import subprocess +import syslog +import time + +from swsscommon.swsscommon import SonicV2Connector + +SYSLOG_IDENTIFIER = os.path.basename(__file__) + +SONIC_CFGGEN_PATH = '/usr/local/bin/sonic-cfggen' + +def log_info(msg): + syslog.openlog(SYSLOG_IDENTIFIER) + syslog.syslog(syslog.LOG_INFO, msg) + syslog.closelog() + +def run_command(cmd, return_cmd=False): + log_info("executing cmd = {}".format(cmd)) + proc = subprocess.Popen(cmd, shell=False, stdout=subprocess.PIPE) + out, err = proc.communicate() + if return_cmd: + if err: + return "Unknown" + + if len(out) > 0: + return out.strip().decode('utf-8') + +def _get_device_type(): + """ + Get device type + """ + device_type = run_command([SONIC_CFGGEN_PATH, '-m', '-v', 'DEVICE_METADATA.localhost.type'], return_cmd=True) + return device_type + +def _is_storage_device(): + """ + Check if the device is a storage device or not + """ + storage_device = run_command([SONIC_CFGGEN_PATH, '-d', '-v', 'DEVICE_METADATA.localhost.storage_device'], return_cmd=True) + return storage_device == "true" + +def _is_acl_table_present(): + """ + Check if acl table exists + """ + acl_table = run_command([SONIC_CFGGEN_PATH, '-d', '-v', 'ACL_TABLE.DATAACL'], return_cmd=True) + return (acl_table != "Unknown" and bool(acl_table)) + +def _is_switch_table_present(): + state_db = SonicV2Connector(host='127.0.0.1') + state_db.connect(state_db.STATE_DB, False) + table_present = False + wait_time = 0 + TIMEOUT = 120 + STEP = 10 + + while wait_time < TIMEOUT: + if state_db.exists(state_db.STATE_DB, 'SWITCH_CAPABILITY|switch'): + table_present = True + break + time.sleep(STEP) + wait_time += STEP + if not table_present: + log_info("Switch table not present") + return table_present + +def load_backend_acl(device_type): + """ + Load acl on backend storage device + """ + BACKEND_ACL_TEMPLATE_FILE = os.path.join('/', "usr", "share", "sonic", "templates", "backend_acl.j2") + BACKEND_ACL_FILE = os.path.join('/', "etc", "sonic", "backend_acl.json") + + # this acl needs to be loaded only on a storage backend ToR. acl load will fail if the switch table isn't present + if _is_storage_device() and _is_acl_table_present() and _is_switch_table_present(): + if os.path.isfile(BACKEND_ACL_TEMPLATE_FILE): + run_command(['sudo', SONIC_CFGGEN_PATH, '-d', '-t', '{},{}'.format(BACKEND_ACL_TEMPLATE_FILE, BACKEND_ACL_FILE)]) + if os.path.isfile(BACKEND_ACL_FILE): + run_command(['acl-loader', 'update', 'incremental', BACKEND_ACL_FILE]) + else: + log_info("Skipping backend acl load - conditions not met") + +def main(): + device_type = _get_device_type() + if device_type != "BackEndToRRouter": + log_info("Skipping backend acl load on unsupported device type: {}".format(device_type)) + return + + load_backend_acl(device_type) + +if __name__ == "__main__": + main() diff --git a/files/image_config/cron.d/logrotate b/files/image_config/cron.d/logrotate deleted file mode 100644 index 173a2abe2bd2..000000000000 --- a/files/image_config/cron.d/logrotate +++ /dev/null @@ -1,3 +0,0 @@ -# Attempt to rotate system logs once every 10 minutes. -# First kill any logrotate process(es) if they are still running, as they're most likely hung -*/10 * * * * root /usr/bin/pkill -9 logrotate > /dev/null 2>&1; /usr/sbin/logrotate /etc/logrotate.conf > /dev/null 2>&1 diff --git a/files/image_config/interfaces/interfaces-config.sh b/files/image_config/interfaces/interfaces-config.sh index f6aa4147a4e4..961349384692 100755 --- a/files/image_config/interfaces/interfaces-config.sh +++ b/files/image_config/interfaces/interfaces-config.sh @@ -60,6 +60,9 @@ for intf_pid in $(ls -1 /var/run/dhclient*.Ethernet*.pid 2> /dev/null); do [[ -f ${intf_pid} ]] && kill `cat ${intf_pid}` && rm -f ${intf_pid} done +[[ -f /var/run/resolvconf/interface/eth0.dhclient ]] && rm -f /var/run/resolvconf/interface/eth0.dhclient +[[ -f /var/run/resolvconf/interface/eth0.ip6.dhclient ]] && rm -f /var/run/resolvconf/interface/eth0.ip6.dhclient + # Read sysctl conf files again sysctl -p /etc/sysctl.d/90-dhcp6-systcl.conf diff --git a/files/image_config/logrotate/timerOverride.conf b/files/image_config/logrotate/timerOverride.conf new file mode 100644 index 000000000000..fff55f5d72b0 --- /dev/null +++ b/files/image_config/logrotate/timerOverride.conf @@ -0,0 +1,2 @@ +[Timer] +OnCalendar=*:00/10:00 diff --git a/files/image_config/monit/memory_checker b/files/image_config/monit/memory_checker index 11604d4c3784..5abe9bbc4497 100755 --- a/files/image_config/monit/memory_checker +++ b/files/image_config/monit/memory_checker @@ -24,6 +24,7 @@ import subprocess import sys import syslog import re +import time import docker @@ -58,14 +59,18 @@ def get_command_result(command): return command_stdout.strip() -def publish_events(events_handle, container_name, mem_usage_bytes, threshold_value): + +def publish_events(container_name, mem_usage_bytes, threshold_value): + events_handle = swsscommon.events_init_publisher(EVENTS_PUBLISHER_SOURCE) params = swsscommon.FieldValueMap() params["ctr_name"] = container_name params["mem_usage"] = mem_usage_bytes params["threshold"] = threshold_value swsscommon.event_publish(events_handle, EVENTS_PUBLISHER_TAG, params) + swsscommon.events_deinit_publisher(events_handle) + -def check_memory_usage(events_handle, container_name, threshold_value): +def check_memory_usage(container_name, threshold_value): """Checks the memory usage of a container and writes an alerting messages into the syslog if the memory usage is larger than the threshold value. @@ -100,7 +105,7 @@ def check_memory_usage(events_handle, container_name, threshold_value): syslog.syslog(syslog.LOG_INFO, "[{}]: Memory usage ({} Bytes) is larger than the threshold ({} Bytes)!" .format(container_name, mem_usage_bytes, threshold_value)) # publish event - publish_events(events_handle, container_name, mem_usage_bytes, threshold_value) + publish_events(container_name, "{:.2f}".format(mem_usage_bytes), str(threshold_value)) sys.exit(3) else: syslog.syslog(syslog.LOG_ERR, "[memory_checker] Failed to retrieve memory value from '{}'" @@ -160,14 +165,13 @@ def main(): sys.exit(0) running_container_names = get_running_container_names() - events_handle = swsscommon.events_init_publisher(EVENTS_PUBLISHER_SOURCE) if args.container_name in running_container_names: - check_memory_usage(events_handle, args.container_name, args.threshold_value) + check_memory_usage(args.container_name, args.threshold_value) else: syslog.syslog(syslog.LOG_INFO, "[memory_checker] Exits without checking memory usage since container '{}' is not running!" .format(args.container_name)) - swsscommon.events_deinit_publisher(events_handle) + if __name__ == "__main__": main() diff --git a/files/image_config/ntp/ntp-config.sh b/files/image_config/ntp/ntp-config.sh index 9b982d8707b6..ace9ad1c8a42 100755 --- a/files/image_config/ntp/ntp-config.sh +++ b/files/image_config/ntp/ntp-config.sh @@ -8,11 +8,11 @@ reboot_type='cold' function get_database_reboot_type() { SYSTEM_WARM_START=`sonic-db-cli STATE_DB hget "WARM_RESTART_ENABLE_TABLE|system" enable` - SYSTEM_FAST_START=`sonic-db-cli STATE_DB get "FAST_REBOOT|system"` + SYSTEM_FAST_START=`sonic-db-cli STATE_DB hget "FAST_RESTART_ENABLE_TABLE|system" enable` if [[ x"${SYSTEM_WARM_START}" == x"true" ]]; then reboot_type='warm' - elif [[ x"${SYSTEM_FAST_START}" == x"1" ]]; then + elif [[ x"${SYSTEM_FAST_START}" == x"true" ]]; then reboot_type='fast' fi } diff --git a/files/image_config/platform/rc.local b/files/image_config/platform/rc.local index 8692ff6484cd..11d26ff9af2c 100755 --- a/files/image_config/platform/rc.local +++ b/files/image_config/platform/rc.local @@ -289,7 +289,7 @@ if [ -f $FIRST_BOOT_FILE ]; then mv /etc/apt/sources.list /etc/apt/sources.list.rc-local echo "deb [trusted=yes] file:///host/image-$SONIC_VERSION/platform/common /" > /etc/apt/sources.list.d/sonic_debian_extension.list LANG=C DEBIAN_FRONTEND=noninteractive apt-get update - LANG=C DEBIAN_FRONTEND=noninteractive apt-get -y install /host/image-$SONIC_VERSION/platform/$platform/*.deb + LANG=C DEBIAN_FRONTEND=noninteractive apt-get -o DPkg::Path=$PATH:/usr/local/bin -y install /host/image-$SONIC_VERSION/platform/$platform/*.deb # Cleanup rm -f /etc/apt/sources.list.d/sonic_debian_extension.list rm -f /var/lib/apt/lists/_host_image-${SONIC_VERSION}_platform_common_Packages.lz4 diff --git a/files/image_config/resolv-config/resolv.conf.head b/files/image_config/resolv-config/resolv.conf.head new file mode 100644 index 000000000000..db81bded75e9 --- /dev/null +++ b/files/image_config/resolv-config/resolv.conf.head @@ -0,0 +1,2 @@ +# Dynamic resolv.conf(5) file generated by resolvconf(8) +# The content of this file may be overwritten during a config reload. diff --git a/files/image_config/rsyslog/rsyslog-config.service b/files/image_config/rsyslog/rsyslog-config.service index 34c56fb0e00b..4290766da203 100644 --- a/files/image_config/rsyslog/rsyslog-config.service +++ b/files/image_config/rsyslog/rsyslog-config.service @@ -4,6 +4,7 @@ Requires=updategraph.service After=updategraph.service BindsTo=sonic.target After=sonic.target +After=interfaces-config.service [Service] Type=oneshot diff --git a/files/image_config/rsyslog/rsyslog-container.conf.j2 b/files/image_config/rsyslog/rsyslog-container.conf.j2 index d17fbb6767ba..a6419eba846a 100644 --- a/files/image_config/rsyslog/rsyslog-container.conf.j2 +++ b/files/image_config/rsyslog/rsyslog-container.conf.j2 @@ -14,8 +14,28 @@ $ModLoad imuxsock # provides support for local system logging # # Set a rate limit on messages from the container # + +{% if SYSLOG_CONFIG_FEATURE is defined %} +{% if container_name in SYSLOG_CONFIG_FEATURE %} +{% if 'rate_limit_interval' in SYSLOG_CONFIG_FEATURE[container_name]%} +{% set rate_limit_interval = SYSLOG_CONFIG_FEATURE[container_name]['rate_limit_interval'] %} +{% endif %} +{% if 'rate_limit_burst' in SYSLOG_CONFIG_FEATURE[container_name]%} +{% set rate_limit_burst = SYSLOG_CONFIG_FEATURE[container_name]['rate_limit_burst'] %} +{% endif %} +{% endif %} +{% endif %} + +{% if rate_limit_interval is defined %} +$SystemLogRateLimitInterval {{ rate_limit_interval }} +{% else %} $SystemLogRateLimitInterval 300 +{% endif %} +{% if rate_limit_burst is defined %} +$SystemLogRateLimitBurst {{ rate_limit_burst }} +{% else %} $SystemLogRateLimitBurst 20000 +{% endif %} #$ModLoad imklog # provides kernel logging support #$ModLoad immark # provides --MARK-- message capability @@ -73,4 +93,4 @@ $RepeatedMsgReduction on ############### #### RULES #### -############### +############### \ No newline at end of file diff --git a/files/image_config/rsyslog/rsyslog.conf.j2 b/files/image_config/rsyslog/rsyslog.conf.j2 index 5db3ec86b795..d20fb5d00aec 100644 --- a/files/image_config/rsyslog/rsyslog.conf.j2 +++ b/files/image_config/rsyslog/rsyslog.conf.j2 @@ -14,6 +14,25 @@ ################# $ModLoad imuxsock # provides support for local system logging + +{% if SYSLOG_CONFIG is defined %} +{% if 'GLOBAL' in SYSLOG_CONFIG %} +{% if 'rate_limit_interval' in SYSLOG_CONFIG['GLOBAL']%} +{% set rate_limit_interval = SYSLOG_CONFIG['GLOBAL']['rate_limit_interval'] %} +{% endif %} +{% if 'rate_limit_burst' in SYSLOG_CONFIG['GLOBAL']%} +{% set rate_limit_burst = SYSLOG_CONFIG['GLOBAL']['rate_limit_burst'] %} +{% endif %} +{% endif %} +{% endif %} + +{% if rate_limit_interval is defined %} +$SystemLogRateLimitInterval {{ rate_limit_interval }} +{% endif %} +{% if rate_limit_burst is defined %} +$SystemLogRateLimitBurst {{ rate_limit_burst }} +{% endif %} + $ModLoad imklog # provides kernel logging support #$ModLoad immark # provides --MARK-- message capability diff --git a/files/image_config/sonic_release b/files/image_config/sonic_release new file mode 100644 index 000000000000..62e6c156f6ce --- /dev/null +++ b/files/image_config/sonic_release @@ -0,0 +1 @@ +202211 diff --git a/files/image_config/sudoers/sudoers b/files/image_config/sudoers/sudoers index fb371c59b8ad..d07d0dcfbcc8 100644 --- a/files/image_config/sudoers/sudoers +++ b/files/image_config/sudoers/sudoers @@ -42,7 +42,8 @@ Cmnd_Alias READ_ONLY_CMDS = /bin/cat /var/log/syslog*, \ /usr/local/bin/pcieutil *, \ /usr/local/bin/psuutil *, \ /usr/local/bin/sonic-installer list, \ - /usr/local/bin/sfputil show * + /usr/local/bin/sfputil show *, \ + /usr/local/bin/storyteller * Cmnd_Alias PASSWD_CMDS = /usr/local/bin/config tacacs passkey *, \ diff --git a/files/image_config/sysctl/sysctl-net.conf b/files/image_config/sysctl/sysctl-net.conf index 1a2cc35ad491..3e7c0811200a 100644 --- a/files/image_config/sysctl/sysctl-net.conf +++ b/files/image_config/sysctl/sysctl-net.conf @@ -34,7 +34,7 @@ net.ipv6.conf.all.keep_addr_on_down=1 net.ipv6.conf.eth0.keep_addr_on_down=1 net.ipv4.tcp_l3mdev_accept=1 net.ipv4.udp_l3mdev_accept=1 -net.core.rmem_max=3145728 -net.core.wmem_max=3145728 +net.core.rmem_max=16777216 +net.core.wmem_max=16777216 net.core.somaxconn=512 net.ipv4.fib_multipath_use_neigh=1 diff --git a/files/image_config/warmboot-finalizer/finalize-warmboot.sh b/files/image_config/warmboot-finalizer/finalize-warmboot.sh index 412559289026..597a9cceacb3 100755 --- a/files/image_config/warmboot-finalizer/finalize-warmboot.sh +++ b/files/image_config/warmboot-finalizer/finalize-warmboot.sh @@ -52,6 +52,17 @@ function check_warm_boot() WARM_BOOT=`sonic-db-cli STATE_DB hget "WARM_RESTART_ENABLE_TABLE|system" enable` } +function check_fast_reboot() +{ + debug "Checking if fast-reboot is enabled..." + FAST_REBOOT=`sonic-db-cli STATE_DB hget "FAST_RESTART_ENABLE_TABLE|system" enable` + if [[ x"${FAST_REBOOT}" == x"true" ]]; then + debug "Fast-reboot is enabled..." + else + debug "Fast-reboot is disabled..." + fi +} + function wait_for_database_service() { @@ -97,6 +108,12 @@ function finalize_warm_boot() sudo config warm_restart disable } +function finalize_fast_reboot() +{ + debug "Finalizing fast-reboot..." + sonic-db-cli STATE_DB hset "FAST_RESTART_ENABLE_TABLE|system" "enable" "false" &>/dev/null +} + function stop_control_plane_assistant() { if [[ -x ${ASSISTANT_SCRIPT} ]]; then @@ -118,14 +135,20 @@ function restore_counters_folder() wait_for_database_service +check_fast_reboot check_warm_boot if [[ x"${WARM_BOOT}" != x"true" ]]; then debug "warmboot is not enabled ..." - exit 0 + if [[ x"${FAST_REBOOT}" != x"true" ]]; then + debug "fastboot is not enabled ..." + exit 0 + fi fi -restore_counters_folder +if [[ (x"${WARM_BOOT}" == x"true") && (x"${FAST_REBOOT}" != x"true") ]]; then + restore_counters_folder +fi get_component_list @@ -142,14 +165,22 @@ for i in `seq 60`; do sleep 5 done -stop_control_plane_assistant +if [[ (x"${WARM_BOOT}" == x"true") && (x"${FAST_REBOOT}" != x"true") ]]; then + stop_control_plane_assistant +fi # Save DB after stopped control plane assistant to avoid extra entries -debug "Save in-memory database after warm reboot ..." +debug "Save in-memory database after warm/fast reboot ..." config save -y if [[ -n "${list}" ]]; then debug "Some components didn't finish reconcile: ${list} ..." fi -finalize_warm_boot +if [ x"${FAST_REBOOT}" == x"true" ]; then + finalize_fast_reboot +fi + +if [ x"${WARM_BOOT}" == x"true" ]; then + finalize_warm_boot +fi \ No newline at end of file diff --git a/files/scripts/arp_update b/files/scripts/arp_update index b686e1a93e24..2725f034668b 100755 --- a/files/scripts/arp_update +++ b/files/scripts/arp_update @@ -14,13 +14,16 @@ while /bin/true; do ARP_UPDATE_VARS=$(sonic-cfggen -d -t ${ARP_UPDATE_VARS_FILE}) SWITCH_TYPE=$(echo $ARP_UPDATE_VARS | jq -r '.switch_type') if [[ "$SWITCH_TYPE" == "chassis-packet" ]]; then - STATIC_ROUTE_NEXTHOPS=$(echo $ARP_UPDATE_VARS | jq -r '.static_route_nexthops') + # Get array of Nexthops and ifnames. Nexthops and ifnames are mapped one to one + STATIC_ROUTE_NEXTHOPS=($(echo $ARP_UPDATE_VARS | jq -r '.static_route_nexthops')) + STATIC_ROUTE_IFNAMES=($(echo $ARP_UPDATE_VARS | jq -r '.static_route_ifnames')) # on supervisor/rp exit the script gracefully - if [[ -z "$STATIC_ROUTE_NEXTHOPS" ]]; then + if [[ -z "$STATIC_ROUTE_NEXTHOPS" ]] || [[ -z "$STATIC_ROUTE_IFNAMES" ]]; then logger "arp_update: exiting as no static route in packet based chassis" exit 0 fi - for nexthop in $STATIC_ROUTE_NEXTHOPS; do + for i in ${!STATIC_ROUTE_NEXTHOPS[@]}; do + nexthop="${STATIC_ROUTE_NEXTHOPS[i]}" if [[ $nexthop == *"."* ]]; then neigh_state=( $(ip -4 neigh show | grep -w $nexthop | tr -s ' ' | cut -d ' ' -f 3,4) ) ping_prefix=ping @@ -28,11 +31,19 @@ while /bin/true; do neigh_state=( $(ip -6 neigh show | grep -w $nexthop | tr -s ' ' | cut -d ' ' -f 3,4) ) ping_prefix=ping6 fi - - if [[ "${neigh_state[1]}" == "INCOMPLETE" ]] || [[ "${neigh_state[1]}" == "FAILED" ]]; then - pingcmd="timeout 0.2 $ping_prefix -I ${neigh_state[0]} -n -q -i 0 -c 1 -W 1 $nexthop >/dev/null" - eval $pingcmd - logger "arp_update: sttaic route nexthop not resolved, pinging $nexthop on ${neigh_state[0]}" + if [[ -z "${neigh_state}" ]] || [[ "${neigh_state[1]}" == "INCOMPLETE" ]] || [[ "${neigh_state[1]}" == "FAILED" ]]; then + interface="${STATIC_ROUTE_IFNAMES[i]}" + if [[ -z "$interface" ]]; then + # should never be here, handling just in case + logger "ERR: arp_update: missing interface entry for static route $nexthop" + interface=${neigh_state[0]} + fi + intf_up=$(ip link show $interface | grep "state UP") + if [[ -n "$intf_up" ]]; then + pingcmd="timeout 0.2 $ping_prefix -I ${interface} -n -q -i 0 -c 1 -W 1 $nexthop >/dev/null" + eval $pingcmd + logger "arp_update: static route nexthop not resolved, pinging $nexthop on ${neigh_state[0]}" + fi fi done diff --git a/files/scripts/bgp.sh b/files/scripts/bgp.sh index b7a383ebbdd7..328f8ab01ec2 100755 --- a/files/scripts/bgp.sh +++ b/files/scripts/bgp.sh @@ -30,7 +30,8 @@ function validate_restore_count() function check_fast_boot () { - if [[ $($SONIC_DB_CLI STATE_DB GET "FAST_REBOOT|system") == "1" ]]; then + SYSTEM_FAST_REBOOT=`sonic-db-cli STATE_DB hget "FAST_RESTART_ENABLE_TABLE|system" enable` + if [[ x"${SYSTEM_FAST_REBOOT}" == x"true" ]]; then FAST_BOOT="true" else FAST_BOOT="false" diff --git a/files/scripts/service_mgmt.sh b/files/scripts/service_mgmt.sh index d400c8472246..a3709bf2bf8b 100755 --- a/files/scripts/service_mgmt.sh +++ b/files/scripts/service_mgmt.sh @@ -19,13 +19,34 @@ function check_warm_boot() function check_fast_boot () { - if [[ $($SONIC_DB_CLI STATE_DB GET "FAST_REBOOT|system") == "1" ]]; then + SYSTEM_FAST_REBOOT=`sonic-db-cli STATE_DB hget "FAST_RESTART_ENABLE_TABLE|system" enable` + if [[ x"${SYSTEM_FAST_REBOOT}" == x"true" ]]; then FAST_BOOT="true" else FAST_BOOT="false" fi } +function check_redundant_type() +{ + DEVICE_SUBTYPE=`$SONIC_DB_CLI CONFIG_DB hget "DEVICE_METADATA|localhost" subtype` + if [[ x"$DEVICE_SUBTYPE" == x"DualToR" ]]; then + MUX_CONFIG=`show muxcable config` + if [[ $MUX_CONFIG =~ .*active-active.* ]]; then + ACTIVE_ACTIVE="true" + else + ACTIVE_ACTIVE="false" + fi + else + ACTIVE_ACTIVE="false" + fi + CONFIG_KNOB=`$SONIC_DB_CLI CONFIG_DB hget "MUX_LINKMGR|SERVICE_MGMT" kill_radv` + if [[ x"$CONFIG_KNOB" == x"False" ]]; then + ACTIVE_ACTIVE='false' + fi + debug "DEVICE_SUBTYPE: ${DEVICE_SUBTYPE}, CONFIG_KNOB: ${CONFIG_KNOB}" +} + start() { debug "Starting ${SERVICE}$DEV service..." @@ -43,13 +64,19 @@ stop() { check_warm_boot check_fast_boot + check_redundant_type debug "Warm boot flag: ${SERVICE}$DEV ${WARM_BOOT}." debug "Fast boot flag: ${SERVICE}$DEV ${FAST_BOOT}." # For WARM/FAST boot do not perform service stop if [[ x"$WARM_BOOT" != x"true" ]] && [[ x"$FAST_BOOT" != x"true" ]]; then - /usr/bin/${SERVICE}.sh stop $DEV - debug "Stopped ${SERVICE}$DEV service..." + if [[ x"$SERVICE" == x"radv" ]] && [[ x"$ACTIVE_ACTIVE" == x"true" ]]; then + debug "Killing Docker ${SERVICE}${DEV} for active-active dualtor device..." + /usr/bin/${SERVICE}.sh kill $DEV + else + /usr/bin/${SERVICE}.sh stop $DEV + debug "Stopped ${SERVICE}$DEV service..." + fi else debug "Killing Docker ${SERVICE}${DEV}..." /usr/bin/${SERVICE}.sh kill $DEV diff --git a/files/scripts/swss.sh b/files/scripts/swss.sh index ba0437a25e91..0e9b029dcd26 100755 --- a/files/scripts/swss.sh +++ b/files/scripts/swss.sh @@ -60,7 +60,8 @@ function check_warm_boot() function check_fast_boot() { - if [[ $($SONIC_DB_CLI STATE_DB GET "FAST_REBOOT|system") == "1" ]]; then + SYSTEM_FAST_REBOOT=`sonic-db-cli STATE_DB hget "FAST_RESTART_ENABLE_TABLE|system" enable` + if [[ x"${SYSTEM_FAST_REBOOT}" == x"true" ]]; then FAST_BOOT="true" else FAST_BOOT="false" @@ -284,8 +285,8 @@ stop() { # encountered error, e.g. syncd crashed. And swss needs to # be restarted. if [[ x"$FAST_BOOT" != x"true" ]]; then - debug "Clearing FAST_REBOOT flag..." - clean_up_tables STATE_DB "'FAST_REBOOT*'" + debug "Clearing FAST_RESTART_ENABLE_TABLE flag..." + sonic-db-cli STATE_DB hset "FAST_RESTART_ENABLE_TABLE|system" "enable" "false" fi # Unlock has to happen before reaching out to peer service unlock_service_state_change @@ -304,7 +305,7 @@ function check_peer_gbsyncd() function check_macsec() { - MACSEC_STATE=`show feature status | grep macsec | awk '{print $2}'` + MACSEC_STATE=`$SONIC_DB_CLI CONFIG_DB hget 'FEATURE|macsec' state` if [[ ${MACSEC_STATE} == 'enabled' ]]; then if [ "$DEV" ]; then @@ -326,11 +327,27 @@ function check_ports_present() return 1 } +function check_service_exists() +{ + systemctl list-units --full -all 2>/dev/null | grep -Fq $1 + if [[ $? -eq 0 ]]; then + echo true + return + else + echo false + return + fi +} + # DEPENDENT initially contains namespace independent services # namespace specific services are added later in this script. -DEPENDENT="radv" +DEPENDENT="" MULTI_INST_DEPENDENT="" +if [[ $(check_service_exists radv) == "true" ]]; then + DEPENDENT="$DEPENDENT radv" +fi + if [ "$DEV" ]; then NET_NS="$NAMESPACE_PREFIX$DEV" #name of the network namespace SONIC_DB_CLI="sonic-db-cli -n $NET_NS" @@ -350,7 +367,7 @@ check_macsec check_ports_present PORTS_PRESENT=$? -if [[ $PORTS_PRESENT == 0 ]]; then +if [[ $PORTS_PRESENT == 0 ]] && [[ $(check_service_exists teamd) == "true" ]]; then MULTI_INST_DEPENDENT="teamd" fi diff --git a/files/scripts/syncd.sh b/files/scripts/syncd.sh index 812cf30e4001..c00d3b5a6964 100755 --- a/files/scripts/syncd.sh +++ b/files/scripts/syncd.sh @@ -28,6 +28,19 @@ function startplatform() { debug "Firmware update procedure ended" fi + if [[ x"$sonic_asic_platform" == x"broadcom" ]]; then + if [[ x"$WARM_BOOT" != x"true" ]]; then + is_bcm0=$(ls /sys/class/net | grep bcm0) + if [[ "$is_bcm0" == "bcm0" ]]; then + debug "stop SDK opennsl-modules ..." + /etc/init.d/opennsl-modules stop + debug "start SDK opennsl-modules ..." + /etc/init.d/opennsl-modules start + debug "started SDK opennsl-modules" + fi + fi + fi + if [[ x"$sonic_asic_platform" == x"barefoot" ]]; then is_usb0=$(ls /sys/class/net | grep usb0) if [[ "$is_usb0" == "usb0" ]]; then diff --git a/files/scripts/syncd_common.sh b/files/scripts/syncd_common.sh index 3d03c8b9e4e5..a850e31b207d 100755 --- a/files/scripts/syncd_common.sh +++ b/files/scripts/syncd_common.sh @@ -50,7 +50,8 @@ function check_warm_boot() function check_fast_boot() { - if [[ $($SONIC_DB_CLI STATE_DB GET "FAST_REBOOT|system") == "1" ]]; then + SYSTEM_FAST_REBOOT=`sonic-db-cli STATE_DB hget "FAST_RESTART_ENABLE_TABLE|system" enable` + if [[ x"${SYSTEM_FAST_REBOOT}" == x"true" ]]; then FAST_BOOT="true" else FAST_BOOT="false" @@ -82,7 +83,8 @@ function getBootType() ;; *SONIC_BOOT_TYPE=fast*|*fast-reboot*) # check that the key exists - if [[ $($SONIC_DB_CLI STATE_DB GET "FAST_REBOOT|system") == "1" ]]; then + SYSTEM_FAST_REBOOT=`sonic-db-cli STATE_DB hget "FAST_RESTART_ENABLE_TABLE|system" enable` + if [[ x"${SYSTEM_FAST_REBOOT}" == x"true" ]]; then TYPE='fast' else TYPE='cold' diff --git a/files/scripts/teamd.sh b/files/scripts/teamd.sh index 4de3f25c4dbd..dd6b05caa4c2 100755 --- a/files/scripts/teamd.sh +++ b/files/scripts/teamd.sh @@ -32,7 +32,8 @@ function validate_restore_count() function check_fast_boot () { - if [[ $($SONIC_DB_CLI STATE_DB GET "FAST_REBOOT|system") == "1" ]]; then + SYSTEM_FAST_REBOOT=`sonic-db-cli STATE_DB hget "FAST_RESTART_ENABLE_TABLE|system" enable` + if [[ x"${SYSTEM_FAST_REBOOT}" == x"true" ]]; then FAST_BOOT="true" else FAST_BOOT="false" diff --git a/files/scripts/write_standby.py b/files/scripts/write_standby.py index 13c5b17ea64e..b9e9ff08aae3 100755 --- a/files/scripts/write_standby.py +++ b/files/scripts/write_standby.py @@ -136,7 +136,7 @@ def tunnel_exists(self): tunnel_key_pattern = 'ASIC_STATE:SAI_OBJECT_TYPE_TUNNEL:*' return len(self.asic_db.keys('ASIC_DB', tunnel_key_pattern)) > 0 - def wait_for_tunnel(self, interval=1, timeout=60): + def wait_for_tunnel(self, interval=1, timeout=90): """ Waits until the IP-in-IP tunnel has been created diff --git a/installer/install.sh b/installer/install.sh index 8ae0fec0e8a2..51b5a75eb574 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -138,6 +138,10 @@ fi # with "OS" or "DIAG". demo_type="%%DEMO_TYPE%%" +# The build system prepares this script by replacing %%ONIE_IMAGE_PART_SIZE%% +# with the partition size +demo_part_size="%%ONIE_IMAGE_PART_SIZE%%" + # The build system prepares this script by replacing %%IMAGE_VERSION%% # with git revision hash as a version identifier image_version="%%IMAGE_VERSION%%" @@ -236,7 +240,6 @@ if [ "$install_env" = "onie" ]; then fi fi -demo_part_size="%%ONIE_IMAGE_PART_SIZE%%" echo "ONIE_IMAGE_PART_SIZE=$demo_part_size" extra_cmdline_linux=%%EXTRA_CMDLINE_LINUX%% diff --git a/onie-image-arm64.conf b/onie-image-arm64.conf index c0cabff2a6ec..d70e9a526677 100644 --- a/onie-image-arm64.conf +++ b/onie-image-arm64.conf @@ -37,7 +37,7 @@ OUTPUT_ONIE_IMAGE=target/sonic-$TARGET_MACHINE.bin OUTPUT_RAW_IMAGE=target/sonic-$TARGET_MACHINE.raw ## Raw image size in MB -RAW_IMAGE_DISK_SIZE=3072 +RAW_IMAGE_DISK_SIZE=4096 ## Output file name for kvm image OUTPUT_KVM_IMAGE=target/sonic-$TARGET_MACHINE.img diff --git a/onie-image-armhf.conf b/onie-image-armhf.conf index 39e89366325a..5ba7a3b19e06 100644 --- a/onie-image-armhf.conf +++ b/onie-image-armhf.conf @@ -37,7 +37,7 @@ OUTPUT_ONIE_IMAGE=target/sonic-$TARGET_MACHINE.bin OUTPUT_RAW_IMAGE=target/sonic-$TARGET_MACHINE.raw ## Raw image size in MB -RAW_IMAGE_DISK_SIZE=3072 +RAW_IMAGE_DISK_SIZE=4096 ## Output file name for kvm image OUTPUT_KVM_IMAGE=target/sonic-$TARGET_MACHINE.img diff --git a/onie-image.conf b/onie-image.conf index 73deded2027e..4efd0d8af9ab 100644 --- a/onie-image.conf +++ b/onie-image.conf @@ -37,7 +37,7 @@ OUTPUT_ONIE_IMAGE=target/sonic-$TARGET_MACHINE.bin OUTPUT_RAW_IMAGE=target/sonic-$TARGET_MACHINE.raw ## Raw image size in MB -RAW_IMAGE_DISK_SIZE=3072 +RAW_IMAGE_DISK_SIZE=4096 ## Output file name for kvm image OUTPUT_KVM_IMAGE=target/sonic-$TARGET_MACHINE.img diff --git a/platform/barefoot/sonic-platform-modules-arista b/platform/barefoot/sonic-platform-modules-arista index 2eae0dd1ad35..7deff3f0256a 160000 --- a/platform/barefoot/sonic-platform-modules-arista +++ b/platform/barefoot/sonic-platform-modules-arista @@ -1 +1 @@ -Subproject commit 2eae0dd1ad35b6fd5a78f3eebed466f2744d4fdc +Subproject commit 7deff3f0256a5d0c905d8fde1df0b466a4065104 diff --git a/platform/broadcom/docker-saiserver-brcm.mk b/platform/broadcom/docker-saiserver-brcm.mk index 2ee39c8600e8..6987e42faa78 100644 --- a/platform/broadcom/docker-saiserver-brcm.mk +++ b/platform/broadcom/docker-saiserver-brcm.mk @@ -3,7 +3,13 @@ DOCKER_SAISERVER_BRCM = docker-saiserver$(SAITHRIFT_VER)-brcm.gz $(DOCKER_SAISERVER_BRCM)_PATH = $(PLATFORM_PATH)/docker-saiserver-brcm $(DOCKER_SAISERVER_BRCM)_DEPENDS += $(SAISERVER) -$(DOCKER_SAISERVER_BRCM)_FILES += $(DSSERVE) $(BCMCMD) + +# Use syncd_init_common.sh to init hardware platform +SYNCD_INIT_COMMON_SCRIPT = syncd_init_common.sh +$(SYNCD_INIT_COMMON_SCRIPT)_PATH = $(SRC_PATH)/sonic-sairedis/syncd/scripts +SONIC_COPY_FILES += $(SYNCD_INIT_COMMON_SCRIPT) + +$(DOCKER_SAISERVER_BRCM)_FILES += $(DSSERVE) $(BCMCMD) $(SYNCD_INIT_COMMON_SCRIPT) $(DOCKER_SAISERVER_BRCM)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_BULLSEYE) SONIC_DOCKER_IMAGES += $(DOCKER_SAISERVER_BRCM) SONIC_BULLSEYE_DOCKERS += $(DOCKER_SAISERVER_BRCM) diff --git a/platform/broadcom/docker-saiserver-brcm/Dockerfile.j2 b/platform/broadcom/docker-saiserver-brcm/Dockerfile.j2 index 92914d7abbf8..2e83500b7ea1 100644 --- a/platform/broadcom/docker-saiserver-brcm/Dockerfile.j2 +++ b/platform/broadcom/docker-saiserver-brcm/Dockerfile.j2 @@ -2,7 +2,6 @@ FROM docker-config-engine-bullseye-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} ARG docker_container_name -RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf ## Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive @@ -26,7 +25,10 @@ debs/ RUN apt-get install -yf kmod COPY ["files/dsserve", "files/bcmcmd", "start.sh", "bcmsh", "/usr/bin/"] +COPY ["saiserver_start.sh", "/usr/bin/"] +COPY ["files/syncd_init_common.sh", "/usr/bin/"] RUN chmod +x /usr/bin/dsserve /usr/bin/bcmcmd +RUN chmod +x /usr/bin/saiserver_start.sh /usr/bin/syncd_init_common.sh COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] diff --git a/platform/broadcom/docker-saiserver-brcm/saiserver_start.sh b/platform/broadcom/docker-saiserver-brcm/saiserver_start.sh new file mode 100755 index 000000000000..06fcf6c3f3ae --- /dev/null +++ b/platform/broadcom/docker-saiserver-brcm/saiserver_start.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +# Copy from src/sonic-sairedis/syncd/scripts/syncd_start.sh +# Re-use the structure for syncd setup +# Use it to start saiserver +# Script to start syncd using supervisord +# + +# Source the file that holds common code for systemd and supervisord +. /usr/bin/syncd_init_common.sh + +get_saiserver_param() +{ + IFS=' ' read -r -a array <<< "$CMD_ARGS" + for index in "${!array[@]}" + do + #echo "$index ${array[index]}" + if [[ "${array[index]}" == *"-p"* ]]; then + SAI_PROFILE="${array[index+1]}" + fi + if [[ "${array[index]}" == *"-m"* ]]; then + PORT_CONFIG="${array[index+1]}" + fi + done +} + +ENABLE_SAITHRIFT=1 +config_syncd +get_saiserver_param + +echo exec /usr/sbin/saiserver -p ${SAI_PROFILE} -f ${PORT_CONFIG} +exec /usr/sbin/saiserver -p ${SAI_PROFILE} -f ${PORT_CONFIG} +#exec ${CMD} ${CMD_ARGS} diff --git a/platform/broadcom/docker-saiserver-brcm/start.sh b/platform/broadcom/docker-saiserver-brcm/start.sh index 81813b57ff9d..6a395866c15d 100755 --- a/platform/broadcom/docker-saiserver-brcm/start.sh +++ b/platform/broadcom/docker-saiserver-brcm/start.sh @@ -1,13 +1,6 @@ #!/usr/bin/env bash HWSKU_DIR=/usr/share/sonic/hwsku -start_bcm() -{ - [ -e /dev/linux-bcm-knet ] || mknod /dev/linux-bcm-knet c 122 0 - [ -e /dev/linux-user-bde ] || mknod /dev/linux-user-bde c 126 0 - [ -e /dev/linux-kernel-bde ] || mknod /dev/linux-kernel-bde c 127 0 -} - generate_profile() { # There are two ways to specify the contents of the SAI_INIT_CONFIG_FILE and they are mutually exclusive @@ -35,10 +28,6 @@ generate_profile() } rm -f /var/run/rsyslogd.pid - supervisorctl start rsyslogd - generate_profile -start_bcm - supervisorctl start saiserver diff --git a/platform/broadcom/docker-saiserver-brcm/supervisord.conf b/platform/broadcom/docker-saiserver-brcm/supervisord.conf index 3574cd782b78..d20dac89141b 100644 --- a/platform/broadcom/docker-saiserver-brcm/supervisord.conf +++ b/platform/broadcom/docker-saiserver-brcm/supervisord.conf @@ -20,7 +20,7 @@ stdout_logfile=syslog stderr_logfile=syslog [program:saiserver] -command=/usr/sbin/saiserver -p /etc/sai.d/sai.profile -f /usr/share/sonic/hwsku/port_config.ini +command=/usr/bin/saiserver_start.sh priority=3 autostart=false autorestart=false diff --git a/platform/broadcom/docker-syncd-brcm-dnx/Dockerfile.j2 b/platform/broadcom/docker-syncd-brcm-dnx/Dockerfile.j2 index 230c2628f41d..8bf6a4e50289 100755 --- a/platform/broadcom/docker-syncd-brcm-dnx/Dockerfile.j2 +++ b/platform/broadcom/docker-syncd-brcm-dnx/Dockerfile.j2 @@ -3,8 +3,6 @@ FROM docker-config-engine-bullseye-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} ARG docker_container_name -RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf - ## Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive diff --git a/platform/broadcom/docker-syncd-brcm/Dockerfile.j2 b/platform/broadcom/docker-syncd-brcm/Dockerfile.j2 index 6900e7c933b5..4037ddc6af1a 100755 --- a/platform/broadcom/docker-syncd-brcm/Dockerfile.j2 +++ b/platform/broadcom/docker-syncd-brcm/Dockerfile.j2 @@ -3,8 +3,6 @@ FROM docker-config-engine-bullseye-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} ARG docker_container_name -RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf - ## Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive diff --git a/platform/broadcom/libsaithrift-dev.mk b/platform/broadcom/libsaithrift-dev.mk index ec4e1f6e6da6..938d4f55e676 100644 --- a/platform/broadcom/libsaithrift-dev.mk +++ b/platform/broadcom/libsaithrift-dev.mk @@ -8,7 +8,7 @@ $(LIBSAITHRIFT_DEV)_SRC_PATH = $(SRC_PATH)/sonic-sairedis/SAI ifeq ($(SAITHRIFT_V2),y) $(LIBSAITHRIFT_DEV)_DEPENDS += $(LIBTHRIFT_0_14_1) $(LIBTHRIFT_0_14_1_DEV) $(PYTHON3_THRIFT_0_14_1) $(THRIFT_0_14_1_COMPILER) $(LIBSAITHRIFT_DEV)_RDEPENDS += $(LIBTHRIFT_0_14_1) -$(LIBSAITHRIFT_DEV)_BUILD_ENV = SAITHRIFTV2=true SAITHRIFT_VER=v2 +$(LIBSAITHRIFT_DEV)_BUILD_ENV = SAITHRIFTV2=true SAITHRIFT_VER=v2 GEN_SAIRPC_OPTS="--adapter_logger" else $(LIBSAITHRIFT_DEV)_DEPENDS += $(LIBTHRIFT) $(LIBTHRIFT_DEV) $(PYTHON_THRIFT) $(THRIFT_COMPILER) $(LIBSAITHRIFT_DEV)_RDEPENDS += $(LIBTHRIFT) diff --git a/platform/broadcom/one-image.mk b/platform/broadcom/one-image.mk old mode 100644 new mode 100755 index 59a3259c9929..6c668ee6894d --- a/platform/broadcom/one-image.mk +++ b/platform/broadcom/one-image.mk @@ -81,7 +81,9 @@ $(SONIC_ONE_IMAGE)_LAZY_INSTALLS += $(DELL_S6000_PLATFORM_MODULE) \ $(RAGILE_RA_B6910_64C_PLATFORM_MODULE) \ $(RAGILE_RA_B6510_32C_PLATFORM_MODULE) \ $(RAGILE_RA_B6920_4S_PLATFORM_MODULE) \ - $(NOKIA_IXR7250_PLATFORM_MODULE) + $(NOKIA_IXR7250_PLATFORM_MODULE) \ + $(TENCENT_TCS8400_PLATFORM_MODULE) \ + $(TENCENT_TCS9400_PLATFORM_MODULE) $(SONIC_ONE_IMAGE)_LAZY_BUILD_INSTALLS = $(BRCM_OPENNSL_KERNEL) $(BRCM_DNX_OPENNSL_KERNEL) ifeq ($(INSTALL_DEBUG_TOOLS),y) $(SONIC_ONE_IMAGE)_DOCKERS += $(SONIC_INSTALL_DOCKER_DBG_IMAGES) diff --git a/platform/broadcom/platform-modules-tencent.dep b/platform/broadcom/platform-modules-tencent.dep new file mode 100644 index 000000000000..02106ee3901f --- /dev/null +++ b/platform/broadcom/platform-modules-tencent.dep @@ -0,0 +1,8 @@ +MPATH := $($(TENCENT_TCS8400_PLATFORM_MODULE)_SRC_PATH) +DEP_FILES := $(SONIC_COMMON_FILES_LIST) platform/broadcom/platform-modules-tencent.mk platform/broadcom/platform-modules-tencent.dep +DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) +DEP_FILES += $(shell git ls-files $(MPATH)) + +$(TENCENT_TCS8400_PLATFORM_MODULE)_CACHE_MODE := GIT_CONTENT_SHA +$(TENCENT_TCS8400_PLATFORM_MODULE)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) +$(TENCENT_TCS8400_PLATFORM_MODULE)_DEP_FILES := $(DEP_FILES) diff --git a/platform/broadcom/platform-modules-tencent.mk b/platform/broadcom/platform-modules-tencent.mk new file mode 100644 index 000000000000..1cbe17737d2c --- /dev/null +++ b/platform/broadcom/platform-modules-tencent.mk @@ -0,0 +1,18 @@ +# Tencent platform modules +TENCENT_TCS8400_PLATFORM_MODULE_VERSION = 1.0 +export TENCENT_TCS8400_PLATFORM_MODULE_VERSION + +TENCENT_TCS8400_PLATFORM_MODULE = platform-modules-ruijie-tcs8400_$(TENCENT_TCS8400_PLATFORM_MODULE_VERSION)_amd64.deb +$(TENCENT_TCS8400_PLATFORM_MODULE)_SRC_PATH = $(PLATFORM_PATH)/sonic-platform-modules-tencent +$(TENCENT_TCS8400_PLATFORM_MODULE)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON) +$(TENCENT_TCS8400_PLATFORM_MODULE)_PLATFORM = x86_64-tencent_tcs8400-r0 +SONIC_DPKG_DEBS += $(TENCENT_TCS8400_PLATFORM_MODULE) +SONIC_STRETCH_DEBS += $(TENCENT_TCS8400_PLATFORM_MODULE) + +## TCS9400 +TENCENT_TCS9400_PLATFORM_MODULE_VERSION = 1.0 +export TENCENT_TCS9400_PLATFORM_MODULE_VERSION + +TENCENT_TCS9400_PLATFORM_MODULE = platform-modules-ruijie-tcs9400_$(TENCENT_TCS9400_PLATFORM_MODULE_VERSION)_amd64.deb +$(TENCENT_TCS9400_PLATFORM_MODULE)_PLATFORM = x86_64-tencent_tcs9400-r0 +$(eval $(call add_extra_package,$(TENCENT_TCS8400_PLATFORM_MODULE),$(TENCENT_TCS9400_PLATFORM_MODULE))) diff --git a/platform/broadcom/rules.mk b/platform/broadcom/rules.mk old mode 100644 new mode 100755 index d946d04cc1d8..28d1cf1a4df5 --- a/platform/broadcom/rules.mk +++ b/platform/broadcom/rules.mk @@ -15,6 +15,7 @@ include $(PLATFORM_PATH)/platform-modules-juniper.mk #include $(PLATFORM_PATH)/platform-modules-brcm-xlr-gts.mk #include $(PLATFORM_PATH)/platform-modules-ruijie.mk #include $(PLATFORM_PATH)/platform-modules-ragile.mk +#include $(PLATFORM_PATH)/platform-modules-tencent.mk include $(PLATFORM_PATH)/docker-syncd-brcm.mk include $(PLATFORM_PATH)/docker-syncd-brcm-rpc.mk include $(PLATFORM_PATH)/docker-saiserver-brcm.mk diff --git a/platform/broadcom/sai.mk b/platform/broadcom/sai.mk index 69254a5ac38b..d7eba3bb7d3e 100644 --- a/platform/broadcom/sai.mk +++ b/platform/broadcom/sai.mk @@ -1,8 +1,9 @@ -LIBSAIBCM_XGS_VERSION = 7.1.21.4 -LIBSAIBCM_DNX_VERSION = 7.1.21.4 -LIBSAIBCM_BRANCH_NAME = REL_7.0 -LIBSAIBCM_XGS_URL_PREFIX = "https://sonicstorage.blob.core.windows.net/public/sai/bcmsai/$(LIBSAIBCM_BRANCH_NAME)/$(LIBSAIBCM_XGS_VERSION)" -LIBSAIBCM_DNX_URL_PREFIX = "https://sonicstorage.blob.core.windows.net/public/sai/bcmsai/$(LIBSAIBCM_BRANCH_NAME)/$(LIBSAIBCM_DNX_VERSION)" +LIBSAIBCM_XGS_VERSION = 8.4.0.2 +LIBSAIBCM_DNX_VERSION = 7.1.111.1 +LIBSAIBCM_XGS_BRANCH_NAME = SAI_8.4.0_GA +LIBSAIBCM_DNX_BRANCH_NAME = REL_7.0_SAI_1.11 +LIBSAIBCM_XGS_URL_PREFIX = "https://sonicstorage.blob.core.windows.net/public/sai/sai-broadcom/$(LIBSAIBCM_XGS_BRANCH_NAME)/$(LIBSAIBCM_XGS_VERSION)/xgs" +LIBSAIBCM_DNX_URL_PREFIX = "https://sonicstorage.blob.core.windows.net/public/sai/bcmsai/$(LIBSAIBCM_DNX_BRANCH_NAME)/$(LIBSAIBCM_DNX_VERSION)" BRCM_XGS_SAI = libsaibcm_$(LIBSAIBCM_XGS_VERSION)_amd64.deb $(BRCM_XGS_SAI)_URL = "$(LIBSAIBCM_XGS_URL_PREFIX)/$(BRCM_XGS_SAI)" diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/Kbuild b/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/Kbuild index 6a60777e9c48..e14e25669cff 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/Kbuild +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/Kbuild @@ -17,8 +17,7 @@ # 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 +ifneq ($(CONFIG_PSAMPLE),) PSAMPLE_CB_OBJS=psample-cb.o endif diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/ngknetcb_main.c b/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/ngknetcb_main.c index c456ebbdf73e..af2a0c9aef3d 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/ngknetcb_main.c +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/ngknetcb_main.c @@ -307,8 +307,8 @@ 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); +#if IS_ENABLED(CONFIG_PSAMPLE) + skb = psample_rx_cb(skb); #endif return skb; } @@ -324,7 +324,7 @@ static int ngknet_netif_create_cb(struct net_device *dev) { int retv = 0; -#ifdef PSAMPLE_SUPPORT +#if IS_ENABLED(CONFIG_PSAMPLE) retv = psample_netif_create_cb(dev); #endif return retv; @@ -334,7 +334,7 @@ static int ngknet_netif_destroy_cb(struct net_device *dev) { int retv = 0; -#ifdef PSAMPLE_SUPPORT +#if IS_ENABLED(CONFIG_PSAMPLE) retv = psample_netif_destroy_cb(dev); #endif return retv; @@ -431,7 +431,7 @@ ngknetcb_init_module(void) ngknet_rx_cb_register(ngknet_rx_cb); ngknet_tx_cb_register(ngknet_tx_cb); -#ifdef PSAMPLE_SUPPORT +#if IS_ENABLED(CONFIG_PSAMPLE) psample_init(); #endif @@ -446,7 +446,7 @@ 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 +#if IS_ENABLED(CONFIG_PSAMPLE) psample_cleanup(); #endif diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/psample-cb.h b/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/psample-cb.h index 2e3342ead5c3..e2922a36bca4 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/psample-cb.h +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/psample-cb.h @@ -24,7 +24,6 @@ #include #include -//#define PSAMPLE_SUPPORT 1 // TODO: MLI@BRCM - Add this as part of conditional in Makefile #define PSAMPLE_CB_NAME "psample" extern int 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 297ef7a1e478..b420e30a3729 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 @@ -46,7 +46,7 @@ #include /* Enable sflow sampling using psample */ -#ifdef PSAMPLE_SUPPORT +#if IS_ENABLED(CONFIG_PSAMPLE) #include "psample-cb.h" #endif @@ -334,7 +334,7 @@ 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 +#if IS_ENABLED(CONFIG_PSAMPLE) if (strncmp(kf->desc, PSAMPLE_CB_NAME, strlen(PSAMPLE_CB_NAME)) == 0) { return psample_filter_cb (pkt, size, dev_no, meta, chan, kf); } @@ -346,7 +346,7 @@ static int knet_netif_create_cb(int unit, kcom_netif_t *netif, uint16 spa, struct net_device *dev) { int retv = 0; -#ifdef PSAMPLE_SUPPORT +#if IS_ENABLED(CONFIG_PSAMPLE) retv = psample_netif_create_cb(unit, netif, spa, dev); #endif return retv; @@ -356,7 +356,7 @@ static int knet_netif_destroy_cb(int unit, kcom_netif_t *netif, uint16 spa, struct net_device *dev) { int retv = 0; -#ifdef PSAMPLE_SUPPORT +#if IS_ENABLED(CONFIG_PSAMPLE) retv = psample_netif_destroy_cb(unit, netif, spa, dev); #endif return retv; @@ -367,7 +367,7 @@ 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 +#if IS_ENABLED(CONFIG_PSAMPLE) if (strncmp(kf->desc, PSAMPLE_CB_NAME, KCOM_FILTER_DESC_MAX) == 0) { return psample_filter_cb (pkt, size, dev_no, meta, chan, kf); } @@ -379,7 +379,7 @@ static int knet_netif_create_cb(int unit, kcom_netif_t *netif, struct net_device *dev) { int retv = 0; -#ifdef PSAMPLE_SUPPORT +#if IS_ENABLED(CONFIG_PSAMPLE) retv = psample_netif_create_cb(unit, netif, dev); #endif return retv; @@ -389,7 +389,7 @@ static int knet_netif_destroy_cb(int unit, kcom_netif_t *netif, struct net_device *dev) { int retv = 0; -#ifdef PSAMPLE_SUPPORT +#if IS_ENABLED(CONFIG_PSAMPLE) retv = psample_netif_destroy_cb(unit, netif, dev); #endif return retv; @@ -427,7 +427,7 @@ _cleanup(void) bkn_netif_create_cb_unregister(knet_netif_create_cb); bkn_netif_destroy_cb_unregister(knet_netif_destroy_cb); -#ifdef PSAMPLE_SUPPORT +#if IS_ENABLED(CONFIG_PSAMPLE) psample_cleanup(); #endif return 0; @@ -445,7 +445,7 @@ _init(void) bkn_tx_skb_cb_register(strip_tag_tx_cb); } -#ifdef PSAMPLE_SUPPORT +#if IS_ENABLED(CONFIG_PSAMPLE) psample_init(); #endif bkn_filter_cb_register(knet_filter_cb); diff --git a/platform/broadcom/sonic-platform-modules-arista b/platform/broadcom/sonic-platform-modules-arista index 2eae0dd1ad35..7deff3f0256a 160000 --- a/platform/broadcom/sonic-platform-modules-arista +++ b/platform/broadcom/sonic-platform-modules-arista @@ -1 +1 @@ -Subproject commit 2eae0dd1ad35b6fd5a78f3eebed466f2744d4fdc +Subproject commit 7deff3f0256a5d0c905d8fde1df0b466a4065104 diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/chassis.py index 5e2b204e3d0b..ed2e339461ac 100644 --- a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/chassis.py @@ -4,6 +4,7 @@ # ############################################################################# import os +import time try: from sonic_platform_pddf_base.pddf_chassis import PddfChassis @@ -14,26 +15,29 @@ import sys import subprocess from sonic_py_common import device_info + from sonic_platform_base.sfp_base import SfpBase except ImportError as e: raise ImportError(str(e) + "- required module not found") -NUM_COMPONENT = 3 -FAN_DIRECTION_FILE_PATH = "/var/fan_direction" +NUM_COMPONENT = 2 class Chassis(PddfChassis): """ PDDF Platform-specific Chassis class """ + sfp_status_dict = {} def __init__(self, pddf_data=None, pddf_plugin_data=None): PddfChassis.__init__(self, pddf_data, pddf_plugin_data) - vendor_ext = self._eeprom.vendor_ext_str() - with open(FAN_DIRECTION_FILE_PATH, "w+") as f: - f.write(vendor_ext) (self.platform, self.hwsku) = device_info.get_platform_and_hwsku() self.__initialize_components() + self.sfp_port_list = list(range(49, 56+1)) + + for port_idx in self.sfp_port_list: + present = self.get_sfp(port_idx).get_presence() + self.sfp_status_dict[port_idx] = '1' if present else '0' def __initialize_components(self): from sonic_platform.component import Component @@ -121,12 +125,14 @@ def get_reboot_cause(self): description = 'Unkown Reason' return (reboot_cause, description) - - def get_serial(self): - return self._eeprom.serial_number_str() - + def get_revision(self): - return self._eeprom.revision_str() + version_str = self._eeprom.revision_str() + + if version_str != "NA": + return str(bytearray(version_str, 'ascii')[0]) + + return version_str @staticmethod def get_position_in_parent(): @@ -134,19 +140,7 @@ def get_position_in_parent(): @staticmethod def is_replaceable(): - return True - - def get_base_mac(self): - return self._eeprom.base_mac_addr() - - def get_system_eeprom_info(self): - return self._eeprom.system_eeprom_info() - - def get_name(self): - return self.modelstr() - - def get_model(self): - return self._eeprom.part_number_str() + return False def set_status_led(self, color): color_dict = { @@ -155,8 +149,94 @@ def set_status_led(self, color): 'amber': "STATUS_LED_COLOR_AMBER", 'off': "STATUS_LED_COLOR_OFF" } - return self.set_system_led("SYS_LED", color_dict.get(color, "off")) + return self.set_system_led("SYS_LED", color_dict.get(color, "STATUS_LED_COLOR_OFF")) def get_status_led(self): return self.get_system_led("SYS_LED") - + + def get_port_or_cage_type(self, index): + """ + Retrieves sfp port or cage type corresponding to physical port + + Args: + index: An integer (>=0), the index of the sfp to retrieve. + The index should correspond to the physical port in a chassis. + For example:- + 1 for Ethernet0, 2 for Ethernet4 and so on for one platform. + 0 for Ethernet0, 1 for Ethernet4 and so on for another platform. + + Returns: + The masks of all types of port or cage that can be supported on the port + Types are defined in sfp_base.py + Eg. + Both SFP and SFP+ are supported on the port, the return value should be 0x0a + which is 0x02 | 0x08 + """ + if index in range(1, 48+1): + return SfpBase.SFP_PORT_TYPE_BIT_RJ45 + elif index in range(49, 56+1): + return (SfpBase.SFP_PORT_TYPE_BIT_SFP | SfpBase.SFP_PORT_TYPE_BIT_SFP_PLUS) + else: + raise NotImplementedError + + 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. + Specifically for SFP event, besides SFP plug in and plug out, + there are some other error event could be raised from SFP, when + these error happened, SFP eeprom will not be avalaible, XCVRD shall + stop to read eeprom before SFP recovered from error status. + status='2' I2C bus stuck, + status='3' Bad eeprom, + status='4' Unsupported cable, + status='5' High Temperature, + status='6' Bad cable. + """ + + sfp_dict = {} + + SFP_REMOVED = '0' + SFP_INSERTED = '1' + + SFP_PRESENT = True + SFP_ABSENT = False + + start_time = time.time() + time_period = timeout/float(1000) #Convert msecs to secs + + while time.time() < (start_time + time_period) or timeout == 0: + for port_idx in self.sfp_port_list: + if self.sfp_status_dict[port_idx] == SFP_REMOVED and \ + self.get_sfp(port_idx).get_presence() == SFP_PRESENT: + sfp_dict[port_idx] = SFP_INSERTED + self.sfp_status_dict[port_idx] = SFP_INSERTED + elif self.sfp_status_dict[port_idx] == SFP_INSERTED and \ + self.get_sfp(port_idx).get_presence() == SFP_ABSENT: + sfp_dict[port_idx] = SFP_REMOVED + self.sfp_status_dict[port_idx] = SFP_REMOVED + + if sfp_dict: + return True, {'sfp':sfp_dict} + + time.sleep(0.5) + + return True, {'sfp':{}} # Timeout diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/component.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/component.py index e4f3e1257da8..3b68c5759b5a 100644 --- a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/component.py +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/component.py @@ -8,10 +8,8 @@ # ############################################################################# -import os.path import subprocess import time -import os try: from sonic_platform_base.component_base import ComponentBase @@ -19,12 +17,11 @@ except ImportError as e: raise ImportError(str(e) + "- required module not found") -SWCPLD_VERSION_PATH = "i2cget -y -f 2 0x32 0" -BIOS_VERSION_PATH = "dmidecode -t bios | grep Version" -COMPONENT_NAME_LIST = ["SWCPLD", "Main_BIOS", "Backup_BIOS"] -COMPONENT_DES_LIST = ["Use for boot control and BIOS switch", - "Main basic Input/Output System", - "Backup basic Input/Output System"] +SWCPLD_VERSION_PATH = ['i2cget', '-y', '-f', '2', '0x32', '0'] +BIOS_VERSION_PATH = ['dmidecode', '-s', 'bios-version'] +COMPONENT_NAME_LIST = ["SWCPLD", "BIOS"] +COMPONENT_DES_LIST = ["Used for managing the chassis and SFP+ ports (49-56)", + "Basic Input/Output System"] class Component(ComponentBase): @@ -35,43 +32,32 @@ class Component(ComponentBase): def __init__(self, component_index): ComponentBase.__init__(self) self.index = component_index - #self._api_helper = APIHelper() self.name = self.get_name() - def run_command(self,cmd): - responses = os.popen(cmd).read() - return responses - def __get_bios_version(self): # Retrieves the BIOS firmware version - result = self.run_command("i2cget -y -f 2 0x32 0x19") - if result.strip() == "0x01": - if self.name == "Main_BIOS": - version = self.run_command(BIOS_VERSION_PATH) - bios_version = version.strip().split(" ")[1] - return str(bios_version) - elif self.name == "Backup_BIOS": - bios_version = "na" - return bios_version - - elif result.strip() == "0x03": - if self.name == "Backup_BIOS": - version = self.run_command(BIOS_VERSION_PATH) - bios_version = version.strip().split(" ")[1] - return str(bios_version) - elif self.name == "Main_BIOS": - bios_version = "na" - return bios_version + version = "N/A" - def __get_cpld_version(self): - if self.name == "SWCPLD": - ver = self.run_command(SWCPLD_VERSION_PATH) - print("ver is %s" % ver) - ver = ver.strip().split("x")[1] - print("ver2 is %s" % ver) - version = int(ver.strip()) / 10 - return str(version) + try: + p = subprocess.Popen(BIOS_VERSION_PATH, stdout=subprocess.PIPE, universal_newlines=True) + data = p.communicate() + version = data[0].strip() + except IOError: + pass + return version + + def __get_cpld_version(self): + version = "N/A" + try: + p = subprocess.Popen(SWCPLD_VERSION_PATH, stdout=subprocess.PIPE, universal_newlines=True) + data = p.communicate() + ver = int(data[0].strip(), 16) + version = "{0}.{1}".format(ver >> 4, ver & 0x0F) + except (IOError, ValueError): + pass + + return version def get_name(self): """ @@ -97,7 +83,7 @@ def get_firmware_version(self): """ fw_version = None - if "BIOS" in self.name: + if self.name == "BIOS": fw_version = self.__get_bios_version() elif "CPLD" in self.name: fw_version = self.__get_cpld_version() diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/fan.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/fan.py index 36e95f2c0c08..5ece7e980980 100644 --- a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/fan.py +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/fan.py @@ -1,6 +1,6 @@ try: from sonic_platform_pddf_base.pddf_fan import PddfFan - import os + import subprocess except ImportError as e: raise ImportError(str(e) + "- required module not found") # ------------------------------------------------------------------ @@ -9,7 +9,6 @@ # add function:set_status_led, # Solve the problem that when a fan is pulled out, the Fan LED on the front panel is still green Issue-#11525 # ------------------------------------------------------------------ -FAN_DIRECTION_FILE_PATH = "/var/fan_direction" class Fan(PddfFan): @@ -31,11 +30,25 @@ def get_speed_tolerance(self): # Fix the speed vairance to 10 percent. If it changes based on platforms, overwrite # this value in derived pddf fan class return 20 - - + def get_presence(self): - #Overwirte the PDDF Common since the FANs on Belgite are all Fixed and present - return True + if self.is_psu_fan: + #For PSU, FAN must be present when PSU is present + try: + cmd = ['i2cget', '-y', '-f', '0x2', '0x32', '0x41'] + p = subprocess.Popen(cmd, stdout=subprocess.PIPE, universal_newlines=True) + data = p.communicate() + status = int(data[0].strip(), 16) + if (self.fans_psu_index == 1 and (status & 0x10) == 0) or \ + (self.fans_psu_index == 2 and (status & 0x20) == 0): + return True + except (IOError, ValueError): + pass + + return False + else: + #Overwirte the PDDF Common since the FANs on Belgite are all Fixed and present + return True def get_direction(self): """ @@ -46,101 +59,35 @@ def get_direction(self): depending on fan direction """ if self.is_psu_fan: - cmd_num = "58" if self.fans_psu_index == 1 else "59" - cmd = "i2cget -y -f 4 0x%s 0x80" % cmd_num - res = os.popen(cmd).read() - # F2B - if res.strip() == "0x01": - direction = "EXHAUST" - else: - direction = "INTAKE" + # Belgite PSU module only has EXHAUST fan + return "EXHAUST" else: - direction = "INTAKE" - with open(FAN_DIRECTION_FILE_PATH, "r") as f: - fan_direction = f.read() - if fan_direction.strip() == "FB": - direction = "EXHAUST" - return direction - - - def get_status(self): - speed = self.get_speed_rpm() - status = True if (speed != 0) else False - return status + return super().get_direction() - def get_target_speed(self): + def get_status_led(self): """ - Retrieves the target (expected) speed of the fan + Gets the state of the fan status LED Returns: - An integer, the percentage of full fan speed, in the range 0 (off) - to 100 (full speed) + A string, one of the predefined STATUS_LED_COLOR_* strings above """ - target_speed = 0 if self.is_psu_fan: - # Target speed not usually supported for PSU fans - target_speed = "N/A" + return "N/A" else: - idx = (self.fantray_index - 1) * 1 + self.fan_index - attr = "fan" + str(idx) + "_pwm" - pwm_path = "/sys/devices/pci0000:00/0000:00:12.0/i2c-0/i2c-2/2-0066/" + attr - pwm = 0 - with open(pwm_path, "r") as f: - pwm = f.read() - - percentage = int(pwm.strip()) - speed_percentage = int(round(percentage / 255 * 100)) - target_speed = speed_percentage - - return target_speed + return super().get_status_led() def set_status_led(self, color): - color_dict = {"green": "STATUS_LED_COLOR_GREEN", - "red": "STATUS_LED_COLOR_AMBER"} - color = color_dict.get(color, "off") - 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) - if result is False: - return False - 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 - - @staticmethod - def get_model(): """ - Retrieves the model number (or part number) of the device - Returns: - string: Model/part number of device - """ - model = "Unknown" - return model + Sets the state of the fan module status LED - @staticmethod - def get_serial(): - """ - Retrieves the serial number of the device - Returns: - string: Serial number of device - """ - serial = "Unknown" - return serial + Args: + color: A string representing the color with which to set the + fan module status LED - def get_position_in_parent(self): - """ - Retrieves the fan/psu fan index number - """ - return self.fantray_index if not self.is_psu_fan else self.fans_psu_index + 4 - - @staticmethod - def is_replaceable(): - """ - Retrieves whether the device is replaceable + Returns: + bool: True if status LED state is set successfully, False if not """ - return False + if self.is_psu_fan: + return False + else: + return super().set_status_led(color) diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/psu.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/psu.py index 9616d030012f..f1047bed740a 100644 --- a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/psu.py +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/psu.py @@ -53,3 +53,21 @@ def get_revision(self): def temperature(self): return self.get_temperature() + + 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-cel/belgite/scripts/pddf_post_device_create.sh b/platform/broadcom/sonic-platform-modules-cel/belgite/scripts/pddf_post_device_create.sh index 414eea7a2b40..436cf61d6dbe 100755 --- a/platform/broadcom/sonic-platform-modules-cel/belgite/scripts/pddf_post_device_create.sh +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/scripts/pddf_post_device_create.sh @@ -7,4 +7,7 @@ sleep 0.1 #Set LM75 shutdown enable sudo i2cset -y -f 2 0x32 0x45 0x1 +# set sys led green status +sudo i2cset -y -f 2 0x32 0x43 0xec + echo -2 | tee /sys/bus/i2c/drivers/pca954x/*-00*/idle_state diff --git a/platform/broadcom/sonic-platform-modules-cel/debian/platform-modules-dx010.init b/platform/broadcom/sonic-platform-modules-cel/debian/platform-modules-dx010.init index 12f8fc61f2ea..fab61467da72 100644 --- a/platform/broadcom/sonic-platform-modules-cel/debian/platform-modules-dx010.init +++ b/platform/broadcom/sonic-platform-modules-cel/debian/platform-modules-dx010.init @@ -147,6 +147,12 @@ start) sleep 0.1 done + # Set pca9548 idle_state + echo -2 > /sys/bus/i2c/devices/i2c-${devnum}/${devnum}-0071/idle_state + echo -2 > /sys/bus/i2c/devices/i2c-${devnum}/${devnum}-0073/idle_state + echo -2 > /sys/bus/i2c/devices/i2c-${devnum}/${devnum}-0077/idle_state + sleep 0.1 + bus_en=8 cfg_r=`i2cget -y -f 8 0x60 0xD1` ((cfg_w=$cfg_r+$bus_en)) diff --git a/platform/broadcom/sonic-platform-modules-cel/dx010/modules/dx010_cpld.c b/platform/broadcom/sonic-platform-modules-cel/dx010/modules/dx010_cpld.c index d8142777c6e1..3cdfb3939558 100644 --- a/platform/broadcom/sonic-platform-modules-cel/dx010/modules/dx010_cpld.c +++ b/platform/broadcom/sonic-platform-modules-cel/dx010/modules/dx010_cpld.c @@ -1,7 +1,7 @@ /* * dx010_cpld.c - driver for SeaStone's CPLD * - * Copyright (C) 2017 Celestica Corp. + * Copyright (C) 2023 Celestica Corp. * * 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 @@ -120,11 +120,11 @@ #define SSRR_ID_BANK2 0x296 #define SSRR_ID_BANK3 0x396 -#define HST_CNTL2_QUICK 0x00 -#define HST_CNTL2_BYTE 0x01 -#define HST_CNTL2_BYTE_DATA 0x02 -#define HST_CNTL2_WORD_DATA 0x03 -#define HST_CNTL2_BLOCK 0x05 +#define SSRR_MASTER_ERR 0x80 +#define SSRR_BUS_BUSY 0x40 + +#define I2C_BAUD_RATE_100K 0x40 + struct dx010_i2c_data { int portid; @@ -610,6 +610,166 @@ static int i2c_read_eeprom(struct i2c_adapter *a, u16 addr, return error; } + +/** + * Read/Write eeprom of CPLD connected QSFP device. + * @param a i2c adapter. + * @param addr address to read. + * @param new_data QSFP port number struct. + * @param rw read/write flag + * @param cmd i2c command. + * @param size access size + * @return 0 if not error, else the error code. + */ +static int dx010_cpld_i2c_access(struct i2c_adapter *a, u16 addr, + struct dx010_i2c_data *new_data, char rw, + u8 cmd, int size, union i2c_smbus_data *data) +{ + u32 reg; + int ioBase=0; + char byte; + char data_len = 0; + short temp; + short portid, opcode, devaddr, cmdbyte0, ssrr, writedata, readdata; + __u16 word_data; + __u8 byte_data; + int error = -EIO; + + mutex_lock(&cpld_data->cpld_lock); + + if (((new_data->portid >= PORT_BANK1_START) + && (new_data->portid <= PORT_BANK1_END)) + || (new_data->portid == PORT_SFPP1) + || (new_data->portid == PORT_SFPP2)) + { + portid = PORT_ID_BANK1; + opcode = OPCODE_ID_BANK1; + devaddr = DEVADDR_ID_BANK1; + cmdbyte0 = CMDBYT_ID_BANK1; + ssrr = SSRR_ID_BANK1; + writedata = WRITE_ID_BANK1; + readdata = READ_ID_BANK1; + }else if ((new_data->portid >= PORT_BANK2_START) && (new_data->portid <= PORT_BANK2_END)){ + portid = PORT_ID_BANK2; + opcode = OPCODE_ID_BANK2; + devaddr = DEVADDR_ID_BANK2; + cmdbyte0 = CMDBYT_ID_BANK2; + ssrr = SSRR_ID_BANK2; + writedata = WRITE_ID_BANK2; + readdata = READ_ID_BANK2; + }else if ((new_data->portid >= PORT_BANK3_START) && (new_data->portid <= PORT_BANK3_END)){ + portid = PORT_ID_BANK3; + opcode = OPCODE_ID_BANK3; + devaddr = DEVADDR_ID_BANK3; + cmdbyte0 = CMDBYT_ID_BANK3; + ssrr = SSRR_ID_BANK3; + writedata = WRITE_ID_BANK3; + readdata = READ_ID_BANK3; + }else{ + /* Invalid parameter! */ + error = -EINVAL; + goto exit; + } + + if (size == I2C_SMBUS_BYTE || size == I2C_SMBUS_BYTE_DATA) + data_len = 1; + else if (size == I2C_SMBUS_WORD_DATA) + data_len = 2; + else { + error = -EINVAL; + goto exit; + } + + while ((inb(ioBase + ssrr) & SSRR_BUS_BUSY)); + if ((inb(ioBase + ssrr) & SSRR_MASTER_ERR) == SSRR_MASTER_ERR) { + error = -EIO; + /* Read error reset the port */ + outb(0x00, ioBase + ssrr); + udelay(3000); + outb(0x01, ioBase + ssrr); + goto exit; + } + + byte = I2C_BAUD_RATE_100K + new_data->portid; + reg = cmd; + outb(byte, ioBase + portid); + outb(reg, ioBase + cmdbyte0); + byte = (data_len << 4) | 0x1; + outb(byte, ioBase + opcode); + addr = addr << 1; + if (rw == I2C_SMBUS_READ) + { + addr |= 0x01; + outb(addr, ioBase + devaddr); + while ((inb(ioBase + ssrr) & SSRR_BUS_BUSY)) + { + udelay(100); + } + + if ((inb(ioBase + ssrr) & SSRR_MASTER_ERR) == SSRR_MASTER_ERR) { + /* Read error reset the port */ + error = -EIO; + outb(0x00, ioBase + ssrr); + udelay(3000); + outb(0x01, ioBase + ssrr); + goto exit; + } + + temp = ioBase + readdata; + if (data_len == 1) + { + byte_data = inb(temp); + data->byte = byte_data; + } + else if (data_len == 2) + { + word_data = inb(temp); + word_data |= (inb(++temp) << 8); + data->word = word_data; + } + } + else // do i2c write + { + temp = ioBase + writedata; + if (data_len == 1) + { + byte_data = data->byte; + outb(byte_data, temp); + } + else if (data_len == 2) + { + word_data = data->word; + outb((word_data & 0xff), temp); + outb((word_data >> 4), (++temp)); + } + // write dev addr + outb(addr, ioBase + devaddr); + + // check bus access status + while ((inb(ioBase + ssrr) & SSRR_BUS_BUSY)) + { + udelay(100); + } + + if ((inb(ioBase + ssrr) & SSRR_MASTER_ERR) == SSRR_MASTER_ERR) { + /* Read error reset the port */ + error = -EIO; + outb(0x00, ioBase + ssrr); + udelay(3000); + outb(0x01, ioBase + ssrr); + goto exit; + } + } + + mutex_unlock(&cpld_data->cpld_lock); + return 0; + +exit: + mutex_unlock(&cpld_data->cpld_lock); + return error; +} + + static int dx010_i2c_access(struct i2c_adapter *a, u16 addr, unsigned short flags, char rw, u8 cmd, int size, union i2c_smbus_data *data) @@ -624,39 +784,19 @@ static int dx010_i2c_access(struct i2c_adapter *a, u16 addr, /* Map the size to what the chip understands */ switch (size) { - case I2C_SMBUS_QUICK: - size = HST_CNTL2_QUICK; - break; case I2C_SMBUS_BYTE: - size = HST_CNTL2_BYTE; - break; case I2C_SMBUS_BYTE_DATA: - size = HST_CNTL2_BYTE_DATA; - break; case I2C_SMBUS_WORD_DATA: - size = HST_CNTL2_WORD_DATA; - break; - case I2C_SMBUS_BLOCK_DATA: - size = HST_CNTL2_BLOCK; - break; - default: - dev_warn(&a->dev, "Unsupported transaction %d\n", size); - error = -EOPNOTSUPP; - goto Done; - } - - switch (size) { - case HST_CNTL2_BYTE: /* Result put in SMBHSTDAT0 */ - break; - case HST_CNTL2_BYTE_DATA: - break; - case HST_CNTL2_WORD_DATA: - if( 0 == i2c_read_eeprom(a,addr,new_data,cmd,data)){ + if(0 == dx010_cpld_i2c_access(a, addr, new_data, rw, cmd, size, data)){ error = 0; }else{ error = -EIO; } break; + default: + dev_warn(&a->dev, "Unsupported transaction %d\n", size); + error = -EOPNOTSUPP; + goto Done; } Done: @@ -790,6 +930,6 @@ module_init(cel_dx010_lpc_init); module_exit(cel_dx010_lpc_exit); MODULE_AUTHOR("Pradchaya P "); -MODULE_VERSION("1.0.1"); +MODULE_VERSION("1.0.2"); MODULE_DESCRIPTION("Celestica SeaStone DX010 LPC Driver"); -MODULE_LICENSE("GPL"); \ No newline at end of file +MODULE_LICENSE("GPL"); diff --git a/platform/broadcom/sonic-platform-modules-juniper/qfx5200/utils/juniper_qfx5200_monitor.py b/platform/broadcom/sonic-platform-modules-juniper/qfx5200/utils/juniper_qfx5200_monitor.py index dc47f1049322..6546fff0cf34 100755 --- a/platform/broadcom/sonic-platform-modules-juniper/qfx5200/utils/juniper_qfx5200_monitor.py +++ b/platform/broadcom/sonic-platform-modules-juniper/qfx5200/utils/juniper_qfx5200_monitor.py @@ -34,7 +34,6 @@ try: import os - import commands import subprocess import logging import logging.config @@ -42,6 +41,7 @@ import time import glob import re + from sonic_py_common.general import getstatusoutput_noshell except ImportError as e: raise ImportError('%s - required module not found' % str(e)) @@ -172,8 +172,8 @@ def get_fan_dutycycle(self): pwm_value = 0 pwm_value1 = 0 device_path = self._pwm_input_path_mapping[x] - cmd = ("sudo cat %s" %(device_path)) - status, pwm_value = commands.getstatusoutput(cmd) + cmd = ["sudo", "cat", device_path] + status, pwm_value = getstatusoutput_noshell(cmd) pwm_value1 = int(pwm_value) time.sleep(0.25) if int(pwm_value1) > 0: @@ -181,6 +181,10 @@ def get_fan_dutycycle(self): break return int(ret_value) + + def write_file(self, text, file): + with open(file, 'w') as f: + f.write(text + '\n') def set_fan_dutycycle(self, val): fan_speed = {35: 86, 55: 139, 75: 192, 90: 230,100: 255} @@ -188,8 +192,7 @@ def set_fan_dutycycle(self, val): device_path = self._pwm_input_path_mapping[x] pwm_value = fan_speed.get(val) pwm_value1 = str(pwm_value) - cmd = ("sudo echo %s > %s" %(pwm_value1,device_path)) - os.system(cmd) + self.write_file(pwm_value1,device_path) time.sleep(0.25) logging.debug('Setting PWM value: %s to all fans', pwm_value1) return True @@ -198,8 +201,8 @@ def get_check_fan_dutycycle(self): pwm_str = '' for x in range(self.PWMINPUT_NUM): device_path = self._pwm_input_path_mapping[x] - cmd = ("sudo cat %s" %(device_path)) - status, pwm_value = commands.getstatusoutput(cmd) + cmd = ["sudo", "cat", device_path] + status, pwm_value = getstatusoutput_noshell(cmd) pwm_str += pwm_value if (x != self.PWMINPUT_NUM -1): pwm_str += ', ' @@ -495,8 +498,8 @@ def getSensorTemp(self): else: proc = subprocess.Popen("bcmcmd \"show temp\" | grep \"maximum peak temperature\" | awk '{ print $5 }' > /var/log/asic_value 2>&1 & ",shell=True) time.sleep(2) - cmd = "kill -9 %s"%(proc.pid) - commands.getstatusoutput(cmd) + cmd = ["kill", "-9", proc.pid] + getstatusoutput_noshell(cmd) if os.stat("/var/log/asic_value").st_size == 0: value = PrevASICValue @@ -568,7 +571,7 @@ def getSensorTemp(self): or SensorFlag[8][11] or SensorFlag[9][11] or SensorFlag[10][11] or SensorFlag[11][11]): logging.debug('Fire Threshold reached: System is going to shutdown now') - os.system("echo 'CRITICAL: Fire Threshold reached: System is going to shutdown now' > /dev/console") + self.write_file('CRITICAL: Fire Threshold reached: System is going to shutdown now', "/dev/console") logging.debug('Executing poweroff command') @@ -583,8 +586,8 @@ def getSensorTemp(self): monitorlog_file.close() - cmd = "poweroff" - os.system(cmd) + cmd = ["poweroff"] + subprocess.call(cmd) # CHECK IF ANY TEMPERATURE SENSORS is running at RED warning , IF YES, SET THE ALARM LED TO 'RED' elif (SensorFlag[0][10] or SensorFlag[1][10] or SensorFlag[2][10] or SensorFlag[3][10] or SensorFlag[4][10] or SensorFlag[5][10] or SensorFlag[6][10] or SensorFlag[7][10] @@ -878,8 +881,7 @@ def set_Default_fan_dutycycle(self, val): pwm_value = fan_speed.get(val) pwm_value1 = str(pwm_value) time.sleep(0.25) - cmd = ("sudo echo %s > %s" %(pwm_value1,device_path)) - os.system(cmd) + self.write_file(pwm_value1, device_path) logging.debug('Setting Default PWM value: 86 to all fans') return True @@ -888,8 +890,8 @@ def get_Initial_fan_dutycycle(self): pwm_str = '' for x in range(self.PWMINPUT_NUM): device_path = self._pwm_input_path_mapping[x] - cmd = ("sudo cat %s" %(device_path)) - status, pwm_value = commands.getstatusoutput(cmd) + cmd = ["sudo", "cat", device_path] + status, pwm_value = getstatusoutput_noshell(cmd) pwm_str += pwm_value if (x != self.PWMINPUT_NUM -1): pwm_str += ', ' diff --git a/platform/broadcom/sonic-platform-modules-juniper/qfx5200/utils/juniper_qfx5200_util.py b/platform/broadcom/sonic-platform-modules-juniper/qfx5200/utils/juniper_qfx5200_util.py index 2e6171d99180..7b265685c366 100755 --- a/platform/broadcom/sonic-platform-modules-juniper/qfx5200/utils/juniper_qfx5200_util.py +++ b/platform/broadcom/sonic-platform-modules-juniper/qfx5200/utils/juniper_qfx5200_util.py @@ -23,6 +23,8 @@ import sys import logging import time +import subprocess +from sonic_py_common.general import getstatusoutput_noshell PROJECT_NAME = 'QFX5200-32C' verbose = False @@ -30,8 +32,8 @@ FORCE = 0 if DEBUG == True: - print sys.argv[0] - print 'ARGV :', sys.argv[1:] + print(sys.argv[0]) + print('ARGV :', sys.argv[1:]) i2c_prefix = '/sys/bus/i2c/devices/' @@ -70,7 +72,7 @@ def my_log(txt): if DEBUG == True: - print txt + print(txt) return def log_os_system(cmd, show): @@ -83,6 +85,10 @@ def log_os_system(cmd, show): if show: print('Failed :'+cmd) return status, output + +def write_file(text, file): + with open(file, 'w') as f: + f.write(text + '\n') def driver_install(): global FORCE @@ -106,7 +112,7 @@ def device_install(): for i in range(0,len(mknod)): status, output = log_os_system(mknod[i], 1) if status: - print output + print(output) if FORCE == 0: return status @@ -123,7 +129,7 @@ def do_install(): if FORCE == 0: return status else: - print PROJECT_NAME.upper()+" devices detected...." + print(PROJECT_NAME.upper()+" devices detected....") return def main(): @@ -139,49 +145,50 @@ def main(): # Enabling REFPGA - EnableREFFGACmd = 'busybox devmem 0xFED50011 8 0x53' + EnableREFFGACmd = ['busybox', 'devmem', '0xFED50011', '8', '0x53'] try: - os.system(EnableREFFGACmd) + subprocess.call(EnableREFFGACmd) except OSError: - print 'Error: Execution of "%s" failed', EnableREFFGACmd + print('Error: Execution of "%s" failed', EnableREFFGACmd) return False time.sleep(2) # Create CPU Board EEPROM device - CreateEEPROMdeviceCmd = 'sudo echo 24c02 0x51 > /sys/bus/i2c/devices/i2c-0/new_device' + CreateEEPROMdeviceCmd = '24c02 0x51' + file = '/sys/bus/i2c/devices/i2c-0/new_device' try: - os.system(CreateEEPROMdeviceCmd) + write_file(CreateEEPROMdeviceCmd, file) except OSError: - print 'Error: Execution of "%s" failed', CreateEEPROMdeviceCmd + print('Error: Execution of "%s" failed', CreateEEPROMdeviceCmd) return False time.sleep(1) #Retrieve the Base MAC Address from EEPROM - status, macAddress = commands.getstatusoutput("decode-syseeprom -m 0x24") + status, macAddress = getstatusoutput_noshell(["decode-syseeprom", "-m", "0x24"]) if status: - print 'Error: Could not retrieve BASE MAC Address from EEPROM' + print('Error: Could not retrieve BASE MAC Address from EEPROM') return False #Make eth0 interface down - status, eth0Down = commands.getstatusoutput("ifconfig eth0 down") + status, eth0Down = getstatusoutput_noshell(["ifconfig", "eth0", "down"]) if status: - print 'Error: Could not make eth0 interface down' + print('Error: Could not make eth0 interface down') return False #Assign BASE MAC ADDRESS retieved from CPU board EEPROM to eth0 interface - mac_address_prog = "ifconfig eth0 hw ether " + str(macAddress) + mac_address_prog = ["ifconfig", "eth0", "hw", "ether", str(macAddress)] - status, MACAddressProg = commands.getstatusoutput(mac_address_prog) + status, MACAddressProg = getstatusoutput_noshell(mac_address_prog) if status: - print 'Error: Could not set up "macAddress" for eth0 interface' + print('Error: Could not set up "macAddress" for eth0 interface') return False #Make eth0 interface up - status, eth0UP = commands.getstatusoutput("ifconfig eth0 up") + status, eth0UP = getstatusoutput_noshell(["ifconfig", "eth0", "up"]) if status: - print 'Error: Could not make eth0 interface up' + print('Error: Could not make eth0 interface up') return False # Juniper QFX5200 platform drivers install @@ -189,20 +196,20 @@ def main(): time.sleep(2) # Juniper SFP Intialization - JuniperSFPInitCmd = 'python /usr/share/sonic/device/x86_64-juniper_qfx5200-r0/plugins/qfx5200_sfp_init.py' + JuniperSFPInitCmd = ['python', '/usr/share/sonic/device/x86_64-juniper_qfx5200-r0/plugins/qfx5200_sfp_init.py'] try: - os.system(JuniperSFPInitCmd) + subprocess.call(JuniperSFPInitCmd) except OSError: - print 'Error: Execution of "%s" failed', JuniperSFPInitCmd + print('Error: Execution of "%s" failed', JuniperSFPInitCmd) return False time.sleep(1) # Invoking the script which retrieves the data from CPU Board and Main Board EEPROM and storing in file - EEPROMDataCmd = 'python /usr/share/sonic/device/x86_64-juniper_qfx5200-r0/plugins/qfx5200_eeprom_data.py' + EEPROMDataCmd = ['python', '/usr/share/sonic/device/x86_64-juniper_qfx5200-r0/plugins/qfx5200_eeprom_data.py'] try: - os.system(EEPROMDataCmd) + subprocess.call(EEPROMDataCmd) except OSError: - print 'Error: Execution of "%s" failed', EEPROMDataCmd + print('Error: Execution of "%s" failed', EEPROMDataCmd) return False for x in range(PWMINPUT_NUM): @@ -218,16 +225,16 @@ def main(): hwmon_dir) device_path = pwm_input_path_mapping[x] time.sleep(1) - cmd = ("sudo echo 22500 > %s" %device_path) - os.system(cmd) + cmd = "22500" + write_file(cmd, device_path) numsensors_input_path_mapping[x] = NUMSENSORS_PATH.format( hwmon_input_node_mapping[x], hwmon_dir) numsensors_path = numsensors_input_path_mapping[x] time.sleep(1) - cmd = ("sudo echo 0 > %s" %numsensors_path) - os.system(cmd) + cmd = "0" + write_file(cmd, numsensors_path) return True diff --git a/platform/broadcom/sonic-platform-modules-juniper/qfx5200/utils/show_thresholds b/platform/broadcom/sonic-platform-modules-juniper/qfx5200/utils/show_thresholds index 29d584e7f328..9dd58b52ae42 100755 --- a/platform/broadcom/sonic-platform-modules-juniper/qfx5200/utils/show_thresholds +++ b/platform/broadcom/sonic-platform-modules-juniper/qfx5200/utils/show_thresholds @@ -1,6 +1,6 @@ #!/usr/bin/env python import os -import commands +from sonic_py_common.general import getstatusoutput_noshell def fantype_detect(): @@ -15,9 +15,8 @@ def fantype_detect(): for filename in os.listdir(refpgaTMC_path): if filename.endswith('_type'): fantype_path = os.path.join(refpgaTMC_path, filename) - cat_string = "cat " - fantype_string = cat_string + fantype_path - status,fan_type=commands.getstatusoutput(fantype_string) + fantype_string = ["cat", fantype_path] + status, fan_type = getstatusoutput_noshell(fantype_string) if ((fan_type == AFO) or (fan_type == AFI)): return fan_type else: diff --git a/platform/broadcom/sonic-platform-modules-juniper/qfx5210/utils/juniper_qfx5210_monitor.py b/platform/broadcom/sonic-platform-modules-juniper/qfx5210/utils/juniper_qfx5210_monitor.py index 77eac5234257..79b3284f1359 100755 --- a/platform/broadcom/sonic-platform-modules-juniper/qfx5210/utils/juniper_qfx5210_monitor.py +++ b/platform/broadcom/sonic-platform-modules-juniper/qfx5210/utils/juniper_qfx5210_monitor.py @@ -34,13 +34,13 @@ try: import os - import commands import subprocess import logging import logging.config import logging.handlers import time import glob + from sonic_py_common.general import getstatusoutput_noshell except ImportError as e: raise ImportError('%s - required module not found' % str(e)) @@ -305,10 +305,12 @@ def getSensorTemp(self): firethr = FireThresholdSecsRemaining - 20 if firethr == 0: logging.critical('CRITICAL: Fire Threshold reached: System is going to shutdown now') - os.system("echo 'CRITICAL: Fire Threshold reached: System is going to shutdown now' > /dev/console") + with open("/dev/console", 'w') as f: + f.write('CRITICAL: Fire Threshold reached: System is going to shutdown now\n') else: logging.critical('CRITICAL: Fire Threshold reached: System is going to shutdown in %s seconds', firethr) - os.system("echo 'CRITICAL: Fire Threshold reached: System is going to shutdown in %s seconds' > /dev/console" % firethr) + with open("/dev/console", 'w') as f: + f.write('CRITICAL: Fire Threshold reached: System is going to shutdown in %s seconds\n' % firethr) FireThresholdSecsRemaining = FireThresholdSecsRemaining - 20 logging.critical('CRITICAL: Value of FireThresholdSecsRemaining %s seconds', FireThresholdSecsRemaining) @@ -316,8 +318,8 @@ def getSensorTemp(self): if (FireThresholdSecsRemaining == 0): isFireThresholdReached == False time.sleep(20) - cmd = "poweroff" - os.system(cmd) + cmd = ["poweroff"] + subprocess.call(cmd) for x in range(self.SENSOR_CORETEMP_NUM_ON_MAIN_BOARD): if x < self.SENSOR_NUM_ON_MAIN_BOARD: @@ -330,8 +332,8 @@ def getSensorTemp(self): logging.debug('Reading ASIC Temp value using bcmcmd') proc = subprocess.Popen("bcmcmd \"show temp\" | grep \"maximum peak temperature\" | awk '{ print $5 }' > /var/log/asic_value 2>&1 & ",shell=True) time.sleep(2) - cmd = "kill -9 %s"%(proc.pid) - commands.getstatusoutput(cmd) + cmd = ["kill", "-9", proc.pid] + getstatusoutput_noshell(cmd) if os.stat("/var/log/asic_value").st_size == 0: value = PrevASICValue @@ -346,7 +348,7 @@ def getSensorTemp(self): logging.debug('Reading from ASIC Temp file: %s', value) logging.debug('Reading from Prev ASIC Temp Value: %s', PrevASICValue) - os.system('rm /var/log/asic_value') + subprocess.call(['rm', '/var/log/asic_value']) # 60% Duty Cycle for AFO and 70% Duty Cycle for AFI if value > temp_policy[x][0][1] and value <= temp_policy[x][0][2]: @@ -389,7 +391,9 @@ def getSensorTemp(self): isFireThresholdReached = True if (isFireThresholdPrint == True): logging.critical('CRITICAL: Fire Threshold reached: System is going to shutdown in 120 seconds') - os.system("echo 'CRITICAL: Fire Threshold reached: System is going to shutdown in 120 seconds' > /dev/console") + with open("/dev/console", 'w') as f: + f.write('CRITICAL: Fire Threshold reached: System is going to shutdown in 120 seconds') + isFireThresholdPrint = False logging.debug('Temp Sensor is set to FIRE SHUTDOWN Flag') @@ -403,7 +407,8 @@ def getSensorTemp(self): logging.debug('Temp Sensor is set to Red Alarm Flag') if (isFireThresholdReached == True): logging.critical('CRITICAL: System Stabilized, not shutting down') - os.system("echo 'CRITICAL: System Stabilized, not shutting down' > /dev/console") + with open("/dev/console", 'w') as f: + f.write('CRITICAL: System Stabilized, not shutting down\n') FireThresholdSecsRemaining = 120 isFireThresholdReached = False @@ -414,7 +419,8 @@ def getSensorTemp(self): logging.debug('Temp Sensor is set to Yellow Alarm Flag') if (isFireThresholdReached == True): logging.critical('CRITICAL: System Stabilized, not shutting down') - os.system("echo 'CRITICAL: System Stabilized, not shutting down' > /dev/console") + with open("/dev/console", 'w') as f: + f.write('CRITICAL: System Stabilized, not shutting down\n') FireThresholdSecsRemaining = 120 isFireThresholdReached = False @@ -442,7 +448,8 @@ def getSensorTemp(self): if (isFireThresholdReached == True): logging.critical('CRITICAL: System Stabilized, not shutting down') - os.system("echo 'CRITICAL: System Stabilized, not shutting down' > /dev/console") + with open("/dev/console", 'w') as f: + f.write('CRITICAL: System Stabilized, not shutting down') FireThresholdSecsRemaining = 120 isFireThresholdReached = False logging.debug('Temp Sensor is set to 80% Prev Duty Cycle Flag') @@ -457,7 +464,8 @@ def getSensorTemp(self): if (isFireThresholdReached == True): logging.critical('CRITICAL: System Stabilized, not shutting down') - os.system("echo 'CRITICAL: System Stabilized, not shutting down' > /dev/console") + with open("/dev/console", 'w') as f: + f.write('CRITICAL: System Stabilized, not shutting down\n') FireThresholdSecsRemaining = 120 isFireThresholdReached = False @@ -483,7 +491,8 @@ def getSensorTemp(self): if (isFireThresholdReached == True): logging.critical('CRITICAL: System Stabilized, not shutting down') - os.system("echo 'CRITICAL: System Stabilized, not shutting down' > /dev/console") + with open("/dev/console", 'w') as f: + f.write('CRITICAL: System Stabilized, not shutting down\n') FireThresholdSecsRemaining = 120 isFireThresholdReached = False @@ -504,7 +513,8 @@ def getSensorTemp(self): if (isFireThresholdReached == True): logging.critical('CRITICAL: System Stabilized, not shutting down') - os.system("echo 'CRITICAL: System Stabilized, not shutting down' > /dev/console") + with open("/dev/console", 'w') as f: + f.write('CRITICAL: System Stabilized, not shutting down\n') FireThresholdSecsRemaining = 120 isFireThresholdReached = False logging.debug('Temp Sensor is set to 60% Duty Cycle Flag') diff --git a/platform/broadcom/sonic-platform-modules-juniper/qfx5210/utils/juniper_qfx5210_util.py b/platform/broadcom/sonic-platform-modules-juniper/qfx5210/utils/juniper_qfx5210_util.py index 5479c0e04126..21e4c71ccea3 100755 --- a/platform/broadcom/sonic-platform-modules-juniper/qfx5210/utils/juniper_qfx5210_util.py +++ b/platform/broadcom/sonic-platform-modules-juniper/qfx5210/utils/juniper_qfx5210_util.py @@ -34,13 +34,12 @@ set : change board setting with fan|led|sfp """ -import os import commands import sys, getopt import binascii import logging import time - +import subprocess @@ -55,8 +54,8 @@ FUNCTION_NAME = '/var/log/juniper_qfx5210_util' if DEBUG == True: - print sys.argv[0] - print 'ARGV :', sys.argv[1:] + print(sys.argv[0]) + print('ARGV :', sys.argv[1:]) def main(): @@ -81,10 +80,10 @@ def main(): format= '[%(asctime)s] {%(pathname)s:%(lineno)d} %(levelname)s - %(message)s', datefmt='%H:%M:%S') - if DEBUG == True: - print options - print args - print len(sys.argv) + if DEBUG is True: + print(options) + print(args) + print(len(sys.argv)) # set up logging to console if log_level == logging.DEBUG: console = logging.StreamHandler() @@ -127,45 +126,45 @@ def main(): else: show_help() - DisableWatchDogCmd = '/usr/sbin/i2cset -f -y 0 0x65 0x3 0x04' + DisableWatchDogCmd = ['/usr/sbin/i2cset', '-f', '-y', '0', '0x65', '0x3', '0x04'] # Disable watchdog try: - os.system(DisableWatchDogCmd) + subprocess.call(DisableWatchDogCmd) except OSError: - print 'Error: Execution of "%s" failed', DisableWatchDogCmd + print('Error: Execution of "%s" failed', DisableWatchDogCmd) return False time.sleep(1) # Invoking the script which retrieves the data from Board EEPROM and storing in file - EEPROMDataCmd = 'python /usr/share/sonic/device/x86_64-juniper_qfx5210-r0/plugins/qfx5210_eeprom_data.py' + EEPROMDataCmd = ['python', '/usr/share/sonic/device/x86_64-juniper_qfx5210-r0/plugins/qfx5210_eeprom_data.py'] try: - os.system(EEPROMDataCmd) + subprocess.call(EEPROMDataCmd) except OSError: - print 'Error: Execution of "%s" failed', EEPROMDataCmd + print('Error: Execution of "%s" failed', EEPROMDataCmd) return False return True def show_help(): - print __doc__ % {'scriptName' : sys.argv[0].split("/")[-1]} + 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" + 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" + print(" use \""+ cmd + " 1-32 \" to dump sfp# eeprom") sys.exit(0) def my_log(txt): - if DEBUG == True: - print txt + if DEBUG is True: + print(txt) return def log_os_system(cmd, show): @@ -283,7 +282,7 @@ def device_install(): status, output = log_os_system(mknod[i], 1) if status: - print output + print(output) if FORCE == 0: return status @@ -291,12 +290,12 @@ def device_install(): path = "/sys/bus/i2c/devices/i2c-"+str(sfp_map[i])+"/new_device" status, output =log_os_system("echo optoe1 0x50 > " + path, 1) if status: - print output + print(output) if FORCE == 0: return status status, output =log_os_system("echo Port"+str(i)+" > /sys/bus/i2c/devices/"+str(sfp_map[i])+"-0050/port_name", 1) if status: - print output + print(output) if FORCE == 0: return status return @@ -310,7 +309,7 @@ def device_uninstall(): 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 + print(output) if FORCE == 0: return status @@ -323,7 +322,7 @@ def device_uninstall(): temp[-1] = temp[-1].replace('new_device', 'delete_device') status, output = log_os_system(" ".join(temp), 1) if status: - print output + print(output) if FORCE == 0: return status @@ -351,14 +350,14 @@ def do_install(): if FORCE == 0: return status else: - print PROJECT_NAME.upper()+" devices detected...." + print(PROJECT_NAME.upper()+" devices detected....") return def do_uninstall(): logging.info('Checking system....') if not device_exist(): - print PROJECT_NAME.upper() +" has no device installed...." + print(PROJECT_NAME.upper() +" has no device installed....") else: logging.info('Removing device....') status = device_uninstall() @@ -367,7 +366,7 @@ def do_uninstall(): return status if driver_check()== False : - print PROJECT_NAME.upper() +" has no driver installed...." + print(PROJECT_NAME.upper() +" has no driver installed....") else: logging.info('Removing installed driver....') status = driver_uninstall() @@ -421,7 +420,7 @@ def devices_info(): ALL_DEVICE[key][ key+str(i+1)].append(path) #show dict all in the order - if DEBUG == True: + if DEBUG is True: for i in sorted(ALL_DEVICE.keys()): print(i+": ") for j in sorted(ALL_DEVICE[i].keys()): @@ -448,22 +447,22 @@ def show_eeprom(index): else: log = 'Failed : no hexdump cmd!!' logging.info(log) - print log + print(log) return 1 - print node + ":" + print(node + ":") ret, log = log_os_system(hex_cmd +" -C "+node, 1) if ret==0: - print log + print(log) else: - print "**********device no found**********" + 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("System's not ready.") print("Please install first!") return @@ -474,7 +473,7 @@ def set_device(args): if int(args[1])>4: show_set_help() return - #print ALL_DEVICE['led'] + #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) @@ -489,10 +488,10 @@ def set_device(args): node = node.replace(node.split("/")[-1], 'fan_duty_cycle_percentage') ret, log = log_os_system("cat "+ node, 1) if ret==0: - print ("Previous fan duty: " + log.strip() +"%") + 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] +"%") + 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: @@ -506,7 +505,7 @@ def set_device(args): show_set_help() return - #print ALL_DEVICE[args[0]] + #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: @@ -531,26 +530,24 @@ def device_traversal(): if len(ALL_DEVICE)==0: devices_info() for i in sorted(ALL_DEVICE.keys()): - print("============================================") + print("============================================") print(i.upper()+": ") print("============================================") for j in sorted(ALL_DEVICE[i].keys(), key=get_value): - print " "+j+":", + print(" "+j+":", end=' ') 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+" ", + print(func+"="+log+" ") else: - print func+"="+"X"+" ", - print + print(func+"="+"X"+" ") print("----------------------------------------------------------------") - print return def device_exist(): diff --git a/platform/broadcom/sonic-platform-modules-juniper/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-juniper/sonic_platform/chassis.py index 9eb9b07a618f..51b846b77e66 100755 --- a/platform/broadcom/sonic-platform-modules-juniper/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-juniper/sonic_platform/chassis.py @@ -36,11 +36,11 @@ try: import os - import subprocess import sys import time import syslog from sonic_platform_base.chassis_base import ChassisBase + from sonic_py_common.general import getstatusoutput_noshell except ImportError as e: raise ImportError(str(e) + "- required module not found") @@ -242,7 +242,7 @@ def get_reboot_cause(self): log_info("Juniper Platform name: {} and {}".format(self.get_platform_name(), platform_name)) if str(platform_name) == "x86_64-juniper_networks_qfx5210-r0": log_info("Juniper Platform QFX5210 ") - status, last_reboot_reason = subprocess.getstatusoutput("i2cget -f -y 0 0x65 0x24") + status, last_reboot_reason = getstatusoutput_noshell(["i2cget", "-f", "-y", "0", "0x65", "0x24"]) if (status == 0): if last_reboot_reason == "0x80": return (ChassisBase.REBOOT_CAUSE_NON_HARDWARE, None) @@ -256,7 +256,7 @@ def get_reboot_cause(self): return (ChassisBase.REBOOT_CAUSE_HARDWARE_OTHER, "Unknown reason") else: time.sleep(3) - status, last_reboot_reason = subprocess.getstatusoutput("i2cget -f -y 0 0x65 0x24") + status, last_reboot_reason = getstatusoutput_noshell(["i2cget", "-f", "-y", "0", "0x65", "0x24"]) if last_reboot_reason == "0x80": return (ChassisBase.REBOOT_CAUSE_NON_HARDWARE, None) elif last_reboot_reason == "0x40" or last_reboot_reason == "0x08": @@ -270,9 +270,9 @@ def get_reboot_cause(self): elif str(platform_name) == "x86_64-juniper_networks_qfx5200-r0" : log_info("Juniper Platform QFX5200 ") - status, major_version = subprocess.getstatusoutput("busybox devmem 0xFED50000 8") - status, minor_version = subprocess.getstatusoutput("busybox devmem 0xFED50001 8") - status, last_reboot_reason = subprocess.getstatusoutput("busybox devmem 0xFED50004 8") + status, major_version = getstatusoutput_noshell(["busybox", "devmem", "0xFED50000", "8"]) + status, minor_version = getstatusoutput_noshell(["busybox", "devmem", "0xFED50001", "8"]) + status, last_reboot_reason = getstatusoutput_noshell(["busybox", "devmem", "0xFED50004", "8"]) if (status == 0): if (major_version == "0x31") and (minor_version == "0x03") and (last_reboot_reason == "0x80"): return (ChassisBase.REBOOT_CAUSE_NON_HARDWARE, None) @@ -288,9 +288,9 @@ def get_reboot_cause(self): return (ChassisBase.REBOOT_CAUSE_HARDWARE_OTHER, "Unknown reason") else: time.sleep(3) - status, major_version = subprocess.getstatusoutput("busybox devmem 0xFED50000 8") - status, minor_version = subprocess.getstatusoutput("busybox devmem 0xFED50001 8") - status, last_reboot_reason = subprocess.getstatusoutput("busybox devmem 0xFED50004 8") + status, major_version = getstatusoutput_noshell(["busybox", "devmem", "0xFED50000", "8"]) + status, minor_version = getstatusoutput_noshell(["busybox", "devmem", "0xFED50001", "8"]) + status, last_reboot_reason = getstatusoutput_noshell(["busybox", "devmem", "0xFED50004", "8"]) if (status == 0): if (major_version == "0x31") and (minor_version == "0x03") and (last_reboot_reason == "0x80"): return (ChassisBase.REBOOT_CAUSE_NON_HARDWARE, None) diff --git a/platform/broadcom/sonic-platform-modules-ragile/common/script/device_i2c.py b/platform/broadcom/sonic-platform-modules-ragile/common/script/device_i2c.py index cca9f0393db7..a76539019cc9 100755 --- a/platform/broadcom/sonic-platform-modules-ragile/common/script/device_i2c.py +++ b/platform/broadcom/sonic-platform-modules-ragile/common/script/device_i2c.py @@ -4,8 +4,10 @@ import click import os import time -from ragileconfig import GLOBALCONFIG, GLOBALINITPARAM, GLOBALINITCOMMAND, MAC_LED_RESET, STARTMODULE, i2ccheck_params -from ragileutil import rgpciwr, os_system, rgi2cset, io_wr +import subprocess +from ragileconfig import GLOBALCONFIG, GLOBALINITPARAM, MAC_LED_RESET, STARTMODULE, i2ccheck_params +from ragileutil import rgpciwr, rgi2cset, io_wr +from sonic_py_common.general import getstatusoutput_noshell, getstatusoutput_noshell_pipe CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help']) @@ -24,7 +26,7 @@ def get_command(self, ctx, cmd_name): def log_os_system(cmd): u'''execute shell command''' - status, output = os_system(cmd) + status, output = getstatusoutput_noshell(cmd) if status: print(output) return status, output @@ -44,7 +46,7 @@ def write_sysfs_value(reg_name, value): def check_driver(): u'''whether there is driver start with rg''' - status, output = log_os_system("lsmod | grep rg | wc -l") + status, output = getstatusoutput_noshell_pipe(["lsmod"], ["grep", "rg"], ["wc", "-l"]) #System execution error if status: return False @@ -68,61 +70,61 @@ def get_pid(name): return ret def start_avs_ctrl(): - cmd = "nohup avscontrol.py start >/dev/null 2>&1 &" + cmd = ["avscontrol.py", "start"] rets = get_pid("avscontrol.py") if len(rets) == 0: - os.system(cmd) + subprocess.Popen(cmd) def start_fan_ctrl(): if STARTMODULE['fancontrol'] == 1: - cmd = "nohup fancontrol.py start >/dev/null 2>&1 &" + cmd = ["fancontrol.py", "start"] rets = get_pid("fancontrol.py") if len(rets) == 0: - os.system(cmd) + subprocess.Popen(cmd) def starthal_fanctrl(): if STARTMODULE.get('hal_fanctrl',0) == 1: - cmd = "nohup hal_fanctrl.py start >/dev/null 2>&1 &" + cmd = ["hal_fanctrl.py", "start"] rets = get_pid("hal_fanctrl.py") if len(rets) == 0: - os.system(cmd) + subprocess.Popen(cmd) def starthal_ledctrl(): if STARTMODULE.get('hal_ledctrl',0) == 1: - cmd = "nohup hal_ledctrl.py start >/dev/null 2>&1 &" + cmd = ["hal_ledctrl.py", "start"] rets = get_pid("hal_ledctrl.py") if len(rets) == 0: - os.system(cmd) + subprocess.Popen(cmd) def start_dev_monitor(): if STARTMODULE.get('dev_monitor',0) == 1: - cmd = "nohup dev_monitor.py start >/dev/null 2>&1 &" + cmd = ["dev_monitor.py", "start"] rets = get_pid("dev_monitor.py") if len(rets) == 0: - os.system(cmd) + subprocess.Popen(cmd) def start_slot_monitor(): if STARTMODULE.get('slot_monitor',0) == 1: - cmd = "nohup slot_monitor.py start >/dev/null 2>&1 &" + cmd = ["slot_monitor.py", "start"] rets = get_pid("slot_monitor.py") if len(rets) == 0: - os.system(cmd) + subprocess.Popen(cmd) def stop_fan_ctrl(): u'''disable fan timer service''' if STARTMODULE['fancontrol'] == 1: rets = get_pid("fancontrol.py") # for ret in rets: - cmd = "kill "+ ret - os.system(cmd) + cmd = ["kill", ret] + subprocess.call(cmd) return True def stophal_ledctrl(): if STARTMODULE.get('hal_ledctrl',0) == 1: rets = get_pid("hal_ledctrl.py") for ret in rets: - cmd = "kill "+ ret - os.system(cmd) + cmd = ["kill", ret] + subprocess.call(cmd) return True @@ -131,8 +133,8 @@ def stop_dev_monitor(): if STARTMODULE.get('dev_monitor',0) == 1: rets = get_pid("dev_monitor.py") # for ret in rets: - cmd = "kill "+ ret - os.system(cmd) + cmd = ["kill", ret] + subprocess.call(cmd) return True def stop_slot_monitor(): @@ -140,31 +142,31 @@ def stop_slot_monitor(): if STARTMODULE.get('slot_monitor',0) == 1: rets = get_pid("slot_monitor.py") # for ret in rets: - cmd = "kill "+ ret - os.system(cmd) + cmd = ["kill", ret] + subprocess.call(cmd) return True def rm_dev(bus, loc): - cmd = "echo 0x%02x > /sys/bus/i2c/devices/i2c-%d/delete_device" % (loc, bus) devpath = "/sys/bus/i2c/devices/%d-%04x"%(bus, loc) if os.path.exists(devpath): - log_os_system(cmd) + with open("/sys/bus/i2c/devices/i2c-%d/delete_device" % bus, 'w') as f: + f.write('0x%02x\n' % loc) def add_dev(name, bus, loc): if name == "lm75": time.sleep(0.1) pdevpath = "/sys/bus/i2c/devices/i2c-%d/" % (bus) for i in range(1, 100):#wait for mother-bus generation,maximum wait time is 10s - if os.path.exists(pdevpath) == True: + if os.path.exists(pdevpath) is True: break time.sleep(0.1) if i % 10 == 0: click.echo("%%DEVICE_I2C-INIT: %s not found, wait 0.1 second ! i %d " % (pdevpath,i)) - cmd = "echo %s 0x%02x > /sys/bus/i2c/devices/i2c-%d/new_device" % (name, loc, bus) devpath = "/sys/bus/i2c/devices/%d-%04x"%(bus, loc) - if os.path.exists(devpath) == False: - os.system(cmd) + if os.path.exists(devpath) is False: + with open("/sys/bus/i2c/devices/i2c-%d/new_device" % bus, 'w') as f: + f.write('%s 0x%02x\n' % (name, loc)) def removedevs(): devs = GLOBALCONFIG["DEVS"] @@ -177,8 +179,7 @@ def adddevs(): add_dev(devs[dev]["name"], devs[dev]["bus"] , devs[dev]["loc"]) def checksignaldriver(name): - modisexistcmd = "lsmod | grep %s | wc -l" % name - status, output = log_os_system(modisexistcmd) + status, output = getstatusoutput_noshell_pipe(["lsmod"], ["grep", name], ["wc", "-l"]) #System execution error if status: return False @@ -188,17 +189,17 @@ def checksignaldriver(name): return False def adddriver(name, delay): - cmd = "modprobe %s" % name + cmd = ["modprobe", name] if delay != 0: time.sleep(delay) - if checksignaldriver(name) != True: - log_os_system(cmd) + if not checksignaldriver(name): + getstatusoutput_noshell(cmd) def removedriver(name, delay): realname = name.lstrip().split(" ")[0]; - cmd = "rmmod -f %s" % realname + cmd = ["rmmod", "-f", realname] if checksignaldriver(realname): - log_os_system(cmd) + getstatusoutput_noshell(cmd) def removedrivers(): u'''remove all drivers''' diff --git a/platform/broadcom/sonic-platform-modules-ragile/common/script/fancontrol.py b/platform/broadcom/sonic-platform-modules-ragile/common/script/fancontrol.py index 19214b30408e..f93e06aa865e 100755 --- a/platform/broadcom/sonic-platform-modules-ragile/common/script/fancontrol.py +++ b/platform/broadcom/sonic-platform-modules-ragile/common/script/fancontrol.py @@ -5,6 +5,7 @@ import time import traceback import glob +import subprocess from rgutil.logutil import Logger from ragileutil import wait_docker @@ -196,7 +197,7 @@ def checkslot(self, ret): loc = item_slot.get("loc") offset = item_slot.get("offset") ind, val = rgi2cget(bus, loc, offset) - if ind == True: + if ind is True: retval = val else: totalerr -= 1 @@ -259,7 +260,7 @@ def checkpsu(self, ret): loc = item_psu.get("loc") offset = item_psu.get("offset") ind, val = rgi2cget(bus, loc, offset) - if ind == True: + if ind is True: retval = val else: totalerr -= 1 @@ -321,7 +322,7 @@ def checkfan(self, ret): presentaddr = presentstatus.get("offset") presentbit = presentstatus.get("bit") ind, val = rgi2cget(presentbus, presentloc, presentaddr) - if ind == True: + if ind is True: val_t = (int(val, 16) & (1 << presentbit)) >> presentbit logger.debug( DEBUG_COMMON, @@ -343,7 +344,7 @@ def checkfan(self, ret): statusaddr = motor.get("offset", None) statusbit = motor.get("bit", None) ind, val = rgi2cget(statusbus, statusloc, statusaddr) - if ind == True: + if ind is True: val_t = (int(val, 16) & (1 << statusbit)) >> statusbit logger.debug( DEBUG_COMMON, @@ -446,7 +447,7 @@ def get_fan_status(self): try: cur_fan_status = [] ret = self.checkfan(cur_fan_status) - if ret == True: + if ret is True: self.set_fan_attr(cur_fan_status) self.fan_present_num(cur_fan_status) logger.debug(DEBUG_COMMON, "%%policy:get_fan_status success") @@ -469,7 +470,7 @@ def get_psu_status(self): try: curPsuStatus = [] ret = self.checkpsu(curPsuStatus) - if ret == True: + if ret is True: self.normal_psu_num(curPsuStatus) logger.debug(DEBUG_COMMON, "%%policy:get_psu_status success") return 0 @@ -499,7 +500,7 @@ def get_temp_status(self): try: monitortemp = [] ret = self.gettemp(monitortemp) - if ret == True: + if ret is True: self.get_monitor_temp(monitortemp) logger.debug(DEBUG_COMMON, "%%policy:get_temp_status success") return 0 @@ -511,9 +512,9 @@ def get_temp_status(self): def get_mac_status_bcmcmd(self): try: - if wait_docker(timeout=0) == True: + if wait_docker(timeout=0) is True: sta, ret = get_mac_temp() - if sta == True: + if sta is True: self._mac_aver = float(ret.get("average", self._mac_aver)) self._mac_max = float(ret.get("maximum", self._mac_max)) logger.debug( @@ -532,7 +533,7 @@ def get_mac_status_bcmcmd(self): def get_mac_status_sysfs(self, conf): try: sta, ret = get_mac_temp_sysfs(conf) - if sta == True: + if sta is True: self._mac_aver = float(ret) / 1000 self._mac_max = float(ret) / 1000 logger.debug( @@ -578,7 +579,7 @@ def get_slot_status(self): try: curSlotStatus = [] ret = self.checkslot(curSlotStatus) - if ret == True: + if ret is True: self.set_slot_attr(curSlotStatus) logger.debug(DEBUG_COMMON, "%%policy:get_slot_status success") except AttributeError as e: @@ -631,8 +632,8 @@ def start_fan_ctrl(self): self.check_crit() if ( self.critnum == 0 - and self.check_warn() == False - and self.detect_fan_status() == True + and self.check_warn() is False + and self.detect_fan_status() is True ): self.fanctrol() self.check_dev_err() @@ -768,13 +769,13 @@ def deal_sys_led_status(self): fanstatus = self.check_fan_status() psustatus = self.check_psu_status() if ( - self.check_temp_crit() == True + self.check_temp_crit() is True or fanstatus == "red" or psustatus == "red" ): status = "red" elif ( - self.check_temp_warn() == True + self.check_temp_warn() is True or fanstatus == "yellow" or psustatus == "yellow" ): @@ -864,7 +865,7 @@ def setled(self, item, color): else: mask = item.get("mask", 0xFF) ind, val = rgi2cget(item["bus"], item["devno"], item["addr"]) - if ind == True: + if ind is True: setval = (int(val, 16) & ~mask) | item.get(color) rgi2cset(item["bus"], item["devno"], item["addr"], setval) else: @@ -884,12 +885,12 @@ def set_sys_psu_leds(self, color): def check_warn(self): try: - if self.check_temp_warn() == True: + if self.check_temp_warn() is True: logger.debug(DEBUG_FANCONTROL, "anti-shake start") time.sleep(MONITOR_CONST.SHAKE_TIME) logger.debug(DEBUG_FANCONTROL, "anti-shake end") self.board_moni_msg() # re-read - if self.check_temp_warn() == True: + if self.check_temp_warn() is True: logger.warn("%%DEV_MONITOR-TEMP:The temperature of device is over warning value.") self.set_fan_max_speed() # fan full speed return True @@ -900,19 +901,19 @@ def check_warn(self): def check_crit(self): try: - if self.check_temp_crit() == True: + if self.check_temp_crit() is True: logger.debug(DEBUG_FANCONTROL, "anti-shake start") time.sleep(MONITOR_CONST.SHAKE_TIME) logger.debug(DEBUG_FANCONTROL, "anti-shake end") self.board_moni_msg() # re-read - if self.check_temp_crit() == True: + if self.check_temp_crit() is True: logger.crit( "%%DEV_MONITOR-TEMP:The temperature of device is over critical value.", ) self.set_fan_max_speed() # fan full speed self.critnum += 1 # anti-shake if self.critnum >= MONITOR_CONST.CRITICAL_NUM: - os.system("reboot") + subprocess.call(["reboot"]) logger.debug(DEBUG_FANCONTROL, "crit times:%d" % self.critnum) else: self.critnum = 0 @@ -929,7 +930,7 @@ def callback(): def do_fan_ctrl(fanctrl): ret = fanctrl.board_moni_msg() - if ret == True: + if ret is True: logger.debug(DEBUG_FANCONTROL, "%%policy:start_fan_ctrl") fanctrl.start_fan_ctrl() else: diff --git a/platform/broadcom/sonic-platform-modules-ragile/common/script/ragileutil.py b/platform/broadcom/sonic-platform-modules-ragile/common/script/ragileutil.py index debfcad5bc6d..72ff74c2daa1 100755 --- a/platform/broadcom/sonic-platform-modules-ragile/common/script/ragileutil.py +++ b/platform/broadcom/sonic-platform-modules-ragile/common/script/ragileutil.py @@ -9,11 +9,6 @@ # Copyright: (c) rd 2018 # ------------------------------------------------------------------------- import sys - -if sys.version_info >= (3, 0): - import subprocess as commands -else: - import commands import os import re import syslog @@ -49,6 +44,7 @@ try: from eepromutil.fru import ipmifru + from sonic_py_common.general import getstatusoutput_noshell, getstatusoutput_noshell_pipe except Exception or SystemExit: pass @@ -344,21 +340,21 @@ def __init__(self, param="ERROR", errno="-1"): def checkinput(b): - if b.isdigit() == False: + if b.isdigit() is False: raise Exception("Ivalid Number") if int(b) > 0xFF or int(b) < 0: raise Exception("Out of area") def checkinputproduct(b): - if b.isalnum() == False: + if b.isalnum() is False: raise Exception("Invalid string") def getInputSetmac(val): bia = val.boardInfoArea pia = val.productInfoArea - if bia != None: + if bia is not None: a = raw_input("[Board Card]Product Serial Number:") if len(a) != 13: raise Exception("Invalid Serial Number length") @@ -368,7 +364,7 @@ def getInputSetmac(val): checkinput(b) b = "%0x" % int(b) bia.boardextra1 = b.upper() - if pia != None: + if pia is not None: a = raw_input("[Product Area]Product Serial Number:") if len(a) != 13: raise Exception("Invalid Serial Number") @@ -633,7 +629,7 @@ def mac_adj(): macavs = 0 name = MAC_DEFAULT_PARAM["sdkreg"] ret, status = getSdkReg(name) - if ret == False: + if ret is False: return False status = strtoint(status) # shift operation @@ -711,8 +707,8 @@ def __new__(cls, *args, **kwargs): def getSdkReg(reg): try: - cmd = "bcmcmd -t 1 'getr %s ' < /dev/null" % reg - ret, result = os_system(cmd) + cmd = ["bcmcmd", "-t", "1", 'getr '+str(reg)] + ret, result = getstatusoutput_noshell(cmd) result_t = result.strip().replace("\r", "").replace("\n", "") if ret != 0 or "Error:" in result_t: return False, result @@ -807,8 +803,8 @@ def get_mac_temp(): result = {} # wait_docker() # exec twice, get the second result - os_system('bcmcmd -t 1 "show temp" < /dev/null') - ret, log = os_system('bcmcmd -t 1 "show temp" < /dev/null') + getstatusoutput_noshell(["bcmcmd", "-t", "1", "show temp"]) + ret, log = getstatusoutput_noshell(["bcmcmd", "-t", "1", "show temp"]) if ret: return False, result else: @@ -875,21 +871,21 @@ def restartDockerService(force=False): "teamd", "pmon", ] - ret, status = os_system("docker ps") + ret, status = getstatusoutput_noshell(["docker", "ps"]) if ret == 0: for tmpname in container_name: if tmpname not in status: if force == True: - os_system("docker restart %s" % tmpname) + getstatusoutput_noshell(["docker", "restart", tmpname]) else: - os_system("systemctl restart %s" % tmpname) + getstatusoutput_noshell(["systemctl", "restart", tmpname]) def wait_dhcp(timeout): time_cnt = 0 while True: try: - ret, status = os_system("systemctl status dhcp_relay.service") + ret, status = getstatusoutput_noshell(["systemctl", "status", "dhcp_relay.service"]) if (ret == 0 and "running" in status) or "SUCCESS" in status: break else: @@ -1028,10 +1024,12 @@ def isValidMac(mac): def util_setmac(eth, mac): rulefile = "/etc/udev/rules.d/70-persistent-net.rules" - if isValidMac(mac) == False: + if isValidMac(mac) is False: return False, "MAC invaild" - cmd = "ethtool -e %s | grep 0x0010 | awk '{print \"0x\"$13$12$15$14}'" % eth - ret, log = os_system(cmd) + cmd1 = ["ethtool", "-e", eth] + cmd2 = ["grep", "0x0010"] + cmd3 = ["awk", '{print \"0x\"$13$12$15$14}'] + ret, log = getstatusoutput_noshell_pipe(cmd1, cmd2, cmd3) log_debug(log) magic = "" if ret == 0 and len(log): @@ -1039,22 +1037,22 @@ def util_setmac(eth, mac): macs = mac.upper().split(":") # chage ETH0 to value after setmac - ifconfigcmd = "ifconfig eth0 hw ether %s" % mac + ifconfigcmd = ["ifconfig", "eth0", "hw", "ether", mac] log_debug(ifconfigcmd) - ret, status = os_system(ifconfigcmd) + ret, status = getstatusoutput_noshell(ifconfigcmd) if ret: raise SETMACException("software set Internet card MAC error") index = 0 for item in macs: - cmd = "ethtool -E %s magic %s offset %d value 0x%s" % (eth, magic, index, item) + cmd = ["ethtool", "-E", eth, "magic", magic, "offset", str(offset), "value", "0x"+str(item)] log_debug(cmd) index += 1 - ret, log = os_system(cmd) + ret, log = getstatusoutput_noshell(cmd) if ret != 0: raise SETMACException("set hardware Internet card MAC error") # get value after setting - cmd_t = "ethtool -e eth0 offset 0 length 6" - ret, log = os_system(cmd_t) + cmd_t = ["ethtool", "-e", "eth0", "offset", "0", "length", "6"] + ret, log = getstatusoutput_noshell(cmd_t) m = re.split(":", log)[-1].strip().upper() mac_result = m.upper().split(" ") @@ -1143,7 +1141,7 @@ def changeTypeValue(_value, type1, tips, example): release_mac += name[i * 2 : i * 2 + 2] else: release_mac += ":" + name[i * 2 : i * 2 + 2] - if isValidMac(release_mac) == True: + if isValidMac(release_mac) is True: _value[type1] = release_mac else: raise SETMACException("MAC address invaild, check please") @@ -1158,7 +1156,7 @@ def changeTypeValue(_value, type1, tips, example): else: raise SETMACException("Version is not number, check please") elif type1 == TLV_CODE_SERIAL_NUMBER: - if name.isalnum() == False: + if name.isalnum() is False: raise SETMACException("Serial Number invaild string, check please") elif len(name) != 13: raise SETMACException("Serial Number length incorrect, check please") @@ -1185,11 +1183,11 @@ def generate_ext(cardid): def rgi2cget(bus, devno, address): - command_line = "i2cget -f -y %d 0x%02x 0x%02x " % (bus, devno, address) + command_line = ["i2cget", "-f", "-y", str(bus), "0x%02x"%devno, "0x%02x"%address] retrytime = 6 ret_t = "" for i in range(retrytime): - ret, ret_t = os_system(command_line) + ret, ret_t = getstatusoutput_noshell(command_line) if ret == 0: return True, ret_t time.sleep(0.1) @@ -1197,11 +1195,11 @@ def rgi2cget(bus, devno, address): def rgi2cset(bus, devno, address, byte): - command_line = "i2cset -f -y %d 0x%02x 0x%02x 0x%02x" % (bus, devno, address, byte) + command_line = ["i2cset", "-f", "-y", str(bus), "0x%02x"%devno, "0x%02x"%address, "0x%02x"%byte] retrytime = 6 ret_t = "" for i in range(retrytime): - ret, ret_t = os_system(command_line) + ret, ret_t = getstatusoutput_noshell(command_line) if ret == 0: return True, ret_t return False, ret_t @@ -1252,30 +1250,30 @@ def rgpciwr(pcibus, slot, fn, bar, offset, data): def rgsysset(location, value): - command_line = "echo 0x%02x > %s" % (value, location) retrytime = 6 - ret_t = "" for i in range(retrytime): - ret, ret_t = os_system(command_line) - if ret == 0: - return True, ret_t - return False, ret_t + try: + with open(location, 'w') as f: + f.write('0x%02x\n' % value) + except (IOError, FileNotFoundError) as e: + return False, str(e) + return True, '' def rgi2cget_word(bus, devno, address): - command_line = "i2cget -f -y %d 0x%02x 0x%02x w" % (bus, devno, address) + command_line = ["i2cget", "-f", "-y", str(bus), "0x%02x"%devno, "0x%02x"%address, 'w'] retrytime = 3 ret_t = "" for i in range(retrytime): - ret, ret_t = os_system(command_line) + ret, ret_t = getstatusoutput_noshell(command_line) if ret == 0: return True, ret_t return False, ret_t def rgi2cset_word(bus, devno, address, byte): - command_line = "i2cset -f -y %d 0x%02x 0x%02x 0x%x w" % (bus, devno, address, byte) - os_system(command_line) + command_line = ["i2cset", "-f", "-y", str(bus), "0x%02x"%devno, "0x%02x"%address, "0x%02x"%byte, 'w'] + getstatusoutput_noshell(command_line) def fan_setmac(): @@ -1395,7 +1393,7 @@ def fac_fans_setmac_tlv(ret): while True: print("Please input[%s]:" % "Serial Number") fan_sn = raw_input() - if checkfansninput(fan_sn, fansntemp) == False: + if checkfansninput(fan_sn, fansntemp) is False: continue fansntemp.append(fan_sn) fan_sn = fan_sn + chr(0x00) @@ -1404,7 +1402,7 @@ def fac_fans_setmac_tlv(ret): while True: print("Please input[%s]:" % "hardware version") hwinfo = raw_input() - if checkfanhwinput(hwinfo) == False: + if checkfanhwinput(hwinfo) is False: continue fan_hwinfo = hwinfo + chr(0x00) fane2.typehwinfo = fan_hwinfo + chr(0x00) @@ -1416,7 +1414,7 @@ def fac_fans_setmac_tlv(ret): print("\n*******************************\n") util_show_fanse2(fans) - if getInputCheck("check input correctly or not(Yes/No):") == True: + if getInputCheck("check input correctly or not(Yes/No):") is True: for fan in fans: log_debug("ouput fan") fac_fan_setmac(fan) @@ -1512,14 +1510,15 @@ def writeToEEprom(rst_arr): elif dealtype == "io": io_wr(E2_PROTECT["io_addr"], E2_PROTECT["close"]) # deal last drivers - os.system("rmmod at24 ") - os.system("modprobe at24 ") - os.system("rm -f /var/cache/sonic/decode-syseeprom/syseeprom_cache") + subprocess.call(["rmmod", "at24"]) + subprocess.call(["modprobe", "at24"]) + subprocess.call(["rm", "-f", "/var/cache/sonic/decode-syseeprom/syseeprom_cache"]) def get_local_eth0_mac(): - cmd = "ifconfig eth0 |grep HWaddr" - print(os_system(cmd)) + cmd1 = ["ifconfig", "eth0"] + cmd2 = ["grep", "HWaddr"] + print(getstatusoutput_noshell_pipe(cmd1, cmd2)) def getonieversion(): @@ -1581,13 +1580,13 @@ def fac_board_setmac(): ) # add setmac time rst, ret = generate_value(_value) if ( - util_setmac("eth0", _value[TLV_CODE_MAC_BASE]) == True + util_setmac("eth0", _value[TLV_CODE_MAC_BASE]) is True ): # set Internet cardIP writeToEEprom(rst) # write to e2 # set BMC MAC if "bmcsetmac" in FACTESTMODULE and FACTESTMODULE["bmcsetmac"] == 1: bmcmac = createbmcMac(_value[TLV_CODE_MAC_BASE]) - if ipmi_set_mac(bmcmac) == True: + if ipmi_set_mac(bmcmac) is True: print("BMC MAC[%s]" % bmcmac) else: print("SET BMC MAC FAILED") @@ -1605,12 +1604,12 @@ def fac_board_setmac(): def ipmi_set_mac(mac): macs = mac.split(":") - cmdinit = "ipmitool raw 0x0c 0x01 0x01 0xc2 0x00" - cmdset = "ipmitool raw 0x0c 0x01 0x01 0x05" + cmdinit = ["ipmitool", "raw", "0x0c", "0x01", "0x01", "0xc2", "0x00"] + cmdset = ["ipmitool", "raw", "0x0c", "0x01", "0x01", "0x05"] for ind in range(len(macs)): - cmdset += " 0x%02x" % int(macs[ind], 16) - os_system(cmdinit) - ret, status = os_system(cmdset) + cmdset.append("0x%02x" % int(macs[ind], 16)) + getstatusoutput_noshell(cmdinit) + ret, status = getstatusoutput_noshell(cmdset) if ret: RJPRINTERR("\n\n%s\n\n" % status) return False @@ -1637,8 +1636,8 @@ def bmc_setmac(): release_mac += name[i * 2 : i * 2 + 2] else: release_mac += ":" + name[i * 2 : i * 2 + 2] - if isValidMac(release_mac) == True: - if ipmi_set_mac(release_mac) == True: + if isValidMac(release_mac) is True: + if ipmi_set_mac(release_mac) is True: return True else: RJPRINTERR("\nMAC address invaild, try again\n") @@ -1650,11 +1649,11 @@ def closeProtocol(): log_info("disable LLDP") sys.stdout.write(".") sys.stdout.flush() - os_system("systemctl stop lldp.service") + getstatusoutput_noshell(["systemctl", "stop", "lldp.service"]) log_info("disable lldp service") sys.stdout.write(".") sys.stdout.flush() - os_system("systemctl stop bgp.service") + getstatusoutput_noshell(["systemctl", "stop", "bgp.service"]) log_info("disable bgp service") sys.stdout.write(".") sys.stdout.flush() @@ -1678,8 +1677,8 @@ def checkSdkMem(): with open(file_name, "w") as f: f.write(file_data) print("change SDK memory to 256, reboot required") - os_system("sync") - os_system("reboot") + getstatusoutput_noshell(["sync"]) + getstatusoutput_noshell(["reboot"]) ########################################################################## @@ -1868,26 +1867,21 @@ def getCardId(): return None -# ==================================== -# execute shell command -# ==================================== -def os_system(cmd): - status, output = commands.getstatusoutput(cmd) - return status, output - - ########################################### # get memory slot and number via DMI command ########################################### def getsysmeminfo(): - ret, log = os_system("which dmidecode ") + ret, log = getstatusoutput_noshell(["which", "dmidecode"]) if ret != 0 or len(log) <= 0: error = "cmd find dmidecode" return False, error - cmd = log + '|grep -P -A5 "Memory\s+Device"|grep Size|grep -v Range' + cmd1 = [log] + cmd2 = ['grep', '-P', '-A5', "Memory\s+Device"] + cmd3 = ['grep', 'Size'] + cmd4 = ['grep', '-v', 'Range'] # get total number first result = [] - ret1, log1 = os_system(cmd) + ret1, log1 = getstatusoutput_noshell_pipe(cmd1, cmd2, cmd3, cmd4) if ret1 == 0 and len(log1): log1 = log1.lstrip() arr = log1.split("\n") @@ -1908,13 +1902,16 @@ def getsysmeminfo(): # return various arrays ########################################### def getsysmeminfo_detail(): - ret, log = os_system("which dmidecode ") + ret, log = getstatusoutput_noshell(["which", "dmidecode"]) if ret != 0 or len(log) <= 0: error = "cmd find dmidecode" return False, error - cmd = log + ' -t 17 | grep -A21 "Memory Device"' # 17 + cmd1 = [log] + cmd2 = ['-t', '17'] + cmd3 = ['grep', '-A21', "Memory Device"] # 17 + cmd = ' '.join(cmd1) + ' '.join(cmd2) + ' '.join(cmd3) # get total number - ret1, log1 = os_system(cmd) + ret1, log1 = getstatusoutput_noshell_pipe(cmd1, cmd2, cmd3) if ret1 != 0 or len(log1) <= 0: return False, "command execution error[%s]" % cmd result_t = log1.split("--") @@ -1935,13 +1932,13 @@ def getsysmeminfo_detail(): # get BIOS info via DMI command ########################################### def getDmiSysByType(type_t): - ret, log = os_system("which dmidecode ") + ret, log = getstatusoutput_noshell(["which", "dmidecode"]) if ret != 0 or len(log) <= 0: error = "cmd find dmidecode" return False, error - cmd = log + " -t %s" % type_t + cmd = [log] + ["-t", type_t] # get total number - ret1, log1 = os_system(cmd) + ret1, log1 = getstatusoutput_noshell(cmd) if ret1 != 0 or len(log1) <= 0: return False, "command execution error[%s]" % cmd its = log1.replace("\t", "").strip().split("\n") @@ -2000,11 +1997,11 @@ def getUsbLocation(): # judge USB file def getusbinfo(): ret, path = getUsbLocation() - if ret == False: + if ret is False: return False, "not usb exists" str = os.path.join(path, "size") ret, value = getfilevalue(str) - if ret == True: + if ret is True: return ( True, { @@ -2017,9 +2014,10 @@ def getusbinfo(): def get_cpu_info(): - cmd = "cat /proc/cpuinfo |grep processor -A18" # 17 - - ret, log1 = os_system(cmd) + cmd1 = ["cat", "/proc/cpuinfo"] + cmd2 = ["grep", "processor", "-A18"] # 17 + cmd = ' '.join(cmd1) + ' '.join(cmd2) + ret, log1 = getstatusoutput_noshell_pipe(cmd1, cmd2) if ret != 0 or len(log1) <= 0: return False, "command execution error[%s]" % cmd result_t = log1.split("--") diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_pcie/pcie_common.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_pcie/pcie_common.py index 56e9d8664a23..12f1cc8ed7b9 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_pcie/pcie_common.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_pcie/pcie_common.py @@ -37,14 +37,14 @@ def get_pcie_device(self): pciList = [] p1 = "^(\w+):(\w+)\.(\w)\s(.*)\s*\(*.*\)*" p2 = "^.*:.*:.*:(\w+)\s*\(*.*\)*" - command1 = "sudo lspci" - command2 = "sudo lspci -n" + command1 = ["sudo", "lspci"] + command2 = ["sudo", "lspci", "-n"] # run command 1 - proc1 = subprocess.Popen(command1, shell=True, universal_newlines=True, stdout=subprocess.PIPE) + proc1 = subprocess.Popen(command1, universal_newlines=True, stdout=subprocess.PIPE) output1 = proc1.stdout.readlines() proc1.communicate() # run command 2 - proc2 = subprocess.Popen(command2, shell=True, universal_newlines=True, stdout=subprocess.PIPE) + proc2 = subprocess.Popen(command2, universal_newlines=True, stdout=subprocess.PIPE) output2 = proc2.stdout.readlines() proc2.communicate() diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/common.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/common.py index c1a85f618609..e1bef19c24d7 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/common.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/common.py @@ -1,6 +1,6 @@ import os import yaml - +import subprocess from sonic_py_common import device_info @@ -10,13 +10,13 @@ class Common: PMON_PLATFORM_PATH = '/usr/share/sonic/platform/' CONFIG_DIR = 'sonic_platform_config' - HOST_CHK_CMD = "docker > /dev/null 2>&1" + HOST_CHK_CMD = ["docker"] def __init__(self): (self.platform, self.hwsku) = device_info.get_platform_and_hwsku() def is_host(self): - return os.system(self.HOST_CHK_CMD) == 0 + return subprocess.call(self.HOST_CHK_CMD) == 0 def load_json_file(self, path): """ diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/component.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/component.py index 7c6fd2df4335..beb701cb5902 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/component.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/component.py @@ -8,10 +8,10 @@ ######################################################################## try: - import subprocess from sonic_platform_base.component_base import ComponentBase from sonic_platform.regutil import Reg from sonic_platform.logger import logger + from sonic_py_common.general import getstatusoutput_noshell except ImportError as e: raise ImportError(str(e) + "- required module not found") @@ -70,12 +70,12 @@ def install_firmware(self, image_path): """ try: successtips = "CPLD Upgrade succeeded!" - status, output = subprocess.getstatusoutput("which firmware_upgrade") + status, output = getstatusoutput_noshell(["which", "firmware_upgrade"]) if status or len(output) <= 0: logger.error("no upgrade tool.") return False - cmdstr = "%s %s cpld %d cpld"%(output,image_path,self.slot) - ret, log = subprocess.getstatusoutput(cmdstr) + cmdstr = [output, image_path, "cpld", str(self.slot), "cpld"] + ret, log = getstatusoutput_noshell(cmdstr) if ret == 0 and successtips in log: return True logger.error("upgrade failed. ret:%d, log:\n%s" % (ret, log)) diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_pcie/pcie_common.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_pcie/pcie_common.py index 56e9d8664a23..12f1cc8ed7b9 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_pcie/pcie_common.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_pcie/pcie_common.py @@ -37,14 +37,14 @@ def get_pcie_device(self): pciList = [] p1 = "^(\w+):(\w+)\.(\w)\s(.*)\s*\(*.*\)*" p2 = "^.*:.*:.*:(\w+)\s*\(*.*\)*" - command1 = "sudo lspci" - command2 = "sudo lspci -n" + command1 = ["sudo", "lspci"] + command2 = ["sudo", "lspci", "-n"] # run command 1 - proc1 = subprocess.Popen(command1, shell=True, universal_newlines=True, stdout=subprocess.PIPE) + proc1 = subprocess.Popen(command1, universal_newlines=True, stdout=subprocess.PIPE) output1 = proc1.stdout.readlines() proc1.communicate() # run command 2 - proc2 = subprocess.Popen(command2, shell=True, universal_newlines=True, stdout=subprocess.PIPE) + proc2 = subprocess.Popen(command2, universal_newlines=True, stdout=subprocess.PIPE) output2 = proc2.stdout.readlines() proc2.communicate() diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/chassis.py index 4783c96b1801..9267a18f0b50 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/chassis.py @@ -6,9 +6,9 @@ try: import time - import subprocess from sonic_platform_pddf_base.pddf_chassis import PddfChassis from rgutil.logutil import Logger + from sonic_py_common.general import getstatusoutput_noshell except ImportError as e: raise ImportError(str(e) + "- required module not found") @@ -30,14 +30,14 @@ class Chassis(PddfChassis): def __init__(self, pddf_data=None, pddf_plugin_data=None): PddfChassis.__init__(self, pddf_data, pddf_plugin_data) - self.enable_read = "i2cset -f -y 2 0x35 0x2a 0x01" - self.disable_read = "i2cset -f -y 2 0x35 0x2a 0x00" - self.enable_write = "i2cset -f -y 2 0x35 0x2b 0x00" - self.disable_write = "i2cset -f -y 2 0x35 0x2b 0x01" - self.enable_erase = "i2cset -f -y 2 0x35 0x2c 0x01" - self.disable_erase = "i2cset -f -y 2 0x35 0x2c 0x00" - self.read_value = "i2cget -f -y 2 0x35 0x25" - self.write_value = "i2cset -f -y 2 0x35 0x21 0x0a" + self.enable_read = ["i2cset", "-f", "-y", "2", "0x35", "0x2a", "0x01"] + self.disable_read = ["i2cset", "-f", "-y", "2", "0x35", "0x2a", "0x00"] + self.enable_write = ["i2cset", "-f", "-y", "2", "0x35", "0x2b", "0x00"] + self.disable_write = ["i2cset", "-f", "-y", "2", "0x35", "0x2b", "0x01"] + self.enable_erase = ["i2cset", "-f", "-y", "2", "0x35", "0x2c", "0x01"] + self.disable_erase = ["i2cset", "-f", "-y", "2", "0x35", "0x2c", "0x00"] + self.read_value = ["i2cget", "-f", "-y", "2", "0x35", "0x25"] + self.write_value = ["i2cset", "-f", "-y", "2", "0x35", "0x21", "0x0a"] def get_reboot_cause(self): """ @@ -52,25 +52,25 @@ def get_reboot_cause(self): try: is_power_loss = False # enable read - subprocess.getstatusoutput(self.disable_write) - subprocess.getstatusoutput(self.enable_read) - ret, log = subprocess.getstatusoutput(self.read_value) + getstatusoutput_noshell(self.disable_write) + getstatusoutput_noshell(self.enable_read) + ret, log = getstatusoutput_noshell(self.read_value) if ret == 0 and "0x0a" in log: is_power_loss = True # erase i2c and e2 - subprocess.getstatusoutput(self.enable_erase) + getstatusoutput_noshell(self.enable_erase) time.sleep(1) - subprocess.getstatusoutput(self.disable_erase) + getstatusoutput_noshell(self.disable_erase) # clear data - subprocess.getstatusoutput(self.enable_write) - subprocess.getstatusoutput(self.disable_read) - subprocess.getstatusoutput(self.disable_write) - subprocess.getstatusoutput(self.enable_read) + getstatusoutput_noshell(self.enable_write) + getstatusoutput_noshell(self.disable_read) + getstatusoutput_noshell(self.disable_write) + getstatusoutput_noshell(self.enable_read) # enable write and set data - subprocess.getstatusoutput(self.enable_write) - subprocess.getstatusoutput(self.disable_read) - subprocess.getstatusoutput(self.write_value) + getstatusoutput_noshell(self.enable_write) + getstatusoutput_noshell(self.disable_read) + getstatusoutput_noshell(self.write_value) if is_power_loss: return(self.REBOOT_CAUSE_POWER_LOSS, None) except Exception as e: diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/common.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/common.py index c1a85f618609..e1bef19c24d7 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/common.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/common.py @@ -1,6 +1,6 @@ import os import yaml - +import subprocess from sonic_py_common import device_info @@ -10,13 +10,13 @@ class Common: PMON_PLATFORM_PATH = '/usr/share/sonic/platform/' CONFIG_DIR = 'sonic_platform_config' - HOST_CHK_CMD = "docker > /dev/null 2>&1" + HOST_CHK_CMD = ["docker"] def __init__(self): (self.platform, self.hwsku) = device_info.get_platform_and_hwsku() def is_host(self): - return os.system(self.HOST_CHK_CMD) == 0 + return subprocess.call(self.HOST_CHK_CMD) == 0 def load_json_file(self, path): """ diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/component.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/component.py index ef9e6e3539e0..1d171a58e435 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/component.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/component.py @@ -8,10 +8,10 @@ ######################################################################## try: - import subprocess from sonic_platform_base.component_base import ComponentBase from sonic_platform.regutil import Reg from sonic_platform.logger import logger + from sonic_py_common.general import getstatusoutput_noshell except ImportError as e: raise ImportError(str(e) + "- required module not found") @@ -70,16 +70,16 @@ def install_firmware(self, image_path): """ try: successtips = "CPLD Upgrade succeeded!" - status, output = subprocess.getstatusoutput("which firmware_upgrade") + status, output = getstatusoutput_noshell(["which", "firmware_upgrade"]) if status or len(output) <= 0: logger.error("no upgrade tool.") return False - cmdstr = "%s %s cpld %d cpld"%(output,image_path,self.slot) - ret, log = subprocess.getstatusoutput(cmdstr) + cmdstr = [output, image_path, "cpld", str(self.slot), "cpld"] + ret, log = getstatusoutput_noshell(cmdstr) if ret == 0 and successtips in log: return True logger.error("upgrade failed. ret:%d, log:\n%s" % (ret, log)) except Exception as e: logger.error(str(e)) return False - + diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/sonic_platform/chassis.py index f4750f4abd5f..396a96420e21 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/sonic_platform/chassis.py @@ -8,9 +8,9 @@ try: import time - import subprocess from sonic_platform_pddf_base.pddf_chassis import PddfChassis from rgutil.logutil import Logger + from sonic_py_common.general import getstatusoutput_noshell except ImportError as e: raise ImportError(str(e) + "- required module not found") @@ -32,14 +32,14 @@ class Chassis(PddfChassis): def __init__(self, pddf_data=None, pddf_plugin_data=None): PddfChassis.__init__(self, pddf_data, pddf_plugin_data) - self.enable_read = "i2cset -f -y 2 0x35 0x2a 0x01" - self.disable_read = "i2cset -f -y 2 0x35 0x2a 0x00" - self.enable_write = "i2cset -f -y 2 0x35 0x2b 0x00" - self.disable_write = "i2cset -f -y 2 0x35 0x2b 0x01" - self.enable_erase = "i2cset -f -y 2 0x35 0x2c 0x01" - self.disable_erase = "i2cset -f -y 2 0x35 0x2c 0x00" - self.read_value = "i2cget -f -y 2 0x35 0x25" - self.write_value = "i2cset -f -y 2 0x35 0x21 0x0a" + self.enable_read = ["i2cset", "-f", "-y", "2", "0x35", "0x2a", "0x01"] + self.disable_read = ["i2cset", "-f", "-y", "2", "0x35", "0x2a", "0x00"] + self.enable_write = ["i2cset", "-f", "-y", "2", "0x35", "0x2b", "0x00"] + self.disable_write = ["i2cset", "-f", "-y", "2", "0x35", "0x2b", "0x01"] + self.enable_erase = ["i2cset", "-f", "-y", "2", "0x35", "0x2c", "0x01"] + self.disable_erase = ["i2cset", "-f", "-y", "2", "0x35", "0x2c", "0x00"] + self.read_value = ["i2cget", "-f", "-y", "2", "0x35", "0x25"] + self.write_value = ["i2cset", "-f", "-y", "2", "0x35", "0x21", "0x0a"] def get_reboot_cause(self): """ @@ -54,25 +54,25 @@ def get_reboot_cause(self): try: is_power_loss = False # enable read - subprocess.getstatusoutput(self.disable_write) - subprocess.getstatusoutput(self.enable_read) - ret, log = subprocess.getstatusoutput(self.read_value) + getstatusoutput_noshell(self.disable_write) + getstatusoutput_noshell(self.enable_read) + ret, log = getstatusoutput_noshell(self.read_value) if ret == 0 and "0x0a" in log: is_power_loss = True # erase i2c and e2 - subprocess.getstatusoutput(self.enable_erase) + getstatusoutput_noshell(self.enable_erase) time.sleep(1) - subprocess.getstatusoutput(self.disable_erase) + getstatusoutput_noshell(self.disable_erase) # clear data - subprocess.getstatusoutput(self.enable_write) - subprocess.getstatusoutput(self.disable_read) - subprocess.getstatusoutput(self.disable_write) - subprocess.getstatusoutput(self.enable_read) + getstatusoutput_noshell(self.enable_write) + getstatusoutput_noshell(self.disable_read) + getstatusoutput_noshell(self.disable_write) + getstatusoutput_noshell(self.enable_read) # enable write and set data - subprocess.getstatusoutput(self.enable_write) - subprocess.getstatusoutput(self.disable_read) - subprocess.getstatusoutput(self.write_value) + getstatusoutput_noshell(self.enable_write) + getstatusoutput_noshell(self.disable_read) + getstatusoutput_noshell(self.write_value) if is_power_loss: return(self.REBOOT_CAUSE_POWER_LOSS, None) except Exception as e: diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/sonic_platform/common.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/sonic_platform/common.py index c1a85f618609..e1bef19c24d7 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/sonic_platform/common.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/sonic_platform/common.py @@ -1,6 +1,6 @@ import os import yaml - +import subprocess from sonic_py_common import device_info @@ -10,13 +10,13 @@ class Common: PMON_PLATFORM_PATH = '/usr/share/sonic/platform/' CONFIG_DIR = 'sonic_platform_config' - HOST_CHK_CMD = "docker > /dev/null 2>&1" + HOST_CHK_CMD = ["docker"] def __init__(self): (self.platform, self.hwsku) = device_info.get_platform_and_hwsku() def is_host(self): - return os.system(self.HOST_CHK_CMD) == 0 + return subprocess.call(self.HOST_CHK_CMD) == 0 def load_json_file(self, path): """ diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/sonic_pcie/pcie_common.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/sonic_pcie/pcie_common.py index 56e9d8664a23..12f1cc8ed7b9 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/sonic_pcie/pcie_common.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/sonic_pcie/pcie_common.py @@ -37,14 +37,14 @@ def get_pcie_device(self): pciList = [] p1 = "^(\w+):(\w+)\.(\w)\s(.*)\s*\(*.*\)*" p2 = "^.*:.*:.*:(\w+)\s*\(*.*\)*" - command1 = "sudo lspci" - command2 = "sudo lspci -n" + command1 = ["sudo", "lspci"] + command2 = ["sudo", "lspci", "-n"] # run command 1 - proc1 = subprocess.Popen(command1, shell=True, universal_newlines=True, stdout=subprocess.PIPE) + proc1 = subprocess.Popen(command1, universal_newlines=True, stdout=subprocess.PIPE) output1 = proc1.stdout.readlines() proc1.communicate() # run command 2 - proc2 = subprocess.Popen(command2, shell=True, universal_newlines=True, stdout=subprocess.PIPE) + proc2 = subprocess.Popen(command2, universal_newlines=True, stdout=subprocess.PIPE) output2 = proc2.stdout.readlines() proc2.communicate() diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/sonic_platform/common.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/sonic_platform/common.py index c1a85f618609..e1bef19c24d7 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/sonic_platform/common.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/sonic_platform/common.py @@ -1,6 +1,6 @@ import os import yaml - +import subprocess from sonic_py_common import device_info @@ -10,13 +10,13 @@ class Common: PMON_PLATFORM_PATH = '/usr/share/sonic/platform/' CONFIG_DIR = 'sonic_platform_config' - HOST_CHK_CMD = "docker > /dev/null 2>&1" + HOST_CHK_CMD = ["docker"] def __init__(self): (self.platform, self.hwsku) = device_info.get_platform_and_hwsku() def is_host(self): - return os.system(self.HOST_CHK_CMD) == 0 + return subprocess.call(self.HOST_CHK_CMD) == 0 def load_json_file(self, path): """ diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/sonic_platform/component.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/sonic_platform/component.py index 7c6fd2df4335..c2ce40ef6a93 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/sonic_platform/component.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/sonic_platform/component.py @@ -8,10 +8,10 @@ ######################################################################## try: - import subprocess from sonic_platform_base.component_base import ComponentBase from sonic_platform.regutil import Reg from sonic_platform.logger import logger + from sonic_py_common.general import getstatusoutput_noshell except ImportError as e: raise ImportError(str(e) + "- required module not found") @@ -70,16 +70,16 @@ def install_firmware(self, image_path): """ try: successtips = "CPLD Upgrade succeeded!" - status, output = subprocess.getstatusoutput("which firmware_upgrade") + status, output = getstatusoutput_noshell(["which", "firmware_upgrade"]) if status or len(output) <= 0: logger.error("no upgrade tool.") return False - cmdstr = "%s %s cpld %d cpld"%(output,image_path,self.slot) - ret, log = subprocess.getstatusoutput(cmdstr) + cmdstr = [output, image_path, "cpld", str(self.slot), "cpld"] + ret, log = getstatusoutput_noshell(cmdstr) if ret == 0 and successtips in log: return True logger.error("upgrade failed. ret:%d, log:\n%s" % (ret, log)) except Exception as e: logger.error(str(e)) return False - + diff --git a/platform/broadcom/sonic-platform-modules-ruijie/b6510-48vs8cq/sonic_pcie/pcie_common.py b/platform/broadcom/sonic-platform-modules-ruijie/b6510-48vs8cq/sonic_pcie/pcie_common.py index 56e9d8664a23..12f1cc8ed7b9 100644 --- a/platform/broadcom/sonic-platform-modules-ruijie/b6510-48vs8cq/sonic_pcie/pcie_common.py +++ b/platform/broadcom/sonic-platform-modules-ruijie/b6510-48vs8cq/sonic_pcie/pcie_common.py @@ -37,14 +37,14 @@ def get_pcie_device(self): pciList = [] p1 = "^(\w+):(\w+)\.(\w)\s(.*)\s*\(*.*\)*" p2 = "^.*:.*:.*:(\w+)\s*\(*.*\)*" - command1 = "sudo lspci" - command2 = "sudo lspci -n" + command1 = ["sudo", "lspci"] + command2 = ["sudo", "lspci", "-n"] # run command 1 - proc1 = subprocess.Popen(command1, shell=True, universal_newlines=True, stdout=subprocess.PIPE) + proc1 = subprocess.Popen(command1, universal_newlines=True, stdout=subprocess.PIPE) output1 = proc1.stdout.readlines() proc1.communicate() # run command 2 - proc2 = subprocess.Popen(command2, shell=True, universal_newlines=True, stdout=subprocess.PIPE) + proc2 = subprocess.Popen(command2, universal_newlines=True, stdout=subprocess.PIPE) output2 = proc2.stdout.readlines() proc2.communicate() diff --git a/platform/broadcom/sonic-platform-modules-ruijie/b6510-48vs8cq/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-ruijie/b6510-48vs8cq/sonic_platform/chassis.py index ea4048e19f6e..18ca047cbab4 100644 --- a/platform/broadcom/sonic-platform-modules-ruijie/b6510-48vs8cq/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-ruijie/b6510-48vs8cq/sonic_platform/chassis.py @@ -10,13 +10,13 @@ try: import time - import subprocess from sonic_platform_base.chassis_base import ChassisBase from sonic_platform.common import Common from sonic_platform.sfp import Sfp from sonic_platform.sfp import PORT_START from sonic_platform.sfp import PORTS_IN_BLOCK from sonic_platform.logger import logger + from sonic_py_common.general import getstatusoutput_noshell except ImportError as e: raise ImportError(str(e) + "- required module not found") @@ -36,17 +36,17 @@ def __init__(self): self.SFP_STATUS_INSERTED = "1" self.SFP_STATUS_REMOVED = "0" self.port_dict = {} - self.enable_read= "i2cset -f -y 2 0x35 0x2a 0x01" - self.disable_read = "i2cset -f -y 2 0x35 0x2a 0x00" - self.enable_write = "i2cset -f -y 2 0x35 0x2b 0x00" - self.disable_write = "i2cset -f -y 2 0x35 0x2b 0x01" - self.enable_erase = "i2cset -f -y 2 0x35 0x2c 0x01" - self.disable_erase = "i2cset -f -y 2 0x35 0x2c 0x00" - self.read_value = "i2cget -f -y 2 0x35 0x25" - self.write_value = "i2cset -f -y 2 0x35 0x21 0x0a" - self.set_sys_led_cmd = "i2cset -f -y 2 0x33 0xb2 " - self.get_sys_led_cmd = "i2cget -f -y 2 0x33 0xb2" - self.led_status = "red" + self.enable_read= ["i2cset", "-f", "-y", "2", "0x35", "0x2a", "0x01"] + self.disable_read = ["i2cset", "-f", "-y", "2", "0x35", "0x2a", "0x00"] + self.enable_write = ["i2cset", "-f", "-y", "2", "0x35", "0x2b", "0x00"] + self.disable_write = ["i2cset", "-f", "-y", "2", "0x35", "0x2b", "0x01"] + self.enable_erase = ["i2cset", "-f", "-y", "2", "0x35", "0x2c", "0x01"] + self.disable_erase = ["i2cset", "-f", "-y", "2", "0x35", "0x2c", "0x00"] + self.read_value = ["i2cget", "-f", "-y", "2", "0x35", "0x25"] + self.write_value = ["i2cset", "-f", "-y", "2", "0x35", "0x21", "0x0a"] + self.set_sys_led_cmd = ["i2cset", "-f", "-y", "2", "0x33", "0xb2"] + self.get_sys_led_cmd = ["i2cget", "-f", "-y", "2", "0x33", "0xb2"] + self.led_status = "red" # Initialize SFP list # sfp.py will read eeprom contents and retrive the eeprom data. # It will also provide support sfp controls like reset and setting @@ -210,25 +210,25 @@ def get_reboot_cause(self): try: is_power_loss = False # enable read - subprocess.getstatusoutput(self.disable_write) - subprocess.getstatusoutput(self.enable_read) - ret , log = subprocess.getstatusoutput(self.read_value) + getstatusoutput_noshell(self.disable_write) + getstatusoutput_noshell(self.enable_read) + ret , log = getstatusoutput_noshell(self.read_value) if ret == 0 and "0x0a" in log: is_power_loss = True # erase i2c and e2 - subprocess.getstatusoutput(self.enable_erase) + getstatusoutput_noshell(self.enable_erase) time.sleep(1) - subprocess.getstatusoutput(self.disable_erase) + getstatusoutput_noshell(self.disable_erase) # clear data - subprocess.getstatusoutput(self.enable_write) - subprocess.getstatusoutput(self.disable_read) - subprocess.getstatusoutput(self.disable_write) - subprocess.getstatusoutput(self.enable_read) + getstatusoutput_noshell(self.enable_write) + getstatusoutput_noshell(self.disable_read) + getstatusoutput_noshell(self.disable_write) + getstatusoutput_noshell(self.enable_read) # enable write and set data - subprocess.getstatusoutput(self.enable_write) - subprocess.getstatusoutput(self.disable_read) - subprocess.getstatusoutput(self.write_value) + getstatusoutput_noshell(self.enable_write) + getstatusoutput_noshell(self.disable_read) + getstatusoutput_noshell(self.write_value) if is_power_loss: return(self.REBOOT_CAUSE_POWER_LOSS, None) except Exception as e: @@ -417,7 +417,8 @@ def set_status_led(self, color): if regval is None: print("Invaild color input.") return False - ret , log = subprocess.getstatusoutput(self.set_sys_led_cmd + regval) + cmd = self.set_sys_led_cmd + [regval] + ret, log = getstatusoutput_noshell(cmd) if ret != 0: print("Cannot execute %s" % self.set_sys_led_cmd + regval) return False @@ -431,7 +432,7 @@ def get_status_led(self): A string, one of the valid LED color strings which could be vendor specified. """ - ret , log = subprocess.getstatusoutput(self.get_sys_led_cmd) + ret , log = getstatusoutput_noshell(self.get_sys_led_cmd) if ret != 0: print("Cannot execute %s" % self.get_sys_led_cmd) return False diff --git a/platform/broadcom/sonic-platform-modules-ruijie/b6510-48vs8cq/sonic_platform/common.py b/platform/broadcom/sonic-platform-modules-ruijie/b6510-48vs8cq/sonic_platform/common.py index c1a85f618609..e1bef19c24d7 100644 --- a/platform/broadcom/sonic-platform-modules-ruijie/b6510-48vs8cq/sonic_platform/common.py +++ b/platform/broadcom/sonic-platform-modules-ruijie/b6510-48vs8cq/sonic_platform/common.py @@ -1,6 +1,6 @@ import os import yaml - +import subprocess from sonic_py_common import device_info @@ -10,13 +10,13 @@ class Common: PMON_PLATFORM_PATH = '/usr/share/sonic/platform/' CONFIG_DIR = 'sonic_platform_config' - HOST_CHK_CMD = "docker > /dev/null 2>&1" + HOST_CHK_CMD = ["docker"] def __init__(self): (self.platform, self.hwsku) = device_info.get_platform_and_hwsku() def is_host(self): - return os.system(self.HOST_CHK_CMD) == 0 + return subprocess.call(self.HOST_CHK_CMD) == 0 def load_json_file(self, path): """ diff --git a/platform/broadcom/sonic-platform-modules-ruijie/b6510-48vs8cq/sonic_platform/component.py b/platform/broadcom/sonic-platform-modules-ruijie/b6510-48vs8cq/sonic_platform/component.py index 33ff6ef8b35d..26e83fb1919c 100644 --- a/platform/broadcom/sonic-platform-modules-ruijie/b6510-48vs8cq/sonic_platform/component.py +++ b/platform/broadcom/sonic-platform-modules-ruijie/b6510-48vs8cq/sonic_platform/component.py @@ -8,10 +8,10 @@ ######################################################################## try: - import subprocess from sonic_platform_base.component_base import ComponentBase from sonic_platform.regutil import Reg from sonic_platform.logger import logger + from sonic_py_common.general import getstatusoutput_noshell except ImportError as e: raise ImportError(str(e) + "- required module not found") @@ -70,12 +70,12 @@ def install_firmware(self, image_path): """ try: successtips = "CPLD Upgrade succeeded!" - status, output = subprocess.getstatusoutput("which firmware_upgrade") + status, output = getstatusoutput_noshell(["which", "firmware_upgrade"]) if status or len(output) <= 0: logger.error("no upgrade tool.") return False - cmdstr = "%s %s cpld %d cpld"%(output,image_path,self.slot) - ret, log = subprocess.getstatusoutput(cmdstr) + cmdstr = [output, image_path, "cpld", self.slot, "cpld"] + ret, log = getstatusoutput_noshell(cmdstr) if ret == 0 and successtips in log: return True logger.error("upgrade failed. ret:%d, log:\n%s" % (ret, log)) diff --git a/platform/broadcom/sonic-platform-modules-ruijie/common/lib/plat_hal/osutil.py b/platform/broadcom/sonic-platform-modules-ruijie/common/lib/plat_hal/osutil.py index 46f3089bbdbf..88453c9e916e 100644 --- a/platform/broadcom/sonic-platform-modules-ruijie/common/lib/plat_hal/osutil.py +++ b/platform/broadcom/sonic-platform-modules-ruijie/common/lib/plat_hal/osutil.py @@ -6,7 +6,6 @@ # ####################################################### -import subprocess import time import glob import re @@ -14,6 +13,7 @@ from rjutil.smbus import SMBus import time from functools import wraps +from sonic_py_common.general import getstatusoutput_noshell def retry(maxretry =6, delay = 0.01): @@ -80,13 +80,13 @@ def rji2csetword_python(bus, addr, reg, value): @staticmethod def command(cmdstr): - retcode, output = subprocess.getstatusoutput(cmdstr) + retcode, output = getstatusoutput_noshell(cmdstr) return retcode, output @staticmethod def geti2cword_i2ctool(bus, addr, offset): - command_line = "i2cget -f -y %d 0x%02x 0x%02x wp" % (bus, addr, offset) + command_line = ["i2cget", "-f", "-y", str(bus), "0x%02x"%addr, "0x%02x"%offset, "wp"] retrytime = 6 ret_t = "" for i in range(retrytime): @@ -99,7 +99,7 @@ def geti2cword_i2ctool(bus, addr, offset): @staticmethod def seti2cword_i2ctool(bus, addr, offset, val): - command_line = "i2cset -f -y %d 0x%02x 0x%0x 0x%04x wp" % (bus, addr, offset, val) + command_line = ["i2cset", "-f", "-y", str(bus), "0x%02x"%addr, "0x%0x"%offset, "0x%04x"%val, "wp"] retrytime = 6 ret_t = "" for i in range(retrytime): @@ -111,7 +111,7 @@ def seti2cword_i2ctool(bus, addr, offset, val): @staticmethod def rji2cget_i2ctool(bus, devno, address): - command_line = "i2cget -f -y %d 0x%02x 0x%02x " % (bus, devno, address) + command_line = ["i2cget", "-f", "-y", str(bus), "0x%02x"%devno, "0x%02x"%address] retrytime = 6 ret_t = "" for i in range(retrytime): @@ -123,8 +123,7 @@ def rji2cget_i2ctool(bus, devno, address): @staticmethod def rji2cset_i2ctool(bus, devno, address, byte): - command_line = "i2cset -f -y %d 0x%02x 0x%02x 0x%02x" % ( - bus, devno, address, byte) + command_line = ["i2cset", "-f", "-y", str(bus), "0x%02x"%devno, "0x%02x"%address, "0x%02x"%byte] retrytime = 6 ret_t = "" for i in range(retrytime): @@ -166,7 +165,7 @@ def readsysfs(location): @staticmethod def getdevmem(addr, digit, mask): - command_line = "devmem 0x%02x %d" %(addr, digit) + command_line = ["devmem", "0x%02x"%addr, str(digit)] retrytime = 6 ret_t = "" for i in range(retrytime): @@ -179,13 +178,13 @@ def getdevmem(addr, digit, mask): @staticmethod def rj_os_system(cmd): - status, output = subprocess.getstatusoutput(cmd) + status, output = getstatusoutput_noshell(cmd) return status, output @staticmethod def getsdkreg(reg): try: - cmd = "bcmcmd -t 1 'getr %s ' < /dev/null" % reg + cmd = ["bcmcmd", "-t", "1", "getr"+str(reg)] ret, result = osutil.rj_os_system(cmd) result_t = result.strip().replace("\r", "").replace("\n", "") if ret != 0 or "Error:" in result_t: @@ -203,8 +202,8 @@ def getmactemp(): result = {} #waitForDocker() #need to exec twice - osutil.rj_os_system("bcmcmd -t 1 \"show temp\" < /dev/null") - ret, log = osutil.rj_os_system("bcmcmd -t 1 \"show temp\" < /dev/null") + osutil.rj_os_system(["bcmcmd", "-t", "1", "show temp"]) + ret, log = osutil.rj_os_system(["bcmcmd", "-t", "1", "show temp"]) if ret: return False, result else: diff --git a/platform/broadcom/sonic-platform-modules-ruijie/common/script/device_i2c.py b/platform/broadcom/sonic-platform-modules-ruijie/common/script/device_i2c.py index 35bca09c0206..c812ba2958ca 100755 --- a/platform/broadcom/sonic-platform-modules-ruijie/common/script/device_i2c.py +++ b/platform/broadcom/sonic-platform-modules-ruijie/common/script/device_i2c.py @@ -6,7 +6,7 @@ import subprocess import time from ruijieconfig import GLOBALCONFIG, GLOBALINITPARAM, GLOBALINITCOMMAND, MAC_LED_RESET, STARTMODULE, i2ccheck_params - +from sonic_py_common.general import getstatusoutput_noshell, getstatusoutput_noshell_pipe from ruijieutil import rjpciwr CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help']) @@ -46,7 +46,7 @@ def write_sysfs_value(reg_name, value): def check_driver(): u'''whether there is driver start with rg''' - status, output = log_os_system("lsmod | grep rg | wc -l") + status, output = getstatusoutput_noshell_pipe(["lsmod"], ["grep", "rg"], ["wc", "-l"]) #System execution error if status: return False @@ -70,61 +70,59 @@ def i2c_getPid(name): return ret def startAvscontrol(): - cmd = "nohup avscontrol.py start >/dev/null 2>&1 &" + cmd = ["avscontrol.py", "start"] rets = i2c_getPid("avscontrol.py") if len(rets) == 0: - os.system(cmd) + subprocess.Popen(cmd) def startFanctrol(): if STARTMODULE['fancontrol'] == 1: - cmd = "nohup fancontrol.py start >/dev/null 2>&1 &" + cmd = ["fancontrol.py", "start"] rets = i2c_getPid("fancontrol.py") if len(rets) == 0: - os.system(cmd) + subprocess.Popen(cmd) def starthal_fanctrl(): if STARTMODULE.get('hal_fanctrl',0) == 1: - cmd = "nohup hal_fanctrl.py start >/dev/null 2>&1 &" + cmd = ["hal_fanctrl.py", "start"] rets = i2c_getPid("hal_fanctrl.py") if len(rets) == 0: - os.system(cmd) + subprocess.Popen(cmd) def starthal_ledctrl(): if STARTMODULE.get('hal_ledctrl',0) == 1: - cmd = "nohup hal_ledctrl.py start >/dev/null 2>&1 &" + cmd = ["hal_ledctrl.py", "start"] rets = i2c_getPid("hal_ledctrl.py") if len(rets) == 0: - os.system(cmd) - + subprocess.Popen(cmd) def startDevmonitor(): if STARTMODULE.get('dev_monitor',0) == 1: - cmd = "nohup dev_monitor.py start >/dev/null 2>&1 &" + cmd = ["dev_monitor.py", "start"] rets = i2c_getPid("dev_monitor.py") if len(rets) == 0: - os.system(cmd) - + subprocess.Popen(cmd) def startSlotmonitor(): if STARTMODULE.get('slot_monitor',0) == 1: - cmd = "nohup slot_monitor.py start >/dev/null 2>&1 &" + cmd = ["slot_monitor.py", "start"] rets = i2c_getPid("slot_monitor.py") if len(rets) == 0: - os.system(cmd) + subprocess.Popen(cmd) def stopFanctrol(): u'''disable fan timer service''' if STARTMODULE['fancontrol'] == 1: rets = i2c_getPid("fancontrol.py") # for ret in rets: - cmd = "kill "+ ret - os.system(cmd) + cmd = ["kill", ret] + subprocess.call(cmd) return True def stophal_ledctrl(): if STARTMODULE.get('hal_ledctrl',0) == 1: rets = i2c_getPid("hal_ledctrl.py") for ret in rets: - cmd = "kill "+ ret - os.system(cmd) + cmd = ["kill", ret] + subprocess.call(cmd) return True @@ -133,8 +131,8 @@ def stopDevmonitor(): if STARTMODULE.get('dev_monitor',0) == 1: rets = i2c_getPid("dev_monitor.py") # for ret in rets: - cmd = "kill "+ ret - os.system(cmd) + cmd = ["kill", ret] + subprocess.call(cmd) return True def stopSlotmonitor(): @@ -142,15 +140,16 @@ def stopSlotmonitor(): if STARTMODULE.get('slot_monitor',0) == 1: rets = i2c_getPid("slot_monitor.py") # for ret in rets: - cmd = "kill "+ ret - os.system(cmd) + cmd = ["kill", ret] + subprocess.call(cmd) return True def removeDev(bus, loc): - cmd = "echo 0x%02x > /sys/bus/i2c/devices/i2c-%d/delete_device" % (loc, bus) devpath = "/sys/bus/i2c/devices/%d-%04x"%(bus, loc) if os.path.exists(devpath): - log_os_system(cmd) + file = "/sys/bus/i2c/devices/i2c-%d/delete_device" % bus + with open(file, 'w') as f: + f.write('0x%02x\n'%str(bus)) def addDev(name, bus, loc): if name == "lm75": @@ -163,10 +162,11 @@ def addDev(name, bus, loc): if i % 10 == 0: click.echo("%%DEVICE_I2C-INIT: %s not found, wait 0.1 second ! i %d " % (pdevpath,i)) - cmd = "echo %s 0x%02x > /sys/bus/i2c/devices/i2c-%d/new_device" % (name, loc, bus) devpath = "/sys/bus/i2c/devices/%d-%04x"%(bus, loc) if os.path.exists(devpath) == False: - os.system(cmd) + file = "/sys/bus/i2c/devices/i2c-%d/new_device" % bus + with open(file, 'w') as f: + f.write('%s 0x%02x\n' % (name, loc)) def removedevs(): devs = GLOBALCONFIG["DEVS"] @@ -179,8 +179,7 @@ def adddevs(): addDev(devs[dev]["name"], devs[dev]["bus"] , devs[dev]["loc"]) def checksignaldriver(name): - modisexistcmd = "lsmod | grep %s | wc -l" % name - status, output = log_os_system(modisexistcmd) + status, output = getstatusoutput_noshell_pipe(["lsmod"], ["grep", name], ["wc", "-l"]) #System execution error if status: return False @@ -190,17 +189,17 @@ def checksignaldriver(name): return False def adddriver(name, delay): - cmd = "modprobe %s" % name + cmd = ["modprobe", name] if delay != 0: time.sleep(delay) if checksignaldriver(name) != True: - log_os_system(cmd) + getstatusoutput_noshell(cmd) def removedriver(name, delay): realname = name.lstrip().split(" ")[0]; - cmd = "rmmod -f %s" % realname + cmd = ["rmmod", "-f", realname] if checksignaldriver(realname): - log_os_system(cmd) + getstatusoutput_noshell(cmd) def removedrivers(): u'''remove all drivers''' diff --git a/platform/broadcom/sonic-platform-modules-ruijie/common/script/fancontrol.py b/platform/broadcom/sonic-platform-modules-ruijie/common/script/fancontrol.py index 87fb01e5f6ac..e12bb25d7fb7 100755 --- a/platform/broadcom/sonic-platform-modules-ruijie/common/script/fancontrol.py +++ b/platform/broadcom/sonic-platform-modules-ruijie/common/script/fancontrol.py @@ -4,6 +4,7 @@ import os import time import syslog +import subprocess from ruijieconfig import MONITOR_CONST, FANCTROLDEBUG, MONITOR_FANS_LED, DEV_LEDS, MONITOR_PSU_STATUS, \ MONITOR_SYS_PSU_LED, MONITOR_DEV_STATUS, MONITOR_FAN_STATUS, MONITOR_DEV_STATUS_DECODE, \ MONITOR_SYS_FAN_LED, MONITOR_SYS_LED, fanloc @@ -766,7 +767,7 @@ def checkCrit(self): self.fanSpeedSetMax() # fan full speed self.critnum += 1 # anti-shake if self.critnum >= MONITOR_CONST.CRITICAL_NUM: - os.system("reboot") + subprocess.call(["reboot"]) fanwarningdebuglog(DEBUG_FANCONTROL,"crit次数:%d" % self.critnum) else: self.critnum = 0 diff --git a/platform/broadcom/sonic-platform-modules-ruijie/common/script/ruijieutil.py b/platform/broadcom/sonic-platform-modules-ruijie/common/script/ruijieutil.py index ff594b72e342..9d1930ec08d1 100755 --- a/platform/broadcom/sonic-platform-modules-ruijie/common/script/ruijieutil.py +++ b/platform/broadcom/sonic-platform-modules-ruijie/common/script/ruijieutil.py @@ -11,7 +11,6 @@ import sys import os import re -import subprocess import syslog import time import binascii @@ -20,6 +19,7 @@ import threading import click import mmap +from sonic_py_common.general import getstatusoutput_noshell, getstatusoutput_noshell_pipe from ruijieconfig import rg_eeprom, FRULISTS, MAC_DEFAULT_PARAM, MAC_AVS_PARAM, FANS_DEF, \ FAN_PROTECT, E2_LOC, E2_PROTECT, RUIJIE_SERVICE_TAG, RUIJIE_DIAG_VERSION, \ STARTMODULE, RUIJIE_CARDID, RUIJIE_PRODUCTNAME, RUIJIE_PART_NUMBER, \ @@ -538,8 +538,8 @@ def __new__(cls, *args, **kwargs): def getSdkReg(reg): try: - cmd = "bcmcmd -t 1 'getr %s ' < /dev/null" % reg - ret, result = rj_os_system(cmd) + cmd = ["bcmcmd", "-t", "1", "getr"+str(reg)] + ret, result = getstatusoutput_noshell(cmd) result_t = result.strip().replace("\r", "").replace("\n", "") if ret != 0 or "Error:" in result_t: return False, result @@ -632,8 +632,8 @@ def getMacTemp(): result = {} #waitForDocker() # exec twice, get the second result - rj_os_system("bcmcmd -t 1 \"show temp\" < /dev/null") - ret, log = rj_os_system("bcmcmd -t 1 \"show temp\" < /dev/null") + getstatusoutput_noshell(["bcmcmd", "-t", "1", "show temp"]) + ret, log = getstatusoutput_noshell(["bcmcmd", "-t", "1", "show temp"]) if ret: return False, result else: @@ -689,21 +689,21 @@ def getMacTemp_sysfs(mactempconf): def restartDockerService(force=False): container_name = ["database","snmp","syncd","swss","dhcp_relay","radv","teamd","pmon"] - ret, status = rj_os_system("docker ps") + ret, status = getstatusoutput_noshell(["docker", "ps"]) if ret == 0 : for tmpname in container_name: if (tmpname not in status): if (force == True): - rj_os_system("docker restart %s"%tmpname) + getstatusoutput_noshell(["docker", "restart", tmpname]) else: - rj_os_system("systemctl restart %s"%tmpname) + getstatusoutput_noshell(["systemctl", "restart", tmpname]) def waitForDhcp(timeout): time_cnt = 0 while True: try: - ret, status = rj_os_system("systemctl status dhcp_relay.service") + ret, status = getstatusoutput_noshell(["systemctl", "status", "dhcp_relay.service"]) if (ret == 0 and "running" in status) or "SUCCESS" in status: break else: @@ -839,8 +839,10 @@ def util_setmac(eth, mac): rulefile = "/etc/udev/rules.d/70-persistent-net.rules" if isValidMac(mac) == False: return False, "MAC invaild" - cmd = "ethtool -e %s | grep 0x0010 | awk '{print \"0x\"$13$12$15$14}'" % eth - ret, log = rj_os_system(cmd) + cmd1 = ["ethtool", "-e", eth] + cmd2 = ["grep", "0x0010"] + cmd3 = ["awk", '{print \"0x\"$13$12$15$14}'] + ret, log = getstatusoutput_noshell_pipe(cmd1, cmd2, cmd3) log_debug(log) magic = "" if ret == 0 and len(log): @@ -848,23 +850,22 @@ def util_setmac(eth, mac): macs = mac.upper().split(":") # chage ETH0 to value after setmac - ifconfigcmd = "ifconfig eth0 hw ether %s" % mac - log_debug(ifconfigcmd) - ret, status = rj_os_system(ifconfigcmd) + ifconfigcmd = ["ifconfig", "eth0", "hw", "ether", mac] + log_debug(' '.join(ifconfigcmd)) + ret, status = getstatusoutput_noshell(ifconfigcmd) if ret: raise SETMACException("software set Internet cardMAC error") index = 0 for item in macs: - cmd = "ethtool -E %s magic %s offset %d value 0x%s" % ( - eth, magic, index, item) + cmd = ["ethtool", "-E", eht, "magic", magic, "offset", str(index), "value", "0x"+item] log_debug(cmd) index += 1 - ret, log = rj_os_system(cmd) + ret, log = getstatusoutput_noshell(cmd) if ret != 0: raise SETMACException(" set hardware Internet card MAC error") # get value after setting - cmd_t = "ethtool -e eth0 offset 0 length 6" - ret, log = rj_os_system(cmd_t) + cmd_t = ["ethtool", "-e", "eth0", "offset", "0", "length", "6"] + ret, log = getstatusoutput_noshell(cmd_t) m = re.split(':', log)[-1].strip().upper() mac_result = m.upper().split(" ") @@ -979,11 +980,11 @@ def generate_ext(cardid): def rji2cget(bus, devno, address): - command_line = "i2cget -f -y %d 0x%02x 0x%02x " % (bus, devno, address) + command_line = ["i2cget", "-f", "-y", str(bus), "0x%02x"%str(devno), "0x%02x"%str(address)] retrytime = 6 ret_t = "" for i in range(retrytime): - ret, ret_t = rj_os_system(command_line) + ret, ret_t = getstatusoutput_noshell(command_line) if ret == 0: return True, ret_t time.sleep(0.1) @@ -991,12 +992,11 @@ def rji2cget(bus, devno, address): def rji2cset(bus, devno, address, byte): - command_line = "i2cset -f -y %d 0x%02x 0x%02x 0x%02x" % ( - bus, devno, address, byte) + command_line = ["i2cset", "-f", "-y", str(bus), "0x%02x"%str(devno), "0x%02x"%str(address), "0x%02x"%str(byte)] retrytime = 6 ret_t = "" for i in range(retrytime): - ret, ret_t = rj_os_system(command_line) + ret, ret_t = getstatusoutput_noshell(command_line) if ret == 0: return True, ret_t return False, ret_t @@ -1033,31 +1033,30 @@ def rjpciwr(pcibus , slot ,fn, bar, offset, data): data.close() def rjsysset(location, value): - command_line = "echo 0x%02x > %s" % (value, location) retrytime = 6 - ret_t = "" for i in range(retrytime): - ret, ret_t = rj_os_system(command_line) - if ret == 0: - return True, ret_t - return False, ret_t + try: + with open(location, 'w') as f: + f.write('0x%02x\n'%value) + except (IOError, FileNotFoundError) as e: + return False, str(e) + return True, '' def rji2cgetWord(bus, devno, address): - command_line = "i2cget -f -y %d 0x%02x 0x%02x w" % (bus, devno, address) + command_line = ["i2cget", "-f", "-y", str(bus), "0x%02x"%str(devno), "0x%02x"%str(address), "w"] retrytime = 3 ret_t = "" for i in range(retrytime): - ret, ret_t = rj_os_system(command_line) + ret, ret_t = getstatusoutput_noshell(command_line) if ret == 0: return True, ret_t return False, ret_t def rji2csetWord(bus, devno, address, byte): - command_line = "i2cset -f -y %d 0x%02x 0x%02x 0x%x w" % ( - bus, devno, address, byte) - rj_os_system(command_line) + command_line = ["i2cset", "-f", "-y", str(bus), "0x%02x"%str(devno), "0x%02x"%str(address), "0x%x"%str(byte), "w"] + getstatusoutput_noshell(command_line) def fan_setmac(): @@ -1264,14 +1263,15 @@ def writeToEEprom(rst_arr): elif dealtype == "io": io_wr(E2_PROTECT["io_addr"], E2_PROTECT["close"]) # deal last drivers - os.system("rmmod at24 ") - os.system("modprobe at24 ") - os.system("rm -f /var/cache/sonic/decode-syseeprom/syseeprom_cache") + getstatusoutput_noshell(["rmmod", "at24"]) + getstatusoutput_noshell(["modprobe", "at24"]) + getstatusoutput_noshell(["rm", "-f", "/var/cache/sonic/decode-syseeprom/syseeprom_cache"]) def get_local_eth0_mac(): - cmd = "ifconfig eth0 |grep HWaddr" - print(rj_os_system(cmd)) + cmd1 = ["ifconfig", "eth0"] + cmd2 = ["grep", "HWaddr"] + print(getstatusoutput_noshell_pipe(cmd1, cmd2)) def getonieversion(): if not os.path.isfile('/host/machine.conf'): @@ -1348,12 +1348,12 @@ def fac_board_setmac(): def ipmi_set_mac(mac): macs = mac.split(":") - cmdinit = "ipmitool raw 0x0c 0x01 0x01 0xc2 0x00" - cmdset = "ipmitool raw 0x0c 0x01 0x01 0x05" + cmdinit = ["ipmitool", "raw", "0x0c", "0x01", "0x01", "0xc2", "0x00"] + cmdset = ["ipmitool", "raw", "0x0c", "0x01", "0x01", "0x05"] for ind in range(len(macs)): - cmdset += " 0x%02x" % int(macs[ind], 16) - rj_os_system(cmdinit) - ret, status = rj_os_system(cmdset) + cmdset.append("0x%02x" % int(macs[ind], 16)) + getstatusoutput_noshell(cmdinit) + ret, status = getstatusoutput_noshell(cmdset) if ret: RJPRINTERR("\n\n%s\n\n" % status) return False @@ -1393,11 +1393,11 @@ def closeProtocol(): log_info("disable LLDP") sys.stdout.write(".") sys.stdout.flush() - rj_os_system("systemctl stop lldp.service") + getstatusoutput_noshell(["systemctl", "stop", "lldp.service"]) log_info("disable lldp service") sys.stdout.write(".") sys.stdout.flush() - rj_os_system("systemctl stop bgp.service") + getstatusoutput_noshell(["systemctl", "stop", "bgp.service"]) log_info("disable bgp service") sys.stdout.write(".") sys.stdout.flush() @@ -1420,8 +1420,8 @@ def checkSdkMem(): with open(file_name, "w") as f: f.write(file_data) print("change SDK memory to 256, reboot required") - rj_os_system("sync") - rj_os_system("reboot") + getstatusoutput_noshell(["sync"]) + getstatusoutput_noshell(["reboot"]) ########################################################################## # receives a character setting @@ -1604,25 +1604,22 @@ def getCardId(): return item.get('value',None) return None -# ==================================== -# execute shell command -# ==================================== -def rj_os_system(cmd): - status, output = subprocess.getstatusoutput(cmd) - return status, output ########################################### # get memory slot and number via DMI command ########################################### def getsysmeminfo(): - ret, log = rj_os_system("which dmidecode ") + ret, log = getstatusoutput_noshell(["which", "dmidecode"]) if ret != 0 or len(log) <= 0: error = "cmd find dmidecode" return False, error - cmd = log + "|grep -P -A5 \"Memory\s+Device\"|grep Size|grep -v Range" + cmd1 = [log[0].rstrip('\n')] + cmd2 = ["grep", "-P", "-A5", "Memory\s+Device"] + cmd3 = ["grep", "Size"] + cmd4 = ["grep", "-v", "Range"] # get total number first result = [] - ret1, log1 = rj_os_system(cmd) + ret1, log1 = getstatusoutput_noshell_pipe(cmd1, cmd2, cmd3, cmd4) if ret1 == 0 and len(log1): log1 = log1.lstrip() arr = log1.split("\n") @@ -1642,15 +1639,16 @@ def getsysmeminfo(): # return various arrays ########################################### def getsysmeminfo_detail(): - ret, log = rj_os_system("which dmidecode ") + ret, log = getstatusoutput_noshell(["which", "dmidecode"]) if ret != 0 or len(log) <= 0: error = "cmd find dmidecode" return False, error - cmd = log + " -t 17 | grep -A21 \"Memory Device\"" # 17 + cmd1 = [log[0].rstrip('\n')] + ["-t", "17"] + cmd2 = ["grep", "-A21", "Memory Device"] # 17 # get total number - ret1, log1 = rj_os_system(cmd) + ret1, log1 = getstatusoutput_noshell_pipe(cmd1, cmd2) if ret1 != 0 or len(log1) <= 0: - return False, "command execution error[%s]" % cmd + return False, "command execution error[%s][%s]" % (cmd1, cmd2) result_t = log1.split("--") mem_rets = [] for item in result_t: @@ -1669,13 +1667,13 @@ def getsysmeminfo_detail(): # get BIOS info via DMI command ########################################### def getDmiSysByType(type_t): - ret, log = rj_os_system("which dmidecode ") + ret, log = getstatusoutput_noshell(["which", "dmidecode"]) if ret != 0 or len(log) <= 0: error = "cmd find dmidecode" return False, error - cmd = log + " -t %s" % type_t + cmd = [log[0].rstrip('\n')] + ["-t", str(type_t)] # get total number - ret1, log1 = rj_os_system(cmd) + ret1, log1 = getstatusoutput_noshell(cmd) if ret1 != 0 or len(log1) <= 0: return False, "command execution error[%s]" % cmd its = log1.replace("\t", "").strip().split("\n") @@ -1742,11 +1740,12 @@ def getusbinfo(): return False, "Err" def get_cpu_info(): - cmd = "cat /proc/cpuinfo |grep processor -A18" # 17 + cmd1 = ["cat", "/proc/cpuinfo"] + cmd2 = ["grep", "processor", "-A18"] # 17 - ret, log1 = rj_os_system(cmd) + ret, log1 = getstatusoutput_noshell_pipe(cmd1, cmd2) if ret != 0 or len(log1) <= 0: - return False, "command execution error[%s]" % cmd + return False, "command execution error[%s][%s]" % (cmd1, cmd2) result_t = log1.split("--") mem_rets = [] for item in result_t: diff --git a/platform/broadcom/sonic-platform-modules-tencent/LICENSE b/platform/broadcom/sonic-platform-modules-tencent/LICENSE new file mode 100755 index 000000000000..5571f1244579 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/LICENSE @@ -0,0 +1,15 @@ +Copyright (C) 2016 Microsoft, Inc +Copyright (C) 2022 Ruijie Network 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 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. diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/Makefile b/platform/broadcom/sonic-platform-modules-tencent/common/Makefile new file mode 100755 index 000000000000..97d777b0d3e5 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/Makefile @@ -0,0 +1,37 @@ +PWD = $(shell pwd) +CC ?=gcc +INSTALL_MOD_DIR ?=extra +KVERSION ?= $(shell uname -r) +KERNEL_SRC ?= /lib/modules/$(KVERSION) +EXTRA_CFLAGS:= -I$(M)/include +EXTRA_CFLAGS+= -Wall +SUB_BUILD_DIR = $(PWD)/build +DIR_KERNEL_SRC = $(PWD)/modules +SCRIPT_DIR = $(PWD)/script +SERVICE_DIR = $(PWD)/service +BLACK_DRIVER_CONF_DIR = $(PWD)/modprobe_conf + +modules_build_dir = $(DIR_KERNEL_SRC)/build + +INSTALL_MODULE_DIR = $(SUB_BUILD_DIR)/$(KERNEL_SRC)/$(INSTALL_MOD_DIR) +INSTALL_SCRIPT_DIR = $(SUB_BUILD_DIR)/usr/local/bin +INSTALL_SERVICE_DIR = $(SUB_BUILD_DIR)/lib/systemd/system +INSTALL_LIB_DIR = $(SUB_BUILD_DIR)/usr/lib/python3/dist-packages +INSTALL_BLACK_DRIVER = $(SUB_BUILD_DIR)/etc/modprobe.d + +all: + $(MAKE) -C $(DIR_KERNEL_SRC) + @if [ ! -d ${INSTALL_MODULE_DIR} ]; then mkdir -p ${INSTALL_MODULE_DIR} ;fi + @if [ ! -d ${INSTALL_SCRIPT_DIR} ]; then mkdir -p ${INSTALL_SCRIPT_DIR} ;fi + @if [ ! -d ${INSTALL_SERVICE_DIR} ]; then mkdir -p ${INSTALL_SERVICE_DIR} ;fi + @if [ ! -d ${INSTALL_LIB_DIR} ]; then mkdir -p ${INSTALL_LIB_DIR} ;fi + @if [ -d $(PWD)/lib/ ]; then cp -r $(PWD)/lib/* ${INSTALL_LIB_DIR} ;fi + @if [ -d $(PWD)/sonic_platform/ ]; then cp -rf $(PWD)/sonic_platform ${INSTALL_LIB_DIR} ;fi + cp -r $(modules_build_dir)/*.ko $(INSTALL_MODULE_DIR) + cp -r $(SCRIPT_DIR)/* $(INSTALL_SCRIPT_DIR) + cp -r $(SERVICE_DIR)/* $(INSTALL_SERVICE_DIR) + @if [ -d $(INSTALL_SCRIPT_DIR) ]; then chmod +x $(INSTALL_SCRIPT_DIR)/* ;fi + @if [ ! -d ${INSTALL_BLACK_DRIVER} ]; then mkdir -p ${INSTALL_BLACK_DRIVER} ;fi + cp -r $(BLACK_DRIVER_CONF_DIR)/* $(INSTALL_BLACK_DRIVER) +clean: + rm -rf $(SUB_BUILD_DIR) diff --git a/files/image_config/resolv-config/resolv.conf b/platform/broadcom/sonic-platform-modules-tencent/common/lib/algorithm/__init__.py old mode 100644 new mode 100755 similarity index 100% rename from files/image_config/resolv-config/resolv.conf rename to platform/broadcom/sonic-platform-modules-tencent/common/lib/algorithm/__init__.py diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/algorithm/hysteresis.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/algorithm/hysteresis.py new file mode 100755 index 000000000000..7a1daf0eb8b8 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/algorithm/hysteresis.py @@ -0,0 +1,167 @@ +#!/usr/bin/env python3 +import os +import syslog +import copy + +from plat_hal.baseutil import baseutil + +HYST_DEBUG_FILE = "/etc/.hysteresis_debug_flag" + +HYSTERROR = 1 +HYSTDEBUG = 2 + +debuglevel = 0 + +def hyst_debug(s): + if HYSTDEBUG & debuglevel: + syslog.openlog("FANCONTROL-HYST", syslog.LOG_PID) + syslog.syslog(syslog.LOG_DEBUG, s) + +def hyst_error(s): + if HYSTERROR & debuglevel: + syslog.openlog("FANCONTROL-HYST", syslog.LOG_PID) + syslog.syslog(syslog.LOG_ERR, s) + +class hysteresis(object): + __config = None + __hyst_config = None + + def __init__(self): + self.__config = baseutil.get_monitor_config() + self.__hyst_config = copy.deepcopy(self.__config.get("hyst", {})) + # init check + errcnt = 0 + errmsg = "" + self.debug_init() + for temp_hyst_conf in self.__hyst_config.values(): + if temp_hyst_conf["flag"] == 0: + continue + for i in range(temp_hyst_conf["temp_min"], temp_hyst_conf["temp_max"] + 1): + if i not in temp_hyst_conf["rising"]: + errcnt -= 1 + msg = "%s hyst config error, temp value %d not in rising curve;" % (temp_hyst_conf["name"], i) + hyst_error(msg) + errmsg += msg + if i not in temp_hyst_conf["descending"]: + errcnt -= 1 + msg = "%s hyst config error, temp value %d not in descending curve;" %(temp_hyst_conf["name"], i) + hyst_error(msg) + errmsg += msg + if errcnt < 0: + raise KeyError(errmsg) + + def debug_init(self): + global debuglevel + if os.path.exists(HYST_DEBUG_FILE): + debuglevel = debuglevel | HYSTDEBUG | HYSTERROR + else: + debuglevel = debuglevel & ~(HYSTDEBUG | HYSTERROR) + + def get_temp_hyst_conf(self, temp_name): + temp_hyst_conf = self.__hyst_config.get(temp_name) + return temp_hyst_conf + + def get_temp_update(self, hyst_para, current_temp): + temp = hyst_para["value"] + if temp is None: + return None + temp.append(current_temp) + del temp[0] + return temp + + def duty_to_pwm(self, duty): + pwm = int(round(float(duty) * 255 / 100)) + return pwm + + def pwm_to_duty(self, pwm): + duty = int(round(float(pwm) * 100 / 255)) + return duty + + def calc_hyst_val(self, temp_name, temp_list): + + temp_hyst_conf = self.get_temp_hyst_conf(temp_name) + hyst_min = temp_hyst_conf["hyst_min"] + hyst_max = temp_hyst_conf["hyst_max"] + temp_min = temp_hyst_conf["temp_min"] + temp_max = temp_hyst_conf["temp_max"] + rising = temp_hyst_conf["rising"] + descending = temp_hyst_conf["descending"] + last_hyst_value = temp_hyst_conf["last_hyst_value"] + current_temp = temp_list[1] + last_temp = temp_list[0] + + hyst_debug("calc_hyst_val, temp_name: %s, current_temp: %s, last_temp: %s, last_hyst_value: %s" % + (temp_name, current_temp, last_temp, last_hyst_value)) + + if current_temp < temp_min: + hyst_debug("%s current_temp %s less than temp_min %s, set min hyst value: %s" % + (temp_name, current_temp, temp_min, hyst_min)) + return hyst_min + + if current_temp > temp_max: + hyst_debug("%s current_temp %s more than temp_max %s, set max hyst value: %s" % + (temp_name, current_temp, temp_max, hyst_max)) + return hyst_max + + if last_temp is None: # first time + hyst_value = rising[current_temp] + hyst_debug("last_temp is None, it's first hysteresis, using rising hyst value: %s" % hyst_value) + return hyst_value + + if current_temp == last_temp: # temp unchanging + hyst_debug("current_temp equal last_temp, keep last hyst value: %s" % last_hyst_value) + return last_hyst_value + + if current_temp > last_temp: + calc_hyst_value = rising[current_temp] + if calc_hyst_value < last_hyst_value: + hyst_value = last_hyst_value + else: + hyst_value = calc_hyst_value + hyst_debug("temp rising, last_hyst_value: %s, calc_hyst_value: %s, set hyst value: %s" % + (last_hyst_value, calc_hyst_value, hyst_value)) + return hyst_value + + calc_hyst_value = descending[current_temp] + if calc_hyst_value > last_hyst_value: + hyst_value = last_hyst_value + else: + hyst_value = calc_hyst_value + hyst_debug("temp descending, last_hyst_value: %s, calc_hyst_value: %s, set hyst value: %s" % + (last_hyst_value, calc_hyst_value, hyst_value)) + return hyst_value + + def cacl(self, temp_name, current_temp): + self.debug_init() + try: + temp_hyst_conf = self.get_temp_hyst_conf(temp_name) + if temp_hyst_conf is None: + hyst_debug("get %s hysteresis config failed" % temp_name) + return None + + flag = temp_hyst_conf["flag"] + if flag != 1: + hyst_debug("%s hysteresis flag == 0, skip" % temp_name) + return None + + temp = self.get_temp_update(temp_hyst_conf, current_temp) + if temp is None: + hyst_debug("get %s update failed" % temp_name) + return None + + value = self.calc_hyst_val(temp_name, temp) + + temp_hyst_conf["last_hyst_value"] = value + + type = temp_hyst_conf["type"] + if type == "duty": + pwm = self.duty_to_pwm(value) + else: + pwm = value + + hyst_debug("temp_name: %s, current_temp: %s, set pwm 0x%x" % (temp_name, current_temp, pwm)) + return pwm + except Exception as e: + hyst_error("temp_name: %s calc hysteresis pwm error, msg: %s" % (temp_name, str(e))) + return None + diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/algorithm/openloop.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/algorithm/openloop.py new file mode 100755 index 000000000000..6876145fd586 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/algorithm/openloop.py @@ -0,0 +1,104 @@ +#!/usr/bin/env python3 +import os +import syslog + +from plat_hal.baseutil import baseutil + +OPENLOOP_DEBUG_FILE = "/etc/.openloop_debug_flag" + +OPENLOOPERROR = 1 +OPENLOOPDEBUG = 2 + +debuglevel = 0 + + +def openloop_debug(s): + if OPENLOOPDEBUG & debuglevel: + syslog.openlog("FANCONTROL-OPENLOOP", syslog.LOG_PID) + syslog.syslog(syslog.LOG_DEBUG, s) + + +def openloop_error(s): + if OPENLOOPERROR & debuglevel: + syslog.openlog("FANCONTROL-OPENLOOP", syslog.LOG_PID) + syslog.syslog(syslog.LOG_ERR, s) + + +class openloop(object): + __config = None + __openloop_config = None + + def __init__(self): + self.__config = baseutil.get_monitor_config() + self.__openloop_config = self.__config["openloop"] + + def debug_init(self): + global debuglevel + if os.path.exists(OPENLOOP_DEBUG_FILE): + debuglevel = debuglevel | OPENLOOPDEBUG | OPENLOOPERROR + else: + debuglevel = debuglevel & ~(OPENLOOPDEBUG | OPENLOOPERROR) + + def get_para(self, type): + para = self.__openloop_config.get(type) + return para + + def linear_cacl(self, temp): + self.debug_init() + openloop_para = self.get_para("linear") + if openloop_para is None: + openloop_debug("linear openloop: get para failed") + return None + + K = openloop_para["K"] + tin_min = openloop_para["tin_min"] + pwm_min = openloop_para["pwm_min"] + pwm_max = openloop_para["pwm_max"] + flag = openloop_para["flag"] + + if flag != 1: + openloop_debug("linear openloop: flag == 0") + return None + + if temp <= tin_min: + openloop_debug("linear openloop: temp = %d less than tin_min[%d]" % (temp, tin_min)) + return pwm_min + + pwm = int(pwm_min + (temp - tin_min) * K) + openloop_debug("linear openloop: cacl_pwm = 0x%x" % pwm) + + pwm = min(pwm, pwm_max) + pwm = max(pwm, pwm_min) + openloop_debug("linear openloop: temp = %d, pwm = 0x%x" % (temp, pwm)) + return pwm + + def curve_cacl(self, temp): + self.debug_init() + openloop_para = self.get_para("curve") + if openloop_para is None: + openloop_debug("curve openloop: get para failed") + return None + + a = openloop_para["a"] + b = openloop_para["b"] + c = openloop_para["c"] + tin_min = openloop_para["tin_min"] + pwm_min = openloop_para["pwm_min"] + pwm_max = openloop_para["pwm_max"] + flag = openloop_para["flag"] + + if flag != 1: + openloop_debug("curve openloop: flag == 0") + return None + + if temp <= tin_min: + openloop_debug("curve openloop: temp = %d less than tin_min[%d]" % (temp, tin_min)) + return pwm_min + + pwm = int(a * temp * temp + b * temp + c) + openloop_debug("curve openloop: cacl_pwm = 0x%x" % pwm) + + pwm = min(pwm, pwm_max) + pwm = max(pwm, pwm_min) + openloop_debug("curve openloop: temp = %d, pwm = 0x%x" % (temp, pwm)) + return pwm diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/algorithm/pid.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/algorithm/pid.py new file mode 100755 index 000000000000..b2cffc5b5210 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/algorithm/pid.py @@ -0,0 +1,106 @@ +#!/usr/bin/env python3 +import os +import syslog +import copy + +from plat_hal.baseutil import baseutil + +PID_DEBUG_FILE = "/etc/.pid_debug_flag" + +PIDERROR = 1 +PIDDEBUG = 2 + +debuglevel = 0 + + +def pid_debug(s): + if PIDDEBUG & debuglevel: + syslog.openlog("FANCONTROL-PID", syslog.LOG_PID) + syslog.syslog(syslog.LOG_DEBUG, s) + + +def pid_error(s): + if PIDERROR & debuglevel: + syslog.openlog("FANCONTROL-PID", syslog.LOG_PID) + syslog.syslog(syslog.LOG_ERR, s) + + +class pid(object): + __config = None + __pid_config = None + + def __init__(self): + self.__config = baseutil.get_monitor_config() + self.__pid_config = copy.deepcopy(self.__config["pid"]) + + def debug_init(self): + global debuglevel + if os.path.exists(PID_DEBUG_FILE): + debuglevel = debuglevel | PIDDEBUG | PIDERROR + else: + debuglevel = debuglevel & ~(PIDDEBUG | PIDERROR) + + def get_para(self, name): + para = self.__pid_config.get(name) + return para + + def get_temp_update(self, pid_para, current_temp): + temp = pid_para["value"] + if temp is None: + return None + temp.append(current_temp) + del temp[0] + return temp + + def cacl(self, last_pwm, name, current_temp): + delta_pwm = 0 + self.debug_init() + pid_debug("last_pwm = %d" % last_pwm) + + pid_para = self.get_para(name) + if pid_para is None: + pid_debug("get %s pid para failed" % name) + return None + + temp = self.get_temp_update(pid_para, current_temp) + if temp is None: + pid_debug("get %s update failed" % name) + return None + + type = pid_para["type"] + Kp = pid_para["Kp"] + Ki = pid_para["Ki"] + Kd = pid_para["Kd"] + target = pid_para["target"] + pwm_min = pid_para["pwm_min"] + pwm_max = pid_para["pwm_max"] + flag = pid_para["flag"] + + if flag != 1: + pid_debug("%s pid flag == 0" % name) + return None + + if type == "duty": + current_pwm = round(last_pwm * 100 / 255) + else: + current_pwm = last_pwm + + if (temp[2] is None): + tmp_pwm = current_pwm + elif ((temp[0] is None) or (temp[1] is None)): + delta_pwm = Ki * (temp[2] - target) + tmp_pwm = current_pwm + delta_pwm + else: + delta_pwm = Kp * (temp[2] - temp[1]) + Ki * (temp[2] - target) + Kd * (temp[2] - 2 * temp[1] + temp[0]) + tmp_pwm = current_pwm + delta_pwm + + pid_debug("delta_pwm = %d" % delta_pwm) + if type == "duty": + pwm = round(tmp_pwm * 255 / 100) + else: + pwm = int(tmp_pwm) + + pwm = min(pwm, pwm_max) + pwm = max(pwm, pwm_min) + pid_debug("last_pwm = 0x%x, pwm = 0x%x" % (last_pwm, pwm)) + return pwm diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/eepromutil/__init__.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/eepromutil/__init__.py new file mode 100755 index 000000000000..e69de29bb2d1 diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/eepromutil/fru.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/eepromutil/fru.py new file mode 100755 index 000000000000..2ccfba01dea2 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/eepromutil/fru.py @@ -0,0 +1,953 @@ +#!/usr/bin/python3 +import collections +from bitarray import bitarray +from datetime import datetime, timedelta + + +__DEBUG__ = "N" + + +class FruException(Exception): + def __init__(self, message='fruerror', code=-100): + err = 'errcode: {0} message:{1}'.format(code, message) + Exception.__init__(self, err) + self.code = code + self.message = message + + +def e_print(err): + print("ERROR: " + err) + + +def d_print(debug_info): + if(__DEBUG__ == "Y"): + print(debug_info) + + +class FruUtil(): + @staticmethod + def decodeLength(value): + a = bitarray(8) + a.setall(True) + a[0:1] = 0 + a[1:2] = 0 + x = ord(a.tobytes()) + return x & ord(value) + + @staticmethod + def minToData(): + starttime = datetime(1996, 1, 1, 0, 0, 0) + endtime = datetime.now() + seconds = (endtime - starttime).total_seconds() + mins = seconds // 60 + m = int(round(mins)) + return m + + @staticmethod + def getTimeFormat(): + return datetime.now().strftime('%Y-%m-%d') + + @staticmethod + def getTypeLength(value): + if value is None or len(value) == 0: + return 0 + a = bitarray(8) + a.setall(False) + a[0:1] = 1 + a[1:2] = 1 + x = ord(a.tobytes()) + return x | len(value) + + @staticmethod + def checksum(b): + result = 0 + for i in range(len(b)): + result += ord(b[i]) + return (0x100 - (result & 0xff)) & 0xff + + +class BaseArea(object): + SUGGESTED_SIZE_COMMON_HEADER = 8 + SUGGESTED_SIZE_INTERNAL_USE_AREA = 72 + SUGGESTED_SIZE_CHASSIS_INFO_AREA = 32 + SUGGESTED_SIZE_BOARD_INFO_AREA = 80 + SUGGESTED_SIZE_PRODUCT_INFO_AREA = 80 + + INITVALUE = b'\x00' + resultvalue = INITVALUE * 256 + COMMON_HEAD_VERSION = b'\x01' + __childList = None + + def __init__(self, name="", size=0, offset=0): + self.__childList = [] + self._offset = offset + self.name = name + self._size = size + self._isPresent = False + self._data = b'\x00' * size + self.__dataoffset = 0 + + @property + def childList(self): + return self.__childList + + @childList.setter + def childList(self, value): + self.__childList = value + + @property + def offset(self): + return self._offset + + @offset.setter + def offset(self, value): + self._offset = value + + @property + def size(self): + return self._size + + @size.setter + def size(self, value): + self._size = value + + @property + def data(self): + return self._data + + @data.setter + def data(self, value): + self._data = value + + @property + def isPresent(self): + return self._isPresent + + @isPresent.setter + def isPresent(self, value): + self._isPresent = value + + +class InternalUseArea(BaseArea): + pass + + +class ChassisInfoArea(BaseArea): + pass + + +class BoardInfoArea(BaseArea): + _boardTime = None + _fields = None + _mfg_date = None + + def __str__(self): + formatstr = "version : %x\n" \ + "length : %d \n" \ + "language : %x \n" \ + "mfg_date : %s \n" \ + "boardManufacturer : %s \n" \ + "boardProductName : %s \n" \ + "boardSerialNumber : %s \n" \ + "boardPartNumber : %s \n" \ + "fruFileId : %s \n" + + tmpstr = formatstr % (ord(self.boardversion), self.size, + self.language, self.getMfgRealData(), + self.boardManufacturer, self.boardProductName, + self.boardSerialNumber, self.boardPartNumber, + self.fruFileId) + for i in range(1, 11): + valtmp = "boardextra%d" % i + if hasattr(self, valtmp): + valtmpval = getattr(self, valtmp) + tmpstr += "boardextra%d : %s \n" % (i, valtmpval) + else: + break + + return tmpstr + + def todict(self): + dic = collections.OrderedDict() + dic["boardversion"] = ord(self.boardversion) + dic["boardlength"] = self.size + dic["boardlanguage"] = self.language + dic["boardmfg_date"] = self.getMfgRealData() + dic["boardManufacturer"] = self.boardManufacturer + dic["boardProductName"] = self.boardProductName + dic["boardSerialNumber"] = self.boardSerialNumber + dic["boardPartNumber"] = self.boardPartNumber + dic["boardfruFileId"] = self.fruFileId + for i in range(1, 11): + valtmp = "boardextra%d" % i + if hasattr(self, valtmp): + valtmpval = getattr(self, valtmp) + dic[valtmp] = valtmpval + else: + break + return dic + + def decodedata(self): + index = 0 + self.areaversion = self.data[index] + index += 1 + d_print("decode length :%d class size:%d" % + ((ord(self.data[index]) * 8), self.size)) + index += 2 + + timetmp = self.data[index: index + 3] + self.mfg_date = ord(timetmp[0]) | ( + ord(timetmp[1]) << 8) | (ord(timetmp[2]) << 16) + d_print("decode getMfgRealData :%s" % self.getMfgRealData()) + index += 3 + + templen = FruUtil.decodeLength(self.data[index]) + self.boardManufacturer = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode boardManufacturer:%s" % self.boardManufacturer) + + templen = FruUtil.decodeLength(self.data[index]) + self.boardProductName = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode boardProductName:%s" % self.boardProductName) + + templen = FruUtil.decodeLength(self.data[index]) + self.boardSerialNumber = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode boardSerialNumber:%s" % self.boardSerialNumber) + + templen = FruUtil.decodeLength(self.data[index]) + self.boardPartNumber = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode boardPartNumber:%s" % self.boardPartNumber) + + templen = FruUtil.decodeLength(self.data[index]) + self.fruFileId = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode fruFileId:%s" % self.fruFileId) + + for i in range(1, 11): + valtmp = "boardextra%d" % i + if self.data[index] != chr(0xc1): + templen = FruUtil.decodeLength(self.data[index]) + tmpval = self.data[index + 1: index + templen + 1] + setattr(self, valtmp, tmpval) + index += templen + 1 + d_print("decode boardextra%d:%s" % (i, tmpval)) + else: + break + return + + def recalcute(self): + d_print("boardInfoArea version:%x" % ord(self.boardversion)) + d_print("boardInfoArea length:%d" % self.size) + d_print("boardInfoArea language:%x" % self.language) + self.mfg_date = FruUtil.minToData() + d_print("boardInfoArea mfg_date:%x" % self.mfg_date) + + self.data = chr(ord(self.boardversion)) + \ + chr(self.size // 8) + chr(self.language) + + self.data += chr(self.mfg_date & 0xFF) + self.data += chr((self.mfg_date >> 8) & 0xFF) + self.data += chr((self.mfg_date >> 16) & 0xFF) + + d_print("boardInfoArea boardManufacturer:%s" % self.boardManufacturer) + typelength = FruUtil.getTypeLength(self.boardManufacturer) + self.data += chr(typelength) + self.data += self.boardManufacturer + + d_print("boardInfoArea boardProductName:%s" % self.boardProductName) + self.data += chr(FruUtil.getTypeLength(self.boardProductName)) + self.data += self.boardProductName + + d_print("boardInfoArea boardSerialNumber:%s" % self.boardSerialNumber) + self.data += chr(FruUtil.getTypeLength(self.boardSerialNumber)) + self.data += self.boardSerialNumber + + d_print("boardInfoArea boardPartNumber:%s" % self.boardPartNumber) + self.data += chr(FruUtil.getTypeLength(self.boardPartNumber)) + self.data += self.boardPartNumber + + d_print("boardInfoArea fruFileId:%s" % self.fruFileId) + self.data += chr(FruUtil.getTypeLength(self.fruFileId)) + self.data += self.fruFileId + + for i in range(1, 11): + valtmp = "boardextra%d" % i + if hasattr(self, valtmp): + valtmpval = getattr(self, valtmp) + d_print("boardInfoArea boardextra%d:%s" % (i, valtmpval)) + self.data += chr(FruUtil.getTypeLength(valtmpval)) + if valtmpval is None: + pass + else: + self.data += valtmpval + else: + break + + self.data += chr(0xc1) + + if len(self.data) > (self.size - 1): + incr = (len(self.data) - self.size) // 8 + 1 + self.size += incr * 8 + + self.data = self.data[0:1] + chr(self.size // 8) + self.data[2:] + d_print("self data:%d" % len(self.data)) + d_print("self size:%d" % self.size) + d_print("adjust size:%d" % (self.size - len(self.data) - 1)) + self.data = self.data.ljust((self.size - 1), chr(self.INITVALUE[0])) + + # checksum + checksum = FruUtil.checksum(self.data) + d_print("board info checksum:%x" % checksum) + self.data += chr(checksum) + + def getMfgRealData(self): + starttime = datetime(1996, 1, 1, 0, 0, 0) + mactime = starttime + timedelta(minutes=self.mfg_date) + return mactime + + @property + def language(self): + self._language = 25 + return self._language + + @property + def mfg_date(self): + return self._mfg_date + + @mfg_date.setter + def mfg_date(self, val): + self._mfg_date = val + + @property + def boardversion(self): + self._boardversion = self.COMMON_HEAD_VERSION + return self._boardversion + + @property + def fruFileId(self): + return self._FRUFileID + + @fruFileId.setter + def fruFileId(self, val): + self._FRUFileID = val + + @property + def boardPartNumber(self): + return self._boardPartNumber + + @boardPartNumber.setter + def boardPartNumber(self, val): + self._boardPartNumber = val + + @property + def boardSerialNumber(self): + return self._boardSerialNumber + + @boardSerialNumber.setter + def boardSerialNumber(self, val): + self._boardSerialNumber = val + + @property + def boardProductName(self): + return self._boradProductName + + @boardProductName.setter + def boardProductName(self, val): + self._boradProductName = val + + @property + def boardManufacturer(self): + return self._boardManufacturer + + @boardManufacturer.setter + def boardManufacturer(self, val): + self._boardManufacturer = val + + @property + def boardTime(self): + return self._boardTime + + @boardTime.setter + def boardTime(self, val): + self._boardTime = val + + @property + def fields(self): + return self._fields + + @fields.setter + def fields(self, val): + self._fields = val + + +class ProductInfoArea(BaseArea): + _productManufacturer = None + _productAssetTag = None + _FRUFileID = None + + def __str__(self): + formatstr = "version : %x\n" \ + "length : %d \n" \ + "language : %x \n" \ + "productManufacturer : %s \n" \ + "productName : %s \n" \ + "productPartModelName: %s \n" \ + "productVersion : %s \n" \ + "productSerialNumber : %s \n" \ + "productAssetTag : %s \n" \ + "fruFileId : %s \n" + + tmpstr = formatstr % (ord(self.areaversion), self.size, + self.language, self.productManufacturer, + self.productName, self.productPartModelName, + self.productVersion, self.productSerialNumber, + self.productAssetTag, self.fruFileId) + + for i in range(1, 11): + valtmp = "productextra%d" % i + if hasattr(self, valtmp): + valtmpval = getattr(self, valtmp) + tmpstr += "productextra%d : %s \n" % (i, valtmpval) + else: + break + + return tmpstr + + def todict(self): + dic = collections.OrderedDict() + dic["productversion"] = ord(self.areaversion) + dic["productlength"] = self.size + dic["productlanguage"] = self.language + dic["productManufacturer"] = self.productManufacturer + dic["productName"] = self.productName + dic["productPartModelName"] = self.productPartModelName + dic["productVersion"] = int(self.productVersion, 16) + dic["productSerialNumber"] = self.productSerialNumber + dic["productAssetTag"] = self.productAssetTag + dic["productfruFileId"] = self.fruFileId + for i in range(1, 11): + valtmp = "productextra%d" % i + if hasattr(self, valtmp): + valtmpval = getattr(self, valtmp) + dic[valtmp] = valtmpval + else: + break + return dic + + def decodedata(self): + index = 0 + self.areaversion = self.data[index] # 0 + index += 1 + d_print("decode length %d" % (ord(self.data[index]) * 8)) + d_print("class size %d" % self.size) + index += 2 + + templen = FruUtil.decodeLength(self.data[index]) + self.productManufacturer = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode productManufacturer:%s" % self.productManufacturer) + + templen = FruUtil.decodeLength(self.data[index]) + self.productName = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode productName:%s" % self.productName) + + templen = FruUtil.decodeLength(self.data[index]) + self.productPartModelName = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode productPartModelName:%s" % self.productPartModelName) + + templen = FruUtil.decodeLength(self.data[index]) + self.productVersion = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode productVersion:%s" % self.productVersion) + + templen = FruUtil.decodeLength(self.data[index]) + self.productSerialNumber = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode productSerialNumber:%s" % self.productSerialNumber) + + templen = FruUtil.decodeLength(self.data[index]) + self.productAssetTag = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode productAssetTag:%s" % self.productAssetTag) + + templen = FruUtil.decodeLength(self.data[index]) + self.fruFileId = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode fruFileId:%s" % self.fruFileId) + + for i in range(1, 11): + valtmp = "productextra%d" % i + if self.data[index] != chr(0xc1) and index < self.size - 1: + templen = FruUtil.decodeLength(self.data[index]) + if templen == 0: + break + tmpval = self.data[index + 1: index + templen + 1] + d_print("decode boardextra%d:%s" % (i, tmpval)) + setattr(self, valtmp, tmpval) + index += templen + 1 + else: + break + + @property + def productVersion(self): + return self._productVersion + + @productVersion.setter + def productVersion(self, name): + self._productVersion = name + + @property + def areaversion(self): + self._areaversion = self.COMMON_HEAD_VERSION + return self._areaversion + + @areaversion.setter + def areaversion(self, name): + self._areaversion = name + + @property + def language(self): + self._language = 25 + return self._language + + @property + def productManufacturer(self): + return self._productManufacturer + + @productManufacturer.setter + def productManufacturer(self, name): + self._productManufacturer = name + + @property + def productName(self): + return self._productName + + @productName.setter + def productName(self, name): + self._productName = name + + @property + def productPartModelName(self): + return self._productPartModelName + + @productPartModelName.setter + def productPartModelName(self, name): + self._productPartModelName = name + + @property + def productSerialNumber(self): + return self._productSerialNumber + + @productSerialNumber.setter + def productSerialNumber(self, name): + self._productSerialNumber = name + + @property + def productAssetTag(self): + return self._productAssetTag + + @productAssetTag.setter + def productAssetTag(self, name): + self._productAssetTag = name + + @property + def fruFileId(self): + return self._FRUFileID + + @fruFileId.setter + def fruFileId(self, name): + self._FRUFileID = name + + def recalcute(self): + d_print("product version:%x" % ord(self.areaversion)) + d_print("product length:%d" % self.size) + d_print("product language:%x" % self.language) + self.data = chr(ord(self.areaversion)) + \ + chr(self.size // 8) + chr(self.language) + + typelength = FruUtil.getTypeLength(self.productManufacturer) + self.data += chr(typelength) + self.data += self.productManufacturer + + self.data += chr(FruUtil.getTypeLength(self.productName)) + self.data += self.productName + + self.data += chr(FruUtil.getTypeLength(self.productPartModelName)) + self.data += self.productPartModelName + + self.data += chr(FruUtil.getTypeLength(self.productVersion)) + self.data += self.productVersion + + self.data += chr(FruUtil.getTypeLength(self.productSerialNumber)) + self.data += self.productSerialNumber + + self.data += chr(FruUtil.getTypeLength(self.productAssetTag)) + if self.productAssetTag is not None: + self.data += self.productAssetTag + + self.data += chr(FruUtil.getTypeLength(self.fruFileId)) + self.data += self.fruFileId + + for i in range(1, 11): + valtmp = "productextra%d" % i + if hasattr(self, valtmp): + valtmpval = getattr(self, valtmp) + d_print("boardInfoArea productextra%d:%s" % (i, valtmpval)) + self.data += chr(FruUtil.getTypeLength(valtmpval)) + if valtmpval is None: + pass + else: + self.data += valtmpval + else: + break + + self.data += chr(0xc1) + if len(self.data) > (self.size - 1): + incr = (len(self.data) - self.size) // 8 + 1 + self.size += incr * 8 + d_print("self.data:%d" % len(self.data)) + d_print("self.size:%d" % self.size) + + self.data = self.data[0:1] + chr(self.size // 8) + self.data[2:] + self.data = self.data.ljust((self.size - 1), chr(self.INITVALUE[0])) + checksum = FruUtil.checksum(self.data) + d_print("board info checksum:%x" % checksum) + self.data += chr(checksum) + + +class MultiRecordArea(BaseArea): + pass + + +class Field(object): + + def __init__(self, fieldType="ASCII", fieldData=""): + self.fieldData = fieldData + self.fieldType = fieldType + + @property + def data(self): + return self._data + + @property + def fieldType(self): + return self._fieldType + + @property + def fieldData(self): + return self._fieldData + + +class ipmifru(BaseArea): + _BoardInfoArea = None + _ProductInfoArea = None + _InternalUseArea = None + _ChassisInfoArea = None + _multiRecordArea = None + _productinfoAreaOffset = BaseArea.INITVALUE + _boardInfoAreaOffset = BaseArea.INITVALUE + _internalUserAreaOffset = BaseArea.INITVALUE + _chassicInfoAreaOffset = BaseArea.INITVALUE + _multiRecordAreaOffset = BaseArea.INITVALUE + _bindata = None + _bodybin = None + _version = BaseArea.COMMON_HEAD_VERSION + _zeroCheckSum = None + _frusize = 256 + + def __str__(self): + tmpstr = "" + if self.boardInfoArea.isPresent: + tmpstr += "\nboardinfoarea: \n" + tmpstr += self.boardInfoArea.__str__() + if self.productInfoArea.isPresent: + tmpstr += "\nproductinfoarea: \n" + tmpstr += self.productInfoArea.__str__() + return tmpstr + + def decodeBin(self, eeprom): + commonHead = eeprom[0:8] + d_print("decode version %x" % ord(commonHead[0])) + if ord(self.COMMON_HEAD_VERSION) != ord(commonHead[0]): + raise FruException("HEAD VERSION error,not Fru format!", -10) + if FruUtil.checksum(commonHead[0:7]) != ord(commonHead[7]): + strtemp = "check header checksum error [cal:%02x data:%02x]" % ( + FruUtil.checksum(commonHead[0:7]), ord(commonHead[7])) + raise FruException(strtemp, -3) + if ord(commonHead[1]) != ord(self.INITVALUE): + d_print("Internal Use Area is present") + self.internalUseArea = InternalUseArea( + name="Internal Use Area", size=self.SUGGESTED_SIZE_INTERNAL_USE_AREA) + self.internalUseArea.isPresent = True + self.internalUserAreaOffset = ord(commonHead[1]) + self.internalUseArea.data = eeprom[self.internalUserAreaOffset * 8: ( + self.internalUserAreaOffset * 8 + self.internalUseArea.size)] + if ord(commonHead[2]) != ord(self.INITVALUE): + d_print("Chassis Info Area is present") + self.chassisInfoArea = ChassisInfoArea( + name="Chassis Info Area", size=self.SUGGESTED_SIZE_CHASSIS_INFO_AREA) + self.chassisInfoArea.isPresent = True + self.chassicInfoAreaOffset = ord(commonHead[2]) + self.chassisInfoArea.data = eeprom[self.chassicInfoAreaOffset * 8: ( + self.chassicInfoAreaOffset * 8 + self.chassisInfoArea.size)] + if ord(commonHead[3]) != ord(self.INITVALUE): + self.boardInfoArea = BoardInfoArea( + name="Board Info Area", size=self.SUGGESTED_SIZE_BOARD_INFO_AREA) + self.boardInfoArea.isPresent = True + self.boardInfoAreaOffset = ord(commonHead[3]) + self.boardInfoArea.size = ord( + eeprom[self.boardInfoAreaOffset * 8 + 1]) * 8 + d_print("Board Info Area is present size:%d" % + (self.boardInfoArea.size)) + self.boardInfoArea.data = eeprom[self.boardInfoAreaOffset * 8: ( + self.boardInfoAreaOffset * 8 + self.boardInfoArea.size)] + if FruUtil.checksum(self.boardInfoArea.data[:-1]) != ord(self.boardInfoArea.data[-1:]): + strtmp = "check boardInfoArea checksum error[cal:%02x data:%02x]" % \ + (FruUtil.checksum( + self.boardInfoArea.data[:-1]), ord(self.boardInfoArea.data[-1:])) + raise FruException(strtmp, -3) + self.boardInfoArea.decodedata() + if ord(commonHead[4]) != ord(self.INITVALUE): + d_print("Product Info Area is present") + self.productInfoArea = ProductInfoArea( + name="Product Info Area ", size=self.SUGGESTED_SIZE_PRODUCT_INFO_AREA) + self.productInfoArea.isPresent = True + self.productinfoAreaOffset = ord(commonHead[4]) + d_print("length offset value: %02x" % + ord(eeprom[self.productinfoAreaOffset * 8 + 1])) + self.productInfoArea.size = ord( + eeprom[self.productinfoAreaOffset * 8 + 1]) * 8 + d_print("Product Info Area is present size:%d" % + (self.productInfoArea.size)) + + self.productInfoArea.data = eeprom[self.productinfoAreaOffset * 8: ( + self.productinfoAreaOffset * 8 + self.productInfoArea.size)] + if FruUtil.checksum(self.productInfoArea.data[:-1]) != ord(self.productInfoArea.data[-1:]): + strtmp = "check productInfoArea checksum error [cal:%02x data:%02x]" % ( + FruUtil.checksum(self.productInfoArea.data[:-1]), ord(self.productInfoArea.data[-1:])) + raise FruException(strtmp, -3) + self.productInfoArea.decodedata() + if ord(commonHead[5]) != ord(self.INITVALUE): + self.multiRecordArea = MultiRecordArea( + name="MultiRecord record Area ") + d_print("MultiRecord record present") + self.multiRecordArea.isPresent = True + self.multiRecordAreaOffset = ord(commonHead[5]) + self.multiRecordArea.data = eeprom[self.multiRecordAreaOffset * 8: ( + self.multiRecordAreaOffset * 8 + self.multiRecordArea.size)] + + def initDefault(self): + self.version = self.COMMON_HEAD_VERSION + self.internalUserAreaOffset = self.INITVALUE + self.chassicInfoAreaOffset = self.INITVALUE + self.boardInfoAreaOffset = self.INITVALUE + self.productinfoAreaOffset = self.INITVALUE + self.multiRecordAreaOffset = self.INITVALUE + self.PAD = self.INITVALUE + self.zeroCheckSum = self.INITVALUE + self.offset = self.SUGGESTED_SIZE_COMMON_HEADER + self.productInfoArea = None + self.internalUseArea = None + self.boardInfoArea = None + self.chassisInfoArea = None + self.multiRecordArea = None + # self.recalcute() + + @property + def version(self): + return self._version + + @version.setter + def version(self, name): + self._version = name + + @property + def internalUserAreaOffset(self): + return self._internalUserAreaOffset + + @internalUserAreaOffset.setter + def internalUserAreaOffset(self, obj): + self._internalUserAreaOffset = obj + + @property + def chassicInfoAreaOffset(self): + return self._chassicInfoAreaOffset + + @chassicInfoAreaOffset.setter + def chassicInfoAreaOffset(self, obj): + self._chassicInfoAreaOffset = obj + + @property + def productinfoAreaOffset(self): + return self._productinfoAreaOffset + + @productinfoAreaOffset.setter + def productinfoAreaOffset(self, obj): + self._productinfoAreaOffset = obj + + @property + def boardInfoAreaOffset(self): + return self._boardInfoAreaOffset + + @boardInfoAreaOffset.setter + def boardInfoAreaOffset(self, obj): + self._boardInfoAreaOffset = obj + + @property + def multiRecordAreaOffset(self): + return self._multiRecordAreaOffset + + @multiRecordAreaOffset.setter + def multiRecordAreaOffset(self, obj): + self._multiRecordAreaOffset = obj + + @property + def zeroCheckSum(self): + return self._zeroCheckSum + + @zeroCheckSum.setter + def zeroCheckSum(self, obj): + self._zeroCheckSum = obj + + @property + def productInfoArea(self): + return self._ProductInfoArea + + @productInfoArea.setter + def productInfoArea(self, obj): + self._ProductInfoArea = obj + + @property + def internalUseArea(self): + return self._InternalUseArea + + @internalUseArea.setter + def internalUseArea(self, obj): + self.internalUseArea = obj + + @property + def boardInfoArea(self): + return self._BoardInfoArea + + @boardInfoArea.setter + def boardInfoArea(self, obj): + self._BoardInfoArea = obj + + @property + def chassisInfoArea(self): + return self._ChassisInfoArea + + @chassisInfoArea.setter + def chassisInfoArea(self, obj): + self._ChassisInfoArea = obj + + @property + def multiRecordArea(self): + return self._multiRecordArea + + @multiRecordArea.setter + def multiRecordArea(self, obj): + self._multiRecordArea = obj + + @property + def bindata(self): + return self._bindata + + @bindata.setter + def bindata(self, obj): + self._bindata = obj + + @property + def bodybin(self): + return self._bodybin + + @bodybin.setter + def bodybin(self, obj): + self._bodybin = obj + + def recalcuteCommonHead(self): + self.bindata = "" + self.offset = self.SUGGESTED_SIZE_COMMON_HEADER + d_print("common Header %d" % self.offset) + d_print("fru eeprom size %d" % self._frusize) + if self.internalUseArea is not None and self.internalUseArea.isPresent: + self.internalUserAreaOffset = self.offset // 8 + self.offset += self.internalUseArea.size + d_print("internalUseArea is present offset:%d" % self.offset) + + if self.chassisInfoArea is not None and self.chassisInfoArea.isPresent: + self.chassicInfoAreaOffset = self.offset // 8 + self.offset += self.chassisInfoArea.size + d_print("chassisInfoArea is present offset:%d" % self.offset) + + if self.boardInfoArea is not None and self.boardInfoArea.isPresent: + self.boardInfoAreaOffset = self.offset // 8 + self.offset += self.boardInfoArea.size + d_print("boardInfoArea is present offset:%d" % self.offset) + d_print("boardInfoArea is present size:%d" % + self.boardInfoArea.size) + + if self.productInfoArea is not None and self.productInfoArea.isPresent: + self.productinfoAreaOffset = self.offset // 8 + self.offset += self.productInfoArea.size + d_print("productInfoArea is present offset:%d" % self.offset) + + if self.multiRecordArea is not None and self.multiRecordArea.isPresent: + self.multiRecordAreaOffset = self.offset // 8 + d_print("multiRecordArea is present offset:%d" % self.offset) + + if self.internalUserAreaOffset == self.INITVALUE: + self.internalUserAreaOffset = 0 + if self.productinfoAreaOffset == self.INITVALUE: + self.productinfoAreaOffset = 0 + if self.chassicInfoAreaOffset == self.INITVALUE: + self.chassicInfoAreaOffset = 0 + if self.boardInfoAreaOffset == self.INITVALUE: + self.boardInfoAreaOffset = 0 + if self.multiRecordAreaOffset == self.INITVALUE: + self.multiRecordAreaOffset = 0 + + self.zeroCheckSum = (0x100 - ord(self.version) - self.internalUserAreaOffset - self.chassicInfoAreaOffset - self.productinfoAreaOffset + - self.boardInfoAreaOffset - self.multiRecordAreaOffset) & 0xff + d_print("zerochecksum:%x" % self.zeroCheckSum) + self.data = "" + self.data += chr(self.version[0]) + chr(self.internalUserAreaOffset) + chr(self.chassicInfoAreaOffset) + chr( + self.boardInfoAreaOffset) + chr(self.productinfoAreaOffset) + chr(self.multiRecordAreaOffset) + chr(self.INITVALUE[0]) + chr(self.zeroCheckSum) + + self.bindata = self.data + self.bodybin + totallen = len(self.bindata) + d_print("totallen %d" % totallen) + if (totallen < self._frusize): + self.bindata = self.bindata.ljust(self._frusize, chr(self.INITVALUE[0])) + else: + raise FruException('bin data more than %d' % self._frusize, -2) + + def recalcutebin(self): + self.bodybin = "" + if self.internalUseArea is not None and self.internalUseArea.isPresent: + d_print("internalUseArea present") + self.bodybin += self.internalUseArea.data + if self.chassisInfoArea is not None and self.chassisInfoArea.isPresent: + d_print("chassisInfoArea present") + self.bodybin += self.chassisInfoArea.data + if self.boardInfoArea is not None and self.boardInfoArea.isPresent: + d_print("boardInfoArea present") + self.boardInfoArea.recalcute() + self.bodybin += self.boardInfoArea.data + if self.productInfoArea is not None and self.productInfoArea.isPresent: + d_print("productInfoAreapresent") + self.productInfoArea.recalcute() + self.bodybin += self.productInfoArea.data + if self.multiRecordArea is not None and self.multiRecordArea.isPresent: + d_print("multiRecordArea present") + self.bodybin += self.productInfoArea.data + + def recalcute(self, fru_eeprom_size=256): + self._frusize = fru_eeprom_size + self.recalcutebin() + self.recalcuteCommonHead() diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/eepromutil/onietlv.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/eepromutil/onietlv.py new file mode 100755 index 000000000000..e75063e8bde4 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/eepromutil/onietlv.py @@ -0,0 +1,449 @@ +#!/usr/bin/python3 +import binascii + + +class OnietlvException(Exception): + def __init__(self, message='onietlverror', code=-100): + err = 'errcode: {0} message:{1}'.format(code, message) + Exception.__init__(self, err) + self.code = code + self.message = message + + +class onie_tlv(object): + TLV_INFO_ID_STRING = "TlvInfo\x00" + TLV_INFO_INIA_ID = "\x00\x00\x13\x11" + TLV_INFO_VERSION = 0x01 + TLV_INFO_LENGTH = 0x00 + TLV_INFO_LENGTH_VALUE = 0xba + + TLV_CODE_PRODUCT_NAME = 0x21 + TLV_CODE_PART_NUMBER = 0x22 + TLV_CODE_SERIAL_NUMBER = 0x23 + TLV_CODE_MAC_BASE = 0x24 + TLV_CODE_MANUF_DATE = 0x25 + TLV_CODE_DEVICE_VERSION = 0x26 + TLV_CODE_LABEL_REVISION = 0x27 + TLV_CODE_PLATFORM_NAME = 0x28 + TLV_CODE_ONIE_VERSION = 0x29 + TLV_CODE_MAC_SIZE = 0x2A + TLV_CODE_MANUF_NAME = 0x2B + TLV_CODE_MANUF_COUNTRY = 0x2C + TLV_CODE_VENDOR_NAME = 0x2D + TLV_CODE_DIAG_VERSION = 0x2E + TLV_CODE_SERVICE_TAG = 0x2F + TLV_CODE_VENDOR_EXT = 0xFD + TLV_CODE_CRC_32 = 0xFE + _TLV_DISPLAY_VENDOR_EXT = 1 + TLV_CODE_RJ_CARID = 0x01 + _TLV_INFO_HDR_LEN = 11 + TLV_CODE_PRODUCT_ID = 0x40 + TLV_CODE_HW_VERSION = 0x41 + TLV_CODE_MAIN_FILENAME = 0x42 + TLV_CODE_DTS_FINENAME = 0x43 + TLV_CODE_SY_SERIAL0 = 0x44 + TLV_CODE_SY_SERIAL1 = 0x45 + TLV_CODE_SY_SERIAL2 = 0x46 + TLV_CODE_SY_SERIAL3 = 0x47 + TLV_CODE_PROJECT_ID = 0x48 + TLV_CODE_SETMAC_VERSION = 0x49 + TLV_CODE_EEPROM_TYPE = 0x4A + + @property + def dstatus(self): + return self._dstatus + + @property + def cardid(self): + return self._cardid + + @property + def productname(self): + return self._productname + + @property + def partnum(self): + return self._partnum + + @property + def serialnum(self): + return self._serialnum + + @property + def macbase(self): + return self._macbase + + @property + def manufdate(self): + return self._manufdate + + @property + def deviceversion(self): + return self._deviceversion + + @property + def labelrevision(self): + return self._labelrevision + + @property + def platformname(self): + return self._platformname + + @property + def onieversion(self): + return self._onieversion + + @property + def macsize(self): + return self._macsize + + @property + def manufname(self): + return self._manufname + + @property + def manufcountry(self): + return self._manufcountry + + @property + def vendorname(self): + return self._vendorname + + @property + def diagname(self): + return self._diagname + + @property + def servicetag(self): + return self._servicetag + + @property + def vendorext(self): + return self._vendorext + + @property + def fanbus(self): + return self._fanbus + + @property + def fanloc(self): + return self._fanloc + + def __init__(self): + self._cardid = "" + self._productname = "" + self._partnum = "" + self._serialnum = "" + self._macbase = "" + self._manufdate = "" + self._deviceversion = "" + self._labelrevision = "" + self._platformname = "" + self._onieversion = "" + self._macsize = "" + self._manufname = "" + self._manufcountry = "" + self._vendorname = "" + self._diagname = "" + self._servicetag = "" + self._vendorext = "" + self._productid = "" + self._hwversion = "" + self._mainfilename = "" + self._dtsfilename = "" + self._syserial0 = "" + self._syserial1 = "" + self._syserial2 = "" + self._syserial3 = "" + self._projectid = "" + self._setmacversion = "" + self._eepromtype = "" + self._crc32 = "" + self._dstatus = 0 + + def oniecrc32(self, v): + data_array = bytearray() + for x in v: + data_array.append(ord(x)) + return '0x%08x' % (binascii.crc32(bytes(data_array)) & 0xffffffff) + + def getTLV_BODY(self, type, value): + x = [] + temp_t = "" + if type == self.TLV_CODE_MAC_BASE: + arr = value.split(':') + for tt in arr: + temp_t += chr(int(tt, 16)) + elif type == self.TLV_CODE_DEVICE_VERSION: + temp_t = chr(value) + elif type == self.TLV_CODE_MAC_SIZE: + temp_t = chr(value >> 8) + chr(value & 0x00ff) + else: + temp_t = value + x.append(chr(type)) + x.append(chr(len(temp_t))) + for i in temp_t: + x.append(i) + return x + + def generate_ext(self, cardid): + s = "%08x" % cardid + ret = "" + for t in range(0, 4): + ret += chr(int(s[2 * t:2 * t + 2], 16)) + ret = chr(0x01) + chr(len(ret)) + ret + return ret + + def generate_value(self, _t): + ret = [] + for i in self.TLV_INFO_ID_STRING: + ret.append(i) + ret.append(chr(self.TLV_INFO_VERSION)) + ret.append(chr(self.TLV_INFO_LENGTH)) + ret.append(chr(self.TLV_INFO_LENGTH_VALUE)) + + total_len = 0 + for key in _t: + x = self.getTLV_BODY(key, _t[key]) + ret += x + total_len += len(x) + ret[10] = chr(total_len + 6) + + ret.append(chr(0xFE)) + ret.append(chr(0x04)) + s = self.oniecrc32(''.join(ret)) + for t in range(0, 4): + ret.append(chr(int(s[2 * t + 2:2 * t + 4], 16))) + totallen = len(ret) + if (totallen < 256): + for left_t in range(0, 256 - totallen): + ret.append(chr(0x00)) + return (ret, True) + + def decode_tlv(self, e): + tlv_index = 0 + tlv_end = len(e) + ret = [] + while tlv_index < tlv_end and (tlv_index + 2 + ord(e[tlv_index + 1])) <= len(e): + rt = self.decoder(e[tlv_index:tlv_index + 2 + ord(e[tlv_index + 1])]) + ret.append(rt) + if ord(e[tlv_index]) == self.TLV_CODE_CRC_32: + break + tlv_index += ord(e[tlv_index + 1]) + 2 + return ret + + def decode(self, e): + if e[0:8] != self.TLV_INFO_ID_STRING: + raise OnietlvException("ONIE tlv head info error,not onie tlv type", -1) + total_len = (ord(e[9]) << 8) | ord(e[10]) + tlv_index = self._TLV_INFO_HDR_LEN + tlv_end = self._TLV_INFO_HDR_LEN + total_len + if tlv_end > len(e): + raise OnietlvException("ONIE tlv length error", -2) + ret = [] + ret = self.decode_tlv(e[tlv_index:tlv_end]) + for item in ret: + if item['code'] == self.TLV_CODE_VENDOR_EXT: + if item["value"][0:4] == self.TLV_INFO_INIA_ID: + rt = self.decode_tlv(item["value"][4:]) + else: + rt = self.decode_tlv(item["value"][0:]) + ret.extend(rt) + return ret + + def decoder(self, t): + if ord(t[0]) == self.TLV_CODE_PRODUCT_NAME: + name = "Product Name" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._productname = value + elif ord(t[0]) == self.TLV_CODE_PART_NUMBER: + name = "Part Number" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._partnum = value + elif ord(t[0]) == self.TLV_CODE_SERIAL_NUMBER: + name = "Serial Number" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._serialnum = value + elif ord(t[0]) == self.TLV_CODE_MAC_BASE: + name = "Base MAC Address" + _len = ord(t[1]) + value = ":".join(['%02X' % ord(T) for T in t[2:8]]).upper() + self._macbase = value + elif ord(t[0]) == self.TLV_CODE_MANUF_DATE: + name = "Manufacture Date" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._manufdate = value + elif ord(t[0]) == self.TLV_CODE_DEVICE_VERSION: + name = "Device Version" + _len = ord(t[1]) + value = ord(t[2]) + self._deviceversion = value + elif ord(t[0]) == self.TLV_CODE_LABEL_REVISION: + name = "Label Revision" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._labelrevision = value + elif ord(t[0]) == self.TLV_CODE_PLATFORM_NAME: + name = "Platform Name" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._platformname = value + elif ord(t[0]) == self.TLV_CODE_ONIE_VERSION: + name = "ONIE Version" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._onieversion = value + elif ord(t[0]) == self.TLV_CODE_MAC_SIZE: + name = "MAC Addresses" + _len = ord(t[1]) + value = str((ord(t[2]) << 8) | ord(t[3])) + self._macsize = value + elif ord(t[0]) == self.TLV_CODE_MANUF_NAME: + name = "Manufacturer" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._manufname = value + elif ord(t[0]) == self.TLV_CODE_MANUF_COUNTRY: + name = "Manufacture Country" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._manufcountry = value + elif ord(t[0]) == self.TLV_CODE_VENDOR_NAME: + name = "Vendor Name" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._vendorname = value + elif ord(t[0]) == self.TLV_CODE_DIAG_VERSION: + name = "Diag Version" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._diagname = value + elif ord(t[0]) == self.TLV_CODE_SERVICE_TAG: + name = "Service Tag" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._servicetag = value + elif ord(t[0]) == self.TLV_CODE_VENDOR_EXT: + name = "Vendor Extension" + _len = ord(t[1]) + value = "" + if self._TLV_DISPLAY_VENDOR_EXT: + value = t[2:2 + ord(t[1])] + self._vendorext = value + elif ord(t[0]) == self.TLV_CODE_CRC_32 and len(t) == 6: + name = "CRC-32" + _len = ord(t[1]) + value = "0x%08X" % (((ord(t[2]) << 24) | ( + ord(t[3]) << 16) | (ord(t[4]) << 8) | ord(t[5])),) + self._crc32 = value + elif ord(t[0]) == self.TLV_CODE_RJ_CARID: + name = "Card id" + _len = ord(t[1]) + value = "" + for c in t[2:2 + ord(t[1])]: + value += "%02X" % (ord(c),) + self._cardid = value + elif ord(t[0]) == self.TLV_CODE_PRODUCT_ID: + name = "Product id" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._productid = value + elif ord(t[0]) == self.TLV_CODE_HW_VERSION: + name = "Hardware Version" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._hwversion = value + elif ord(t[0]) == self.TLV_CODE_MAIN_FILENAME: + name = "Main File Name" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._mainfilename = value + elif ord(t[0]) == self.TLV_CODE_DTS_FINENAME: + name = "DTS File Name" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._dtsfilename = value + elif ord(t[0]) == self.TLV_CODE_SY_SERIAL0: + name = "SY Serial 0" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._syserial0 = value + elif ord(t[0]) == self.TLV_CODE_SY_SERIAL1: + name = "SY Serial 1" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._syserial1 = value + elif ord(t[0]) == self.TLV_CODE_SY_SERIAL2: + name = "SY Serial 2" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._syserial2 = value + elif ord(t[0]) == self.TLV_CODE_SY_SERIAL3: + name = "SY Serial 3" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._syserial3 = value + elif ord(t[0]) == self.TLV_CODE_PROJECT_ID: + name = "Project id" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._projectid = value + elif ord(t[0]) == self.TLV_CODE_SETMAC_VERSION: + name = "Setmac Version" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._setmacversion = value + elif ord(t[0]) == self.TLV_CODE_EEPROM_TYPE: + name = "EEPROM Type" + _len = ord(t[1]) + value = "" + for c in t[2:2 + ord(t[1])]: + value += "%02X" % (ord(c),) + self._eepromtype = value + else: + name = "Unknown" + _len = ord(t[1]) + value = "" + for c in t[2:2 + ord(t[1])]: + value += "0x%02X " % (ord(c),) + return {"name": name, "code": ord(t[0]), "value": value, "lens": _len} + + def __str__(self): + formatstr = "Card id : %s \n" \ + "Product Name : %s \n" \ + "Part Number : %s \n" \ + "Serial Number : %s \n" \ + "Base MAC Address : %s \n" \ + "Manufacture Date : %s \n" \ + "Device Version : %s \n" \ + "Label Revision : %s \n" \ + "Platform Name : %s \n" \ + "ONIE Version : %s \n" \ + "MAC Addresses : %s \n" \ + "Manufacturer : %s \n" \ + "Manufacture Country : %s \n" \ + "Vendor Name : %s \n" \ + "Diag Version : %s \n" \ + "Service Tag : %s \n" \ + "CRC-32 : %s \n" + return formatstr % (self._cardid, + self._productname, + self._partnum, + self._serialnum, + self._macbase, + self._manufdate, + self._deviceversion, + self._labelrevision, + self._platformname, + self._onieversion, + self._macsize, + self._manufname, + self._manufcountry, + self._vendorname, + self._diagname, + self._servicetag, + self._crc32) diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/__init__.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/__init__.py new file mode 100755 index 000000000000..e69de29bb2d1 diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/baseutil.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/baseutil.py new file mode 100755 index 000000000000..33d559a39d0f --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/baseutil.py @@ -0,0 +1,141 @@ +#!/usr/bin/env python3 +####################################################### +# +# baseutil.py +# Python implementation of the Class baseutil +# Original author: rd@ruijie.com.cn +# +####################################################### +import importlib.machinery +import os +import syslog +from plat_hal.osutil import osutil + +SYSLOG_IDENTIFIER = "HAL" + +CONFIG_DB_PATH = "/etc/sonic/config_db.json" +BOARD_ID_PATH = "/sys/module/ruijie_common/parameters/dfd_my_type" + + +def getonieplatform(path): + if not os.path.isfile(path): + return "" + machine_vars = {} + with open(path) as machine_file: + for line in machine_file: + tokens = line.split('=') + if len(tokens) < 2: + continue + machine_vars[tokens[0]] = tokens[1].strip() + return machine_vars.get("onie_platform") + + +def getboardid(): + if not os.path.exists(BOARD_ID_PATH): + return "NA" + with open(BOARD_ID_PATH) as fd: + id_str = fd.read().strip() + return "0x%x" % (int(id_str, 10)) + + +def getplatform_config_db(): + if not os.path.isfile(CONFIG_DB_PATH): + return "" + val = os.popen("sonic-cfggen -j %s -v DEVICE_METADATA.localhost.platform" % CONFIG_DB_PATH).read().strip() + if len(val) <= 0: + return "" + else: + return val + + +def getplatform_name(): + if os.path.isfile('/host/machine.conf'): + return getonieplatform('/host/machine.conf') + elif os.path.isfile('/usr/share/sonic/hwsku/machine.conf'): + return getonieplatform('/usr/share/sonic/hwsku/machine.conf') + else: + return getplatform_config_db() + + +CONFIG_FILE_LIST = ["/usr/local/bin/", "/usr/lib/python3/dist-packages/", "/usr/local/lib/python3.7/dist-packages/hal-config/", "/usr/local/lib/python3.9/dist-packages/hal-config/"] + +platform = (getplatform_name()).replace("-", "_") +boardid = getboardid() + +boardid_devicefile = (platform + "_"+ boardid + "_device.py") +boardid_monitorfile = (platform + "_"+ boardid + "_monitor.py") + +devicefile = (platform + "_device.py") +monitorfile = (platform + "_monitor.py") + + +class baseutil: + + CONFIG_NAME = 'devices' + MONITOR_CONFIG_NAME = 'monitor' + UBOOT_ENV_URL = '/etc/device/uboot_env' + + @staticmethod + def get_config(): + real_path = None + for configfile_path in CONFIG_FILE_LIST: + boardid_config_file_path = (configfile_path + boardid_devicefile) + config_file_path = (configfile_path + devicefile) + if os.path.exists(boardid_config_file_path): + real_path = boardid_config_file_path + break + elif os.path.exists(config_file_path): + real_path = config_file_path + break + if real_path is None: + raise Exception("get hal device config error") + devices = importlib.machinery.SourceFileLoader(baseutil.CONFIG_NAME, real_path).load_module() + return devices.devices + + @staticmethod + def get_monitor_config(): + real_path = None + for configfile_path in CONFIG_FILE_LIST: + boardid_config_file_path = (configfile_path + boardid_monitorfile) + config_file_path = (configfile_path + monitorfile) + if os.path.exists(boardid_config_file_path): + real_path = boardid_config_file_path + break + elif os.path.exists(config_file_path): + real_path = config_file_path + break + if real_path is None: + raise Exception("get hal monitor config error") + monitor = importlib.machinery.SourceFileLoader(baseutil.MONITOR_CONFIG_NAME, real_path).load_module() + return monitor.monitor + + @staticmethod + def get_productname(): + ret, val = osutil.command("cat %s |grep productname | awk -F\"=\" '{print $2;}'" % baseutil.UBOOT_ENV_URL) + tmp = val.lower().replace('-', '_') + if ret != 0 or len(val) <= 0: + raise Exception("get productname error") + else: + return tmp + + @staticmethod + def get_platform(): + ret, val = osutil.command("cat %s |grep conffitname | awk -F\"=\" '{print $2;}'" % baseutil.UBOOT_ENV_URL) + if ret != 0 or len(val) <= 0: + raise Exception("get platform error") + else: + return val + + @staticmethod + def get_product_fullname(): + ret, val = osutil.command("cat %s |grep productname | awk -F\"=\" '{print $2;}'" % baseutil.UBOOT_ENV_URL) + if ret != 0 or len(val) <= 0: + raise Exception("get productname error") + else: + return val + + @staticmethod + def logger_debug(msg): + syslog.openlog(SYSLOG_IDENTIFIER) + syslog.syslog(syslog.LOG_DEBUG, msg) + syslog.closelog() diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/chassisbase.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/chassisbase.py new file mode 100755 index 000000000000..b1b08e12bc7a --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/chassisbase.py @@ -0,0 +1,322 @@ +#!/usr/bin/env python3 +####################################################### +# +# chassisbase.py +# Python implementation of the Class chassisbase +# Original author: rd@ruijie.com.cn +# +####################################################### +from plat_hal.dcdc import dcdc +from plat_hal.onie_e2 import onie_e2 +from plat_hal.psu import psu +from plat_hal.led import led +from plat_hal.temp import temp +from plat_hal.fan import fan +from plat_hal.cpld import cpld +from plat_hal.component import component +from plat_hal.cpu import cpu +from plat_hal.baseutil import baseutil + + +class chassisbase(object): + __onie_e2_list = [] + __psu_list = [] + __led_list = [] + __temp_list = [] + __fan_list = [] + __card_list = [] + __sensor_list = [] + __dcdc_list = [] + __cpld_list = [] + __comp_list = [] + __bios_list = [] + __bmc_list = [] + __cpu = None + + def __init__(self, conftype=0, conf=None): + # type: (object, object, object) -> object + """ + init chassisbase as order + + type = 0 use default conf, maybe auto find by platform + type = 1 use given conf, conf is not None + + BITMAP + bit 16 + bit 0 PSU + bit 1 LED + bit 2 TEMP + bit 3 fan + bit 4 card + bit 5 sensor + """ + __confTemp = None + + if conftype == 0: + # user + __confTemp = baseutil.get_config() + elif conftype == 1: + __confTemp = conf + + # onie_e2 + onie_e2temp = [] + onie_e2config = __confTemp.get('onie_e2', []) + for i in range(len((onie_e2config))): + onie_e2_1 = onie_e2(onie_e2config[i]) + onie_e2temp.append(onie_e2_1) + self.onie_e2_list = onie_e2temp + + # psu + psutemp = [] + psuconfig = __confTemp.get('psus', []) + for i in range(len((psuconfig))): + psu1 = psu(psuconfig[i]) + psutemp.append(psu1) + self.psu_list = psutemp + + # led + ledtemp = [] + ledconfig = __confTemp.get('leds', []) + for i in range(len((ledconfig))): + led1 = led(ledconfig[i]) + ledtemp.append(led1) + self.led_list = ledtemp + + # temp + temptemp = [] + tempconfig = __confTemp.get('temps', []) + for i in range(len((tempconfig))): + temp1 = temp(tempconfig[i]) + temptemp.append(temp1) + self.temp_list = temptemp + + # fan + fantemp = [] + fanconfig = __confTemp.get('fans', []) + for i in range(len((fanconfig))): + fan1 = fan(fanconfig[i]) + fantemp.append(fan1) + self.fan_list = fantemp + + # dcdc + dcdctemp = [] + dcdcconfig = __confTemp.get('dcdc', []) + for i in dcdcconfig: + dcdc1 = dcdc(i) + dcdctemp.append(dcdc1) + self.dcdc_list = dcdctemp + + # cpld + cpldtemp = [] + cpldconfig = __confTemp.get('cplds', []) + for i in range(len((cpldconfig))): + cpld1 = cpld(cpldconfig[i]) + cpldtemp.append(cpld1) + self.cpld_list = cpldtemp + + # compoment: cpld/fpga/bios + comptemp = [] + compconfig = __confTemp.get('comp_cpld', []) + for i in range(len((compconfig))): + comp1 = component(compconfig[i]) + comptemp.append(comp1) + self.comp_list = comptemp + + compconfig = __confTemp.get('comp_fpga', []) + for i in range(len((compconfig))): + comp1 = component(compconfig[i]) + self.comp_list.append(comp1) + + compconfig = __confTemp.get('comp_bios', []) + for i in range(len((compconfig))): + comp1 = component(compconfig[i]) + self.comp_list.append(comp1) + + # cpu + cpuconfig = __confTemp.get('cpu', []) + if len(cpuconfig): + self.cpu = cpu(cpuconfig[0]) + + # dcdc + @property + def dcdc_list(self): + return self.__dcdc_list + + @dcdc_list.setter + def dcdc_list(self, val): + self.__dcdc_list = val + + # sensor + @property + def sensor_list(self): + return self.__sensor_list + + @sensor_list.setter + def sensor_list(self, val): + self.__sensor_list = val + + def get_sensor_byname(self, name): + tmp = self.sensor_list + for i in range(len(tmp)): + if name == tmp[i].name: + return tmp[i] + return None + + # onie_e2 + @property + def onie_e2_list(self): + return self.__onie_e2_list + + @onie_e2_list.setter + def onie_e2_list(self, val): + self.__onie_e2_list = val + + def get_onie_e2_byname(self, name): + tmp = self.onie_e2_list + for i in range(len(tmp)): + if name == tmp[i].name: + return tmp[i] + return None + + # psu + @property + def psu_list(self): + return self.__psu_list + + @psu_list.setter + def psu_list(self, val): + self.__psu_list = val + + def get_psu_byname(self, name): + tmp = self.psu_list + for i in range(len(tmp)): + if name == tmp[i].name: + return tmp[i] + return None + + # fan + @property + def fan_list(self): + return self.__fan_list + + @fan_list.setter + def fan_list(self, val): + self.__fan_list = val + + def get_fan_byname(self, name): + tmp = self.fan_list + for i in range(len(tmp)): + if name == tmp[i].name: + return tmp[i] + return None + + # led + + @property + def led_list(self): + return self.__led_list + + @led_list.setter + def led_list(self, val): + self.__led_list = val + + def get_ledlist_config(self): + pass + + def get_led_byname(self, name): + tmp = self.led_list + for i in range(len(tmp)): + if name == tmp[i].name: + return tmp[i] + return None + + # temp + @property + def temp_list(self): + return self.__temp_list + + @temp_list.setter + def temp_list(self, val): + self.__temp_list = val + + def get_temp_byname(self, name): + tmp = self.temp_list + for i in range(len(tmp)): + if name == tmp[i].name: + return tmp[i] + return None + + # cpld + @property + def cpld_list(self): + return self.__cpld_list + + @cpld_list.setter + def cpld_list(self, val): + self.__cpld_list = val + + def get_cpld_byname(self, name): + tmp = self.cpld_list + for i in range(len(tmp)): + if name == tmp[i].name: + return tmp[i] + return None + + @property + def comp_list(self): + return self.__comp_list + + @comp_list.setter + def comp_list(self, val): + self.__comp_list = val + + def get_comp_byname(self, name): + tmp = self.comp_list + for i in range(len(tmp)): + if name == tmp[i].name: + return tmp[i] + return None + + # bios + @property + def bios_list(self): + return self.__bios_list + + @bios_list.setter + def bios_list(self, val): + self.__bios_list = val + + def get_bios_byname(self, name): + tmp = self.bios_list + for i in range(len(tmp)): + if name == tmp[i].name: + return tmp[i] + return None + + # bmc + @property + def bmc_list(self): + return self.__bmc_list + + @bmc_list.setter + def bmc_list(self, val): + self.__bmc_list = val + + def get_bmc_byname(self, name): + tmp = self.bmc_list + for i in range(len(tmp)): + if name == tmp[i].name: + return tmp[i] + return None + + # cpu + @property + def cpu(self): + return self.__cpu + + @cpu.setter + def cpu(self, val): + self.__cpu = val + + def get_cpu_byname(self, name): + return self.cpu diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/component.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/component.py new file mode 100755 index 000000000000..2a85e518d31e --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/component.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 +####################################################### +# +# component.py +# Python implementation of the Class fan +# Original author: rd@ruijie.com.cn +# +####################################################### +from plat_hal.devicebase import devicebase +from plat_hal.osutil import osutil + +class component(devicebase): + __user_reg = None + + def __init__(self, conf=None): + if conf is not None: + self.name = conf.get('name', None) + self.version_file = conf.get('VersionFile', None) + self.comp_id = conf.get("comp_id", None) + self.desc = conf.get("desc", None) + self.slot = conf.get("slot", None) + + def get_version(self): + version = "NA" + try: + ret, version = self.get_value(self.version_file) + if (ret == False): + return version + pattern = self.version_file.get('pattern', None) + version = osutil.std_match(version, pattern) + except Exception as e: + return version + return version diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/cpld.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/cpld.py new file mode 100755 index 000000000000..594a248b379b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/cpld.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python3 +####################################################### +# +# fan.py +# Python implementation of the Class fan +# Original author: rd@ruijie.com.cn +# +####################################################### +from plat_hal.devicebase import devicebase + + +class cpld(devicebase): + __user_reg = None + + def __init__(self, conf=None): + if conf is not None: + self.name = conf.get('name', None) + self.user_reg = conf.get('UserReg', None) + self.console_reg = conf.get('ConsoleReg', None) + self.console_reg_attrs = conf.get('ConsoleRegAttrs', None) + self.version_file = conf.get('VersionFile', None) + self.cpld_id = conf.get("cpld_id", None) + self.desc = conf.get("desc", None) + self.slot = conf.get("slot", None) + self.format = conf.get("format", "big_endian") + + def get_user_reg(self): + if (self.user_reg is None): + return False + ret, val = self.get_value(self.user_reg) + return val + + def set_user_reg(self, value): + if (self.user_reg is None): + return False + byte = value & 0xFF + ret, val = self.set_value(self.user_reg, byte) + return ret + + def set_console_owner(self, owner): + ret = False + + if (self.console_reg is None): + return False + tmpattr = self.console_reg_attrs.get(owner, None) + if tmpattr is not None: + ret, val = self.set_value(self.console_reg, tmpattr) + return ret + + def get_version(self): + ret, val = self.get_value(self.version_file) + if (ret == False): + val = "N/A" + return val + val = val.strip('\n').split(" ") + if len(val) < 4: + val = "N/A" + return val + if self.format == "little_endian": + cpld_version = "%s%s%s%s" % (val[3], val[2], val[1], val[0]) + else: + cpld_version = "%s%s%s%s" % (val[0], val[1], val[2], val[3]) + return cpld_version diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/cpu.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/cpu.py new file mode 100755 index 000000000000..d89394a579f5 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/cpu.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 +############################################################################### +# +# Hardware Abstraction Layer APIs -- CPU APIs. +# +# Copyright (C) Ruijie, INC. +# +############################################################################### +from plat_hal.devicebase import devicebase + + +class cpu(devicebase): + + def __init__(self, conf=None): + if conf is not None: + self.name = conf.get('name', None) + self.cpu_reset_cnt_reg = conf.get('CpuResetCntReg', None) + + def get_cpu_reset_num(self): + """ + get cpu reset num. + @return cpu reset number, -1 for failure + """ + ret = -1 + if self.cpu_reset_cnt_reg is None: + self.logger_debug("ERR: no support get cpu reset num") + return ret + ret, reset_num = self.get_value(self.cpu_reset_cnt_reg) + if ret is False or reset_num is None: + self.logger_debug("ERR: i2c read cpu_reset_cnt_reg,result:%s" % reset_num) + else: + if isinstance(reset_num, str): + ret = int(reset_num, 16) + else: + ret = reset_num + return ret diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/dcdc.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/dcdc.py new file mode 100755 index 000000000000..ba604995043d --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/dcdc.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python3 +from plat_hal.devicebase import devicebase +from plat_hal.sensor import sensor + + +class dcdc(devicebase): + def __init__(self, conf=None): + if conf is not None: + self.name = conf.get('name', None) + self.dcdc_id = conf.get("dcdc_id", None) + self.sensor = sensor(conf) diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/devicebase.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/devicebase.py new file mode 100755 index 000000000000..8574962f36ac --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/devicebase.py @@ -0,0 +1,223 @@ +#!/usr/bin/env python3 +####################################################### +# +# devicebase.py +# Python implementation of the Class devicebase +# Original author: rd@ruijie.com.cn +# +####################################################### +from plat_hal.osutil import osutil +from plat_hal.baseutil import baseutil +import subprocess + + +class devicebase(object): + _name = None + __error_ret = -99999 + + @property + def name(self): + return self._name + + @name.setter + def name(self, val): + self._name = val + + def dumpValueByI2c(self, bus, loc): + str = "" + for i in range(256): + ret, val = self.get_i2c(bus, loc, i) + str += chr(val) + return str + + def byteTostr(self, val): + strtmp = '' + for i in range(len(val)): + strtmp += chr(val[i]) + return strtmp + + def get_eeprom_info(self, conf): + if conf.get('way') == 'sysfs' or conf.get('way') == 'devfile': + ret, eeprom = self.get_value(conf) + if ret is False: + return None + else: + eeprom = self.dumpValueByI2c(conf.get('bus'), conf.get('addr')) + return eeprom + + def exec_os_cmd(self, cmd): + proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True, stderr=subprocess.STDOUT) + stdout = proc.communicate()[0] + proc.wait() + return proc.returncode, stdout + + def get_value(self, config): + ''' + get value by config way + way i2c/sysfs/lpc + ''' + way = config.get("way") + if way == 'sysfs': + return self.get_sysfs(config.get("loc"), config.get("flock_path")) + elif way == "i2c": + bus = config.get("bus") + addr = config.get("addr") + offset = config.get("offset") + return self.get_i2c(bus, addr, offset) + elif way == "io": + io_addr = config.get('io_addr') + read_len = config.get('read_len', 1) + return self.get_io(io_addr, read_len) + elif way == "i2cword": + bus = config.get("bus") + addr = config.get("addr") + offset = config.get("offset") + return self.get_i2cword(bus, addr, offset) + elif way == "devmem": + addr = config.get("addr") + digit = config.get("digit") + mask = config.get("mask", None) + return self.get_devmem(addr, digit, mask) + elif way == "sdk": + type = config.get("type") + if type == "bcm_temp": + return self.getbcmtemp() + elif type == "bcm_reg": + reg = config.get("reg") + return self.getbcmreg(reg) + else: + raise Exception("cannot found sdk type deal") + elif way == "devfile": + loc = config.get("loc") + offset = config.get("offset") + len = config.get("len") + return self.devfile_read(loc, offset, len) + elif way == "devfile_ascii": + loc = config.get("loc") + offset = config.get("offset") + len = config.get("len") + return self.devfile_read_ascii(loc, offset, len) + elif way == 'cmd': + cmd = config.get("cmd") + ret, log = self.exec_os_cmd(cmd) + if ret: + return False, ("cmd write exec %s failed, log: %s" % (cmd, log)) + else: + return True, log + else: + raise Exception("cannot found way deal") + + def devfile_read(self, loc, offset, len): + return osutil.readdevfile(loc, offset, len) + + def devfile_read_ascii(self, loc, offset, len): + return osutil.readdevfile_ascii(loc, offset, len) + + def get_sysfs(self, loc, flock_path=None): + return self.getsysfs(loc, flock_path) + + def getsysfs(self, loc, flock_path=None): + ret, val = osutil.readsysfs(loc, flock_path) + return ret, val + + def get_devmem(self, addr, digit, mask): + return osutil.getdevmem(addr, digit, mask) + + def get_i2cword(self, bus, addr, offset): + return self.geti2cword(bus, addr, offset) + + def geti2cword(self, bus, addr, offset): + ret, val = osutil.geti2cword(bus, addr, offset) + return ret, val + + def get_io(self, reg_addr, read_len): + return self.getio(reg_addr, read_len) + + def getio(self, reg_addr, read_len): + ret, val = osutil.io_rd(reg_addr, read_len) + return ret, val + + def get_i2c(self, bus, addr, offset): + return self.geti2c(bus, addr, offset) + + def geti2c(self, bus, addr, offset): + ret, val = osutil.rji2cget(bus, addr, offset) + return ret, val + + def set_value(self, config, val): + ''' + get value by config way + way i2c/sysfs/lpc + ''' + way = config.get("way") + if way == 'sysfs': + return self.set_sysfs(config.get("loc"), "0x%02x" % val) + elif way == "i2c": + bus = config.get("bus") + addr = config.get("addr") + offset = config.get("offset") + return self.set_i2c(bus, addr, offset, val) + elif way == "i2cpec": + bus = config.get("bus") + addr = config.get("addr") + offset = config.get("offset") + return self.seti2c_byte_pec(bus, addr, offset, val) + elif way == 'i2cword': + bus = config.get("bus") + addr = config.get("addr") + offset = config.get("offset") + return self.set_i2cword(bus, addr, offset, val) + elif way == "i2cwordpec": + bus = config.get("bus") + addr = config.get("addr") + offset = config.get("offset") + return self.set_i2cwordpec(bus, addr, offset, val) + return False, "unsupport ways: %s" % way + + def set_sysfs(self, loc, value): + return self.setsysfs(loc, value) + + def setsysfs(self, loc, value): + return osutil.writesysfs(loc, value) + + def set_i2cword(self, bus, addr, offset, byte): + return self.seti2cword(bus, addr, offset, byte) + + def seti2cword(self, bus, addr, offset, byte): + return osutil.seti2cword(bus, addr, offset, byte) + + def set_i2cwordpec(self, bus, addr, offset, val): + return osutil.seti2cwordpec(bus, addr, offset, val) + + def seti2c_byte_pec(self, bus, addr, offset, val): + return osutil.seti2c_byte_pec(bus, addr, offset, val) + + def set_i2c(self, bus, addr, offset, byte): + return self.seti2c(bus, addr, offset, byte) + + def seti2c(self, bus, addr, offset, byte): + ret, val = osutil.rji2cset(bus, addr, offset, byte) + return ret, val + + def getbcmtemp(self): + try: + sta, ret = osutil.getmactemp() + if sta == True: + mac_aver = float(ret.get("average", self.__error_ret)) + mac_aver = mac_aver * 1000 + else: + return False, ret + except AttributeError as e: + return False, str(e) + return True, mac_aver + + def getbcmreg(self, reg): + ret, val = osutil.getsdkreg(reg) + return ret, val + + def logger_debug(self, msg): + baseutil.logger_debug(msg) + + def command(self, cmd): + ret, output = osutil.command(cmd) + return ret, output diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/fan.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/fan.py new file mode 100755 index 000000000000..5799dfb9981c --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/fan.py @@ -0,0 +1,381 @@ +#!/usr/bin/env python3 +####################################################### +# +# fan.py +# Python implementation of the Class fan +# Original author: rd@ruijie.com.cn +# +####################################################### +from plat_hal.devicebase import devicebase +from eepromutil.fru import ipmifru +from plat_hal.rotor import rotor + + +class fan(devicebase): + __rotor_list = [] + __pn = None + __raweeprom = None + __sn = None + __hw_version = None + __present = None + __e2loc = None + __rotors = None + __AirFlow = None + __SpeedMin = None + __SpeedMax = None + __productName = None + __productSerialNumber = None + __WatchdogStatus = None + __led_attrs_config = None + __led_config = None + __WatchdogStatus_config = None + __AirFlowconifg = None + __EnableWatchdogConf = None + __Rotor_config = None + __fan_display_name = None # 'N/A' + __fan_display_name_conifg = None + + def __init__(self, conf=None): + if conf is not None: + self.name = conf.get('name', None) + self.sn = conf.get('sn', None) + self.present = conf.get('present', None) + self.e2loc = conf.get('e2loc', None) + self.SpeedMin = conf.get('SpeedMin', None) + self.SpeedMax = conf.get('SpeedMax', None) + self.AirFlowconifg = conf.get("airflow", None) + self.WatchdogStatus_config = conf.get('WatchdogStatus', None) + self.EnableWatchdogConf = conf.get('EnableWatchdogConf', None) + self.led_attrs_config = conf.get('led_attrs', None) + self.led_config = conf.get('led', None) + self.Rotor_config = conf.get('Rotor', None) + self.fan_display_name_conifg = conf.get("fan_display_name", None) + rotor_tmp = [] + for key, value in (self.Rotor_config).items(): + rotor_tmp.append(rotor(value)) + rotor_tmp.sort(key=lambda x: x.name, reverse=False) + self.rotor_list = rotor_tmp + self.rotors = len(self.rotor_list) + + @property + def EnableWatchdogConf(self): + return self.__EnableWatchdogConf + + @EnableWatchdogConf.setter + def EnableWatchdogConf(self, val): + self.__EnableWatchdogConf = val + + @property + def rotor_list(self): + return self.__rotor_list + + @rotor_list.setter + def rotor_list(self, val): + self.__rotor_list = val + + @property + def Rotor_config(self): + return self.__Rotor_config + + @Rotor_config.setter + def Rotor_config(self, val): + self.__Rotor_config = val + + @property + def productName(self): + return self.__productName + + @productName.setter + def productName(self, val): + self.__productName = val + + @property + def productSerialNumber(self): + return self.__productSerialNumber + + @productSerialNumber.setter + def productSerialNumber(self, val): + self.__productSerialNumber = val + + @property + def hw_version(self): + return self.__hw_version + + @hw_version.setter + def hw_version(self, val): + self.__hw_version = val + + @property + def sn(self): + return self.__sn + + @sn.setter + def sn(self, val): + self.__sn = val + + @property + def pn(self): + return self.__pn + + @pn.setter + def pn(self, val): + self.__pn = val + + @property + def raweeprom(self): + return self.__raweeprom + + @raweeprom.setter + def raweeprom(self, val): + self.__raweeprom = val + + @property + def SpeedMax(self): + return self.__SpeedMax + + @SpeedMax.setter + def SpeedMax(self, val): + self.__SpeedMax = val + + @property + def SpeedMin(self): + return self.__SpeedMin + + @SpeedMin.setter + def SpeedMin(self, val): + self.__SpeedMin = val + + @property + def rotors(self): + return self.__rotors + + @property + def AirFlow(self): + return self.__AirFlow + + @AirFlow.setter + def AirFlow(self, val): + self.__AirFlow = val + + @rotors.setter + def rotors(self, val): + self.__rotors = val + + @property + def fan_display_name_conifg(self): + return self.__fan_display_name_conifg + + @fan_display_name_conifg.setter + def fan_display_name_conifg(self, val): + self.__fan_display_name_conifg = val + + @property + def fan_display_name(self): + return self.__fan_display_name + + @fan_display_name.setter + def fan_display_name(self, val): + self.__fan_display_name = val + + def getspeed(self, conf): + tmp = None + if conf is None: + return -1 + ret, val = self.get_value(conf) + if ret == True: + tmp = int(str(val), 10) + else: + val = None + if val is not None: + return int(15000000 / tmp) + return -1 + + def get_speed(self, rotor_index): + rotor = self.get_rotor_index(rotor_index) + if rotor is None: + return None + speed = rotor.rotor_Speed.Value + if speed is None: + return None + return int(speed) + + def set_led(self, color): + status = self.led_attrs_config.get(color, None) + if status is None: + return False + + mask = self.led_attrs_config.get('mask', 0xff) + ret, value = self.get_value(self.led_config) + if ret is False or value is None: + return False + setval = (int(value) & ~mask) | (status) + ret, val = self.set_value(self.led_config, setval) + return ret + + def get_led(self): + mask = self.led_attrs_config.get('mask', 0xff) + ret, value = self.get_value(self.led_config) + if ret is False or value is None: + return False, 'N/A' + ledval = (int(value) & mask) + for key, val in self.led_attrs_config.items(): + if (ledval == val) and (key != "mask"): + return True, key + return False, 'N/A' + + def set_speed(self, rotor_index, level): + if level > 255 or level < 0: + return False + rotor = self.get_rotor_index(rotor_index) + if rotor is None: + return False + ret, val = self.set_value(rotor.Speedconfig, int(level)) + return ret + + def get_rotor_index(self, rotor_index): + if rotor_index > len(self.rotor_list): + return None + rotor = self.rotor_list[rotor_index - 1] + return rotor + + def get_rotor_byname(self, rotor_index): + for rotor in self.rotor_list: + if rotor.name == rotor_index: + return rotor + return None + + def get_presence(self): + ret, val = self.get_value(self.present) + if ret is False or val is None: + return -1 + if isinstance(val, str): + value = int(val, 16) + else: + value = val + mask = self.present.get("mask") + flag = value & mask + okval = self.present.get("okval", 0) + if flag == okval: + return True + else: + return False + + def get_speed_pwm(self, rotor_index): + rotor = self.get_rotor_index(rotor_index) + if rotor is None: + return False + if rotor.i2c_speed is None: + return False + val = round(rotor.i2c_speed * 100 / 255) + return val + + def feed_watchdog(self, pwm): + ret = False + for rotor in self.rotor_list: + ret, val = rotor.feed_watchdog() + if ret is False: + return ret + return ret + + def get_fru_info(self): + try: + if self.get_presence() is False: + raise Exception("%s: not present" % self.name) + eeprom = self.get_eeprom_info(self.e2loc) + if eeprom is None: + raise Exception("%s: value is none" % self.name) + fru = ipmifru() + if isinstance(eeprom, bytes): + eeprom = self.byteTostr(eeprom) + fru.decodeBin(eeprom) + self.productName = fru.productInfoArea.productName.strip() # PN + self.productSerialNumber = fru.productInfoArea.productSerialNumber.strip() # SN + self.hw_version = fru.productInfoArea.productVersion.strip() # HW + except Exception as e: + self.productName = None + self.productSerialNumber = None + self.hw_version = None + return False + return True + + def decode_eeprom_info(self): + '''get fan name, hw version, sn''' + return self.get_fru_info() + + def get_AirFlow(self): + if self.productName is None: + ret = self.decode_eeprom_info() + if ret is False: + self.AirFlow = None + return False + if self.AirFlowconifg is None: + self.AirFlow = None + return False + else: + for i in self.AirFlowconifg: + if self.productName in self.AirFlowconifg[i]: + self.AirFlow = i + return True + self.AirFlow = None + return False + + def enable_watchdog(self, enable, timeout_sec): + ret = False + if enable == True: + byte = self.EnableWatchdogConf.get("enable_byte", None) + ret, val = self.set_value(self.EnableWatchdogConf, byte) + elif enable == False: + byte = self.EnableWatchdogConf.get("disable_byte", None) + ret, val = self.set_value(self.EnableWatchdogConf, byte) + return ret + + def get_watchdog_status(self): + dic = {"support": None, "open": None, "work_full": None, "work_allow_set": None} + if self.WatchdogStatus_config is None: + return None + ret, val = self.get_value(self.WatchdogStatus_config) + if ret is False or val is None: + return None + support_watchdog_off = self.WatchdogStatus_config.get("support_watchdog_off", None) + is_open_off = self.WatchdogStatus_config.get("is_open_off", None) + full_running_off = self.WatchdogStatus_config.get("full_running_off", None) + running_setting_off = self.WatchdogStatus_config.get("running_setting_off", None) + if support_watchdog_off is not None: + if support_watchdog_off & val == self.WatchdogStatus_config.get("support_watchdog_mask", None): + dic["support"] = True + else: + dic["support"] = False + return dic + if is_open_off is not None: + if is_open_off & val == self.WatchdogStatus_config.get("is_open_mask", None): + dic["open"] = True + else: + dic["open"] = False + if full_running_off is not None: + if full_running_off & val == self.WatchdogStatus_config.get("full_running_mask", None): + dic["work_full"] = True + else: + dic["work_full"] = False + if running_setting_off is not None: + if running_setting_off & val == self.WatchdogStatus_config.get("running_setting_mask", None): + dic["work_allow_set"] = True + else: + dic["work_allow_set"] = False + return dic + + def get_fan_display_name(self): + if self.productName is None: + ret = self.get_fru_info() + if ret is False: + self.fan_display_name = None + return False + if self.fan_display_name_conifg is None: + self.fan_display_name = self.productName + return False + else: + for i in self.fan_display_name_conifg: + if self.productName in self.fan_display_name_conifg[i]: + self.fan_display_name = i + return True + self.fan_display_name = self.productName + return False diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/interface.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/interface.py new file mode 100755 index 000000000000..43ffa7d4f29c --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/interface.py @@ -0,0 +1,1331 @@ +#!/usr/bin/env python3 +####################################################### +# +# interface.py +# Python implementation of the Class interface +# Original author: rd@ruijie.com.cn +# +####################################################### +from plat_hal.chassisbase import chassisbase +import collections +from plat_hal.baseutil import baseutil +from plat_hal.osutil import osutil + + +def Singleton(cls): + _instance = {} + + def _singleton(*args, **kargs): + if cls not in _instance: + _instance[cls] = cls(*args, **kargs) + return _instance[cls] + + return _singleton + + +@Singleton +class interface(object): + __chas = None + __error_ret = None + + def __init__(self): + self.chas = chassisbase() + self.__error_ret = -99999 + self.__na_ret = 'N/A' + + @property + def na_ret(self): + return self.__na_ret + + @na_ret.setter + def na_ret(self, val): + self.__na_ret = val + + @property + def error_ret(self): + return self.__error_ret + + @error_ret.setter + def error_ret(self, val): + self.__error_ret = val + + @property + def chas(self): + return self.__chas + + @chas.setter + def chas(self, val): + self.__chas = val + + # onie_e2 + def get_onie_e2(self): + onie_e2_list = self.chas.onie_e2_list + return onie_e2_list + + def get_onie_e2_path(self, name): + onie_e2 = self.chas.get_onie_e2_byname(name) + if onie_e2 is None: + return None + return onie_e2.e2_path + + def get_onie_e2_obj(self, name): + onie_e2 = self.chas.get_onie_e2_byname(name) + if onie_e2 is None: + return None + onie_e2.get_onie_e2_info() + return onie_e2 + + # temp + def get_temps(self): + templist = self.chas.temp_list + return templist + + def get_temp_total_number(self): + templist = self.chas.temp_list + return len(templist) + + def check_temp_id_exist(self, temp_id): + templist = self.chas.temp_list + for temp in templist: + if temp.temp_id == temp_id: + return True + return False + + def get_temp_id_number(self): + templist = self.chas.temp_list + temp_num = 0 + for i in range(len(templist)): + temp_id = "TEMP" + str(i + 1) + ret = self.check_temp_id_exist(temp_id) + if ret == True: + temp_num = temp_num + 1 + else: + return temp_num + return temp_num + + def get_temp_location(self, temp_name): + temp = self.chas.get_temp_byname(temp_name) + return temp.get_location() + + def set_temp_location(self, temp_name, location): + temp = self.chas.get_temp_byname(temp_name) + return temp.set_location(location) + + def set_temp_name(self, temp_name, name): + temp = self.chas.get_temp_byname(temp_name) + return temp.set_name(name) + + def get_appoint_temp(self, temp_name): + temp = self.chas.get_led_byname(temp_name) + return temp.get_temp() + + def set_appoint_temp(self, temp_name, val): + temp = self.chas.get_temp_byname(temp_name) + return temp.set_temp(val) + + def get_temp_mintemp(self, temp_name): + temp = self.chas.get_temp_byname(temp_name) + return temp.get_mintemp() + + def set_temp_mintemp(self, temp_name, val): + temp = self.chas.get_temp_byname(temp_name) + return temp.set_mintemp(val) + + # led + def get_leds(self): + ledlist = self.chas.led_list + return ledlist + + def get_led_total_number(self): + ledlist = self.chas.led_list + return len(ledlist) + + def get_led_color(self, led_name): + led = self.chas.get_led_byname(led_name) + if led is None: + return -1 + return led.get_color() + + def get_led_color_by_type(self, led_type): + ledlist = self.chas.led_list + ledtmp = None + for temp in ledlist: + if temp.led_type == led_type: + ledtmp = temp + break + if ledtmp is None: + return -1 + return ledtmp.get_color() + + def set_led_color(self, led_name, color): + led = self.chas.get_led_byname(led_name) + if led is None: + return -1 + return led.set_color(color) + + # psu + def get_psu_total_number(self): + psulist = self.chas.psu_list + if psulist is None: + return -1 + return len(psulist) + + def get_psus(self): + psulist = self.chas.psu_list + return psulist + + def get_psu_presence(self, psu_name): + psu = self.chas.get_psu_byname(psu_name) + if psu is None: + return -1 + return psu.present + + def get_psu_fru_info(self, psu_name): + ''' + { + "Name": "PSU1", + "SN": "serial_number_example", # 'N/A' + "PN": "part_number_example", # 'N/A' + "AirFlow": "B2F" # 'N/A' + } + ''' + psu = self.chas.get_psu_byname(psu_name) + if psu is None: + return -1 + psu.get_fru_info() + psu.get_AirFlow() + psu.get_psu_display_name() + + dic = collections.OrderedDict() + dic["Name"] = psu.name + dic["SN"] = psu.productSerialNumber if (psu.productSerialNumber is not None) else self.na_ret + dic["PN"] = psu.productPartModelName if (psu.productPartModelName is not None) else self.na_ret + dic["DisplayName"] = psu.psu_display_name if (psu.psu_display_name is not None) else self.na_ret + dic["VENDOR"] = psu.productManufacturer if (psu.productManufacturer is not None) else self.na_ret + dic["HW"] = psu.productVersion if (psu.productVersion is not None) else self.na_ret + dic["AirFlow"] = psu.AirFlow if (psu.AirFlow is not None) else self.na_ret + return dic + + def get_psu_input_output_status(self, psu_name): + psu = self.chas.get_psu_byname(psu_name) + if psu is None: + return -1 + psu.InputsCurrent.Value # just for clear faults + if (psu.InputStatus == True) and (psu.OutputStatus == True): + status = True + else: + status = False + return status + + def get_psu_status(self, psu_name): + """ + Get status of a specific PSU + @return dict of the specific PSU's status, None for failure + Example return value(all keys are mandatory) + { + "Name": "PSU1", + "InputType": "DC", # "AC" or 'N/A' + "InputStatus": True, # H/W status bit + "OutputStatus": True # H/W status bit + "FanSpeed": { + "Value": 4000, # -99999 + "Min": 2000, # -99999 + "Max": 10000 # -99999 + }, + "Temperature": { + "Value": 40.0, # -99999.0 + "Min": -30.0, # -99999.0 + "Max": 50.0 # -99999.0 + } + } + """ + psu = self.chas.get_psu_byname(psu_name) + if psu is None: + return -1 + + dic = collections.OrderedDict() + # psu.get_Temperature() + temp_dict = collections.OrderedDict() + temp_dict['Min'] = psu.Temperature.Min + temp_dict['Max'] = psu.Temperature.Max + temp_dict['Value'] = psu.Temperature.Value + temp_dict['Unit'] = psu.Temperature.Unit + dic["Temperature"] = temp_dict + + # psu.get_FanSpeed() + fan_speed_dict = collections.OrderedDict() + fan_speed_dict['Min'] = psu.FanSpeed.Min + fan_speed_dict['Max'] = psu.FanSpeed.Max + fan_speed_dict['Tolerance'] = psu.FanSpeedTolerance + fan_speed_dict['Value'] = psu.FanSpeed.Value + fan_speed_dict['Unit'] = psu.FanSpeed.Unit + dic["FanSpeed"] = fan_speed_dict + + dic["Name"] = psu.name + dic["InputType"] = psu.InputsType + dic["InputStatus"] = psu.InputStatus + dic["OutputStatus"] = psu.OutputStatus + dic["TempStatus"] = psu.TempStatus + dic["FanStatus"] = psu.FanStatus + return dic + + def get_psu_power_status(self, psu_name): + """ + Get power status of a specific PSU + @return dict of the specific PSU's power status, None for failure + Example return value + { + "Name": "PSU1", + "Inputs": { + "Status": True, # H/W status bit + "Type": "DC", # or "AC" or "N/A" + "Voltage": { + "Value": 220, # -1 + "LowAlarm": 200, # -1 + "HighAlarm": 240, # -1 + "Unit": "V" + }, + "Current": { + "Value": 6.0, # -99999.0 + "LowAlarm": 0.2, # -99999.0 + "HighAlarm": 7.0, # -99999.0 + "Unit": "A" + }, + "Power": { + "Value": 1000, # -99999 + "LowAlarm": -1, # -99999 + "HighAlarm": 1400, # -99999 + "Unit": "W" + } + }, + "Outputs": { + "Status": True, + "Voltage": { + "Value": 220, + "LowAlarm": 200, + "HighAlarm": 240, + "Unit": "V" + }, + "Current": { + "Value": 6.0, + "LowAlarm": 0.2, + "HighAlarm": 7.0, + "Unit": "A" + }, + "Power": { + "Value": 1000, + "LowAlarm": -1, # Don't care + "HighAlarm": 1400, + "Unit": "W" + } + } + } + """ + psu = self.chas.get_psu_byname(psu_name) + if psu is None: + return -1 + + dic = collections.OrderedDict() + inputdic = collections.OrderedDict() + Outputsdic = collections.OrderedDict() + dic["Name"] = psu.name + inputdic["Status"] = psu.InputStatus + inputdic["Type"] = psu.InputsType + + # psu.get_InputsVoltage() + inputdic_voltage = collections.OrderedDict() + + inputdic_voltage["Value"] = psu.InputsVoltage.Value + inputdic_voltage["LowAlarm"] = psu.InputsVoltage.Min + inputdic_voltage["HighAlarm"] = psu.InputsVoltage.Max + inputdic_voltage["Unit"] = psu.InputsVoltage.Unit + + inputdic["Voltage"] = inputdic_voltage + inputdic_current = collections.OrderedDict() + inputdic_current["Value"] = psu.InputsCurrent.Value + inputdic_current["LowAlarm"] = psu.InputsCurrent.Min + inputdic_current["HighAlarm"] = psu.InputsCurrent.Max + inputdic_current["Unit"] = psu.InputsCurrent.Unit + inputdic["Current"] = inputdic_current + + inputdic_power = collections.OrderedDict() + inputdic_power["Value"] = psu.InputsPower.Value + inputdic_power["LowAlarm"] = psu.InputsPower.Min + inputdic_power["HighAlarm"] = psu.InputsPower.Max + inputdic_power["Unit"] = psu.InputsPower.Unit + inputdic["Power"] = inputdic_power + Outputsdic["Status"] = psu.InputStatus + + outputdic_voltage = collections.OrderedDict() + outputdic_current = collections.OrderedDict() + outputdic_power = collections.OrderedDict() + + outputdic_voltage["Value"] = psu.OutputsVoltage.Value + outputdic_voltage["LowAlarm"] = psu.OutputsVoltage.Min + outputdic_voltage["HighAlarm"] = psu.OutputsVoltage.Max + outputdic_voltage["Unit"] = psu.OutputsVoltage.Unit + + outputdic_current["Value"] = psu.OutputsCurrent.Value + outputdic_current["LowAlarm"] = psu.OutputsCurrent.Min + outputdic_current["HighAlarm"] = psu.OutputsCurrent.Max + outputdic_current["Unit"] = psu.OutputsCurrent.Unit + + outputdic_power["Value"] = psu.OutputsPower.Value + outputdic_power["LowAlarm"] = psu.OutputsPower.Min + outputdic_power["HighAlarm"] = psu.OutputsPower.Max + outputdic_power["Unit"] = psu.OutputsPower.Unit + + Outputsdic["Voltage"] = outputdic_voltage + Outputsdic["Current"] = outputdic_current + Outputsdic["Power"] = outputdic_power + + dic["Inputs"] = inputdic + dic["Outputs"] = Outputsdic + + return dic + + def set_psu_fan_speed_pwm(self, psu_name, pwm): + psu = self.chas.get_psu_byname(psu_name) + if psu is None: + return -1 + return psu.set_fan_speed_pwm(pwm) + + def get_psu_fan_speed_pwm(self, psu_name): + psu = self.chas.get_psu_byname(psu_name) + if psu is None: + return -1 + return psu.get_fan_speed_pwm() + + def get_psu_info_all(self): + """ + { + "Number": 2, + "PSU1": { + "SN": "serial_number_example", # 'N/A' + "PN": "part_number_example", # 'N/A' + "AirFlow": "F2B", # 'N/A' + + "FanSpeed": { + "Value": 4000, + "Min": 2000, + "Max": 30000 + }, + "Temperature": { + "Value": 35.0, + "Min": -20.0, + "Max": 45.0 + }, + "Inputs": { + "Status": True, # H/W status bit + "Type": "DC", # or "AC" + "Voltage": { + "Value": 220, + "LowAlarm": 200, + "HighAlarm": 240, + "Unit": "V" + }, + "Current": { + "Value": 6.0, + "LowAlarm": 0.2, + "HighAlarm": 7.0, + "Unit": "A" + }, + "Power": { + "Value": 1000, + "LowAlarm": -1, + "HighAlarm": 1400, + "Unit": "W" + } + }, + "Outputs": { + "Status": True, + "Voltage": { + "Value": 220, + "LowAlarm": 200, + "HighAlarm": 240, + "Unit": "V" + }, + "Current": { + "Value": 6.0, + "LowAlarm": 0.2, + "HighAlarm": 7.0, + "Unit": "A" + }, + "Power": { + "Value": 1000, + "LowAlarm": -1, # Don't care + "HighAlarm": 1400, + "Unit": "W" + } + } + } + } + """ + + psus = self.get_psus() + dict = collections.OrderedDict() + dict['Number'] = len(psus) + for psu in psus: + dicttmp = self.get_psu_fru_info(psu.name) + dicttmp.update(self.get_psu_status(psu.name)) + dicttmp.update(self.get_psu_power_status(psu.name)) + if self.get_psu_presence(psu.name) is True: + dicttmp['Present'] = 'yes' + else: + dicttmp['Present'] = 'no' + dict[psu.name] = dicttmp + return dict + + def get_fans(self): + fanlist = self.chas.fan_list + return fanlist + + # fan + def get_fan_total_number(self): + fanlist = self.chas.fan_list + if fanlist is None: + return -1 + return len(fanlist) + + def get_fan_rotor_number(self, fan_name): + fan = self.chas.get_fan_byname(fan_name) + if fan is None: + return -1 + ret = fan.rotors + if ret is None: + return -1 + return ret + + def get_fan_speed(self, fan_name, rotor_index): + fan = self.chas.get_fan_byname(fan_name) + if fan is None: + return -1 + ret = fan.get_speed(rotor_index) + if ret is None: + return -1 + return ret + + def set_fan_speed(self, fan_name, rotor_index, speed): + return -1 + + def fan_speed_set_level(self, fan_name, rotor_index, level): + fan = self.chas.get_fan_byname(fan_name) + if fan is None: + return -1 + ret = fan.set_speed(rotor_index, level) + if ret is True: + return 0 + else: + return -1 + + def get_fan_speed_pwm(self, fan_name, rotor_index): + fan = self.chas.get_fan_byname(fan_name) + if fan is None: + return -1 + val = fan.get_speed_pwm(rotor_index) + if val is False: + return -1 + return val + + def set_fan_speed_pwm(self, fan_name, rotor_index, pwm): + fan = self.chas.get_fan_byname(fan_name) + if fan is None: + return -1 + if isinstance(pwm, str): + rate = float(pwm.strip('%s')) + speed = round(rate * 255 / 100) + elif isinstance(pwm, int): + speed = round(pwm * 255 / 100) + elif isinstance(pwm, float): + speed = round(pwm * 255 / 100) + else: + return -1 + ret = self.fan_speed_set_level(fan.name, rotor_index, speed) + if ret == 0: + return 0 + return -1 + + def get_fan_watchdog_status(self): + fan = self.chas.fan_list[0] + dic = fan.get_watchdog_status() + if dic is None or dic["support"] == False: + return self.na_ret + elif dic["open"] is False or dic["work_allow_set"] is True: + return "Normal" + elif dic["work_full"] is True: + return "Abnormal" + else: + return "Abnormal" + + def enable_fan_watchdog(self, enable=True, timeout_sec=10): + fan = self.chas.fan_list[0] + ret = fan.enable_watchdog(enable, timeout_sec) + if ret is True: + return 0 + else: + return -1 + + def feed_fan_watchdog(self, pwm): + fan_list = self.chas.fan_list + if fan_list is None: + return -1 + for fan in fan_list: + ret = fan.feed_watchdog(pwm) + if ret is False: + return -1 + return 0 + + def set_fan_led(self, fan_name, color): + fan = self.chas.get_fan_byname(fan_name) + if fan is None: + return -1 + ret = fan.set_led(color) + if ret is True: + return 0 + return -1 + + def get_fan_led(self, fan_name): + fan = self.chas.get_fan_byname(fan_name) + if fan is None: + return False, 'N/A' + return fan.get_led() + + def get_fan_presence(self, fan_name): + fan = self.chas.get_fan_byname(fan_name) + if fan is None: + return -1 + return fan.get_presence() + + def get_fan_fru_info(self, fan_name): + """ + Get specific fan's information + # Properties + "Name": "FAN1", + "SN": "serial_number_example", # 'N/A' + "PN": "part_number_exampple", # 'N/A' + "Rotors": 2, # -1 + "AirFlow": "F2B", # 'N/A' + "SpeedMin": 2000, # -1 + "SpeedMax": 30000 # -1 + """ + fan = self.chas.get_fan_byname(fan_name) + fan.get_fru_info() + fan.get_AirFlow() + fan.get_fan_display_name() + + dic = collections.OrderedDict() + dic["Name"] = fan.name + dic["SN"] = fan.productSerialNumber + if dic["SN"] is None: + dic["SN"] = self.na_ret + dic["PN"] = fan.productName + if dic["PN"] is None: + dic["PN"] = self.na_ret + dic["DisplayName"] = fan.fan_display_name + if dic["DisplayName"] is None: + dic["DisplayName"] = self.na_ret + + dic["Rotors"] = fan.rotors + dic["AirFlow"] = fan.AirFlow + if dic["AirFlow"] is None: + dic["AirFlow"] = self.na_ret + dic["SpeedMin"] = fan.SpeedMin + dic["SpeedMax"] = fan.SpeedMax + return dic + + def get_fan_eeprom_info(self, fan_name): + """ + Get specific fan's information + # Properties + "Name": "M6510-FAN-F", # 'N/A' + "SN": "serial_number_example", # 'N/A' + "HW": "hw_version_exampple", # 'N/A' + """ + fan = self.chas.get_fan_byname(fan_name) + fan.decode_eeprom_info() + dic = collections.OrderedDict() + dic["NAME"] = fan.productName + if dic["NAME"] is None: + dic["NAME"] = self.na_ret + dic["SN"] = fan.productSerialNumber + if dic["SN"] is None: + dic["SN"] = self.na_ret + dic["HW"] = fan.hw_version + if dic["HW"] is None: + dic["HW"] = self.na_ret + + return dic + + def get_product_fullname(self): + return baseutil.get_product_fullname() + + def get_fan_status(self, fan_name): + fan = self.chas.get_fan_byname(fan_name) + if fan is None: + return -1 + rotorlist = fan.rotor_list + dir = collections.OrderedDict() + for rotor in rotorlist: + dir_val = collections.OrderedDict() + if rotor.rotor_Running == True: + dir_val['Running'] = 'yes' + else: + dir_val['Running'] = 'no' + if rotor.rotor_HwAlarm == True: + dir_val['HwAlarm'] = 'yes' + else: + dir_val['HwAlarm'] = 'no' + dir_val['Speed'] = int(rotor.rotor_Speed.Value) + dir[rotor.name] = dir_val + return dir + + def get_fan_rotor_status(self, fan_name, rotor_name): + fan = self.chas.get_fan_byname(fan_name) + if fan is None: + return -1 + rotorlist = fan.rotor_list + for i in range(len(rotorlist)): + if rotor_name == rotorlist[i].name: + rotor = rotorlist[i] + if rotor.rotor_Running == True: + return True + else: + return False + return -1 + + def get_fan_roll_status(self, fan_name, rotor_index): + fan = self.chas.get_fan_byname(fan_name) + if fan is None: + return -1 + rotor = fan.get_rotor_index(rotor_index) + if rotor is None: + return -1 + if rotor.rotor_Running == True: + return True + return False + + def get_fan_info_fru(self, fan_name): + fan = self.chas.get_fan_byname(fan_name) + fan.get_fru_info() + fan.get_AirFlow() + dic = collections.OrderedDict() + dic["Name"] = fan.name + dic["SN"] = fan.productSerialNumber + if dic["SN"] is None: + dic["SN"] = self.na_ret + dic["PN"] = fan.productPartModelName + if dic["PN"] is None: + dic["PN"] = self.na_ret + flag = self.get_fan_presence(fan_name) + if flag is True: + dic["Present"] = "yes" + elif flag is False: + dic["Present"] = "no" + else: + dic["Present"] = self.na_ret + dic["Rotors"] = fan.rotors + dic["AirFlow"] = fan.AirFlow + if dic["AirFlow"] is None: + dic["AirFlow"] = self.na_ret + return dic + + # support TLV and FRU FAN E2 + def get_fan_info(self, fan_name): + fan = self.chas.get_fan_byname(fan_name) + if fan is None: + return None + fan.get_AirFlow() + dic = self.get_fan_eeprom_info(fan_name) + flag = self.get_fan_presence(fan_name) + if flag is True: + dic["Present"] = "yes" + elif flag is False: + dic["Present"] = "no" + else: + dic["Present"] = self.na_ret + dic["Rotors"] = fan.rotors + dic["AirFlow"] = fan.AirFlow + if dic["AirFlow"] is None: + dic["AirFlow"] = self.na_ret + return dic + + def get_fan_info_rotor(self, fan_name): + fan = self.chas.get_fan_byname(fan_name) + if fan is None: + return -1 + rotorlist = fan.rotor_list + dir = collections.OrderedDict() + for rotor in rotorlist: + dir_val = collections.OrderedDict() + if rotor.rotor_Running == True: + dir_val['Running'] = 'yes' + else: + dir_val['Running'] = 'no' + if rotor.rotor_HwAlarm == True: + dir_val['HwAlarm'] = 'yes' + else: + dir_val['HwAlarm'] = 'no' + speed_value = rotor.rotor_Speed.Value + if speed_value is None: + dir_val['Speed'] = self.error_ret + else: + dir_val['Speed'] = int(speed_value) + if rotor.SpeedMin is None: + dir_val['SpeedMin'] = self.error_ret + else: + dir_val['SpeedMin'] = rotor.SpeedMin + if rotor.SpeedMax is None: + dir_val['SpeedMax'] = self.error_ret + else: + dir_val['SpeedMax'] = rotor.SpeedMax + if rotor.Tolerance is None: + dir_val['Tolerance'] = self.error_ret + else: + dir_val['Tolerance'] = rotor.Tolerance + + dir[rotor.name] = dir_val + return dir + + def get_fan_info_all(self): + fanlist = self.chas.fan_list + dic = collections.OrderedDict() + dic['Number'] = len(fanlist) + dic['WatchdogStatus'] = self.get_fan_watchdog_status() + for fan in fanlist: + dic[fan.name] = self.get_fan_info(fan.name) + dic[fan.name].update(self.get_fan_info_rotor(fan.name)) + return dic + + def temp_test(self): + templist = self.chas.temp_list + dicret = collections.OrderedDict() + + for temp in templist: + dic = collections.OrderedDict() + temp_value = temp.Value + dic["Value"] = temp_value if (temp_value is not None) else self.error_ret + dic["LowAlarm"] = temp.Min + dic["HighAlarm"] = temp.Max + dicret[temp.name] = dic + return dicret + + # dcdc + def get_dcdc_total_number(self): + dcdclist = self.chas.dcdc_list + if dcdclist is None: + return -1 + return len(dcdclist) + + def get_dcdc_by_id(self, dcdc_id): + dcdclist = self.chas.dcdc_list + dcdctmp = None + for dcdc in dcdclist: + if dcdc.dcdc_id == dcdc_id: + dcdctmp = dcdc + dic = collections.OrderedDict() + if dcdctmp is None: + dic["Name"] = self.error_ret + dic["Min"] = self.error_ret + dic["Max"] = self.error_ret + dic["Low"] = self.error_ret + dic["High"] = self.error_ret + dic["Value"] = self.error_ret + dic["Unit"] = self.error_ret + else: + dic["Name"] = dcdctmp.name + dic["Min"] = dcdctmp.sensor.Min + dic["Max"] = dcdctmp.sensor.Max + dic["Low"] = dcdctmp.sensor.Low + dic["High"] = dcdctmp.sensor.High + tmp = dcdctmp.sensor.Value + if tmp is not None: + dic['Value'] = tmp + else: + dic['Value'] = self.error_ret + dic["Unit"] = dcdctmp.sensor.Unit + return dic + + def get_dcdc_all_info(self): + val_list = collections.OrderedDict() + dcdclist = self.chas.dcdc_list + for dcdc in dcdclist: + dicttmp = {} + sensorname = "%s" % (dcdc.name) + dicttmp['Min'] = dcdc.sensor.Min + dicttmp['Max'] = dcdc.sensor.Max + tmp = dcdc.sensor.Value + if tmp is not None: + dicttmp['Value'] = tmp + else: + dicttmp['Value'] = self.error_ret + dicttmp['Unit'] = dcdc.sensor.Unit + val_list[sensorname] = dicttmp + return val_list + + # sensors + def get_monitor_temp(self, name): + templist = self.chas.temp_list + temptmp = None + for temp in templist: + if temp.name == name: + temptmp = temp + + dic = collections.OrderedDict() + if temptmp is None: + dic["Min"] = self.error_ret + dic["Max"] = self.error_ret + dic["Value"] = self.error_ret + dic["Unit"] = self.error_ret + else: + dic["Min"] = temptmp.Min + dic["Max"] = temptmp.Max + temp_value = temptmp.Value + dic["Value"] = temp_value if (temp_value is not None) else self.error_ret + dic["Unit"] = temptmp.Unit + return dic + + def get_monitor_temp_by_id(self, temp_id): + templist = self.chas.temp_list + temptmp = None + for temp in templist: + if temp.temp_id == temp_id: + temptmp = temp + + dic = collections.OrderedDict() + if temptmp is None: + dic["Name"] = self.error_ret + dic["Api_name"] = self.error_ret + dic["Min"] = self.error_ret + dic["Max"] = self.error_ret + dic["Low"] = self.error_ret + dic["High"] = self.error_ret + dic["Value"] = self.error_ret + dic["Unit"] = self.error_ret + else: + dic["Name"] = temptmp.name + dic["Api_name"] = temptmp.api_name + dic["Min"] = temptmp.Min + dic["Max"] = temptmp.Max + dic["Low"] = temptmp.Low + dic["High"] = temptmp.High + temp_value = temptmp.Value + dic["Value"] = temp_value if (temp_value is not None) else self.error_ret + dic["Unit"] = temptmp.Unit + return dic + + def get_temp_info(self): + val_list = collections.OrderedDict() + # temp + templist = self.chas.temp_list + for temp in templist: + dic = collections.OrderedDict() + dic["Min"] = temp.Min + dic["Max"] = temp.Max + dic["Low"] = temp.Low + dic["High"] = temp.High + temp_value = temp.Value + dic["Value"] = temp_value if (temp_value is not None) else self.error_ret + dic["Unit"] = temp.Unit + val_list[temp.name] = dic + return val_list + + def get_sensor_info(self): + val_list = collections.OrderedDict() + # temp + templist = self.chas.temp_list + for temp in templist: + dic = collections.OrderedDict() + dic["Min"] = temp.Min + dic["Max"] = temp.Max + dic["Low"] = temp.Low + dic["High"] = temp.High + temp_value = temp.Value + dic["Value"] = temp_value if (temp_value is not None) else self.error_ret + dic["Unit"] = temp.Unit + val_list[temp.name] = dic + # fan + fanlist = self.chas.fan_list + for fan in fanlist: + for rotor in fan.rotor_list: + sensorname = "%s%s" % (fan.name, rotor.name) + speed = collections.OrderedDict() + speed['Min'] = rotor.rotor_Speed.Min + speed['Max'] = rotor.rotor_Speed.Max + rotor_speed_Value = rotor.rotor_Speed.Value + speed['Value'] = rotor_speed_Value if (rotor_speed_Value is not None) else self.error_ret + speed['Unit'] = rotor.rotor_Speed.Unit + val_list[sensorname] = speed + + val_list.update(self.get_dcdc_all_info()) + + # psu + psulist = self.chas.psu_list + for psu in psulist: + inputdic_voltage = collections.OrderedDict() + inputdic_current = collections.OrderedDict() + inputdic_power = collections.OrderedDict() + outputdic_voltage = collections.OrderedDict() + outputdic_current = collections.OrderedDict() + outputdic_power = collections.OrderedDict() + temperature = collections.OrderedDict() + fanspeed = collections.OrderedDict() + + psu_temp_value = psu.Temperature.Value + temperature["Value"] = psu_temp_value if (psu_temp_value is not None) else self.error_ret + temperature["Min"] = psu.Temperature.Min + temperature["Max"] = psu.Temperature.Max + temperature["Unit"] = psu.Temperature.Unit + + fanspeed["Value"] = psu.FanSpeed.Value + fanspeed["Min"] = psu.FanSpeed.Min + fanspeed["Max"] = psu.FanSpeed.Max + fanspeed["Unit"] = psu.FanSpeed.Unit + + psu_inputvoltage_value = psu.InputsVoltage.Value + inputdic_voltage["Value"] = psu_inputvoltage_value if ( + psu_inputvoltage_value is not None) else self.error_ret + inputdic_voltage["Min"] = psu.InputsVoltage.Min + inputdic_voltage["Max"] = psu.InputsVoltage.Max + inputdic_voltage["Unit"] = psu.InputsVoltage.Unit + + psu_inputcurrent_value = psu.InputsCurrent.Value + inputdic_current["Value"] = psu_inputcurrent_value if ( + psu_inputcurrent_value is not None) else self.error_ret + inputdic_current["Min"] = psu.InputsCurrent.Min + inputdic_current["Max"] = psu.InputsCurrent.Max + inputdic_current["Unit"] = psu.InputsCurrent.Unit + + psu_inputpower_value = psu.InputsPower.Value + inputdic_power["Value"] = psu_inputpower_value if (psu_inputpower_value is not None) else self.error_ret + inputdic_power["Min"] = psu.InputsPower.Min + inputdic_power["Max"] = psu.InputsPower.Max + inputdic_power["Unit"] = psu.InputsPower.Unit + + psu_outputvoltage_value = psu.OutputsVoltage.Value + outputdic_voltage["Value"] = psu_outputvoltage_value if ( + psu_outputvoltage_value is not None) else self.error_ret + outputdic_voltage["Min"] = psu.OutputsVoltage.Min + outputdic_voltage["Max"] = psu.OutputsVoltage.Max + outputdic_voltage["Unit"] = psu.OutputsVoltage.Unit + + psu_outputcurrent_value = psu.OutputsCurrent.Value + outputdic_current["Value"] = psu_outputcurrent_value if ( + psu_outputcurrent_value is not None) else self.error_ret + outputdic_current["Min"] = psu.OutputsCurrent.Min + outputdic_current["Max"] = psu.OutputsCurrent.Max + outputdic_current["Unit"] = psu.OutputsCurrent.Unit + + psu_outputpower_value = psu.OutputsPower.Value + outputdic_power["Value"] = psu_outputpower_value if ( + psu_outputpower_value is not None) else self.error_ret + outputdic_power["Min"] = psu.OutputsPower.Min + outputdic_power["Max"] = psu.OutputsPower.Max + outputdic_power["Unit"] = psu.OutputsPower.Unit + + val_list["%s%s" % (psu.name, "Vol_I")] = inputdic_voltage + val_list["%s%s" % (psu.name, "Curr_I")] = inputdic_current + val_list["%s%s" % (psu.name, "Power_I")] = inputdic_power + val_list["%s%s" % (psu.name, "Vol_O")] = outputdic_voltage + val_list["%s%s" % (psu.name, "Curr_O")] = outputdic_current + val_list["%s%s" % (psu.name, "Power_O")] = outputdic_power + val_list["%s%s" % (psu.name, "Fan")] = fanspeed + val_list["%s%s" % (psu.name, "Temp")] = temperature + + return val_list + + # cpld + def get_cpld_total_number(self): + cpldlist = self.chas.cpld_list + return len(cpldlist) + + def get_cpld_user_reg(self): + cpld = self.chas.get_cpld_byname("BASE_CPLD") + if cpld is None: + return None + else: + return cpld.get_user_reg() + + def set_cpld_user_reg(self, value): + if (isinstance(value, int) == False): + baseutil.logger_debug("value must int %s" % type(value)) + return -1 + if (int(value) < 0 or int(value) > 255): + baseutil.logger_debug("value must [0 - 255]") + return -1 + cpld = self.chas.get_cpld_byname("BASE_CPLD") + if cpld is None: + baseutil.logger_debug("name BASE_CPLD not find") + return -1 + if cpld.set_user_reg(value) == True: + return 0 + else: + return -1 + + def set_cpld_console_owner(self, owner): + """ + Set console I/O owner + + @param owner I/O owner of the console, either "cpu" or "bmc" + + @return 0 for success, -1 for failure + """ + if (owner is None): + baseutil.logger_debug("owner is None") + return -1 + if (owner != "cpu" and owner != "bmc"): + baseutil.logger_debug("owner is %s, must cpu or bmc" % owner) + return -1 + cpld = self.chas.get_cpld_byname("BASE_CPLD") + if cpld is None: + baseutil.logger_debug("name BASE_CPLD not find") + return -1 + if cpld.set_console_owner(owner) == True: + return 0 + else: + return -1 + + def get_cpld_version_by_id(self, cpld_id): + cpldlist = self.chas.cpld_list + cpldtmp = None + for cpld in cpldlist: + if cpld.cpld_id == cpld_id: + cpldtmp = cpld + + dic = collections.OrderedDict() + if cpldtmp is None: + dic["Name"] = self.na_ret + dic["Version"] = self.na_ret + dic["Desc"] = self.na_ret + dic["Slot"] = None + else: + dic["Name"] = cpldtmp.name + dic["Version"] = cpldtmp.get_version() + dic["Desc"] = cpldtmp.desc + dic["Slot"] = cpldtmp.slot + return dic + + def get_cpld_all_version(self): + """ + Get version of all CPLDs' that can be read from BMC + + @return dict of CPLDs' version or None for failure. + example outputs: + { + "BASE_CPLD": "0.1", # or "N/A" for read failure + "FAN_CPLD": "0.2" + } + """ + cpld_version = { + "BASE_CPLD": "N/A", + "FAN_CPLD": "N/A" + } + for cpld_name in cpld_version.keys(): + cpld = self.chas.get_cpld_byname(cpld_name) + if cpld is None: + baseutil.logger_debug("name %s not find" % cpld_name) + continue + cpld_version[cpld_name] = cpld.get_version() + return cpld_version + + # comp + def get_comp_total_number(self): + complist = self.chas.comp_list + return len(complist) + + def get_comp_list(self): + return self.chas.comp_list + + def get_comp_id(self, comp): + return comp.comp_id + + def get_comp_version_by_id(self, id): + comp_list = self.chas.comp_list + comptmp = None + for comp in comp_list: + if comp.comp_id == id: + comptmp = comp + break + + dic = collections.OrderedDict() + if comptmp is None: + dic["Name"] = self.na_ret + dic["Version"] = self.na_ret + dic["Desc"] = self.na_ret + dic["Slot"] = None + else: + dic["Name"] = comptmp.name + dic["Version"] = comptmp.get_version() + dic["Desc"] = comptmp.desc + dic["Slot"] = comptmp.slot + return dic + + def get_bmc_productname(self): + """ + Get product name + + @return product name string, e.g. $(device name)-F-$(VENDOR_NAME), if error return "N/A" + """ + bmc = self.chas.get_bmc_byname("master") + if (bmc is None): + baseutil.logger_debug("name bmc(master) not find") + return self.na_ret + return bmc.get_productname() + + def call_bmc_diagcmd(self, cmdstr): + """ + Call BMC diag comman func + + @return ret: 0 sucess , -1 fail + outmsg: if success is out msg, or fail is err msg + """ + if (cmdstr is None or cmdstr == ""): + outmsg = "cmdstr is empty" + baseutil.logger_debug(outmsg) + return -1, outmsg + bmc = self.chas.get_bmc_byname("master") + if (bmc is None): + outmsg = "name bmc(master) not find" + baseutil.logger_debug(outmsg) + return -1, outmsg + baseutil.logger_debug("call cmdstr %s" % cmdstr) + return bmc.call_diagcmd(cmdstr) + + def write_bios_version(self, flash, version): + bios = self.chas.get_bios_byname("master") + if bios is None: + baseutil.logger_debug("name bios(master) not find") + return -1 + return bios.set_bios_version(flash, version) + + def get_bios_version(self): + bios = self.chas.get_bios_byname("master") + if bios is None: + baseutil.logger_debug("name bios(master) not find") + return -1 + return bios.get_bios_version() + + def get_bios_status(self): + bios = self.chas.get_bios_byname("master") + if bios is None: + baseutil.logger_debug("name bios(master) not find") + return -1 + return bios.get_bios_boot_status() + + def monitor_cpu_host_watchdog(self, value): + cpu = self.chas.get_cpu_byname("cpu") + if cpu is None: + baseutil.logger_debug("name cpu not find") + return -1 + return cpu.set_cpu_host_watchdog(value) + + def get_bmc_mac_rov(self): + """ + Get BMC mac rov + + @return ret: 0 sucess , -1 fail + outmsg: if success is out msg, or fail is err msg + """ + bmc = self.chas.get_bmc_byname("master") + if bmc is None: + msg = "name master not find" + baseutil.logger_debug(msg) + return -1, msg + return bmc.get_mac_rov() + + def get_bmc_next_boot(self): + """ + Get next booting flash of BMC + + @return 'master'/'slave' on success, "N/A" for failure + """ + bmc = self.chas.get_bmc_byname("master") + if bmc is None: + baseutil.logger_debug("name master not find") + return self.na_ret + return bmc.get_next_boot() + + def set_bmc_next_boot(self, flash): + """ + Set flash from which next BMC boot + + @param flash Booting flash of BMC, "master" or "slave" + + @return 0 on success, -1 for failure + """ + if flash is None or (flash != "master" and flash != "slave"): + baseutil.logger_debug("parameter flash illegal, should be [master|slave]") + return -1 + bmc = self.chas.get_bmc_byname("master") + if bmc is None: + baseutil.logger_debug("name master not find") + return -1 + return bmc.set_next_boot(flash) + + def reboot_bmc(self): + """ + Reboot running BMC + """ + bmc = self.chas.get_bmc_byname("master") + if bmc is None: + baseutil.logger_debug("name master not find") + return -1 + return bmc.reboot() + + def get_bmc_info(self): + """ + Get BMC info + + @return dict of BMC info or None for failure + "Version": "1.1.1", # "N/A" + "Flash": "master", # "N/A" + "Next": "master" # "N/A" + """ + bmc = self.chas.get_bmc_byname("master") + if bmc is None: + baseutil.logger_debug("name master not find") + return self.na_ret + return bmc.get_info() + + def get_bmc_version_all(self): + """ + @return dict of BMCs + { + "MasterVersion": "1.1.1", # "N/A" + "SlaveVersion": "1.1.1" # "N/A" + } + """ + bmc = self.chas.get_bmc_byname("master") + if bmc is None: + baseutil.logger_debug("name master not find") + return self.na_ret + return bmc.get_version_all() + + def bmc_execute_command(self, cmd_str): + ret, output = osutil.command(cmd_str) + if ret: + baseutil.logger_debug("execute %s command failed" % (cmd_str)) + return ret, output + + def get_cpu_status(self): + """ + Get CPU current status. + + @return 'S0', ..., 'S5', or 'N/A' for failure + """ + cpu = self.chas.get_cpu_byname("cpu") + if cpu is None: + baseutil.logger_debug("name cpu not find") + return self.na_ret + return cpu.get_state() + + def get_cpu_reset_num(self): + """ + Get CPU reset num + @return CPU reset num on success, -1 for failure + """ + cpu = self.chas.get_cpu_byname("cpu") + if cpu is None: + msg = "name cpu not find" + baseutil.logger_debug(msg) + return -1 + return cpu.get_cpu_reset_num() diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/led.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/led.py new file mode 100755 index 000000000000..967a100b9826 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/led.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python3 +####################################################### +# +# led.py +# Python implementation of the Class led +# Original author: rd@ruijie.com.cn +# +####################################################### +from plat_hal.devicebase import devicebase + + +class led(devicebase): + def __init__(self, conf=None): + if conf is not None: + self.name = conf.get('name', None) + self.led_type = conf.get('led_type', None) + self.led_attrs_config = conf.get('led_attrs', None) + self.led_config = conf.get('led', None) + + def set_color(self, color): + status = self.led_attrs_config.get(color, None) + if status is None: + return False + + mask = self.led_attrs_config.get('mask', 0xff) + + if isinstance(self.led_config, list): + for led_config_index in self.led_config: + ret, value = self.get_value(led_config_index) + if (ret is False) or (value is None): + return False + setval = (int(value) & ~mask) | (status) + ret, val = self.set_value(led_config_index, setval) + if ret is False: + return ret + else: + ret, value = self.get_value(self.led_config) + if (ret is False) or (value is None): + return False + setval = (int(value) & ~mask) | (status) + ret, val = self.set_value(self.led_config, setval) + return ret + + def get_color(self): + mask = self.led_attrs_config.get('mask', 0xff) + ret, value = self.get_value(self.led_config) + if ret is False or value is None: + return False, 'N/A' + ledval = (int(value) & mask) + for key, val in self.led_attrs_config.items(): + if (ledval == val) and (key != "mask"): + return True, key + return False, 'N/A' + diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/onie_e2.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/onie_e2.py new file mode 100755 index 000000000000..76ac1658267b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/onie_e2.py @@ -0,0 +1,127 @@ +#!/usr/bin/env python3 +####################################################### +# +# onie_e2.py +# Python implementation of the Class onie_e2 +# Original author: rd@ruijie.com.cn +# +####################################################### +from plat_hal.devicebase import devicebase +from eepromutil.onietlv import onie_tlv + + +class onie_e2(devicebase): + + def __init__(self, conf=None): + self._cardid = "" + self._productname = "" + self._partnum = "" + self._serialnum = "" + self._macbase = "" + self._manufdate = "" + self._deviceversion = "" + self._labelrevision = "" + self._platformname = "" + self._onieversion = "" + self._macsize = "" + self._manufname = "" + self._manufcountry = "" + self._vendorname = "" + self._diagname = "" + self._servicetag = "" + + if conf is not None: + self.name = conf.get('name', None) + self.e2loc = conf.get('e2loc', None) + self.e2_path = self.e2loc.get('loc', None) + + @property + def cardid(self): + return self._cardid + + @property + def productname(self): + return self._productname + + @property + def partnum(self): + return self._partnum + + @property + def serialnum(self): + return self._serialnum + + @property + def macbase(self): + return self._macbase + + @property + def manufdate(self): + return self._manufdate + + @property + def deviceversion(self): + return self._deviceversion + + @property + def labelrevision(self): + return self._labelrevision + + @property + def platformname(self): + return self._platformname + + @property + def onieversion(self): + return self._onieversion + + @property + def macsize(self): + return self._macsize + + @property + def manufname(self): + return self._manufname + + @property + def manufcountry(self): + return self._manufcountry + + @property + def vendorname(self): + return self._vendorname + + @property + def diagname(self): + return self._diagname + + @property + def servicetag(self): + return self._servicetag + + def get_onie_e2_info(self): + try: + eeprom = self.get_eeprom_info(self.e2loc) + if eeprom is None: + raise Exception("%s: value is none" % self.name) + onietlv = onie_tlv() + onietlv.decode(eeprom) + self._cardid = onietlv.cardid + self._productname = onietlv.productname + self._partnum = onietlv.partnum + self._serialnum = onietlv.serialnum + self._macbase = onietlv.macbase + self._manufdate = onietlv.manufdate + self._deviceversion = onietlv.deviceversion + self._labelrevision = onietlv.labelrevision + self._platformname = onietlv.platformname + self._onieversion = onietlv.onieversion + self._macsize = onietlv.macsize + self._manufname = onietlv.manufname + self._manufcountry = onietlv.manufcountry + self._vendorname = onietlv.vendorname + self._diagname = onietlv.diagname + self._servicetag = onietlv.servicetag + except Exception as e: + return False + return True diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/osutil.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/osutil.py new file mode 100755 index 000000000000..aa6f39b20f8c --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/osutil.py @@ -0,0 +1,401 @@ +#!/usr/bin/env python3 +####################################################### +# +# osutil.py +# Python implementation of the Class osutil +# Original author: rd@ruijie.com.cn +# +####################################################### + +import os +import time +import glob +import re +from rjutil.smbus import SMBus +import time +import subprocess +from functools import wraps +import fcntl +import syslog + + +PLATFORM_HAL_DEBUG_FILE = "/etc/.platform_hal_debug_flag" + + +def platform_hal_debug(s): + if os.path.exists(PLATFORM_HAL_DEBUG_FILE): + syslog.openlog("PLATFORM_HAL", syslog.LOG_PID) + syslog.syslog(syslog.LOG_DEBUG, s) + + +def retry(maxretry=6, delay=0.01): + ''' + maxretry: max retry times + delay : interval after last retry + ''' + def decorator(f): + @wraps(f) + def wrapper(*args, **kwargs): + time_retry = maxretry + time_delay = delay + result_msg = "" + while time_retry: + try: + val, result_msg = f(*args, **kwargs) + if val is False: + time_retry -= 1 + time.sleep(time_delay) + continue + else: + return val, result_msg + except Exception as e: + time_retry -= 1 + result_msg = str(e) + time.sleep(time_delay) + return False, "max time retry last errmsg is {}".format(result_msg) + return wrapper + return decorator + + +pidfile = -1 + + +def file_rw_lock(file_path): + global pidfile + pidfile = open(file_path, "r") + try: + fcntl.flock(pidfile, fcntl.LOCK_EX | fcntl.LOCK_NB) + platform_hal_debug("file_rw_lock success") + return True + except Exception as e: + pidfile.close() + pidfile = -1 + return False + + +def file_rw_unlock(): + try: + global pidfile + + if pidfile != -1: + fcntl.flock(pidfile, fcntl.LOCK_UN) + pidfile.close() + pidfile = -1 + platform_hal_debug("file_rw_unlock success") + else: + platform_hal_debug("pidfile is invalid, do nothing") + return True + except Exception as e: + platform_hal_debug("file_rw_unlock err, msg: %s" % (str(e))) + return False + + +def take_file_rw_lock(file_path): + loop = 1000 + ret = False + for i in range(0, loop): + ret = file_rw_lock(file_path) + if ret is True: + break + time.sleep(0.001) + return ret + + +class osutil(object): + """ + osutil + """ + + @staticmethod + @retry(maxretry=6) + def rji2cget_python(bus, addr, reg): + with SMBus(bus) as y: + val, ind = y.read_byte_data(addr, reg, True) + return val, ind + + @staticmethod + @retry(maxretry=6) + def rji2cset_python(bus, addr, reg, value): + with SMBus(bus) as y: + val, ind = y.write_byte_data(addr, reg, value, True) + return val, ind + + @staticmethod + @retry(maxretry=6) + def rji2cgetword_python(bus, addr, reg): + with SMBus(bus) as y: + val, ind = y.read_word_data(addr, reg, True) + return val, ind + + @staticmethod + @retry(maxretry=6) + def rji2csetword_python(bus, addr, reg, value): + with SMBus(bus) as y: + val, ind = y.write_word_data(addr, reg, value, True) + return val, ind + + @staticmethod + @retry(maxretry=6) + def rji2csetwordpec_python(bus, addr, reg, value): + with SMBus(bus) as y: + val, ind = y.write_word_data_pec(addr, reg, value, True) + return val, ind + + @staticmethod + @retry(maxretry=6) + def rji2cset_byte_pec_python(bus, addr, reg, value): + with SMBus(bus) as y: + val, ind = y.write_byte_data_pec(addr, reg, value, True) + return val, ind + + @staticmethod + def command(cmdstr): + retcode, output = subprocess.getstatusoutput(cmdstr) + return retcode, output + + @staticmethod + def geti2cword_i2ctool(bus, addr, offset): + command_line = "i2cget -f -y %d 0x%02x 0x%02x wp" % (bus, addr, offset) + retrytime = 6 + ret_t = "" + for i in range(retrytime): + ret, ret_t = osutil.command(command_line) + if ret == 0: + return True, int(ret_t, 16) + time.sleep(0.1) + return False, ret_t + + @staticmethod + def seti2cword_i2ctool(bus, addr, offset, val): + command_line = "i2cset -f -y %d 0x%02x 0x%0x 0x%04x wp" % (bus, addr, offset, val) + retrytime = 6 + ret_t = "" + for i in range(retrytime): + ret, ret_t = osutil.command(command_line) + if ret == 0: + return True, ret_t + time.sleep(0.1) + return False, ret_t + + @staticmethod + def rji2cget_i2ctool(bus, devno, address): + command_line = "i2cget -f -y %d 0x%02x 0x%02x " % (bus, devno, address) + retrytime = 6 + ret_t = "" + for i in range(retrytime): + ret, ret_t = osutil.command(command_line) + if ret == 0: + return True, int(ret_t, 16) + time.sleep(0.1) + return False, ret_t + + @staticmethod + def rji2cset_i2ctool(bus, devno, address, byte): + command_line = "i2cset -f -y %d 0x%02x 0x%02x 0x%02x" % ( + bus, devno, address, byte) + retrytime = 6 + ret_t = "" + for i in range(retrytime): + ret, ret_t = osutil.command(command_line) + if ret == 0: + return True, ret_t + return False, ret_t + + @staticmethod + def geti2cword(bus, addr, offset): + return osutil.rji2cgetword_python(bus, addr, offset) + + @staticmethod + def seti2cword(bus, addr, offset, val): + return osutil.rji2csetword_python(bus, addr, offset, val) + + @staticmethod + def seti2cwordpec(bus, addr, offset, val): + return osutil.rji2csetwordpec_python(bus, addr, offset, val) + + @staticmethod + def seti2c_byte_pec(bus, addr, offset, val): + return osutil.rji2cset_byte_pec_python(bus, addr, offset, val) + + @staticmethod + def rji2cget(bus, devno, address): + return osutil.rji2cget_python(bus, devno, address) + + @staticmethod + def rji2cset(bus, devno, address, byte): + return osutil.rji2cset_python(bus, devno, address, byte) + + @staticmethod + def byteTostr(val): + strtmp = '' + for i in range(len(val)): + strtmp += chr(val[i]) + return strtmp + + @staticmethod + def io_rd(reg_addr, read_len=1): + try: + regaddr = 0 + if isinstance(reg_addr, int): + regaddr = reg_addr + else: + regaddr = int(reg_addr, 16) + devfile = "/dev/port" + fd = os.open(devfile, os.O_RDWR | os.O_CREAT) + os.lseek(fd, regaddr, os.SEEK_SET) + str = os.read(fd, read_len) + return True, "".join(["%02x" % item for item in str]) + except ValueError as e: + return False, str(e) + except Exception as e: + return False, str(e) + finally: + os.close(fd) + + @staticmethod + def readsysfs(location, flock_path=None): + flock_path_tmp = None + platform_hal_debug("readsysfs, location:%s, flock_path:%s" % (location, flock_path)) + try: + if flock_path is not None: + flock_paths = glob.glob(flock_path) + if len(flock_paths) != 0: + flock_path_tmp = flock_paths[0] + platform_hal_debug("try to get file lock, path:%s" % flock_path_tmp) + ret = take_file_rw_lock(flock_path_tmp) + if ret is False: + platform_hal_debug("take file lock timeout, path:%s" % flock_path_tmp) + return False, ("take file rw lock timeout, path:%s" % flock_path_tmp) + else: + platform_hal_debug("config error, can't find flock_path:%s" % flock_path) + + locations = glob.glob(location) + with open(locations[0], 'rb') as fd1: + retval = fd1.read() + retval = osutil.byteTostr(retval) + if flock_path_tmp is not None: + file_rw_unlock() + + retval = retval.rstrip('\r\n') + retval = retval.lstrip(" ") + except Exception as e: + if flock_path_tmp is not None: + file_rw_unlock() + platform_hal_debug("readsysfs error, msg:%s" % str(e)) + return False, (str(e) + " location[%s]" % location) + return True, retval + + @staticmethod + def writesysfs(location, value): + try: + if not os.path.isfile(location): + print(location, 'not found !') + return False, ("location[%s] not found !" % location) + with open(location, 'w') as fd1: + fd1.write(value) + except Exception as e: + return False, (str(e) + " location[%s]" % location) + return True, ("set location[%s] %s success !" % (location, value)) + + @staticmethod + def getdevmem(addr, digit, mask): + command_line = "devmem 0x%02x %d" % (addr, digit) + retrytime = 6 + ret_t = "" + for i in range(retrytime): + ret, ret_t = osutil.command(command_line) + if ret == 0: + if mask is not None: + ret_t = str(int(ret_t, 16) & mask) + return True, ret_t + return False, ret_t + + @staticmethod + def readdevfile_ascii(path, offset, len): + msg = "" + ret = "" + joinstr = '' + fd = -1 + + if not os.path.exists(path): + msg = path + " not found !" + return False, msg + + try: + fd = os.open(path, os.O_RDONLY) + os.lseek(fd, offset, os.SEEK_SET) + ret = os.read(fd, len) + for item in ret: + joinstr += '%02x ' % item # like sysfs, display in hex + except Exception as e: + msg = str(e) + return False, msg + finally: + if fd > 0: + os.close(fd) + return True, joinstr + + @staticmethod + def readdevfile(path, offset, len): + msg = "" + ret = "" + fd = -1 + + if not os.path.exists(path): + msg = path + " not found !" + return False, msg + + try: + fd = os.open(path, os.O_RDONLY) + os.lseek(fd, offset, os.SEEK_SET) + ret = os.read(fd, len) + except Exception as e: + msg = str(e) + return False, msg + finally: + if fd > 0: + os.close(fd) + return True, ret + + @staticmethod + def rj_os_system(cmd): + status, output = subprocess.getstatusoutput(cmd) + return status, output + + @staticmethod + def getsdkreg(reg): + try: + cmd = "bcmcmd -t 1 'getr %s ' < /dev/null" % reg + ret, result = osutil.rj_os_system(cmd) + result_t = result.strip().replace("\r", "").replace("\n", "") + if ret != 0 or "Error:" in result_t: + return False, result + patt = r"%s.(.*):(.*)>drivshell" % reg + rt = re.findall(patt, result_t, re.S) + test = re.findall("=(.*)", rt[0][0])[0] + except Exception as e: + return False, 'get sdk register error' + return True, test + + @staticmethod + def getmactemp(): + try: + result = {} + # waitForDocker() + # need to exec twice + osutil.rj_os_system("bcmcmd -t 1 \"show temp\" < /dev/null") + ret, log = osutil.rj_os_system("bcmcmd -t 1 \"show temp\" < /dev/null") + if ret: + return False, result + else: + logs = log.splitlines() + for line in logs: + if "average" in line: + b = re.findall(r'\d+.\d+', line) + result["average"] = b[0] + elif "maximum" in line: + b = re.findall(r'\d+.\d+', line) + result["maximum"] = b[0] + except Exception as e: + return False, str(e) + return True, result diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/psu.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/psu.py new file mode 100755 index 000000000000..d59173c5670b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/psu.py @@ -0,0 +1,620 @@ +#!/usr/bin/env python3 +####################################################### +# +# psu.py +# Python implementation of the Class psu +# Original author: rd@ruijie.com.cn +# +####################################################### +from plat_hal.devicebase import devicebase +from eepromutil.fru import ipmifru +from plat_hal.sensor import sensor + + +class psu(devicebase): + __pmbus = None + __e2loc = None + __present = None + __productManufacturer = None # : ARTESYN + __productName = None # : CRPS550W + __productPartModelName = None # : CSU550AP-3-300 + __productVersion = None # : AB + __productSerialNumber = None # : M623UZ00JYABL + __AirFlow = None # 'N/A' + __AirFlowconifg = None + __psu_display_name = None # 'N/A' + __psu_display_name_conifg = None + __psu_not_present_pwm = None + __InputStatus_config = None + __OutputStatus_config = None + __FanSpeed_config = None + __Temperature_config = None + __InputStatus = None + __OutputStatus = None + __FanSpeed = None + __Temperature = None + __FanSpeedMin = None + __FanSpeedMax = None + __FanSpeedTolerance = None + __InputsVoltage_config = None + __InputsCurrent_config = None + __InputsPower_config = None + __OutputsVoltage_config = None + __OutputsCurrent_config = None + __OutputsPower_config = None + __InputsVoltage = {} + __InputsCurrent = None + __InputsPower = None + __OutputsVoltage = None + __OutputsCurrent = None + __OutputsPower = None + __InputsType_config = None + __InputsType = None + __psu_sn_config = None + __psu_hw_config = None + __psu_pn_config = None + __psu_vendor_config = None + __TempStatus_config = None + __FanStatus_config = None + __TempStatus = None + __FanStatus = None + + def __init__(self, conf=None): + self.pmbus = conf.get("pmbusloc", None) + self.e2loc = conf.get("e2loc", None) + self.__presentconfig = conf.get("present", None) + self.name = conf.get("name", None) + self.AirFlowconifg = conf.get("airflow", None) + self.psu_display_name_conifg = conf.get("psu_display_name", None) + self.psu_not_present_pwm = conf.get("psu_not_present_pwm", 100) + self.Temperature_config = conf.get("Temperature", None) + self.Temperature = sensor(self.Temperature_config) + + self.FanSpeedTolerance = conf.get('psu_fan_tolerance', 30) + self.FanSpeed_config = conf.get("FanSpeed", None) + self.FanSpeed = sensor(self.FanSpeed_config) + + self.__InputsVoltage_config = conf.get("InputsVoltage", None) + self.generate_psu_input_vol(self.__InputsVoltage_config) + self.__InputsCurrent_config = conf.get("InputsCurrent", None) + self.InputsCurrent = sensor(self.__InputsCurrent_config) + self.__InputsPower_config = conf.get("InputsPower", None) + self.InputsPower = sensor(self.__InputsPower_config) + self.__OutputsVoltage_config = conf.get("OutputsVoltage", None) + self.OutputsVoltage = sensor(self.__OutputsVoltage_config) + self.__OutputsCurrent_config = conf.get("OutputsCurrent", None) + self.OutputsCurrent = sensor(self.__OutputsCurrent_config) + self.__OutputsPower_config = conf.get("OutputsPower", None) + self.OutputsPower = sensor(self.__OutputsPower_config) + + self.__InputStatus_config = conf.get("InputsStatus", None) + self.__OutputStatus_config = conf.get("OutputsStatus", None) + self.__InputsType_config = conf.get('InputsType', None) + self.__psu_sn_config = conf.get('psu_sn', None) + self.__psu_hw_config = conf.get('psu_hw', None) + self.__psu_pn_config = conf.get('psu_pn', None) + self.__psu_vendor_config = conf.get('psu_vendor', None) + self.__TempStatus_config = conf.get("TempStatus", None) + self.__FanStatus_config = conf.get("FanStatus", None) + + def generate_psu_input_vol(self, config): + tmp = {} + for (key, item) in config.items(): + tmp.setdefault(key, sensor(item)) + self.__InputsVoltage = tmp + + def get_psu_sensor_by_name(self, psutype): + return self.__InputsVoltage.get(psutype) or self.__InputsVoltage.get('other') + + @property + def InputsVoltage(self): + psutype = self.InputsType + input_sensor = self.get_psu_sensor_by_name(psutype) + if input_sensor is None: + return None + else: + return input_sensor + + @InputsVoltage.setter + def InputsVoltage(self, val): + self.__InputsVoltage = val + + @property + def InputsCurrent(self): + return self.__InputsCurrent + + @InputsCurrent.setter + def InputsCurrent(self, val): + self.__InputsCurrent = val + + @property + def InputsPower(self): + return self.__InputsPower + + @InputsPower.setter + def InputsPower(self, val): + self.__InputsPower = val + + @property + def OutputsVoltage(self): + return self.__OutputsVoltage + + @OutputsVoltage.setter + def OutputsVoltage(self, val): + self.__OutputsVoltage = val + + @property + def OutputsCurrent(self): + return self.__OutputsCurrent + + @OutputsCurrent.setter + def OutputsCurrent(self, val): + self.__OutputsCurrent = val + + @property + def OutputsPower(self): + return self.__OutputsPower + + @OutputsPower.setter + def OutputsPower(self, val): + self.__OutputsPower = val + + @property + def InputStatus(self): + if self.present == False: + self.__InputStatus = False + else: + ret, val = self.get_value(self.__InputStatus_config) + mask = self.__InputStatus_config.get("mask") + if ret == True: + ttt = val & mask + if ttt == 0: + self.__InputStatus = True + else: + self.__InputStatus = False + else: + self.__InputStatus = False + return self.__InputStatus + + @InputStatus.setter + def InputStatus(self, val): + self.__InputStatus = val + + @property + def TempStatus(self): + if self.__TempStatus_config is None: + return None + if self.present == False: + self.__TempStatus = False + else: + ret, val = self.get_value(self.__TempStatus_config) + mask = self.__TempStatus_config.get("mask") + if ret == True: + ttt = val & mask + if ttt == 0: + self.__TempStatus = True + else: + self.__TempStatus = False + else: + self.__TempStatus = False + return self.__TempStatus + + @TempStatus.setter + def TempStatus(self, val): + self.__TempStatus = val + + @property + def FanStatus(self): + if self.__FanStatus_config is None: + return None + if self.present == False: + self.__FanStatus = False + else: + ret, val = self.get_value(self.__FanStatus_config) + mask = self.__FanStatus_config.get("mask") + if ret == True: + ttt = val & mask + if ttt == 0: + self.__FanStatus = True + else: + self.__FanStatus = False + else: + self.__FanStatus = False + return self.__FanStatus + + @FanStatus.setter + def FanStatus(self, val): + self.__FanStatus = val + + @property + def InputsType(self): + psutypedecode = self.__InputsType_config.get('psutypedecode', None) + if self.present == False: + self.__InputsType = psutypedecode.get(0x00) + else: + ret, val = self.get_value(self.__InputsType_config) + self.__InputsType = self.__InputsType_config.get(val, None) + if self.__InputsType is not None: + return self.__InputsType + if ret == True and val in psutypedecode: + self.__InputsType = psutypedecode.get(val) + else: + self.__InputsType = psutypedecode.get(0x00) + return self.__InputsType + + @InputsType.setter + def InputsType(self, val): + self.__InputsType = val + + @property + def FanSpeedMin(self): + return self.__FanSpeedMin + + @FanSpeedMin.setter + def FanSpeedMin(self, val): + self.__FanSpeedMin = val + + @property + def FanSpeedMax(self): + return self.__FanSpeedMax + + @FanSpeedMax.setter + def FanSpeedMax(self, val): + self.__FanSpeedMax = val + + @property + def FanSpeedTolerance(self): + return self.__FanSpeedTolerance + + @FanSpeedTolerance.setter + def FanSpeedTolerance(self, val): + self.__FanSpeedTolerance = val + + @property + def OutputStatus(self): + if self.present == False: + self.__OutputStatus = False + else: + ret, val = self.get_value(self.__OutputStatus_config) + mask = self.__OutputStatus_config.get("mask") + if ret == True: + ttt = val & mask + if ttt == 0: + self.__OutputStatus = True + else: + self.__OutputStatus = False + else: + self.__OutputStatus = False + return self.__OutputStatus + + @OutputStatus.setter + def OutputStatus(self, val): + self.__OutputStatus = val + + @property + def FanSpeed(self): + return self.__FanSpeed + + @FanSpeed.setter + def FanSpeed(self, val): + self.__FanSpeed = val + + @property + def Temperature(self): + return self.__Temperature + + @Temperature.setter + def Temperature(self, val): + self.__Temperature = val + + @property + def Temperature_config(self): + return self.__Temperature_config + + @Temperature_config.setter + def Temperature_config(self, val): + self.__Temperature_config = val + + @property + def AirFlowconifg(self): + return self.__AirFlowconifg + + @AirFlowconifg.setter + def AirFlowconifg(self, val): + self.__AirFlowconifg = val + + @property + def psu_display_name_conifg(self): + return self.__psu_display_name_conifg + + @psu_display_name_conifg.setter + def psu_display_name_conifg(self, val): + self.__psu_display_name_conifg = val + + @property + def pmbus(self): + return self.__pmbus + + @pmbus.setter + def pmbus(self, val): + self.__pmbus = val + + @property + def e2loc(self): + return self.__e2loc + + @e2loc.setter + def e2loc(self, val): + self.__e2loc = val + + @property + def AirFlow(self): + return self.__AirFlow + + @AirFlow.setter + def AirFlow(self, val): + self.__AirFlow = val + + @property + def psu_display_name(self): + return self.__psu_display_name + + @psu_display_name.setter + def psu_display_name(self, val): + self.__psu_display_name = val + + @property + def psu_not_present_pwm(self): + return self.__psu_not_present_pwm + + @psu_not_present_pwm.setter + def psu_not_present_pwm(self, val): + self.__psu_not_present_pwm = val + + @property + def present(self): + ret, val = self.get_value(self.__presentconfig) + if ret is False or val is None: + return False + mask = self.__presentconfig.get("mask") + if isinstance(val, str): + value = int(val, 16) + else: + value = val + ttt = value & mask + okval = self.__presentconfig.get("okval", 0) + if ttt == okval: + return True + else: + return False + + @present.setter + def present(self, val): + self.__present = val + + @property + def productManufacturer(self): + return self.__productManufacturer + + @productManufacturer.setter + def productManufacturer(self, val): + self.__productManufacturer = val + + @property + def productName(self): + return self.__productName + + @productName.setter + def productName(self, val): + self.__productName = val + + @property + def productPartModelName(self): + return self.__productPartModelName + + @productPartModelName.setter + def productPartModelName(self, val): + self.__productPartModelName = val + + @property + def productVersion(self): + return self.__productVersion + + @productVersion.setter + def productVersion(self, val): + self.__productVersion = val + + @property + def productSerialNumber(self): + return self.__productSerialNumber + + @productSerialNumber.setter + def productSerialNumber(self, val): + self.__productSerialNumber = val + + @property + def psu_sn_sysfs(self): + if self.__psu_sn_config is None: + return None + ret, val = self.get_value(self.__psu_sn_config) + if ret is False or val is None: + return None + return val + + @property + def psu_hw_sysfs(self): + if self.__psu_hw_config is None: + return None + ret, val = self.get_value(self.__psu_hw_config) + if ret is False or val is None: + return None + return val + + @property + def psu_pn_sysfs(self): + if self.__psu_pn_config is None: + return None + ret, val = self.get_value(self.__psu_pn_config) + if ret is False or val is None: + return None + return val + + @property + def psu_vendor_sysfs(self): + if self.__psu_vendor_config is None: + return None + ret, val = self.get_value(self.__psu_vendor_config) + if ret is False or val is None: + return None + return val + + def __str__(self): + formatstr = \ + "name : %s \n" \ + "productManufacturer : %s \n" \ + "productName : %s \n" \ + "productPartModelName: %s \n" \ + "productVersion : %s \n" \ + "productSerialNumber : %s \n" \ + "AirFlow : %s \n" \ + + tmpstr = formatstr % (self.name, self.productManufacturer, + self.productName, self.productPartModelName, + self.productVersion, self.productSerialNumber, self.AirFlow) + return tmpstr + + def get_fan_speed_pwm(self): + if self.present == False: + return self.psu_not_present_pwm + selfconfig = {} + selfconfig['bus'] = self.pmbus['bus'] + selfconfig['addr'] = self.pmbus['addr'] + selfconfig['way'] = 'i2cword' + selfconfig['offset'] = 0x3b + ret, val = self.get_value(selfconfig) + if ret == True: + return val + else: + return None + + def set_fan_speed_pwm(self, pwm): + ''' + pmbus + if duty: + i2cset -f -y 0x3b 0x0064 wp + ''' + if self.present == False: + return None + if 0 <= pwm <= 100: + '''enable duty first ''' + selfconfig = {} + + selfconfig['bus'] = self.pmbus['bus'] + selfconfig['addr'] = self.pmbus['addr'] + selfconfig['way'] = 'i2cpec' + selfconfig['offset'] = 0x3a + self.set_value(selfconfig, 0x80) + + selfconfig['way'] = 'i2cwordpec' + selfconfig['offset'] = 0x3b + bytetmp = pwm + ret, val = self.set_value(selfconfig, int(bytetmp)) + if ret == True: + return True + else: + return None + else: + raise Exception("pwm not in range [0,100]") + + def get_fru_info_by_sysfs(self): + try: + psu_sn = self.psu_sn_sysfs + psu_hw = self.psu_hw_sysfs + psu_pn = self.psu_pn_sysfs + psu_vendor = self.psu_vendor_sysfs + if psu_sn is None or psu_hw is None or psu_pn is None or psu_vendor is None: + return False + self.productSerialNumber = psu_sn.strip().replace(chr(0), "") + self.productVersion = psu_hw.strip() + self.productPartModelName = psu_pn.strip() + self.productManufacturer = psu_vendor.strip().replace(chr(0), "") + except Exception as e: + self.productSerialNumber = None + self.productVersion = None + self.productPartModelName = None + self.productManufacturer = None + return False + return True + + def get_fru_info_by_decode(self): + try: + eeprom = self.get_eeprom_info(self.e2loc) + if eeprom is None: + raise Exception("%s:value is none" % self.name) + fru = ipmifru() + if isinstance(eeprom, bytes): + eeprom = self.byteTostr(eeprom) + fru.decodeBin(eeprom) + if fru.productInfoArea is not None: + self.productManufacturer = fru.productInfoArea.productManufacturer.strip() + self.productName = fru.productInfoArea.productName.strip() + self.productPartModelName = fru.productInfoArea.productPartModelName.strip() + self.productVersion = fru.productInfoArea.productVersion.strip() + self.productSerialNumber = fru.productInfoArea.productSerialNumber.strip().replace(chr(0), "") + except Exception as e: + self.productManufacturer = None + self.productName = None + self.productPartModelName = None + self.productVersion = None + self.productSerialNumber = None + return False + return True + + def get_fru_info(self): + try: + if self.present is not True: + raise Exception("%s: not present" % self.name) + if self.get_fru_info_by_sysfs() is True: + return True + return self.get_fru_info_by_decode() + except Exception as e: + self.productManufacturer = None + self.productName = None + self.productPartModelName = None + self.productVersion = None + self.productSerialNumber = None + return False + + def get_AirFlow(self): + if self.productPartModelName is None: + ret = self.get_fru_info() + if ret is False: + self.AirFlow = None + return False + if self.AirFlowconifg is None: + self.AirFlow = None + return False + else: + for i in self.AirFlowconifg: + if self.productPartModelName in self.AirFlowconifg[i]: + self.AirFlow = i + return True + self.AirFlow = None + return False + + def get_psu_display_name(self): + if self.productPartModelName is None: + ret = self.get_fru_info() + if ret is False: + self.psu_display_name = None + return False + if self.psu_display_name_conifg is None: + self.psu_display_name = self.productPartModelName + return False + else: + for i in self.psu_display_name_conifg: + if self.productPartModelName in self.psu_display_name_conifg[i]: + self.psu_display_name = i + return True + self.psu_display_name = self.productPartModelName + return False diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/rotor.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/rotor.py new file mode 100755 index 000000000000..80e318d4132a --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/rotor.py @@ -0,0 +1,156 @@ +#!/usr/bin/env python3 +####################################################### +# +# rotor.py +# Python implementation of the Class rotor +# Original author: rd@ruijie.com.cn +# +####################################################### +from plat_hal.devicebase import devicebase +from plat_hal.sensor import sensor + + +class rotor(devicebase): + __rotor_Running = None + __rotor_HwAlarm_conf = None + __rotor_Speed = None + __rotor_run_conf = None + __Speedconfig = None + __i2c_speed = None + __SpeedMin = None + __SpeedMax = None + __SpeedTolerance = None + + def __init__(self, conf=None): + self.name = conf.get('name', None) + self.rotor_HwAlarm_conf = conf.get('HwAlarm', None) + self.rotor_run_conf = conf.get('Running', None) + self.SpeedMin = conf.get('SpeedMin', None) + self.SpeedMax = conf.get('SpeedMax', None) + self.Tolerance = conf.get('tolerance', 30) + self.rotor_Speed = sensor(conf.get('Speed', None)) + self.Speedconfig = conf.get('Set_speed', None) + + def getRunning(self): + ret, val = self.get_value(self.rotor_run_conf) + if ret is False or val is None: + return False + if isinstance(val, str): + value = int(val, 16) + else: + value = val + mask = self.rotor_run_conf.get("mask") + is_runing_value = self.rotor_run_conf.get("is_runing") + flag = value & mask + if flag == is_runing_value: + return True + else: + return False + + @property + def SpeedMin(self): + return self.__SpeedMin + + @SpeedMin.setter + def SpeedMin(self, val): + self.__SpeedMin = val + + @property + def SpeedMax(self): + return self.__SpeedMax + + @SpeedMax.setter + def SpeedMax(self, val): + self.__SpeedMax = val + + @property + def Tolerance(self): + return self.__SpeedTolerance + + @Tolerance.setter + def Tolerance(self, val): + self.__SpeedTolerance = val + + @property + def i2c_speed(self): + ret, val = self.get_value(self.Speedconfig) + if ret == False: + return None + if val is not None: + self.__i2c_speed = val + return self.__i2c_speed + + def feed_watchdog(self): + ret, val = self.get_value(self.Speedconfig) + if ret == False: + return False, None + if val is not None: + ret, val = self.set_value(self.Speedconfig, val) + return ret, val + return False, None + + @i2c_speed.setter + def i2c_speed(self, val): + self.__i2c_speed = val + + @property + def Speedconfig(self): + return self.__Speedconfig + + @Speedconfig.setter + def Speedconfig(self, val): + self.__Speedconfig = val + + @property + def rotor_run_conf(self): + return self.__rotor_run_conf + + @rotor_run_conf.setter + def rotor_run_conf(self, val): + self.__rotor_run_conf = val + + @property + def rotor_Speed(self): + return self.__rotor_Speed + + @rotor_Speed.setter + def rotor_Speed(self, val): + self.__rotor_Speed = val + + @property + def rotor_HwAlarm(self): + ret, val = self.get_value(self.rotor_HwAlarm_conf) + mask = self.rotor_HwAlarm_conf.get("mask") + no_alarm_value = self.rotor_HwAlarm_conf.get("no_alarm") + if ret is False or val is None: + return False + if isinstance(val, str): + value = int(val, 16) + else: + value = val + flag = value & mask + if flag == no_alarm_value: + return False + else: + return True + + @rotor_HwAlarm.setter + def rotor_HwAlarm(self, val): + self.__rotor_HwAlarm = val + + @property + def rotor_HwAlarm_conf(self): + return self.__rotor_HwAlarm_conf + + @rotor_HwAlarm_conf.setter + def rotor_HwAlarm_conf(self, val): + self.__rotor_HwAlarm_conf = val + + @property + def rotor_Running(self): + self.__rotor_Running = self.getRunning() + return self.__rotor_Running + + @rotor_Running.setter + def rotor_Running(self, val): + self.__rotor_Running = val diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/sensor.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/sensor.py new file mode 100755 index 000000000000..eb932f2629b0 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/sensor.py @@ -0,0 +1,220 @@ +#!/usr/bin/env python3 +####################################################### +# +# sensor.py +# Python implementation of the Class sensor +# Original author: rd@ruijie.com.cn +# +####################################################### +import time +from plat_hal.devicebase import devicebase + + +class sensor(devicebase): + + __Value = None + __Min = None + __Max = None + __Low = None + __High = None + __ValueConfig = None + __Flag = None + __Unit = None + __format = None + __read_times = None + + __Min_config = None + __Max_config = None + __Low_config = None + __High_config = None + + @property + def Min_config(self): + return self.__Min_config + + @Min_config.setter + def Min_config(self, val): + self.__Min_config = val + + @property + def Max_config(self): + return self.__Max_config + + @Max_config.setter + def Max_config(self, val): + self.__Max_config = val + + @property + def Low_config(self): + return self.__Low_config + + @Low_config.setter + def Low_config(self, val): + self.__Low_config = val + + @property + def High_config(self): + return self.__High_config + + @High_config.setter + def High_config(self, val): + self.__High_config = val + + @property + def Unit(self): + return self.__Unit + + @Unit.setter + def Unit(self, val): + self.__Unit = val + + @property + def format(self): + return self.__format + + @format.setter + def format(self, val): + self.__format = val + + @property + def read_times(self): + return self.__read_times + + @read_times.setter + def read_times(self, val): + self.__read_times = val + + @property + def ValueConfig(self): + return self.__ValueConfig + + @ValueConfig.setter + def ValueConfig(self, val): + self.__ValueConfig = val + + @property + def Flag(self): + return self.__Flag + + @Flag.setter + def Flag(self, val): + self.__Flag = val + + def get_median(self, value_config, read_times): + val_list = [] + for i in range(0, read_times): + ret, real_value = self.get_value(value_config) + if i != (read_times - 1): + time.sleep(0.01) + if ret is False or real_value is None: + continue + val_list.append(real_value) + val_list.sort() + if val_list: + return True, val_list[int((len(val_list) - 1) / 2)] + return False, None + + @property + def Value(self): + try: + ret, val = self.get_median(self.ValueConfig, self.read_times) + if ret is False or val is None: + return None + if self.format is None: + self.__Value = int(val) + else: + self.__Value = eval(self.format % val) + self.__Value = round(float(self.__Value), 3) + except Exception as e: + return None + return self.__Value + + @Value.setter + def Value(self, val): + self.__Value = val + + @property + def Min(self): + try: + if self.format is None: + self.__Min = self.Min_config + else: + self.__Min = eval(self.format % self.Min_config) + self.__Min = round(float(self.__Min), 3) + except Exception as e: + return None + return self.__Min + + @Min.setter + def Min(self, val): + self.__Min = val + + @property + def Max(self): + try: + if self.format is None: + self.__Max = self.Max_config + else: + self.__Max = eval(self.format % self.Max_config) + self.__Max = round(float(self.__Max), 3) + except Exception as e: + return None + return self.__Max + + @Max.setter + def Max(self, val): + self.__Max = val + + @property + def Low(self): + try: + if self.format is None: + self.__Low = self.Low_config + else: + self.__Low = eval(self.format % self.Low_config) + except Exception as e: + return None + return self.__Low + + @Low.setter + def Low(self, val): + self.__Low = val + + @property + def High(self): + try: + if self.format is None: + self.__High = self.High_config + else: + self.__High = eval(self.format % self.High_config) + except Exception as e: + return None + return self.__High + + @High.setter + def High(self, val): + self.__High = val + + def __init__(self, conf=None): + self.ValueConfig = conf.get("value", None) + self.Flag = conf.get("flag", None) + self.Min_config = conf.get("Min", None) + self.Max_config = conf.get("Max", None) + self.Low_config = conf.get("Low", None) + self.High_config = conf.get("High", None) + self.Unit = conf.get('Unit', None) + self.format = conf.get('format', None) + self.read_times = conf.get('read_times', 1) + + def __str__(self): + formatstr = \ + "ValueConfig: : %s \n" \ + "Min : %s \n" \ + "Max : %s \n" \ + "Unit : %s \n" \ + "format: : %s \n" + + tmpstr = formatstr % (self.ValueConfig, self.Min, + self.Max, self.Unit, + self.format) + return tmpstr diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/temp.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/temp.py new file mode 100755 index 000000000000..2652d11cc493 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/temp.py @@ -0,0 +1,138 @@ +#!/usr/bin/env python3 +####################################################### +# +# temp.py +# Python implementation of the Class temp +# Original author: rd@ruijie.com.cn +# +####################################################### +from plat_hal.sensor import sensor +import os +import syslog + + +PLATFORM_HAL_TEMP_DEBUG_FILE = "/etc/.platform_hal_temp_debug_flag" + +def platform_hal_temp_debug(s): + if os.path.exists(PLATFORM_HAL_TEMP_DEBUG_FILE): + syslog.openlog("PLATFORM_HAL_TEPM", syslog.LOG_PID) + syslog.syslog(syslog.LOG_DEBUG, s) + +class temp(sensor): + def __init__(self, conf=None): + super(temp, self).__init__(conf.get('Temperature', None)) + self.name = conf.get("name", None) + self.temp_id = conf.get("temp_id", None) + self.api_name = conf.get("api_name", self.name) + self.fix_value = conf.get("fix_value", None) + self.temp_invalid = conf.get("invalid", None) + self.temp_error = conf.get("error", None) + + def __str__(self): + super(temp, self).__str__() + + def temp_cali_by_fan_pwm(self, param, origin_value): + fan_pwm_conf = param.get("fan_pwm") + temp_fix_list = param.get("temp_fix_list") + + + ret, val = self.get_value(fan_pwm_conf) + if ret is False or val is None: + platform_hal_temp_debug("temp calibration get fan pwm failed, msg: %s, return None" % (val)) + return None + + fan_pwm = int(val) + for item in temp_fix_list: + if fan_pwm >= item["min"] and fan_pwm <= item["max"]: + fix_value = origin_value + item["fix"] + platform_hal_temp_debug("temp calibration by fan pwm, origin_value: %s, pwm: %s, fix_value: %s" % + (origin_value, fan_pwm, fix_value)) + return fix_value + platform_hal_temp_debug("temp calibration by fan pwm, origin_value: %s, pwm: %s, not match return None" % + (origin_value, fan_pwm)) + return None + + def fix_temp_value(self, origin_value): + try: + fix_type = self.fix_value.get("fix_type") + + if fix_type == "func": + func_name = self.fix_value.get("func_name") + func_param = self.fix_value.get("func_param") + value = eval(func_name)(func_param, origin_value) + return value + + if fix_type == "config": + coefficient = self.fix_value.get("coefficient", 1) + addend = self.fix_value.get("addend", 0) + value = (origin_value + addend) * coefficient + platform_hal_temp_debug("temp calibration by config, coefficient: %s, addend: %s, origin_value: %s, fix_value: %s" % + (coefficient, addend, origin_value, value)) + return value + + platform_hal_temp_debug("unsupport fix type: %s, return origin value: %s" % (fix_type, origin_value)) + return origin_value + except Exception as e: + platform_hal_temp_debug("fix_temp_value raise exception, msg: %s" % (str(e))) + return None + + def get_max_value(self, conf): + try: + ret, val = self.get_value(conf) + if ret is False or val is None: + return None + return val + except Exception as e: + return None + + def check_flag(self): + try: + okbit = self.Flag.get('okbit') + okval = self.Flag.get('okval') + ret, val = self.get_value(self.Flag) + if (ret == False) or (val is None): + return False + val_t = (int(val) & (1 << okbit)) >> okbit + if val_t != okval: + return False + except Exception as e: + return False + return True + + @property + def Value(self): + try: + if self.Flag is not None: + if self.check_flag() == False: + return None + if isinstance(self.ValueConfig, list): + max = None + for i in self.ValueConfig: + tmp = self.get_max_value(i) + if tmp is None: + continue + if max is None or max < tmp: + max = tmp + if max is None: + return None + if self.format is None: + self.__Value = int(max) + else: + self.__Value = eval(self.format % max) + else: + ret, val = self.get_value(self.ValueConfig) + if ret is False or val is None: + return None + if self.format is None: + self.__Value = int(val) + else: + self.__Value = eval(self.format % val) + except Exception as e: + return None + if self.fix_value is not None and self.__Value != self.temp_invalid and self.__Value != self.temp_error: + self.__Value = self.fix_temp_value(self.__Value) + return self.__Value + + @Value.setter + def Value(self, val): + self.__Value = val diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/rjutil/__init__.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/rjutil/__init__.py new file mode 100755 index 000000000000..e69de29bb2d1 diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/rjutil/baseutil.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/rjutil/baseutil.py new file mode 100755 index 000000000000..fa7dadd91350 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/rjutil/baseutil.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 +import os + + +def get_machine_info(): + if not os.path.isfile('/host/machine.conf'): + return None + machine_vars = {} + with open('/host/machine.conf') as machine_file: + for line in machine_file: + tokens = line.split('=') + if len(tokens) < 2: + continue + machine_vars[tokens[0]] = tokens[1].strip() + return machine_vars + + +def get_platform_info(machine_info): + if machine_info is not None: + if 'onie_platform' in machine_info: + return machine_info['onie_platform'] + elif 'aboot_platform' in machine_info: + return machine_info['aboot_platform'] + return None + + +def get_board_id(machine_info): + if machine_info is not None: + if 'onie_board_id' in machine_info: + return machine_info['onie_board_id'].lower() + return "NA" + + +def get_onie_machine(machine_info): + if machine_info is not None: + if 'onie_machine' in machine_info: + return machine_info['onie_machine'] + return None + diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/rjutil/smbus.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/rjutil/smbus.py new file mode 100755 index 000000000000..f3fee702bb46 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/rjutil/smbus.py @@ -0,0 +1,777 @@ +#!/usr/bin/env python3 +# smbus2 - A drop-in replacement for smbus-cffi/smbus-python +# The MIT License (MIT) +# Copyright (c) 2017 Karl-Petter Lindegaard +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +import os +import sys +from fcntl import ioctl +from ctypes import c_uint32, c_uint8, c_uint16, c_char, POINTER, Structure, Array, Union, create_string_buffer, string_at + + +# Commands from uapi/linux/i2c-dev.h +I2C_SLAVE = 0x0703 # Use this slave address +I2C_SLAVE_FORCE = 0x0706 # Use this slave address, even if it is already in use by a driver! +I2C_FUNCS = 0x0705 # Get the adapter functionality mask +I2C_RDWR = 0x0707 # Combined R/W transfer (one STOP only) +I2C_SMBUS = 0x0720 # SMBus transfer. Takes pointer to i2c_smbus_ioctl_data +I2C_PEC = 0x0708 + +# SMBus transfer read or write markers from uapi/linux/i2c.h +I2C_SMBUS_WRITE = 0 +I2C_SMBUS_READ = 1 + +# Size identifiers uapi/linux/i2c.h +I2C_SMBUS_QUICK = 0 +I2C_SMBUS_BYTE = 1 +I2C_SMBUS_BYTE_DATA = 2 +I2C_SMBUS_WORD_DATA = 3 +I2C_SMBUS_PROC_CALL = 4 +# This isn't supported by Pure-I2C drivers with SMBUS emulation, like those in RaspberryPi, OrangePi, etc :( +I2C_SMBUS_BLOCK_DATA = 5 +I2C_SMBUS_BLOCK_PROC_CALL = 7 # Like I2C_SMBUS_BLOCK_DATA, it isn't supported by Pure-I2C drivers either. +I2C_SMBUS_I2C_BLOCK_DATA = 8 +I2C_SMBUS_BLOCK_MAX = 32 + +# To determine what functionality is present (uapi/linux/i2c.h) +try: + from enum import IntFlag +except Exception as e: + IntFlag = int + + +class I2cFunc(IntFlag): + """ + These flags identify the operations supported by an I2C/SMBus device. + + You can test these flags on your `smbus.funcs` + + On newer python versions, I2cFunc is an IntFlag enum, but it + falls back to class with a bunch of int constants on older releases. + """ + I2C = 0x00000001 + ADDR_10BIT = 0x00000002 + PROTOCOL_MANGLING = 0x00000004 # I2C_M_IGNORE_NAK etc. + SMBUS_PEC = 0x00000008 + NOSTART = 0x00000010 # I2C_M_NOSTART + SLAVE = 0x00000020 + SMBUS_BLOCK_PROC_CALL = 0x00008000 # SMBus 2.0 + SMBUS_QUICK = 0x00010000 + SMBUS_READ_BYTE = 0x00020000 + SMBUS_WRITE_BYTE = 0x00040000 + SMBUS_READ_BYTE_DATA = 0x00080000 + SMBUS_WRITE_BYTE_DATA = 0x00100000 + SMBUS_READ_WORD_DATA = 0x00200000 + SMBUS_WRITE_WORD_DATA = 0x00400000 + SMBUS_PROC_CALL = 0x00800000 + SMBUS_READ_BLOCK_DATA = 0x01000000 + SMBUS_WRITE_BLOCK_DATA = 0x02000000 + SMBUS_READ_I2C_BLOCK = 0x04000000 # I2C-like block xfer + SMBUS_WRITE_I2C_BLOCK = 0x08000000 # w/ 1-byte reg. addr. + SMBUS_HOST_NOTIFY = 0x10000000 + + SMBUS_BYTE = 0x00060000 + SMBUS_BYTE_DATA = 0x00180000 + SMBUS_WORD_DATA = 0x00600000 + SMBUS_BLOCK_DATA = 0x03000000 + SMBUS_I2C_BLOCK = 0x0c000000 + SMBUS_EMUL = 0x0eff0008 + + +# i2c_msg flags from uapi/linux/i2c.h +I2C_M_RD = 0x0001 + +# Pointer definitions +LP_c_uint8 = POINTER(c_uint8) +LP_c_uint16 = POINTER(c_uint16) +LP_c_uint32 = POINTER(c_uint32) + + +############################################################# +# Type definitions as in i2c.h + + +class i2c_smbus_data(Array): + """ + Adaptation of the i2c_smbus_data union in ``i2c.h``. + + Data for SMBus messages. + """ + _length_ = I2C_SMBUS_BLOCK_MAX + 2 + _type_ = c_uint8 + + +class union_i2c_smbus_data(Union): + _fields_ = [ + ("byte", c_uint8), + ("word", c_uint16), + ("block", i2c_smbus_data) + ] + + +union_pointer_type = POINTER(union_i2c_smbus_data) + + +class i2c_smbus_ioctl_data(Structure): + """ + As defined in ``i2c-dev.h``. + """ + _fields_ = [ + ('read_write', c_uint8), + ('command', c_uint8), + ('size', c_uint32), + ('data', union_pointer_type)] + __slots__ = [name for name, type in _fields_] + + @staticmethod + def create(read_write=I2C_SMBUS_READ, command=0, size=I2C_SMBUS_BYTE_DATA): + u = union_i2c_smbus_data() + return i2c_smbus_ioctl_data( + read_write=read_write, command=command, size=size, + data=union_pointer_type(u)) + + +############################################################# +# Type definitions for i2c_rdwr combined transactions + + +class i2c_msg(Structure): + """ + As defined in ``i2c.h``. + """ + _fields_ = [ + ('addr', c_uint16), + ('flags', c_uint16), + ('len', c_uint16), + ('buf', POINTER(c_char))] + + def __iter__(self): + """ Iterator / Generator + + :return: iterates over :py:attr:`buf` + :rtype: :py:class:`generator` which returns int values + """ + idx = 0 + while idx < self.len: + yield ord(self.buf[idx]) + idx += 1 + + def __len__(self): + return self.len + + def __bytes__(self): + return string_at(self.buf, self.len) + + def __repr__(self): + return 'i2c_msg(%d,%d,%r)' % (self.addr, self.flags, self.__bytes__()) + + def __str__(self): + s = self.__bytes__() + if sys.version_info.major >= 3: + s = ''.join(map(chr, s)) + return s + + @staticmethod + def read(address, length): + """ + Prepares an i2c read transaction. + + :param address: Slave address. + :type: address: int + :param length: Number of bytes to read. + :type: length: int + :return: New :py:class:`i2c_msg` instance for read operation. + :rtype: :py:class:`i2c_msg` + """ + arr = create_string_buffer(length) + return i2c_msg( + addr=address, flags=I2C_M_RD, len=length, + buf=arr) + + @staticmethod + def write(address, buf): + """ + Prepares an i2c write transaction. + + :param address: Slave address. + :type address: int + :param buf: Bytes to write. Either list of values or str. + :type buf: list + :return: New :py:class:`i2c_msg` instance for write operation. + :rtype: :py:class:`i2c_msg` + """ + if sys.version_info.major >= 3: + if isinstance(buf, str): + buf = bytes(map(ord, buf)) + else: + buf = bytes(buf) + else: + if not isinstance(buf, str): + buf = ''.join([chr(x) for x in buf]) + arr = create_string_buffer(buf, len(buf)) + return i2c_msg( + addr=address, flags=0, len=len(arr), + buf=arr) + + +class i2c_rdwr_ioctl_data(Structure): + """ + As defined in ``i2c-dev.h``. + """ + _fields_ = [ + ('msgs', POINTER(i2c_msg)), + ('nmsgs', c_uint32) + ] + __slots__ = [name for name, type in _fields_] + + @staticmethod + def create(*i2c_msg_instances): + """ + Factory method for creating a i2c_rdwr_ioctl_data struct that can + be called with ``ioctl(fd, I2C_RDWR, data)``. + + :param i2c_msg_instances: Up to 42 i2c_msg instances + :rtype: i2c_rdwr_ioctl_data + """ + n_msg = len(i2c_msg_instances) + msg_array = (i2c_msg * n_msg)(*i2c_msg_instances) + return i2c_rdwr_ioctl_data( + msgs=msg_array, + nmsgs=n_msg + ) + + +############################################################# + + +class SMBus(object): + + def __init__(self, bus=None, force=False): + """ + Initialize and (optionally) open an i2c bus connection. + + :param bus: i2c bus number (e.g. 0 or 1) + or an absolute file path (e.g. `/dev/i2c-42`). + If not given, a subsequent call to ``open()`` is required. + :type bus: int or str + :param force: force using the slave address even when driver is + already using it. + :type force: boolean + """ + self.fd = None + self.funcs = I2cFunc(0) + if bus is not None: + self.open(bus) + self.address = None + self.force = force + self._force_last = None + + def __enter__(self): + """Enter handler.""" + return self + + def __exit__(self, exc_type, exc_val, exc_tb): + """Exit handler.""" + self.close() + + def open(self, bus): + """ + Open a given i2c bus. + + :param bus: i2c bus number (e.g. 0 or 1) + or an absolute file path (e.g. '/dev/i2c-42'). + :type bus: int or str + :raise TypeError: if type(bus) is not in (int, str) + """ + if isinstance(bus, int): + filepath = "/dev/i2c-{}".format(bus) + elif isinstance(bus, str): + filepath = bus + else: + raise TypeError("Unexpected type(bus)={}".format(type(bus))) + + self.fd = os.open(filepath, os.O_RDWR) + self.funcs = self._get_funcs() + + def close(self): + """ + Close the i2c connection. + """ + if self.fd: + os.close(self.fd) + self.fd = None + + def _set_address(self, address, force=None): + """ + Set i2c slave address to use for subsequent calls. + + :param address: + :type address: int + :param force: + :type force: Boolean + """ + force = force if force is not None else self.force + if self.address != address or self._force_last != force: + if force is True: + ioctl(self.fd, I2C_SLAVE_FORCE, address) + else: + ioctl(self.fd, I2C_SLAVE, address) + self.address = address + self._force_last = force + + def _get_funcs(self): + """ + Returns a 32-bit value stating supported I2C functions. + + :rtype: int + """ + f = c_uint32() + ioctl(self.fd, I2C_FUNCS, f) + return f.value + + def write_quick(self, i2c_addr, force=None): + """ + Perform quick transaction. Throws IOError if unsuccessful. + :param i2c_addr: i2c address + :type i2c_addr: int + :param force: + :type force: Boolean + """ + self._set_address(i2c_addr, force=force) + msg = i2c_smbus_ioctl_data.create( + read_write=I2C_SMBUS_WRITE, command=0, size=I2C_SMBUS_QUICK) + ioctl(self.fd, I2C_SMBUS, msg) + + def read_byte(self, i2c_addr, force=None): + """ + Read a single byte from a device. + + :rtype: int + :param i2c_addr: i2c address + :type i2c_addr: int + :param force: + :type force: Boolean + :return: Read byte value + """ + self._set_address(i2c_addr, force=force) + msg = i2c_smbus_ioctl_data.create( + read_write=I2C_SMBUS_READ, command=0, size=I2C_SMBUS_BYTE + ) + ioctl(self.fd, I2C_SMBUS, msg) + return msg.data.contents.byte + + def write_byte(self, i2c_addr, value, force=None): + """ + Write a single byte to a device. + + :param i2c_addr: i2c address + :type i2c_addr: int + :param value: value to write + :type value: int + :param force: + :type force: Boolean + """ + self._set_address(i2c_addr, force=force) + msg = i2c_smbus_ioctl_data.create( + read_write=I2C_SMBUS_WRITE, command=value, size=I2C_SMBUS_BYTE + ) + ioctl(self.fd, I2C_SMBUS, msg) + + def read_byte_data(self, i2c_addr, register, force=None): + """ + Read a single byte from a designated register. + + :param i2c_addr: i2c address + :type i2c_addr: int + :param register: Register to read + :type register: int + :param force: + :type force: Boolean + :return: Read byte value + :rtype: int + """ + val_t = -1 + returnmsg = "" + try: + self._set_address(i2c_addr, force=force) + msg = i2c_smbus_ioctl_data.create( + read_write=I2C_SMBUS_READ, command=register, size=I2C_SMBUS_BYTE_DATA + ) + val_t = ioctl(self.fd, I2C_SMBUS, msg) + except Exception as e: + self.close() + returnmsg = str(e) + if val_t < 0: + return False, returnmsg + else: + return True, msg.data.contents.byte + + def write_byte_data(self, i2c_addr, register, value, force=None): + """ + Write a byte to a given register. + + :param i2c_addr: i2c address + :type i2c_addr: int + :param register: Register to write to + :type register: int + :param value: Byte value to transmit + :type value: int + :param force: + :type force: Boolean + :rtype: None + """ + val_t = -1 + returnmsg = "" + try: + self._set_address(i2c_addr, force=force) + msg = i2c_smbus_ioctl_data.create( + read_write=I2C_SMBUS_WRITE, command=register, size=I2C_SMBUS_BYTE_DATA + ) + msg.data.contents.byte = value + val_t = ioctl(self.fd, I2C_SMBUS, msg) + except Exception as e: + returnmsg = str(e) + self.close() + if val_t < 0: + return False, returnmsg or "" + else: + return True, "" + + def write_byte_data_pec(self, i2c_addr, register, value, force=None): + """ + Write a byte to a given register. + + :param i2c_addr: i2c address + :type i2c_addr: int + :param register: Register to write to + :type register: int + :param value: Byte value to transmit + :type value: int + :param force: + :type force: Boolean + :rtype: None + """ + val_t = -1 + returnmsg = "" + try: + val_t = ioctl(self.fd, I2C_PEC, 1) + if val_t < 0: + raise Exception("set pec mod error") + self._set_address(i2c_addr, force=force) + msg = i2c_smbus_ioctl_data.create( + read_write=I2C_SMBUS_WRITE, command=register, size=I2C_SMBUS_BYTE_DATA + ) + msg.data.contents.byte = value + val_t = ioctl(self.fd, I2C_SMBUS, msg) + except Exception as e: + returnmsg = str(e) + self.close() + if val_t < 0: + return False, returnmsg or "" + else: + return True, "" + + def read_word_data(self, i2c_addr, register, force=None): + """ + Read a single word (2 bytes) from a given register. + + :param i2c_addr: i2c address + :type i2c_addr: int + :param register: Register to read + :type register: int + :param force: + :type force: Boolean + :return: 2-byte word + :rtype: int + """ + val_t = -1 + returnmsg = "" + try: + self._set_address(i2c_addr, force=force) + msg = i2c_smbus_ioctl_data.create( + read_write=I2C_SMBUS_READ, command=register, size=I2C_SMBUS_WORD_DATA + ) + val_t = ioctl(self.fd, I2C_SMBUS, msg) + except Exception as e: + returnmsg = str(e) + self.close() + if val_t < 0: + return False, returnmsg or "" + else: + return True, msg.data.contents.word + + def write_word_data_pec(self, i2c_addr, register, value, force=None): + """ + Write a byte to a given register. + + :param i2c_addr: i2c address + :type i2c_addr: int + :param register: Register to write to + :type register: int + :param value: Word value to transmit + :type value: int + :param force: + :type force: Boolean + :rtype: None + """ + val_t = -1 + returnmsg = "" + try: + val_t = ioctl(self.fd, I2C_PEC, 1) + if val_t < 0: + raise Exception("set pec mod error") + self._set_address(i2c_addr, force=force) + msg = i2c_smbus_ioctl_data.create( + read_write=I2C_SMBUS_WRITE, command=register, size=I2C_SMBUS_WORD_DATA + ) + msg.data.contents.word = value + val_t = ioctl(self.fd, I2C_SMBUS, msg) + except Exception as e: + returnmsg = str(e) + self.close() + if val_t < 0: + return False, returnmsg or "" + else: + return True, "" + + def write_word_data(self, i2c_addr, register, value, force=None): + """ + Write a byte to a given register. + + :param i2c_addr: i2c address + :type i2c_addr: int + :param register: Register to write to + :type register: int + :param value: Word value to transmit + :type value: int + :param force: + :type force: Boolean + :rtype: None + """ + val_t = -1 + returnmsg = "" + try: + self._set_address(i2c_addr, force=force) + msg = i2c_smbus_ioctl_data.create( + read_write=I2C_SMBUS_WRITE, command=register, size=I2C_SMBUS_WORD_DATA + ) + msg.data.contents.word = value + val_t = ioctl(self.fd, I2C_SMBUS, msg) + except Exception as e: + returnmsg = str(e) + self.close() + if val_t < 0: + return False, returnmsg or "" + else: + return True, "" + + def process_call(self, i2c_addr, register, value, force=None): + """ + Executes a SMBus Process Call, sending a 16-bit value and receiving a 16-bit response + + :param i2c_addr: i2c address + :type i2c_addr: int + :param register: Register to read/write to + :type register: int + :param value: Word value to transmit + :type value: int + :param force: + :type force: Boolean + :rtype: int + """ + self._set_address(i2c_addr, force=force) + msg = i2c_smbus_ioctl_data.create( + read_write=I2C_SMBUS_WRITE, command=register, size=I2C_SMBUS_PROC_CALL + ) + msg.data.contents.word = value + ioctl(self.fd, I2C_SMBUS, msg) + return msg.data.contents.word + + def read_block_data(self, i2c_addr, register, force=None): + """ + Read a block of up to 32-bytes from a given register. + + :param i2c_addr: i2c address + :type i2c_addr: int + :param register: Start register + :type register: int + :param force: + :type force: Boolean + :return: List of bytes + :rtype: list + """ + self._set_address(i2c_addr, force=force) + msg = i2c_smbus_ioctl_data.create( + read_write=I2C_SMBUS_READ, command=register, size=I2C_SMBUS_BLOCK_DATA + ) + ioctl(self.fd, I2C_SMBUS, msg) + length = msg.data.contents.block[0] + return msg.data.contents.block[1:length + 1] + + def write_block_data(self, i2c_addr, register, data, force=None): + """ + Write a block of byte data to a given register. + + :param i2c_addr: i2c address + :type i2c_addr: int + :param register: Start register + :type register: int + :param data: List of bytes + :type data: list + :param force: + :type force: Boolean + :rtype: None + """ + length = len(data) + if length > I2C_SMBUS_BLOCK_MAX: + raise ValueError("Data length cannot exceed %d bytes" % I2C_SMBUS_BLOCK_MAX) + self._set_address(i2c_addr, force=force) + msg = i2c_smbus_ioctl_data.create( + read_write=I2C_SMBUS_WRITE, command=register, size=I2C_SMBUS_BLOCK_DATA + ) + msg.data.contents.block[0] = length + msg.data.contents.block[1:length + 1] = data + ioctl(self.fd, I2C_SMBUS, msg) + + def block_process_call(self, i2c_addr, register, data, force=None): + """ + Executes a SMBus Block Process Call, sending a variable-size data + block and receiving another variable-size response + + :param i2c_addr: i2c address + :type i2c_addr: int + :param register: Register to read/write to + :type register: int + :param data: List of bytes + :type data: list + :param force: + :type force: Boolean + :return: List of bytes + :rtype: list + """ + length = len(data) + if length > I2C_SMBUS_BLOCK_MAX: + raise ValueError("Data length cannot exceed %d bytes" % I2C_SMBUS_BLOCK_MAX) + self._set_address(i2c_addr, force=force) + msg = i2c_smbus_ioctl_data.create( + read_write=I2C_SMBUS_WRITE, command=register, size=I2C_SMBUS_BLOCK_PROC_CALL + ) + msg.data.contents.block[0] = length + msg.data.contents.block[1:length + 1] = data + ioctl(self.fd, I2C_SMBUS, msg) + length = msg.data.contents.block[0] + return msg.data.contents.block[1:length + 1] + + def read_i2c_block_data(self, i2c_addr, register, length, force=None): + """ + Read a block of byte data from a given register. + + :param i2c_addr: i2c address + :type i2c_addr: int + :param register: Start register + :type register: int + :param length: Desired block length + :type length: int + :param force: + :type force: Boolean + :return: List of bytes + :rtype: list + """ + if length > I2C_SMBUS_BLOCK_MAX: + raise ValueError("Desired block length over %d bytes" % I2C_SMBUS_BLOCK_MAX) + self._set_address(i2c_addr, force=force) + msg = i2c_smbus_ioctl_data.create( + read_write=I2C_SMBUS_READ, command=register, size=I2C_SMBUS_I2C_BLOCK_DATA + ) + msg.data.contents.byte = length + ioctl(self.fd, I2C_SMBUS, msg) + return msg.data.contents.block[1:length + 1] + + def write_i2c_block_data(self, i2c_addr, register, data, force=None): + """ + Write a block of byte data to a given register. + + :param i2c_addr: i2c address + :type i2c_addr: int + :param register: Start register + :type register: int + :param data: List of bytes + :type data: list + :param force: + :type force: Boolean + :rtype: None + """ + length = len(data) + if length > I2C_SMBUS_BLOCK_MAX: + raise ValueError("Data length cannot exceed %d bytes" % I2C_SMBUS_BLOCK_MAX) + self._set_address(i2c_addr, force=force) + msg = i2c_smbus_ioctl_data.create( + read_write=I2C_SMBUS_WRITE, command=register, size=I2C_SMBUS_I2C_BLOCK_DATA + ) + msg.data.contents.block[0] = length + msg.data.contents.block[1:length + 1] = data + ioctl(self.fd, I2C_SMBUS, msg) + + def i2c_rdwr(self, *i2c_msgs): + """ + Combine a series of i2c read and write operations in a single + transaction (with repeated start bits but no stop bits in between). + + This method takes i2c_msg instances as input, which must be created + first with :py:meth:`i2c_msg.read` or :py:meth:`i2c_msg.write`. + + :param i2c_msgs: One or more i2c_msg class instances. + :type i2c_msgs: i2c_msg + :rtype: None + """ + ioctl_data = i2c_rdwr_ioctl_data.create(*i2c_msgs) + ioctl(self.fd, I2C_RDWR, ioctl_data) + + +class SMBusWrapper: + """ + Wrapper class around the SMBus. + Deprecated as of version 0.3.0. Please replace with :py:class:`SMBus`. + + Enables the user to wrap access to the :py:class:`SMBus` class in a + "with" statement. If auto_cleanup is True (default), the + :py:class:`SMBus` handle will be automatically closed + upon exit of the ``with`` block. + """ + + def __init__(self, bus_number=0, auto_cleanup=True, force=False): + """ + :param auto_cleanup: Close bus when leaving scope. + :type auto_cleanup: Boolean + :param force: Force using the slave address even when driver is already using it. + :type force: Boolean + """ + self.bus_number = bus_number + self.auto_cleanup = auto_cleanup + self.force = force + + def __enter__(self): + self.bus = SMBus(bus=self.bus_number, force=self.force) + return self.bus + + def __exit__(self, exc_type, exc_val, exc_tb): + if self.auto_cleanup: + self.bus.close() diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modprobe_conf/kernel_drivers_blacklist.conf b/platform/broadcom/sonic-platform-modules-tencent/common/modprobe_conf/kernel_drivers_blacklist.conf new file mode 100755 index 000000000000..6abab99a644e --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modprobe_conf/kernel_drivers_blacklist.conf @@ -0,0 +1,2 @@ +blacklist rg_fpga_pcie +blacklist rg_spi_gpio diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/Makefile b/platform/broadcom/sonic-platform-modules-tencent/common/modules/Makefile new file mode 100755 index 000000000000..420a47054215 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/Makefile @@ -0,0 +1,50 @@ +PWD = $(shell pwd) +EXTRA_CFLAGS:= -I$(M)/include +EXTRA_CFLAGS+= -Wall +KVERSION ?= $(shell uname -r) +KERNEL_SRC ?= /lib/modules/$(KVERSION) + +module_out_put_dir := $(PWD)/build +export module_out_put_dir + +RG_PLAT_SYSFS_DIR = $(PWD)/rg_plat_sysfs + +export RG_PLAT_SYSFS_DIR + +ruijie_common-objs := ruijie_common_module.o dfd_tlveeprom.o +obj-m += rg_pmbus_core.o +obj-m += rg_csu550.o +obj-m += ruijie_common.o +obj-m += rg_ina3221.o +obj-m += rg_mac_bsc.o +obj-m += rg_tps53622.o +obj-m += rg_fpga_pcie.o +obj-m += rg_pcie_dev.o +obj-m += rg_fpga_i2c_bus_drv.o +obj-m += rg_fpga_pca954x_drv.o +obj-m += rg_lpc_drv.o +obj-m += rg_i2c_dev.o +obj-m += rg_io_dev.o +obj-m += rg_eeprom_93xx46.o +obj-m += rg_ucd9000.o +obj-m += rg_spi_93xx46.o +obj-m += rg_gpio_d1500.o +obj-m += rg_gpio_device.o +obj-m += rg_wdt.o +obj-m += rg_optoe.o +obj-m += rg_spi_gpio.o +obj-m += rg_spi_gpio_device.o +obj-m += rg_xdpe132g5c.o +obj-m += rg_i2c_gpio_device.o + +all : + $(MAKE) -C $(RG_PLAT_SYSFS_DIR) + $(MAKE) -C $(KERNEL_SRC)/build M=$(PWD) modules + @if [ ! -d $(module_out_put_dir) ]; then mkdir -p $(module_out_put_dir) ;fi + cp -p $(PWD)/*.ko $(module_out_put_dir) + +clean : + rm -rf $(module_out_put_dir) + rm -f ${PWD}/*.o ${PWD}/*.ko ${PWD}/*.mod.c ${PWD}/.*.cmd ${PWD}/.*.o.d ${PWD}/*.mod + rm -f ${PWD}/Module.markers ${PWD}/Module.symvers ${PWD}/modules.order + rm -rf ${PWD}/.tmp_versions diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/dfd_tlveeprom.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/dfd_tlveeprom.c new file mode 100644 index 000000000000..cc209981d18a --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/dfd_tlveeprom.c @@ -0,0 +1,516 @@ +/* + * Copyright (C) 2003-2014 FreeIPMI Core Team + * + * 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 . + * + */ +/*****************************************************************************\ + * Copyright (C) 2007-2014 Lawrence Livermore National Security, LLC. + * Copyright (C) 2007 The Regents of the University of California. + * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). + * Written by Albert Chu + * UCRL-CODE-232183 + * + * This file is part of Ipmi-fru, a tool used for retrieving + * motherboard field replaceable unit (FRU) information. For details, + * see http://www.llnl.gov/linux/. + * + * Ipmi-fru 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. + * + * Ipmi-fru 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 Ipmi-fru. If not, see . +\*****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "ruijie.h" +#include "dfd_tlveeprom.h" + +/* using in is_valid_tlvinfo_header */ +static u_int32_t eeprom_size; + +/* + * List of TLV codes and names. + */ +static const struct tlv_code_desc tlv_code_list[] = { + { TLV_CODE_PRODUCT_NAME , "Product Name"}, + { TLV_CODE_PART_NUMBER , "Part Number"}, + { TLV_CODE_SERIAL_NUMBER , "Serial Number"}, + { TLV_CODE_MAC_BASE , "Base MAC Address"}, + { TLV_CODE_MANUF_DATE , "Manufacture Date"}, + { TLV_CODE_DEVICE_VERSION , "Device Version"}, + { TLV_CODE_LABEL_REVISION , "Label Revision"}, + { TLV_CODE_PLATFORM_NAME , "Platform Name"}, + { TLV_CODE_ONIE_VERSION , "ONIE Version"}, + { TLV_CODE_MAC_SIZE , "MAC Addresses"}, + { TLV_CODE_MANUF_NAME , "Manufacturer"}, + { TLV_CODE_MANUF_COUNTRY , "Country Code"}, + { TLV_CODE_VENDOR_NAME , "Vendor Name"}, + { TLV_CODE_DIAG_VERSION , "Diag Version"}, + { TLV_CODE_SERVICE_TAG , "Service Tag"}, + { TLV_CODE_VENDOR_EXT , "Vendor Extension"}, + { TLV_CODE_CRC_32 , "CRC-32"}, +}; + +#if 0 +#define OPENBMC_VPD_KEY_INVAIL_VAL 0 + +static const tlv_code_map_t tlv_code_map[] = { + { TLV_CODE_PRODUCT_NAME , OPENBMC_VPD_KEY_PRODUCT_NAME}, + { TLV_CODE_PART_NUMBER , OPENBMC_VPD_KEY_PRODUCT_PART_MODEL_NUM}, + { TLV_CODE_SERIAL_NUMBER , OPENBMC_VPD_KEY_PRODUCT_SERIAL_NUM}, + { TLV_CODE_MAC_BASE , OPENBMC_VPD_KEY_INVAIL_VAL}, + { TLV_CODE_MANUF_DATE , OPENBMC_VPD_KEY_BOARD_MFG_DATE}, + { TLV_CODE_DEVICE_VERSION , OPENBMC_VPD_KEY_PRODUCT_VER}, + { TLV_CODE_LABEL_REVISION , OPENBMC_VPD_KEY_PRODUCT_CUSTOM7}, + { TLV_CODE_PLATFORM_NAME , OPENBMC_VPD_KEY_PRODUCT_CUSTOM1}, + { TLV_CODE_ONIE_VERSION , OPENBMC_VPD_KEY_PRODUCT_CUSTOM2}, + { TLV_CODE_MAC_SIZE , OPENBMC_VPD_KEY_INVAIL_VAL}, + { TLV_CODE_MANUF_NAME , OPENBMC_VPD_KEY_PRODUCT_MFR}, + { TLV_CODE_MANUF_COUNTRY , OPENBMC_VPD_KEY_PRODUCT_CUSTOM3}, + { TLV_CODE_VENDOR_NAME , OPENBMC_VPD_KEY_PRODUCT_CUSTOM4}, + { TLV_CODE_DIAG_VERSION , OPENBMC_VPD_KEY_PRODUCT_CUSTOM8}, + { TLV_CODE_SERVICE_TAG , OPENBMC_VPD_KEY_PRODUCT_CUSTOM5}, + { TLV_CODE_VENDOR_EXT , OPENBMC_VPD_KEY_PRODUCT_CUSTOM6}, + { TLV_CODE_CRC_32 , OPENBMC_VPD_KEY_INVAIL_VAL}, +}; +#endif + +#define TLV_CODE_NUM (sizeof(tlv_code_list) / sizeof(tlv_code_list[0])) + +#if 0 +#define TLV_CODE_MAP_NUM (sizeof(tlv_code_map) / sizeof(tlv_code_map[0])) +#endif + +const unsigned long crc_table[] = { + 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, + 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, + 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, + 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, + 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, + 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, + 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, + 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, + 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, + 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, + 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, + 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, + 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, + 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, + 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, + 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, + 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, + 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, + 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, + 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, + 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, + 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, + 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, + 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, + 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, + 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, + 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, + 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, + 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, + 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, + 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, + 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d, +}; + +static unsigned long crc32(unsigned long crc, const unsigned char *buf, unsigned len) +{ + unsigned i; + if (len < 1) + return 0xffffffff; + + for (i = 0; i != len; ++i) + { + crc = crc_table[(crc ^ buf[i]) & 0xff] ^ (crc >> 8); + } + + crc = crc ^ 0xffffffff; + + return crc; +} + +/* + * is_valid_tlv + * + * Perform basic sanity checks on a TLV field. The TLV is pointed to + * by the parameter provided. + * 1. The type code is not reserved (0x00 or 0xFF) + */ +static inline bool is_valid_tlv(tlvinfo_tlv_t *tlv) +{ + return ((tlv->type != 0x00) && (tlv->type != 0xFF)); +} + +/* + * is_valid_tlvinfo_header + * + * Perform sanity checks on the first 11 bytes of the TlvInfo EEPROM + * data pointed to by the parameter: + * 1. First 8 bytes contain null-terminated ASCII string "TlvInfo" + * 2. Version byte is 1 + * 3. Total length bytes contain value which is less than or equal + * to the allowed maximum (2048-11) + * + */ +static inline bool is_valid_tlvinfo_header(tlvinfo_header_t *hdr) +{ + int max_size = eeprom_size; + return((strcmp(hdr->signature, TLV_INFO_ID_STRING) == 0) && + (hdr->version == TLV_INFO_VERSION) && + (be16_to_cpu(hdr->totallen) <= max_size) ); +} + +/* + * decode_tlv_value + * + * Decode a single TLV value into a string. + + * The validity of EEPROM contents and the TLV field have been verified + * prior to calling this function. + */ +static void decode_tlv_value(tlvinfo_tlv_t *tlv, tlv_decode_value_t *decode_value) +{ + int i; + char *value; + u_int32_t length; + + value = (char *)decode_value->value; + + switch (tlv->type) { + case TLV_CODE_PRODUCT_NAME: + case TLV_CODE_PART_NUMBER: + case TLV_CODE_SERIAL_NUMBER: + case TLV_CODE_MANUF_DATE: + case TLV_CODE_LABEL_REVISION: + case TLV_CODE_PLATFORM_NAME: + case TLV_CODE_ONIE_VERSION: + case TLV_CODE_MANUF_NAME: + case TLV_CODE_MANUF_COUNTRY: + case TLV_CODE_VENDOR_NAME: + case TLV_CODE_DIAG_VERSION: + case TLV_CODE_SERVICE_TAG: + case TLV_CODE_VENDOR_EXT: + memcpy(value, tlv->value, tlv->length); + value[tlv->length] = 0; + length = tlv->length; + break; + case TLV_CODE_MAC_BASE: + length = sprintf(value, "%02X:%02X:%02X:%02X:%02X:%02X", + tlv->value[0], tlv->value[1], tlv->value[2], + tlv->value[3], tlv->value[4], tlv->value[5]); + break; + case TLV_CODE_DEVICE_VERSION: + length = sprintf(value, "%u", tlv->value[0]); + break; + case TLV_CODE_MAC_SIZE: + length = sprintf(value, "%u", (tlv->value[0] << 8) | tlv->value[1]); + break; + #if 0 + case TLV_CODE_VENDOR_EXT: + value[0] = 0; + length = 0; + for (i = 0; (i < (TLV_DECODE_VALUE_MAX_LEN/5)) && (i < tlv->length); i++) { + length += sprintf(value, "%s 0x%02X", value, tlv->value[i]); + } + break; + #endif + case TLV_CODE_CRC_32: + length = sprintf(value, "0x%02X%02X%02X%02X", tlv->value[0], + tlv->value[1], tlv->value[2], tlv->value[3]); + break; + default: + value[0] = 0; + length = 0; + for (i = 0; (i < (TLV_DECODE_VALUE_MAX_LEN/5)) && (i < tlv->length); i++) { + length += sprintf(value, "%s 0x%02X", value, tlv->value[i]); + } + break; + } + + decode_value->length = length; +} + +/* + * is_checksum_valid + * + * Validate the checksum in the provided TlvInfo EEPROM data. First, + * verify that the TlvInfo header is valid, then make sure the last + * TLV is a CRC-32 TLV. Then calculate the CRC over the EEPROM data + * and compare it to the value stored in the EEPROM CRC-32 TLV. + */ +static bool is_checksum_valid(u_int8_t *eeprom) +{ + tlvinfo_header_t *eeprom_hdr; + tlvinfo_tlv_t *eeprom_crc; + unsigned int calc_crc; + unsigned int stored_crc; + + eeprom_hdr = (tlvinfo_header_t *) eeprom; + + // Is the eeprom header valid? + if (!is_valid_tlvinfo_header(eeprom_hdr)) { + return false; + } + + // Is the last TLV a CRC? + eeprom_crc = (tlvinfo_tlv_t *) &eeprom[sizeof(tlvinfo_header_t) + + be16_to_cpu(eeprom_hdr->totallen) - (sizeof(tlvinfo_tlv_t) + 4)]; + if ((eeprom_crc->type != TLV_CODE_CRC_32) || (eeprom_crc->length != 4)) { + return false; + } + + // Calculate the checksum + calc_crc = crc32(0xffffffffL, (const unsigned char *)eeprom, sizeof(tlvinfo_header_t) + + be16_to_cpu(eeprom_hdr->totallen) - 4); + stored_crc = ((eeprom_crc->value[0] << 24) | (eeprom_crc->value[1] << 16) | + (eeprom_crc->value[2] << 8) | eeprom_crc->value[3]); + + return (calc_crc == stored_crc); +} + +/* + * tlvinfo_find_tlv + * + * This function finds the TLV with the supplied code in the EERPOM. + * An offset from the beginning of the EEPROM is returned in the + * eeprom_index parameter if the TLV is found. + */ +static bool tlvinfo_find_tlv(u_int8_t *eeprom, u_int8_t tcode, int *eeprom_index) +{ + tlvinfo_header_t *eeprom_hdr; + tlvinfo_tlv_t *eeprom_tlv; + int eeprom_end; + + eeprom_hdr = (tlvinfo_header_t *) eeprom; + + // Search through the TLVs, looking for the first one which matches the + // supplied type code. + *eeprom_index = sizeof(tlvinfo_header_t); + eeprom_end = sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen); + while (*eeprom_index < eeprom_end) { + eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[*eeprom_index]; + if (!is_valid_tlv(eeprom_tlv)) { + return false; + } + + if (eeprom_tlv->type == tcode) { + return true; + } + + *eeprom_index += sizeof(tlvinfo_tlv_t) + eeprom_tlv->length; + } + + return false; +} + +/* + * tlvinfo_decode_tlv + * + * This function finds the TLV with the supplied code in the EERPOM + * and decodes the value into the buffer provided. + */ +static bool tlvinfo_decode_tlv(u_int8_t *eeprom, u_int8_t tcode, tlv_decode_value_t *decode_value) +{ + int eeprom_index; + tlvinfo_tlv_t *eeprom_tlv; + + // Find the TLV and then decode it + if (tlvinfo_find_tlv(eeprom, tcode, &eeprom_index)) { + eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[eeprom_index]; + decode_tlv_value(eeprom_tlv, decode_value); + return true; + } + + return false; +} + +/* + * parse_tlv_eeprom + * + * parse the EEPROM into memory, if it hasn't already been read. + */ +int parse_tlv_eeprom(u_int8_t *eeprom, u_int32_t size) +{ + unsigned int i; + bool ret; + tlvinfo_header_t *eeprom_hdr; + //tlv_info_vec_t tlv_info; + tlv_decode_value_t decode_value; + int j; + + eeprom_hdr = (tlvinfo_header_t *) eeprom; + eeprom_size = size; /* eeprom real size */ + + if (!is_valid_tlvinfo_header(eeprom_hdr)) { + DBG_ERROR("Failed to check tlv header.\n"); + return -1; + } + + if (!is_checksum_valid(eeprom)) { + DBG_ERROR("Failed to check tlv crc.\n"); + return -1; + } + + for (i = 0; i < TLV_CODE_NUM; i++) { + memset((void *)&decode_value, 0, sizeof(tlv_decode_value_t)); + ret = tlvinfo_decode_tlv(eeprom, tlv_code_list[i].m_code, &decode_value); + if (!ret) { + DBG_ERROR("No found type: %s\n", tlv_code_list[i].m_name); + continue; + } + + DBG_DEBUG("i: %d,Found type: %s tlv[%d]:%s\n", i, tlv_code_list[i].m_name, tlv_code_list[i].m_code, + decode_value.value); + for (j = 0; j < decode_value.length; j++) { + if ((j % 16) == 0) { + DBG_DEBUG("\n"); + } + DBG_DEBUG("%02x ", decode_value.value[j]); + } + DBG_DEBUG("\n\n"); + } + return 0; +} +static int dfd_parse_tlv_eeprom(u_int8_t *eeprom, u_int32_t size, u_int8_t main_type, tlv_decode_value_t *decode_value) +{ + bool ret; + tlvinfo_header_t *eeprom_hdr; + //tlv_info_vec_t tlv_info; + int j; + + eeprom_hdr = (tlvinfo_header_t *) eeprom; + eeprom_size = size; /* eeprom real size */ + + if (!is_valid_tlvinfo_header(eeprom_hdr)) { + DBG_ERROR("Failed to check tlv header.\n"); + return -1; + } + + if (!is_checksum_valid(eeprom)) { + DBG_ERROR("Failed to check tlv crc.\n"); + return -1; + } + + ret = tlvinfo_decode_tlv(eeprom, main_type, decode_value); + if (!ret) { + DBG_ERROR("No found type: %d\n", main_type); + return -1; + } + + DBG_DEBUG("Found type: %d, value: %s\n", main_type,decode_value->value); + for (j = 0; j < decode_value->length; j++) { + if ((j % 16) == 0) { + DBG_DEBUG("\n"); + } + DBG_DEBUG("%02x ", decode_value->value[j]); + } + DBG_DEBUG("\n\n"); + + return 0; +} + +static int tlvinfo_find_rg_ext_tlv(tlv_decode_value_t *ext_tlv_value, u_int8_t ext_type, + u_int8_t *buf, u_int8_t *buf_len) +{ + tlvinfo_tlv_t *eeprom_tlv; + int eeprom_end, eeprom_index; + + // Search through the TLVs, looking for the first one which matches the + // supplied type code. + DBG_DEBUG("ext_tlv_value->length: %d.\n", ext_tlv_value->length); + for (eeprom_index = 0; eeprom_index < ext_tlv_value->length; eeprom_index++) { + if ((eeprom_index % 16) == 0) { + DBG_DEBUG("\n"); + } + DBG_DEBUG("%02x ", ext_tlv_value->value[eeprom_index]); + } + + DBG_DEBUG("\n"); + + eeprom_index = 0; + eeprom_end = ext_tlv_value->length; + while (eeprom_index < eeprom_end) { + eeprom_tlv = (tlvinfo_tlv_t *) &(ext_tlv_value->value[eeprom_index]); + if (!is_valid_tlv(eeprom_tlv)) { + DBG_ERROR("tlv is not valid, eeprom_tlv->type 0x%x.\n", eeprom_tlv->type); + return -1; + } + + DBG_DEBUG("eeprom_tlv->length %d.\n", eeprom_tlv->length); + if (eeprom_tlv->type == ext_type) { + if (*buf_len >= eeprom_tlv->length) { + memcpy(buf, eeprom_tlv->value, eeprom_tlv->length); + DBG_DEBUG("eeprom_tlv->length %d.\n", eeprom_tlv->length); + *buf_len = eeprom_tlv->length; + return 0; + } + DBG_ERROR("buf_len %d small than info_len %d.\n", *buf_len, eeprom_tlv->length); + return -1; + } + + eeprom_index += sizeof(tlvinfo_tlv_t) + eeprom_tlv->length; + } + + DBG_ERROR("ext_type %d: tlv is not found.\n", ext_type); + return -1; +} + +int dfd_tlvinfo_get_e2prom_info(u_int8_t *eeprom, u_int32_t size, dfd_tlv_type_t *tlv_type, u_int8_t* buf, u_int8_t *buf_len) +{ + tlv_decode_value_t decode_value; + int ret; + + if (eeprom == NULL || tlv_type == NULL || buf == NULL) { + DBG_ERROR("Input para invalid.\n"); + return -1; + } + + memset((void *)&decode_value, 0, sizeof(tlv_decode_value_t)); + ret = dfd_parse_tlv_eeprom(eeprom, size, tlv_type->main_type, &decode_value); + if (ret) { + DBG_ERROR("dfd_parse_tlv_eeprom failed ret %d.\n", ret); + return ret; + } + + if (tlv_type->main_type != TLV_CODE_VENDOR_EXT) { + if (*buf_len >= decode_value.length) { + memcpy(buf, decode_value.value, decode_value.length); + *buf_len = decode_value.length; + return 0; + } + DBG_ERROR("buf_len %d small than info_len %d.\n", *buf_len, decode_value.length); + return -1; + } + DBG_DEBUG("info_len %d.\n", decode_value.length); + + return tlvinfo_find_rg_ext_tlv(&decode_value, tlv_type->ext_type, buf, buf_len); +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/dfd_tlveeprom.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/dfd_tlveeprom.h new file mode 100644 index 000000000000..6eaac5848223 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/dfd_tlveeprom.h @@ -0,0 +1,121 @@ +#ifndef DFD_OPENBMC_TLVEEPROM_H +#define DFD_OPENBMC_TLVEEPROM_H + +#ifndef u_int8_t +#define u_int8_t unsigned char +#endif + +#ifndef u_int16_t +#define u_int16_t unsigned short +#endif + +#ifndef u_int32_t +#define u_int32_t unsigned int +#endif + +#ifndef be16_to_cpu +#define be16_to_cpu(x) ntohs(x) +#endif + +#ifndef cpu_to_be16 +#define cpu_to_be16(x) htons(x) +#endif + +/** + * The TLV Types. + * + * Keep these in sync with tlv_code_list in cmd_sys_eeprom.c + */ +#define TLV_CODE_PRODUCT_NAME 0x21 +#define TLV_CODE_PART_NUMBER 0x22 +#define TLV_CODE_SERIAL_NUMBER 0x23 +#define TLV_CODE_MAC_BASE 0x24 +#define TLV_CODE_MANUF_DATE 0x25 +#define TLV_CODE_DEVICE_VERSION 0x26 +#define TLV_CODE_LABEL_REVISION 0x27 +#define TLV_CODE_PLATFORM_NAME 0x28 +#define TLV_CODE_ONIE_VERSION 0x29 +#define TLV_CODE_MAC_SIZE 0x2A +#define TLV_CODE_MANUF_NAME 0x2B +#define TLV_CODE_MANUF_COUNTRY 0x2C +#define TLV_CODE_VENDOR_NAME 0x2D +#define TLV_CODE_DIAG_VERSION 0x2E +#define TLV_CODE_SERVICE_TAG 0x2F +#define TLV_CODE_VENDOR_EXT 0xFD +#define TLV_CODE_CRC_32 0xFE + +#define TLV_CODE_NAME_LEN 64 +/* + * Struct for displaying the TLV codes and names. + */ +struct tlv_code_desc { + u_int8_t m_code; + char m_name[TLV_CODE_NAME_LEN]; +}; + +typedef struct dfd_tlv_type_s { + u_int8_t main_type; + u_int8_t ext_type; +} dfd_tlv_type_t; + +// Header Field Constants +#define TLV_INFO_ID_STRING "TlvInfo" +#define TLV_INFO_VERSION 0x01 +/*#define TLV_TOTAL_LEN_MAX (XXXXXXXX - sizeof(tlvinfo_header_t))*/ + +struct __attribute__ ((__packed__)) tlvinfo_header_s { + char signature[8]; /* 0x00 - 0x07 EEPROM Tag "TlvInfo" */ + u_int8_t version; /* 0x08 Structure version */ + u_int16_t totallen; /* 0x09 - 0x0A Length of all data which follows */ +}; +typedef struct tlvinfo_header_s tlvinfo_header_t; + +/* + * TlvInfo TLV: Layout of a TLV field + */ +struct __attribute__ ((__packed__)) tlvinfo_tlv_s { + u_int8_t type; + u_int8_t length; + u_int8_t value[0]; +}; +typedef struct tlvinfo_tlv_s tlvinfo_tlv_t; + +#define TLV_VALUE_MAX_LEN 255 +/* + * The max decode value is currently for the 'raw' type or the 'vendor + * extension' type, both of which have the same decode format. The + * max decode string size is computed as follows: + * + * strlen(" 0xFF") * TLV_VALUE_MAX_LEN + 1 + * + */ +#define TLV_DECODE_VALUE_MAX_LEN ((5 * TLV_VALUE_MAX_LEN) + 1) + +typedef struct tlv_decode_value_s { + u_int8_t value[TLV_DECODE_VALUE_MAX_LEN]; + u_int32_t length; +} tlv_decode_value_t; + +typedef enum dfd_tlvinfo_ext_tlv_type_e { + DFD_TLVINFO_EXT_TLV_TYPE_DEV_TYPE = 1, +} dfd_tlvinfo_ext_tlv_type_t; + +#if 0 +#define TLV_TIME_LEN 64 + +int ipmi_tlv_validate_fru_area(const uint8_t fruid, const char *fru_file_name, + sd_bus *bus_type, const bool bmc_fru); + +extern const char *get_vpd_key_names(int key_id); +extern std::string getService(sdbusplus::bus::bus& bus, + const std::string& intf, + const std::string& path); +extern std::string getFRUValue(const std::string& section, + const std::string& key, + const std::string& delimiter, + IPMIFruInfo& fruData); +#endif + +int dfd_tlvinfo_get_e2prom_info(u_int8_t *eeprom, u_int32_t size, dfd_tlv_type_t *tlv_type, u_int8_t* buf, u_int8_t *buf_len); + +#endif /* endif DFD_OPENBMC_TLVEEPROM_H */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/fpga_i2c.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/fpga_i2c.h new file mode 100644 index 000000000000..8271a6706025 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/fpga_i2c.h @@ -0,0 +1,129 @@ +#ifndef _FPGA_I2C_H +#define _FPGA_I2C_H + +#include +#include +#include +#if 0 + +#define FPGA_I2C_EXT_9548_ADDR (0x00) +#define FPGA_I2C_EXT_9548_CHAN (0x04) +#define FPGA_I2C_DEV_SLAVE_ADDR (0x08) +#define FPGA_I2C_DEV_REG_ADDR (0x0C) +#define FPGA_I2C_DEV_RDWR_LEN (0x10) +#define FPGA_I2C_CTRL_REG (0x14) +#define FPGA_I2C_STATUS_REG (0x18) +#define FPGA_I2C_SCALE_REG (0x1C) +#define FPGA_I2C_FILTER_REG (0x20) +#define FPGA_I2C_STRETCH_REG (0x24) +#define FPGA_I2C_EXT_9548_EXITS_FLAG (0x28) +#define FPGA_I2C_INTERNAL_9548_CHAN (0x2C) +#define FPGA_I2C_RDWR_DATA_BUF (0x80) +#endif +#define FPGA_I2C_RDWR_MAX_LEN_DEFAULT (128) +#define I2C_REG_MAX_WIDTH (16) + +#define DEV_NAME_MAX_LEN (64) + +#define FPGA_I2C_MAX_TIMES (10) +#define FPGA_I2C_XFER_TIME_OUT (100000) +#define FPGA_I2C_SLEEP_TIME (40) + +typedef struct fpga_i2c_reg_s { + uint32_t i2c_scale; + uint32_t i2c_filter; + uint32_t i2c_stretch; + uint32_t i2c_ext_9548_exits_flag; + uint32_t i2c_ext_9548_addr; + uint32_t i2c_ext_9548_chan; + uint32_t i2c_in_9548_chan; + uint32_t i2c_slave; + uint32_t i2c_reg; + uint32_t i2c_reg_len; + uint32_t i2c_data_len; + uint32_t i2c_ctrl; + uint32_t i2c_status; + uint32_t i2c_err_vec; + uint32_t i2c_data_buf; + uint32_t i2c_data_buf_len; +} fpga_i2c_reg_t; + +typedef struct fpga_i2c_reset_cfg_s { + uint32_t i2c_adap_reset_flag; + uint32_t reset_addr; + uint32_t reset_on; + uint32_t reset_off; + uint32_t reset_delay_b; + uint32_t reset_delay; + uint32_t reset_delay_a; +} fpga_i2c_reset_cfg_t; + +typedef struct fpga_i2c_reg_addr_s { + uint8_t reg_addr_len; + uint8_t read_reg_addr[I2C_REG_MAX_WIDTH]; +} fpga_i2c_reg_addr_t; + +typedef struct fpga_i2c_dev_s { + fpga_i2c_reg_t reg; + fpga_i2c_reset_cfg_t reset_cfg; + fpga_i2c_reg_addr_t i2c_addr_desc; + const char *dev_name; + uint32_t i2c_scale_value; + uint32_t i2c_filter_value; + uint32_t i2c_stretch_value; + uint32_t i2c_timeout; + uint32_t i2c_func_mode; + wait_queue_head_t queue; + struct i2c_adapter adap; + int adap_nr; + struct device *dev; + bool i2c_params_check; +} fpga_i2c_dev_t; + +typedef struct fpga_i2c_bus_device_s { + int i2c_timeout; + int i2c_scale; + int i2c_filter; + int i2c_stretch; + int i2c_ext_9548_exits_flag; + int i2c_ext_9548_addr; + int i2c_ext_9548_chan; + int i2c_in_9548_chan; + int i2c_slave; + int i2c_reg; + int i2c_reg_len; + int i2c_data_len; + int i2c_ctrl; + int i2c_status; + int i2c_err_vec; + int i2c_data_buf; + int i2c_data_buf_len; + char dev_name[DEV_NAME_MAX_LEN]; + int adap_nr; + int i2c_scale_value; + int i2c_filter_value; + int i2c_stretch_value; + int i2c_func_mode; + int i2c_adap_reset_flag; + int i2c_reset_addr; + int i2c_reset_on; + int i2c_reset_off; + int i2c_rst_delay_b; /* delay time before reset(us) */ + int i2c_rst_delay; /* reset time(us) */ + int i2c_rst_delay_a; /* delay time after reset(us) */ + int device_flag; + bool i2c_params_check; + int i2c_data_buf_len_reg; + int i2c_offset_reg; +} fpga_i2c_bus_device_t; + +typedef struct fpga_pca954x_device_s { + struct i2c_client *client; + uint32_t i2c_bus; + uint32_t i2c_addr; + uint32_t fpga_9548_flag; + uint32_t fpga_9548_reset_flag; + uint32_t pca9548_base_nr; +} fpga_pca954x_device_t; + +#endif /* _FPGA_I2C_H */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_csu550.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_csu550.c new file mode 100644 index 000000000000..4b6794237b2e --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_csu550.c @@ -0,0 +1,203 @@ +/* + * csu550.c - PMBUS for csu550 + * + * Copyright (c) 2018 sonic_rd + * + */ +#include +#include +#include +#include +#include +#include +#include +#include +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,19,152) +#include +#else +#include +#endif +#include +#include +#include "rg_pmbus.h" + +/* + * Find sensor groups and status registers on each page. + */ +static void pmbus_find_sensor_groups(struct i2c_client *client, + struct pmbus_driver_info *info) +{ + int page; + + /* Sensors detected on page 0 only */ + if (rg_pmbus_check_word_register(client, 0, PMBUS_READ_VIN)) + info->func[0] |= PMBUS_HAVE_VIN; + if (rg_pmbus_check_word_register(client, 0, PMBUS_READ_IIN)) + info->func[0] |= PMBUS_HAVE_IIN; + if (rg_pmbus_check_word_register(client, 0, PMBUS_READ_PIN)) + info->func[0] |= PMBUS_HAVE_PIN; + if (info->func[0] + && rg_pmbus_check_byte_register(client, 0, PMBUS_STATUS_INPUT)) + info->func[0] |= PMBUS_HAVE_STATUS_INPUT; + if (rg_pmbus_check_byte_register(client, 0, PMBUS_FAN_CONFIG_12) && + rg_pmbus_check_word_register(client, 0, PMBUS_READ_FAN_SPEED_1)) { + info->func[0] |= PMBUS_HAVE_FAN12; + if (rg_pmbus_check_byte_register(client, 0, PMBUS_STATUS_FAN_12)) + info->func[0] |= PMBUS_HAVE_STATUS_FAN12; + } + if (rg_pmbus_check_word_register(client, 0, PMBUS_READ_TEMPERATURE_1)) + info->func[0] |= PMBUS_HAVE_TEMP; + if (rg_pmbus_check_word_register(client, 0, PMBUS_READ_TEMPERATURE_2)) + info->func[0] |= PMBUS_HAVE_TEMP2; + if (rg_pmbus_check_word_register(client, 0, PMBUS_READ_TEMPERATURE_3)) + info->func[0] |= PMBUS_HAVE_TEMP3; + if (info->func[0] & (PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2 + | PMBUS_HAVE_TEMP3) + && rg_pmbus_check_byte_register(client, 0, + PMBUS_STATUS_TEMPERATURE)) + info->func[0] |= PMBUS_HAVE_STATUS_TEMP; + + /* Sensors detected on all pages */ + for (page = 0; page < info->pages; page++) { + if (rg_pmbus_check_word_register(client, page, PMBUS_READ_VOUT)) { + info->func[page] |= PMBUS_HAVE_VOUT; + if (rg_pmbus_check_byte_register(client, page, + PMBUS_STATUS_VOUT)) + info->func[page] |= PMBUS_HAVE_STATUS_VOUT; + } + if (rg_pmbus_check_word_register(client, page, PMBUS_READ_IOUT)) { + info->func[page] |= PMBUS_HAVE_IOUT; + if (rg_pmbus_check_byte_register(client, 0, + PMBUS_STATUS_IOUT)) + info->func[page] |= PMBUS_HAVE_STATUS_IOUT; + } + if (rg_pmbus_check_word_register(client, page, PMBUS_READ_POUT)) + info->func[page] |= PMBUS_HAVE_POUT; + } +} + +/* + * Identify chip parameters. + */ +static int pmbus_identify(struct i2c_client *client, + struct pmbus_driver_info *info) +{ + int ret = 0; + + if (!info->pages) { + /* + * Check if the PAGE command is supported. If it is, + * keep setting the page number until it fails or until the + * maximum number of pages has been reached. Assume that + * this is the number of pages supported by the chip. + */ + if (rg_pmbus_check_byte_register(client, 0, PMBUS_PAGE)) { + int page; + + for (page = 1; page < PMBUS_PAGES; page++) { + if (rg_pmbus_set_page(client, page) < 0) + break; + } + (void)rg_pmbus_set_page(client, 0); + info->pages = page; + } else { + info->pages = 1; + } + } + + if (rg_pmbus_check_byte_register(client, 0, PMBUS_VOUT_MODE)) { + int vout_mode; + + vout_mode = rg_pmbus_read_byte_data(client, 0, PMBUS_VOUT_MODE); + if (vout_mode >= 0 && vout_mode != 0xff) { + switch (vout_mode >> 5) { + case 0: + break; + case 1: + info->format[PSC_VOLTAGE_OUT] = vid; + break; + case 2: + info->format[PSC_VOLTAGE_OUT] = direct; + break; + default: + ret = -ENODEV; + goto abort; + } + } + } + + /* + * We should check if the COEFFICIENTS register is supported. + * If it is, and the chip is configured for direct mode, we can read + * the coefficients from the chip, one set per group of sensor + * registers. + * + * To do this, we will need access to a chip which actually supports the + * COEFFICIENTS command, since the command is too complex to implement + * without testing it. Until then, abort if a chip configured for direct + * mode was detected. + */ + if (info->format[PSC_VOLTAGE_OUT] == direct) { + ret = -ENODEV; + goto abort; + } + + /* Try to find sensor groups */ + pmbus_find_sensor_groups(client, info); +abort: + return ret; +} + +static int pmbus_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct pmbus_driver_info *info; + struct pmbus_platform_data *pdata = NULL; + struct device *dev = &client->dev; + + info = devm_kzalloc(&client->dev, sizeof(struct pmbus_driver_info), + GFP_KERNEL); + if (!info) + return -ENOMEM; + + if (!strncmp(id->name, "dps460", sizeof("dps460")) || + !strncmp(id->name, "rg_fsp1200", sizeof("rg_fsp1200")) || !strncmp(id->name, "rg_dps550", sizeof("rg_dps550"))) { + pdata = kzalloc(sizeof(struct pmbus_platform_data), GFP_KERNEL); + if (!pdata) { + kfree(info); + return -ENOMEM; + } + pdata->flags = PMBUS_SKIP_STATUS_CHECK; + } + + info->pages = id->driver_data; + info->identify = pmbus_identify; + dev->platform_data = pdata; + + return rg_pmbus_do_probe(client, id, info); +} + +static const struct i2c_device_id pmbus_id[] = { + {"rg_csu550", 0}, + {"rg_csu800", 1}, + {"rg_fsp1200", 1}, + {"rg_dps550", 1}, + {} +}; +MODULE_DEVICE_TABLE(i2c, pmbus_id); + +/* This is the driver that will be inserted */ +static struct i2c_driver pmbus_driver = { + .driver = { + .name = "rg_pmbus", + }, + .probe = pmbus_probe, + .remove = rg_pmbus_do_remove, + .id_table = pmbus_id, +}; + +module_i2c_driver(pmbus_driver); + +MODULE_AUTHOR("sonic_rd "); +MODULE_DESCRIPTION("ruijie psupmbus driver"); +MODULE_LICENSE("GPL"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_eeprom_93xx46.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_eeprom_93xx46.c new file mode 100644 index 000000000000..41d3aab35a33 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_eeprom_93xx46.c @@ -0,0 +1,555 @@ +/* + * Driver for 93xx46 EEPROMs + * + * (C) 2011 DENX Software Engineering, Anatolij Gustschin + * + * 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 +#include +#include + +#define OP_START 0x4 +#define OP_WRITE (OP_START | 0x1) +#define OP_READ (OP_START | 0x2) +#define ADDR_EWDS 0x00 +#define ADDR_ERAL 0x20 +#define ADDR_EWEN 0x30 + +static int g_rg_eeprom_93xx46_debug = 0; + +module_param(g_rg_eeprom_93xx46_debug, int, S_IRUGO | S_IWUSR); + +#define SPI_93xx46_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_rg_eeprom_93xx46_debug) { \ + printk(KERN_INFO "[EEPROM-93xx46][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +struct eeprom_93xx46_devtype_data { + unsigned int quirks; +}; + +static const struct eeprom_93xx46_devtype_data atmel_at93c46d_data = { + .quirks = EEPROM_93XX46_QUIRK_SINGLE_WORD_READ | + EEPROM_93XX46_QUIRK_INSTRUCTION_LENGTH, +}; + +struct eeprom_93xx46_dev { + struct spi_device *spi; + struct eeprom_93xx46_platform_data *pdata; + struct mutex lock; + struct nvmem_config nvmem_config; + struct nvmem_device *nvmem; + int addrlen; + int size; +}; + +static inline bool has_quirk_single_word_read(struct eeprom_93xx46_dev *edev) +{ + return edev->pdata->quirks & EEPROM_93XX46_QUIRK_SINGLE_WORD_READ; +} + +static inline bool has_quirk_instruction_length(struct eeprom_93xx46_dev *edev) +{ + return edev->pdata->quirks & EEPROM_93XX46_QUIRK_INSTRUCTION_LENGTH; +} + +static int eeprom_93xx46_read(void *priv, unsigned int off, + void *val, size_t count) +{ + struct eeprom_93xx46_dev *edev = priv; + char *buf = val; + int err = 0; + + if (unlikely(off >= edev->size)) + return 0; + if ((off + count) > edev->size) + count = edev->size - off; + if (unlikely(!count)) + return count; + + mutex_lock(&edev->lock); + + if (edev->pdata->prepare) + edev->pdata->prepare(edev); + + while (count) { + struct spi_message m; + struct spi_transfer t[2] = { { 0 } }; + u16 cmd_addr = OP_READ << edev->addrlen; + size_t nbytes = count; + int bits; + int data_bit; + + if (edev->addrlen == 7) { + cmd_addr |= off & 0x7f; + bits = 10; + data_bit = 8; + if (has_quirk_single_word_read(edev)) + nbytes = 1; + } else { + cmd_addr |= (off >> 1) & 0x3f; + bits = 9; + data_bit = 16; + if (has_quirk_single_word_read(edev)) + nbytes = 2; + } + + dev_dbg(&edev->spi->dev, "read cmd 0x%x, %d Hz\n", + cmd_addr, edev->spi->max_speed_hz); + + spi_message_init(&m); + + t[0].tx_buf = (char *)&cmd_addr; + t[0].len = 2; + t[0].bits_per_word = bits; + spi_message_add_tail(&t[0], &m); + + t[1].rx_buf = buf; + t[1].len = nbytes; + t[1].bits_per_word = data_bit; + spi_message_add_tail(&t[1], &m); + + err = spi_sync(edev->spi, &m); + /* have to wait at least Tcsl ns */ + ndelay(250); + + if (err) { + dev_err(&edev->spi->dev, "read %zu bytes at %d: err. %d\n", + nbytes, (int)off, err); + break; + } + + buf += nbytes; + off += nbytes; + count -= nbytes; + } + + if (edev->pdata->finish) + edev->pdata->finish(edev); + + mutex_unlock(&edev->lock); + + return err; +} + +static int eeprom_93xx46_ew(struct eeprom_93xx46_dev *edev, int is_on) +{ + struct spi_message m; + struct spi_transfer t; + int bits, ret; + u16 cmd_addr; + + cmd_addr = OP_START << edev->addrlen; + if (edev->addrlen == 7) { + cmd_addr |= (is_on ? ADDR_EWEN : ADDR_EWDS) << 1; + bits = 10; + } else { + cmd_addr |= (is_on ? ADDR_EWEN : ADDR_EWDS); + bits = 9; + } + + if (has_quirk_instruction_length(edev)) { + cmd_addr <<= 2; + bits += 2; + } + + dev_dbg(&edev->spi->dev, "ew%s cmd 0x%04x, %d bits\n", + is_on ? "en" : "ds", cmd_addr, bits); + + spi_message_init(&m); + memset(&t, 0, sizeof(t)); + + t.tx_buf = &cmd_addr; + t.len = 2; + t.bits_per_word = bits; + spi_message_add_tail(&t, &m); + + mutex_lock(&edev->lock); + + if (edev->pdata->prepare) + edev->pdata->prepare(edev); + + ret = spi_sync(edev->spi, &m); + /* have to wait at least Tcsl ns */ + ndelay(250); + if (ret) + dev_err(&edev->spi->dev, "erase/write %sable error %d\n", + is_on ? "en" : "dis", ret); + + if (edev->pdata->finish) + edev->pdata->finish(edev); + + mutex_unlock(&edev->lock); + return ret; +} + +static ssize_t +eeprom_93xx46_write_word(struct eeprom_93xx46_dev *edev, + char *buf, unsigned off) +{ + struct spi_message m; + struct spi_transfer t[2]; + int bits, data_len, ret; + u16 cmd_addr; + int data_bit; + + cmd_addr = OP_WRITE << edev->addrlen; + + if (edev->addrlen == 7) { + cmd_addr |= off & 0x7f; + bits = 10; + data_len = 1; + data_bit = 8; + } else { + cmd_addr |= (off >> 1) & 0x3f; + bits = 9; + data_len = 2; + data_bit = 16; + } + + dev_dbg(&edev->spi->dev, "write cmd 0x%x\n", cmd_addr); + + spi_message_init(&m); + memset(t, 0, sizeof(t)); + + t[0].tx_buf = (char *)&cmd_addr; + t[0].len = 2; + t[0].bits_per_word = bits; + spi_message_add_tail(&t[0], &m); + + t[1].tx_buf = buf; + t[1].len = data_len; + t[1].bits_per_word = data_bit; + spi_message_add_tail(&t[1], &m); + + ret = spi_sync(edev->spi, &m); + /* have to wait program cycle time Twc ms */ + mdelay(6); + return ret; +} + +static int eeprom_93xx46_write(void *priv, unsigned int off, + void *val, size_t count) +{ + struct eeprom_93xx46_dev *edev = priv; + char *buf = val; + int i, ret, step = 1; + + if (unlikely(off >= edev->size)) + return -EFBIG; + if ((off + count) > edev->size) + count = edev->size - off; + if (unlikely(!count)) + return count; + + /* only write even number of bytes on 16-bit devices */ + if (edev->addrlen == 6) { + step = 2; + count &= ~1; + } + + /* erase/write enable */ + ret = eeprom_93xx46_ew(edev, 1); + if (ret) + return ret; + + mutex_lock(&edev->lock); + + if (edev->pdata->prepare) + edev->pdata->prepare(edev); + + for (i = 0; i < count; i += step) { + ret = eeprom_93xx46_write_word(edev, &buf[i], off + i); + if (ret) { + dev_err(&edev->spi->dev, "write failed at %d: %d\n", + (int)off + i, ret); + break; + } + } + + if (edev->pdata->finish) + edev->pdata->finish(edev); + + mutex_unlock(&edev->lock); + + /* erase/write disable */ + eeprom_93xx46_ew(edev, 0); + return ret; +} + +static int eeprom_93xx46_eral(struct eeprom_93xx46_dev *edev) +{ + struct eeprom_93xx46_platform_data *pd = edev->pdata; + struct spi_message m; + struct spi_transfer t; + int bits, ret; + u16 cmd_addr; + + cmd_addr = OP_START << edev->addrlen; + if (edev->addrlen == 7) { + cmd_addr |= ADDR_ERAL << 1; + bits = 10; + } else { + cmd_addr |= ADDR_ERAL; + bits = 9; + } + + if (has_quirk_instruction_length(edev)) { + cmd_addr <<= 2; + bits += 2; + } + + dev_dbg(&edev->spi->dev, "eral cmd 0x%04x, %d bits\n", cmd_addr, bits); + + spi_message_init(&m); + memset(&t, 0, sizeof(t)); + + t.tx_buf = &cmd_addr; + t.len = 2; + t.bits_per_word = bits; + spi_message_add_tail(&t, &m); + + mutex_lock(&edev->lock); + + if (edev->pdata->prepare) + edev->pdata->prepare(edev); + + ret = spi_sync(edev->spi, &m); + if (ret) + dev_err(&edev->spi->dev, "erase error %d\n", ret); + /* have to wait erase cycle time Tec ms */ + mdelay(6); + + if (pd->finish) + pd->finish(edev); + + mutex_unlock(&edev->lock); + return ret; +} + +static ssize_t eeprom_93xx46_store_erase(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct eeprom_93xx46_dev *edev = dev_get_drvdata(dev); + int erase = 0, ret; + + sscanf(buf, "%d", &erase); + if (erase) { + ret = eeprom_93xx46_ew(edev, 1); + if (ret) + return ret; + ret = eeprom_93xx46_eral(edev); + if (ret) + return ret; + ret = eeprom_93xx46_ew(edev, 0); + if (ret) + return ret; + } + return count; +} +static DEVICE_ATTR(erase, S_IWUSR, NULL, eeprom_93xx46_store_erase); + +static void select_assert(void *context) +{ + struct eeprom_93xx46_dev *edev = context; + + gpiod_set_value_cansleep(edev->pdata->select, 1); +} + +static void select_deassert(void *context) +{ + struct eeprom_93xx46_dev *edev = context; + + gpiod_set_value_cansleep(edev->pdata->select, 0); +} + +static const struct of_device_id eeprom_93xx46_of_table[] = { + { .compatible = "eeprom-93xx46", }, + { .compatible = "atmel,at93c46d", .data = &atmel_at93c46d_data, }, + {} +}; +MODULE_DEVICE_TABLE(of, eeprom_93xx46_of_table); + +static int eeprom_93xx46_probe_dt(struct spi_device *spi) +{ + const struct of_device_id *of_id = + of_match_device(eeprom_93xx46_of_table, &spi->dev); + struct device_node *np = spi->dev.of_node; + struct eeprom_93xx46_platform_data *pd; + u32 tmp; + int gpio; + enum of_gpio_flags of_flags; + int ret; + + pd = devm_kzalloc(&spi->dev, sizeof(*pd), GFP_KERNEL); + if (!pd) + return -ENOMEM; + + ret = of_property_read_u32(np, "data-size", &tmp); + if (ret < 0) { + dev_err(&spi->dev, "data-size property not found\n"); + return ret; + } + + if (tmp == 8) { + pd->flags |= EE_ADDR8; + } else if (tmp == 16) { + pd->flags |= EE_ADDR16; + } else { + dev_err(&spi->dev, "invalid data-size (%d)\n", tmp); + return -EINVAL; + } + + if (of_property_read_bool(np, "read-only")) + pd->flags |= EE_READONLY; + + gpio = of_get_named_gpio_flags(np, "select-gpios", 0, &of_flags); + if (gpio_is_valid(gpio)) { + unsigned long flags = + of_flags == OF_GPIO_ACTIVE_LOW ? GPIOF_ACTIVE_LOW : 0; + + ret = devm_gpio_request_one(&spi->dev, gpio, flags, + "eeprom_93xx46_select"); + if (ret) + return ret; + + pd->select = gpio_to_desc(gpio); + pd->prepare = select_assert; + pd->finish = select_deassert; + + gpiod_direction_output(pd->select, 0); + } + + if (of_id) { + if (of_id->data) { + const struct eeprom_93xx46_devtype_data *data = of_id->data; + + pd->quirks = data->quirks; + } + } + + spi->dev.platform_data = pd; + + return 0; +} + +static int eeprom_93xx46_probe(struct spi_device *spi) +{ + struct eeprom_93xx46_platform_data *pd; + struct eeprom_93xx46_dev *edev; + int err; + + if (spi->dev.of_node) { + err = eeprom_93xx46_probe_dt(spi); + if (err < 0) + return err; + } + + pd = spi->dev.platform_data; + if (!pd) { + dev_err(&spi->dev, "missing platform data\n"); + return -ENODEV; + } + + edev = kzalloc(sizeof(*edev), GFP_KERNEL); + if (!edev) + return -ENOMEM; + + if (pd->flags & EE_ADDR8) + edev->addrlen = 7; + else if (pd->flags & EE_ADDR16) + edev->addrlen = 6; + else { + dev_err(&spi->dev, "unspecified address type\n"); + err = -EINVAL; + goto fail; + } + + mutex_init(&edev->lock); + + edev->spi = spi; + edev->pdata = pd; + + edev->size = 128; + edev->nvmem_config.name = dev_name(&spi->dev); + edev->nvmem_config.dev = &spi->dev; + edev->nvmem_config.read_only = pd->flags & EE_READONLY; + edev->nvmem_config.root_only = true; + edev->nvmem_config.owner = THIS_MODULE; + edev->nvmem_config.compat = true; + edev->nvmem_config.base_dev = &spi->dev; + edev->nvmem_config.reg_read = eeprom_93xx46_read; + edev->nvmem_config.reg_write = eeprom_93xx46_write; + edev->nvmem_config.priv = edev; + edev->nvmem_config.stride = 4; + edev->nvmem_config.word_size = 1; + edev->nvmem_config.size = edev->size; + + edev->nvmem = nvmem_register(&edev->nvmem_config); + if (IS_ERR(edev->nvmem)) { + err = PTR_ERR(edev->nvmem); + goto fail; + } + + if (g_rg_eeprom_93xx46_debug) { + dev_info(&spi->dev, "%d-bit eeprom %s\n", + (pd->flags & EE_ADDR8) ? 8 : 16, + (pd->flags & EE_READONLY) ? "(readonly)" : ""); + } + + if (!(pd->flags & EE_READONLY)) { + if (device_create_file(&spi->dev, &dev_attr_erase)) + dev_err(&spi->dev, "can't create erase interface\n"); + } + + spi_set_drvdata(spi, edev); + return 0; +fail: + kfree(edev); + return err; +} + +static int eeprom_93xx46_remove(struct spi_device *spi) +{ + struct eeprom_93xx46_dev *edev = spi_get_drvdata(spi); + + nvmem_unregister(edev->nvmem); + + if (!(edev->pdata->flags & EE_READONLY)) + device_remove_file(&spi->dev, &dev_attr_erase); + + kfree(edev); + return 0; +} + +static struct spi_driver rg_eeprom_93xx46_driver = { + .driver = { + .name = "rg_93xx46", + .of_match_table = of_match_ptr(eeprom_93xx46_of_table), + }, + .probe = eeprom_93xx46_probe, + .remove = eeprom_93xx46_remove, +}; + +module_spi_driver(rg_eeprom_93xx46_driver); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("Driver for 93xx46 EEPROMs"); +MODULE_AUTHOR("Anatolij Gustschin "); +MODULE_ALIAS("spi:93xx46"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_fpga_i2c_bus_drv.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_fpga_i2c_bus_drv.c new file mode 100644 index 000000000000..18b2b341fe9b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_fpga_i2c_bus_drv.c @@ -0,0 +1,1106 @@ +/* + * Copyright(C) 2016 Ruijie Network. All rights reserved. + * + * fpga_i2c_bus_drv.c + * ko to create fpga i2c adapter + * Original Author: sonic_rd@ruijie.com.cn 2020-08-10 + */ +#include +#include +#include +#include +#include +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,12,0) +#include +#endif +#include +#include +#include +#include +#include +#include +#include "fpga_i2c.h" + +#include +#include + +#define DRV_NAME "rg-fpga-i2c" +#define DRV_VERSION "1.0" +#define DTS_NO_CFG_FLAG (0) + +extern int i2c_device_func_write(const char *path, uint32_t pos, uint8_t *val, size_t size); +extern int i2c_device_func_read(const char *path, uint32_t pos, uint8_t *val, size_t size); +extern int pcie_device_func_read(const char *path, uint32_t offset, uint8_t *buf, size_t count); +extern int pcie_device_func_write(const char *path, uint32_t offset, uint8_t *buf, size_t count); + +#define FPGA_I2C_STRETCH_TIMEOUT (0x01) +#define FPGA_I2C_DEADLOCK_FAILED (0x02) +#define FPGA_I2C_SLAVE_NO_RESPOND (0x03) +#define FPGA_I2C_STA_FAIL (0x01) +#define FPGA_I2C_STA_BUSY (0x02) +#define FPGA_I2C_CTL_BG (0x01 << 1) +#define FPGA_I2C_CTL_NO_REG (0x01 << 2) +#define FPGA_I2C_CTL_RD (0x01) +#define FPGA_I2C_CTL_WR (0x00) +#define I2C_READ_MSG_NUM (0x02) +#define I2C_WRITE_MSG_NUM (0x01) +#define FPGA_REG_WIDTH (4) + +#define SYMBOL_I2C_DEV_MODE (1) +#define FILE_MODE (2) +#define SYMBOL_PCIE_DEV_MODE (3) +#define SYMBOL_IO_DEV_MODE (4) + +int g_rg_fpga_i2c_debug = 0; +int g_rg_fpga_i2c_error = 0; + +module_param(g_rg_fpga_i2c_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_fpga_i2c_error, int, S_IRUGO | S_IWUSR); + +#define FPGA_I2C_VERBOSE(fmt, args...) do { \ + if (g_rg_fpga_i2c_debug) { \ + printk(KERN_INFO "[FPFA_I2C_BUS][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define FPGA_I2C_ERROR(fmt, args...) do { \ + if (g_rg_fpga_i2c_error) { \ + printk(KERN_ERR "[FPFA_I2C_BUS][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static int fpga_file_read(const char *path, uint32_t pos, uint8_t *val, size_t size) +{ + int ret; + struct file *filp; + loff_t tmp_pos; + + filp = filp_open(path, O_RDONLY, 0); + if (IS_ERR(filp)) { + FPGA_I2C_ERROR("read open failed errno = %ld\r\n", -PTR_ERR(filp)); + filp = NULL; + goto exit; + } + + tmp_pos = (loff_t)pos; + ret = kernel_read(filp, val, size, &tmp_pos); + if (ret < 0) { + FPGA_I2C_ERROR("kernel_read failed, path=%s, addr=0x%x, size=%ld, ret=%d\r\n", path, pos, size, ret); + goto exit; + } + + filp_close(filp, NULL); + + return ret; + +exit: + if (filp != NULL) { + filp_close(filp, NULL); + } + + return -1; +} + +static int fpga_file_write(const char *path, uint32_t pos, uint8_t *val, size_t size) +{ + int ret; + struct file *filp; + loff_t tmp_pos; + + filp = filp_open(path, O_RDWR, 777); + if (IS_ERR(filp)) { + FPGA_I2C_ERROR("write open failed errno = %ld\r\n", -PTR_ERR(filp)); + filp = NULL; + goto exit; + } + + tmp_pos = (loff_t)pos; + ret = kernel_write(filp, val, size, &tmp_pos); + if (ret < 0) { + FPGA_I2C_ERROR("kernel_write failed, path=%s, addr=0x%x, size=%ld, ret=%d\r\n", path, pos, size, ret); + goto exit; + } + vfs_fsync(filp, 1); + filp_close(filp, NULL); + + return ret; + +exit: + if (filp != NULL) { + filp_close(filp, NULL); + } + + return -1; +} + +static int fpga_device_write(fpga_i2c_dev_t *fpga_i2c, uint32_t pos, uint8_t *val, size_t size) +{ + int ret; + + switch (fpga_i2c->i2c_func_mode) { + case SYMBOL_I2C_DEV_MODE: + ret = i2c_device_func_write(fpga_i2c->dev_name, pos, val, size); + break; + case FILE_MODE: + ret = fpga_file_write(fpga_i2c->dev_name, pos, val, size); + break; + case SYMBOL_PCIE_DEV_MODE: + ret = pcie_device_func_write(fpga_i2c->dev_name, pos, val, size); + break; + default: + FPGA_I2C_ERROR("err func_mode, write failed.\n"); + return -EINVAL; + } + return ret; + +} + +static int fpga_device_read(fpga_i2c_dev_t *fpga_i2c, uint32_t pos, uint8_t *val, size_t size) +{ + int ret; + + switch (fpga_i2c->i2c_func_mode) { + case SYMBOL_I2C_DEV_MODE: + ret = i2c_device_func_read(fpga_i2c->dev_name, pos, val, size); + break; + case FILE_MODE: + ret = fpga_file_read(fpga_i2c->dev_name, pos, val, size); + break; + case SYMBOL_PCIE_DEV_MODE: + ret = pcie_device_func_read(fpga_i2c->dev_name, pos, val, size); + break; + default: + FPGA_I2C_ERROR("err func_mode, read failed.\n"); + return -EINVAL; + } + + return ret; +} + +static int little_endian_dword_to_buf(uint8_t *buf, int len, uint32_t dword) +{ + uint8_t tmp_buf[FPGA_REG_WIDTH]; + + if (len < 4) { + FPGA_I2C_ERROR("Not enough buf, dword to buf: len[%d], dword[0x%x]\n", len, dword); + return -1; + } + + memset(tmp_buf, 0, sizeof(tmp_buf)); + tmp_buf[0] = dword & 0xff; + tmp_buf[1] = (dword >> 8) & 0xff; + tmp_buf[2] = (dword >> 16) & 0xff; + tmp_buf[3] = (dword >> 24) & 0xff; + + memcpy(buf, tmp_buf, sizeof(tmp_buf)); + + return 0; +} + +static int little_endian_buf_to_dword(uint8_t *buf, int len, uint32_t *dword) +{ + int i; + uint32_t dword_tmp; + + if (len != FPGA_REG_WIDTH) { + FPGA_I2C_ERROR("buf length %d error, can't convert to dowrd.\n", len); + return -1; + } + dword_tmp = 0; + for (i = 0; i < FPGA_REG_WIDTH; i++) { + dword_tmp |= (buf[i] << (i * 8)); + } + *dword = dword_tmp; + return 0; +} + +static int fpga_reg_write(fpga_i2c_dev_t *fpga_i2c, uint32_t addr, uint8_t val) +{ + int ret; + + ret = fpga_device_write(fpga_i2c, addr, &val, sizeof(uint8_t)); + if (ret < 0) { + FPGA_I2C_ERROR("fpga reg write failed, dev name:%s, offset:0x%x, value:0x%x.\n", + fpga_i2c->dev_name, addr, val); + return -EIO; + } + + FPGA_I2C_VERBOSE("fpga reg write success, dev name:%s, offset:0x%x, value:0x%x.\n", + fpga_i2c->dev_name, addr, val); + return 0; +} + +static int fpga_reg_read(fpga_i2c_dev_t *fpga_i2c, uint32_t addr, uint8_t *val) +{ + int ret; + + ret = fpga_device_read(fpga_i2c, addr, val, sizeof(uint8_t)); + if (ret < 0) { + FPGA_I2C_ERROR("fpga reg read failed, dev name:%s, offset:0x%x\n", + fpga_i2c->dev_name, addr); + return -EIO; + } + + FPGA_I2C_VERBOSE("fpga reg read success, dev name:%s, offset:0x%x, value:0x%x.\n", + fpga_i2c->dev_name, addr, *val); + return 0; +} + +static int fpga_data_write(fpga_i2c_dev_t *fpga_i2c, uint32_t addr, uint8_t *val, size_t size) +{ + int ret; + + ret = fpga_device_write(fpga_i2c, addr, val, size); + if (ret < 0) { + FPGA_I2C_ERROR("fpga data write failed, dev name:%s, offset:0x%x, size:%lu.\n", + fpga_i2c->dev_name, addr, size); + return -EIO; + } + + FPGA_I2C_VERBOSE("fpga data write success, dev name:%s, offset:0x%x, size:%lu.\n", + fpga_i2c->dev_name, addr, size); + return 0; +} + +static int fpga_data_read(fpga_i2c_dev_t *fpga_i2c, uint32_t addr, uint8_t *val, size_t size) +{ + int ret; + + ret = fpga_device_read(fpga_i2c, addr, val, size); + if (ret < 0) { + FPGA_I2C_ERROR("fpga data read failed, dev name:%s, offset:0x%x, size:%lu.\n", + fpga_i2c->dev_name, addr, size); + return -EIO; + } + + FPGA_I2C_VERBOSE("fpga data read success, dev name:%s, offset:0x%x, size:%lu.\n", + fpga_i2c->dev_name, addr, size); + return 0; +} + +static int fpga_reg_write_32(fpga_i2c_dev_t *fpga_i2c, uint32_t addr, uint32_t val) +{ + int ret; + uint8_t buf[FPGA_REG_WIDTH]; + + memset(buf, 0, sizeof(buf)); + little_endian_dword_to_buf(buf, sizeof(buf), val); + ret = fpga_device_write(fpga_i2c, addr, buf, sizeof(buf)); + if (ret < 0) { + FPGA_I2C_ERROR("fpga reg write failed, dev name: %s, offset: 0x%x, value: 0x%x.\n", + fpga_i2c->dev_name, addr, val); + return -EIO; + } + + FPGA_I2C_VERBOSE("fpga reg write success, dev name: %s, offset: 0x%x, value: 0x%x.\n", + fpga_i2c->dev_name, addr, val); + return 0; +} + +static int fpga_reg_read_32(fpga_i2c_dev_t *fpga_i2c, uint32_t addr, uint32_t *val) +{ + int ret; + uint8_t buf[FPGA_REG_WIDTH]; + + memset(buf, 0, sizeof(buf)); + ret = fpga_device_read(fpga_i2c, addr, buf, sizeof(buf)); + if (ret < 0) { + FPGA_I2C_ERROR("fpga reg read failed, dev name: %s, offset: 0x%x, ret: %d\n", + fpga_i2c->dev_name, addr, ret); + return -EIO; + } + little_endian_buf_to_dword(buf, sizeof(buf), val); + FPGA_I2C_VERBOSE("fpga reg read success, dev name: %s, offset: 0x%x, value: 0x%x.\n", + fpga_i2c->dev_name, addr, *val); + return 0; +} + +static int fpga_i2c_is_busy(fpga_i2c_dev_t *fpga_i2c) +{ + uint8_t val; + int ret; + fpga_i2c_reg_t *reg; + + reg = &fpga_i2c->reg; + ret = fpga_reg_read(fpga_i2c, reg->i2c_status, &val); + if (ret < 0 ) { + FPGA_I2C_ERROR("read fpga i2c status reg failed, reg addr:0x%x, ret:%d.\n", + reg->i2c_status, ret); + return 1; + } + if (val & FPGA_I2C_STA_BUSY) { + FPGA_I2C_ERROR("fpga i2c status busy, reg addr:0x%x, value:0x%x.\n", + reg->i2c_status, val); + return 1; + } else { + return 0; + } +} + +static int fpga_i2c_wait(fpga_i2c_dev_t *fpga_i2c) +{ + int retry_cnt; + + retry_cnt = FPGA_I2C_XFER_TIME_OUT/FPGA_I2C_SLEEP_TIME; + while (retry_cnt--) { + if (fpga_i2c_is_busy(fpga_i2c)) { + usleep_range(FPGA_I2C_SLEEP_TIME, FPGA_I2C_SLEEP_TIME + 1); + } else { + return 0; + } + } + + return -EBUSY; +} + +static int fpga_i2c_check_status(fpga_i2c_dev_t *fpga_i2c) +{ + uint8_t data; + int ret; + fpga_i2c_reg_t *reg; + + reg = &fpga_i2c->reg; + + ret = fpga_reg_read(fpga_i2c, reg->i2c_status, &data); + if (ret) { + FPGA_I2C_ERROR("read fpga i2c status reg failed, reg addr:0x%x, ret:%d.\n", + reg->i2c_status, ret); + return ret; + } + + if (data & FPGA_I2C_STA_FAIL) { + FPGA_I2C_ERROR("fpga i2c status error, reg addr:0x%x, value:%d.\n", + reg->i2c_status, data); + + /* read i2c_err_vec to confirm err type*/ + if (reg->i2c_err_vec != DTS_NO_CFG_FLAG) { + /* read i2c_err_vec reg */ + ret = fpga_reg_read(fpga_i2c, reg->i2c_err_vec, &data); + if (ret) { + FPGA_I2C_ERROR("read fpga i2c err vec reg failed, reg addr:0x%x, ret:%d.\n", + reg->i2c_err_vec, ret); + return ret; + } + FPGA_I2C_VERBOSE("get i2c err vec, reg addr:0x%x, read value:0x%x\n", reg->i2c_err_vec, data); + + /* match i2c_err_vec reg value and err type*/ + switch (data) { + case FPGA_I2C_STRETCH_TIMEOUT: + ret = -ETIMEDOUT; + break; + case FPGA_I2C_DEADLOCK_FAILED: + ret = -EDEADLK; + break; + case FPGA_I2C_SLAVE_NO_RESPOND: + ret = -ENXIO; + break; + default: + FPGA_I2C_ERROR("get i2c err vec value out of range, reg addr:0x%x, read value:0x%x\n", + reg->i2c_err_vec, data); + ret = -EREMOTEIO; + break; + } + return ret; + } else { + FPGA_I2C_VERBOSE("i2c err vec not config, fpga i2c status check return -1\n"); + return -EREMOTEIO; + } + } + return 0; +} + +static int fpga_i2c_do_work(fpga_i2c_dev_t *fpga_i2c, int i2c_addr, + unsigned char *data, uint32_t length, int is_read) +{ + int ret, i; + uint8_t op, i2c_reg_addr_len; + uint8_t *i2c_read_addr_buf; + fpga_i2c_reg_t *reg; + fpga_i2c_reg_addr_t *i2c_addr_desc; + + reg = &fpga_i2c->reg; + + ret = fpga_reg_write(fpga_i2c, reg->i2c_slave, i2c_addr); + if (ret) { + FPGA_I2C_ERROR("write fpga i2c slave reg failed, reg addr:0x%x, value:0x%x, ret:%d.\n", + reg->i2c_slave, i2c_addr, ret); + goto exit; + } + + i2c_addr_desc = &fpga_i2c->i2c_addr_desc; + i2c_reg_addr_len = i2c_addr_desc->reg_addr_len; + i2c_read_addr_buf = &i2c_addr_desc->read_reg_addr[0]; + + if (i2c_reg_addr_len > 0 && i2c_reg_addr_len <= I2C_REG_MAX_WIDTH) { + ret = fpga_data_write(fpga_i2c, reg->i2c_reg, i2c_read_addr_buf, i2c_reg_addr_len); + if (ret) { + FPGA_I2C_ERROR("write fpga i2c offset reg failed, fpga addr:0x%x, reg len:%d, ret:%d\n", + reg->i2c_reg, i2c_reg_addr_len, ret); + for (i = 0; i < i2c_reg_addr_len; i++) { + FPGA_I2C_ERROR("%02d : %02x\n", i, i2c_read_addr_buf[i]); + } + goto exit; + } + } + + ret = fpga_reg_write_32(fpga_i2c, reg->i2c_data_len, length); + if (ret) { + FPGA_I2C_ERROR("write fpga i2c date len reg failed, reg addr:0x%x, value:0x%x, ret:%d.\n", + reg->i2c_data_len, length, ret); + goto exit; + } + + ret = fpga_reg_write(fpga_i2c, reg->i2c_reg_len, i2c_reg_addr_len); + if (ret) { + FPGA_I2C_ERROR("write fpga i2c reg len reg failed, reg addr:0x%x, value:0x%x, ret:%d.\n", + reg->i2c_reg_len, i2c_reg_addr_len, ret); + goto exit; + } + + if (is_read) { + op = FPGA_I2C_CTL_RD | FPGA_I2C_CTL_BG; + } else { + + ret = fpga_data_write(fpga_i2c, reg->i2c_data_buf, data, length); + if (ret) { + FPGA_I2C_ERROR("write fpga i2c date buf failed, reg addr:0x%x, write len:%d, ret:%d.\n", + reg->i2c_data_buf, length, ret); + goto exit; + } + op = FPGA_I2C_CTL_WR | FPGA_I2C_CTL_BG ; + } + + ret = fpga_reg_write(fpga_i2c, reg->i2c_ctrl, op); + if (ret) { + FPGA_I2C_ERROR("write fpga i2c control reg failed, reg addr:0x%x, value:%d, ret:%d.\n", + reg->i2c_ctrl, op, ret); + goto exit; + } + + ret = fpga_i2c_wait(fpga_i2c); + if (ret) { + FPGA_I2C_ERROR("wait fpga i2c status timeout.\n"); + goto exit; + } + + ret = fpga_i2c_check_status(fpga_i2c); + if (ret) { + FPGA_I2C_ERROR("check fpga i2c status error.\n"); + goto exit; + } + + if (is_read) { + + ret = fpga_data_read(fpga_i2c, reg->i2c_data_buf, data, length); + if (ret) { + FPGA_I2C_ERROR("read fpga i2c data buf failed, reg addr:0x%x, read len:%d, ret:%d.\n", + reg->i2c_data_buf, length, ret); + goto exit; + } + } + +exit: + return ret; +} + +static int fpga_i2c_write(fpga_i2c_dev_t *fpga_i2c, int target, + u8 *data, int length, int i2c_msg_num) +{ + int ret, i; + fpga_i2c_reg_addr_t *i2c_addr_desc; + + if (i2c_msg_num == I2C_READ_MSG_NUM) { + + if (length > I2C_REG_MAX_WIDTH) { + FPGA_I2C_ERROR("read reg addr len %d, more than max length.\n", length); + return -EINVAL; + } + + i2c_addr_desc = &fpga_i2c->i2c_addr_desc; + for (i = 0; i < length; i++) { + i2c_addr_desc->read_reg_addr[i] = data[length -i -1]; + FPGA_I2C_VERBOSE("%02d : %02x\n", i, i2c_addr_desc->read_reg_addr[i]); + } + i2c_addr_desc->reg_addr_len = length; + ret = 0; + } else { + + ret = fpga_i2c_do_work(fpga_i2c, target, data, length, 0); + } + + return ret; +} + +/** + * fpga_i2c_read - receive data from the bus. + * @i2c: The struct fpga_i2c_dev_t. + * @target: Target address. + * @data: Pointer to the location to store the datae . + * @length: Length of the data. + * + * The address is sent over the bus, then the data is read. + * + * Returns 0 on success, otherwise a negative errno. + */ +static int fpga_i2c_read(fpga_i2c_dev_t *fpga_i2c, int target, + u8 *data, int length) +{ + int ret, offset_size; + int i, tmp_val; + fpga_i2c_reg_addr_t *i2c_addr_desc; + uint8_t i2c_reg_addr_len; + uint8_t *i2c_read_addr_buf; + + offset_size = 0; + i2c_addr_desc = &fpga_i2c->i2c_addr_desc; + i2c_reg_addr_len = i2c_addr_desc->reg_addr_len; + i2c_read_addr_buf = &i2c_addr_desc->read_reg_addr[0]; + + while (1) { + if (length <= fpga_i2c->reg.i2c_data_buf_len) { + return fpga_i2c_do_work(fpga_i2c, target, data + offset_size, length, 1); + } + + ret = fpga_i2c_do_work(fpga_i2c, target, data + offset_size, fpga_i2c->reg.i2c_data_buf_len, 1); + if (ret != 0) { + FPGA_I2C_ERROR("fpga_i2c_read failed, i2c addr:0x%x, offset:0x%x, ret:%d.\n", + target, offset_size, ret); + return ret; + } + + tmp_val = i2c_read_addr_buf[0]; + tmp_val += fpga_i2c->reg.i2c_data_buf_len; + if (tmp_val > 0xff) { + i2c_read_addr_buf[0] = tmp_val & 0xff; + for (i = 1; i < i2c_reg_addr_len; i++) { + if (i2c_read_addr_buf[i] == 0xff) { + i2c_read_addr_buf[i] = 0; + } else { + i2c_read_addr_buf[i]++; + break; + } + } + } else { + i2c_read_addr_buf[0] = tmp_val & 0xff; + } + offset_size += fpga_i2c->reg.i2c_data_buf_len; + length -= fpga_i2c->reg.i2c_data_buf_len; + } + + return ret; +} + +static void fpga_i2c_reset(fpga_i2c_dev_t *fpga_i2c) { + fpga_i2c_reset_cfg_t *reset_cfg; + uint32_t reset_addr; + + reset_cfg = &fpga_i2c->reset_cfg; + reset_addr = reset_cfg->reset_addr; + if (reset_cfg->reset_delay_b) { + usleep_range(reset_cfg->reset_delay_b, reset_cfg->reset_delay_b + 1); + } + + fpga_reg_write_32(fpga_i2c, reset_addr, reset_cfg->reset_on); + if (reset_cfg->reset_delay) { + usleep_range(reset_cfg->reset_delay, reset_cfg->reset_delay + 1); + } + + fpga_reg_write_32(fpga_i2c, reset_addr, reset_cfg->reset_off); + if (reset_cfg->reset_delay_a) { + usleep_range(reset_cfg->reset_delay_a, reset_cfg->reset_delay_a + 1); + } + + return; +} + +/** + * fpga_i2c_xfer - The driver's master_xfer function. + * @adap: Pointer to the i2c_adapter structure. + * @msgs: Pointer to the messages to be processed. + * @num: Length of the MSGS array. + * + * Returns the number of messages processed, or a negative errno on + * failure. + */ +static int fpga_i2c_adapter_init(fpga_i2c_dev_t *fpga_i2c) +{ + int ret; + fpga_i2c_reg_t *reg; + + reg = &fpga_i2c->reg; + + ret = 0; + ret += fpga_reg_write(fpga_i2c, reg->i2c_scale, fpga_i2c->i2c_scale_value); + ret += fpga_reg_write(fpga_i2c, reg->i2c_filter, fpga_i2c->i2c_filter_value); + ret += fpga_reg_write(fpga_i2c, reg->i2c_stretch, fpga_i2c->i2c_stretch_value); + if (ret < 0) { + FPGA_I2C_ERROR("fpga_i2c_init failed.\n"); + return ret; + } + + FPGA_I2C_VERBOSE("fpga_i2c_init ok.\n"); + return 0; +} + +static int fpga_i2c_params_check(fpga_i2c_dev_t *fpga_i2c) +{ + int ret; + fpga_i2c_reg_t *reg; + uint8_t i2c_scale_value, i2c_filter_value, i2c_stretch_value; + + reg = &fpga_i2c->reg; + ret = 0; + ret += fpga_reg_read(fpga_i2c, reg->i2c_scale, &i2c_scale_value); + ret += fpga_reg_read(fpga_i2c, reg->i2c_filter, &i2c_filter_value); + ret += fpga_reg_read(fpga_i2c, reg->i2c_stretch, &i2c_stretch_value); + if (ret < 0) { + FPGA_I2C_ERROR("read fpga i2c params failed.\n"); + return 1; + } + + if ((i2c_scale_value != fpga_i2c->i2c_scale_value) + || (i2c_filter_value != fpga_i2c->i2c_filter_value) + || (i2c_stretch_value != fpga_i2c->i2c_stretch_value)) { + FPGA_I2C_ERROR("fpga i2c params check error, read value: i2c_scale 0x%x, i2c_filter:0x%x, i2c_stretch:0x%x.\n", + i2c_scale_value, i2c_filter_value, i2c_stretch_value); + FPGA_I2C_ERROR("fpga i2c params check error, config value: i2c_scale 0x%x, i2c_filter:0x%x, i2c_stretch:0x%x.\n", + fpga_i2c->i2c_scale_value, fpga_i2c->i2c_filter_value, fpga_i2c->i2c_stretch_value); + return 1; + } + + FPGA_I2C_VERBOSE("fpga i2c params check ok.\n"); + return 0; +} + +static int fpga_i2c_xfer(struct i2c_adapter *adap, + struct i2c_msg *msgs, int num) +{ + struct i2c_msg *pmsg; + int i; + int ret; + fpga_i2c_dev_t *fpga_i2c; + fpga_i2c_reg_addr_t *i2c_addr_desc; + + fpga_i2c = i2c_get_adapdata(adap); + + if (num != I2C_READ_MSG_NUM && num != I2C_WRITE_MSG_NUM) { + FPGA_I2C_ERROR("unsupport i2c_msg len:%d.\n", num); + return -EINVAL; + } + + if ((num == I2C_WRITE_MSG_NUM) && (msgs[0].len > fpga_i2c->reg.i2c_data_buf_len)) { + FPGA_I2C_ERROR("unsupport i2c_msg type:msg[0].flag:0x%x, buf len:0x%x.\n", + msgs[0].flags, msgs[0].len); + return -EINVAL; + } + + if (num == I2C_READ_MSG_NUM ) { + if ((msgs[0].flags & I2C_M_RD) ||!(msgs[1].flags & I2C_M_RD)) { + FPGA_I2C_ERROR("unsupport i2c_msg type:msg[0].flag:0x%x, msg[1].flag:0x%x.\n", + msgs[0].flags, msgs[1].flags); + return -EINVAL; + } + } + + if (fpga_i2c_is_busy(fpga_i2c)) { + FPGA_I2C_ERROR("fpga i2c adapter %d is busy, do reset.\n", adap->nr); + if (fpga_i2c->reset_cfg.i2c_adap_reset_flag == 1) { + + fpga_i2c_reset(fpga_i2c); + + fpga_i2c_adapter_init(fpga_i2c); + } + return -EAGAIN; + } + + if (fpga_i2c->i2c_params_check && fpga_i2c_params_check(fpga_i2c)) { + FPGA_I2C_ERROR("fpga i2c params check failed, try to reinitialize.\n"); + fpga_i2c_adapter_init(fpga_i2c); + } + + ret = 0; + i2c_addr_desc = &fpga_i2c->i2c_addr_desc; + i2c_addr_desc->reg_addr_len = 0; + memset(i2c_addr_desc->read_reg_addr , 0, sizeof(i2c_addr_desc->read_reg_addr)); + + for (i = 0; ret == 0 && i < num; i++) { + pmsg = &msgs[i]; + FPGA_I2C_VERBOSE("Doing %s %d byte(s) to/from 0x%02x - %d of %d messages\n", + pmsg->flags & I2C_M_RD ? "read" : "write", pmsg->len, pmsg->addr, i + 1, num); + + if (pmsg->flags & I2C_M_RD) { + ret = fpga_i2c_read(fpga_i2c, pmsg->addr, pmsg->buf, pmsg->len); + + if ((pmsg->len == 1) && (pmsg->flags & I2C_M_RECV_LEN)) { + if ((ret != 0) || (pmsg->buf[0] > I2C_SMBUS_BLOCK_MAX)) { + FPGA_I2C_ERROR("smbus block data read failed, ret:%d, read len:%u.\n", + ret, pmsg->buf[0]); + return -EPROTO; + } + pmsg->len = 1 + pmsg->buf[0]; + FPGA_I2C_VERBOSE("smbus block data read, read len:%d.\n", pmsg->len); + ret = fpga_i2c_read(fpga_i2c, pmsg->addr, pmsg->buf, pmsg->len); + } + } else { + ret = fpga_i2c_write(fpga_i2c, pmsg->addr, pmsg->buf, pmsg->len, num); + } + } + + return (ret != 0) ? ret : num; +} + +static u32 fpga_i2c_functionality(struct i2c_adapter *adap) +{ + return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_SMBUS_BLOCK_DATA; +} + +static const struct i2c_algorithm fpga_i2c_algo = { + .master_xfer = fpga_i2c_xfer, + .functionality = fpga_i2c_functionality, +}; + +static struct i2c_adapter fpga_i2c_ops = { + .owner = THIS_MODULE, + .name = "rg_fpga_i2c", + .algo = &fpga_i2c_algo, +}; + +static int fpga_i2c_config_init(fpga_i2c_dev_t *fpga_i2c) +{ + int ret = 0, rv = 0; + fpga_i2c_reg_t *reg; + fpga_i2c_reset_cfg_t *reset_cfg; + struct device *dev; + uint32_t i2c_offset_reg, i2c_data_buf_len_reg; + int32_t i2c_offset_val; + + fpga_i2c_bus_device_t *fpga_i2c_bus_device; + + dev = fpga_i2c->dev; + reg = &fpga_i2c->reg; + reset_cfg = &fpga_i2c->reset_cfg; + + i2c_offset_val = 0; + + if (dev->of_node) { + ret = 0; + ret += of_property_read_u32(dev->of_node, "i2c_ext_9548_addr", ®->i2c_ext_9548_addr); + ret += of_property_read_u32(dev->of_node, "i2c_ext_9548_chan", ®->i2c_ext_9548_chan); + ret += of_property_read_u32(dev->of_node, "i2c_slave", ®->i2c_slave); + ret += of_property_read_u32(dev->of_node, "i2c_reg", ®->i2c_reg); + ret += of_property_read_u32(dev->of_node, "i2c_data_len", ®->i2c_data_len); + ret += of_property_read_u32(dev->of_node, "i2c_ctrl", ®->i2c_ctrl); + ret += of_property_read_u32(dev->of_node, "i2c_status", ®->i2c_status); + ret += of_property_read_u32(dev->of_node, "i2c_scale", ®->i2c_scale); + ret += of_property_read_u32(dev->of_node, "i2c_filter", ®->i2c_filter); + ret += of_property_read_u32(dev->of_node, "i2c_stretch", ®->i2c_stretch); + ret += of_property_read_u32(dev->of_node, "i2c_ext_9548_exits_flag", ®->i2c_ext_9548_exits_flag); + ret += of_property_read_u32(dev->of_node, "i2c_reg_len", ®->i2c_reg_len); + ret += of_property_read_u32(dev->of_node, "i2c_in_9548_chan", ®->i2c_in_9548_chan); + ret += of_property_read_u32(dev->of_node, "i2c_data_buf", ®->i2c_data_buf); + ret += of_property_read_string(dev->of_node, "dev_name", &fpga_i2c->dev_name); + ret += of_property_read_u32(dev->of_node, "i2c_scale_value", &fpga_i2c->i2c_scale_value); + ret += of_property_read_u32(dev->of_node, "i2c_filter_value", &fpga_i2c->i2c_filter_value); + ret += of_property_read_u32(dev->of_node, "i2c_stretch_value", &fpga_i2c->i2c_stretch_value); + ret += of_property_read_u32(dev->of_node, "i2c_timeout", &fpga_i2c->i2c_timeout); + ret += of_property_read_u32(dev->of_node, "i2c_func_mode", &fpga_i2c->i2c_func_mode); + ret += of_property_read_u32(dev->of_node, "i2c_reset_addr", &reset_cfg->reset_addr); + ret += of_property_read_u32(dev->of_node, "i2c_reset_on", &reset_cfg->reset_on); + ret += of_property_read_u32(dev->of_node, "i2c_reset_off", &reset_cfg->reset_off); + ret += of_property_read_u32(dev->of_node, "i2c_rst_delay_b", &reset_cfg->reset_delay_b); + ret += of_property_read_u32(dev->of_node, "i2c_rst_delay", &reset_cfg->reset_delay); + ret += of_property_read_u32(dev->of_node, "i2c_rst_delay_a", &reset_cfg->reset_delay_a); + ret += of_property_read_u32(dev->of_node, "i2c_adap_reset_flag", &reset_cfg->i2c_adap_reset_flag); + + if (ret != 0) { + FPGA_I2C_ERROR("dts config error, ret:%d.\n", ret); + ret = -ENXIO; + return ret; + } + + rv = of_property_read_u32(dev->of_node, "i2c_data_buf_len_reg", &i2c_data_buf_len_reg); + if (rv == 0) { + ret = fpga_reg_read_32(fpga_i2c, i2c_data_buf_len_reg, ®->i2c_data_buf_len); + if (ret < 0) { + dev_err(fpga_i2c->dev, "Failed to get fpga i2c data buf length, reg addr: 0x%x, ret: %d\n", + i2c_data_buf_len_reg, ret); + return ret; + } + FPGA_I2C_VERBOSE("fpga i2c data buf length reg addr: 0x%x, value: %d\n", + i2c_data_buf_len_reg, reg->i2c_data_buf_len); + if (reg->i2c_data_buf_len == 0) { + reg->i2c_data_buf_len = FPGA_I2C_RDWR_MAX_LEN_DEFAULT; + } + } else { + ret = of_property_read_u32(dev->of_node, "i2c_data_buf_len", ®->i2c_data_buf_len); + if (ret != 0) { + reg->i2c_data_buf_len = FPGA_I2C_RDWR_MAX_LEN_DEFAULT; + ret = 0; + } + } + + rv = of_property_read_u32(dev->of_node, "i2c_offset_reg", &i2c_offset_reg); + if (rv == 0) { + ret = fpga_reg_read_32(fpga_i2c, i2c_offset_reg, &i2c_offset_val); + if (ret < 0) { + dev_err(fpga_i2c->dev, "Failed to get fpga i2c adapter offset value, reg addr: 0x%x, ret: %d\n", + i2c_offset_reg, ret); + return ret; + } + FPGA_I2C_VERBOSE("fpga i2c adapter offset reg addr: 0x%x, value: %d\n", + i2c_offset_reg, i2c_offset_val); + reg->i2c_scale +=i2c_offset_val; + reg->i2c_filter += i2c_offset_val; + reg->i2c_stretch += i2c_offset_val; + reg->i2c_ext_9548_exits_flag += i2c_offset_val; + reg->i2c_ext_9548_addr += i2c_offset_val; + reg->i2c_ext_9548_chan += i2c_offset_val; + reg->i2c_in_9548_chan += i2c_offset_val; + reg->i2c_slave += i2c_offset_val; + reg->i2c_reg += i2c_offset_val; + reg->i2c_reg_len += i2c_offset_val; + reg->i2c_data_len += i2c_offset_val; + reg->i2c_ctrl += i2c_offset_val; + reg->i2c_status += i2c_offset_val; + reg->i2c_data_buf += i2c_offset_val; + } + + ret = of_property_read_u32(dev->of_node, "i2c_err_vec", ®->i2c_err_vec); + if (ret != 0) { + reg->i2c_err_vec = DTS_NO_CFG_FLAG; + FPGA_I2C_VERBOSE("not support i2c_err_vec cfg. ret: %d, set DTS_NO_CFG_FLAG: %d\n", + ret, reg->i2c_err_vec); + ret = 0; /* Not configuring i2c_err_vec is not an error */ + } else { + if (i2c_offset_val != 0) { + reg->i2c_err_vec += i2c_offset_val; + } + } + } else { + if (dev->platform_data == NULL) { + dev_err(fpga_i2c->dev, "Failed to get platform data config.\n"); + ret = -ENXIO; + return ret; + } + fpga_i2c_bus_device = dev->platform_data; + fpga_i2c->dev_name = fpga_i2c_bus_device->dev_name; + fpga_i2c->adap_nr = fpga_i2c_bus_device->adap_nr; + fpga_i2c->i2c_scale_value = fpga_i2c_bus_device->i2c_scale_value; + fpga_i2c->i2c_filter_value = fpga_i2c_bus_device->i2c_filter_value; + fpga_i2c->i2c_stretch_value = fpga_i2c_bus_device->i2c_stretch_value; + fpga_i2c->i2c_timeout = fpga_i2c_bus_device->i2c_timeout; + fpga_i2c->i2c_func_mode = fpga_i2c_bus_device->i2c_func_mode; + fpga_i2c->i2c_params_check = fpga_i2c_bus_device->i2c_func_mode; + + reset_cfg->reset_addr = fpga_i2c_bus_device->i2c_reset_addr; + reset_cfg->reset_on = fpga_i2c_bus_device->i2c_reset_on; + reset_cfg->reset_off = fpga_i2c_bus_device->i2c_reset_off; + reset_cfg->reset_delay_b = fpga_i2c_bus_device->i2c_rst_delay_b; + reset_cfg->reset_delay = fpga_i2c_bus_device->i2c_rst_delay; + reset_cfg->reset_delay_a = fpga_i2c_bus_device->i2c_rst_delay_a; + reset_cfg->i2c_adap_reset_flag = fpga_i2c_bus_device->i2c_adap_reset_flag; + + reg->i2c_ext_9548_addr = fpga_i2c_bus_device->i2c_ext_9548_addr; + reg->i2c_ext_9548_chan = fpga_i2c_bus_device->i2c_ext_9548_chan; + reg->i2c_slave = fpga_i2c_bus_device->i2c_slave; + reg->i2c_reg = fpga_i2c_bus_device->i2c_reg; + reg->i2c_data_len = fpga_i2c_bus_device->i2c_data_len; + reg->i2c_ctrl = fpga_i2c_bus_device->i2c_ctrl; + reg->i2c_status = fpga_i2c_bus_device->i2c_status; + reg->i2c_scale = fpga_i2c_bus_device->i2c_scale; + reg->i2c_filter = fpga_i2c_bus_device->i2c_filter; + reg->i2c_stretch = fpga_i2c_bus_device->i2c_stretch; + reg->i2c_ext_9548_exits_flag = fpga_i2c_bus_device->i2c_ext_9548_exits_flag; + reg->i2c_reg_len = fpga_i2c_bus_device->i2c_reg_len; + reg->i2c_in_9548_chan = fpga_i2c_bus_device->i2c_in_9548_chan; + reg->i2c_data_buf = fpga_i2c_bus_device->i2c_data_buf; + + i2c_data_buf_len_reg = fpga_i2c_bus_device->i2c_data_buf_len_reg; + if (i2c_data_buf_len_reg > 0) { + ret = fpga_reg_read_32(fpga_i2c, i2c_data_buf_len_reg, ®->i2c_data_buf_len); + if (ret < 0) { + dev_err(fpga_i2c->dev, "Failed to get fpga i2c data buf length, reg addr: 0x%x, ret: %d\n", + i2c_data_buf_len_reg, ret); + return ret; + } + FPGA_I2C_VERBOSE("fpga i2c data buf length reg addr: 0x%x, value: %d\n", + i2c_data_buf_len_reg, reg->i2c_data_buf_len); + if (reg->i2c_data_buf_len == 0) { + reg->i2c_data_buf_len = FPGA_I2C_RDWR_MAX_LEN_DEFAULT; + } + } else { + if (fpga_i2c_bus_device->i2c_data_buf_len == 0) { + reg->i2c_data_buf_len = FPGA_I2C_RDWR_MAX_LEN_DEFAULT; + FPGA_I2C_VERBOSE("not support i2c_data_buf_len cfg, set default_val:%d\n", + reg->i2c_data_buf_len); + } else { + reg->i2c_data_buf_len = fpga_i2c_bus_device->i2c_data_buf_len; + } + } + + i2c_offset_reg = fpga_i2c_bus_device->i2c_offset_reg; + if (i2c_offset_reg > 0) { + rv = fpga_reg_read_32(fpga_i2c, i2c_offset_reg, &i2c_offset_val); + if (rv < 0) { + dev_err(fpga_i2c->dev, "Failed to get fpga i2c adapter offset value, reg addr: 0x%x, rv: %d\n", + i2c_offset_reg, rv); + return rv; + } + FPGA_I2C_VERBOSE("fpga i2c adapter offset reg addr: 0x%x, value: %d\n", + i2c_offset_reg, i2c_offset_val); + reg->i2c_scale +=i2c_offset_val; + reg->i2c_filter += i2c_offset_val; + reg->i2c_stretch += i2c_offset_val; + reg->i2c_ext_9548_exits_flag += i2c_offset_val; + reg->i2c_ext_9548_addr += i2c_offset_val; + reg->i2c_ext_9548_chan += i2c_offset_val; + reg->i2c_in_9548_chan += i2c_offset_val; + reg->i2c_slave += i2c_offset_val; + reg->i2c_reg += i2c_offset_val; + reg->i2c_reg_len += i2c_offset_val; + reg->i2c_data_len += i2c_offset_val; + reg->i2c_ctrl += i2c_offset_val; + reg->i2c_status += i2c_offset_val; + reg->i2c_data_buf += i2c_offset_val; + } + + if (fpga_i2c_bus_device->i2c_err_vec == 0) { + reg->i2c_err_vec = DTS_NO_CFG_FLAG; + FPGA_I2C_VERBOSE("not support i2c_err_vec cfg, set DTS_NO_CFG_FLAG:%d\n", + reg->i2c_err_vec); + } else { + reg->i2c_err_vec = fpga_i2c_bus_device->i2c_err_vec; + if (i2c_offset_val != 0) { + reg->i2c_err_vec += i2c_offset_val; + } + } + } + + FPGA_I2C_VERBOSE("i2c_ext_9548_addr:0x%x, i2c_ext_9548_chan:0x%x, i2c_slave:0x%x, i2c_reg:0x%x, i2c_data_len:0x%x.\n", + reg->i2c_ext_9548_addr, reg->i2c_ext_9548_chan, reg->i2c_slave, reg->i2c_reg, reg->i2c_data_len); + FPGA_I2C_VERBOSE("i2c_ctrl:0x%x, i2c_status:0x%x, i2c_scale:0x%x, i2c_filter:0x%x, i2c_stretch:0x%x.\n", + reg->i2c_ctrl, reg->i2c_status, reg->i2c_scale, reg->i2c_filter, reg->i2c_stretch); + FPGA_I2C_VERBOSE("i2c_ext_9548_exits_flag:0x%x, i2c_in_9548_chan:0x%x, i2c_data_buf:0x%x, i2c_reg_len:0x%x, i2c_data_buf_len:0x%x.\n", + reg->i2c_ext_9548_exits_flag, reg->i2c_in_9548_chan, reg->i2c_data_buf, reg->i2c_reg_len, reg->i2c_data_buf_len); + FPGA_I2C_VERBOSE("dev_name:%s, i2c_scale_value:0x%x, i2c_filter_value:0x%x, i2c_stretch_value:0x%x, i2c_timeout:0x%x.\n", + fpga_i2c->dev_name, fpga_i2c->i2c_scale_value, fpga_i2c->i2c_filter_value, fpga_i2c->i2c_stretch_value, fpga_i2c->i2c_timeout); + FPGA_I2C_VERBOSE("i2c_reset_addr:0x%x, i2c_reset_on:0x%x, i2c_reset_off:0x%x, i2c_rst_delay_b:0x%x, i2c_rst_delay:0x%x, i2c_rst_delay_a:0x%x.\n", + reset_cfg->reset_addr, reset_cfg->reset_on, reset_cfg->reset_off, reset_cfg->reset_delay_b, reset_cfg->reset_delay, reset_cfg->reset_delay_a); + FPGA_I2C_VERBOSE("i2c_adap_reset_flag:0x%x.\n", reset_cfg->i2c_adap_reset_flag); + FPGA_I2C_VERBOSE("i2c_err_vec:0x%x\n", reg->i2c_err_vec); + + return ret; +} + +static int fpga_i2c_probe(struct platform_device *pdev) +{ + int ret; + fpga_i2c_dev_t *fpga_i2c; + struct device *dev; + + fpga_i2c = devm_kzalloc(&pdev->dev, sizeof(fpga_i2c_dev_t), GFP_KERNEL); + if (!fpga_i2c) { + dev_err(&pdev->dev, "devm_kzalloc failed.\n"); + ret = -ENOMEM; + goto out; + } + + fpga_i2c->dev = &pdev->dev; + + ret = fpga_i2c_config_init(fpga_i2c); + if (ret !=0) { + dev_err(fpga_i2c->dev, "Failed to get fpga i2c dts config.\n"); + goto out; + } + + ret = fpga_i2c_adapter_init(fpga_i2c); + if (ret !=0) { + dev_err(fpga_i2c->dev, "Failed to init fpga i2c adapter.\n"); + goto out; + } + + if (fpga_i2c->dev->of_node) { + fpga_i2c->i2c_params_check = of_property_read_bool(fpga_i2c->dev->of_node, "i2c_params_check"); + } + FPGA_I2C_VERBOSE("fpga i2c params check flag:%d.\n", fpga_i2c->i2c_params_check); + + init_waitqueue_head(&fpga_i2c->queue); + + dev = fpga_i2c->dev; + fpga_i2c->adap = fpga_i2c_ops; + fpga_i2c->adap.timeout = msecs_to_jiffies(fpga_i2c->i2c_timeout); + fpga_i2c->adap.dev.parent = &pdev->dev; + fpga_i2c->adap.dev.of_node = pdev->dev.of_node; + i2c_set_adapdata(&fpga_i2c->adap, fpga_i2c); + platform_set_drvdata(pdev, fpga_i2c); + + if (fpga_i2c->dev->of_node) { + /* adap.nr get from dts aliases */ + ret = i2c_add_adapter(&fpga_i2c->adap); + } else { + fpga_i2c->adap.nr = fpga_i2c->adap_nr; + ret = i2c_add_numbered_adapter(&fpga_i2c->adap); + } + + if (ret < 0) { + dev_info(fpga_i2c->dev, "Failed to add adapter.\n"); + goto fail_add; + } + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,12,0) + of_i2c_register_devices(&fpga_i2c->adap); +#endif + dev_info(fpga_i2c->dev, "registered i2c-%d for %s using mode %d with base address:0x%x, data buf len: %d success.\n", + fpga_i2c->adap.nr, fpga_i2c->dev_name, fpga_i2c->i2c_func_mode, fpga_i2c->reg.i2c_scale, + fpga_i2c->reg.i2c_data_buf_len); + return 0; + +fail_add: + platform_set_drvdata(pdev, NULL); +out: + return ret; +}; + +static int fpga_i2c_remove(struct platform_device *pdev) +{ + fpga_i2c_dev_t *fpga_i2c; + + fpga_i2c = platform_get_drvdata(pdev); + i2c_del_adapter(&fpga_i2c->adap); + platform_set_drvdata(pdev, NULL); + return 0; +}; + +static struct of_device_id fpga_i2c_match[] = { + { + .compatible = "ruijie,rg-fpga-i2c", + }, + {}, +}; +MODULE_DEVICE_TABLE(of, fpga_i2c_match); + +static struct platform_driver rg_fpga_i2c_driver = { + .probe = fpga_i2c_probe, + .remove = fpga_i2c_remove, + .driver = { + .owner = THIS_MODULE, + .name = DRV_NAME, + .of_match_table = fpga_i2c_match, + }, +}; + +static int __init rg_fpga_i2c_init(void) +{ + return platform_driver_register(&rg_fpga_i2c_driver); +} + +static void __exit rg_fpga_i2c_exit(void) +{ + platform_driver_unregister(&rg_fpga_i2c_driver); +} + +module_init(rg_fpga_i2c_init); +module_exit(rg_fpga_i2c_exit); +MODULE_DESCRIPTION("fpga i2c adapter driver"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd "); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_fpga_pca954x_drv.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_fpga_pca954x_drv.c new file mode 100644 index 000000000000..5f25012d446f --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_fpga_pca954x_drv.c @@ -0,0 +1,531 @@ +/* + * Copyright(C) 2016 Ruijie Network. All rights reserved. + * + * fpga_pca954x_drv.c + * Original Author: sonic_rd@ruijie.com.cn 2020-08-10 + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "fpga_i2c.h" + +extern int i2c_device_func_write(const char *path, uint32_t pos, uint8_t *val, size_t size); +extern int pcie_device_func_write(const char *path, uint32_t offset, uint8_t *buf, size_t count); + +#define PCA954X_MAX_NCHANS (8) +#define FPGA_INTERNAL_PCA9548 (1) +#define FPGA_EXTERNAL_PCA9548 (2) +#define FPGA_I2C_EXT_9548_EXITS (0x01 << 0) +#define FPGA_I2C_9548_NO_RESET (0x01 << 1) + +#define SYMBOL_I2C_DEV_MODE (1) +#define FILE_MODE (2) +#define SYMBOL_PCIE_DEV_MODE (3) +#define SYMBOL_IO_DEV_MODE (4) + +int g_fpga_pca954x_debug = 0; +int g_fpga_pca954x_error = 0; + +module_param(g_fpga_pca954x_debug, int, S_IRUGO | S_IWUSR); +module_param(g_fpga_pca954x_error, int, S_IRUGO | S_IWUSR); + +#define FPGA_PCA954X_VERBOSE(fmt, args...) do { \ + if (g_fpga_pca954x_debug) { \ + printk(KERN_INFO "[FPGA_PCA954X][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define FPGA_PCA954X_ERROR(fmt, args...) do { \ + if (g_fpga_pca954x_error) { \ + printk(KERN_ERR "[FPGA_PCA954X][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +enum pca_type { + pca_9540, + pca_9541, + pca_9542, + pca_9543, + pca_9544, + pca_9545, + pca_9546, + pca_9547, + pca_9548, +}; + +struct pca954x { + enum pca_type type; + struct i2c_adapter *virt_adaps[PCA954X_MAX_NCHANS]; + u8 last_chan; /* last register value */ + uint32_t fpga_9548_flag; + uint32_t fpga_9548_reset_flag; + uint32_t pca9548_base_nr; + struct i2c_client *client; +}; + +struct chip_desc { + u8 nchans; + u8 enable; /* used for muxes only */ + enum muxtype { + pca954x_ismux = 0, + pca954x_isswi + } muxtype; +}; + +/* Provide specs for the PCA954x types we know about */ +static const struct chip_desc chips[] = { + [pca_9540] = { + .nchans = 2, + .enable = 0x4, + .muxtype = pca954x_ismux, + }, + [pca_9541] = { + .nchans = 1, + .muxtype = pca954x_isswi, + }, + [pca_9543] = { + .nchans = 2, + .muxtype = pca954x_isswi, + }, + [pca_9544] = { + .nchans = 4, + .enable = 0x4, + .muxtype = pca954x_ismux, + }, + [pca_9545] = { + .nchans = 4, + .muxtype = pca954x_isswi, + }, + [pca_9547] = { + .nchans = 8, + .enable = 0x8, + .muxtype = pca954x_ismux, + }, + [pca_9548] = { + .nchans = 8, + .muxtype = pca954x_isswi, + }, +}; + +static const struct i2c_device_id fpga_pca954x_id[] = { + { "rg_fpga_pca9540", pca_9540 }, + { "rg_fpga_pca9541", pca_9541 }, + { "rg_fpga_pca9542", pca_9543 }, + { "rg_fpga_pca9543", pca_9543 }, + { "rg_fpga_pca9544", pca_9544 }, + { "rg_fpga_pca9545", pca_9545 }, + { "rg_fpga_pca9546", pca_9545 }, + { "rg_fpga_pca9547", pca_9547 }, + { "rg_fpga_pca9548", pca_9548 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, fpga_pca954x_id); + +static int fpga_file_write(const char *path, int pos, unsigned char *val, size_t size) +{ + int ret; + struct file *filp; + loff_t tmp_pos; + + filp = filp_open(path, O_RDWR, 777); + if (IS_ERR(filp)) { + FPGA_PCA954X_ERROR("write open failed errno = %ld\r\n", -PTR_ERR(filp)); + filp = NULL; + goto exit; + } + + tmp_pos = (loff_t)pos; + ret = kernel_write(filp, val, size, &tmp_pos); + if (ret < 0) { + FPGA_PCA954X_ERROR("kernel_write failed, path=%s, addr=%d, size=%ld, ret=%d\r\n", path, pos, size, ret); + goto exit; + } + + vfs_fsync(filp, 1); + filp_close(filp, NULL); + + return ret; + +exit: + if (filp != NULL) { + filp_close(filp, NULL); + } + + return -1; + +} +static int fpga_device_write(fpga_i2c_dev_t *fpga_i2c, int pos, unsigned char *val, size_t size) +{ + int ret; + + switch (fpga_i2c->i2c_func_mode) { + case SYMBOL_I2C_DEV_MODE: + ret = i2c_device_func_write(fpga_i2c->dev_name, pos, val, size); + break; + case FILE_MODE: + ret = fpga_file_write(fpga_i2c->dev_name, pos, val, size); + break; + case SYMBOL_PCIE_DEV_MODE: + ret = pcie_device_func_write(fpga_i2c->dev_name, pos, val, size); + break; + default: + FPGA_PCA954X_ERROR("err func mode, write failed.\n"); + return -EINVAL; + } + + return ret; +} + +static int fpga_reg_write(fpga_i2c_dev_t *fpga_i2c, uint32_t addr, uint8_t val) +{ + int ret; + + ret = fpga_device_write(fpga_i2c, addr, &val, sizeof(uint8_t)); + if (ret < 0) { + FPGA_PCA954X_ERROR("fpga_device_write failed. name:%s, addr:0x%x, value:0x%x.\n", + fpga_i2c->dev_name, addr, val); + return ret; + } + + FPGA_PCA954X_VERBOSE("fpga reg write success, dev name:%s, offset:0x%x, value:0x%x.\n", + fpga_i2c->dev_name, addr, val); + return 0; +} + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,7) +static int pca954x_select_chan(struct i2c_adapter *adap, void *client, u32 chan) +{ + struct pca954x *data = i2c_get_clientdata(client); + fpga_i2c_dev_t *fpga_i2c; + fpga_i2c_reg_t *reg; + int ret; + u8 regval, i2c_9548_opt; + + while(i2c_parent_is_i2c_adapter(adap)){ + adap = to_i2c_adapter(adap->dev.parent); + } + + FPGA_PCA954X_VERBOSE("root bus:%d, chan:0x%x, 9548 flag:0x%x, 9548 addr:0x%x.\n", + adap->nr, chan, data->fpga_9548_flag, client->addr); + fpga_i2c = i2c_get_adapdata(adap); + reg = &fpga_i2c->reg; + + regval = 1 << chan; + if (data->fpga_9548_flag == FPGA_INTERNAL_PCA9548) { + ret = fpga_reg_write(fpga_i2c, reg->i2c_in_9548_chan, regval); + } else { + if (data->fpga_9548_reset_flag == 1) { + i2c_9548_opt = FPGA_I2C_EXT_9548_EXITS & ~(FPGA_I2C_9548_NO_RESET); + } else { + i2c_9548_opt = FPGA_I2C_EXT_9548_EXITS | FPGA_I2C_9548_NO_RESET; + } + FPGA_PCA954X_VERBOSE("fpga pca9548 reset flag:0x%x, opt:0x%x.\n", + data->fpga_9548_reset_flag, i2c_9548_opt); + ret = fpga_reg_write(fpga_i2c, reg->i2c_ext_9548_exits_flag, i2c_9548_opt); + ret += fpga_reg_write(fpga_i2c, reg->i2c_ext_9548_addr, client->addr); + ret += fpga_reg_write(fpga_i2c, reg->i2c_ext_9548_chan, regval); + } + + return ret; +} + +static int pca954x_deselect_mux(struct i2c_adapter *adap, void *client, u32 chan) +{ + struct pca954x *data = i2c_get_clientdata(client); + fpga_i2c_dev_t *fpga_i2c; + fpga_i2c_reg_t *reg; + int ret; + + while(i2c_parent_is_i2c_adapter(adap)){ + adap = to_i2c_adapter(adap->dev.parent); + } + + fpga_i2c = i2c_get_adapdata(adap); + reg = &fpga_i2c->reg; + /* Deselect active channel */ + data->last_chan = 0; + if (data->fpga_9548_flag == FPGA_INTERNAL_PCA9548) { + ret = fpga_reg_write(fpga_i2c, reg->i2c_in_9548_chan, 0); + } else { + + ret = fpga_reg_write(fpga_i2c, reg->i2c_ext_9548_exits_flag, FPGA_I2C_9548_NO_RESET); + ret += fpga_reg_write(fpga_i2c, reg->i2c_ext_9548_chan, 0); + } + + return ret; +} +#else +static int pca954x_select_chan(struct i2c_mux_core *muxc, u32 chan) +{ + struct pca954x *data = i2c_mux_priv(muxc); + struct i2c_client *client = data->client; + struct i2c_adapter *adap; + fpga_i2c_dev_t *fpga_i2c; + fpga_i2c_reg_t *reg; + int ret; + u8 regval, i2c_9548_opt; + + adap = muxc->parent; + while(i2c_parent_is_i2c_adapter(adap)){ + adap = to_i2c_adapter(adap->dev.parent); + } + + FPGA_PCA954X_VERBOSE("root bus:%d, chan:0x%x, 9548 flag:0x%x, 9548 addr:0x%x.\n", + adap->nr, chan, data->fpga_9548_flag, client->addr); + fpga_i2c = i2c_get_adapdata(adap); + reg = &fpga_i2c->reg; + + regval = 1 << chan; + if (data->fpga_9548_flag == FPGA_INTERNAL_PCA9548) { + ret = fpga_reg_write(fpga_i2c, reg->i2c_in_9548_chan, regval); + } else { + if (data->fpga_9548_reset_flag == 1) { + i2c_9548_opt = FPGA_I2C_EXT_9548_EXITS & ~(FPGA_I2C_9548_NO_RESET); + } else { + i2c_9548_opt = FPGA_I2C_EXT_9548_EXITS | FPGA_I2C_9548_NO_RESET; + } + FPGA_PCA954X_VERBOSE("fpga pca9548 reset flag:0x%x, opt:0x%x.\n", + data->fpga_9548_reset_flag, i2c_9548_opt); + ret = fpga_reg_write(fpga_i2c, reg->i2c_ext_9548_exits_flag, i2c_9548_opt); + ret += fpga_reg_write(fpga_i2c, reg->i2c_ext_9548_addr, client->addr); + ret += fpga_reg_write(fpga_i2c, reg->i2c_ext_9548_chan, regval); + } + + return ret; +} + +static int pca954x_deselect_mux(struct i2c_mux_core *muxc, u32 chan) +{ + struct pca954x *data = i2c_mux_priv(muxc); + struct i2c_adapter *adap; + fpga_i2c_dev_t *fpga_i2c; + fpga_i2c_reg_t *reg; + int ret; + + adap = muxc->parent; + while(i2c_parent_is_i2c_adapter(adap)){ + adap = to_i2c_adapter(adap->dev.parent); + } + + fpga_i2c = i2c_get_adapdata(adap); + reg = &fpga_i2c->reg; + ret = 0; + /* Deselect active channel */ + data->last_chan = 0; + + if (data->fpga_9548_flag == FPGA_INTERNAL_PCA9548) { + ret = fpga_reg_write(fpga_i2c, reg->i2c_in_9548_chan, 0); + } else { + + ret = fpga_reg_write(fpga_i2c, reg->i2c_ext_9548_exits_flag, FPGA_I2C_9548_NO_RESET); + ret += fpga_reg_write(fpga_i2c, reg->i2c_ext_9548_chan, 0); + } + + return ret; +} +#endif +/* + * I2C init/probing/exit functions + */ +static int fpga_i2c_pca954x_probe(struct i2c_client *client, const struct i2c_device_id *id) +{ + struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent); + int num, force, class; + struct pca954x *data; + int ret = -ENODEV; + struct device *dev; + int dynamic_nr = 1; + fpga_pca954x_device_t *fpga_pca954x_device; + +#if LINUX_VERSION_CODE > KERNEL_VERSION(4,6,7) + struct i2c_mux_core *muxc; +#endif + + if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE)) { + dev_err(&client->dev, "i2c adapter:%d, unsupport I2C_FUNC_SMBUS_BYTE.\n", adap->nr); + goto err; + } + +#if LINUX_VERSION_CODE <= KERNEL_VERSION(4,6,7) + data = kzalloc(sizeof(struct pca954x), GFP_KERNEL); + if (!data) { + dev_err(&client->dev, "kzalloc failed.\n"); + ret = -ENOMEM; + goto err; + } + + i2c_set_clientdata(client, data); +#else + muxc = i2c_mux_alloc(adap, &client->dev, + PCA954X_MAX_NCHANS, sizeof(*data), 0, + pca954x_select_chan, pca954x_deselect_mux); + if (!muxc) { + dev_err(&client->dev, "i2c_mux_alloc failed.\n"); + return -ENOMEM; + } + data = i2c_mux_priv(muxc); + i2c_set_clientdata(client, muxc); + data->client = client; +#endif + + dev = &client->dev; + if (dev == NULL) { + dev_err(&client->dev, "dev is NULL.\n"); + ret = -ENODEV; + goto exit_free; + } + + if (dev->of_node == NULL) { + if (client->dev.platform_data == NULL) { + dev_err(&client->dev, "Failed to get 954x platform data config.\n"); + ret = -EINVAL; + goto exit_free; + } + fpga_pca954x_device = client->dev.platform_data; + data->fpga_9548_flag = fpga_pca954x_device->fpga_9548_flag; + data->fpga_9548_reset_flag = fpga_pca954x_device->fpga_9548_reset_flag; + data->pca9548_base_nr = fpga_pca954x_device->pca9548_base_nr; + if (data->pca9548_base_nr == 0) { + + dynamic_nr = 1; + } else { + dynamic_nr = 0; + FPGA_PCA954X_VERBOSE("pca9548_base_nr:%u.\n", data->pca9548_base_nr); + } + } else { + data->type = id->driver_data; + /* BUS ID */ + ret = of_property_read_u32(dev->of_node, "fpga_9548_flag", &data->fpga_9548_flag); + ret += of_property_read_u32(dev->of_node, "fpga_9548_reset_flag", &data->fpga_9548_reset_flag); + if (ret != 0) { + dev_err(&client->dev, "Failed to get 954x dts config, ret:%d.\n", ret); + ret = -EINVAL; + goto exit_free; + } + if (of_property_read_u32(dev->of_node, "pca9548_base_nr", &data->pca9548_base_nr)) { + + dynamic_nr = 1; + FPGA_PCA954X_VERBOSE("pca9548_base_nr not found, use dynamic adap number"); + } else { + dynamic_nr = 0; + FPGA_PCA954X_VERBOSE("pca9548_base_nr:%u.\n", data->pca9548_base_nr); + } + } + + if (data->fpga_9548_flag != FPGA_EXTERNAL_PCA9548 && data->fpga_9548_flag != FPGA_INTERNAL_PCA9548) { + dev_err(&client->dev, "Error: fpga 954x flag config error, value:0x%x.\n", data->fpga_9548_flag); + ret = -EINVAL; + goto exit_free; + } + + data->type = id->driver_data; + data->last_chan = 0; /* force the first selection */ + + /* Now create an adapter for each channel */ + for (num = 0; num < chips[data->type].nchans; num++) { + if (dynamic_nr == 1) { + force = 0; /* dynamic adap number */ + } else { + force = data->pca9548_base_nr + num; + } + class = 0; /* no class by default */ +#if LINUX_VERSION_CODE <= KERNEL_VERSION(4,6,7) + data->virt_adaps[num] = + i2c_add_mux_adapter(adap, &client->dev, client, + force, num, class, pca954x_select_chan, pca954x_deselect_mux); + + if (data->virt_adaps[num] == NULL) { + ret = -ENODEV; + dev_err(&client->dev, "Failed to register multiplexed adapter %d as bus %d\n", + num, force); + goto virt_reg_failed; + } +#else + ret = i2c_mux_add_adapter(muxc, force, num, class); + if (ret) { + dev_err(&client->dev, "Failed to register multiplexed adapter %d as bus %d\n", + num, force); + goto virt_reg_failed; + } +#endif + } /* end for num = 0; num < chips[data->type].nchans... */ + + dev_info(&client->dev, "registered %d multiplexed busses for I2C %s %s\n", + num, chips[data->type].muxtype == pca954x_ismux ? "mux" : "switch", client->name); + + return 0; + +virt_reg_failed: +#if LINUX_VERSION_CODE <= KERNEL_VERSION(4,6,7) + for (num--; num >= 0; num--) + i2c_del_mux_adapter(data->virt_adaps[num]); +exit_free: + kfree(data); +#else +exit_free: + i2c_mux_del_adapters(muxc); +#endif +err: + return ret; +} + +static int fpga_i2c_pca954x_remove(struct i2c_client *client) +{ +#if LINUX_VERSION_CODE <= KERNEL_VERSION(4,6,7) + struct pca954x *data = i2c_get_clientdata(client); + const struct chip_desc *chip = &chips[data->type]; + int i; + + for (i = 0; i < chip->nchans; ++i) + if (data->virt_adaps[i]) { + i2c_del_mux_adapter(data->virt_adaps[i]); + data->virt_adaps[i] = NULL; + } + + kfree(data); +#else + struct i2c_mux_core *muxc = i2c_get_clientdata(client); + + i2c_mux_del_adapters(muxc); +#endif + + return 0; +} + +static struct i2c_driver fpga_i2c_pca954x_driver = { + .driver = { + .name = "rg_fpga_pca954x", + .owner = THIS_MODULE, + }, + .probe = fpga_i2c_pca954x_probe, + .remove = fpga_i2c_pca954x_remove, + .id_table = fpga_pca954x_id, +}; + +static int __init fpga_i2c_pca954x_init(void) +{ + int ret; + + ret = i2c_add_driver(&fpga_i2c_pca954x_driver); + return ret; +} + +static void __exit fpga_i2c_pca954x_exit(void) +{ + i2c_del_driver(&fpga_i2c_pca954x_driver); +} + +module_init(fpga_i2c_pca954x_init); +module_exit(fpga_i2c_pca954x_exit); +MODULE_DESCRIPTION("fpga pca954x driver"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd "); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_fpga_pcie.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_fpga_pcie.c new file mode 100644 index 000000000000..d644d973e1b4 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_fpga_pcie.c @@ -0,0 +1,167 @@ +/* + * Copyright(C) 2016 Ruijie Network. All rights reserved. + * + * rg_fpga_pcie.c + * ko to enable fpga pcie + * Original Author: sonic_rd@ruijie.com.cn 2020-08-10 + */ +#include +#include +#include +#include +#include + +#define FPGA_MSI_IRQ_NUM (14) +#define FPGA_MSI_IRQ_BEGIN (0) +#define XILINX_FPGA_USE_MSI (0) +#define XILINX_FPGA_NUSE_MSI (1) + +int g_fpga_pcie_dev_debug = 0; +int g_fpga_pcie_dev_error = 0; +module_param(g_fpga_pcie_dev_debug, int, S_IRUGO | S_IWUSR); +module_param(g_fpga_pcie_dev_error, int, S_IRUGO | S_IWUSR); + +#define FPGA_PCIE_DEV_VERBOSE(fmt, args...) do { \ + if (g_fpga_pcie_dev_debug) { \ + printk(KERN_INFO "[FPGA_PCIE][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define FPGA_PCIE_DEV_ERROR(fmt, args...) do { \ + if (g_fpga_pcie_dev_error) { \ + printk(KERN_ERR "[FPGA_PCIE][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +typedef struct rg_fpga_pcie_s { + struct pci_dev *pci_dev; + int driver_data; +} rg_fpga_pcie_t; + +static void fpga_pcie_recover(struct pci_dev *pdev, const struct pci_device_id *id) +{ + struct resource *mem_base; + u32 bar0_val; + int ret; + + mem_base = &pdev->resource[0]; + ret = pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &bar0_val); + if (ret) { + FPGA_PCIE_DEV_ERROR("pci_read_config_dword failed ret %d.\n", ret); + return; + } + FPGA_PCIE_DEV_VERBOSE("mem_base->start[0x%llx], bar0_val[0x%x], ret %d.\n", + mem_base->start, bar0_val, ret); + + if (bar0_val != mem_base->start) { + ret = pci_write_config_dword(pdev, PCI_BASE_ADDRESS_0, mem_base->start); + if (ret) { + FPGA_PCIE_DEV_ERROR("pci_write_config_dword mem_base->start[0x%llx], failed ret %d.\n", mem_base->start, ret); + return; + } + FPGA_PCIE_DEV_VERBOSE("pci_write_config_dword mem_base->start[0x%llx] success.\n", mem_base->start); + } else { + FPGA_PCIE_DEV_VERBOSE("mem_base->start[0x%llx], bar0_val[0x%x], do nothing.\n", + mem_base->start, bar0_val); + } +} + +static int fpga_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id) +{ + int err; + rg_fpga_pcie_t *rg_fpga_pcie; + + FPGA_PCIE_DEV_VERBOSE("Enter vendor 0x%x, subsystem_vendor 0x%x.\n", pdev->vendor, pdev->subsystem_vendor); + + rg_fpga_pcie = devm_kzalloc(&pdev->dev, sizeof(rg_fpga_pcie_t), GFP_KERNEL); + if (!rg_fpga_pcie) { + dev_err(&pdev->dev, "devm_kzalloc failed.\n"); + return -ENOMEM; + } + + fpga_pcie_recover(pdev, id); + + /* enable device: ask low-level code to enable I/O and memory */ + FPGA_PCIE_DEV_VERBOSE("start pci_enable_device!\n"); + err = pci_enable_device(pdev); + if (err) { + dev_err(&pdev->dev, "Failed to enable pci device, ret:%d.\n", err); + return err; + } + + FPGA_PCIE_DEV_VERBOSE("start pci_set_master!\n"); + pci_set_master(pdev); + + rg_fpga_pcie->driver_data = id->driver_data; + rg_fpga_pcie->pci_dev = pdev; + pci_set_drvdata(pdev, rg_fpga_pcie); + + if (rg_fpga_pcie->driver_data == XILINX_FPGA_USE_MSI) { + FPGA_PCIE_DEV_VERBOSE("start pci_enable_msi_range!\n"); +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,19,152) + err = pci_enable_msi_range(pdev, FPGA_MSI_IRQ_BEGIN + 1, FPGA_MSI_IRQ_NUM); +#else + err = pci_alloc_irq_vectors_affinity(pdev, FPGA_MSI_IRQ_BEGIN + 1, + FPGA_MSI_IRQ_NUM, PCI_IRQ_MSI, NULL); +#endif + if (err != FPGA_MSI_IRQ_NUM) { + FPGA_PCIE_DEV_ERROR("pci_enable_msi_block err %d FPGA_MSI_IRQ_NUM %d.\n", err, + FPGA_MSI_IRQ_NUM); + dev_err(&pdev->dev, "Failed to enable pci msi, ret:%d.\n", err); + return -EINVAL; + } + } + + dev_info(&pdev->dev, "fpga pci device init success.\n"); + return 0; +} + +static void fpga_pcie_remove(struct pci_dev *pdev) +{ + rg_fpga_pcie_t *rg_fpga_pcie; + + FPGA_PCIE_DEV_VERBOSE("fpga_pcie_remove.\n"); + + rg_fpga_pcie = pci_get_drvdata(pdev); + if (rg_fpga_pcie->driver_data == XILINX_FPGA_USE_MSI) { + FPGA_PCIE_DEV_VERBOSE("start pci_disable_msi!\n"); + pci_disable_msi(pdev); + } + + pci_disable_device(pdev); + return; +} + +static const struct pci_device_id fpga_pci_ids[] = { + { PCI_DEVICE(0x10ee, 0x7022), .driver_data = XILINX_FPGA_USE_MSI}, + { PCI_DEVICE(0x10ee, 0x7011), .driver_data = XILINX_FPGA_NUSE_MSI}, + {0} +}; +MODULE_DEVICE_TABLE(pci, fpga_pci_ids); + +static struct pci_driver rg_fpga_pcie_driver = { + .name = "rg_fpga_pcie", + .id_table = fpga_pci_ids,/* only dynamic id's */ + .probe = fpga_pcie_probe, + .remove = fpga_pcie_remove, +}; + +static int __init rg_fpga_pcie_init(void) +{ + + FPGA_PCIE_DEV_VERBOSE("rg_fpga_pcie_init enter!\n"); + return pci_register_driver(&rg_fpga_pcie_driver); +} + +static void __exit rg_fpga_pcie_exit(void) +{ + FPGA_PCIE_DEV_VERBOSE("rg_fpga_pcie_exit enter!\n"); + pci_unregister_driver(&rg_fpga_pcie_driver); + return; +} + +module_init(rg_fpga_pcie_init); +module_exit(rg_fpga_pcie_exit); +MODULE_DESCRIPTION("fpga pcie driver"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd "); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_gpio_d1500.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_gpio_d1500.c new file mode 100644 index 000000000000..41c63ec195ce --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_gpio_d1500.c @@ -0,0 +1,367 @@ +/* + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + * + * Copyright (C) 2011, 2012 Cavium Inc. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define GPIO_NAME "rg_gpio_d1500" + +#define GPIO_BASE (0x500) +#define GP_IO_SEL (GPIO_BASE + 0x4) +#define GP_LVL (GPIO_BASE + 0xC) +#define GPI_NMI_EN (GPIO_BASE + 0x28) +#define GPI_NMI_STS (GPIO_BASE + 0x2a) +#define GPI_INV (GPIO_BASE + 0x2c) +#define GPIO_USE_SEL2 (GPIO_BASE + 0x30) +#define GP_IO_SEL2 (GPIO_BASE + 0x34) +#define GP_LVL2 (GPIO_BASE + 0x38) +#define GPI_NMI_EN_2 (GPIO_BASE + 0x3c) +#define GPI_NMI_STS_2 (GPIO_BASE + 0x3e) +#define GPIO_USE_SEL3 (GPIO_BASE + 0x40) +#define GP_IO_SEL3 (GPIO_BASE + 0x44) +#define GP_LVL3 (GPIO_BASE + 0x48) +#define GPI_NMI_EN_3 (GPIO_BASE + 0x50) +#define GPI_NMI_STS_3 (GPIO_BASE + 0x54) + +#define GPIO_BASE_ID (0) +#define BANKSIZE (32) +#define D1500_GPIO_PIN_NUM (96) +#define CELL_NUM (2) + +int g_gpio_d1500_debug = 0; +int g_gpio_d1500_error = 0; +module_param(g_gpio_d1500_debug, int, S_IRUGO | S_IWUSR); +module_param(g_gpio_d1500_error, int, S_IRUGO | S_IWUSR); + +#define GPIO_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_gpio_d1500_debug) { \ + printk(KERN_ERR "[GPIO-D1500][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define GPIO_DEBUG_ERROR(fmt, args...) do { \ + if (g_gpio_d1500_error) { \ + printk(KERN_ERR "[GPIO-D1500][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static DEFINE_SPINLOCK(sio_lock); + +struct gpio_d1500_t { + struct gpio_chip chip; + u64 register_base; +}; + +static int rg_gpio_get(struct gpio_chip *gc, unsigned gpio_num) +{ + u32 data = 0; + unsigned int bank, offset; + unsigned long flags; + + bank = gpio_num / BANKSIZE; + offset = gpio_num % BANKSIZE; + + spin_lock_irqsave(&sio_lock, flags); + if (bank == 0) { + data = inl(GP_LVL) & (1 << offset); + if (data) { + data = 1; + } + } else if (bank == 1) { + data = inl(GP_LVL2) & (1 << offset); + if (data) { + data = 1; + } + } else if (bank == 2) { + data = inl(GP_LVL3) & (1 << offset); + if (data) { + data = 1; + } + } + spin_unlock_irqrestore(&sio_lock, flags); + + return data; +} + +static int rg_gpio_direction_in(struct gpio_chip *gc, unsigned gpio_num) +{ + u32 data; + unsigned int bank, offset; + unsigned long flags; + + bank = gpio_num / BANKSIZE; + offset = gpio_num % BANKSIZE; + + spin_lock_irqsave(&sio_lock, flags); + if (bank == 0) { + data = inl(GP_IO_SEL); + data = data | (1 << offset); + outl(data, GP_IO_SEL); + } else if (bank == 1) { + data = inl(GP_IO_SEL2); + data = data | (1 << offset); + outl(data, GP_IO_SEL2); + } else if (bank == 2) { + data = inl(GP_IO_SEL3); + data = data | (1 << offset); + outl(data, GP_IO_SEL3); + } + spin_unlock_irqrestore(&sio_lock, flags); + + return 0; +} + +static void rg_gpio_set(struct gpio_chip *gc, + unsigned gpio_num, int val) +{ + u32 data; + unsigned int bank, offset; + unsigned long flags; + + bank = gpio_num / BANKSIZE; + offset = gpio_num % BANKSIZE; + + spin_lock_irqsave(&sio_lock, flags); + if (bank == 0) { + data = inl(GP_LVL); + if (val) { + data = data | (1 << offset); + } else { + data = data & ~(1 << offset); + } + outl(data, GP_LVL); + } else if (bank == 1) { + data = inl(GP_LVL2); + if (val) { + data = data | (1 << offset); + } else { + data = data & ~(1 << offset); + } + outl(data, GP_LVL2); + } else if (bank == 2) { + data = inl(GP_LVL3); + if (val) { + data = data | (1 << offset); + } else { + data = data & ~(1 << offset); + } + outl(data, GP_LVL3); + } + spin_unlock_irqrestore(&sio_lock, flags); + + return; +} + +static int rg_gpio_direction_out(struct gpio_chip *gc, + unsigned gpio_num, int val) +{ + u32 data; + unsigned int bank, offset; + unsigned long flags; + + bank = gpio_num / BANKSIZE; + offset = gpio_num % BANKSIZE; + + spin_lock_irqsave(&sio_lock, flags); + if (bank == 0) { + data = inl(GP_IO_SEL); + data = data & ~(1 << offset); + outl(data, GP_IO_SEL); + + data = inl(GP_LVL); + if (val) { + data = data | (1 << offset); + } else { + data = data & ~(1 << offset); + } + outl(data, GP_LVL); + } else if (bank == 1) { + data = inl(GP_IO_SEL2); + data = data & ~(1 << offset); + outl(data, GP_IO_SEL2); + + data = inl(GP_LVL2); + if (val) { + data = data | (1 << offset); + } else { + data = data & ~(1 << offset); + } + outl(data, GP_LVL2); + } else if (bank == 2) { + data = inl(GP_IO_SEL3); + data = data & ~(1 << offset); + outl(data, GP_IO_SEL3); + + data = inl(GP_LVL3); + if (val) { + data = data | (1 << offset); + } else { + data = data & ~(1 << offset); + } + outl(data, GP_LVL3); + } + spin_unlock_irqrestore(&sio_lock, flags); + + return 0; +} + +#ifdef CONFIG_OF +static int rg_gpio_of_xlate(struct gpio_chip *chip, + const struct of_phandle_args *gpio_desc, + u32 *flags) +{ + if (chip->of_gpio_n_cells < 2) { + return -EINVAL; + } + + if (flags) { + *flags = gpio_desc->args[1]; + } + + return gpio_desc->args[0]; +} +#endif + +static int rg_gpio_request(struct gpio_chip *chip, unsigned int offset) +{ + u32 data; + unsigned int bank, tmp_offset; + unsigned long flags; + + bank = offset / BANKSIZE; + tmp_offset = offset % BANKSIZE; + + spin_lock_irqsave(&sio_lock, flags); + if (bank == 0) { + data = inl(GPIO_BASE); + data = data | (1 << tmp_offset); + outl(data, GPIO_BASE); + } else if (bank == 1) { + data = inl(GPIO_USE_SEL2); + data = data | (1 << tmp_offset); + outl(data, GPIO_USE_SEL2); + } else if (bank == 2) { + data = inl(GPIO_USE_SEL3); + data = data | (1 << tmp_offset); + outl(data, GPIO_USE_SEL3); + } + spin_unlock_irqrestore(&sio_lock, flags); + + return 0; +} + +#if 0 +static void rg_gpio_free(struct gpio_chip *chip, unsigned int offset) +{ + u32 data; + unsigned int bank, tmp_offset; + unsigned long flags; + + bank = offset / BANKSIZE; + tmp_offset = offset % BANKSIZE; + + spin_lock_irqsave(&sio_lock, flags); + if (bank == 0) { + data = inl(GPIO_BASE); + data = data & ~(1 << tmp_offset); + outl(data, GPIO_BASE); + } else if (bank == 1) { + data = inl(GPIO_USE_SEL2); + data = data & ~(1 << tmp_offset); + outl(data, GPIO_USE_SEL2); + } else if (bank == 2) { + data = inl(GPIO_USE_SEL3); + data = data & ~(1 << tmp_offset); + outl(data, GPIO_USE_SEL3); + } + + spin_unlock_irqrestore(&sio_lock, flags); + + return; +} +#endif + +static struct gpio_chip rg_gpio_chip = { + .label = GPIO_NAME, + .owner = THIS_MODULE, + .base = GPIO_BASE_ID, + .get = rg_gpio_get, + .direction_input = rg_gpio_direction_in, + .set = rg_gpio_set, + .direction_output = rg_gpio_direction_out, +#ifdef CONFIG_OF + .of_xlate = rg_gpio_of_xlate, +#endif + .request = rg_gpio_request, + .ngpio = D1500_GPIO_PIN_NUM, +#ifdef CONFIG_OF + .of_gpio_n_cells = CELL_NUM, +#endif + .can_sleep = false, +}; + +static int rg_gpio_probe(struct platform_device *pdev) +{ + struct gpio_d1500_t *gpio; + int err; + + gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL); + if (!gpio) { + dev_err(&pdev->dev, "gpio kzalloc failed\n"); + return -ENOMEM; + } + + rg_gpio_chip.parent = &pdev->dev; + gpio->register_base = GPIO_BASE; + gpio->chip = rg_gpio_chip; + pdev->dev.platform_data = &rg_gpio_chip; + err = devm_gpiochip_add_data(&pdev->dev, &rg_gpio_chip, gpio); + if (err) { + dev_err(&pdev->dev, "gpiochip add failed\n"); + return err; + } + + dev_info(&pdev->dev, "register %llu gpio success.\n", gpio->register_base); + + return 0; +} + +static int rg_gpio_remove(struct platform_device *pdev) +{ + dev_info(&pdev->dev, "unregister d1500 gpio success\n"); + return 0; +} + +static const struct of_device_id gpio_d1500_match[] = { + { + .compatible = "ruijie,rg_gpio_d1500", + }, + {}, +}; +MODULE_DEVICE_TABLE(of, gpio_d1500_match); + +static struct platform_driver rg_gpio_driver = { + .driver = { + .name = GPIO_NAME, + .of_match_table = gpio_d1500_match, + }, + .probe = rg_gpio_probe, + .remove = rg_gpio_remove, +}; + +module_platform_driver(rg_gpio_driver); + +MODULE_DESCRIPTION("d1500 gpio driver"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd "); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_gpio_device.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_gpio_device.c new file mode 100644 index 000000000000..fccb813bbd2d --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_gpio_device.c @@ -0,0 +1,54 @@ +#include +#include +#include +#include +#include + +static int g_rg_gpio_device_debug = 0; +static int g_rg_gpio_device_error = 0; + +module_param(g_rg_gpio_device_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_gpio_device_error, int, S_IRUGO | S_IWUSR); + +#define RG_GPIO_DEVICE_VERBOSE(fmt, args...) do { \ + if (g_rg_gpio_device_debug) { \ + printk(KERN_INFO "[RG_GPIO_DEVICE][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RG_GPIO_DEVICE_ERROR(fmt, args...) do { \ + if (g_rg_gpio_device_error) { \ + printk(KERN_ERR "[RG_GPIO_DEVICE][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static void rg_gpio_device_release(struct device *dev) +{ + return; +} + +static struct platform_device rg_gpio_d1500_device = { + .name = "rg_gpio_d1500", + .id = -1, + .dev = { + .release = rg_gpio_device_release, + }, +}; + +static int __init rg_gpio_device_init(void) +{ + RG_GPIO_DEVICE_VERBOSE("rg_gpio_device_init enter!\n"); + return platform_device_register(&rg_gpio_d1500_device); +} + +static void __exit rg_gpio_device_exit(void) +{ + RG_GPIO_DEVICE_VERBOSE("rg_gpio_device_exit enter!\n"); + return platform_device_unregister(&rg_gpio_d1500_device); +} + +module_init(rg_gpio_device_init); +module_exit(rg_gpio_device_exit); +MODULE_DESCRIPTION("GPIO Devices"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd@ruijie.com.cn"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_i2c_dev.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_i2c_dev.c new file mode 100644 index 000000000000..8fb1c75dfee4 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_i2c_dev.c @@ -0,0 +1,777 @@ +/* + * Copyright(C) 2022 Ruijie Network. All rights reserved. + * + * rg_io_dev.c + * ko to read/write i2c client through /dev/XXX device + * Original Author: sonic_rd@ruijie.com.cn 2022-09-09 + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "rg_i2c_dev.h" + +#define MAX_I2C_DEV_NUM (256) +#define FPGA_MAX_LEN (256) +#define MAX_NAME_SIZE (20) +#define MAX_BUS_WIDTH (16) +#define TRANSFER_WRITE_BUFF (FPGA_MAX_LEN + MAX_BUS_WIDTH) + +#define WIDTH_1Byte (1) +#define WIDTH_2Byte (2) +#define WIDTH_4Byte (4) + +static int g_i2c_dev_debug = 0; +static int g_i2c_dev_error = 0; + +module_param(g_i2c_dev_debug, int, S_IRUGO | S_IWUSR); +module_param(g_i2c_dev_error, int, S_IRUGO | S_IWUSR); + +#define I2C_DEV_DEBUG_DMESG(fmt, args...) do { \ + if (g_i2c_dev_debug) { \ + printk(KERN_ERR "[I2C_DEV][DEBUG][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define I2C_DEV_DEBUG_ERROR(fmt, args...) do { \ + if (g_i2c_dev_error) { \ + printk(KERN_ERR "[I2C_DEV][ERR][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static struct i2c_dev_info* i2c_dev_arry[MAX_I2C_DEV_NUM]; + +struct i2c_dev_info { + const char *name; + uint32_t data_bus_width; + uint32_t addr_bus_width; + uint32_t per_rd_len; + uint32_t per_wr_len; + uint32_t i2c_len; + struct miscdevice misc; + struct i2c_client *client; +}; + +static int transfer_read(struct i2c_client *client, u8 *buf, loff_t regaddr, size_t count) +{ + struct i2c_adapter *adap; + int i; + u8 offset_buf[MAX_BUS_WIDTH]; + struct i2c_msg msgs[2]; + int msgs_num, ret; + struct i2c_dev_info *i2c_dev; + + if (!client) { + I2C_DEV_DEBUG_ERROR("can't get read client\n"); + return -ENODEV; + } + + adap = client->adapter; + if (!adap) { + I2C_DEV_DEBUG_ERROR("can't get read adap\n"); + return -ENODEV; + } + + i2c_dev = i2c_get_clientdata(client); + if (!i2c_dev) { + I2C_DEV_DEBUG_ERROR("can't get read i2c_dev\n"); + return -ENODEV; + } + + i = 0; + + memset(offset_buf, 0, sizeof(offset_buf)); + + switch (i2c_dev->addr_bus_width) { + case WIDTH_4Byte: + offset_buf[i++] = (regaddr >> 24) & 0xFF; + offset_buf[i++] = (regaddr >> 16) & 0xFF; + offset_buf[i++] = (regaddr >> 8) & 0xFF; + offset_buf[i++] = regaddr & 0xFF; + break; + case WIDTH_2Byte: + offset_buf[i++] = (regaddr >> 8) & 0xFF; + offset_buf[i++] = regaddr & 0xFF; + break; + case WIDTH_1Byte: + offset_buf[i++] = regaddr & 0xFF; + break; + default: + I2C_DEV_DEBUG_ERROR("Only support 1,2,4 Byte Address Width,but set width = %u\n", + i2c_dev->addr_bus_width); + return -EINVAL; + } + + if (adap->algo->master_xfer) { + memset(msgs, 0, sizeof(msgs)); + msgs[0].addr = client->addr; + msgs[0].flags = 0; + msgs[0].len = i2c_dev->addr_bus_width; + msgs[0].buf = offset_buf; + + msgs[1].addr = client->addr; + msgs[1].flags = I2C_M_RD; + msgs[1].len = count; + msgs[1].buf = buf; + + msgs_num = 2; + ret = i2c_transfer(client->adapter, msgs, msgs_num); + if (ret != msgs_num) { + I2C_DEV_DEBUG_ERROR("i2c_transfer read error\n"); + return -EINVAL; + } + } else { + I2C_DEV_DEBUG_ERROR("don't find read master_xfer\n"); + return -EINVAL; + + } + return 0; +} + +static int transfer_write(struct i2c_client *client, u8 *buf, loff_t regaddr, size_t count) +{ + struct i2c_adapter *adap; + int i; + u8 offset_buf[TRANSFER_WRITE_BUFF]; + struct i2c_msg msgs[1]; + int msgs_num, ret; + struct i2c_dev_info *i2c_dev; + + if (!client) { + I2C_DEV_DEBUG_ERROR("can't get write client\n"); + return -ENODEV; + } + + adap = client->adapter; + if (!adap) { + I2C_DEV_DEBUG_ERROR("can't get write adap\n"); + return -ENODEV; + } + + i2c_dev = i2c_get_clientdata(client); + if (!i2c_dev) { + I2C_DEV_DEBUG_ERROR("can't get read i2c_dev\n"); + return -ENODEV; + } + + i = 0; + + memset(offset_buf, 0, sizeof(offset_buf)); + + switch (i2c_dev->addr_bus_width) { + case WIDTH_4Byte: + offset_buf[i++] = (regaddr >> 24) & 0xFF; + offset_buf[i++] = (regaddr >> 16) & 0xFF; + offset_buf[i++] = (regaddr >> 8) & 0xFF; + offset_buf[i++] = regaddr & 0xFF; + break; + case WIDTH_2Byte: + offset_buf[i++] = (regaddr >> 8) & 0xFF; + offset_buf[i++] = regaddr & 0xFF; + break; + case WIDTH_1Byte: + offset_buf[i++] = regaddr & 0xFF; + break; + default: + I2C_DEV_DEBUG_ERROR("Only support 1,2,4 Byte Address Width,but set width = %u\n", + i2c_dev->addr_bus_width); + return -EINVAL; + } + + memcpy(offset_buf + i2c_dev->addr_bus_width, buf, count); + + if (adap->algo->master_xfer) { + memset(msgs, 0, sizeof(msgs)); + + msgs[0].addr = client->addr; + msgs[0].flags = 0; + msgs[0].len = i2c_dev->addr_bus_width + count; + msgs[0].buf = offset_buf; + + msgs_num = 1; + ret = i2c_transfer(adap, msgs, msgs_num); + if (ret != msgs_num) { + I2C_DEV_DEBUG_ERROR("i2c_transfer write error\n"); + return -EINVAL; + } + } else { + I2C_DEV_DEBUG_ERROR("don't find write master_xfer\n"); + return -EINVAL; + } + + return 0; +} + +static long i2c_dev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +{ + return 0; +} + +static int i2c_dev_open(struct inode *inode, struct file *file) +{ + unsigned int minor = iminor(inode); + struct i2c_dev_info *i2c_dev; + + i2c_dev = i2c_dev_arry[minor]; + if (i2c_dev == NULL) { + return -ENODEV; + } + + file->private_data = i2c_dev; + + return 0; +} + +static int i2c_dev_release(struct inode *inode, struct file *file) +{ + file->private_data = NULL; + + return 0; +} + +static int device_read(struct i2c_dev_info *i2c_dev, uint32_t offset, uint8_t *buf, size_t count) +{ + int i, j, ret; + u8 tmp_offset; + u8 val[FPGA_MAX_LEN]; + u32 width, rd_len, per_len, tmp; + u32 max_per_len; + + if (offset > i2c_dev->i2c_len) { + I2C_DEV_DEBUG_DMESG("offset: 0x%x, i2c len: 0x%x, count: %lu, EOF.\n", + offset, i2c_dev->i2c_len, count); + return 0; + } + + if (count > (i2c_dev->i2c_len - offset)) { + I2C_DEV_DEBUG_DMESG("read count out of range. input len:%lu, read len:%u.\n", + count, i2c_dev->i2c_len - offset); + count = i2c_dev->i2c_len - offset; + } + + if (count == 0) { + I2C_DEV_DEBUG_DMESG("offset: 0x%x, i2c len: 0x%x, read len: %lu, EOF.\n", + offset, i2c_dev->i2c_len, count); + return 0; + } + + width = i2c_dev->data_bus_width; + switch (width) { + case WIDTH_4Byte: + tmp_offset = offset & 0x3; + if (tmp_offset) { + I2C_DEV_DEBUG_ERROR("data bus width:%u, offset:%u, read size %lu invalid.\n", + width, offset, count); + return -EINVAL; + } + break; + case WIDTH_2Byte: + tmp_offset = offset & 0x1; + if (tmp_offset) { + I2C_DEV_DEBUG_ERROR("data bus width:%u, offset:%u, read size %lu invalid.\n", + width, offset, count); + return -EINVAL; + } + break; + case WIDTH_1Byte: + break; + default: + I2C_DEV_DEBUG_ERROR("Only support 1,2,4 Byte Data Width,but set width = %u\n", width); + return -EINVAL; + } + + max_per_len = i2c_dev->per_rd_len; + tmp = (width - 1) & count; + rd_len = (tmp == 0) ? count : count + width - tmp; + per_len = (rd_len > max_per_len) ? (max_per_len) : (rd_len); + + memset(val, 0, sizeof(val)); + for (i = 0; i < rd_len; i += per_len) { + ret = transfer_read(i2c_dev->client, val + i, offset + i, per_len); + if (ret < 0) { + I2C_DEV_DEBUG_ERROR("read error.read offset = %u\n", (offset + i)); + return -EFAULT; + } + } + + if (width == WIDTH_1Byte) { + memcpy(buf, val, count); + } else { + for (i = 0; i < count; i += width) { + for (j = 0; (j < width) && (i + j < count); j++) { + buf[i + j] = val[i + width - j - 1]; + } + } + } + + return count; +} + +static int device_write(struct i2c_dev_info *i2c_dev, uint32_t offset, uint8_t *buf, size_t count) +{ + int i, j, ret; + u8 tmp_offset; + u32 width; + u8 val[FPGA_MAX_LEN]; + u32 wr_len, per_len, tmp; + u32 max_per_len; + + if (offset > i2c_dev->i2c_len) { + I2C_DEV_DEBUG_DMESG("offset: 0x%x, i2c len: 0x%x, count: %lu, EOF.\n", + offset, i2c_dev->i2c_len, count); + return 0; + } + + if (count > (i2c_dev->i2c_len - offset)) { + I2C_DEV_DEBUG_DMESG("read count out of range. input len:%lu, read len:%u.\n", + count, i2c_dev->i2c_len - offset); + count = i2c_dev->i2c_len - offset; + } + + if (count == 0) { + I2C_DEV_DEBUG_DMESG("offset: 0x%x, i2c len: 0x%x, read len: %lu, EOF.\n", + offset, i2c_dev->i2c_len, count); + return 0; + } + + width = i2c_dev->data_bus_width; + switch (width) { + case WIDTH_4Byte: + tmp_offset = offset & 0x3; + if (tmp_offset) { + I2C_DEV_DEBUG_ERROR("data bus width:%u, offset:%u, read size %lu invalid.\n", + width, offset, count); + return -EINVAL; + } + break; + case WIDTH_2Byte: + tmp_offset = offset & 0x1; + if (tmp_offset) { + I2C_DEV_DEBUG_ERROR("data bus width:%u, offset:%u, read size %lu invalid.\n", + width, offset, count); + return -EINVAL; + } + break; + case WIDTH_1Byte: + break; + default: + I2C_DEV_DEBUG_ERROR("Only support 1,2,4 Byte Data Width,but set width = %u\n", width); + return -EINVAL; + } + + memset(val, 0, sizeof(val)); + + if (width == WIDTH_1Byte) { + memcpy(val, buf, count); + } else { + for (i = 0; i < count; i += width) { + for (j = 0; (j < width) && (i + j < count); j++) { + val[i + width - j - 1] = buf[i + j]; + } + } + } + + max_per_len = i2c_dev->per_wr_len; + tmp = (width - 1) & count; + wr_len = (tmp == 0) ? count : count + width - tmp; + per_len = (wr_len > max_per_len) ? (max_per_len) : (wr_len); + + for (i = 0; i < wr_len; i += per_len) { + ret = transfer_write(i2c_dev->client, val + i, offset + i, per_len); + if (ret < 0) { + I2C_DEV_DEBUG_ERROR("write error.offset = %u\n", (offset + i)); + return -EFAULT; + } + } + return count; +} + +static ssize_t i2c_dev_read(struct file *file, char __user *buf, size_t count, loff_t *offset) +{ + u8 val[FPGA_MAX_LEN]; + int ret, read_len; + struct i2c_dev_info *i2c_dev; + + i2c_dev = file->private_data; + if (i2c_dev == NULL) { + I2C_DEV_DEBUG_ERROR("can't get read private_data.n"); + return -EINVAL; + } + + if (count == 0) { + I2C_DEV_DEBUG_ERROR("Invalid params, read count is 0.n"); + return -EINVAL; + } + + if (count > sizeof(val)) { + I2C_DEV_DEBUG_DMESG("read conut %lu exceed max %lu.\n", count, sizeof(val)); + count = sizeof(val); + } + + memset(val, 0, sizeof(val)); + read_len = device_read(i2c_dev, (uint32_t)*offset, val, count); + if (read_len < 0) { + I2C_DEV_DEBUG_ERROR("i2c dev read failed, dev name:%s, offset:0x%x, len:%lu.\n", + i2c_dev->name, (uint32_t)*offset, count); + return read_len; + } + + if (access_ok(buf, read_len)) { + I2C_DEV_DEBUG_DMESG("user space read, buf: %p, offset: %lld, read conut %lu.\n", + buf, *offset, count); + if (copy_to_user(buf, val, read_len)) { + I2C_DEV_DEBUG_ERROR("copy_to_user failed.\n"); + return -EFAULT; + } + } else { + I2C_DEV_DEBUG_DMESG("kernel space read, buf: %p, offset: %lld, read conut %lu.\n", + buf, *offset, count); + memcpy(buf, val, read_len); + } + + *offset += read_len; + ret = read_len; + return ret; +} + +static ssize_t i2c_dev_read_iter(struct kiocb *iocb, struct iov_iter *to) +{ + int ret; + + I2C_DEV_DEBUG_DMESG("i2c_dev_read_iter, file: %p, count: %lu, offset: %lld\n", + iocb->ki_filp, to->count, iocb->ki_pos); + ret = i2c_dev_read(iocb->ki_filp, to->kvec->iov_base, to->count, &iocb->ki_pos); + return ret; +} + +static ssize_t i2c_dev_write(struct file *file, const char __user *buf, size_t count, loff_t *offset) +{ + u8 val[FPGA_MAX_LEN]; + int write_len; + struct i2c_dev_info *i2c_dev; + + i2c_dev = file->private_data; + if (i2c_dev == NULL) { + I2C_DEV_DEBUG_ERROR("get write private_data error.\n"); + return -EINVAL; + } + + if (count == 0) { + I2C_DEV_DEBUG_ERROR("Invalid params, write count is 0.\n"); + return -EINVAL; + } + + if (count > sizeof(val)) { + I2C_DEV_DEBUG_DMESG("write conut %lu exceed max %lu.\n", count, sizeof(val)); + count = sizeof(val); + } + + memset(val, 0, sizeof(val)); + if (access_ok(buf, count)) { + I2C_DEV_DEBUG_DMESG("user space write, buf: %p, offset: %lld, write conut %lu.\n", + buf, *offset, count); + if (copy_from_user(val, buf, count)) { + I2C_DEV_DEBUG_ERROR("copy_from_user failed.\n"); + return -EFAULT; + } + } else { + I2C_DEV_DEBUG_DMESG("kernel space write, buf: %p, offset: %lld, write conut %lu.\n", + buf, *offset, count); + memcpy(val, buf, count); + } + + write_len = device_write(i2c_dev, (uint32_t)*offset, val, count); + if (write_len < 0) { + I2C_DEV_DEBUG_ERROR("i2c dev write failed, dev name:%s, offset:0x%llx, len:%lu.\n", + i2c_dev->name, *offset, count); + return write_len; + } + + *offset += write_len; + return write_len; +} + +static ssize_t i2c_dev_write_iter(struct kiocb *iocb, struct iov_iter *from) +{ + int ret; + + I2C_DEV_DEBUG_DMESG("i2c_dev_write_iter, file: %p, count: %lu, offset: %lld\n", + iocb->ki_filp, from->count, iocb->ki_pos); + ret = i2c_dev_write(iocb->ki_filp, from->kvec->iov_base, from->count, &iocb->ki_pos); + return ret; +} + +static loff_t i2c_dev_llseek(struct file *file, loff_t offset, int origin) +{ + loff_t ret = 0; + struct i2c_dev_info *i2c_dev; + + i2c_dev = file->private_data; + if (i2c_dev == NULL) { + I2C_DEV_DEBUG_ERROR("i2c_dev is NULL, llseek failed.\n"); + return -EINVAL; + } + + switch (origin) { + case SEEK_SET: + if (offset < 0) { + I2C_DEV_DEBUG_ERROR("SEEK_SET, offset:%lld, invalid.\n", offset); + ret = -EINVAL; + break; + } + if (offset > i2c_dev->i2c_len) { + I2C_DEV_DEBUG_ERROR("SEEK_SET out of range, offset:%lld, i2c_len:0x%x.\n", + offset, i2c_dev->i2c_len); + ret = - EINVAL; + break; + } + file->f_pos = offset; + ret = file->f_pos; + break; + case SEEK_CUR: + if (((file->f_pos + offset) > i2c_dev->i2c_len) || ((file->f_pos + offset) < 0)) { + I2C_DEV_DEBUG_ERROR("SEEK_CUR out of range, f_ops:%lld, offset:%lld, i2c_len:0x%x.\n", + file->f_pos, offset, i2c_dev->i2c_len); + ret = - EINVAL; + break; + } + file->f_pos += offset; + ret = file->f_pos; + break; + default: + I2C_DEV_DEBUG_ERROR("unsupport llseek type:%d.\n", origin); + ret = -EINVAL; + break; + } + return ret; +} + +static const struct file_operations i2c_dev_fops = { + .owner = THIS_MODULE, + .llseek = i2c_dev_llseek, + .read_iter = i2c_dev_read_iter, + .write_iter = i2c_dev_write_iter, + .unlocked_ioctl = i2c_dev_ioctl, + .open = i2c_dev_open, + .release = i2c_dev_release, +}; + +static struct i2c_dev_info * dev_match(const char *path) +{ + struct i2c_dev_info * i2c_dev; + char dev_name[MAX_NAME_SIZE]; + int i; + for (i = 0; i < MAX_I2C_DEV_NUM; i++) { + if (i2c_dev_arry[ i ] == NULL) { + continue; + } + i2c_dev = i2c_dev_arry[ i ]; + snprintf(dev_name, MAX_NAME_SIZE,"/dev/%s", i2c_dev->name); + if (!strcmp(path, dev_name)) { + I2C_DEV_DEBUG_DMESG("get dev_name = %s, minor = %d\n", dev_name, i); + return i2c_dev; + } + } + + return NULL; +} + +int i2c_device_func_read(const char *path, uint32_t offset, uint8_t *buf, size_t count) +{ + struct i2c_dev_info *i2c_dev = NULL; + int ret; + + if(path == NULL){ + I2C_DEV_DEBUG_ERROR("path NULL"); + return -EINVAL; + } + + if(buf == NULL){ + I2C_DEV_DEBUG_ERROR("buf NULL"); + return -EINVAL; + } + + if (count > FPGA_MAX_LEN) { + I2C_DEV_DEBUG_ERROR("read conut %lu, beyond max:%d.\n", count, FPGA_MAX_LEN); + return -EINVAL; + } + + i2c_dev = dev_match(path); + if (i2c_dev == NULL) { + I2C_DEV_DEBUG_ERROR("i2c_dev match failed. dev path = %s", path); + return -EINVAL; + } + + ret = device_read(i2c_dev, offset, buf, count); + if (ret < 0) { + I2C_DEV_DEBUG_ERROR("fpga i2c dev read failed, dev name:%s, offset:0x%x, len:%lu.\n", + i2c_dev->name, offset, count); + return -EINVAL; + } + + return count; +} +EXPORT_SYMBOL(i2c_device_func_read); + +int i2c_device_func_write(const char *path, uint32_t offset, uint8_t *buf, size_t count) +{ + struct i2c_dev_info *i2c_dev = NULL; + int ret; + + if(path == NULL){ + I2C_DEV_DEBUG_ERROR("path NULL"); + return -EINVAL; + } + + if(buf == NULL){ + I2C_DEV_DEBUG_ERROR("buf NULL"); + return -EINVAL; + } + + if (count > FPGA_MAX_LEN) { + I2C_DEV_DEBUG_ERROR("write conut %lu, beyond max:%d.\n", count, FPGA_MAX_LEN); + return -EINVAL; + } + + i2c_dev = dev_match(path); + if (i2c_dev == NULL) { + I2C_DEV_DEBUG_ERROR("i2c_dev match failed. dev path = %s", path); + return -EINVAL; + } + + ret = device_write (i2c_dev, offset, buf, count); + if (ret < 0) { + I2C_DEV_DEBUG_ERROR("i2c dev write failed, dev name:%s, offset:0x%x, len:%lu.\n", + i2c_dev->name, offset, count); + return -EINVAL; + } + + return count; +} +EXPORT_SYMBOL(i2c_device_func_write); + +static int i2c_dev_probe(struct i2c_client *client, const struct i2c_device_id *id) +{ + int ret = 0; + struct i2c_dev_info *i2c_dev; + struct miscdevice *misc; + i2c_dev_device_t *i2c_dev_device; + + i2c_dev = devm_kzalloc(&client->dev, sizeof(struct i2c_dev_info), GFP_KERNEL); + if (!i2c_dev) { + dev_err(&client->dev, "devm_kzalloc error. \n"); + return -ENOMEM; + } + + i2c_set_clientdata(client, i2c_dev); + i2c_dev->client = client; + + if (client->dev.of_node) { + + ret += of_property_read_string(client->dev.of_node, "i2c_name", &i2c_dev->name); + ret += of_property_read_u32(client->dev.of_node, "data_bus_width", &i2c_dev->data_bus_width); + ret += of_property_read_u32(client->dev.of_node, "addr_bus_width", &i2c_dev->addr_bus_width); + ret += of_property_read_u32(client->dev.of_node, "per_rd_len", &i2c_dev->per_rd_len); + ret += of_property_read_u32(client->dev.of_node, "per_wr_len", &i2c_dev->per_wr_len); + ret += of_property_read_u32(client->dev.of_node, "i2c_len", &i2c_dev->i2c_len); + if (ret != 0) { + dev_err(&client->dev, "dts config error.ret:%d.\n", ret); + return -ENXIO; + } + } else { + if (client->dev.platform_data == NULL) { + dev_err(&client->dev, "Failed to get platform data config.\n"); + return -ENXIO; + } + i2c_dev_device = client->dev.platform_data; + i2c_dev->name = i2c_dev_device->i2c_name; + i2c_dev->data_bus_width = i2c_dev_device->data_bus_width; + i2c_dev->addr_bus_width = i2c_dev_device->addr_bus_width; + i2c_dev->per_rd_len = i2c_dev_device->per_rd_len; + i2c_dev->per_wr_len = i2c_dev_device->per_wr_len; + i2c_dev->i2c_len = i2c_dev_device->i2c_len; + } + + if ((i2c_dev->per_rd_len & (i2c_dev->data_bus_width - 1)) || + (i2c_dev->per_wr_len & (i2c_dev->data_bus_width - 1))) { + dev_err(&client->dev, "Invalid config per_rd_len %d per_wr_len %d data bus_width %d.\n", + i2c_dev->per_rd_len, i2c_dev->per_wr_len, i2c_dev->data_bus_width); + return -ENXIO; + } + + if ((i2c_dev->i2c_len == 0) || (i2c_dev->i2c_len & (i2c_dev->data_bus_width - 1))) { + dev_err(&client->dev, "Invalid config i2c_len %d, data bus_width %d.\n", + i2c_dev->i2c_len, i2c_dev->data_bus_width); + return -ENXIO; + } + + misc = &i2c_dev->misc; + misc->minor = MISC_DYNAMIC_MINOR; + misc->name = i2c_dev->name; + misc->fops = &i2c_dev_fops; + misc->mode = 0666; + if (misc_register(misc) != 0) { + dev_err(&client->dev, "register %s faild.\n", misc->name); + return -ENXIO; + } + + if (misc->minor >= MAX_I2C_DEV_NUM) { + dev_err(&client->dev, "minor number beyond the limit! is %d.\n", misc->minor); + misc_deregister(misc); + return -ENXIO; + } + i2c_dev_arry[misc->minor] = i2c_dev; + + dev_info(&client->dev, "register %u addr_bus_width %u data_bus_width 0x%x i2c_len device %s with %u per_rd_len %u per_wr_len success.\n", + i2c_dev->addr_bus_width, i2c_dev->data_bus_width, i2c_dev->i2c_len, i2c_dev->name, i2c_dev->per_rd_len, i2c_dev->per_wr_len); + + return 0; +} + +static int i2c_dev_remove(struct i2c_client *client) +{ + int i; + for (i = 0; i < MAX_I2C_DEV_NUM; i++) { + if (i2c_dev_arry[i] != NULL) { + misc_deregister(&i2c_dev_arry[i]->misc); + i2c_dev_arry[i] = NULL; + } + } + return 0; +} + +static const struct i2c_device_id i2c_dev_id[] = { + { "rg-i2c-dev", 0 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, i2c_dev_id); + +static const struct of_device_id i2c_dev_of_match[] = { + { .compatible = "ruijie,rg-i2c-dev" }, + { }, +}; +MODULE_DEVICE_TABLE(of, i2c_dev_of_match); + +static struct i2c_driver i2c_dev_driver = { + .driver = { + .name = "rg-i2c-dev", + .of_match_table = i2c_dev_of_match, + }, + .probe = i2c_dev_probe, + .remove = i2c_dev_remove, + .id_table = i2c_dev_id, +}; +module_i2c_driver(i2c_dev_driver); + +MODULE_DESCRIPTION("i2c dev driver"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd "); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_i2c_dev.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_i2c_dev.h new file mode 100644 index 000000000000..1096a54613e7 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_i2c_dev.h @@ -0,0 +1,18 @@ +#ifndef __RG_I2C_DEV_H__ +#define __RG_I2C_DEV_H__ + +#define I2C_DEV_NAME_MAX_LEN (64) + +typedef struct i2c_dev_device_s { + struct i2c_client *client; + uint32_t i2c_bus; + uint32_t i2c_addr; + char i2c_name[I2C_DEV_NAME_MAX_LEN]; + uint32_t data_bus_width; + uint32_t addr_bus_width; + uint32_t per_rd_len; + uint32_t per_wr_len; + uint32_t i2c_len; +} i2c_dev_device_t; + +#endif diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_i2c_gpio_device.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_i2c_gpio_device.c new file mode 100644 index 000000000000..2f81c7582260 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_i2c_gpio_device.c @@ -0,0 +1,110 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static int gpio_sda = 17; +module_param(gpio_sda, int, S_IRUGO | S_IWUSR); + +static int gpio_scl = 1; +module_param(gpio_scl, int, S_IRUGO | S_IWUSR); + +static int gpio_udelay = 2; +module_param(gpio_udelay, int, S_IRUGO | S_IWUSR); + +static int g_rg_i2c_gpio_device_debug = 0; +static int g_rg_i2c_gpio_device_error = 0; + +module_param(g_rg_i2c_gpio_device_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_i2c_gpio_device_error, int, S_IRUGO | S_IWUSR); + +#define RG_I2C_GPIO_DEVICE_VERBOSE(fmt, args...) do { \ + if (g_rg_i2c_gpio_device_debug) { \ + printk(KERN_INFO "[RG_I2C_GPIO_DEVICE][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RG_I2C_GPIO_DEVICE_ERROR(fmt, args...) do { \ + if (g_rg_i2c_gpio_device_error) { \ + printk(KERN_ERR "[RG_I2C_GPIO_DEVICE][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +/****************** i2c adapter with gpio ***********************/ +static struct i2c_gpio_platform_data i2c_pdata = { + .udelay = 2, + .scl_is_output_only = 0, + .sda_is_open_drain = 0, + .scl_is_open_drain = 0, +}; + +static void i2c_gpio_release(struct device *dev) +{ + return; +} + +static struct platform_device rg_i2c_gpio_device = { + .name = "i2c-gpio", + .id = -1, + .num_resources = 0, + .resource = NULL, + .dev = { + .platform_data = &i2c_pdata, + .release = i2c_gpio_release, + }, +}; + +/* + * i2c + */ +static struct gpiod_lookup_table rg_i2c_gpio_table = { + .dev_id = "i2c-gpio", + .table = { + GPIO_LOOKUP_IDX("rg_gpio_d1500", 17, NULL, 0, + GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN), + GPIO_LOOKUP_IDX("rg_gpio_d1500", 1, NULL, 1, + GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN), + }, +}; + +static int __init rg_i2c_gpio_device_init(void) +{ + int err; + + RG_I2C_GPIO_DEVICE_VERBOSE("rg_i2c_gpio_device_init enter!\n"); + rg_i2c_gpio_table.table[0].chip_hwnum = gpio_sda; + rg_i2c_gpio_table.table[1].chip_hwnum = gpio_scl; + i2c_pdata.udelay = gpio_udelay; + gpiod_add_lookup_table(&rg_i2c_gpio_table); + + err = platform_device_register(&rg_i2c_gpio_device); + if (err < 0) { + printk(KERN_ERR "register i2c gpio device fail(%d). \n", err); + gpiod_remove_lookup_table(&rg_i2c_gpio_table); + return -1; + } + return 0; +} + +static void __exit rg_i2c_gpio_device_exit(void) +{ + RG_I2C_GPIO_DEVICE_VERBOSE("rg_i2c_gpio_device_exit enter!\n"); + platform_device_unregister(&rg_i2c_gpio_device); + gpiod_remove_lookup_table(&rg_i2c_gpio_table); +} + +module_init(rg_i2c_gpio_device_init); +module_exit(rg_i2c_gpio_device_exit); +MODULE_DESCRIPTION("I2C GPIO Devices"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd@ruijie.com.cn"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_ina3221.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_ina3221.c new file mode 100644 index 000000000000..36c8a1b26a2e --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_ina3221.c @@ -0,0 +1,445 @@ +/* + * INA3221 Triple Current/Voltage Monitor + * + * Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/ + * Andrew F. Davis + * + * 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. + */ + +#include +#include +#include +#include +#include +#include + +#define INA3221_DRIVER_NAME "rg_ina3221" + +#define INA3221_CONFIG 0x00 +#define INA3221_SHUNT1 0x01 +#define INA3221_BUS1 0x02 +#define INA3221_SHUNT2 0x03 +#define INA3221_BUS2 0x04 +#define INA3221_SHUNT3 0x05 +#define INA3221_BUS3 0x06 +#define INA3221_CRIT1 0x07 +#define INA3221_WARN1 0x08 +#define INA3221_CRIT2 0x09 +#define INA3221_WARN2 0x0a +#define INA3221_CRIT3 0x0b +#define INA3221_WARN3 0x0c +#define INA3221_MASK_ENABLE 0x0f + +#define INA3221_CONFIG_MODE_SHUNT BIT(1) +#define INA3221_CONFIG_MODE_BUS BIT(2) +#define INA3221_CONFIG_MODE_CONTINUOUS BIT(3) + +#define INA3221_RSHUNT_DEFAULT 10000 + +enum ina3221_fields { + /* Configuration */ + F_RST, + + /* Alert Flags */ + F_WF3, F_WF2, F_WF1, + F_CF3, F_CF2, F_CF1, + + /* sentinel */ + F_MAX_FIELDS +}; + +static const struct reg_field ina3221_reg_fields[] = { + [F_RST] = REG_FIELD(INA3221_CONFIG, 15, 15), + + [F_WF3] = REG_FIELD(INA3221_MASK_ENABLE, 3, 3), + [F_WF2] = REG_FIELD(INA3221_MASK_ENABLE, 4, 4), + [F_WF1] = REG_FIELD(INA3221_MASK_ENABLE, 5, 5), + [F_CF3] = REG_FIELD(INA3221_MASK_ENABLE, 7, 7), + [F_CF2] = REG_FIELD(INA3221_MASK_ENABLE, 8, 8), + [F_CF1] = REG_FIELD(INA3221_MASK_ENABLE, 9, 9), +}; + +enum ina3221_channels { + INA3221_CHANNEL1, + INA3221_CHANNEL2, + INA3221_CHANNEL3, + INA3221_NUM_CHANNELS +}; + +static const unsigned int register_channel[] = { + [INA3221_SHUNT1] = INA3221_CHANNEL1, + [INA3221_SHUNT2] = INA3221_CHANNEL2, + [INA3221_SHUNT3] = INA3221_CHANNEL3, + [INA3221_CRIT1] = INA3221_CHANNEL1, + [INA3221_CRIT2] = INA3221_CHANNEL2, + [INA3221_CRIT3] = INA3221_CHANNEL3, + [INA3221_WARN1] = INA3221_CHANNEL1, + [INA3221_WARN2] = INA3221_CHANNEL2, + [INA3221_WARN3] = INA3221_CHANNEL3, +}; + +/** + * struct ina3221_data - device specific information + * @regmap: Register map of the device + * @fields: Register fields of the device + * @shunt_resistors: Array of resistor values per channel + */ +struct ina3221_data { + struct regmap *regmap; + struct regmap_field *fields[F_MAX_FIELDS]; + int shunt_resistors[INA3221_NUM_CHANNELS]; +}; + +static int ina3221_read_value(struct ina3221_data *ina, unsigned int reg, + int *val) +{ + unsigned int regval; + int ret; + + ret = regmap_read(ina->regmap, reg, ®val); + if (ret) + return ret; + + *val = sign_extend32(regval >> 3, 12); + + return 0; +} + +static ssize_t ina3221_show_bus_voltage(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct sensor_device_attribute *sd_attr = to_sensor_dev_attr(attr); + struct ina3221_data *ina = dev_get_drvdata(dev); + unsigned int reg = sd_attr->index; + int val, voltage_mv, ret; + + ret = ina3221_read_value(ina, reg, &val); + if (ret) + return ret; + + voltage_mv = val * 8; + + return snprintf(buf, PAGE_SIZE, "%d\n", voltage_mv); +} + +static ssize_t ina3221_show_shunt_voltage(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct sensor_device_attribute *sd_attr = to_sensor_dev_attr(attr); + struct ina3221_data *ina = dev_get_drvdata(dev); + unsigned int reg = sd_attr->index; + int val, voltage_uv, ret; + + ret = ina3221_read_value(ina, reg, &val); + if (ret) + return ret; + voltage_uv = val * 40; + + return snprintf(buf, PAGE_SIZE, "%d\n", voltage_uv); +} + +static ssize_t ina3221_show_current(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct sensor_device_attribute *sd_attr = to_sensor_dev_attr(attr); + struct ina3221_data *ina = dev_get_drvdata(dev); + unsigned int reg = sd_attr->index; + unsigned int channel = register_channel[reg]; + int resistance_uo = ina->shunt_resistors[channel]; + int val, current_ma, voltage_nv, ret; + + ret = ina3221_read_value(ina, reg, &val); + if (ret) + return ret; + voltage_nv = val * 40000; + + current_ma = DIV_ROUND_CLOSEST(voltage_nv, resistance_uo); + + return snprintf(buf, PAGE_SIZE, "%d\n", current_ma); +} + +static ssize_t ina3221_set_current(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct sensor_device_attribute *sd_attr = to_sensor_dev_attr(attr); + struct ina3221_data *ina = dev_get_drvdata(dev); + unsigned int reg = sd_attr->index; + unsigned int channel = register_channel[reg]; + int resistance_uo = ina->shunt_resistors[channel]; + int val, current_ma, voltage_uv, ret; + + ret = kstrtoint(buf, 0, ¤t_ma); + if (ret) + return ret; + + /* clamp current */ + current_ma = clamp_val(current_ma, + INT_MIN / resistance_uo, + INT_MAX / resistance_uo); + + voltage_uv = DIV_ROUND_CLOSEST(current_ma * resistance_uo, 1000); + + /* clamp voltage */ + voltage_uv = clamp_val(voltage_uv, -163800, 163800); + + /* 1 / 40uV(scale) << 3(register shift) = 5 */ + val = DIV_ROUND_CLOSEST(voltage_uv, 5) & 0xfff8; + + ret = regmap_write(ina->regmap, reg, val); + if (ret) + return ret; + + return count; +} + +static ssize_t ina3221_show_shunt(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct sensor_device_attribute *sd_attr = to_sensor_dev_attr(attr); + struct ina3221_data *ina = dev_get_drvdata(dev); + unsigned int channel = sd_attr->index; + unsigned int resistance_uo; + + resistance_uo = ina->shunt_resistors[channel]; + + return snprintf(buf, PAGE_SIZE, "%d\n", resistance_uo); +} + +static ssize_t ina3221_set_shunt(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct sensor_device_attribute *sd_attr = to_sensor_dev_attr(attr); + struct ina3221_data *ina = dev_get_drvdata(dev); + unsigned int channel = sd_attr->index; + int val; + int ret; + + ret = kstrtoint(buf, 0, &val); + if (ret) + return ret; + + val = clamp_val(val, 1, INT_MAX); + + ina->shunt_resistors[channel] = val; + + return count; +} + +static ssize_t ina3221_show_alert(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct sensor_device_attribute *sd_attr = to_sensor_dev_attr(attr); + struct ina3221_data *ina = dev_get_drvdata(dev); + unsigned int field = sd_attr->index; + unsigned int regval; + int ret; + + ret = regmap_field_read(ina->fields[field], ®val); + if (ret) + return ret; + + return snprintf(buf, PAGE_SIZE, "%d\n", regval); +} + +/* bus voltage */ +static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, + ina3221_show_bus_voltage, NULL, INA3221_BUS1); +static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, + ina3221_show_bus_voltage, NULL, INA3221_BUS2); +static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, + ina3221_show_bus_voltage, NULL, INA3221_BUS3); + +/* calculated current */ +static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, + ina3221_show_current, NULL, INA3221_SHUNT1); +static SENSOR_DEVICE_ATTR(curr2_input, S_IRUGO, + ina3221_show_current, NULL, INA3221_SHUNT2); +static SENSOR_DEVICE_ATTR(curr3_input, S_IRUGO, + ina3221_show_current, NULL, INA3221_SHUNT3); + +/* shunt resistance */ +static SENSOR_DEVICE_ATTR(shunt1_resistor, S_IRUGO | S_IWUSR, + ina3221_show_shunt, ina3221_set_shunt, INA3221_CHANNEL1); +static SENSOR_DEVICE_ATTR(shunt2_resistor, S_IRUGO | S_IWUSR, + ina3221_show_shunt, ina3221_set_shunt, INA3221_CHANNEL2); +static SENSOR_DEVICE_ATTR(shunt3_resistor, S_IRUGO | S_IWUSR, + ina3221_show_shunt, ina3221_set_shunt, INA3221_CHANNEL3); + +/* critical current */ +static SENSOR_DEVICE_ATTR(curr1_crit, S_IRUGO | S_IWUSR, + ina3221_show_current, ina3221_set_current, INA3221_CRIT1); +static SENSOR_DEVICE_ATTR(curr2_crit, S_IRUGO | S_IWUSR, + ina3221_show_current, ina3221_set_current, INA3221_CRIT2); +static SENSOR_DEVICE_ATTR(curr3_crit, S_IRUGO | S_IWUSR, + ina3221_show_current, ina3221_set_current, INA3221_CRIT3); + +/* critical current alert */ +static SENSOR_DEVICE_ATTR(curr1_crit_alarm, S_IRUGO, + ina3221_show_alert, NULL, F_CF1); +static SENSOR_DEVICE_ATTR(curr2_crit_alarm, S_IRUGO, + ina3221_show_alert, NULL, F_CF2); +static SENSOR_DEVICE_ATTR(curr3_crit_alarm, S_IRUGO, + ina3221_show_alert, NULL, F_CF3); + +/* warning current */ +static SENSOR_DEVICE_ATTR(curr1_max, S_IRUGO | S_IWUSR, + ina3221_show_current, ina3221_set_current, INA3221_WARN1); +static SENSOR_DEVICE_ATTR(curr2_max, S_IRUGO | S_IWUSR, + ina3221_show_current, ina3221_set_current, INA3221_WARN2); +static SENSOR_DEVICE_ATTR(curr3_max, S_IRUGO | S_IWUSR, + ina3221_show_current, ina3221_set_current, INA3221_WARN3); + +/* warning current alert */ +static SENSOR_DEVICE_ATTR(curr1_max_alarm, S_IRUGO, + ina3221_show_alert, NULL, F_WF1); +static SENSOR_DEVICE_ATTR(curr2_max_alarm, S_IRUGO, + ina3221_show_alert, NULL, F_WF2); +static SENSOR_DEVICE_ATTR(curr3_max_alarm, S_IRUGO, + ina3221_show_alert, NULL, F_WF3); + +/* shunt voltage */ +static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, + ina3221_show_shunt_voltage, NULL, INA3221_SHUNT1); +static SENSOR_DEVICE_ATTR(in5_input, S_IRUGO, + ina3221_show_shunt_voltage, NULL, INA3221_SHUNT2); +static SENSOR_DEVICE_ATTR(in6_input, S_IRUGO, + ina3221_show_shunt_voltage, NULL, INA3221_SHUNT3); + +static struct attribute *ina3221_attrs[] = { + /* channel 1 */ + &sensor_dev_attr_in1_input.dev_attr.attr, + &sensor_dev_attr_curr1_input.dev_attr.attr, + &sensor_dev_attr_shunt1_resistor.dev_attr.attr, + &sensor_dev_attr_curr1_crit.dev_attr.attr, + &sensor_dev_attr_curr1_crit_alarm.dev_attr.attr, + &sensor_dev_attr_curr1_max.dev_attr.attr, + &sensor_dev_attr_curr1_max_alarm.dev_attr.attr, + &sensor_dev_attr_in4_input.dev_attr.attr, + + /* channel 2 */ + &sensor_dev_attr_in2_input.dev_attr.attr, + &sensor_dev_attr_curr2_input.dev_attr.attr, + &sensor_dev_attr_shunt2_resistor.dev_attr.attr, + &sensor_dev_attr_curr2_crit.dev_attr.attr, + &sensor_dev_attr_curr2_crit_alarm.dev_attr.attr, + &sensor_dev_attr_curr2_max.dev_attr.attr, + &sensor_dev_attr_curr2_max_alarm.dev_attr.attr, + &sensor_dev_attr_in5_input.dev_attr.attr, + + /* channel 3 */ + &sensor_dev_attr_in3_input.dev_attr.attr, + &sensor_dev_attr_curr3_input.dev_attr.attr, + &sensor_dev_attr_shunt3_resistor.dev_attr.attr, + &sensor_dev_attr_curr3_crit.dev_attr.attr, + &sensor_dev_attr_curr3_crit_alarm.dev_attr.attr, + &sensor_dev_attr_curr3_max.dev_attr.attr, + &sensor_dev_attr_curr3_max_alarm.dev_attr.attr, + &sensor_dev_attr_in6_input.dev_attr.attr, + + NULL, +}; +ATTRIBUTE_GROUPS(ina3221); + +static const struct regmap_range ina3221_yes_ranges[] = { + regmap_reg_range(INA3221_SHUNT1, INA3221_BUS3), + regmap_reg_range(INA3221_MASK_ENABLE, INA3221_MASK_ENABLE), +}; + +static const struct regmap_access_table ina3221_volatile_table = { + .yes_ranges = ina3221_yes_ranges, + .n_yes_ranges = ARRAY_SIZE(ina3221_yes_ranges), +}; + +static const struct regmap_config ina3221_regmap_config = { + .reg_bits = 8, + .val_bits = 16, + + .cache_type = REGCACHE_RBTREE, + .volatile_table = &ina3221_volatile_table, +}; + +static int ina3221_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct device *dev = &client->dev; + struct ina3221_data *ina; + struct device *hwmon_dev; + int i, ret; + + ina = devm_kzalloc(dev, sizeof(*ina), GFP_KERNEL); + if (!ina) + return -ENOMEM; + + ina->regmap = devm_regmap_init_i2c(client, &ina3221_regmap_config); + if (IS_ERR(ina->regmap)) { + dev_err(dev, "Unable to allocate register map\n"); + return PTR_ERR(ina->regmap); + } + + for (i = 0; i < F_MAX_FIELDS; i++) { + ina->fields[i] = devm_regmap_field_alloc(dev, + ina->regmap, + ina3221_reg_fields[i]); + if (IS_ERR(ina->fields[i])) { + dev_err(dev, "Unable to allocate regmap fields\n"); + return PTR_ERR(ina->fields[i]); + } + } + + for (i = 0; i < INA3221_NUM_CHANNELS; i++) + ina->shunt_resistors[i] = INA3221_RSHUNT_DEFAULT; + + ret = regmap_field_write(ina->fields[F_RST], true); + if (ret) { + dev_err(dev, "Unable to reset device\n"); + return ret; + } + + hwmon_dev = devm_hwmon_device_register_with_groups(dev, + client->name, + ina, ina3221_groups); + if (IS_ERR(hwmon_dev)) { + dev_err(dev, "Unable to register hwmon device\n"); + return PTR_ERR(hwmon_dev); + } + + return 0; +} + +static const struct of_device_id ina3221_of_match_table[] = { + { .compatible = "ruijie,rg_ina3221", }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, ina3221_of_match_table); + +static const struct i2c_device_id ina3221_ids[] = { + { "rg_ina3221", 0 }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(i2c, ina3221_ids); + +static struct i2c_driver ina3221_i2c_driver = { + .probe = ina3221_probe, + .driver = { + .name = INA3221_DRIVER_NAME, + .of_match_table = ina3221_of_match_table, + }, + .id_table = ina3221_ids, +}; +module_i2c_driver(ina3221_i2c_driver); + +MODULE_AUTHOR("Andrew F. Davis "); +MODULE_DESCRIPTION("Texas Instruments INA3221 HWMon Driver"); +MODULE_LICENSE("GPL v2"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_io_dev.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_io_dev.c new file mode 100644 index 000000000000..5fa050a7dc7a --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_io_dev.c @@ -0,0 +1,574 @@ +/* + * Copyright(C) 2022 Ruijie Network. All rights reserved. + * + * rg_io_dev.c + * ko to read/write ioports through /dev/XXX device + * Original Author: sonic_rd@ruijie.com.cn 2022-09-09 + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "rg_io_dev.h" + +#define PROXY_NAME "rg-io-dev" +#define MAX_IO_DEV_NUM (256) +#define IO_RDWR_MAX_LEN (256) +#define MAX_NAME_SIZE (20) +#define IO_INDIRECT_ADDR_H(addr) ((addr >> 8) & 0xff) +#define IO_INDIRECT_ADDR_L(addr) ((addr) & 0xff) +#define IO_INDIRECT_OP_WRITE (0x2) +#define IO_INDIRECT_OP_READ (0X3) + +static int g_io_dev_debug = 0; +static int g_io_dev_error = 0; + +module_param(g_io_dev_debug, int, S_IRUGO | S_IWUSR); +module_param(g_io_dev_error, int, S_IRUGO | S_IWUSR); + +#define IO_DEV_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_io_dev_debug) { \ + printk(KERN_INFO "[IO_DEV][VER][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define IO_DEV_DEBUG_ERROR(fmt, args...) do { \ + if (g_io_dev_error) { \ + printk(KERN_ERR "[IO_DEV][ERR][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +typedef struct rg_io_dev_s { + const char *name; + uint32_t io_base; + uint32_t io_len; + uint32_t indirect_addr; + uint32_t wr_data; + uint32_t addr_low; + uint32_t addr_high; + uint32_t rd_data; + uint32_t opt_ctl; + spinlock_t io_dev_lock; + struct miscdevice misc; +} rg_io_dev_t; + +static rg_io_dev_t* io_dev_arry[MAX_IO_DEV_NUM]; + +static int io_dev_open(struct inode *inode, struct file *file) +{ + unsigned int minor = iminor(inode); + rg_io_dev_t *rg_io_dev; + + if (minor >= MAX_IO_DEV_NUM) { + IO_DEV_DEBUG_ERROR("minor out of range, minor = %d.\n", minor); + return -ENODEV; + } + + rg_io_dev = io_dev_arry[minor]; + if (rg_io_dev == NULL) { + IO_DEV_DEBUG_ERROR("rg_io_dev is NULL, open failed, minor = %d\n", minor); + return -ENODEV; + } + + file->private_data = rg_io_dev; + return 0; +} + +static int io_dev_release(struct inode *inode, struct file *file) +{ + file->private_data = NULL; + return 0; +} + +uint8_t io_indirect_addressing_read(rg_io_dev_t *rg_io_dev, uint32_t address) +{ + uint8_t addr_l, addr_h, value; + unsigned long flags; + + addr_h = IO_INDIRECT_ADDR_H(address); + addr_l = IO_INDIRECT_ADDR_L(address); + IO_DEV_DEBUG_VERBOSE("read one count, addr = 0x%x\n", address); + + spin_lock_irqsave(&rg_io_dev->io_dev_lock, flags); + + outb(addr_l, rg_io_dev->io_base + rg_io_dev->addr_low); + + outb(addr_h, rg_io_dev->io_base + rg_io_dev->addr_high); + + outb(IO_INDIRECT_OP_READ, rg_io_dev->io_base + rg_io_dev->opt_ctl); + + value = inb(rg_io_dev->io_base + rg_io_dev->rd_data); + + spin_unlock_irqrestore(&rg_io_dev->io_dev_lock, flags); + + return value; +} + +static int io_dev_read_tmp(rg_io_dev_t *rg_io_dev, uint32_t offset, uint8_t *buf, size_t count) +{ + int i; + + if (offset > rg_io_dev->io_len) { + IO_DEV_DEBUG_VERBOSE("offset:0x%x, io len:0x%x, EOF.\n", offset, rg_io_dev->io_len); + return 0; + } + + if (count > rg_io_dev->io_len - offset) { + IO_DEV_DEBUG_VERBOSE("read count out of range. input len:%lu, read len:%u.\n", + count, rg_io_dev->io_len - offset); + count = rg_io_dev->io_len - offset; + } + if (rg_io_dev->indirect_addr) { + for (i = 0; i < count; i++) { + buf[i] = io_indirect_addressing_read(rg_io_dev, offset + i); + } + } else { + for (i = 0; i < count; i++) { + buf[i] = inb(rg_io_dev->io_base + offset + i); + } + } + + return count; +} + +static ssize_t io_dev_read(struct file *file, char __user *buf, size_t count, loff_t *offset) +{ + rg_io_dev_t *rg_io_dev; + int ret, read_len; + u8 buf_tmp[IO_RDWR_MAX_LEN]; + + rg_io_dev = file->private_data; + if (rg_io_dev == NULL) { + IO_DEV_DEBUG_ERROR("rg_io_dev is NULL, read failed.\n"); + return -EINVAL; + } + + if (count == 0) { + IO_DEV_DEBUG_ERROR("Invalid params, read count is 0.n"); + return -EINVAL; + } + + if (count > sizeof(buf_tmp)) { + IO_DEV_DEBUG_VERBOSE("read conut %lu exceed max %lu.\n", count, sizeof(buf_tmp)); + count = sizeof(buf_tmp); + } + + memset(buf_tmp, 0, sizeof(buf_tmp)); + read_len = io_dev_read_tmp(rg_io_dev, *offset, buf_tmp, count); + if (read_len < 0) { + IO_DEV_DEBUG_ERROR("io_dev_read_tmp failed, ret:%d.\n", read_len); + return read_len; + } + + if (access_ok(buf, read_len)) { + IO_DEV_DEBUG_VERBOSE("user space read, buf: %p, offset: %lld, read conut %lu.\n", + buf, *offset, count); + if (copy_to_user(buf, buf_tmp, read_len)) { + IO_DEV_DEBUG_ERROR("copy_to_user failed.\n"); + return -EFAULT; + } + } else { + IO_DEV_DEBUG_VERBOSE("kernel space read, buf: %p, offset: %lld, read conut %lu.\n", + buf, *offset, count); + memcpy(buf, buf_tmp, read_len); + } + *offset += read_len; + ret = read_len; + return ret; +} + +static ssize_t io_dev_read_iter(struct kiocb *iocb, struct iov_iter *to) +{ + int ret; + + IO_DEV_DEBUG_VERBOSE("io_dev_read_iter, file: %p, count: %lu, offset: %lld\n", + iocb->ki_filp, to->count, iocb->ki_pos); + ret = io_dev_read(iocb->ki_filp, to->kvec->iov_base, to->count, &iocb->ki_pos); + return ret; +} + +void io_indirect_addressing_write(rg_io_dev_t *rg_io_dev, uint32_t address, uint8_t reg_val) +{ + uint8_t addr_l, addr_h; + unsigned long flags; + + addr_h = IO_INDIRECT_ADDR_H(address); + addr_l = IO_INDIRECT_ADDR_L(address); + IO_DEV_DEBUG_VERBOSE("write one count, addr = 0x%x\n", address); + + spin_lock_irqsave(&rg_io_dev->io_dev_lock, flags); + + outb(reg_val, rg_io_dev->io_base + rg_io_dev->wr_data); + + outb(addr_l, rg_io_dev->io_base + rg_io_dev->addr_low); + + outb(addr_h, rg_io_dev->io_base + rg_io_dev->addr_high); + + outb(IO_INDIRECT_OP_WRITE, rg_io_dev->io_base + rg_io_dev->opt_ctl); + + spin_unlock_irqrestore(&rg_io_dev->io_dev_lock, flags); + + return; +} + +static int io_dev_write_tmp(rg_io_dev_t *rg_io_dev, uint32_t offset, uint8_t *buf, size_t count) +{ + int i; + + if (offset > rg_io_dev->io_len) { + IO_DEV_DEBUG_VERBOSE("offset:0x%x, io len:0x%x, EOF.\n", offset, rg_io_dev->io_len); + return 0; + } + + if (count > rg_io_dev->io_len - offset) { + IO_DEV_DEBUG_VERBOSE("write count out of range. input len:%lu, write len:%u.\n", + count, rg_io_dev->io_len - offset); + count = rg_io_dev->io_len - offset; + } + if (rg_io_dev->indirect_addr) { + for (i = 0; i < count; i++) { + io_indirect_addressing_write(rg_io_dev, offset + i, buf[i]); + } + } else { + for (i = 0; i < count; i++) { + outb(buf[i], rg_io_dev->io_base + offset + i); + } + } + + return count; +} + +static ssize_t io_dev_write(struct file *file, const char __user *buf, size_t count, loff_t *offset) +{ + rg_io_dev_t *rg_io_dev; + int write_len; + u8 buf_tmp[IO_RDWR_MAX_LEN]; + + rg_io_dev = file->private_data; + if (rg_io_dev == NULL) { + IO_DEV_DEBUG_ERROR("rg_io_dev is NULL, write failed.\n"); + return -EINVAL; + } + + if (count == 0) { + IO_DEV_DEBUG_ERROR("Invalid params, write count is 0.\n"); + return -EINVAL; + } + + if (count > sizeof(buf_tmp)) { + IO_DEV_DEBUG_VERBOSE("write conut %lu exceed max %lu.\n", count, sizeof(buf_tmp)); + count = sizeof(buf_tmp); + } + + memset(buf_tmp, 0, sizeof(buf_tmp)); + if (access_ok(buf, count)) { + IO_DEV_DEBUG_VERBOSE("user space write, buf: %p, offset: %lld, write conut %lu.\n", + buf, *offset, count); + if (copy_from_user(buf_tmp, buf, count)) { + IO_DEV_DEBUG_ERROR("copy_from_user failed.\n"); + return -EFAULT; + } + } else { + IO_DEV_DEBUG_VERBOSE("kernel space write, buf: %p, offset: %lld, write conut %lu.\n", + buf, *offset, count); + memcpy(buf_tmp, buf, count); + } + + write_len = io_dev_write_tmp(rg_io_dev, *offset, buf_tmp, count); + if (write_len < 0) { + IO_DEV_DEBUG_ERROR("io_dev_write_tmp failed, ret:%d.\n", write_len); + return write_len; + } + + *offset += write_len; + return write_len; +} + +static ssize_t io_dev_write_iter(struct kiocb *iocb, struct iov_iter *from) +{ + int ret; + + IO_DEV_DEBUG_VERBOSE("io_dev_write_iter, file: %p, count: %lu, offset: %lld\n", + iocb->ki_filp, from->count, iocb->ki_pos); + ret = io_dev_write(iocb->ki_filp, from->kvec->iov_base, from->count, &iocb->ki_pos); + return ret; +} + +static loff_t io_dev_llseek(struct file *file, loff_t offset, int origin) +{ + loff_t ret = 0; + rg_io_dev_t *rg_io_dev; + + rg_io_dev = file->private_data; + if (rg_io_dev == NULL) { + IO_DEV_DEBUG_ERROR("rg_io_dev is NULL, llseek failed.\n"); + return -EINVAL; + } + + switch (origin) { + case SEEK_SET: + if (offset < 0) { + IO_DEV_DEBUG_ERROR("SEEK_SET, offset:%lld, invalid.\n", offset); + ret = -EINVAL; + break; + } + if (offset > rg_io_dev->io_len) { + IO_DEV_DEBUG_ERROR("SEEK_SET out of range, offset:%lld, io_len:0x%x.\n", + offset, rg_io_dev->io_len); + ret = - EINVAL; + break; + } + file->f_pos = offset; + ret = file->f_pos; + break; + case SEEK_CUR: + if (((file->f_pos + offset) > rg_io_dev->io_len) || ((file->f_pos + offset) < 0)) { + IO_DEV_DEBUG_ERROR("SEEK_CUR out of range, f_ops:%lld, offset:%lld, io_len:0x%x.\n", + file->f_pos, offset, rg_io_dev->io_len); + ret = - EINVAL; + break; + } + file->f_pos += offset; + ret = file->f_pos; + break; + default: + IO_DEV_DEBUG_ERROR("unsupport llseek type:%d.\n", origin); + ret = -EINVAL; + break; + } + return ret; +} + +static long io_dev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +{ + return 0; +} + +static const struct file_operations io_dev_fops = { + .owner = THIS_MODULE, + .llseek = io_dev_llseek, + .read_iter = io_dev_read_iter, + .write_iter = io_dev_write_iter, + .unlocked_ioctl = io_dev_ioctl, + .open = io_dev_open, + .release = io_dev_release, +}; + +static rg_io_dev_t *dev_match(const char *path) +{ + rg_io_dev_t *rg_io_dev; + char dev_name[MAX_NAME_SIZE]; + int i; + + for (i = 0; i < MAX_IO_DEV_NUM; i++) { + if (io_dev_arry[i] == NULL) { + continue; + } + rg_io_dev = io_dev_arry[i]; + snprintf(dev_name, MAX_NAME_SIZE,"/dev/%s", rg_io_dev->name); + if (!strcmp(path, dev_name)) { + IO_DEV_DEBUG_VERBOSE("get dev_name = %s, minor = %d\n", dev_name, i); + return rg_io_dev; + } + } + + return NULL; +} + +int io_device_func_read(const char *path, uint32_t offset, uint8_t *buf, size_t count) +{ + rg_io_dev_t *rg_io_dev; + int read_len; + + if (path == NULL) { + IO_DEV_DEBUG_ERROR("path NULL"); + return -EINVAL; + } + + if (buf == NULL) { + IO_DEV_DEBUG_ERROR("buf NULL"); + return -EINVAL; + } + + rg_io_dev = dev_match(path); + if (rg_io_dev == NULL) { + IO_DEV_DEBUG_ERROR("io_dev match failed. dev path = %s", path); + return -EINVAL; + } + + read_len = io_dev_read_tmp(rg_io_dev, offset, buf, count); + if (read_len < 0) { + IO_DEV_DEBUG_ERROR("io_dev_read_tmp failed, ret:%d.\n", read_len); + } + return read_len; +} +EXPORT_SYMBOL(io_device_func_read); + +int io_device_func_write(const char *path, uint32_t offset, uint8_t *buf, size_t count) +{ + rg_io_dev_t *rg_io_dev; + int write_len; + + if (path == NULL) { + IO_DEV_DEBUG_ERROR("path NULL"); + return -EINVAL; + } + + if (buf == NULL) { + IO_DEV_DEBUG_ERROR("buf NULL"); + return -EINVAL; + } + + rg_io_dev = dev_match(path); + if (rg_io_dev == NULL) { + IO_DEV_DEBUG_ERROR("i2c_dev match failed. dev path = %s", path); + return -EINVAL; + } + + write_len = io_dev_write_tmp(rg_io_dev, offset, buf, count); + if (write_len < 0) { + IO_DEV_DEBUG_ERROR("io_dev_write_tmp failed, ret:%d.\n", write_len); + } + return write_len; +} +EXPORT_SYMBOL(io_device_func_write); + +static int io_dev_probe(struct platform_device *pdev) +{ + int ret; + rg_io_dev_t *rg_io_dev; + struct miscdevice *misc; + io_dev_device_t *io_dev_device; + + rg_io_dev = devm_kzalloc(&pdev->dev, sizeof(rg_io_dev_t), GFP_KERNEL); + if (!rg_io_dev) { + dev_err(&pdev->dev, "devm_kzalloc failed.\n"); + ret = -ENOMEM; + return ret; + } + spin_lock_init(&rg_io_dev->io_dev_lock); + + if (pdev->dev.of_node) { + ret = 0; + ret += of_property_read_string(pdev->dev.of_node, "io_dev_name", &rg_io_dev->name); + ret += of_property_read_u32(pdev->dev.of_node, "io_base", &rg_io_dev->io_base); + ret += of_property_read_u32(pdev->dev.of_node, "io_len", &rg_io_dev->io_len); + if (of_property_read_bool(pdev->dev.of_node, "indirect_addr")) { + + rg_io_dev->indirect_addr = 1; + ret += of_property_read_u32(pdev->dev.of_node, "wr_data", &rg_io_dev->wr_data); + ret += of_property_read_u32(pdev->dev.of_node, "addr_low", &rg_io_dev->addr_low); + ret += of_property_read_u32(pdev->dev.of_node, "addr_high", &rg_io_dev->addr_high); + ret += of_property_read_u32(pdev->dev.of_node, "rd_data", &rg_io_dev->rd_data); + ret += of_property_read_u32(pdev->dev.of_node, "opt_ctl", &rg_io_dev->opt_ctl); + } else { + + rg_io_dev->indirect_addr = 0; + } + if (ret != 0) { + dev_err(&pdev->dev, "Failed to get dts config, ret:%d.\n", ret); + return -ENXIO; + } + } else { + if (pdev->dev.platform_data == NULL) { + dev_err(&pdev->dev, "Failed to get platform data config.\n"); + return -ENXIO; + } + io_dev_device = pdev->dev.platform_data; + rg_io_dev->name = io_dev_device->io_dev_name; + rg_io_dev->io_base = io_dev_device->io_base; + rg_io_dev->io_len = io_dev_device->io_len; + rg_io_dev->indirect_addr = io_dev_device->indirect_addr; + if (rg_io_dev->indirect_addr == 1) { + rg_io_dev->wr_data = io_dev_device->wr_data; + rg_io_dev->addr_low = io_dev_device->addr_low; + rg_io_dev->addr_high = io_dev_device->addr_high; + rg_io_dev->rd_data = io_dev_device->rd_data; + rg_io_dev->opt_ctl = io_dev_device->opt_ctl; + } + } + + IO_DEV_DEBUG_VERBOSE("name:%s, io base:0x%x, io len:0x%x, addressing type:%s.\n", + rg_io_dev->name, rg_io_dev->io_base, rg_io_dev->io_len, + rg_io_dev->indirect_addr ? "indirect" : "direct"); + + misc = &rg_io_dev->misc; + misc->minor = MISC_DYNAMIC_MINOR; + misc->name = rg_io_dev->name; + misc->fops = &io_dev_fops; + misc->mode = 0666; + if (misc_register(misc) != 0) { + dev_err(&pdev->dev, "Failed to register %s device.\n", misc->name); + return -ENXIO; + } + if (misc->minor >= MAX_IO_DEV_NUM) { + dev_err(&pdev->dev, "Error: device minor[%d] more than max io device num[%d].\n", + misc->minor, MAX_IO_DEV_NUM); + misc_deregister(misc); + return -EINVAL; + } + io_dev_arry[misc->minor] = rg_io_dev; + dev_info(&pdev->dev, "register %s device [0x%x][0x%x] with minor %d using %s addressing success.\n", + misc->name, rg_io_dev->io_base, rg_io_dev->io_len, misc->minor, + rg_io_dev->indirect_addr ? "indirect" : "direct"); + + return 0; +} + +static int io_dev_remove(struct platform_device *pdev) +{ + int i; + + for (i = 0; i < MAX_IO_DEV_NUM ; i++) { + if (io_dev_arry[i] != NULL) { + misc_deregister(&io_dev_arry[i]->misc); + io_dev_arry[i] = NULL; + } + } + + return 0; +} + +static struct of_device_id io_dev_match[] = { + { + .compatible = "ruijie,rg-io-dev", + }, + {}, +}; +MODULE_DEVICE_TABLE(of, io_dev_match); + +static struct platform_driver rg_io_dev_driver = { + .probe = io_dev_probe, + .remove = io_dev_remove, + .driver = { + .owner = THIS_MODULE, + .name = PROXY_NAME, + .of_match_table = io_dev_match, + }, +}; + +static int __init rg_io_dev_init(void) +{ + return platform_driver_register(&rg_io_dev_driver); +} + +static void __exit rg_io_dev_exit(void) +{ + platform_driver_unregister(&rg_io_dev_driver); +} + +module_init(rg_io_dev_init); +module_exit(rg_io_dev_exit); +MODULE_DESCRIPTION("IO device driver"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd "); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_io_dev.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_io_dev.h new file mode 100644 index 000000000000..6414fd112a30 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_io_dev.h @@ -0,0 +1,19 @@ +#ifndef __RG_IO_DEV_H__ +#define __RG_IO_DEV_H__ + +#define IO_DEV_NAME_MAX_LEN (64) + +typedef struct io_dev_device_s { + char io_dev_name[IO_DEV_NAME_MAX_LEN]; + uint32_t io_base; + uint32_t io_len; + uint32_t indirect_addr; + uint32_t wr_data; + uint32_t addr_low; + uint32_t addr_high; + uint32_t rd_data; + uint32_t opt_ctl; + int device_flag; +} io_dev_device_t; + +#endif diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_lpc_drv.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_lpc_drv.c new file mode 100644 index 000000000000..40841ccae8fc --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_lpc_drv.c @@ -0,0 +1,169 @@ +/* + * Copyright(C) 2016 Ruijie Network. All rights reserved. + * + * rg_lpc_drv.c + * ko to set lpc pcie config io addr and enable lpc + * Original Author: sonic_rd@ruijie.com.cn 2020-08-14 + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "rg_lpc_drv.h" + +#define LPC_DRIVER_NAME "rg-lpc" +#define LPC_MAKE_PCI_IO_RANGE(__base) ((0xfc0001) | ((__base) & (0xFFFC))) + +int g_lpc_dev_debug = 0; +int g_lpc_dev_error = 0; + +module_param(g_lpc_dev_debug, int, S_IRUGO | S_IWUSR); +module_param(g_lpc_dev_error, int, S_IRUGO | S_IWUSR); + +#define LPC_DEV_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_lpc_dev_debug) { \ + printk(KERN_INFO "[LPC_DEV][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define LPC_DEV_DEBUG_ERROR(fmt, args...) do { \ + if (g_lpc_dev_error) { \ + printk(KERN_ERR "[LPC_DEV][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +typedef struct rg_lpc_dev_s { + const char *lpc_io_name; + uint32_t domain; + uint32_t bus; + uint32_t slot; + uint32_t fn; + uint32_t lpc_io_base; + uint32_t lpc_io_size; + uint32_t lpc_gen_dec; +} rg_lpc_dev_t; + +static int rg_lpc_probe(struct platform_device *pdev) +{ + int ret, devfn; + rg_lpc_dev_t *rg_lpc_dev; + struct pci_dev *pci_dev; + lpc_drv_device_t *lpc_drv_device; + + rg_lpc_dev = devm_kzalloc(&pdev->dev, sizeof(rg_lpc_dev_t), GFP_KERNEL); + if (!rg_lpc_dev) { + dev_err(&pdev->dev, "devm_kzalloc failed.\n"); + ret = -ENOMEM; + return ret; + } + + if (pdev->dev.of_node) { + ret = 0; + ret += of_property_read_string(pdev->dev.of_node, "lpc_io_name", &rg_lpc_dev->lpc_io_name); + ret += of_property_read_u32(pdev->dev.of_node, "pci_domain", &rg_lpc_dev->domain); + ret += of_property_read_u32(pdev->dev.of_node, "pci_bus", &rg_lpc_dev->bus); + ret += of_property_read_u32(pdev->dev.of_node, "pci_slot", &rg_lpc_dev->slot); + ret += of_property_read_u32(pdev->dev.of_node, "pci_fn", &rg_lpc_dev->fn); + ret += of_property_read_u32(pdev->dev.of_node, "lpc_io_base", &rg_lpc_dev->lpc_io_base); + ret += of_property_read_u32(pdev->dev.of_node, "lpc_io_size", &rg_lpc_dev->lpc_io_size); + ret += of_property_read_u32(pdev->dev.of_node, "lpc_gen_dec", &rg_lpc_dev->lpc_gen_dec); + if (ret != 0) { + dev_err(&pdev->dev, "Failed to get dts config, ret:%d.\n", ret); + return -ENXIO; + } + } else { + if (pdev->dev.platform_data == NULL) { + dev_err(&pdev->dev, "Failed to get platform data config.\n"); + return -ENXIO; + } + lpc_drv_device = pdev->dev.platform_data; + rg_lpc_dev->lpc_io_name = lpc_drv_device->lpc_io_name; + rg_lpc_dev->domain = lpc_drv_device->pci_domain; + rg_lpc_dev->bus = lpc_drv_device->pci_bus; + rg_lpc_dev->slot = lpc_drv_device->pci_slot; + rg_lpc_dev->fn = lpc_drv_device->pci_fn; + rg_lpc_dev->lpc_io_base = lpc_drv_device->lpc_io_base; + rg_lpc_dev->lpc_io_size = lpc_drv_device->lpc_io_size; + rg_lpc_dev->lpc_gen_dec = lpc_drv_device->lpc_gen_dec; + } + + LPC_DEV_DEBUG_VERBOSE("domain:0x%04x, bus:0x%02x, slot:0x%02x, fn:%u\n", + rg_lpc_dev->domain,rg_lpc_dev->bus, rg_lpc_dev->slot, rg_lpc_dev->fn); + LPC_DEV_DEBUG_VERBOSE("lpc_io_name:%s, lpc_io_base:0x%x, lpc_io_size:%u, lpc_gen_dec:0x%x.\n", + rg_lpc_dev->lpc_io_name, rg_lpc_dev->lpc_io_base, rg_lpc_dev->lpc_io_size, rg_lpc_dev->lpc_gen_dec); + + devfn = PCI_DEVFN(rg_lpc_dev->slot, rg_lpc_dev->fn); + pci_dev = pci_get_domain_bus_and_slot(rg_lpc_dev->domain, rg_lpc_dev->bus, devfn); + if (pci_dev == NULL) { + dev_err(&pdev->dev, "Failed to find pci_dev, domain:0x%04x, bus:0x%02x, devfn:0x%x\n", + rg_lpc_dev->domain, rg_lpc_dev->bus, devfn); + return -ENXIO; + } + + pci_write_config_dword(pci_dev, rg_lpc_dev->lpc_gen_dec, LPC_MAKE_PCI_IO_RANGE(rg_lpc_dev->lpc_io_base)); + if (!request_region(rg_lpc_dev->lpc_io_base, rg_lpc_dev->lpc_io_size, rg_lpc_dev->lpc_io_name)) { + dev_err(&pdev->dev, "Failed to request_region [0x%x][0x%x].\n", rg_lpc_dev->lpc_io_base, rg_lpc_dev->lpc_io_size); + return -EBUSY; + } + + platform_set_drvdata(pdev, rg_lpc_dev); + + dev_info(&pdev->dev, "lpc request_region [0x%x][0x%x] success.\n", rg_lpc_dev->lpc_io_base, rg_lpc_dev->lpc_io_size); + + return 0; +} + +static int rg_lpc_remove(struct platform_device *pdev) +{ + rg_lpc_dev_t *rg_lpc_dev; + + rg_lpc_dev = platform_get_drvdata(pdev); + if (rg_lpc_dev) { + release_region(rg_lpc_dev->lpc_io_base , rg_lpc_dev->lpc_io_size); + LPC_DEV_DEBUG_VERBOSE("lpc base:0x%x, len:0x%x.\n", rg_lpc_dev->lpc_io_base, rg_lpc_dev->lpc_io_size); + } + LPC_DEV_DEBUG_VERBOSE("lpc remove.\n"); + + return 0; +} + +static struct of_device_id lpc_dev_match[] = { + { + .compatible = "ruijie,rg-lpc", + }, + {}, +}; +MODULE_DEVICE_TABLE(of, lpc_dev_match); + +static struct platform_driver rg_lpc_driver = { + .probe = rg_lpc_probe, + .remove = rg_lpc_remove, + .driver = { + .owner = THIS_MODULE, + .name = LPC_DRIVER_NAME, + .of_match_table = lpc_dev_match, + }, +}; + +static int __init rg_lpc_init(void) +{ + return platform_driver_register(&rg_lpc_driver); +} + +static void __exit rg_lpc_exit(void) +{ + platform_driver_unregister(&rg_lpc_driver); +} + +module_init(rg_lpc_init); +module_exit(rg_lpc_exit); +MODULE_DESCRIPTION("lpc driver"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd "); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_lpc_drv.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_lpc_drv.h new file mode 100644 index 000000000000..ed978c728296 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_lpc_drv.h @@ -0,0 +1,18 @@ +#ifndef __RG_LPC_DRV_H__ +#define __RG_LPC_DRV_H__ + +#define LPC_IO_NAME_MAX_LEN (64) + +typedef struct lpc_drv_device_s { + char lpc_io_name[LPC_IO_NAME_MAX_LEN]; + int pci_domain; + int pci_bus; + int pci_slot; + int pci_fn; + int lpc_io_base; + int lpc_io_size; + int lpc_gen_dec; + int device_flag; +} lpc_drv_device_t; + +#endif diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_mac_bsc.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_mac_bsc.c new file mode 100644 index 000000000000..e148a709d699 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_mac_bsc.c @@ -0,0 +1,658 @@ +/* + * rg_mac_th3.c - A driver for control rg_mac_th3 base on rg_mac.c + * + * Copyright (c) 1998, 1999 Frodo Looijaard + * Copyright (c) 2018 ruijie + * + * 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 + +#define MAC_TEMP_INVALID (99999999) + +#define MAC_SIZE (256) +#define MAC_TEMP_NUM (16) + +#define MAC_ID_REG (0x02000000) + +typedef enum { + DBG_START, + DBG_VERBOSE, + DBG_KEY, + DBG_WARN, + DBG_ERROR, + DBG_END, +} dbg_level_t; + +typedef enum{ + MAC_TYPE_START, + TD4_X9 = 0xb780, + TD4_X9_8 = 0xb788, + TH3 = 0xb980, + TD3 = 0xb870, + TD4 = 0xb880, + TH4 = 0xb990, + MAC_TYPE_END, +} mac_type; + +typedef struct sensor_regs_s { + int id; + u32 reg; +} sensor_reg_t; + +typedef struct mac_temp_regs_s { + int mac_type; + sensor_reg_t sensor_reg[MAC_TEMP_NUM]; +} mac_temp_reg_t; + +typedef enum { + MAC_TEMP_START, + MAC_TEMP_INDEX1, + MAC_TEMP_INDEX2, + MAC_TEMP_INDEX3, + MAC_TEMP_INDEX4, + MAC_TEMP_INDEX5, + MAC_TEMP_INDEX6, + MAC_TEMP_INDEX7, + MAC_TEMP_INDEX8, + MAC_TEMP_INDEX9, + MAC_TEMP_INDEX10, + MAC_TEMP_INDEX11, + MAC_TEMP_INDEX12, + MAC_TEMP_INDEX13, + MAC_TEMP_INDEX14, + MAC_TEMP_INDEX15, + MAC_TEMP_END, +} mac_hwmon_index; + +static mac_temp_reg_t mac_temp_reg[] = { + { + /* TD3 */ + .mac_type = TD3, + .sensor_reg = { + {.id = MAC_TEMP_INDEX1, .reg = 0x02004700}, + {.id = MAC_TEMP_INDEX2, .reg = 0x02004800}, + {.id = MAC_TEMP_INDEX3, .reg = 0x02004900}, + {.id = MAC_TEMP_INDEX4, .reg = 0x02004a00}, + {.id = MAC_TEMP_INDEX5, .reg = 0x02004b00}, + {.id = MAC_TEMP_INDEX6, .reg = 0x02004c00}, + {.id = MAC_TEMP_INDEX7, .reg = 0x02004d00}, + {.id = MAC_TEMP_INDEX8, .reg = 0x02004e00}, + {.id = MAC_TEMP_INDEX9, .reg = 0x02005200}, + {.id = MAC_TEMP_INDEX10, .reg = 0x02005100}, + {.id = MAC_TEMP_INDEX11, .reg = 0x02005000}, + {.id = MAC_TEMP_INDEX12, .reg = 0x02004f00}, + }, + }, + { + /* TD4 */ + .mac_type = TD4, + .sensor_reg = { + {.id = MAC_TEMP_INDEX1, .reg = 0x02004900}, + {.id = MAC_TEMP_INDEX2, .reg = 0x02004b00}, + {.id = MAC_TEMP_INDEX3, .reg = 0x02004d00}, + {.id = MAC_TEMP_INDEX4, .reg = 0x02004f00}, + {.id = MAC_TEMP_INDEX5, .reg = 0x02005100}, + {.id = MAC_TEMP_INDEX6, .reg = 0x02005300}, + {.id = MAC_TEMP_INDEX7, .reg = 0x02005500}, + {.id = MAC_TEMP_INDEX8, .reg = 0x02005700}, + {.id = MAC_TEMP_INDEX9, .reg = 0x02005900}, + {.id = MAC_TEMP_INDEX10, .reg = 0x02005b00}, + {.id = MAC_TEMP_INDEX11, .reg = 0x02005d00}, + {.id = MAC_TEMP_INDEX12, .reg = 0x02005f00}, + {.id = MAC_TEMP_INDEX13, .reg = 0x02006100}, + {.id = MAC_TEMP_INDEX14, .reg = 0x02006300}, + {.id = MAC_TEMP_INDEX15, .reg = 0x02006500}, + }, + }, + { + /* TD4_X9 */ + .mac_type = TD4_X9, + .sensor_reg = { + {.id = MAC_TEMP_INDEX1, .reg = 0x02005a00}, + {.id = MAC_TEMP_INDEX2, .reg = 0x02005c00}, + {.id = MAC_TEMP_INDEX3, .reg = 0x02005e00}, + {.id = MAC_TEMP_INDEX4, .reg = 0x02006000}, + {.id = MAC_TEMP_INDEX5, .reg = 0x02006200}, + {.id = MAC_TEMP_INDEX6, .reg = 0x02006400}, + {.id = MAC_TEMP_INDEX7, .reg = 0x02006600}, + {.id = MAC_TEMP_INDEX8, .reg = 0x02006800}, + {.id = MAC_TEMP_INDEX9, .reg = 0x02006a00}, + }, + }, + { + /* TD4_X9_8 */ + .mac_type = TD4_X9_8, + .sensor_reg = { + {.id = MAC_TEMP_INDEX1, .reg = 0x02005a00}, + {.id = MAC_TEMP_INDEX2, .reg = 0x02005c00}, + {.id = MAC_TEMP_INDEX3, .reg = 0x02005e00}, + {.id = MAC_TEMP_INDEX4, .reg = 0x02006000}, + {.id = MAC_TEMP_INDEX5, .reg = 0x02006200}, + {.id = MAC_TEMP_INDEX6, .reg = 0x02006400}, + {.id = MAC_TEMP_INDEX7, .reg = 0x02006600}, + {.id = MAC_TEMP_INDEX8, .reg = 0x02006800}, + {.id = MAC_TEMP_INDEX9, .reg = 0x02006a00}, + }, + }, + { + /* TH3 */ + .mac_type = TH3, + .sensor_reg = { + {.id = MAC_TEMP_INDEX1, .reg = 0x02004a00}, + {.id = MAC_TEMP_INDEX2, .reg = 0x02004b00}, + {.id = MAC_TEMP_INDEX3, .reg = 0x02004c00}, + {.id = MAC_TEMP_INDEX4, .reg = 0x02004d00}, + {.id = MAC_TEMP_INDEX5, .reg = 0x02004e00}, + {.id = MAC_TEMP_INDEX6, .reg = 0x02004f00}, + {.id = MAC_TEMP_INDEX7, .reg = 0x02005000}, + {.id = MAC_TEMP_INDEX8, .reg = 0x02005100}, + {.id = MAC_TEMP_INDEX9, .reg = 0x02005200}, + {.id = MAC_TEMP_INDEX10, .reg = 0x02005300}, + {.id = MAC_TEMP_INDEX11, .reg = 0x02005400}, + {.id = MAC_TEMP_INDEX12, .reg = 0x02005500}, + {.id = MAC_TEMP_INDEX13, .reg = 0x02005600}, + {.id = MAC_TEMP_INDEX14, .reg = 0x02005700}, + {.id = MAC_TEMP_INDEX15, .reg = 0x02005800}, + }, + }, + { + /* TH4 */ + .mac_type = TH4, + .sensor_reg = { + {.id = MAC_TEMP_INDEX1, .reg = 0x0201d800}, + {.id = MAC_TEMP_INDEX2, .reg = 0x0201e000}, + {.id = MAC_TEMP_INDEX3, .reg = 0x0201e800}, + {.id = MAC_TEMP_INDEX4, .reg = 0x0201f000}, + {.id = MAC_TEMP_INDEX5, .reg = 0x0201f800}, + {.id = MAC_TEMP_INDEX6, .reg = 0x02020000}, + {.id = MAC_TEMP_INDEX7, .reg = 0x02020800}, + {.id = MAC_TEMP_INDEX8, .reg = 0x02021000}, + {.id = MAC_TEMP_INDEX9, .reg = 0x02021800}, + {.id = MAC_TEMP_INDEX10, .reg = 0x02022000}, + {.id = MAC_TEMP_INDEX11, .reg = 0x02022800}, + {.id = MAC_TEMP_INDEX12, .reg = 0x02023000}, + {.id = MAC_TEMP_INDEX13, .reg = 0x02023800}, + {.id = MAC_TEMP_INDEX14, .reg = 0x02024000}, + {.id = MAC_TEMP_INDEX15, .reg = 0x02024800}, + }, + }, +}; + +static int debuglevel = 0; +module_param(debuglevel, int, S_IRUGO | S_IWUSR); + +static int mac_pcie_id = MAC_TYPE_START; +module_param(mac_pcie_id, int, S_IRUGO | S_IWUSR); + +#define DBG_DEBUG(fmt, arg...) do { \ + if ( debuglevel > DBG_START && debuglevel < DBG_ERROR) { \ + printk(KERN_INFO "[DEBUG]:<%s, %d>:"fmt, __FUNCTION__, __LINE__, ##arg); \ + } else if ( debuglevel >= DBG_ERROR ) { \ + printk(KERN_ERR "[DEBUG]:<%s, %d>:"fmt, __FUNCTION__, __LINE__, ##arg); \ + } else { } \ +} while (0) + +#define DBG_ERROR(fmt, arg...) do { \ + if ( debuglevel > DBG_START) { \ + printk(KERN_ERR "[ERROR]:<%s, %d>:"fmt, __FUNCTION__, __LINE__, ##arg); \ + } \ + } while (0) + +struct mac_data { + struct i2c_client *client; + struct device *hwmon_dev; + struct mutex update_lock; + u8 data[MAC_SIZE]; /* Register value */ +}; + +static int rg_i2c_read_one_time(struct i2c_client *client, u8 *recv_buf, int size) +{ + struct i2c_msg msgs[2]; + int ret = 0; + + if ((client == NULL) || (recv_buf == NULL)) { + DBG_DEBUG("i2c_client || recv_buf = NULL\r\n"); + return -1; + } + + memset(msgs, 0, sizeof(msgs)); + + msgs[0].buf = recv_buf; + msgs[0].len = size; + msgs[0].addr = client->addr; + msgs[0].flags |= I2C_M_RD; + + ret = i2c_transfer(client->adapter, msgs, 1); + if (ret < 0) { + return ret; + } + DBG_DEBUG("i2c_transfer, dev_addr 0x%x, size %d.\n", client->addr, size); + + return 0; +} + +static int rg_i2c_write_one_time(struct i2c_client *client, u8 *write_buf, int size) +{ + struct i2c_msg msgs[2]; + int ret = 0; + + if ((client == NULL) || (write_buf == NULL)) { + DBG_DEBUG("i2c_client || write_buf = NULL\r\n"); + return -1; + } + + if ((size <= 0)) { + DBG_DEBUG("size invalid, size %d\n", size); + return -1; + } + + memset(msgs, 0, sizeof(msgs)); + + msgs[0].len = size; + msgs[0].buf = write_buf; + msgs[0].addr = client->addr; + + ret = i2c_transfer(client->adapter, msgs, 1); + if (ret < 0) { + return ret; + } + DBG_DEBUG("i2c_transfer, dev_addr 0x%x, size %d\n", client->addr, size); + + return 0; +} + +static u8 step2_buf1[8] = {0x03, 0x21, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00}; +static u8 step2_buf2[8] = {0x03, 0x21, 0x04, 0x0c, 0x2c, 0x38, 0x02, 0x00}; +static u8 step2_buf3[8] = {0x03, 0x21, 0x04, 0x10, 0x02, 0x00, 0x4a, 0x00}; +static u8 step2_buf4[8] = {0x03, 0x21, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01}; +static u8 step2_buf5[4] = {0x03, 0x21, 0x04, 0x08}; +static u8 step2_buf6[4] = {0x03, 0x21, 0x04, 0x10}; + +static int getmac_register(struct i2c_client *client, u32 index, int *reg_value) +{ + int i; + int ret = 0; + int value = 0; + unsigned char read_buf[8]; + + if (index == 0) { + DBG_ERROR("invalid index\n"); + return -1; + } + + step2_buf3[7] = index & 0xff; + step2_buf3[6] = (index >> 8) & 0xff; + step2_buf3[5] = (index >> 16) & 0xff; + step2_buf3[4] = (index >> 24) & 0xff; + + ret = rg_i2c_write_one_time(client, step2_buf1, 8); + if (ret < 0) { + DBG_ERROR("write step2_buf1 failed, ret = %d\n", ret); + } + ret = rg_i2c_write_one_time(client, step2_buf2, 8); + if (ret < 0) { + DBG_ERROR("write step2_buf2 failed, ret = %d\n", ret); + } + ret = rg_i2c_write_one_time(client, step2_buf3, 8); + if (ret < 0) { + DBG_ERROR("write step2_buf3 failed, ret = %d\n", ret); + } + ret = rg_i2c_write_one_time(client, step2_buf4, 8); + if (ret < 0) { + DBG_ERROR("write step2_buf4 failed, ret = %d\n", ret); + } + + ret = rg_i2c_write_one_time(client, step2_buf5, 4); + if (ret < 0) { + DBG_ERROR("write step2_buf5 failed, ret = %d\n", ret); + } + ret = rg_i2c_read_one_time(client, read_buf, 4); + if (ret < 0) { + DBG_ERROR("read failed, ret = %d\n", ret); + } + for (i = 0; i < 4; i++) { + DBG_DEBUG("read_buf[%d] = 0x%x \n", i, read_buf[i]); + } + + ret = rg_i2c_write_one_time(client, step2_buf6, 4); + if (ret < 0) { + DBG_ERROR("write step2_buf6 failed, ret = %d\n", ret); + } + + ret = rg_i2c_read_one_time(client, read_buf, 4); + if (ret < 0) { + DBG_ERROR("read failed, ret = %d\n", ret); + return ret; + } + + value = (read_buf[0] << 24)| (read_buf[1] << 16) | (read_buf[2] << 8) | read_buf[3]; + *reg_value = value; + + return ret; +} + +static int mac_calcute(u32 reg, int *temp) +{ + int ret = 0; + u32 tmp = 0; + + switch(mac_pcie_id) { + case TD3: + case TH3: + tmp = reg & 0x3ff; + *temp = 434100 - (tmp * 535); + break; + case TD4: + case TH4: + case TD4_X9: + case TD4_X9_8: + tmp = reg & 0x7ff; + *temp = (356070 - (tmp * 237)); + break; + default: + ret = -1; + DBG_ERROR("read failed, ret = %d\n", ret); + break; + } + + if ((*temp / 1000 < -70) || (*temp / 1000 > 200)) { + ret = -1; + DBG_ERROR("mac temp invalid, temp = %d\n", *temp ); + } + + return ret; +} + +static int find_reg_type(int type, int *type_index) +{ + int i; + int size; + + size = ARRAY_SIZE(mac_temp_reg); + for (i = 0; i < size; i++) { + if (mac_temp_reg[i].mac_type == type) { + *type_index = i; + return 0; + } + } + + return -1; +} + +static sensor_reg_t * find_reg_offset(int type, int index) +{ + int i; + int type_index; + int ret; + + ret = find_reg_type(type, &type_index); + if (ret < 0) { + DBG_ERROR("find_reg_type failed, ret = %d\n", ret); + return NULL; + } + + for (i = 0; i < MAC_TEMP_NUM; i++) { + if (mac_temp_reg[type_index].sensor_reg[i].id == index) { + return &(mac_temp_reg[type_index].sensor_reg[i]); + } + } + + return NULL; +} + +static int get_mactemp(struct i2c_client *client, int index, int *temp) +{ + int ret; + int reg_value; + + if (index == 0) { + DBG_ERROR("invalid index\n"); + return -1; + } + + ret = getmac_register(client, index, ®_value); + if (ret < 0) { + DBG_ERROR("getmac_register failed, ret = %d\n", ret); + return ret; + } + DBG_DEBUG("reg_value = 0x%x \n", reg_value); + + ret = mac_calcute(reg_value, temp); + if (ret < 0) { + DBG_ERROR("mac_calcute failed, ret = %d\n", ret); + return ret; + } + + return 0; +} + +static ssize_t show_mac_temp(struct device *dev, struct device_attribute *da, char *buf) +{ + struct mac_data *data = dev_get_drvdata(dev); + struct i2c_client *client = data->client; + u32 index_value = to_sensor_dev_attr_2(da)->index; + sensor_reg_t *t; + int result = 0; + int temp = -MAC_TEMP_INVALID; + + mutex_lock(&data->update_lock); + t = find_reg_offset(mac_pcie_id, index_value); + if (t == NULL) { + temp = -MAC_TEMP_INVALID; + DBG_ERROR("find_reg_offset failed, mac_pcie_id = %d, index_value = %d\n", mac_pcie_id, index_value); + } else { + result = get_mactemp(client, t->reg, &temp); + if (result < 0) { + temp = -MAC_TEMP_INVALID; + DBG_ERROR("get_mactemp failed, ret = %d\n", result); + } + } + + mutex_unlock(&data->update_lock); + return snprintf(buf, MAC_SIZE, "%d\n", temp); +} + +static ssize_t show_mac_max_temp(struct device *dev, struct device_attribute *da, char *buf) +{ + struct mac_data *data = dev_get_drvdata(dev); + struct i2c_client *client = data->client; + int i; + int result; + int temp = -MAC_TEMP_INVALID; + int type_index; + int tmp; + + mutex_lock(&data->update_lock); + + result = find_reg_type(mac_pcie_id, &type_index); + if (result < 0) { + DBG_ERROR("find_reg_type failed, ret = %d\n", result); + goto exit; + } + + for (i = 0; i < MAC_TEMP_NUM; i++) { + result = get_mactemp(client, mac_temp_reg[type_index].sensor_reg[i].reg, &tmp); + if (result < 0) { + DBG_ERROR("get_mactemp failed, ret = %d\n", result); + tmp = -MAC_TEMP_INVALID; + } + + temp = (temp > tmp) ? temp : tmp; + } + +exit: + mutex_unlock(&data->update_lock); + return snprintf(buf, MAC_SIZE, "%d\n", temp); +} + +static int mac_bsc_init(struct i2c_client *client) +{ + int ret; + int reg_value; + int mac_id = 0; + + ret = getmac_register(client, MAC_ID_REG, ®_value); + if (ret < 0) { + DBG_ERROR("getmac_register failed, ret = %d\n", ret); + return ret; + } + + DBG_DEBUG("reg_value = 0x%x \n", reg_value); + mac_id = reg_value & 0xffff; + return mac_id; +} + +static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_mac_temp, NULL, MAC_TEMP_INDEX1); +static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_mac_temp, NULL, MAC_TEMP_INDEX2); +static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_mac_temp, NULL, MAC_TEMP_INDEX3); +static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_mac_temp, NULL, MAC_TEMP_INDEX4); +static SENSOR_DEVICE_ATTR(temp5_input, S_IRUGO, show_mac_temp, NULL, MAC_TEMP_INDEX5); +static SENSOR_DEVICE_ATTR(temp6_input, S_IRUGO, show_mac_temp, NULL, MAC_TEMP_INDEX6); +static SENSOR_DEVICE_ATTR(temp7_input, S_IRUGO, show_mac_temp, NULL, MAC_TEMP_INDEX7); +static SENSOR_DEVICE_ATTR(temp8_input, S_IRUGO, show_mac_temp, NULL, MAC_TEMP_INDEX8); +static SENSOR_DEVICE_ATTR(temp9_input, S_IRUGO, show_mac_temp, NULL, MAC_TEMP_INDEX9); +static SENSOR_DEVICE_ATTR(temp10_input, S_IRUGO, show_mac_temp, NULL, MAC_TEMP_INDEX10); +static SENSOR_DEVICE_ATTR(temp11_input, S_IRUGO, show_mac_temp, NULL, MAC_TEMP_INDEX11); +static SENSOR_DEVICE_ATTR(temp12_input, S_IRUGO, show_mac_temp, NULL, MAC_TEMP_INDEX12); +static SENSOR_DEVICE_ATTR(temp13_input, S_IRUGO, show_mac_temp, NULL, MAC_TEMP_INDEX13); +static SENSOR_DEVICE_ATTR(temp14_input, S_IRUGO, show_mac_temp, NULL, MAC_TEMP_INDEX14); +static SENSOR_DEVICE_ATTR(temp15_input, S_IRUGO, show_mac_temp, NULL, MAC_TEMP_INDEX15); +static SENSOR_DEVICE_ATTR(temp99_input, S_IRUGO, show_mac_max_temp, NULL, 0); + +static struct attribute *mac_hwmon_attrs[] = { + &sensor_dev_attr_temp1_input.dev_attr.attr, + &sensor_dev_attr_temp2_input.dev_attr.attr, + &sensor_dev_attr_temp3_input.dev_attr.attr, + &sensor_dev_attr_temp4_input.dev_attr.attr, + &sensor_dev_attr_temp5_input.dev_attr.attr, + &sensor_dev_attr_temp6_input.dev_attr.attr, + &sensor_dev_attr_temp7_input.dev_attr.attr, + &sensor_dev_attr_temp8_input.dev_attr.attr, + &sensor_dev_attr_temp9_input.dev_attr.attr, + &sensor_dev_attr_temp10_input.dev_attr.attr, + &sensor_dev_attr_temp11_input.dev_attr.attr, + &sensor_dev_attr_temp12_input.dev_attr.attr, + &sensor_dev_attr_temp13_input.dev_attr.attr, + &sensor_dev_attr_temp14_input.dev_attr.attr, + &sensor_dev_attr_temp15_input.dev_attr.attr, + &sensor_dev_attr_temp99_input.dev_attr.attr, + NULL +}; +ATTRIBUTE_GROUPS(mac_hwmon); + +static int init_bcs_command(int mac_type) { + int ret; + + ret = 0; + switch (mac_type) { + case TD3: + step2_buf2[5] = 0x38; + break; + case TH3: + case TH4: + case TD4: + case TD4_X9: + case TD4_X9_8: + step2_buf2[5] = 0x40; + break; + default: + ret = -1; + break; + } + return ret; +} + +static int mac_probe(struct i2c_client *client, const struct i2c_device_id *id) +{ + struct mac_data *data; + int mac_type; + int ret; + + mac_type = id->driver_data; + mac_pcie_id = mac_type; + if (init_bcs_command(mac_type) < 0) { + DBG_ERROR("mactype[%x] not support \n", mac_type); + return -1; + }; + + if (mac_type == TD4) { + ret = mac_bsc_init(client); + if (ret < 0) { + DBG_ERROR("mac_bsc_init failed, ret = %d\n", ret); + return -1; + } + mac_type = ret; + mac_pcie_id = mac_type; + } + + DBG_DEBUG("=========mac_probe(%x)===========\n",client->addr); + DBG_DEBUG("mac_type: %x\n", mac_type); + data = devm_kzalloc(&client->dev, sizeof(struct mac_data), GFP_KERNEL); + if (!data) { + return -ENOMEM; + } + + data->client = client; + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + + data->hwmon_dev = hwmon_device_register_with_groups(&client->dev, client->name, data, mac_hwmon_groups); + if (IS_ERR(data->hwmon_dev)) { + return PTR_ERR(data->hwmon_dev); + } + + return 0; +} + +static int mac_remove(struct i2c_client *client) +{ + struct mac_data *data = i2c_get_clientdata(client); + hwmon_device_unregister(data->hwmon_dev); + return 0; +} + +static const struct i2c_device_id mac_id[] = { + { "rg_mac_bsc_td3", TD3 }, + { "rg_mac_bsc_td4", TD4 }, + { "rg_mac_bsc_th3", TH3 }, + { "rg_mac_bsc_th4", TH4 }, + {} +}; +MODULE_DEVICE_TABLE(i2c, mac_id); + +static struct i2c_driver rg_mac_bsc_driver = { + .driver = { + .name = "rg_mac_bsc", + }, + .probe = mac_probe, + .remove = mac_remove, + .id_table = mac_id, +}; + +module_i2c_driver(rg_mac_bsc_driver); + +MODULE_AUTHOR("sonic_rd "); +MODULE_DESCRIPTION("ruijie mac bsc driver"); +MODULE_LICENSE("GPL"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_optoe.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_optoe.c new file mode 100644 index 000000000000..fb0e5cec8a27 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_optoe.c @@ -0,0 +1,1190 @@ +/* + * optoe.c - A driver to read and write the EEPROM on optical transceivers + * (SFP, QSFP and similar I2C based devices) + * + * Copyright (C) 2014 Cumulus networks Inc. + * Copyright (C) 2017 Finisar Corp. + * + * 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 Freeoftware Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +/* + * Description: + * a) Optical transceiver EEPROM read/write transactions are just like + * the at24 eeproms managed by the at24.c i2c driver + * b) The register/memory layout is up to 256 128 byte pages defined by + * a "pages valid" register and switched via a "page select" + * register as explained in below diagram. + * c) 256 bytes are mapped at a time. 'Lower page 00h' is the first 128 + * bytes of address space, and always references the same + * location, independent of the page select register. + * All mapped pages are mapped into the upper 128 bytes + * (offset 128-255) of the i2c address. + * d) Devices with one I2C address (eg QSFP) use I2C address 0x50 + * (A0h in the spec), and map all pages in the upper 128 bytes + * of that address. + * e) Devices with two I2C addresses (eg SFP) have 256 bytes of data + * at I2C address 0x50, and 256 bytes of data at I2C address + * 0x51 (A2h in the spec). Page selection and paged access + * only apply to this second I2C address (0x51). + * e) The address space is presented, by the driver, as a linear + * address space. For devices with one I2C client at address + * 0x50 (eg QSFP), offset 0-127 are in the lower + * half of address 50/A0h/client[0]. Offset 128-255 are in + * page 0, 256-383 are page 1, etc. More generally, offset + * 'n' resides in page (n/128)-1. ('page -1' is the lower + * half, offset 0-127). + * f) For devices with two I2C clients at address 0x50 and 0x51 (eg SFP), + * the address space places offset 0-127 in the lower + * half of 50/A0/client[0], offset 128-255 in the upper + * half. Offset 256-383 is in the lower half of 51/A2/client[1]. + * Offset 384-511 is in page 0, in the upper half of 51/A2/... + * Offset 512-639 is in page 1, in the upper half of 51/A2/... + * Offset 'n' is in page (n/128)-3 (for n > 383) + * + * One I2c addressed (eg QSFP) Memory Map + * + * 2-Wire Serial Address: 1010000x + * + * Lower Page 00h (128 bytes) + * ===================== + * | | + * | | + * | | + * | | + * | | + * | | + * | | + * | | + * | | + * | | + * |Page Select Byte(127)| + * ===================== + * | + * | + * | + * | + * V + * ------------------------------------------------------------ + * | | | | + * | | | | + * | | | | + * | | | | + * | | | | + * | | | | + * | | | | + * | | | | + * | | | | + * V V V V + * ------------ -------------- --------------- -------------- + * | | | | | | | | + * | Upper | | Upper | | Upper | | Upper | + * | Page 00h | | Page 01h | | Page 02h | | Page 03h | + * | | | (Optional) | | (Optional) | | (Optional | + * | | | | | | | for Cable | + * | | | | | | | Assemblies) | + * | ID | | AST | | User | | | + * | Fields | | Table | | EEPROM Data | | | + * | | | | | | | | + * | | | | | | | | + * | | | | | | | | + * ------------ -------------- --------------- -------------- + * + * The SFF 8436 (QSFP) spec only defines the 4 pages described above. + * In anticipation of future applications and devices, this driver + * supports access to the full architected range, 256 pages. + * + * The CMIS (Common Management Interface Specification) defines use of + * considerably more pages (at least to page 0xAF), which this driver + * supports. + * + * NOTE: This version of the driver ONLY SUPPORTS BANK 0 PAGES on CMIS + * devices. + * + **/ + +/* #define DEBUG 1 */ + +#undef EEPROM_CLASS +#ifdef CONFIG_EEPROM_CLASS +#define EEPROM_CLASS +#endif +#ifdef CONFIG_EEPROM_CLASS_MODULE +#define EEPROM_CLASS +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef EEPROM_CLASS +#include +#endif + +#include + +/* The maximum length of a port name */ +#define MAX_PORT_NAME_LEN 20 + +struct optoe_platform_data { + u32 byte_len; /* size (sum of all addr) */ + u16 page_size; /* for writes */ + u8 flags; + void *dummy1; /* backward compatibility */ + void *dummy2; /* backward compatibility */ + +#ifdef EEPROM_CLASS + struct eeprom_platform_data *eeprom_data; +#endif + char port_name[MAX_PORT_NAME_LEN]; +}; + +/* fundamental unit of addressing for EEPROM */ +#define OPTOE_PAGE_SIZE 128 +/* + * Single address devices (eg QSFP) have 256 pages, plus the unpaged + * low 128 bytes. If the device does not support paging, it is + * only 2 'pages' long. + */ +#define OPTOE_ARCH_PAGES 256 +#define ONE_ADDR_EEPROM_SIZE ((1 + OPTOE_ARCH_PAGES) * OPTOE_PAGE_SIZE) +#define ONE_ADDR_EEPROM_UNPAGED_SIZE (2 * OPTOE_PAGE_SIZE) +/* + * Dual address devices (eg SFP) have 256 pages, plus the unpaged + * low 128 bytes, plus 256 bytes at 0x50. If the device does not + * support paging, it is 4 'pages' long. + */ +#define TWO_ADDR_EEPROM_SIZE ((3 + OPTOE_ARCH_PAGES) * OPTOE_PAGE_SIZE) +#define TWO_ADDR_EEPROM_UNPAGED_SIZE (4 * OPTOE_PAGE_SIZE) +#define TWO_ADDR_NO_0X51_SIZE (2 * OPTOE_PAGE_SIZE) + +/* a few constants to find our way around the EEPROM */ +#define OPTOE_PAGE_SELECT_REG 0x7F +#define ONE_ADDR_PAGEABLE_REG 0x02 +#define QSFP_NOT_PAGEABLE (1<<2) +#define CMIS_NOT_PAGEABLE (1<<7) +#define TWO_ADDR_PAGEABLE_REG 0x40 +#define TWO_ADDR_PAGEABLE (1<<4) +#define TWO_ADDR_0X51_REG 92 +#define TWO_ADDR_0X51_SUPP (1<<6) +#define OPTOE_ID_REG 0 +#define OPTOE_READ_OP 0 +#define OPTOE_WRITE_OP 1 +#define OPTOE_EOF 0 /* used for access beyond end of device */ + +struct optoe_data { + struct optoe_platform_data chip; + int use_smbus; + char port_name[MAX_PORT_NAME_LEN]; + + /* + * Lock protects against activities from other Linux tasks, + * but not from changes by other I2C masters. + */ + struct mutex lock; + struct bin_attribute bin; + struct attribute_group attr_group; + + u8 *writebuf; + unsigned int write_max; + + unsigned int num_addresses; + +#ifdef EEPROM_CLASS + struct eeprom_device *eeprom_dev; +#endif + + /* dev_class: ONE_ADDR (QSFP) or TWO_ADDR (SFP) */ + int dev_class; + + struct i2c_client *client[]; +}; + +/* + * This parameter is to help this driver avoid blocking other drivers out + * of I2C for potentially troublesome amounts of time. With a 100 kHz I2C + * clock, one 256 byte read takes about 1/43 second which is excessive; + * but the 1/170 second it takes at 400 kHz may be quite reasonable; and + * at 1 MHz (Fm+) a 1/430 second delay could easily be invisible. + * + * This value is forced to be a power of two so that writes align on pages. + */ +static unsigned int io_limit = OPTOE_PAGE_SIZE; + +/* + * specs often allow 5 msec for a page write, sometimes 20 msec; + * it's important to recover from write timeouts. + */ +static unsigned int write_timeout = 50; + +/* + * flags to distinguish one-address (QSFP family) from two-address (SFP family) + * If the family is not known, figure it out when the device is accessed + */ +#define ONE_ADDR 1 +#define TWO_ADDR 2 +#define CMIS_ADDR 3 + +static const struct i2c_device_id optoe_ids[] = { + { "rg_optoe1", ONE_ADDR }, + { "rg_optoe2", TWO_ADDR }, + { "rg_optoe3", CMIS_ADDR }, + { "rg_sff8436", ONE_ADDR }, + { "rg_24c04", TWO_ADDR }, + { /* END OF LIST */ } +}; +MODULE_DEVICE_TABLE(i2c, optoe_ids); + +/*-------------------------------------------------------------------------*/ +/* + * This routine computes the addressing information to be used for + * a given r/w request. + * + * Task is to calculate the client (0 = i2c addr 50, 1 = i2c addr 51), + * the page, and the offset. + * + * Handles both single address (eg QSFP) and two address (eg SFP). + * For SFP, offset 0-255 are on client[0], >255 is on client[1] + * Offset 256-383 are on the lower half of client[1] + * Pages are accessible on the upper half of client[1]. + * Offset >383 are in 128 byte pages mapped into the upper half + * + * For QSFP, all offsets are on client[0] + * offset 0-127 are on the lower half of client[0] (no paging) + * Pages are accessible on the upper half of client[1]. + * Offset >127 are in 128 byte pages mapped into the upper half + * + * Callers must not read/write beyond the end of a client or a page + * without recomputing the client/page. Hence offset (within page) + * plus length must be less than or equal to 128. (Note that this + * routine does not have access to the length of the call, hence + * cannot do the validity check.) + * + * Offset within Lower Page 00h and Upper Page 00h are not recomputed + */ + +static uint8_t optoe_translate_offset(struct optoe_data *optoe, + loff_t *offset, struct i2c_client **client) +{ + unsigned int page = 0; + + *client = optoe->client[0]; + + /* if SFP style, offset > 255, shift to i2c addr 0x51 */ + if (optoe->dev_class == TWO_ADDR) { + if (*offset > 255) { + /* like QSFP, but shifted to client[1] */ + *client = optoe->client[1]; + *offset -= 256; + } + } + + /* + * if offset is in the range 0-128... + * page doesn't matter (using lower half), return 0. + * offset is already correct (don't add 128 to get to paged area) + */ + if (*offset < OPTOE_PAGE_SIZE) + return page; + + /* note, page will always be positive since *offset >= 128 */ + page = (*offset >> 7)-1; + /* 0x80 places the offset in the top half, offset is last 7 bits */ + *offset = OPTOE_PAGE_SIZE + (*offset & 0x7f); + + return page; /* note also returning client and offset */ +} + +static ssize_t optoe_eeprom_read(struct optoe_data *optoe, + struct i2c_client *client, + char *buf, unsigned int offset, size_t count) +{ + struct i2c_msg msg[2]; + u8 msgbuf[2]; + unsigned long timeout, read_time; + int status, i; + + memset(msg, 0, sizeof(msg)); + + switch (optoe->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + /*smaller eeproms can work given some SMBus extension calls */ + if (count > I2C_SMBUS_BLOCK_MAX) + count = I2C_SMBUS_BLOCK_MAX; + break; + case I2C_SMBUS_WORD_DATA: + /* Check for odd length transaction */ + count = (count == 1) ? 1 : 2; + break; + case I2C_SMBUS_BYTE_DATA: + count = 1; + break; + default: + /* + * When we have a better choice than SMBus calls, use a + * combined I2C message. Write address; then read up to + * io_limit data bytes. msgbuf is u8 and will cast to our + * needs. + */ + i = 0; + msgbuf[i++] = offset; + + msg[0].addr = client->addr; + msg[0].buf = msgbuf; + msg[0].len = i; + + msg[1].addr = client->addr; + msg[1].flags = I2C_M_RD; + msg[1].buf = buf; + msg[1].len = count; + } + + /* + * Reads fail if the previous write didn't complete yet. We may + * loop a few times until this one succeeds, waiting at least + * long enough for one entire page write to work. + */ + timeout = jiffies + msecs_to_jiffies(write_timeout); + do { + read_time = jiffies; + + switch (optoe->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + status = i2c_smbus_read_i2c_block_data(client, offset, + count, buf); + break; + case I2C_SMBUS_WORD_DATA: + status = i2c_smbus_read_word_data(client, offset); + if (status >= 0) { + buf[0] = status & 0xff; + if (count == 2) + buf[1] = status >> 8; + status = count; + } + break; + case I2C_SMBUS_BYTE_DATA: + status = i2c_smbus_read_byte_data(client, offset); + if (status >= 0) { + buf[0] = status; + status = count; + } + break; + default: + status = i2c_transfer(client->adapter, msg, 2); + if (status == 2) + status = count; + } + + dev_dbg(&client->dev, "eeprom read %zu@%d --> %d (%ld)\n", + count, offset, status, jiffies); + + if (status == count) /* happy path */ + return count; + + /* REVISIT: at HZ=100, this is sloooow */ + usleep_range(1000, 2000); + } while (time_before(read_time, timeout)); + + return -ETIMEDOUT; +} + +static ssize_t optoe_eeprom_write(struct optoe_data *optoe, + struct i2c_client *client, + const char *buf, + unsigned int offset, size_t count) +{ + struct i2c_msg msg; + ssize_t status; + unsigned long timeout, write_time; + unsigned int next_page_start; + int i = 0; + + /* write max is at most a page + * (In this driver, write_max is actually one byte!) + */ + if (count > optoe->write_max) + count = optoe->write_max; + + /* shorten count if necessary to avoid crossing page boundary */ + next_page_start = roundup(offset + 1, OPTOE_PAGE_SIZE); + if (offset + count > next_page_start) + count = next_page_start - offset; + + switch (optoe->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + /*smaller eeproms can work given some SMBus extension calls */ + if (count > I2C_SMBUS_BLOCK_MAX) + count = I2C_SMBUS_BLOCK_MAX; + break; + case I2C_SMBUS_WORD_DATA: + /* Check for odd length transaction */ + count = (count == 1) ? 1 : 2; + break; + case I2C_SMBUS_BYTE_DATA: + count = 1; + break; + default: + /* If we'll use I2C calls for I/O, set up the message */ + msg.addr = client->addr; + msg.flags = 0; + + /* msg.buf is u8 and casts will mask the values */ + msg.buf = optoe->writebuf; + + msg.buf[i++] = offset; + memcpy(&msg.buf[i], buf, count); + msg.len = i + count; + break; + } + + /* + * Reads fail if the previous write didn't complete yet. We may + * loop a few times until this one succeeds, waiting at least + * long enough for one entire page write to work. + */ + timeout = jiffies + msecs_to_jiffies(write_timeout); + do { + write_time = jiffies; + + switch (optoe->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + status = i2c_smbus_write_i2c_block_data(client, + offset, count, buf); + if (status == 0) + status = count; + break; + case I2C_SMBUS_WORD_DATA: + if (count == 2) { + status = i2c_smbus_write_word_data(client, + offset, (u16)((buf[0])|(buf[1] << 8))); + } else { + /* count = 1 */ + status = i2c_smbus_write_byte_data(client, + offset, buf[0]); + } + if (status == 0) + status = count; + break; + case I2C_SMBUS_BYTE_DATA: + status = i2c_smbus_write_byte_data(client, offset, + buf[0]); + if (status == 0) + status = count; + break; + default: + status = i2c_transfer(client->adapter, &msg, 1); + if (status == 1) + status = count; + break; + } + + dev_dbg(&client->dev, "eeprom write %zu@%d --> %ld (%lu)\n", + count, offset, (long int) status, jiffies); + + if (status == count) + return count; + + /* REVISIT: at HZ=100, this is sloooow */ + usleep_range(1000, 2000); + } while (time_before(write_time, timeout)); + + return -ETIMEDOUT; +} + +static ssize_t optoe_eeprom_update_client(struct optoe_data *optoe, + char *buf, loff_t off, + size_t count, int opcode) +{ + struct i2c_client *client; + ssize_t retval = 0; + uint8_t page = 0; + uint8_t loc; + loff_t phy_offset = off; + int ret = 0; + + page = optoe_translate_offset(optoe, &phy_offset, &client); + dev_dbg(&client->dev, + "%s off %lld page:%d phy_offset:%lld, count:%ld, opcode:%d\n", + __func__, off, page, phy_offset, (long int) count, opcode); + + ret = optoe_eeprom_read(optoe, client, &loc, OPTOE_PAGE_SELECT_REG, 1); + if (ret < 0) { + dev_dbg(&client->dev, "Read page register for get now location page failed. ret:%d\n", ret); + return ret; + } + + /* Only when read and now location page is inconsistent, will doing switch page */ + if (loc != page) { + ret = optoe_eeprom_write(optoe, client, &page, + OPTOE_PAGE_SELECT_REG, 1); + if (ret < 0) { + dev_dbg(&client->dev, + "Write page register for page %d failed ret:%d!\n", + page, ret); + return ret; + } + } + + while (count) { + ssize_t status; + + if (opcode == OPTOE_READ_OP) { + status = optoe_eeprom_read(optoe, client, + buf, phy_offset, count); + } else { + status = optoe_eeprom_write(optoe, client, + buf, phy_offset, count); + } + if (status <= 0) { + if (retval == 0) + retval = status; + break; + } + buf += status; + phy_offset += status; + count -= status; + retval += status; + } + + return retval; +} + +/* + * Figure out if this access is within the range of supported pages. + * Note this is called on every access because we don't know if the + * module has been replaced since the last call. + * If/when modules support more pages, this is the routine to update + * to validate and allow access to additional pages. + * + * Returns updated len for this access: + * - entire access is legal, original len is returned. + * - access begins legal but is too long, len is truncated to fit. + * - initial offset exceeds supported pages, return OPTOE_EOF (zero) + */ +static ssize_t optoe_page_legal(struct optoe_data *optoe, + loff_t off, size_t len) +{ + struct i2c_client *client = optoe->client[0]; + u8 regval; + int not_pageable; + int status; + size_t maxlen; + + if (off < 0) + return -EINVAL; + if (optoe->dev_class == TWO_ADDR) { + /* SFP case */ + /* if only using addr 0x50 (first 256 bytes) we're good */ + if ((off + len) <= TWO_ADDR_NO_0X51_SIZE) + return len; + /* if offset exceeds possible pages, we're not good */ + if (off >= TWO_ADDR_EEPROM_SIZE) + return OPTOE_EOF; + /* in between, are pages supported? */ + status = optoe_eeprom_read(optoe, client, ®val, + TWO_ADDR_PAGEABLE_REG, 1); + if (status < 0) + return status; /* error out (no module?) */ + if (regval & TWO_ADDR_PAGEABLE) { + /* Pages supported, trim len to the end of pages */ + maxlen = TWO_ADDR_EEPROM_SIZE - off; + } else { + /* pages not supported, trim len to unpaged size */ + if (off >= TWO_ADDR_EEPROM_UNPAGED_SIZE) + return OPTOE_EOF; + + /* will be accessing addr 0x51, is that supported? */ + /* byte 92, bit 6 implies DDM support, 0x51 support */ + status = optoe_eeprom_read(optoe, client, ®val, + TWO_ADDR_0X51_REG, 1); + if (status < 0) + return status; + if (regval & TWO_ADDR_0X51_SUPP) { + /* addr 0x51 is OK */ + maxlen = TWO_ADDR_EEPROM_UNPAGED_SIZE - off; + } else { + /* addr 0x51 NOT supported, trim to 256 max */ + if (off >= TWO_ADDR_NO_0X51_SIZE) + return OPTOE_EOF; + maxlen = TWO_ADDR_NO_0X51_SIZE - off; + } + } + len = (len > maxlen) ? maxlen : len; + dev_dbg(&client->dev, + "page_legal, SFP, off %lld len %ld\n", + off, (long int) len); + } else { + /* QSFP case, CMIS case */ + /* if no pages needed, we're good */ + if ((off + len) <= ONE_ADDR_EEPROM_UNPAGED_SIZE) + return len; + /* if offset exceeds possible pages, we're not good */ + if (off >= ONE_ADDR_EEPROM_SIZE) + return OPTOE_EOF; + /* in between, are pages supported? */ + status = optoe_eeprom_read(optoe, client, ®val, + ONE_ADDR_PAGEABLE_REG, 1); + if (status < 0) + return status; /* error out (no module?) */ + + if (optoe->dev_class == ONE_ADDR) { + not_pageable = QSFP_NOT_PAGEABLE; + } else { + not_pageable = CMIS_NOT_PAGEABLE; + } + dev_dbg(&client->dev, + "Paging Register: 0x%x; not_pageable mask: 0x%x\n", + regval, not_pageable); + + if (regval & not_pageable) { + /* pages not supported, trim len to unpaged size */ + if (off >= ONE_ADDR_EEPROM_UNPAGED_SIZE) + return OPTOE_EOF; + maxlen = ONE_ADDR_EEPROM_UNPAGED_SIZE - off; + } else { + /* Pages supported, trim len to the end of pages */ + maxlen = ONE_ADDR_EEPROM_SIZE - off; + } + len = (len > maxlen) ? maxlen : len; + dev_dbg(&client->dev, + "page_legal, QSFP, off %lld len %ld\n", + off, (long int) len); + } + return len; +} + +static ssize_t optoe_read_write(struct optoe_data *optoe, + char *buf, loff_t off, size_t len, int opcode) +{ + struct i2c_client *client = optoe->client[0]; + int chunk; + int status = 0; + ssize_t retval; + size_t pending_len = 0, chunk_len = 0; + loff_t chunk_offset = 0, chunk_start_offset = 0; + loff_t chunk_end_offset = 0; + + dev_dbg(&client->dev, + "%s: off %lld len:%ld, opcode:%s\n", + __func__, off, (long int) len, + (opcode == OPTOE_READ_OP) ? "r" : "w"); + if (unlikely(!len)) + return len; + + /* + * Read data from chip, protecting against concurrent updates + * from this host, but not from other I2C masters. + */ + mutex_lock(&optoe->lock); + + /* + * Confirm this access fits within the device suppored addr range + */ + status = optoe_page_legal(optoe, off, len); + if ((status == OPTOE_EOF) || (status < 0)) { + mutex_unlock(&optoe->lock); + return status; + } + len = status; + + /* + * For each (128 byte) chunk involved in this request, issue a + * separate call to sff_eeprom_update_client(), to + * ensure that each access recalculates the client/page + * and writes the page register as needed. + * Note that chunk to page mapping is confusing, is different for + * QSFP and SFP, and never needs to be done. Don't try! + */ + pending_len = len; /* amount remaining to transfer */ + retval = 0; /* amount transferred */ + for (chunk = off >> 7; chunk <= (off + len - 1) >> 7; chunk++) { + + /* + * Compute the offset and number of bytes to be read/write + * + * 1. start at an offset not equal to 0 (within the chunk) + * and read/write less than the rest of the chunk + * 2. start at an offset not equal to 0 and read/write the rest + * of the chunk + * 3. start at offset 0 (within the chunk) and read/write less + * than entire chunk + * 4. start at offset 0 (within the chunk), and read/write + * the entire chunk + */ + chunk_start_offset = chunk * OPTOE_PAGE_SIZE; + chunk_end_offset = chunk_start_offset + OPTOE_PAGE_SIZE; + + if (chunk_start_offset < off) { + chunk_offset = off; + if ((off + pending_len) < chunk_end_offset) + chunk_len = pending_len; + else + chunk_len = chunk_end_offset - off; + } else { + chunk_offset = chunk_start_offset; + if (pending_len < OPTOE_PAGE_SIZE) + chunk_len = pending_len; + else + chunk_len = OPTOE_PAGE_SIZE; + } + + dev_dbg(&client->dev, + "sff_r/w: off %lld, len %ld, chunk_start_offset %lld, chunk_offset %lld, chunk_len %ld, pending_len %ld\n", + off, (long int) len, chunk_start_offset, chunk_offset, + (long int) chunk_len, (long int) pending_len); + + /* + * note: chunk_offset is from the start of the EEPROM, + * not the start of the chunk + */ + status = optoe_eeprom_update_client(optoe, buf, + chunk_offset, chunk_len, opcode); + if (status != chunk_len) { + /* This is another 'no device present' path */ + dev_dbg(&client->dev, + "o_u_c: chunk %d c_offset %lld c_len %ld failed %d!\n", + chunk, chunk_offset, (long int) chunk_len, status); + if (status > 0) + retval += status; + if (retval == 0) + retval = status; + break; + } + buf += status; + pending_len -= status; + retval += status; + } + mutex_unlock(&optoe->lock); + + return retval; +} + +static ssize_t optoe_bin_read(struct file *filp, struct kobject *kobj, + struct bin_attribute *attr, + char *buf, loff_t off, size_t count) +{ + struct i2c_client *client = to_i2c_client(container_of(kobj, + struct device, kobj)); + struct optoe_data *optoe = i2c_get_clientdata(client); + + return optoe_read_write(optoe, buf, off, count, OPTOE_READ_OP); +} + +static ssize_t optoe_bin_write(struct file *filp, struct kobject *kobj, + struct bin_attribute *attr, + char *buf, loff_t off, size_t count) +{ + struct i2c_client *client = to_i2c_client(container_of(kobj, + struct device, kobj)); + struct optoe_data *optoe = i2c_get_clientdata(client); + + return optoe_read_write(optoe, buf, off, count, OPTOE_WRITE_OP); +} + +static int optoe_remove(struct i2c_client *client) +{ + struct optoe_data *optoe; + int i; + + optoe = i2c_get_clientdata(client); + sysfs_remove_group(&client->dev.kobj, &optoe->attr_group); + sysfs_remove_bin_file(&client->dev.kobj, &optoe->bin); + + for (i = 1; i < optoe->num_addresses; i++) + i2c_unregister_device(optoe->client[i]); + +#ifdef EEPROM_CLASS + eeprom_device_unregister(optoe->eeprom_dev); +#endif + + kfree(optoe->writebuf); + kfree(optoe); + return 0; +} + +static ssize_t show_dev_class(struct device *dev, + struct device_attribute *dattr, char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct optoe_data *optoe = i2c_get_clientdata(client); + ssize_t count; + + mutex_lock(&optoe->lock); + count = sprintf(buf, "%d\n", optoe->dev_class); + mutex_unlock(&optoe->lock); + + return count; +} + +static ssize_t set_dev_class(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct i2c_client *client = to_i2c_client(dev); + struct optoe_data *optoe = i2c_get_clientdata(client); + int dev_class; + + /* + * dev_class is actually the number of i2c addresses used, thus + * legal values are "1" (QSFP class) and "2" (SFP class) + * And... CMIS spec is 1 i2c address, but puts the pageable + * bit in a different location, so CMIS devices are "3" + */ + + if (kstrtoint(buf, 0, &dev_class) != 0 || + dev_class < 1 || dev_class > 3) + return -EINVAL; + + mutex_lock(&optoe->lock); + if (dev_class == TWO_ADDR) { + /* SFP family */ + /* if it doesn't exist, create 0x51 i2c address */ + if (!optoe->client[1]) { + optoe->client[1] = i2c_new_dummy_device(client->adapter, 0x51); + if (!optoe->client[1]) { + dev_err(&client->dev, + "address 0x51 unavailable\n"); + mutex_unlock(&optoe->lock); + return -EADDRINUSE; + } + } + optoe->bin.size = TWO_ADDR_EEPROM_SIZE; + optoe->num_addresses = 2; + } else { + /* one-address (eg QSFP) and CMIS family */ + /* if it exists, remove 0x51 i2c address */ + if (optoe->client[1]) { + i2c_unregister_device(optoe->client[1]); + optoe->client[1] = NULL; + } + optoe->bin.size = ONE_ADDR_EEPROM_SIZE; + optoe->num_addresses = 1; + } + optoe->dev_class = dev_class; + mutex_unlock(&optoe->lock); + + return count; +} + +/* + * if using the EEPROM CLASS driver, we don't report a port_name, + * the EEPROM CLASS drive handles that. Hence all this code is + * only compiled if we are NOT using the EEPROM CLASS driver. + */ +#ifndef EEPROM_CLASS + +static ssize_t show_port_name(struct device *dev, + struct device_attribute *dattr, char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct optoe_data *optoe = i2c_get_clientdata(client); + ssize_t count; + + mutex_lock(&optoe->lock); + count = sprintf(buf, "%s\n", optoe->port_name); + mutex_unlock(&optoe->lock); + + return count; +} + +static ssize_t set_port_name(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct i2c_client *client = to_i2c_client(dev); + struct optoe_data *optoe = i2c_get_clientdata(client); + char port_name[MAX_PORT_NAME_LEN]; + + /* no checking, this value is not used except by show_port_name */ + + if (sscanf(buf, "%19s", port_name) != 1) + return -EINVAL; + + mutex_lock(&optoe->lock); + strcpy(optoe->port_name, port_name); + mutex_unlock(&optoe->lock); + + return count; +} + +static DEVICE_ATTR(port_name, 0644, show_port_name, set_port_name); +#endif /* if NOT defined EEPROM_CLASS, the common case */ + +static DEVICE_ATTR(dev_class, 0644, show_dev_class, set_dev_class); + +static struct attribute *optoe_attrs[] = { +#ifndef EEPROM_CLASS + &dev_attr_port_name.attr, +#endif + &dev_attr_dev_class.attr, + NULL, +}; + +static struct attribute_group optoe_attr_group = { + .attrs = optoe_attrs, +}; + +static int optoe_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + int err; + int use_smbus = 0; + struct optoe_platform_data chip; + struct optoe_data *optoe; + int num_addresses = 0; + char port_name[MAX_PORT_NAME_LEN]; + + if (client->addr != 0x50) { + dev_dbg(&client->dev, "probe, bad i2c addr: 0x%x\n", + client->addr); + err = -EINVAL; + goto exit; + } + + if (client->dev.platform_data) { + chip = *(struct optoe_platform_data *)client->dev.platform_data; + /* take the port name from the supplied platform data */ +#ifdef EEPROM_CLASS + strncpy(port_name, chip.eeprom_data->label, MAX_PORT_NAME_LEN); +#else + memcpy(port_name, chip.port_name, MAX_PORT_NAME_LEN); +#endif + dev_dbg(&client->dev, + "probe, chip provided, flags:0x%x; name: %s\n", + chip.flags, client->name); + } else { + if (!id->driver_data) { + err = -ENODEV; + goto exit; + } + dev_dbg(&client->dev, "probe, building chip\n"); + strcpy(port_name, "unitialized"); + chip.flags = 0; +#ifdef EEPROM_CLASS + chip.eeprom_data = NULL; +#endif + } + + /* Use I2C operations unless we're stuck with SMBus extensions. */ + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { + if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { + use_smbus = I2C_SMBUS_I2C_BLOCK_DATA; + } else if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_WORD_DATA)) { + use_smbus = I2C_SMBUS_WORD_DATA; + } else if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_BYTE_DATA)) { + use_smbus = I2C_SMBUS_BYTE_DATA; + } else { + err = -EPFNOSUPPORT; + goto exit; + } + } + + /* + * Make room for two i2c clients + */ + num_addresses = 2; + + optoe = kzalloc(sizeof(struct optoe_data) + + num_addresses * sizeof(struct i2c_client *), + GFP_KERNEL); + if (!optoe) { + err = -ENOMEM; + goto exit; + } + + mutex_init(&optoe->lock); + + /* determine whether this is a one-address or two-address module */ + if ((strcmp(client->name, "rg_optoe1") == 0) || + (strcmp(client->name, "rg_sff8436") == 0)) { + /* one-address (eg QSFP) family */ + optoe->dev_class = ONE_ADDR; + chip.byte_len = ONE_ADDR_EEPROM_SIZE; + num_addresses = 1; + } else if ((strcmp(client->name, "rg_optoe2") == 0) || + (strcmp(client->name, "rg_24c04") == 0)) { + /* SFP family */ + optoe->dev_class = TWO_ADDR; + chip.byte_len = TWO_ADDR_EEPROM_SIZE; + num_addresses = 2; + } else if (strcmp(client->name, "rg_optoe3") == 0) { + /* CMIS spec */ + optoe->dev_class = CMIS_ADDR; + chip.byte_len = ONE_ADDR_EEPROM_SIZE; + num_addresses = 1; + } else { /* those were the only choices */ + err = -EINVAL; + goto exit; + } + + dev_dbg(&client->dev, "dev_class: %d\n", optoe->dev_class); + optoe->use_smbus = use_smbus; + optoe->chip = chip; + optoe->num_addresses = num_addresses; + memcpy(optoe->port_name, port_name, MAX_PORT_NAME_LEN); + + /* + * Export the EEPROM bytes through sysfs, since that's convenient. + * By default, only root should see the data (maybe passwords etc) + */ + sysfs_bin_attr_init(&optoe->bin); + optoe->bin.attr.name = "eeprom"; + optoe->bin.attr.mode = 0444; + optoe->bin.read = optoe_bin_read; + optoe->bin.size = chip.byte_len; + + if (!use_smbus || + (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) || + i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_WORD_DATA) || + i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) { + /* + * NOTE: AN-2079 + * Finisar recommends that the host implement 1 byte writes + * only since this module only supports 32 byte page boundaries. + * 2 byte writes are acceptable for PE and Vout changes per + * Application Note AN-2071. + */ + unsigned int write_max = 1; + + optoe->bin.write = optoe_bin_write; + optoe->bin.attr.mode |= 0200; + + if (write_max > io_limit) + write_max = io_limit; + if (use_smbus && write_max > I2C_SMBUS_BLOCK_MAX) + write_max = I2C_SMBUS_BLOCK_MAX; + optoe->write_max = write_max; + + /* buffer (data + address at the beginning) */ + optoe->writebuf = kmalloc(write_max + 2, GFP_KERNEL); + if (!optoe->writebuf) { + err = -ENOMEM; + goto exit_kfree; + } + } else { + dev_warn(&client->dev, + "cannot write due to controller restrictions."); + } + + optoe->client[0] = client; + + /* SFF-8472 spec requires that the second I2C address be 0x51 */ + if (num_addresses == 2) { + optoe->client[1] = i2c_new_dummy_device(client->adapter, 0x51); + if (!optoe->client[1]) { + dev_err(&client->dev, "address 0x51 unavailable\n"); + err = -EADDRINUSE; + goto err_struct; + } + } + + /* create the sysfs eeprom file */ + err = sysfs_create_bin_file(&client->dev.kobj, &optoe->bin); + if (err) + goto err_struct; + + optoe->attr_group = optoe_attr_group; + + err = sysfs_create_group(&client->dev.kobj, &optoe->attr_group); + if (err) { + dev_err(&client->dev, "failed to create sysfs attribute group.\n"); + goto err_struct; + } + +#ifdef EEPROM_CLASS + optoe->eeprom_dev = eeprom_device_register(&client->dev, + chip.eeprom_data); + if (IS_ERR(optoe->eeprom_dev)) { + dev_err(&client->dev, "error registering eeprom device.\n"); + err = PTR_ERR(optoe->eeprom_dev); + goto err_sysfs_cleanup; + } +#endif + + i2c_set_clientdata(client, optoe); + + dev_info(&client->dev, "%zu byte %s EEPROM, %s\n", + optoe->bin.size, client->name, + optoe->bin.write ? "read/write" : "read-only"); + + if (use_smbus == I2C_SMBUS_WORD_DATA || + use_smbus == I2C_SMBUS_BYTE_DATA) { + dev_notice(&client->dev, + "Falling back to %s reads, performance will suffer\n", + use_smbus == I2C_SMBUS_WORD_DATA ? "word" : "byte"); + } + + return 0; + +#ifdef EEPROM_CLASS +err_sysfs_cleanup: + sysfs_remove_group(&client->dev.kobj, &optoe->attr_group); + sysfs_remove_bin_file(&client->dev.kobj, &optoe->bin); +#endif + +err_struct: + if (num_addresses == 2) { + if (optoe->client[1]) { + i2c_unregister_device(optoe->client[1]); + optoe->client[1] = NULL; + } + } + + kfree(optoe->writebuf); +exit_kfree: + kfree(optoe); +exit: + dev_dbg(&client->dev, "probe error %d\n", err); + + return err; +} + +/*-------------------------------------------------------------------------*/ + +static struct i2c_driver optoe_driver = { + .driver = { + .name = "rg_optoe", + .owner = THIS_MODULE, + }, + .probe = optoe_probe, + .remove = optoe_remove, + .id_table = optoe_ids, +}; + +static int __init optoe_init(void) +{ + + if (!io_limit) { + pr_err("optoe: io_limit must not be 0!\n"); + return -EINVAL; + } + + io_limit = rounddown_pow_of_two(io_limit); + return i2c_add_driver(&optoe_driver); +} +module_init(optoe_init); + +static void __exit optoe_exit(void) +{ + i2c_del_driver(&optoe_driver); +} +module_exit(optoe_exit); + +MODULE_DESCRIPTION("Driver for optical transceiver (SFP, QSFP, ...) EEPROMs"); +MODULE_AUTHOR("DON BOLLINGER "); +MODULE_LICENSE("GPL"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_pcie_dev.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_pcie_dev.c new file mode 100644 index 000000000000..006568de5160 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_pcie_dev.c @@ -0,0 +1,773 @@ +/* + * Copyright(C) 2022 Ruijie Network. All rights reserved. + * + * rg_pcie_dev.c + * ko to read/write pcie iomem and ioports through /dev/XXX device + * Original Author: sonic_rd@ruijie.com.cn 2022-09-09 + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "rg_pcie_dev.h" + +#define PROXY_NAME "rg-pci-dev" +#define MAX_NAME_SIZE (20) +#define MAX_PCIE_NUM (256) +#define PCI_RDWR_MAX_LEN (256) +#define PCIE_BUS_WIDTH_1 (1) +#define PCIE_BUS_WIDTH_2 (2) +#define PCIE_BUS_WIDTH_4 (4) + +static int g_pcie_dev_debug = 0; +static int g_pcie_dev_error = 0; + +module_param(g_pcie_dev_debug, int, S_IRUGO | S_IWUSR); +module_param(g_pcie_dev_error, int, S_IRUGO | S_IWUSR); + +#define PCIE_DEV_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_pcie_dev_debug) { \ + printk(KERN_INFO "[PCIE_DEV][VER][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define PCIE_DEV_DEBUG_ERROR(fmt, args...) do { \ + if (g_pcie_dev_error) { \ + printk(KERN_ERR "[PCIE_DEV][ERR][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +typedef struct firmware_upg_s { + int upg_ctrl_base; + int upg_flash_base; +} firmware_upg_t; + +typedef struct rg_pci_dev_s { + const char *name; + uint32_t domain; + uint32_t bus; + uint32_t slot; + uint32_t fn; + uint32_t bar; + void __iomem *pci_mem_base; + uint32_t pci_io_base; + uint32_t bar_len; + uint32_t bar_flag; + uint32_t bus_width; + struct miscdevice misc; + void (*setreg)(struct rg_pci_dev_s *rg_pci_dev, int reg, u32 value); + u32 (*getreg)(struct rg_pci_dev_s *rg_pci_dev, int reg); + firmware_upg_t firmware_upg; +} rg_pci_dev_t; + +static rg_pci_dev_t* pcie_dev_arry[MAX_PCIE_NUM]; + +static void pci_dev_setreg_8(rg_pci_dev_t *rg_pci_dev, int reg, u32 value) +{ + u8 w_value; + + w_value = (u8)(value & 0xff); + if (rg_pci_dev->bar_flag == IORESOURCE_MEM) { + writeb(w_value, rg_pci_dev->pci_mem_base + reg); + } else { + outb(w_value, rg_pci_dev->pci_io_base + reg); + } + return; +} + +static void pci_dev_setreg_16(rg_pci_dev_t *rg_pci_dev, int reg, u32 value) +{ + u16 w_value; + + w_value = (u16)(value & 0xffff); + if (rg_pci_dev->bar_flag == IORESOURCE_MEM) { + writew(w_value, rg_pci_dev->pci_mem_base + reg); + } else { + outw(w_value, rg_pci_dev->pci_io_base + reg); + } + + return; +} + +static void pci_dev_setreg_32(rg_pci_dev_t *rg_pci_dev, int reg, u32 value) +{ + + if (rg_pci_dev->bar_flag == IORESOURCE_MEM) { + writel(value, rg_pci_dev->pci_mem_base + reg); + } else { + outl(value, rg_pci_dev->pci_io_base + reg); + } + return; +} + +static inline u32 pci_dev_getreg_8(rg_pci_dev_t *rg_pci_dev, int reg) +{ + u32 value; + + if (rg_pci_dev->bar_flag == IORESOURCE_MEM) { + value = readb(rg_pci_dev->pci_mem_base + reg); + } else { + value = inb(rg_pci_dev->pci_io_base + reg); + } + + return value; +} + +static inline u32 pci_dev_getreg_16(rg_pci_dev_t *rg_pci_dev, int reg) +{ + u32 value; + + if (rg_pci_dev->bar_flag == IORESOURCE_MEM) { + value = readw(rg_pci_dev->pci_mem_base + reg); + } else { + value = inw(rg_pci_dev->pci_io_base + reg); + } + + return value; +} + +static inline u32 pci_dev_getreg_32(rg_pci_dev_t *rg_pci_dev, int reg) +{ + u32 value; + + if (rg_pci_dev->bar_flag == IORESOURCE_MEM) { + value = readl(rg_pci_dev->pci_mem_base + reg); + } else { + value = inl(rg_pci_dev->pci_io_base + reg); + } + + return value; +} + +static inline void pci_dev_setreg(rg_pci_dev_t *rg_pci_dev, int reg, u32 value) +{ + rg_pci_dev->setreg(rg_pci_dev, reg, value); +} + +static inline u32 pci_dev_getreg(rg_pci_dev_t *rg_pci_dev, int reg) +{ + return rg_pci_dev->getreg(rg_pci_dev, reg); +} + +static int pci_dev_open(struct inode *inode, struct file *file) +{ + unsigned int minor = iminor(inode); + rg_pci_dev_t *rg_pci_dev; + + PCIE_DEV_DEBUG_VERBOSE("inode: %p, file: %p, minor: %u", inode, file, minor); + + if (minor >= MAX_PCIE_NUM) { + PCIE_DEV_DEBUG_ERROR("minor out of range, minor = %d.\n", minor); + return -ENODEV; + } + + rg_pci_dev = pcie_dev_arry[minor]; + if (rg_pci_dev == NULL) { + PCIE_DEV_DEBUG_ERROR("rg_pci_dev is NULL, open failed, minor = %d\n", minor); + return -ENODEV; + } + + file->private_data = rg_pci_dev; + return 0; +} + +static int pci_dev_release(struct inode *inode, struct file *file) +{ + file->private_data = NULL; + return 0; +} + +static int pci_dev_read_tmp(rg_pci_dev_t *rg_pci_dev, uint32_t offset, uint8_t *buf, size_t count) +{ + int width, i, j; + u32 val; + + if (offset > rg_pci_dev->bar_len) { + PCIE_DEV_DEBUG_VERBOSE("offset:0x%x, bar len:0x%x, EOF.\n", offset, rg_pci_dev->bar_len); + return 0; + } + + width = rg_pci_dev->bus_width; + + if (offset % width) { + PCIE_DEV_DEBUG_ERROR("pci bus width:%d, offset:0x%x, read size %lu invalid.\n", + width, offset, count); + return -EINVAL; + } + + if (count > rg_pci_dev->bar_len - offset) { + PCIE_DEV_DEBUG_VERBOSE("read count out of range. input len:%lu, read len:%u.\n", + count, rg_pci_dev->bar_len - offset); + count = rg_pci_dev->bar_len - offset; + } + + for (i = 0; i < count; i += width) { + val = pci_dev_getreg(rg_pci_dev, offset + i); + for (j = 0; (j < width) && (i + j < count); j++) { + buf[i + j] = (val >> (8 * j)) & 0xff; + } + } + return count; +} + +static ssize_t pci_dev_read(struct file *file, char __user *buf, size_t count, loff_t *offset) +{ + rg_pci_dev_t *rg_pci_dev; + int ret, read_len; + u8 buf_tmp[PCI_RDWR_MAX_LEN]; + + rg_pci_dev = file->private_data; + if (rg_pci_dev == NULL) { + PCIE_DEV_DEBUG_ERROR("rg_pci_dev is NULL, read failed.\n"); + return -EINVAL; + } + + if (count == 0) { + PCIE_DEV_DEBUG_ERROR("Invalid params, read count is 0.n"); + return -EINVAL; + } + + if (count > sizeof(buf_tmp)) { + PCIE_DEV_DEBUG_VERBOSE("read conut %lu exceed max %lu.\n", count, sizeof(buf_tmp)); + count = sizeof(buf_tmp); + } + + memset(buf_tmp, 0, sizeof(buf_tmp)); + read_len = pci_dev_read_tmp(rg_pci_dev, *offset, buf_tmp, count); + if (read_len < 0) { + PCIE_DEV_DEBUG_ERROR("pci_dev_read_tmp failed, ret:%d.\n", read_len); + return read_len; + } + if (access_ok(buf, read_len)) { + PCIE_DEV_DEBUG_VERBOSE("user space read, buf: %p, offset: %lld, read conut %lu.\n", + buf, *offset, count); + if (copy_to_user(buf, buf_tmp, read_len)) { + PCIE_DEV_DEBUG_ERROR("copy_to_user failed.\n"); + return -EFAULT; + } + } else { + PCIE_DEV_DEBUG_VERBOSE("kernel space read, buf: %p, offset: %lld, read conut %lu.\n", + buf, *offset, count); + memcpy(buf, buf_tmp, read_len); + } + *offset += read_len; + ret = read_len; + return ret; +} + +static ssize_t pci_dev_read_iter(struct kiocb *iocb, struct iov_iter *to) +{ + int ret; + + PCIE_DEV_DEBUG_VERBOSE("pci_dev_read_iter, file: %p, count: %lu, offset: %lld\n", + iocb->ki_filp, to->count, iocb->ki_pos); + ret = pci_dev_read(iocb->ki_filp, to->kvec->iov_base, to->count, &iocb->ki_pos); + return ret; +} + +static int pci_dev_write_tmp(rg_pci_dev_t *rg_pci_dev, uint32_t offset, uint8_t *buf, size_t count) +{ + int width, i, j; + u32 val; + + if (offset > rg_pci_dev->bar_len) { + PCIE_DEV_DEBUG_VERBOSE("offset:0x%x, bar len:0x%x, EOF.\n", offset, rg_pci_dev->bar_len); + return 0; + } + + width = rg_pci_dev->bus_width; + + if (offset % width) { + PCIE_DEV_DEBUG_ERROR("pci bus width:%d, offset:0x%x, read size %lu invalid.\n", + width, offset, count); + return -EINVAL; + } + + if (count > rg_pci_dev->bar_len - offset) { + PCIE_DEV_DEBUG_VERBOSE("write count out of range. input len:%lu, write len:%u.\n", + count, rg_pci_dev->bar_len - offset); + count = rg_pci_dev->bar_len - offset; + } + + for (i = 0; i < count; i += width) { + val = 0; + for (j = 0; (j < width) && (i + j < count); j++) { + val |= buf[i + j] << (8 * j); + } + pci_dev_setreg(rg_pci_dev, i + offset, val); + } + + return count; +} + +static ssize_t pci_dev_write(struct file *file, const char __user *buf, size_t count, + loff_t *offset) +{ + rg_pci_dev_t *rg_pci_dev; + u8 buf_tmp[PCI_RDWR_MAX_LEN]; + int write_len; + + rg_pci_dev = file->private_data; + if (rg_pci_dev == NULL) { + PCIE_DEV_DEBUG_ERROR("rg_pci_dev is NULL, write failed.\n"); + return -EINVAL; + } + + if (count == 0) { + PCIE_DEV_DEBUG_ERROR("Invalid params, write count is 0.\n"); + return -EINVAL; + } + + if (count > sizeof(buf_tmp)) { + PCIE_DEV_DEBUG_VERBOSE("write conut %lu exceed max %lu.\n", count, sizeof(buf_tmp)); + count = sizeof(buf_tmp); + } + + memset(buf_tmp, 0, sizeof(buf_tmp)); + if (access_ok(buf, count)) { + PCIE_DEV_DEBUG_VERBOSE("user space write, buf: %p, offset: %lld, write conut %lu.\n", + buf, *offset, count); + if (copy_from_user(buf_tmp, buf, count)) { + PCIE_DEV_DEBUG_ERROR("copy_from_user failed.\n"); + return -EFAULT; + } + } else { + PCIE_DEV_DEBUG_VERBOSE("kernel space write, buf: %p, offset: %lld, write conut %lu.\n", + buf, *offset, count); + memcpy(buf_tmp, buf, count); + } + + write_len = pci_dev_write_tmp(rg_pci_dev, *offset, buf_tmp, count); + if (write_len < 0) { + PCIE_DEV_DEBUG_ERROR("pci_dev_write_tmp failed, ret:%d.\n", write_len); + return write_len; + } + + *offset += write_len; + return write_len; +} + +static ssize_t pci_dev_write_iter(struct kiocb *iocb, struct iov_iter *from) +{ + int ret; + + PCIE_DEV_DEBUG_VERBOSE("pci_dev_write_iter, file: %p, count: %lu, offset: %lld\n", + iocb->ki_filp, from->count, iocb->ki_pos); + ret = pci_dev_write(iocb->ki_filp, from->kvec->iov_base, from->count, &iocb->ki_pos); + return ret; +} + +static loff_t pci_dev_llseek(struct file *file, loff_t offset, int origin) +{ + loff_t ret = 0; + rg_pci_dev_t *rg_pci_dev; + + rg_pci_dev = file->private_data; + if (rg_pci_dev == NULL) { + PCIE_DEV_DEBUG_ERROR("rg_pci_dev is NULL, llseek failed.\n"); + return -EINVAL; + } + + switch (origin) { + case SEEK_SET: + if (offset < 0) { + PCIE_DEV_DEBUG_ERROR("SEEK_SET, offset:%lld, invalid.\n", offset); + ret = -EINVAL; + break; + } + if (offset > rg_pci_dev->bar_len) { + PCIE_DEV_DEBUG_ERROR("SEEK_SET out of range, offset:%lld, bar len:0x%x.\n", + offset, rg_pci_dev->bar_len); + ret = - EINVAL; + break; + } + file->f_pos = offset; + ret = file->f_pos; + break; + case SEEK_CUR: + if (((file->f_pos + offset) > rg_pci_dev->bar_len) || ((file->f_pos + offset) < 0)) { + PCIE_DEV_DEBUG_ERROR("SEEK_CUR out of range, f_ops:%lld, offset:%lld, bar len:0x%x.\n", + file->f_pos, offset, rg_pci_dev->bar_len); + ret = - EINVAL; + break; + } + file->f_pos += offset; + ret = file->f_pos; + break; + default: + PCIE_DEV_DEBUG_ERROR("unsupport llseek type:%d.\n", origin); + ret = -EINVAL; + break; + } + return ret; +} + +static long pci_dev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +{ + rg_pci_dev_t *rg_pci_dev; + void __user *argp; + firmware_upg_t *firmware_upg; + int upg_ctrl_base; + int upg_flash_base; + + PCIE_DEV_DEBUG_VERBOSE("ioctl, cmd=0x%02x, arg=0x%02lx\n",cmd, arg); + + rg_pci_dev = file->private_data; + if (rg_pci_dev == NULL) { + PCIE_DEV_DEBUG_ERROR("rg_pci_dev is NULL, ioctl failed.\n"); + return -EINVAL; + } + + firmware_upg = &rg_pci_dev->firmware_upg; + + argp = (void __user *)arg; + + switch (cmd) { + case GET_FPGA_UPG_CTL_BASE: + if (firmware_upg->upg_ctrl_base < 0) { + PCIE_DEV_DEBUG_ERROR("dts not adaptive upg_ctrl_base\n"); + return -EFAULT; + } else { + upg_ctrl_base = firmware_upg->upg_ctrl_base; + if (copy_to_user(argp, &upg_ctrl_base, sizeof(upg_ctrl_base))) { + PCIE_DEV_DEBUG_ERROR("upg_ctrl_base copy_from_user failed\n"); + return -EFAULT; + } + } + break; + case GET_FPGA_UPG_FLASH_BASE: + if (firmware_upg->upg_flash_base < 0) { + PCIE_DEV_DEBUG_ERROR("dts not adaptive upg_flash_base\n"); + return -EFAULT; + } else { + upg_flash_base = firmware_upg->upg_flash_base; + if (copy_to_user(argp, &upg_flash_base, sizeof(upg_flash_base))) { + PCIE_DEV_DEBUG_ERROR("upg_flash_base copy_from_user failed\n"); + return -EFAULT; + } + } + break; + default: + PCIE_DEV_DEBUG_ERROR("command unsupported \n"); + return -ENOTTY; + } + + return 0; +} + +static const struct file_operations pcie_dev_fops = { + .owner = THIS_MODULE, + .llseek = pci_dev_llseek, + .read_iter = pci_dev_read_iter, + .write_iter = pci_dev_write_iter, + .unlocked_ioctl = pci_dev_ioctl, + .open = pci_dev_open, + .release = pci_dev_release, +}; + +static rg_pci_dev_t *dev_match(const char *path) +{ + rg_pci_dev_t *rg_pci_dev; + char dev_name[MAX_NAME_SIZE]; + int i; + + for (i = 0; i < MAX_PCIE_NUM; i++) { + if (pcie_dev_arry[i] == NULL) { + continue; + } + rg_pci_dev = pcie_dev_arry[i]; + snprintf(dev_name, MAX_NAME_SIZE,"/dev/%s", rg_pci_dev->name); + if (!strcmp(path, dev_name)) { + PCIE_DEV_DEBUG_VERBOSE("get dev_name = %s, minor = %d\n", dev_name, i); + return rg_pci_dev; + } + } + + return NULL; +} + +int pcie_device_func_read(const char *path, uint32_t offset, uint8_t *buf, size_t count) +{ + rg_pci_dev_t *rg_pci_dev; + int read_len; + + if (path == NULL) { + PCIE_DEV_DEBUG_ERROR("path NULL"); + return -EINVAL; + } + + if (buf == NULL) { + PCIE_DEV_DEBUG_ERROR("buf NULL"); + return -EINVAL; + } + + rg_pci_dev = dev_match(path); + if (rg_pci_dev == NULL) { + PCIE_DEV_DEBUG_ERROR("i2c_dev match failed. dev path = %s", path); + return -EINVAL; + } + + read_len = pci_dev_read_tmp(rg_pci_dev, offset, buf, count); + if (read_len < 0) { + PCIE_DEV_DEBUG_ERROR("pci_dev_read_tmp failed, ret:%d.\n", read_len); + } + return read_len; +} +EXPORT_SYMBOL(pcie_device_func_read); + +int pcie_device_func_write(const char *path, uint32_t offset, uint8_t *buf, size_t count) +{ + rg_pci_dev_t *rg_pci_dev; + int write_len; + + if (path == NULL) { + PCIE_DEV_DEBUG_ERROR("path NULL"); + return -EINVAL; + } + + if (buf == NULL) { + PCIE_DEV_DEBUG_ERROR("buf NULL"); + return -EINVAL; + } + + rg_pci_dev = dev_match(path); + if (rg_pci_dev == NULL) { + PCIE_DEV_DEBUG_ERROR("i2c_dev match failed. dev path = %s", path); + return -EINVAL; + } + + write_len = pci_dev_write_tmp(rg_pci_dev, offset, buf, count); + if (write_len < 0) { + PCIE_DEV_DEBUG_ERROR("pci_dev_write_tmp failed, ret:%d.\n", write_len); + } + return write_len; +} +EXPORT_SYMBOL(pcie_device_func_write); + +static int pci_setup_bars(rg_pci_dev_t *rg_pci_dev, struct pci_dev *dev) +{ + int ret; + uint32_t addr, len, flags; + + ret = 0; + addr = pci_resource_start(dev, rg_pci_dev->bar); + len = pci_resource_len(dev, rg_pci_dev->bar); + if (addr == 0 || len == 0) { + PCIE_DEV_DEBUG_ERROR("get bar addr failed. bar:%d, addr:0x%x, len:0x%x.\n", + rg_pci_dev->bar, addr, len); + return -EFAULT; + } + rg_pci_dev->bar_len = len; + + flags = pci_resource_flags(dev, rg_pci_dev->bar); + PCIE_DEV_DEBUG_VERBOSE("bar:%d, flag:0x%08x, phys addr:0x%x, len:0x%x\n", + rg_pci_dev->bar, flags, addr, len); + if (flags & IORESOURCE_MEM) { + rg_pci_dev->bar_flag = IORESOURCE_MEM; + rg_pci_dev->pci_mem_base = ioremap(addr, len); + PCIE_DEV_DEBUG_VERBOSE("pci mem base:%p.\n", rg_pci_dev->pci_mem_base); + } else if (flags & IORESOURCE_IO) { + rg_pci_dev->bar_flag = IORESOURCE_IO; + rg_pci_dev->pci_io_base = addr; + PCIE_DEV_DEBUG_VERBOSE("pci io base:0x%x.\n", rg_pci_dev->pci_io_base); + } else { + PCIE_DEV_DEBUG_ERROR("unknow pci bar flag:0x%08x.\n", flags); + ret = -EINVAL; + } + + return ret; +} + +static int pci_dev_probe(struct platform_device *pdev) +{ + int ret, devfn; + rg_pci_dev_t *rg_pci_dev; + struct pci_dev *pci_dev; + struct miscdevice *misc; + firmware_upg_t *firmware_upg; + pci_dev_device_t *pci_dev_device; + + rg_pci_dev = devm_kzalloc(&pdev->dev, sizeof(rg_pci_dev_t), GFP_KERNEL); + if (!rg_pci_dev) { + dev_err(&pdev->dev, "devm_kzalloc failed.\n"); + ret = -ENOMEM; + return ret; + } + + firmware_upg = &rg_pci_dev->firmware_upg; + + if (pdev->dev.of_node) { + ret = 0; + ret += of_property_read_string(pdev->dev.of_node, "pci_dev_name", &rg_pci_dev->name); + ret += of_property_read_u32(pdev->dev.of_node, "pci_domain", &rg_pci_dev->domain); + ret += of_property_read_u32(pdev->dev.of_node, "pci_bus", &rg_pci_dev->bus); + ret += of_property_read_u32(pdev->dev.of_node, "pci_slot", &rg_pci_dev->slot); + ret += of_property_read_u32(pdev->dev.of_node, "pci_fn", &rg_pci_dev->fn); + ret += of_property_read_u32(pdev->dev.of_node, "pci_bar", &rg_pci_dev->bar); + ret += of_property_read_u32(pdev->dev.of_node, "bus_width", &rg_pci_dev->bus_width); + + if (ret != 0) { + dev_err(&pdev->dev, "Failed to get dts config, ret:%d.\n", ret); + return -ENXIO; + } + + ret = 0; + ret += of_property_read_u32(pdev->dev.of_node, "upg_ctrl_base", &firmware_upg->upg_ctrl_base); + ret += of_property_read_u32(pdev->dev.of_node, "upg_flash_base", &firmware_upg->upg_flash_base); + if (ret != 0) { + PCIE_DEV_DEBUG_VERBOSE("dts don't adaptive fpga upg related, ret:%d.\n", ret); + firmware_upg->upg_ctrl_base = -1; + firmware_upg->upg_flash_base = -1; + } else { + PCIE_DEV_DEBUG_VERBOSE("upg_ctrl_base:0x%04x, upg_flash_base:0x%02x.\n", + firmware_upg->upg_ctrl_base, firmware_upg->upg_flash_base); + } + } else { + if (pdev->dev.platform_data == NULL) { + dev_err(&pdev->dev, "Failed to get platform data config.\n"); + return -ENXIO; + } + pci_dev_device = pdev->dev.platform_data; + rg_pci_dev->name = pci_dev_device->pci_dev_name; + rg_pci_dev->domain = pci_dev_device->pci_domain; + rg_pci_dev->bus = pci_dev_device->pci_bus; + rg_pci_dev->slot = pci_dev_device->pci_slot; + rg_pci_dev->fn = pci_dev_device->pci_fn; + rg_pci_dev->bar = pci_dev_device->pci_bar; + rg_pci_dev->bus_width = pci_dev_device->bus_width; + firmware_upg->upg_ctrl_base = pci_dev_device->upg_ctrl_base; + firmware_upg->upg_flash_base = pci_dev_device->upg_flash_base; + PCIE_DEV_DEBUG_VERBOSE("upg_ctrl_base:0x%04x, upg_flash_base:0x%02x.\n", + firmware_upg->upg_ctrl_base, firmware_upg->upg_flash_base); + } + + PCIE_DEV_DEBUG_VERBOSE("name:%s, domain:0x%04x, bus:0x%02x, slot:0x%02x, fn:%u, bar:%u, bus_width:%d.\n", + rg_pci_dev->name, rg_pci_dev->domain, rg_pci_dev->bus, rg_pci_dev->slot, rg_pci_dev->fn, + rg_pci_dev->bar, rg_pci_dev->bus_width); + + devfn = PCI_DEVFN(rg_pci_dev->slot, rg_pci_dev->fn); + pci_dev = pci_get_domain_bus_and_slot(rg_pci_dev->domain, rg_pci_dev->bus, devfn); + if (pci_dev == NULL) { + dev_err(&pdev->dev, "Failed to find pci_dev, domain:0x%04x, bus:0x%02x, devfn:0x%x\n", + rg_pci_dev->domain, rg_pci_dev->bus, devfn); + return -ENXIO; + } + ret = pci_setup_bars(rg_pci_dev, pci_dev); + if (ret != 0) { + dev_err(&pdev->dev, "Failed to get pci bar address.\n"); + return ret; + } + + if (!rg_pci_dev->setreg || !rg_pci_dev->getreg) { + switch (rg_pci_dev->bus_width) { + case 1: + rg_pci_dev->setreg = pci_dev_setreg_8; + rg_pci_dev->getreg = pci_dev_getreg_8; + break; + + case 2: + rg_pci_dev->setreg = pci_dev_setreg_16; + rg_pci_dev->getreg = pci_dev_getreg_16; + break; + + case 4: + rg_pci_dev->setreg = pci_dev_setreg_32; + rg_pci_dev->getreg = pci_dev_getreg_32; + break; + default: + dev_err(&pdev->dev, "Error: unsupported I/O width (%d).\n", rg_pci_dev->bus_width); + ret = -EINVAL; + goto io_unmap; + } + } + + misc = &rg_pci_dev->misc; + misc->minor = MISC_DYNAMIC_MINOR; + misc->name = rg_pci_dev->name; + misc->fops = &pcie_dev_fops; + misc->mode = 0666; + if (misc_register(misc) != 0) { + dev_err(&pdev->dev, "Failed to register %s device.\n", misc->name); + ret = -ENXIO; + goto io_unmap; + } + if (misc->minor >= MAX_PCIE_NUM) { + dev_err(&pdev->dev, "Error: device minor[%d] more than max pcie num[%d].\n", + misc->minor, MAX_PCIE_NUM); + misc_deregister(misc); + ret = -EINVAL; + goto io_unmap; + } + pcie_dev_arry[misc->minor] = rg_pci_dev; + dev_info(&pdev->dev, "%04x:%02x:%02x.%d[bar%d: %s]: register %s device with minor:%d success.\n", + rg_pci_dev->domain, rg_pci_dev->bus, rg_pci_dev->slot, rg_pci_dev->fn, rg_pci_dev->bar, + rg_pci_dev->bar_flag == IORESOURCE_MEM ? "IORESOURCE_MEM" : "IORESOURCE_IO", + misc->name, misc->minor ); + return 0; + +io_unmap: + if (rg_pci_dev->pci_mem_base) { + iounmap(rg_pci_dev->pci_mem_base); + } + return ret; +} + +static int pci_dev_remove(struct platform_device *pdev) +{ + int i; + + for (i = 0; i < MAX_PCIE_NUM ; i++) { + if (pcie_dev_arry[i] != NULL) { + if (pcie_dev_arry[i]->pci_mem_base) { + iounmap(pcie_dev_arry[i]->pci_mem_base); + } + misc_deregister(&pcie_dev_arry[i]->misc); + pcie_dev_arry[i] = NULL; + } + } + + return 0; +} + +static struct of_device_id pci_dev_match[] = { + { + .compatible = "ruijie,rg-pci-dev", + }, + {}, +}; +MODULE_DEVICE_TABLE(of, pci_dev_match); + +static struct platform_driver rg_pci_dev_driver = { + .probe = pci_dev_probe, + .remove = pci_dev_remove, + .driver = { + .owner = THIS_MODULE, + .name = PROXY_NAME, + .of_match_table = pci_dev_match, + }, +}; + +static int __init rg_pci_dev_init(void) +{ + return platform_driver_register(&rg_pci_dev_driver); +} + +static void __exit rg_pci_dev_exit(void) +{ + platform_driver_unregister(&rg_pci_dev_driver); +} + +module_init(rg_pci_dev_init); +module_exit(rg_pci_dev_exit); +MODULE_DESCRIPTION("pcie device driver"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd "); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_pcie_dev.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_pcie_dev.h new file mode 100644 index 000000000000..c967e021070d --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_pcie_dev.h @@ -0,0 +1,23 @@ +#ifndef __RG_PCIE_DEV_H__ +#define __RG_PCIE_DEV_H__ + +#define UPG_TYPE 'U' +#define GET_FPGA_UPG_CTL_BASE _IOR(UPG_TYPE, 0, int) +#define GET_FPGA_UPG_FLASH_BASE _IOR(UPG_TYPE, 1, int) + +#define PCI_DEV_NAME_MAX_LEN (64) + +typedef struct pci_dev_device_s { + char pci_dev_name[PCI_DEV_NAME_MAX_LEN]; + int pci_domain; + int pci_bus; + int pci_slot; + int pci_fn; + int pci_bar; + int bus_width; + int upg_ctrl_base; + int upg_flash_base; + int device_flag; +} pci_dev_device_t; + +#endif diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/Makefile b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/Makefile new file mode 100755 index 000000000000..369b64605dd3 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/Makefile @@ -0,0 +1,20 @@ +pes_parent_dir:=$(shell pwd)/$(lastword $(MAKEFILE_LIST)) +pes_parent_dir:=$(shell dirname $(pes_parent_dir)) + +SUBDIRS=$(shell ls -l | grep ^d | awk '{if($$9 != "build") print $$9}') +INC = -I./inc + +all : CHECK $(SUBDIRS) +CHECK : + @echo $(pes_parent_dir) + +$(SUBDIRS):ECHO + #@echo $@ + make -C $@ + +ECHO: + @echo $(SUBDIRS) + +.PHONY : clean +clean : + -rm -rf $(SYSFS_OUT_PUT) diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/Makefile b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/Makefile new file mode 100755 index 000000000000..ec190b348367 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/Makefile @@ -0,0 +1,31 @@ +PWD = $(shell pwd) + +EXTRA_CFLAGS:= -I$(M)/include +EXTRA_CFLAGS+= -Wall +SUBDIR_CFG = cfg +rg_plat_dfd-objs := dfd_module.o dfd_fan_driver.o \ +dfd_syseeprom_driver.o \ +dfd_cpld_driver.o \ +dfd_led_driver.o \ +dfd_slot_driver.o \ +dfd_sensors_driver.o \ +dfd_psu_driver.o \ +dfd_sff_driver.o \ +dfd_sfpbase.o \ +$(SUBDIR_CFG)/dfd_cfg.o \ +$(SUBDIR_CFG)/dfd_cfg_adapter.o \ +$(SUBDIR_CFG)/dfd_cfg_file.o \ +$(SUBDIR_CFG)/dfd_cfg_info.o \ +$(SUBDIR_CFG)/dfd_cfg_listnode.o \ +$(SUBDIR_CFG)/dfd_frueeprom.o \ +$(SUBDIR_CFG)/dfd_tlveeprom.o \ + +obj-m := rg_plat_dfd.o +all: + $(MAKE) -C $(KERNEL_SRC)/build M=$(PWD) modules + @if [ ! -d $(module_out_put_dir) ]; then mkdir -p $(module_out_put_dir) ;fi + cp -p $(PWD)/*.ko $(module_out_put_dir) +clean: + rm -f $(PWD)/*.o $(PWD)/$(SUBDIR_CFG)/*.o $(PWD)/*.ko $(PWD)/*.mod.c $(PWD)/.*.cmd $(PWD)/$(SUBDIR_CFG)/.*.cmd $(PWD)/*.mod + rm -f $(PWD)/Module.markers $(PWD)/Module.symvers $(PWD)/modules.order + rm -rf $(PWD)/.tmp_versions diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_cfg.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_cfg.c new file mode 100644 index 000000000000..c9b3f6a0e371 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_cfg.c @@ -0,0 +1,815 @@ +/* + * Copyright(C) 2001-2015 Ruijie Network. All rights reserved. + */ + +#include +#include +#include +#include +#include +#include + +#include "../include/dfd_module.h" +#include "../include/dfd_cfg_file.h" +#include "../include/dfd_cfg_listnode.h" +#include "../include/dfd_cfg_info.h" +#include "../include/dfd_cfg_adapter.h" +#include "../include/dfd_cfg.h" + +#ifdef DFD_CFG_ITEM +#undef DFD_CFG_ITEM +#endif +#define DFD_CFG_ITEM(_id, _name, _index_min, _index_max) _name, +static char *dfd_cfg_item_name[] = { + DFD_CFG_ITEM_ALL +}; + +#ifdef DFD_CFG_ITEM +#undef DFD_CFG_ITEM +#endif +#define DFD_CFG_ITEM(_id, _name, _index_min, _index_max) {_index_min, _index_max}, +static index_range_t dfd_cfg_item_index_range[] = { + DFD_CFG_ITEM_ALL +}; + +static lnode_root_t dfd_ko_cfg_list_root; + +static void dfd_ko_cfg_del_space_lf_cr(char *str) +{ + int i, j; + int len; + + len = strlen(str); + for (i = 0; i < len; i++) { + if (str[i] == '\r' || str[i] == '\n' || str[i] == ' ') { + for (j = i; j < len - 1; j++) { + str[j] = str[j + 1]; + } + str[j] = '\0'; + len--; + i--; + } + } +} + +static int dfd_ko_cfg_get_value_from_char(char *value_str, int32_t *value, int line_num) +{ + int value_tmp = 0; + + if (strlen(value_str) == 0) { + DBG_DEBUG(DBG_WARN, "line%d: value str is empty\n", line_num); + *value = DFD_CFG_EMPTY_VALUE; + return 0; + } + + if ((strlen(value_str) > 2) && (value_str[0] == '0') + && (value_str[1] == 'x' || value_str[1] == 'X')) { + value_tmp = (int32_t)simple_strtol(value_str, NULL, 16); + } else { + value_tmp = (int32_t)simple_strtol(value_str, NULL, 10); + } + + *value = value_tmp; + return 0; +} + +static int dfd_ko_cfg_analyse_index(char *index_str, int *index1, int *index2, int line_num) +{ + int rv; + char *index1_begin_char, *index2_begin_char; + + if (index_str[0] != '_') { + DBG_DEBUG(DBG_ERROR, "line%d: no '-' between name and index1\n", line_num); + return -1; + } + + index1_begin_char = index_str; + rv = dfd_ko_cfg_get_value_from_char(++index1_begin_char, index1, line_num); + if (rv < 0) { + return -1; + } + + if (index2 == NULL) { + return 0; + } + + index2_begin_char = strchr(index1_begin_char, '_'); + if (index2_begin_char == NULL) { + DBG_DEBUG(DBG_ERROR, "line%d: no '-' between index1 and index2\n", line_num); + return -1; + } else { + rv = dfd_ko_cfg_get_value_from_char(++index2_begin_char, index2, line_num); + if (rv < 0) { + return -1; + } + } + + return 0; +} + +static int dfd_ko_cfg_check_array_index(index_range_t *index_range, int *index1, int *index2, + int line_num) +{ + + if ((*index1 < 0) || (*index1 > index_range->index1_max)) { + DBG_DEBUG(DBG_ERROR, "line%d: index1[%d] invalid, max=%d\n", line_num, *index1, + index_range->index1_max); + return -1; + } + + if (index2 == NULL) { + return 0; + } + + if ((*index2 < 0) || (*index2 > index_range->index2_max)) { + DBG_DEBUG(DBG_ERROR, "line%d: index2[%d] invalid, max=%d\n", line_num, *index2, + index_range->index2_max); + return -1; + } + + return 0; +} + +static int dfd_ko_cfg_get_index(char *index_str, index_range_t *index_range, int *index1, + int *index2, int line_num) +{ + int rv; + + if (index_range->index2_max == INDEX_NOT_EXIST) { + index2 = NULL; + } + + rv = dfd_ko_cfg_analyse_index(index_str, index1, index2, line_num); + if (rv < 0) { + return -1; + } + + rv = dfd_ko_cfg_check_array_index(index_range, index1, index2, line_num); + if (rv < 0) { + return -1; + } + + return 0; +} + +static int dfd_ko_cfg_add_int_item(int key, int value, int line_num) +{ + int rv; + int *int_cfg; + + int_cfg = lnode_find_node(&dfd_ko_cfg_list_root, key); + if (int_cfg == NULL) { + + int_cfg = (int *)kmalloc(sizeof(int), GFP_KERNEL); + if (int_cfg == NULL) { + DBG_DEBUG(DBG_ERROR, "line%d: kmalloc int fail\n", line_num); + return -1; + } + + *int_cfg = value; + rv = lnode_insert_node(&dfd_ko_cfg_list_root, key, int_cfg); + if (rv == 0) { + DBG_DEBUG(DBG_VERBOSE, "line%d: add int item[%d] success, key=0x%08x\n", line_num, value, key); + } else { + kfree(int_cfg); + int_cfg = NULL; + DBG_DEBUG(DBG_ERROR, "line%d: add int item[%d] fail, key=0x%08x rv=%d \n", line_num, value, key, rv); + return -1; + } + } else { + + DBG_DEBUG(DBG_WARN, "line%d: replace int item[%d->%d], key=0x%08x\n", line_num, *int_cfg, value, key); + *int_cfg = value; + } + + return 0; +} + +static int dfd_ko_cfg_analyse_int_item(dfd_cfg_item_id_t cfg_item_id, char *arg_name, char *arg_value, + char *cfg_pre, index_range_t *index_range, int line_num) +{ + int rv; + int index1 = 0, index2 = 0; + int value, key; + char *arg_name_tmp; + + if (index_range->index1_max != INDEX_NOT_EXIST) { + arg_name_tmp = arg_name + strlen(cfg_pre); + rv = dfd_ko_cfg_get_index(arg_name_tmp, index_range, &index1, &index2, line_num); + if (rv < 0) { + return -1; + } + } + + rv = dfd_ko_cfg_get_value_from_char(arg_value, &value, line_num); + if (rv < 0) { + return -1; + } + + key = DFD_CFG_KEY(cfg_item_id, index1, index2); + rv = dfd_ko_cfg_add_int_item(key, value, line_num); + if (rv < 0) { + return -1; + } + + return 0; +} + +static int dfd_ko_cfg_add_str_item(int key, char *str, int line_num) +{ + int rv; + char *str_cfg; + + str_cfg = lnode_find_node(&dfd_ko_cfg_list_root, key); + if (str_cfg == NULL) { + + str_cfg = (char *)kmalloc(DFD_CFG_STR_MAX_LEN, GFP_KERNEL); + if (str_cfg == NULL) { + DBG_DEBUG(DBG_ERROR, "line%d: kmalloc str[%lu] fail\n", line_num, strlen(str)); + return -1; + } + memset(str_cfg, 0, DFD_CFG_STR_MAX_LEN); + strncpy(str_cfg, str, DFD_CFG_STR_MAX_LEN - 1); + + rv = lnode_insert_node(&dfd_ko_cfg_list_root, key, str_cfg); + if (rv == 0) { + DBG_DEBUG(DBG_VERBOSE, "line%d: add string item[%s] success, key=0x%08x\n", line_num, str_cfg, key); + } else { + kfree(str_cfg); + str_cfg = NULL; + DBG_DEBUG(DBG_ERROR, "line%d: add string item[%s] fail, key=0x%08x rv=%d \n", line_num, str_cfg, key, rv); + return -1; + } + } else { + DBG_DEBUG(DBG_WARN, "line%d: replace string item[%s->%s], key=0x%08x\n", line_num, str_cfg, str, key); + memset(str_cfg, 0, DFD_CFG_STR_MAX_LEN); + strncpy(str_cfg, str, DFD_CFG_STR_MAX_LEN - 1); + } + + return 0; +} + +static int dfd_ko_cfg_analyse_str_item(dfd_cfg_item_id_t cfg_item_id, char *arg_name, char *arg_value, + char *cfg_pre, index_range_t *index_range, int line_num) +{ + int rv; + int index1 = 0, index2 = 0; + int btree_key; + char *arg_name_tmp; + + if (index_range->index1_max != INDEX_NOT_EXIST) { + arg_name_tmp = arg_name + strlen(cfg_pre); + rv = dfd_ko_cfg_get_index(arg_name_tmp, index_range, &index1, &index2, line_num); + if (rv < 0) { + return -1; + } + } + + if (strlen(arg_value) >= DFD_CFG_STR_MAX_LEN) { + DBG_DEBUG(DBG_ERROR, "line%d: string item[%s] is too long \n", line_num, arg_value); + return -1; + } + + btree_key = DFD_CFG_KEY(cfg_item_id, index1, index2); + rv = dfd_ko_cfg_add_str_item(btree_key, arg_value, line_num); + if (rv < 0) { + return -1; + } + + return 0; +} + +static int dfd_ko_cfg_get_i2c_dev_member(char *member_str, dfd_i2c_dev_mem_t *member, int line_num) +{ + dfd_i2c_dev_mem_t mem_index; + + for (mem_index = DFD_I2C_DEV_MEM_BUS; mem_index < DFD_I2C_DEV_MEM_END; mem_index++) { + if (memcmp(member_str, g_dfd_i2c_dev_mem_str[mem_index], + strlen(g_dfd_i2c_dev_mem_str[mem_index])) == 0) { + *member = mem_index; + return 0; + } + } + + DBG_DEBUG(DBG_ERROR, "line%d: i2c dev member[%s] invalid\n", line_num, member_str); + return -1; +} + +static void dfd_ko_cfg_set_i2c_dev_mem_value(dfd_i2c_dev_t *i2c_dev, dfd_i2c_dev_mem_t member, + int value) +{ + switch (member) { + case DFD_I2C_DEV_MEM_BUS: + i2c_dev->bus = value; + break; + case DFD_I2C_DEV_MEM_ADDR: + i2c_dev->addr = value; + break; + default: + break; + } +} + +static int dfd_ko_cfg_add_i2c_dev_item(int key, dfd_i2c_dev_mem_t member, int value, int line_num) +{ + int rv; + dfd_i2c_dev_t *i2c_dev_cfg; + + i2c_dev_cfg = lnode_find_node(&dfd_ko_cfg_list_root, key); + if (i2c_dev_cfg == NULL) { + + i2c_dev_cfg = (dfd_i2c_dev_t *)kmalloc(sizeof(dfd_i2c_dev_t), GFP_KERNEL); + if (i2c_dev_cfg == NULL) { + DBG_DEBUG(DBG_ERROR, "line%d: kmalloc i2c_dev fail\n", line_num); + return -1; + } + memset(i2c_dev_cfg, 0, sizeof(dfd_i2c_dev_t)); + + dfd_ko_cfg_set_i2c_dev_mem_value(i2c_dev_cfg, member, value); + rv = lnode_insert_node(&dfd_ko_cfg_list_root, key, i2c_dev_cfg); + if (rv == 0) { + DBG_DEBUG(DBG_VERBOSE, "line%d: add i2c_dev item[%s=%d] success, key=0x%08x\n", line_num, + g_dfd_i2c_dev_mem_str[member], value, key); + } else { + kfree(i2c_dev_cfg); + i2c_dev_cfg = NULL; + DBG_DEBUG(DBG_ERROR, "line%d: add i2c_dev item[%s=%d] fail, key=0x%08x rv=%d\n", line_num, + g_dfd_i2c_dev_mem_str[member], value, key, rv); + return -1; + } + } else { + + DBG_DEBUG(DBG_VERBOSE, "line%d: replace i2c_dev item[%s=%d], key=0x%08x\n", line_num, + g_dfd_i2c_dev_mem_str[member], value, key); + dfd_ko_cfg_set_i2c_dev_mem_value(i2c_dev_cfg, member, value); + } + + return 0; +} + +static int dfd_ko_cfg_analyse_i2c_dev_item(dfd_cfg_item_id_t cfg_item_id, char *arg_name, + char *arg_value, char *cfg_pre, index_range_t *index_range, int line_num) +{ + int rv; + int index1 = 0, index2 = 0; + int value, key; + char *arg_name_tmp; + dfd_i2c_dev_mem_t member; + + arg_name_tmp = arg_name + strlen(cfg_pre); + rv = dfd_ko_cfg_get_i2c_dev_member(arg_name_tmp, &member, line_num); + if (rv < 0) { + return -1; + } + + if (index_range->index1_max != INDEX_NOT_EXIST) { + arg_name_tmp += strlen(g_dfd_i2c_dev_mem_str[member]); + rv = dfd_ko_cfg_get_index(arg_name_tmp, index_range, &index1, &index2, line_num); + if (rv < 0) { + return -1; + } + } + + rv = dfd_ko_cfg_get_value_from_char(arg_value, &value, line_num); + if (rv < 0) { + return -1; + } + + key = DFD_CFG_KEY(cfg_item_id, index1, index2); + rv = dfd_ko_cfg_add_i2c_dev_item(key, member, value, line_num); + if (rv < 0) { + return -1; + } + + return 0; +} + +static int dfd_ko_cfg_get_enum_value_by_str(char *enum_val_str[], int enum_val_end, char *buf) +{ + int i; + int enum_val; + + enum_val = DFD_CFG_INVALID_VALUE; + for (i = 0; i < enum_val_end; i++) { + if (memcmp(buf, enum_val_str[i], strlen(enum_val_str[i])) == 0) { + enum_val = i; + break; + } + } + + return enum_val; +} + +static int dfd_ko_cfg_get_info_ctrl_member(char *member_str, info_ctrl_mem_t *member, int line_num) +{ + info_ctrl_mem_t mem_index; + + for (mem_index = INFO_CTRL_MEM_MODE; mem_index < INFO_CTRL_MEM_END; mem_index++) { + if (memcmp(member_str, g_info_ctrl_mem_str[mem_index], + strlen(g_info_ctrl_mem_str[mem_index])) == 0) { + *member = mem_index; + return 0; + } + } + + DBG_DEBUG(DBG_ERROR, "line%d: info ctrl member[%s] invalid\n", line_num, member_str); + return -1; +} + +static void dfd_ko_cfg_set_info_ctrl_mem_value(info_ctrl_t *info_ctrl, info_ctrl_mem_t member, + char *buf_val, int line_num) +{ + switch (member) { + case INFO_CTRL_MEM_MODE: + info_ctrl->mode = dfd_ko_cfg_get_enum_value_by_str(g_info_ctrl_mode_str, INFO_CTRL_MODE_END, buf_val);; + break; + case INFO_CTRL_MEM_INT_CONS: + dfd_ko_cfg_get_value_from_char(buf_val, &(info_ctrl->int_cons), line_num); + break; + case INFO_CTRL_MEM_SRC: + info_ctrl->src = dfd_ko_cfg_get_enum_value_by_str(g_info_src_str, INFO_SRC_END, buf_val); + break; + case INFO_CTRL_MEM_FRMT: + info_ctrl->frmt = dfd_ko_cfg_get_enum_value_by_str(g_info_frmt_str, INFO_FRMT_END, buf_val); + break; + case INFO_CTRL_MEM_POLA: + info_ctrl->pola = dfd_ko_cfg_get_enum_value_by_str(g_info_pola_str, INFO_POLA_END, buf_val); + break; + case INFO_CTRL_MEM_FPATH: + memset(info_ctrl->fpath, 0, sizeof(info_ctrl->fpath)); + strncpy(info_ctrl->fpath, buf_val, sizeof(info_ctrl->fpath) - 1); + break; + case INFO_CTRL_MEM_ADDR: + dfd_ko_cfg_get_value_from_char(buf_val, &(info_ctrl->addr), line_num); + break; + case INFO_CTRL_MEM_LEN: + dfd_ko_cfg_get_value_from_char(buf_val, &(info_ctrl->len), line_num); + break; + case INFO_CTRL_MEM_BIT_OFFSET: + dfd_ko_cfg_get_value_from_char(buf_val, &(info_ctrl->bit_offset), line_num); + break; + case INFO_CTRL_MEM_STR_CONS: + memset(info_ctrl->str_cons, 0, sizeof(info_ctrl->str_cons)); + strncpy(info_ctrl->str_cons, buf_val, sizeof(info_ctrl->str_cons) - 1); + break; + case INFO_CTRL_MEM_INT_EXTRA1: + dfd_ko_cfg_get_value_from_char(buf_val, &(info_ctrl->int_extra1), line_num); + break; + case INFO_CTRL_MEM_INT_EXTRA2: + dfd_ko_cfg_get_value_from_char(buf_val, &(info_ctrl->int_extra2), line_num); + break; + default: + break; + } +} + +static int dfd_ko_cfg_add_info_ctrl_item(int key, info_ctrl_mem_t member, char *buf_val, + int line_num) +{ + int rv; + info_ctrl_t *info_ctrl_cfg; + + info_ctrl_cfg = lnode_find_node(&dfd_ko_cfg_list_root, key); + if (info_ctrl_cfg == NULL) { + + info_ctrl_cfg = (info_ctrl_t *)kmalloc(sizeof(info_ctrl_t), GFP_KERNEL); + if (info_ctrl_cfg == NULL) { + DBG_DEBUG(DBG_ERROR, "line%d: kmalloc info_ctrl fail\n", line_num); + return -1; + } + memset(info_ctrl_cfg, 0, sizeof(info_ctrl_t)); + + dfd_ko_cfg_set_info_ctrl_mem_value(info_ctrl_cfg, member, buf_val, line_num); + rv = lnode_insert_node(&dfd_ko_cfg_list_root, key, info_ctrl_cfg); + if (rv == 0) { + DBG_DEBUG(DBG_VERBOSE, "line%d: add info_ctrl item[%s=%s] success, key=0x%08x\n", line_num, + g_info_ctrl_mem_str[member], buf_val, key); + } else { + kfree(info_ctrl_cfg); + info_ctrl_cfg = NULL; + DBG_DEBUG(DBG_ERROR, "line%d: add info_ctrl item[%s=%s] fail, key=0x%08x rv=%d\n", line_num, + g_info_ctrl_mem_str[member], buf_val, key, rv); + return -1; + } + } else { + + DBG_DEBUG(DBG_VERBOSE, "line%d: replace info_ctrl item[%s=%s], key=0x%08x\n", line_num, + g_info_ctrl_mem_str[member], buf_val, key); + dfd_ko_cfg_set_info_ctrl_mem_value(info_ctrl_cfg, member, buf_val, line_num); + } + + return 0; +} + +static int dfd_ko_cfg_analyse_info_ctrl_item(dfd_cfg_item_id_t cfg_item_id, char *arg_name, + char *arg_value, char *cfg_pre, index_range_t *index_range, int line_num) +{ + int rv; + int index1 = 0, index2 = 0; + int key; + char *arg_name_tmp; + info_ctrl_mem_t member; + + arg_name_tmp = arg_name + strlen(cfg_pre); + rv = dfd_ko_cfg_get_info_ctrl_member(arg_name_tmp, &member, line_num); + if (rv < 0) { + return -1; + } + + if (index_range->index1_max != INDEX_NOT_EXIST) { + arg_name_tmp += strlen(g_info_ctrl_mem_str[member]); + rv = dfd_ko_cfg_get_index(arg_name_tmp, index_range, &index1, &index2, line_num); + if (rv < 0) { + return -1; + } + } + + key = DFD_CFG_KEY(cfg_item_id, index1, index2); + rv = dfd_ko_cfg_add_info_ctrl_item(key, member, arg_value, line_num); + if (rv < 0) { + return -1; + } + + return 0; +} + +static int dfd_ko_cfg_analyse_config(char *arg_name, char*arg_value, int line_num) +{ + int i, rv = 0; + int cfg_item_num; + + cfg_item_num = sizeof(dfd_cfg_item_name) / sizeof(dfd_cfg_item_name[0]); + for (i = 0; i < cfg_item_num; i++) { + if (memcmp(arg_name, dfd_cfg_item_name[i], strlen(dfd_cfg_item_name[i])) == 0){ + if (DFD_CFG_ITEM_IS_INT(i)) { + rv = dfd_ko_cfg_analyse_int_item(i, arg_name, arg_value, dfd_cfg_item_name[i], + &(dfd_cfg_item_index_range[i]), line_num); + } else if (DFD_CFG_ITEM_IS_STRING(i)) { + rv = dfd_ko_cfg_analyse_str_item(i, arg_name, arg_value, dfd_cfg_item_name[i], + &(dfd_cfg_item_index_range[i]), line_num); + } else if (DFD_CFG_ITEM_IS_I2C_DEV(i)) { + rv = dfd_ko_cfg_analyse_i2c_dev_item(i, arg_name, arg_value, dfd_cfg_item_name[i], + &(dfd_cfg_item_index_range[i]), line_num); + } else if (DFD_CFG_ITEM_IS_INFO_CTRL(i)) { + rv = dfd_ko_cfg_analyse_info_ctrl_item(i, arg_name, arg_value, dfd_cfg_item_name[i], + &(dfd_cfg_item_index_range[i]), line_num); + } else { + rv = -1; + } + break; + } + } + + return rv; +} + +static int dfd_ko_cfg_cut_config_line(char *config_line, char *arg_name, char *arg_value) +{ + int i, j = 0, k = 0; + int len, name_value_flag = 0; + + len = strlen(config_line); + for (i = 0; i < len; i++) { + if (config_line[i] == '=') { + name_value_flag = 1; + continue; + } + + if (name_value_flag == 0) { + arg_name[j++] = config_line[i]; + } else { + arg_value[k++] = config_line[i]; + } + } + + if (name_value_flag == 0) { + return -1; + } else { + return 0; + } +} + +static int dfd_ko_cfg_analyse_config_line(char *config_line, int line_num) +{ + int rv; + char arg_name[DFD_CFG_NAME_MAX_LEN] = {0}; + char arg_value[DFD_CFG_VALUE_MAX_LEN] = {0}; + + dfd_ko_cfg_del_space_lf_cr(config_line); + + if (strlen(config_line) == 0) { + DBG_DEBUG(DBG_VERBOSE, "line%d: space line\n", line_num); + return 0; + } + + if (config_line[0] == '#') { + DBG_DEBUG(DBG_VERBOSE, "line%d: comment line[%s]\n", line_num, config_line); + return 0; + } + + rv = dfd_ko_cfg_cut_config_line(config_line, arg_name, arg_value); + if (rv < 0) { + DBG_DEBUG(DBG_VERBOSE, "line%d: [%s]no '=' between name and value\n", line_num, config_line); + return -1; + } + + DBG_DEBUG(DBG_VERBOSE, "line%d: config_line[%s] name[%s] value[%s]\n", line_num, config_line, arg_name, arg_value); + return dfd_ko_cfg_analyse_config(arg_name, arg_value, line_num); +} + +static int dfd_ko_cfg_analyse_config_file(char *fpath) +{ + int rv; + int line_num = 1; + kfile_ctrl_t kfile_ctrl; + char config_line[DFD_CFG_CMDLINE_MAX_LEN] = {0}; + + rv = kfile_open(fpath, &kfile_ctrl); + if (rv != KFILE_RV_OK) { + DBG_DEBUG(DBG_ERROR, "open config file[%s] fail, rv=%d\n", fpath, rv); + return -1; + } + + while(kfile_gets(config_line, sizeof(config_line), &kfile_ctrl) > 0){ + rv = dfd_ko_cfg_analyse_config_line(config_line, line_num++); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "!!!!file[%s] config line[%d %s] analyse fail\n", fpath, line_num - 1, + config_line); + break; + } + + (void)memset(config_line, 0, sizeof(config_line)); + + } + kfile_close(&kfile_ctrl); + + return rv; +} + +void *dfd_ko_cfg_get_item(int key) +{ + return lnode_find_node(&dfd_ko_cfg_list_root, key); +} + +static void dfd_ko_cfg_print_item(int key, const void *cfg) +{ + int item_id; + dfd_i2c_dev_t *i2c_dev; + info_ctrl_t *info_ctrl; + + if (cfg == NULL) { + DBG_DEBUG(DBG_ERROR, "input arguments error\n"); + return; + } + printk(KERN_INFO "**************************\n"); + printk(KERN_INFO "key=0x%08x\n", key); + + item_id = DFD_CFG_ITEM_ID(key); + if (DFD_CFG_ITEM_IS_INT(item_id)) { + printk(KERN_INFO "int=%d\n", *((int *)cfg)); + } else if (DFD_CFG_ITEM_IS_I2C_DEV(item_id)) { + i2c_dev = (dfd_i2c_dev_t *)cfg; + printk(KERN_INFO ".bus=0x%02x\n", i2c_dev->bus); + printk(KERN_INFO ".addr=0x%02x\n", i2c_dev->addr); + } else if (DFD_CFG_ITEM_IS_INFO_CTRL(item_id)) { + info_ctrl = (info_ctrl_t *)cfg; + printk(KERN_INFO ".mode=%s\n", g_info_ctrl_mode_str[info_ctrl->mode]); + printk(KERN_INFO ".int_cons=%d\n", info_ctrl->int_cons); + printk(KERN_INFO ".src=%s\n", g_info_src_str[info_ctrl->src]); + printk(KERN_INFO ".frmt=%s\n", g_info_frmt_str[info_ctrl->frmt]); + printk(KERN_INFO ".pola=%s\n", g_info_pola_str[info_ctrl->pola]); + printk(KERN_INFO ".fpath=%s\n", info_ctrl->fpath); + printk(KERN_INFO ".addr=0x%02x\n", info_ctrl->addr); + printk(KERN_INFO ".len=%d\n", info_ctrl->len); + printk(KERN_INFO ".bit_offset=%d\n", info_ctrl->bit_offset); + } else { + printk(KERN_INFO "item[%d] error!\n", item_id); + } +} + +void dfd_ko_cfg_show_item(int key) +{ + void *cfg; + + cfg = lnode_find_node(&dfd_ko_cfg_list_root, key); + if (cfg == 0) { + printk(KERN_INFO "item[0x%08x] not exist\n", key); + return; + } + + dfd_ko_cfg_print_item(key, cfg); +} + +static int dfd_get_my_dev_type_by_file(void) +{ + struct file *fp; + loff_t pos; + int card_type; + char buf[DFD_PID_BUF_LEN]; + int ret; + + fp= filp_open(DFD_PUB_CARDTYPE_FILE, O_RDONLY, 0); + if (IS_ERR(fp)) { + DBG_DEBUG(DBG_VERBOSE, "open file fail!\n"); + return -1; + } + memset(buf, 0, DFD_PID_BUF_LEN); + pos = 0; + ret = kernel_read(fp, buf, DFD_PRODUCT_ID_LENGTH + 1, &pos); + if (ret < 0) { + DBG_DEBUG(DBG_VERBOSE, "kernel_read failed, path=%s, addr=0, size=%d, ret=%d\n", + DFD_PUB_CARDTYPE_FILE, DFD_PRODUCT_ID_LENGTH + 1, ret); + filp_close(fp, NULL); + return -1; + } + + card_type = simple_strtoul(buf, NULL, 10); + DBG_DEBUG(DBG_VERBOSE, "card_type 0x%x.\n", card_type); + + filp_close(fp, NULL); + return card_type; +} + +static int drv_get_my_dev_type(void) +{ + static int type = -1; + + if (type > 0) { + return type; + } + type = dfd_get_my_dev_type_by_file(); + DBG_DEBUG(DBG_VERBOSE, "ko board type %d\n", type); + return type; +} + +static int dfd_ko_cfg_init(void) +{ + int rv; + int card_type; + char file_name[32] = {0}; + char fpath[128] = {0}; + kfile_ctrl_t kfile_ctrl; + + rv = lnode_init_root(&dfd_ko_cfg_list_root); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "init list root fail, rv=%d\n", rv); + return -1; + } + + card_type = drv_get_my_dev_type(); + if (card_type > 0) { + snprintf(fpath, sizeof(fpath), "%s0x%x", DFD_KO_CFG_FILE_DIR, card_type); + rv = kfile_open(fpath, &kfile_ctrl); + if (rv != KFILE_RV_OK) { + DBG_DEBUG(DBG_VERBOSE, "open config file[%s] fail, rv=%d, maybe not exist\n", + fpath, rv); + + rv = kfile_open(DFD_KO_CFG_FILE_NAME, &kfile_ctrl); + if (rv != KFILE_RV_OK) { + DBG_DEBUG(DBG_ERROR, "open config file[%s] fail, rv=%d\n", DFD_KO_CFG_FILE_NAME, + rv); + return -1; + } + DBG_DEBUG(DBG_ERROR, "get config file from: %s, success.\n", DFD_KO_CFG_FILE_NAME); + } else { + DBG_DEBUG(DBG_VERBOSE, "get config file from: %s, success.\n", fpath); + } + } else { + DBG_DEBUG(DBG_VERBOSE, "get board id failed, try to get config file from: %s\n", + DFD_KO_CFG_FILE_NAME); + + rv = kfile_open(DFD_KO_CFG_FILE_NAME, &kfile_ctrl); + if (rv != KFILE_RV_OK) { + DBG_DEBUG(DBG_ERROR, "open config file[%s] fail, rv=%d\n", DFD_KO_CFG_FILE_NAME, rv); + return -1; + } + DBG_DEBUG(DBG_ERROR, "get config file from: %s, success.\n", DFD_KO_CFG_FILE_NAME); + } + + while (kfile_gets(file_name, sizeof(file_name), &kfile_ctrl) > 0) { + + dfd_ko_cfg_del_space_lf_cr(file_name); + memset(fpath, 0, sizeof(fpath)); + snprintf(fpath, sizeof(fpath), "%s%s.cfg", DFD_KO_CFG_FILE_DIR, file_name); + DBG_DEBUG(DBG_VERBOSE, ">>>>start parsing config file[%s]\n", fpath); + + rv = dfd_ko_cfg_analyse_config_file(fpath); + if (rv < 0) { + break; + } + } + kfile_close(&kfile_ctrl); + + return 0; +} + +int32_t dfd_dev_cfg_init(void) +{ + return dfd_ko_cfg_init(); +} + +void dfd_dev_cfg_exit(void) +{ + lnode_free_list(&dfd_ko_cfg_list_root); + return; +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_cfg_adapter.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_cfg_adapter.c new file mode 100644 index 000000000000..b758bf62bd8c --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_cfg_adapter.c @@ -0,0 +1,354 @@ +/* + * Copyright(C) 2015 Ruijie Network. All rights reserved. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "../include/dfd_module.h" +#include "../include/dfd_cfg_file.h" +#include "../include/dfd_cfg.h" +#include "../include/dfd_cfg_adapter.h" + +char *g_dfd_i2c_dev_mem_str[DFD_I2C_DEV_MEM_END] = { + ".bus", + ".addr", +}; + +static dfd_i2c_dev_t* dfd_ko_get_cpld_i2c_dev(int sub_slot, int cpld_id) +{ + int key; + dfd_i2c_dev_t *i2c_dev; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_CPLD_I2C_DEV, sub_slot, cpld_id); + i2c_dev = dfd_ko_cfg_get_item(key); + if (i2c_dev == NULL) { + DBG_DEBUG(DBG_ERROR, "get cpld[%d] i2c dev config fail, key=0x%08x\n", cpld_id, key); + return NULL; + } + + return i2c_dev; +} + +static int32_t dfd_ko_i2c_smbus_transfer(int read_write, int bus, int addr, int offset, uint8_t *buf, uint32_t size) +{ + int rv; + struct i2c_adapter *i2c_adap; + union i2c_smbus_data data; + + i2c_adap = i2c_get_adapter(bus); + if (i2c_adap == NULL) { + DBG_DEBUG(DBG_ERROR, "get i2c bus[%d] adapter fail\n", bus); + return -DFD_RV_DEV_FAIL; + } + + if (read_write == I2C_SMBUS_WRITE) { + data.byte = *buf; + } else { + data.byte = 0; + } + rv = i2c_smbus_xfer(i2c_adap, addr, 0, read_write, offset, I2C_SMBUS_BYTE_DATA, &data); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "i2c dev[bus=%d addr=0x%x offset=0x%x size=%d rw=%d] transfer fail, rv=%d\n", + bus, addr, offset, size, read_write, rv); + rv = -DFD_RV_DEV_FAIL; + } else { + DBG_DEBUG(DBG_VERBOSE, "i2c dev[bus=%d addr=0x%x offset=0x%x size=%d rw=%d] transfer success\n", + bus, addr, offset, size, read_write); + rv = DFD_RV_OK; + } + + if (read_write == I2C_SMBUS_READ) { + if (rv == DFD_RV_OK) { + *buf = data.byte; + } else { + *buf = 0; + } + } + + i2c_put_adapter(i2c_adap); + return rv; +} + +static int32_t dfd_ko_i2c_read_data(int bus, int addr, int offset, uint8_t *buf, uint32_t size) +{ + int i, rv; + for (i = 0; i < DFD_KO_CPLD_I2C_RETRY_TIMES; i++) { + rv = dfd_ko_i2c_smbus_transfer(I2C_SMBUS_READ, bus, addr, offset, buf, size); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "[%d]cpld read[offset=0x%x] fail, rv %d\n", i, addr, rv); + msleep(DFD_KO_CPLD_I2C_RETRY_SLEEP); + } else { + DBG_DEBUG(DBG_VERBOSE, "[%d]cpld read[offset=0x%x] success, value=0x%x\n", + i, addr, *buf); + break; + } + } + return rv; +} + +static int32_t dfd_ko_i2c_write_data(int bus, int addr, int offset, uint8_t data, uint32_t size) +{ + int i, rv; + for (i = 0; i < DFD_KO_CPLD_I2C_RETRY_TIMES; i++) { + rv = dfd_ko_i2c_smbus_transfer(I2C_SMBUS_WRITE, bus, addr, offset, &data, size); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "[%d]cpld write[offset=0x%x] fail, rv=%d\n", i, addr, rv); + msleep(DFD_KO_CPLD_I2C_RETRY_SLEEP); + } else { + DBG_DEBUG(DBG_VERBOSE, "[%d]cpld write[offset=0x%x, data=%d] success\n", i, addr, data); + break; + } + } + + return rv; +} + +static int32_t dfd_ko_cpld_i2c_read(int32_t addr, uint8_t *buf) +{ + int rv; + int sub_slot, cpld_id, cpld_addr; + dfd_i2c_dev_t *i2c_dev; + + if (buf == NULL) { + DBG_DEBUG(DBG_ERROR, "input arguments error\n"); + return -DFD_RV_INDEX_INVALID; + } + + sub_slot = DFD_KO_CPLD_GET_SLOT(addr); + cpld_id = DFD_KO_CPLD_GET_ID(addr); + cpld_addr = DFD_KO_CPLD_GET_INDEX(addr); + + i2c_dev = dfd_ko_get_cpld_i2c_dev(sub_slot, cpld_id); + if (i2c_dev == NULL) { + return -DFD_RV_DEV_NOTSUPPORT; + } + rv = dfd_ko_i2c_read_data(i2c_dev->bus, i2c_dev->addr, cpld_addr, buf, sizeof(uint8_t)); + + return rv; +} + +static int32_t dfd_ko_cpld_i2c_write(int32_t addr, uint8_t data) +{ + int rv; + int sub_slot, cpld_id, cpld_addr; + dfd_i2c_dev_t *i2c_dev; + + sub_slot = DFD_KO_CPLD_GET_SLOT(addr); + cpld_id = DFD_KO_CPLD_GET_ID(addr); + cpld_addr = DFD_KO_CPLD_GET_INDEX(addr); + + i2c_dev = dfd_ko_get_cpld_i2c_dev(sub_slot, cpld_id); + if (i2c_dev == NULL) { + return -DFD_RV_DEV_NOTSUPPORT; + } + + rv = dfd_ko_i2c_write_data(i2c_dev->bus, i2c_dev->addr, cpld_addr, data, sizeof(uint8_t)); + + return rv; +} + +static int32_t dfd_ko_cpld_io_read(int32_t addr, uint8_t *buf) +{ + int cpld_id, sub_slot, offset; + int key; + int *tmp; + uint16_t io_port; + + sub_slot = DFD_KO_CPLD_GET_SLOT(addr); + cpld_id = DFD_KO_CPLD_GET_ID(addr); + offset = DFD_KO_CPLD_GET_INDEX(addr); + + key = DFD_CFG_KEY(DFD_CFG_ITEM_CPLD_LPC_DEV, sub_slot, cpld_id); + tmp = dfd_ko_cfg_get_item(key); + if (tmp == NULL) { + DBG_DEBUG(DBG_ERROR,"get cpld io base config fail, key=0x%08x\n", key); + return -1; + } + + io_port = (u16)(*tmp) + offset; + *buf = inb(io_port); + DBG_DEBUG(DBG_VERBOSE, "read cpld io port addr 0x%x, data 0x%x\n", io_port, *buf); + + return DFD_RV_OK; + +} + +static int32_t dfd_ko_cpld_io_write(int32_t addr, uint8_t data) +{ + int cpld_id, sub_slot, offset; + int key; + int *tmp; + uint16_t io_port; + + sub_slot = DFD_KO_CPLD_GET_SLOT(addr); + cpld_id = DFD_KO_CPLD_GET_ID(addr); + offset = DFD_KO_CPLD_GET_INDEX(addr); + + key = DFD_CFG_KEY(DFD_CFG_ITEM_CPLD_LPC_DEV, sub_slot, cpld_id); + tmp = dfd_ko_cfg_get_item(key); + if (tmp == NULL) { + DBG_DEBUG(DBG_ERROR, "get cpld io base config fail, key=0x%08x\n", key); + return -1; + } + + io_port = (u16)(*tmp) + offset; + DBG_DEBUG(DBG_VERBOSE, "write cpld io port addr 0x%x, data 0x%x\n", io_port, data); + outb(data, (u16)io_port); + + return DFD_RV_OK; +} + +static int dfd_cfg_get_cpld_mode(int sub_slot, int cpld_id, int *mode) +{ + int key; + char *name; + + if (mode == NULL) { + DBG_DEBUG(DBG_ERROR, "input arguments error\n"); + return -DFD_RV_TYPE_ERR; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_CPLD_MODE, sub_slot, cpld_id); + name = dfd_ko_cfg_get_item(key); + if (name == NULL) { + DBG_DEBUG(DBG_ERROR, "get cpld[%d] mode info ctrl fail, key=0x%08x\n", cpld_id, key); + return -DFD_RV_NODE_FAIL; + } + + DBG_DEBUG(DBG_VERBOSE, "cpld_id %d mode_name %s.\n", cpld_id, name); + if (!strncmp(name, DFD_KO_CPLD_MODE_I2C_STRING, strlen(DFD_KO_CPLD_MODE_I2C_STRING))) { + *mode = DFD_CPLD_MODE_I2C; + } else if (!strncmp(name, DFD_KO_CPLD_MODE_LPC_STRING, strlen(DFD_KO_CPLD_MODE_LPC_STRING))) { + *mode = DFD_CPLD_MODE_LPC; + } else { + + *mode = DFD_CPLD_MODE_I2C; + } + + DBG_DEBUG(DBG_VERBOSE, "cpld_id %d mode %d.\n", cpld_id, *mode); + return 0; +} + +int32_t dfd_ko_cpld_read(int32_t addr, uint8_t *buf) +{ + int ret; + int sub_slot, cpld_id; + int cpld_mode; + + sub_slot = DFD_KO_CPLD_GET_SLOT(addr); + cpld_id = DFD_KO_CPLD_GET_ID(addr); + + ret = dfd_cfg_get_cpld_mode(sub_slot, cpld_id, &cpld_mode); + if (ret) { + DBG_DEBUG(DBG_WARN, "drv_get_cpld_mode sub_slot %d cpldid %d faile, set default i2c mode.\n", sub_slot, cpld_id); + cpld_mode = DFD_CPLD_MODE_I2C; + } + + if (cpld_mode == DFD_CPLD_MODE_I2C) { + ret = dfd_ko_cpld_i2c_read(addr, buf); + } else if (cpld_mode == DFD_CPLD_MODE_LPC) { + ret = dfd_ko_cpld_io_read(addr, buf); + } else { + DBG_DEBUG(DBG_ERROR, "cpld_mode %d invalid.\n", cpld_mode); + ret = -DFD_RV_DEV_NOTSUPPORT; + } + + DBG_DEBUG(DBG_VERBOSE, "addr 0x%x val 0x%x ret %d\n", addr, *buf, ret); + return ret; +} + +int32_t dfd_ko_cpld_write(int32_t addr, uint8_t val) +{ + int ret; + int sub_slot, cpld_id, cpld_mode; + + sub_slot = DFD_KO_CPLD_GET_SLOT(addr); + cpld_id = DFD_KO_CPLD_GET_ID(addr); + + ret = dfd_cfg_get_cpld_mode(sub_slot, cpld_id, &cpld_mode); + if (ret) { + DBG_DEBUG(DBG_ERROR, "drv_get_cpld_mode sub_slot %d cpldid %d faile, set default local_bus mode.\n", sub_slot, cpld_id); + cpld_mode = DFD_CPLD_MODE_I2C; + } + + if (cpld_mode == DFD_CPLD_MODE_I2C) { + ret = dfd_ko_cpld_i2c_write(addr, val); + } else if (cpld_mode == DFD_CPLD_MODE_LPC) { + ret = dfd_ko_cpld_io_write(addr, val); + } else { + DBG_DEBUG(DBG_ERROR, "cpld_mode %d invalid.\n", cpld_mode); + ret = -DFD_RV_DEV_NOTSUPPORT; + } + + DBG_DEBUG(DBG_VERBOSE, "addr 0x%x val 0x%x ret %d\n", addr, val, ret); + return ret; +} + +int32_t dfd_ko_i2c_read(int bus, int addr, int offset, uint8_t *buf, uint32_t size) +{ + int i, rv; + + for (i = 0; i < size; i++) { + rv = dfd_ko_i2c_read_data(bus, addr, offset, &buf[i], sizeof(uint8_t)); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "dfd_ko_i2c_read[bus=%d addr=0x%x offset=0x%x]fail, rv=%d\n", + bus, addr, offset, rv); + return rv; + } + offset++; + } + + return size; +} + +int32_t dfd_ko_i2c_write(int bus, int addr, int offset, uint8_t *buf, uint32_t size) +{ + int i, rv; + + for (i = 0; i < size; i++) { + rv = dfd_ko_i2c_write_data(bus, addr, offset, buf[i], sizeof(uint8_t)); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "dfd_ko_i2c_write[bus=%d addr=0x%x offset=0x%x]fail, rv=%d\n", + bus, addr, offset, rv); + return rv; + } + offset++; + } + + return size; + +} + +int32_t dfd_ko_read_file(char *fpath, int32_t addr, uint8_t *val, int32_t read_bytes) +{ + int32_t ret; + struct file *filp; + loff_t pos; + + if ((fpath == NULL) || (val == NULL) || (addr < 0) || (read_bytes < 0)) { + DBG_DEBUG(DBG_ERROR, "input arguments error, addr=%d read_bytes=%d\n", addr, read_bytes); + return -DFD_RV_INDEX_INVALID; + } + + filp = filp_open(fpath, O_RDONLY, 0); + if (IS_ERR(filp)){ + DBG_DEBUG(DBG_ERROR, "open file[%s] fail\n", fpath); + return -DFD_RV_DEV_FAIL; + } + + pos = addr; + ret = kernel_read(filp, val, read_bytes, &pos); + if (ret < 0) { + DBG_DEBUG(DBG_ERROR, "kernel_read failed, path=%s, addr=%d, size=%d, ret=%d\n", fpath, addr, read_bytes, ret); + ret = -DFD_RV_DEV_FAIL; + } + + filp_close(filp, NULL); + return ret; +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_cfg_file.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_cfg_file.c new file mode 100644 index 000000000000..ffb96992d3d6 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_cfg_file.c @@ -0,0 +1,239 @@ +/* + * Copyright(C) 2001-2015s Ruijie Network. All rights reserved. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../include/dfd_cfg_file.h" +#include "../include/dfd_module.h" + +struct getdents_callback { + struct dir_context ctx; + const char *obj_name; + char *match_name; + int dir_len; + int found; +}; + +int kfile_open(char *fname, kfile_ctrl_t *kfile_ctrl) +{ + int ret; + struct file *filp; + loff_t pos; + + if ((fname == NULL) || (kfile_ctrl == NULL)) { + return KFILE_RV_INPUT_ERR; + } + + filp = filp_open(fname, O_RDONLY, 0); + if (IS_ERR(filp)){ + return KFILE_RV_OPEN_FAIL; + } + + kfile_ctrl->size = filp->f_inode->i_size; + + kfile_ctrl->buf = kmalloc(kfile_ctrl->size, GFP_KERNEL); + if (kfile_ctrl->buf == NULL) { + ret = KFILE_RV_MALLOC_FAIL; + goto close_fp; + } + memset(kfile_ctrl->buf, 0, kfile_ctrl->size); + + pos = 0; + ret = kernel_read(filp, kfile_ctrl->buf, kfile_ctrl->size, &pos); + if (ret < 0) { + ret = KFILE_RV_RD_FAIL; + goto free_buf; + } + + kfile_ctrl->pos = 0; + + ret = KFILE_RV_OK; + goto close_fp; + +free_buf: + kfree(kfile_ctrl->buf); + kfile_ctrl->buf = NULL; + +close_fp: + filp_close(filp, NULL); + return ret; +} + +void kfile_close(kfile_ctrl_t *kfile_ctrl) +{ + if (kfile_ctrl == NULL) { + return; + } + + kfile_ctrl->size = 0; + kfile_ctrl->pos = 0; + if (kfile_ctrl->buf) { + kfree(kfile_ctrl->buf); + kfile_ctrl->buf = NULL; + } +} + +int kfile_gets(char *buf, int buf_size, kfile_ctrl_t *kfile_ctrl) +{ + int i; + int has_cr = 0; + + if ((buf == NULL) || (buf_size <= 0) || (kfile_ctrl == NULL) || (kfile_ctrl->buf == NULL) + || (kfile_ctrl->size <= 0)) { + return KFILE_RV_INPUT_ERR; + } + + memset(buf, 0, buf_size); + for (i = 0; i < buf_size; i++) { + + if (kfile_ctrl->pos >= kfile_ctrl->size) { + break; + } + + if (has_cr) { + break; + } + + if (IS_CR(kfile_ctrl->buf[kfile_ctrl->pos])) { + has_cr = 1; + } + + buf[i] = kfile_ctrl->buf[kfile_ctrl->pos]; + kfile_ctrl->pos++; + } + + return i; +} + +int kfile_read(int32_t addr, char *buf, int buf_size, kfile_ctrl_t *kfile_ctrl) +{ + int i; + + if ((buf == NULL) || (buf_size <= 0) || (kfile_ctrl == NULL) || (kfile_ctrl->buf == NULL) + || (kfile_ctrl->size <= 0)) { + return KFILE_RV_INPUT_ERR; + } + + if ((addr < 0) || (addr >= kfile_ctrl->size)) { + return KFILE_RV_ADDR_ERR; + } + + memset(buf, 0, buf_size); + + kfile_ctrl->pos = addr; + for (i = 0; i < buf_size; i++) { + + if (kfile_ctrl->pos >= kfile_ctrl->size) { + break; + } + + buf[i] = kfile_ctrl->buf[kfile_ctrl->pos]; + kfile_ctrl->pos++; + } + + return i; +} + +static int kfile_filldir_one(struct dir_context *ctx, const char * name, int len, + loff_t pos, u64 ino, unsigned int d_type) +{ + struct getdents_callback *buf ; + int result; + buf = container_of(ctx, struct getdents_callback, ctx); + result = 0; + if (strncmp(buf->obj_name, name, strlen(buf->obj_name)) == 0) { + if (buf->dir_len < len) { + DBG_DEBUG(DBG_ERROR, "match ok. dir name:%s, but buf_len %d small than dir len %d.\n", + name, buf->dir_len, len); + buf->found = 0; + return -1; + } + memset(buf->match_name, 0 , buf->dir_len); + memcpy(buf->match_name, name, len); + buf->found = 1; + result = -1; + } + return result; +} + +int kfile_iterate_dir(const char *dir_path, const char *obj_name, char *match_name, int len) +{ + int ret; + struct file *dir; + struct getdents_callback buffer = { + .ctx.actor = kfile_filldir_one, + }; + + if(!dir_path || !obj_name || !match_name) { + DBG_DEBUG(DBG_ERROR, "params error. \n"); + return KFILE_RV_INPUT_ERR; + } + buffer.obj_name = obj_name; + buffer.match_name = match_name; + buffer.dir_len = len; + buffer.found = 0; + + dir = filp_open(dir_path, O_RDONLY, 0); + if (IS_ERR(dir)) { + DBG_DEBUG(DBG_ERROR, "filp_open error, dir path:%s\n", dir_path); + return KFILE_RV_OPEN_FAIL; + } + ret = iterate_dir(dir, &buffer.ctx); + if (buffer.found) { + DBG_DEBUG(DBG_VERBOSE, "match ok, dir name:%s\n", match_name); + filp_close(dir, NULL); + return DFD_RV_OK; + } + filp_close(dir, NULL); + return -DFD_RV_NODE_FAIL; +} + +#if 0 + +int kfile_write(char *fpath, int32_t addr, char *buf, int buf_size) +{ + int ret = KFILE_RV_OK; + struct file *filp; + mm_segment_t old_fs; + int wlen; + + if ((fpath == NULL) || (buf == NULL) || (buf_size <= 0)) { + return KFILE_RV_INPUT_ERR; + } + + if (addr < 0) { + return KFILE_RV_ADDR_ERR; + } + + filp = filp_open(fpath, O_RDWR, 0); + if (IS_ERR(filp)){ + return KFILE_RV_OPEN_FAIL; + } + + old_fs = get_fs(); + set_fs(KERNEL_DS); + + filp->f_op->llseek(filp,0,0); + filp->f_pos = addr; + + wlen = filp->f_op->write(filp, buf, buf_size, &(filp->f_pos)); + if (wlen < 0) { + ret = KFILE_RV_WR_FAIL; + } + + filp->f_op->llseek(filp,0,0); + set_fs(old_fs); + filp_close(filp, NULL); + + return ret; +} +#endif diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_cfg_info.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_cfg_info.c new file mode 100644 index 000000000000..50e7dbf126d7 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_cfg_info.c @@ -0,0 +1,590 @@ +/* + * Copyright(C) 2013 Ruijie Network. All rights reserved. + */ + +#include +#include +#include + +#include "../include/dfd_module.h" +#include "../include/dfd_cfg_adapter.h" +#include "../include/dfd_cfg.h" +#include "../include/dfd_cfg_info.h" +#include "../include/dfd_cfg_file.h" + +#define DFD_HWMON_NAME "hwmon" +#define DFD_GET_CPLD_VOLATGE_CODE_VALUE(value) ((value >> 4)& 0xfff) +#define DFD_GET_CPLD_VOLATGE_REAL_VALUE(code_val, k) ((code_val * 16 * 33 * k) / ((65536 - 5000) * 10)) + +char *g_info_ctrl_mem_str[INFO_CTRL_MEM_END] = { + ".mode", + ".int_cons", + ".src", + ".frmt", + ".pola", + ".fpath", + ".addr", + ".len", + ".bit_offset", + ".str_cons", + ".int_extra1", + ".int_extra2", +}; + +char *g_info_ctrl_mode_str[INFO_CTRL_MODE_END] = { + "none", + "config", + "constant", + "tlv", + "str_constant", +}; + +char *g_info_src_str[INFO_SRC_END] = { + "none", + "cpld", + "fpga", + "other_i2c", + "file", +}; + +char *g_info_frmt_str[INFO_FRMT_END] = { + "none", + "bit", + "byte", + "num_bytes", + "num_str", + "num_buf", + "buf", +}; + +char *g_info_pola_str[INFO_POLA_END] = { + "none", + "positive", + "negative", +}; + +static int dfd_read_info_from_cpld(int32_t addr, int read_bytes, uint8_t *val) +{ + int i, rv; + + for (i = 0; i < read_bytes; i++) { + rv = dfd_ko_cpld_read(addr, &(val[i])); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "read info[addr=0x%x read_bytes=%d] from cpld fail, reading_byte=%d rv=%d\n", + addr, read_bytes, i, rv); + return rv; + } + addr++; + } + + return read_bytes; +} + +static int dfd_write_info_to_cpld(int32_t addr, int write_bytes, uint8_t *val, uint8_t bit_mask) +{ + int rv; + uint8_t val_tmp; + + if (bit_mask != 0xff) { + rv = dfd_ko_cpld_read(addr, &val_tmp); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "read original info[addr=0x%x] from cpld fail, rv=%d\n", addr, rv); + return -1; + } + + val_tmp = (val_tmp & (~bit_mask)) | (val[0] & bit_mask); + } else { + val_tmp = val[0]; + } + + rv = dfd_ko_cpld_write(addr, val_tmp); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "write info[addr=0x%x val=0x%x] to cpld fail, rv=%d\n", addr, val_tmp, rv); + return -1; + } + + return 0; +} + +static int dfd_read_info(info_src_t src, char *fpath, int32_t addr, int read_bytes, uint8_t *val) +{ + int rv = 0; + + switch (src) { + case INFO_SRC_CPLD: + rv = dfd_read_info_from_cpld(addr, read_bytes, val); + break; + case INFO_SRC_FPGA: + rv = -1; + DBG_DEBUG(DBG_ERROR, "not support read info from fpga\n"); + break; + case INFO_SRC_OTHER_I2C: + rv = -1; + DBG_DEBUG(DBG_ERROR, "not support read info from other i2c\n"); + break; + case INFO_SRC_FILE: + rv = dfd_ko_read_file(fpath, addr, val, read_bytes); + break; + default: + rv = -1; + DBG_DEBUG(DBG_ERROR, "info src[%d] error\n", src); + break; + } + + return rv; +} + +static int dfd_write_info(info_src_t src, char *fpath, int32_t addr, int write_bytes, uint8_t *val, uint8_t bit_mask) +{ + int rv = 0; + + switch (src) { + case INFO_SRC_CPLD: + rv = dfd_write_info_to_cpld(addr, write_bytes, val, bit_mask); + break; + case INFO_SRC_FPGA: + rv = -1; + DBG_DEBUG(DBG_ERROR, "not support write info to fpga\n"); + break; + case INFO_SRC_OTHER_I2C: + rv = -1; + DBG_DEBUG(DBG_ERROR, "not support write info to other i2c\n"); + break; + case INFO_SRC_FILE: + rv = -1; + DBG_DEBUG(DBG_ERROR, "not support write info to file\n"); + break; + default: + rv = -1; + DBG_DEBUG(DBG_ERROR, "info src[%d] error\n", src); + break; + } + + return rv; +} + +int dfd_info_get_int(int key, int *ret, info_num_buf_to_value_f pfun) +{ + int i, rv; + int read_bytes, readed_bytes, int_tmp; + uint8_t byte_tmp, val[INFO_INT_MAX_LEN + 1] = {0}; + info_ctrl_t *info_ctrl; + + if (!DFD_CFG_ITEM_IS_INFO_CTRL(DFD_CFG_ITEM_ID(key)) || (ret == NULL)) { + DBG_DEBUG(DBG_ERROR, "input arguments error, key=0x%08x\n", key); + return -DFD_RV_INDEX_INVALID; + } + + info_ctrl = dfd_ko_cfg_get_item(key); + if (info_ctrl == NULL) { + DBG_DEBUG(DBG_WARN, "get info ctrl fail, key=0x%08x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + + if (info_ctrl->mode == INFO_CTRL_MODE_CONS) { + *ret = info_ctrl->int_cons; + return DFD_RV_OK; + } else if (info_ctrl->mode == INFO_CTRL_MODE_TLV) { + return INFO_CTRL_MODE_TLV; + } + + if (IS_INFO_FRMT_BIT(info_ctrl->frmt)) { + + if (!INFO_BIT_OFFSET_VALID(info_ctrl->bit_offset)) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] bit_offsest[%d] invalid\n", + key, info_ctrl->bit_offset); + return -DFD_RV_TYPE_ERR; + } + + read_bytes = 1; + } else if (IS_INFO_FRMT_BYTE(info_ctrl->frmt) || IS_INFO_FRMT_NUM_STR(info_ctrl->frmt) + || IS_INFO_FRMT_NUM_BUF(info_ctrl->frmt)) { + + if (!INFO_INT_LEN_VALAID(info_ctrl->len)) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] len[%d] invalid\n", key, info_ctrl->len); + return -DFD_RV_TYPE_ERR; + } + read_bytes = info_ctrl->len; + } else { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] info format[%d] error\n", key, info_ctrl->frmt); + return -DFD_RV_TYPE_ERR; + } + + readed_bytes = dfd_read_info(info_ctrl->src, info_ctrl->fpath, info_ctrl->addr, read_bytes, &(val[0])); + if (readed_bytes <= 0) { + DBG_DEBUG(DBG_ERROR, "read int info[key=0x%08x src=%s frmt=%s fpath=%s addr=0x%x read_bytes=%d] fail, rv=%d\n", + key, g_info_src_str[info_ctrl->src], g_info_frmt_str[info_ctrl->frmt], info_ctrl->fpath, + info_ctrl->addr, read_bytes, readed_bytes); + return -DFD_RV_DEV_FAIL; + } + + if (IS_INFO_FRMT_BIT(info_ctrl->frmt)) { + + if (info_ctrl->pola == INFO_POLA_NEGA) { + val[0] = ~val[0]; + } + + byte_tmp = (val[0] >> info_ctrl->bit_offset) & (~(0xff << info_ctrl->len)); + + if (pfun) { + rv = pfun(&byte_tmp, sizeof(byte_tmp), &int_tmp); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] bit process fail, rv=%d\n", key, rv); + return rv; + } + } else { + int_tmp = (int)byte_tmp; + } + } else if (IS_INFO_FRMT_BYTE(info_ctrl->frmt)) { + + int_tmp = 0; + for (i = 0; i < info_ctrl->len; i++) { + if (info_ctrl->pola == INFO_POLA_NEGA) { + int_tmp |= val[info_ctrl->len - i - 1]; + } else { + int_tmp |= val[i]; + } + + if (i != (info_ctrl->len - 1)) { + int_tmp <<= 8; + } + } + } else if (IS_INFO_FRMT_NUM_STR(info_ctrl->frmt)) { + + val[readed_bytes] = '\0'; + int_tmp = simple_strtol((char *)(&(val[0])), NULL, 10); + } else { + if (pfun == NULL) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] number buf process function is null\n", key); + return -DFD_RV_INDEX_INVALID; + } + + rv = pfun(val, readed_bytes, &int_tmp); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] number buf process fail, rv=%d\n", key, rv); + return rv; + } + } + + *ret = int_tmp; + DBG_DEBUG(DBG_VERBOSE, "read int info[key=0x%08x src=%s frmt=%s pola=%s fpath=%s addr=0x%x len=%d bit_offset=%d] success, ret=%d\n", + key, g_info_src_str[info_ctrl->src], g_info_frmt_str[info_ctrl->frmt], g_info_pola_str[info_ctrl->pola], + info_ctrl->fpath, info_ctrl->addr, info_ctrl->len, info_ctrl->bit_offset, *ret); + return DFD_RV_OK; +} + +int dfd_info_get_buf(int key, uint8_t *buf, int buf_len, info_buf_to_buf_f pfun) +{ + int rv; + int read_bytes, buf_real_len; + uint8_t buf_tmp[INFO_BUF_MAX_LEN]; + info_ctrl_t *info_ctrl; + + if (!DFD_CFG_ITEM_IS_INFO_CTRL(DFD_CFG_ITEM_ID(key)) || (buf == NULL)) { + DBG_DEBUG(DBG_ERROR, "input arguments error, key=0x%08x\n", key); + return -DFD_RV_INDEX_INVALID; + } + + info_ctrl = dfd_ko_cfg_get_item(key); + if (info_ctrl == NULL) { + DBG_DEBUG(DBG_WARN, "get info ctrl fail, key=0x%08x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + + if (info_ctrl->mode != INFO_CTRL_MODE_CFG) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] mode[%d] invalid\n", key, info_ctrl->mode); + return -DFD_RV_TYPE_ERR; + } + + if (!IS_INFO_FRMT_BUF(info_ctrl->frmt) || !INFO_BUF_LEN_VALAID(info_ctrl->len) + || (buf_len <= info_ctrl->len)) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] format=%d or len=%d invlaid, buf_len=%d\n", + key, info_ctrl->frmt, info_ctrl->len, buf_len); + return -DFD_RV_TYPE_ERR; + } + + read_bytes = dfd_read_info(info_ctrl->src, info_ctrl->fpath, info_ctrl->addr, info_ctrl->len, buf_tmp); + if (read_bytes <= 0) { + DBG_DEBUG(DBG_ERROR, "read buf info[key=0x%08x src=%s frmt=%s fpath=%s addr=0x%x len=%d] fail, rv=%d\n", + key, g_info_src_str[info_ctrl->src], g_info_frmt_str[info_ctrl->frmt], info_ctrl->fpath, + info_ctrl->addr, info_ctrl->len, read_bytes); + return -DFD_RV_DEV_FAIL; + } + + if (pfun) { + buf_real_len = buf_len; + rv = pfun(buf_tmp, read_bytes, buf, &buf_real_len); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] buf process fail, rv=%d\n", key, rv); + return -DFD_RV_DEV_NOTSUPPORT; + } + } else { + buf_real_len = read_bytes; + memcpy(buf, buf_tmp, read_bytes); + } + + return buf_real_len; +} + +static int dfd_2key_info_get_buf(info_ctrl_t *info_ctrl, uint8_t *buf, int buf_len, info_hwmon_buf_f pfun) +{ + int rv; + int read_bytes, buf_real_len; + uint8_t buf_tmp[INFO_BUF_MAX_LEN]; + char temp_fpath[INFO_FPATH_MAX_LEN]; + + if (!IS_INFO_FRMT_BUF(info_ctrl->frmt) || !INFO_BUF_LEN_VALAID(info_ctrl->len) + || (buf_len <= info_ctrl->len)) { + DBG_DEBUG(DBG_ERROR, "key_path info ctrl format=%d or len=%d invlaid, buf_len=%d\n", + info_ctrl->frmt, info_ctrl->len, buf_len); + return -DFD_RV_TYPE_ERR; + } + + memset(buf_tmp, 0 , sizeof(buf_tmp)); + rv = kfile_iterate_dir(info_ctrl->fpath, DFD_HWMON_NAME, buf_tmp, INFO_BUF_MAX_LEN); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "dir patch:%s ,can find name %s dir \n", + info_ctrl->fpath, DFD_HWMON_NAME); + return -DFD_RV_NO_NODE; + } + memset(temp_fpath, 0 , sizeof(temp_fpath)); + snprintf(temp_fpath, sizeof(temp_fpath), "%s%s/%s", + info_ctrl->fpath, buf_tmp, info_ctrl->str_cons); + DBG_DEBUG(DBG_VERBOSE, "match ok path = %s \n", temp_fpath); + + memset(buf_tmp, 0, sizeof(buf_tmp)); + + read_bytes = dfd_read_info(info_ctrl->src, temp_fpath, info_ctrl->addr, info_ctrl->len, buf_tmp); + if (read_bytes <= 0) { + DBG_DEBUG(DBG_ERROR, "read buf info[src=%s frmt=%s fpath=%s addr=0x%x len=%d] fail, rv=%d\n", + g_info_src_str[info_ctrl->src], g_info_src_str[info_ctrl->frmt], temp_fpath, + info_ctrl->addr, info_ctrl->len, read_bytes); + return -DFD_RV_DEV_FAIL; + } + + if (pfun) { + buf_real_len = buf_len; + rv = pfun(buf_tmp, read_bytes, buf, &buf_real_len, info_ctrl); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "info ctrl buf process fail, rv=%d\n", rv); + return -DFD_RV_DEV_NOTSUPPORT; + } + } else { + buf_real_len = read_bytes; + memcpy(buf, buf_tmp, buf_real_len); + } + return buf_real_len; +} + +int dfd_info_set_int(int key, int val) +{ + int rv; + int write_bytes; + uint8_t byte_tmp, bit_mask; + info_ctrl_t *info_ctrl; + + if (!DFD_CFG_ITEM_IS_INFO_CTRL(DFD_CFG_ITEM_ID(key))) { + DBG_DEBUG(DBG_ERROR, "input arguments error, key=0x%08x\n", key); + return -DFD_RV_INDEX_INVALID; + } + + info_ctrl = dfd_ko_cfg_get_item(key); + if (info_ctrl == NULL) { + DBG_DEBUG(DBG_WARN, "get info ctrl fail, key=0x%08x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + + if (info_ctrl->mode != INFO_CTRL_MODE_CFG) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] mode[%d] warnning\n", key, info_ctrl->mode); + return -DFD_RV_TYPE_ERR; + } + + if (IS_INFO_FRMT_BIT(info_ctrl->frmt)) { + + if (!INFO_BIT_OFFSET_VALID(info_ctrl->bit_offset)) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] bit_offsest[%d] invalid\n", + key, info_ctrl->bit_offset); + return -DFD_RV_TYPE_ERR; + } + + write_bytes = 1; + + byte_tmp = (uint8_t)(val & 0xff); + byte_tmp <<= info_ctrl->bit_offset; + if (info_ctrl->pola == INFO_POLA_NEGA) { + byte_tmp = ~byte_tmp; + } + + bit_mask = (~(0xff << info_ctrl->len)) << info_ctrl->bit_offset; + } else if (IS_INFO_FRMT_BYTE(info_ctrl->frmt)) { + + if (!INFO_INT_LEN_VALAID(info_ctrl->len)) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] len[%d] invalid\n", key, info_ctrl->len); + return -DFD_RV_TYPE_ERR; + } + + write_bytes = 1; + + byte_tmp = (uint8_t)(val & 0xff); + + bit_mask = 0xff; + } else if (IS_INFO_FRMT_NUM_STR(info_ctrl->frmt)) { + + DBG_DEBUG(DBG_ERROR, "not support str int set\n"); + return -1; + } else if (IS_INFO_FRMT_NUM_BUF(info_ctrl->frmt)) { + + if (!INFO_INT_LEN_VALAID(info_ctrl->len)) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] len[%d] invalid\n", key, info_ctrl->len); + return -DFD_RV_TYPE_ERR; + } + + write_bytes = 1; + + byte_tmp = (uint8_t)(val & 0xff); + + bit_mask = 0xff; + } else { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] format[%d] error\n", key, info_ctrl->frmt); + return -DFD_RV_TYPE_ERR; + } + + rv = dfd_write_info(info_ctrl->src, info_ctrl->fpath, info_ctrl->addr, write_bytes, + &byte_tmp, bit_mask); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "write int info[src=%s frmt=%s fpath=%s addr=0x%x len=%d val=%d] fail, rv=%d\n", + g_info_src_str[info_ctrl->src], g_info_frmt_str[info_ctrl->frmt], info_ctrl->fpath, + info_ctrl->addr, info_ctrl->len, val, rv); + return -DFD_RV_DEV_FAIL; + } + + DBG_DEBUG(DBG_VERBOSE, "write int info[src=%s frmt=%s pola=%s fpath=%s addr=0x%x len=%d bit_offset=%d val=%d] success\n", + g_info_src_str[info_ctrl->src], g_info_frmt_str[info_ctrl->frmt], g_info_pola_str[info_ctrl->pola], + info_ctrl->fpath, info_ctrl->addr, info_ctrl->len, info_ctrl->bit_offset, val); + return DFD_RV_OK; +} + +static int dfd_info_get_cpld_voltage(int key, int *value) +{ + int rv, addr_tmp; + int vol_ref_tmp, vol_ref; + int vol_curr_tmp, vol_curr; + info_ctrl_t *info_ctrl; + + info_ctrl = dfd_ko_cfg_get_item(key); + if (info_ctrl == NULL) { + DBG_DEBUG(DBG_WARN, "get info ctrl fail, key=0x%08x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + + rv = dfd_info_get_int(key, &vol_curr_tmp, NULL); + if(rv < 0) { + DBG_DEBUG(DBG_ERROR, "get cpld current voltage error, addr:0x%x, rv =%d\n", info_ctrl->addr, rv); + return rv; + } + vol_curr_tmp = DFD_GET_CPLD_VOLATGE_CODE_VALUE(vol_curr_tmp); + if(info_ctrl->addr == info_ctrl->int_extra1) { + + vol_curr = DFD_GET_CPLD_VOLATGE_REAL_VALUE(vol_curr_tmp, info_ctrl->int_extra2); + } else { + + addr_tmp = info_ctrl->addr; + info_ctrl->addr = info_ctrl->int_extra1; + rv = dfd_info_get_int(key, &vol_ref_tmp, NULL); + info_ctrl->addr = addr_tmp; + if(rv < 0) { + DBG_DEBUG(DBG_ERROR, "get cpld reference voltage error, addr:0x%x rv:%d\n", info_ctrl->addr, rv); + return rv; + } + vol_ref = DFD_GET_CPLD_VOLATGE_CODE_VALUE(vol_ref_tmp); + vol_curr = (vol_curr_tmp * info_ctrl->int_extra2) / vol_ref; + } + *value = vol_curr; + return DFD_RV_OK; +} + +static int dfd_info_get_sensor_value(int key, uint8_t *buf, int buf_len, info_hwmon_buf_f pfun) +{ + int rv, buf_real_len; + int value; + uint8_t buf_tmp[INFO_BUF_MAX_LEN]; + info_ctrl_t *info_ctrl; + + info_ctrl = dfd_ko_cfg_get_item(key); + if (info_ctrl == NULL) { + DBG_DEBUG(DBG_ERROR, "get info ctrl fail, key=0x%08x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + + if ( DFD_CFG_ITEM_ID(key) == DFD_CFG_ITEM_HWMON_IN && info_ctrl->src == INFO_SRC_CPLD) { + + rv = dfd_info_get_cpld_voltage(key, &value); + if(rv < 0) { + DBG_DEBUG(DBG_ERROR, "get cpld voltage failed.key=0x%08x, rv:%d\n", key, rv); + return -DFD_RV_DEV_NOTSUPPORT; + } + DBG_DEBUG(DBG_VERBOSE, "get cpld voltage ok, value:%d\n", value); + memset(buf_tmp, 0 ,sizeof(buf_tmp)); + snprintf(buf_tmp, sizeof(buf_tmp), "%d\n", value); + buf_real_len = strlen(buf_tmp); + if(buf_len <= buf_real_len) { + DBG_DEBUG(DBG_ERROR, "length not enough.buf_len:%d,need length:%d\n", buf_len, buf_real_len); + return -DFD_RV_DEV_FAIL; + } + if (pfun) { + buf_real_len = buf_len; + rv = pfun(buf_tmp, strlen(buf_tmp), buf, &buf_real_len, info_ctrl); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "deal date error.org value:%s, buf_len:%d, rv=%d\n", + buf_tmp, buf_len, rv); + return -DFD_RV_DEV_NOTSUPPORT; + } + } else { + memcpy(buf, buf_tmp, buf_real_len); + } + return buf_real_len; + } + + DBG_DEBUG(DBG_ERROR, "not support mode. key:0x%08x\n", key); + return -DFD_RV_MODE_NOTSUPPORT; +} + +int dfd_info_get_sensor(uint32_t key, char *buf, int buf_len, info_hwmon_buf_f pfun) +{ + info_ctrl_t *key_info_ctrl; + int rv; + + if (!DFD_CFG_ITEM_IS_INFO_CTRL(DFD_CFG_ITEM_ID(key)) || + (buf == NULL) || buf_len <= 0) { + DBG_DEBUG(DBG_ERROR, "input arguments error, key_path=0x%08x, buf_len:%d.\n", + key, buf_len); + return -DFD_RV_INVALID_VALUE; + } + + key_info_ctrl = dfd_ko_cfg_get_item(key); + if (key_info_ctrl == NULL) { + DBG_DEBUG(DBG_ERROR, "key_path info error, key=0x%08x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + memset(buf, 0 , buf_len); + + if (key_info_ctrl->mode == INFO_CTRL_MODE_SRT_CONS) { + snprintf(buf, buf_len, "%s\n", key_info_ctrl->str_cons); + DBG_DEBUG(DBG_VERBOSE, "get sensor value through string config, key=0x%08x, value:%s\n", key, buf); + return strlen(buf); + } + + if (key_info_ctrl->mode == INFO_CTRL_MODE_CFG && key_info_ctrl->src == INFO_SRC_FILE) { + DBG_DEBUG(DBG_VERBOSE, "get sensor value through hwmon, key:0x%08x\n", key); + rv = dfd_2key_info_get_buf(key_info_ctrl, buf, buf_len, pfun); + if (rv < 0) { + DBG_DEBUG(DBG_VERBOSE, "get sensor value through hwmon failed, key:0x%08x, rv:%d\n", key, rv); + } + return rv; + } + rv = dfd_info_get_sensor_value(key, buf, buf_len, pfun); + if( rv < 0) { + DBG_DEBUG(DBG_ERROR, "get sensor value failed, key=0x%08x, rv:%d.\n", key, rv); + } + return rv; +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_cfg_listnode.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_cfg_listnode.c new file mode 100644 index 000000000000..056d98ffdc42 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_cfg_listnode.c @@ -0,0 +1,85 @@ +/* + * Copyright(C) 2001-2015 Ruijie Network. All rights reserved. + */ + +#include +#include + +#include "../include/dfd_cfg_listnode.h" + +void *lnode_find_node(lnode_root_t *root, int key) +{ + lnode_node_t *lnode; + + if (root == NULL){ + return NULL; + } + + list_for_each_entry(lnode, &(root->root), lst) { + if (lnode->key == key) { + return lnode->data; + } + } + + return NULL; +} + +int lnode_insert_node(lnode_root_t *root, int key, void *data) +{ + lnode_node_t *lnode; + void *data_tmp; + + if ((root == NULL) || (data == NULL)) { + return LNODE_RV_INPUT_ERR; + } + + data_tmp = lnode_find_node(root, key); + if (data_tmp != NULL) { + return LNODE_RV_NODE_EXIST; + } + + lnode = kmalloc(sizeof(lnode_node_t), GFP_KERNEL); + if (lnode == NULL) { + return LNODE_RV_NOMEM; + } + + lnode->key = key; + lnode->data = data; + list_add_tail(&(lnode->lst), &(root->root)); + + return LNODE_RV_OK; +} + +int lnode_init_root(lnode_root_t *root) +{ + if (root == NULL) { + return LNODE_RV_INPUT_ERR; + } + + INIT_LIST_HEAD(&(root->root)); + + return LNODE_RV_OK; +} + +void lnode_free_list(lnode_root_t *root) +{ + lnode_node_t *lnode, *lnode_next; + + if (root == NULL){ + return ; + } + + list_for_each_entry_safe(lnode, lnode_next, &(root->root), lst) { + if ( lnode->data ) { + kfree(lnode->data); + lnode->data = NULL; + lnode->key = 0; + } + list_del(&lnode->lst); + kfree(lnode); + lnode = NULL; + } + + return ; + +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_frueeprom.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_frueeprom.c new file mode 100644 index 000000000000..b0d885218907 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_frueeprom.c @@ -0,0 +1,496 @@ +/* + * Copyright(C) 2001-2012 Ruijie Network. All rights reserved. + */ + +#include +#include +#include +#include + +#include "../include/dfd_frueeprom.h" +#include "../include/dfd_cfg_adapter.h" +#include "../include/dfd_module.h" +#include "../../rg_dev_sysfs/include/rg_sysfs_common.h" + +int g_dfd_fru_dbg_level = 0; +module_param(g_dfd_fru_dbg_level, int, S_IRUGO | S_IWUSR); + +/** + * Takes the pointer to stream of bytes and length + * and returns the 8 bit checksum + * This algo is per IPMI V2.0 spec + */ +static unsigned char ipmi_calculate_crc(const unsigned char *data, size_t len) +{ + char crc = 0; + size_t byte = 0; + + for(byte = 0; byte < len; byte++) + { + crc += *data++; + } + + return(-crc); +} + +/* Validates the data for crc and mandatory fields */ +static int ipmi_verify_fru_data(const uint8_t *data, const size_t len) +{ + uint8_t checksum = 0; + int rc = -DFD_RV_TYPE_ERR; + + /* Validate for first byte to always have a value of [1] */ + if(data[0] != IPMI_FRU_HDR_BYTE_ZERO) + { + DBG_FRU_DEBUG(DBG_ERROR, "Invalid entry:[%d] in byte-0\n",data[0]); + return rc; + } else { + DBG_FRU_DEBUG(DBG_VERBOSE, "SUCCESS: Validated [0x%X] in entry_1 of fru_data\n",data[0]); + } + + /* See if the calculated CRC matches with the embedded one. + * CRC to be calculated on all except the last one that is CRC itself.*/ + checksum = ipmi_calculate_crc(data, len - 1); + if(checksum != data[len-1]) + { + DBG_FRU_DEBUG(DBG_ERROR, "Checksum mismatch." + " Calculated:[0x%X], Embedded:[0x%X]\n", + checksum, data[len - 1]); + return rc; + } else { + DBG_FRU_DEBUG(DBG_VERBOSE, "SUCCESS: Checksum matches:[0x%X]\n",checksum); + } + + return 0; +} + +/* private method to parse type/length */ +static int ipmi_parse_type_length (const void *areabuf, + unsigned int areabuflen, + unsigned int current_area_offset, + uint8_t *number_of_data_bytes, + ipmi_fru_field_t *field) +{ + const uint8_t *areabufptr = (const uint8_t*) areabuf; + uint8_t type_length; + uint8_t type_code; + + type_length = areabufptr[current_area_offset]; + + /* ipmi workaround + * + * dell p weredge r610 + * + * my reading of the fru spec is that all non-custom fields are + * required to be listed by the vendor. however, on this + * motherboard, some areas list this, indicating that there is + * no more data to be parsed. so now, for "required" fields, i + * check to see if the type-length field is a sentinel before + * calling this function. + */ + + type_code = (type_length & IPMI_FRU_TYPE_LENGTH_TYPE_CODE_MASK) >> IPMI_FRU_TYPE_LENGTH_TYPE_CODE_SHIFT; + (*number_of_data_bytes) = type_length & IPMI_FRU_TYPE_LENGTH_NUMBER_OF_DATA_BYTES_MASK; + + /* special case: this shouldn't be a length of 0x01 (see type/length + * byte format in fru information storage definition). + */ + DBG_FRU_DEBUG(DBG_VERBOSE, "areabuflen:%d, current_area_offset:0x%x, type_code:0x%x, number_of_data_bytes:%d\n", + areabuflen, current_area_offset, type_code, *number_of_data_bytes ); + if (type_code == IPMI_FRU_TYPE_LENGTH_TYPE_CODE_LANGUAGE_CODE + && (*number_of_data_bytes) == 0x01) { + DBG_FRU_DEBUG(DBG_ERROR, "fru type length error.value:0x%x\n", type_length); + return (-1); + } + + if ((current_area_offset + 1 + (*number_of_data_bytes)) > areabuflen) { + DBG_FRU_DEBUG(DBG_ERROR, "buf length error. current_area_offset:0x%x, need length:%d, total length:0x%x\n", + current_area_offset, *number_of_data_bytes, areabuflen ); + return (-1); + } + + if (field) { + memset (field->type_length_field, '\0', IPMI_FRU_AREA_TYPE_LENGTH_FIELD_MAX); + memcpy (field->type_length_field, &areabufptr[current_area_offset + 1], *number_of_data_bytes); + DBG_FRU_DEBUG(DBG_VERBOSE, "fru parse ok. value:%s\n", field->type_length_field); + field->type_length_field_length = *number_of_data_bytes; + } + + return (0); +} + +static int ipmi_fru_product_info_area(const void *areabuf, + unsigned int areabuflen, ipmi_product_info_t *ipmi_product_info) +{ + const uint8_t *areabufptr = (const uint8_t*) areabuf; + unsigned int area_offset = 2; + uint8_t number_of_data_bytes; + int rv; + ipmi_fru_field_t **ipmi_fru_field_point; + int ipmi_fru_field_len, i; + + if (!areabuf || !areabuflen || !ipmi_product_info) { + DBG_FRU_DEBUG(DBG_ERROR, "Invalid Parameter.\n"); + return -DFD_RV_INVALID_VALUE; + } + + /* Verify the crc and size */ + rv = ipmi_verify_fru_data(areabuf, areabuflen); + if(rv < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Failed to validate fru product info data\n"); + return rv; + } + + ipmi_fru_field_len = (sizeof(ipmi_product_info_t) - sizeof(uint8_t *)) /(sizeof(ipmi_fru_field_t *)); + + if (ipmi_product_info->language_code) { + (*ipmi_product_info->language_code) = areabufptr[area_offset]; + } + area_offset++; + ipmi_fru_field_point = (ipmi_fru_field_t **)((uint8_t *)ipmi_product_info + sizeof(uint8_t *)); + for(i = 0; i < ipmi_fru_field_len; i++) { + if (*ipmi_fru_field_point) { + memset(*ipmi_fru_field_point, '\0', sizeof(ipmi_fru_field_t)); + } + + if ((areabufptr[area_offset] == IPMI_FRU_SENTINEL_VALUE) || (area_offset == areabuflen - 1)) { + rv = 0; + break; + } + + rv = ipmi_parse_type_length(areabufptr, areabuflen, area_offset, &number_of_data_bytes, *ipmi_fru_field_point); + if (rv < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "[%d] _parse_type_length area_offset[%d] rv=%d \n", i, area_offset, rv); + break; + } + + area_offset += 1; /* type/length byte */ + area_offset += number_of_data_bytes; + ipmi_fru_field_point++; + } + + return (rv); +} + +static int ipmi_fru_board_info_area(const void *areabuf, + unsigned int areabuflen, ipmi_board_info_t *ipmi_board_info) +{ + const uint8_t *areabufptr = (const uint8_t*) areabuf; + unsigned int area_offset = 2; + uint8_t number_of_data_bytes; + int rv; + ipmi_fru_field_t **ipmi_fru_field_point; + int ipmi_fru_field_len, i; + + if (!areabuf || !areabuflen || !ipmi_board_info) { + DBG_FRU_DEBUG(DBG_ERROR, "Invalid Parameter.\n"); + return -DFD_RV_INVALID_VALUE; + } + + /* Verify the crc and size */ + rv = ipmi_verify_fru_data(areabuf, areabuflen); + if(rv < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Failed to validate fru product info data\n"); + return rv; + } + + ipmi_fru_field_len = (sizeof(ipmi_board_info_t) - sizeof(uint8_t *) - sizeof(uint8_t *)) /(sizeof(ipmi_fru_field_t *)); + + if (ipmi_board_info->language_code) { + (*ipmi_board_info->language_code) = areabufptr[area_offset]; + } + area_offset++; + + if (ipmi_board_info->mfg_time) { + memcpy(ipmi_board_info->mfg_time, &areabufptr[area_offset], IPMI_FRU_BOARD_INFO_MFG_TIME_LENGTH); + } + area_offset += IPMI_FRU_BOARD_INFO_MFG_TIME_LENGTH; + ipmi_fru_field_point = (ipmi_fru_field_t **)((uint8_t *)ipmi_board_info + sizeof(uint8_t *) + sizeof(uint8_t *)); + for(i = 0; i < ipmi_fru_field_len; i++) { + if (*ipmi_fru_field_point) { + memset(*ipmi_fru_field_point, '\0', sizeof(ipmi_fru_field_t)); + } + + if ((areabufptr[area_offset] == IPMI_FRU_SENTINEL_VALUE) || (area_offset == areabuflen - 1)) { + rv = 0; + break; + } + + rv = ipmi_parse_type_length(areabufptr, areabuflen, area_offset, &number_of_data_bytes, *ipmi_fru_field_point); + if (rv < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "[%d] _parse_type_length area_offset[%d] rv=%d \n", i, area_offset, rv); + break; + } + + area_offset += 1; /* type/length byte */ + area_offset += number_of_data_bytes; + ipmi_fru_field_point++; + } + + return (rv); +} + +/** + * Validates the fru data per ipmi common header constructs. + * Returns with updated common_hdr and also file_size + */ +static int ipmi_validate_common_hdr(const uint8_t *fru_data, const size_t data_len) +{ + int rc = -1; + + uint8_t common_hdr[sizeof(fru_common_header_t)] = {0}; + if(data_len >= sizeof(common_hdr)) + { + memcpy(common_hdr, fru_data, sizeof(common_hdr)); + } + else + { + DBG_FRU_DEBUG(DBG_ERROR, "Incomplete fru data file. Size:[%zd]\n", data_len); + return rc; + } + + /* Verify the crc and size */ + rc = ipmi_verify_fru_data(common_hdr, sizeof(common_hdr)); + if(rc < 0) + { + DBG_FRU_DEBUG(DBG_ERROR, "Failed to validate common header\n"); + return rc; + } + + return 0; +} + +static int dfd_get_frue2prom_info(int bus, int dev_addr, fru_common_header_t *info) +{ + int ret; + uint8_t fru_common_header_info[sizeof(fru_common_header_t)]; + + if (info == NULL) { + DBG_FRU_DEBUG(DBG_ERROR, "Invalid parameter!\n"); + return -DFD_RV_INVALID_VALUE; + } + + ret = dfd_ko_i2c_read(bus, dev_addr, 0, (uint8_t *)info, sizeof(fru_common_header_t)); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Read eeprom head info error(bus: %d, addr: 0x%02x).\n", bus, dev_addr); + return ret; + } + + memcpy(fru_common_header_info, (uint8_t *)info, sizeof(fru_common_header_t)); + + if (ipmi_validate_common_hdr(fru_common_header_info, sizeof(fru_common_header_t)) != 0) { + return -DFD_RV_TYPE_ERR; + } + + return DFD_RV_OK; +} + +static int dfd_set_fru_product_info(ipmi_product_info_t *ipmi_product_info, ipmi_fru_field_t *vpd_info, int type) +{ + int ret; + ret = DFD_RV_OK; + if (ipmi_product_info == NULL || vpd_info == NULL) { + DBG_FRU_DEBUG(DBG_ERROR, "Invalid parameter!\n"); + return -DFD_RV_INVALID_VALUE; + } + + memset((uint8_t *)ipmi_product_info, 0, sizeof(ipmi_product_info_t)); + switch(type) { + case DFD_DEV_INFO_TYPE_SN: + ipmi_product_info->product_serial_number = vpd_info; + break; + case DFD_DEV_INFO_TYPE_NAME: + ipmi_product_info->product_name = vpd_info; + break; + case DFD_DEV_INFO_TYPE_DEV_TYPE: + ipmi_product_info->product_type_fields = vpd_info; + break; + case DFD_DEV_INFO_TYPE_HW_INFO: + ipmi_product_info->product_version = vpd_info; + break; + case DFD_DEV_INFO_TYPE_PART_NAME: + ipmi_product_info->product_part_model_number = vpd_info; + break; + case DFD_DEV_INFO_TYPE_PART_NUMBER: + ipmi_product_info->product_part_model_number = vpd_info; + break; + default: + ret = -1; + break; + } + + return ret; +} + +static int dfd_set_fru_board_info(ipmi_board_info_t *ipmi_board_info, ipmi_fru_field_t *vpd_info, int type) +{ + int ret; + ret = DFD_RV_OK; + if (ipmi_board_info == NULL || vpd_info == NULL) { + DBG_FRU_DEBUG(DBG_ERROR, "Invalid parameter!\n"); + return -DFD_RV_INVALID_VALUE; + } + + memset((uint8_t *)ipmi_board_info, 0, sizeof(ipmi_board_info_t)); + switch(type) { + case DFD_DEV_INFO_TYPE_SN: + ipmi_board_info->board_serial_number = vpd_info; + break; + case DFD_DEV_INFO_TYPE_NAME: + ipmi_board_info->board_product_name = vpd_info; + break; + case DFD_DEV_INFO_TYPE_HW_INFO: + ipmi_board_info->board_custom_fields = vpd_info; + break; + case DFD_DEV_INFO_TYPE_PART_NUMBER: + ipmi_board_info->board_part_number = vpd_info; + break; + default: + ret = -1; + break; + } + + return ret; +} + +int dfd_get_fru_data(int bus, int dev_addr, int type, uint8_t *buf, uint32_t buf_len) +{ + fru_common_header_t info; + uint8_t *fru_data; + int ret; + uint8_t fru_len; + ipmi_product_info_t ipmi_product_info; + ipmi_fru_field_t vpd_info; + int product_offset; + int fru_len_tmp; + + if (buf == NULL || buf_len <= 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Invalid parameter!\n"); + return -DFD_RV_INVALID_VALUE; + } + + DBG_FRU_DEBUG(DBG_VERBOSE, "Read fru eeprom (bus: %d, addr: 0x%02x, type:%d, buf: %p, len: %d).\n", + bus, dev_addr, type, buf, buf_len); + + ret = dfd_get_frue2prom_info(bus, dev_addr, &info); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Read eeprom info head error(bus: %d, addr: 0x%02x, buf: %p, len: %d).\n", + bus, dev_addr, buf, buf_len); + return ret; + } + + product_offset = info.product_offset * IPMI_EIGHT_BYTES; + ret = dfd_ko_i2c_read(bus, dev_addr, product_offset + 1, &fru_len, 1); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "read eeprom info product_offset(bus: %d, addr: 0x%02x, product offset:%d).\n", + bus, dev_addr, info.product_offset); + return -DFD_RV_DEV_FAIL; + } + + fru_len_tmp = fru_len * IPMI_EIGHT_BYTES; + fru_data = (uint8_t *)kmalloc(sizeof(uint8_t) * fru_len_tmp, GFP_KERNEL); + if (fru_data == NULL) { + DBG_FRU_DEBUG(DBG_ERROR, "Allocate buffer(len:%d) error!\n", fru_len_tmp); + return -DFD_RV_NO_MEMORY; + } + + ret = dfd_ko_i2c_read(bus, dev_addr, product_offset, fru_data, fru_len_tmp); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Get FRU data error.\n"); + kfree(fru_data); + return ret; + } + + memset((uint8_t *)&vpd_info, 0, sizeof(ipmi_fru_field_t)); + ret = dfd_set_fru_product_info(&ipmi_product_info, &vpd_info, type); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Not support to get info: %d.\n", type); + kfree(fru_data); + return ret; + } + + ret = ipmi_fru_product_info_area(fru_data, fru_len_tmp, &ipmi_product_info); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "analysis FRU product info error.\n"); + kfree(fru_data); + return ret; + } + + kfree(fru_data); + + buf_len = buf_len < vpd_info.type_length_field_length ? buf_len : vpd_info.type_length_field_length; + memcpy(buf, (uint8_t *)&vpd_info, buf_len); + + return DFD_RV_OK; +} + +int dfd_get_fru_board_data(int bus, int dev_addr, int type, uint8_t *buf, uint32_t buf_len) +{ + fru_common_header_t info; + uint8_t *fru_data; + int ret; + uint8_t fru_len; + ipmi_board_info_t ipmi_board_info; + ipmi_fru_field_t vpd_info; + int board_offset; + int fru_len_tmp; + + if (buf == NULL || buf_len <= 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Invalid parameter!\n"); + return -DFD_RV_INVALID_VALUE; + } + + DBG_FRU_DEBUG(DBG_VERBOSE, "Read fru eeprom (bus: %d, addr: 0x%02x, type:%d, buf: %p, len: %d).\n", + bus, dev_addr, type, buf, buf_len); + + ret = dfd_get_frue2prom_info(bus, dev_addr, &info); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Read eeprom info head error(bus: %d, addr: 0x%02x, buf: %p, len: %d).\n", + bus, dev_addr, buf, buf_len); + return ret; + } + + board_offset = info.board_offset * IPMI_EIGHT_BYTES; + ret = dfd_ko_i2c_read(bus, dev_addr, board_offset + 1, &fru_len, 1); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "read eeprom info product_offset(bus: %d, addr: 0x%02x, product offset:%d).\n", + bus, dev_addr, info.board_offset); + return -DFD_RV_DEV_FAIL; + } + + fru_len_tmp = fru_len * IPMI_EIGHT_BYTES; + fru_data = (uint8_t *)kmalloc(sizeof(uint8_t) * fru_len_tmp, GFP_KERNEL); + if (fru_data == NULL) { + DBG_FRU_DEBUG(DBG_ERROR, "Allocate buffer(len:%d) error!\n", fru_len_tmp); + return -DFD_RV_NO_MEMORY; + } + + ret = dfd_ko_i2c_read(bus, dev_addr, board_offset, fru_data, fru_len_tmp); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Get FRU data error.\n"); + kfree(fru_data); + return ret; + } + + memset((uint8_t *)&vpd_info, 0, sizeof(ipmi_fru_field_t)); + ret = dfd_set_fru_board_info(&ipmi_board_info, &vpd_info, type); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Not support to get info: %d.\n", type); + kfree(fru_data); + return ret; + } + + ret = ipmi_fru_board_info_area(fru_data, fru_len_tmp, &ipmi_board_info); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "analysis FRU product info error.\n"); + kfree(fru_data); + return ret; + } + + kfree(fru_data); + + buf_len = buf_len < vpd_info.type_length_field_length ? buf_len : vpd_info.type_length_field_length; + memcpy(buf, (uint8_t *)&vpd_info, buf_len); + + return DFD_RV_OK; +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_tlveeprom.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_tlveeprom.c new file mode 100644 index 000000000000..d5819e5c6714 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_tlveeprom.c @@ -0,0 +1,474 @@ +/* + * Copyright (C) 2003-2014 FreeIPMI Core Team + * + * 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 . + * + */ +/*****************************************************************************\ + * Copyright (C) 2007-2014 Lawrence Livermore National Security, LLC. + * Copyright (C) 2007 The Regents of the University of California. + * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). + * Written by Albert Chu + * UCRL-CODE-232183 + * + * This file is part of Ipmi-fru, a tool used for retrieving + * motherboard field replaceable unit (FRU) information. For details, + * see http://www.llnl.gov/linux/. + * + * Ipmi-fru 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. + * + * Ipmi-fru 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 Ipmi-fru. If not, see . +\*****************************************************************************/ +#include + +#include "../include/dfd_tlveeprom.h" +#include "../include/dfd_module.h" +#include "../../rg_dev_sysfs/include/rg_sysfs_common.h" + +/* using in is_valid_tlvinfo_header */ +static uint32_t g_eeprom_size; + +/* + * List of TLV codes and names. + */ +static const struct tlv_code_desc tlv_code_list[] = { + { TLV_CODE_PRODUCT_NAME , "Product Name"}, + { TLV_CODE_PART_NUMBER , "Part Number"}, + { TLV_CODE_SERIAL_NUMBER , "Serial Number"}, + { TLV_CODE_MAC_BASE , "Base MAC Address"}, + { TLV_CODE_MANUF_DATE , "Manufacture Date"}, + { TLV_CODE_DEVICE_VERSION , "Device Version"}, + { TLV_CODE_LABEL_REVISION , "Label Revision"}, + { TLV_CODE_PLATFORM_NAME , "Platform Name"}, + { TLV_CODE_ONIE_VERSION , "ONIE Version"}, + { TLV_CODE_MAC_SIZE , "MAC Addresses"}, + { TLV_CODE_MANUF_NAME , "Manufacturer"}, + { TLV_CODE_MANUF_COUNTRY , "Country Code"}, + { TLV_CODE_VENDOR_NAME , "Vendor Name"}, + { TLV_CODE_DIAG_VERSION , "Diag Version"}, + { TLV_CODE_SERVICE_TAG , "Service Tag"}, + { TLV_CODE_VENDOR_EXT , "Vendor Extension"}, + { TLV_CODE_CRC_32 , "CRC-32"}, +}; + +#define TLV_CODE_NUM (sizeof(tlv_code_list) / sizeof(tlv_code_list[0])) + +const unsigned long g_crc_table[] = { + 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, + 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, + 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, + 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, + 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, + 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, + 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, + 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, + 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, + 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, + 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, + 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, + 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, + 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, + 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, + 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, + 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, + 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, + 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, + 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, + 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, + 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, + 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, + 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, + 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, + 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, + 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, + 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, + 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, + 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, + 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, + 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d, +}; + +static unsigned long crc32(unsigned long crc, const unsigned char *buf, unsigned len) +{ + unsigned i; + if (len < 1) + return 0xffffffff; + + for (i = 0; i != len; ++i) + { + crc = g_crc_table[(crc ^ buf[i]) & 0xff] ^ (crc >> 8); + } + + crc = crc ^ 0xffffffff; + + return crc; +} + +/* + * is_valid_tlv + * + * Perform basic sanity checks on a TLV field. The TLV is pointed to + * by the parameter provided. + * 1. The type code is not reserved (0x00 or 0xFF) + */ +static inline bool is_valid_tlv(tlvinfo_tlv_t *tlv) +{ + return ((tlv->type != 0x00) && (tlv->type != 0xFF)); +} + +/* + * is_valid_tlvinfo_header + * + * Perform sanity checks on the first 11 bytes of the TlvInfo EEPROM + * data pointed to by the parameter: + * 1. First 8 bytes contain null-terminated ASCII string "TlvInfo" + * 2. Version byte is 1 + * 3. Total length bytes contain value which is less than or equal + * to the allowed maximum (2048-11) + * + */ +static inline bool is_valid_tlvinfo_header(tlvinfo_header_t *hdr) +{ + int max_size = g_eeprom_size; + return((strcmp(hdr->signature, TLV_INFO_ID_STRING) == 0) && + (hdr->version == TLV_INFO_VERSION) && + (be16_to_cpu(hdr->totallen) <= max_size) ); +} + +/* + * decode_tlv_value + * + * Decode a single TLV value into a string. + + * The validity of EEPROM contents and the TLV field have been verified + * prior to calling this function. + */ +static void decode_tlv_value(tlvinfo_tlv_t *tlv, tlv_decode_value_t *decode_value) +{ + int i; + char *value; + uint32_t length; + + value = (char *)decode_value->value; + + switch (tlv->type) { + case TLV_CODE_PRODUCT_NAME: + case TLV_CODE_PART_NUMBER: + case TLV_CODE_SERIAL_NUMBER: + case TLV_CODE_MANUF_DATE: + case TLV_CODE_LABEL_REVISION: + case TLV_CODE_PLATFORM_NAME: + case TLV_CODE_ONIE_VERSION: + case TLV_CODE_MANUF_NAME: + case TLV_CODE_MANUF_COUNTRY: + case TLV_CODE_VENDOR_NAME: + case TLV_CODE_DIAG_VERSION: + case TLV_CODE_SERVICE_TAG: + memcpy(value, tlv->value, tlv->length); + value[tlv->length] = 0; + length = tlv->length; + break; + case TLV_CODE_MAC_BASE: + length = sprintf(value, "%02X:%02X:%02X:%02X:%02X:%02X", + tlv->value[0], tlv->value[1], tlv->value[2], + tlv->value[3], tlv->value[4], tlv->value[5]); + break; + case TLV_CODE_DEVICE_VERSION: + length = sprintf(value, "%u", tlv->value[0]); + break; + case TLV_CODE_MAC_SIZE: + length = sprintf(value, "%u", (tlv->value[0] << 8) | tlv->value[1]); + break; + case TLV_CODE_VENDOR_EXT: + value[0] = 0; + length = 0; + for (i = 0; (i < (TLV_DECODE_VALUE_MAX_LEN/5)) && (i < tlv->length); i++) { + length += sprintf(value, "%s %02X", value, tlv->value[i]); + } + break; + case TLV_CODE_CRC_32: + length = sprintf(value, "0x%02X%02X%02X%02X", tlv->value[0], + tlv->value[1], tlv->value[2], tlv->value[3]); + break; + default: + value[0] = 0; + length = 0; + for (i = 0; (i < (TLV_DECODE_VALUE_MAX_LEN/5)) && (i < tlv->length); i++) { + length += sprintf(value, "%s 0x%02X", value, tlv->value[i]); + } + break; + } + + decode_value->length = length; +} + +/* + * is_checksum_valid + * + * Validate the checksum in the provided TlvInfo EEPROM data. First, + * verify that the TlvInfo header is valid, then make sure the last + * TLV is a CRC-32 TLV. Then calculate the CRC over the EEPROM data + * and compare it to the value stored in the EEPROM CRC-32 TLV. + */ +static bool is_checksum_valid(uint8_t *eeprom) +{ + tlvinfo_header_t *eeprom_hdr; + tlvinfo_tlv_t *eeprom_crc; + unsigned int calc_crc; + unsigned int stored_crc; + + eeprom_hdr = (tlvinfo_header_t *) eeprom; + + /* Is the eeprom header valid? */ + if (!is_valid_tlvinfo_header(eeprom_hdr)) { + return false; + } + + /* Is the last TLV a CRC? */ + eeprom_crc = (tlvinfo_tlv_t *) &eeprom[sizeof(tlvinfo_header_t) + + be16_to_cpu(eeprom_hdr->totallen) - (sizeof(tlvinfo_tlv_t) + 4)]; + if ((eeprom_crc->type != TLV_CODE_CRC_32) || (eeprom_crc->length != 4)) { + return false; + } + + /* Calculate the checksum */ + calc_crc = crc32(0xffffffffL, (const unsigned char *)eeprom, sizeof(tlvinfo_header_t) + + be16_to_cpu(eeprom_hdr->totallen) - 4); + stored_crc = ((eeprom_crc->value[0] << 24) | (eeprom_crc->value[1] << 16) | + (eeprom_crc->value[2] << 8) | eeprom_crc->value[3]); + + return (calc_crc == stored_crc); +} + +/* + * tlvinfo_find_tlv + * + * This function finds the TLV with the supplied code in the EERPOM. + * An offset from the beginning of the EEPROM is returned in the + * eeprom_index parameter if the TLV is found. + */ +static bool tlvinfo_find_tlv(uint8_t *eeprom, uint8_t tcode, int *eeprom_index) +{ + tlvinfo_header_t *eeprom_hdr; + tlvinfo_tlv_t *eeprom_tlv; + int eeprom_end; + + eeprom_hdr = (tlvinfo_header_t *) eeprom; + + /* Search through the TLVs, looking for the first one which matches the + * supplied type code. */ + *eeprom_index = sizeof(tlvinfo_header_t); + eeprom_end = sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen); + while (*eeprom_index < eeprom_end) { + eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[*eeprom_index]; + if (!is_valid_tlv(eeprom_tlv)) { + return false; + } + + if (eeprom_tlv->type == tcode) { + return true; + } + + *eeprom_index += sizeof(tlvinfo_tlv_t) + eeprom_tlv->length; + } + + return false; +} + +/* + * tlvinfo_decode_tlv + * + * This function finds the TLV with the supplied code in the EERPOM + * and decodes the value into the buffer provided. + */ +static bool tlvinfo_decode_tlv(uint8_t *eeprom, uint8_t tcode, tlv_decode_value_t *decode_value) +{ + int eeprom_index; + tlvinfo_tlv_t *eeprom_tlv; + + /* Find the TLV and then decode it */ + if (tlvinfo_find_tlv(eeprom, tcode, &eeprom_index)) { + eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[eeprom_index]; + decode_tlv_value(eeprom_tlv, decode_value); + return true; + } + + return false; +} + +/* + * parse_tlv_eeprom + * + * parse the EEPROM into memory, if it hasn't already been read. + */ +int parse_tlv_eeprom(uint8_t *eeprom, uint32_t size) +{ + unsigned int i; + bool ret; + tlvinfo_header_t *eeprom_hdr; + tlv_decode_value_t decode_value; + int j; + + eeprom_hdr = (tlvinfo_header_t *) eeprom; + g_eeprom_size = size; /* eeprom real size */ + + if (!is_valid_tlvinfo_header(eeprom_hdr)) { + DBG_DEBUG(DBG_ERROR, "Failed to check tlv header.\n"); + return -1; + } + + if (!is_checksum_valid(eeprom)) { + DBG_DEBUG(DBG_ERROR, "Failed to check tlv crc.\n"); + return -1; + } + + for (i = 0; i < TLV_CODE_NUM; i++) { + memset((void *)&decode_value, 0, sizeof(tlv_decode_value_t)); + ret = tlvinfo_decode_tlv(eeprom, tlv_code_list[i].m_code, &decode_value); + if (!ret) { + DBG_DEBUG(DBG_ERROR, "No found type: %s\n", tlv_code_list[i].m_name); + continue; + } + + DBG_DEBUG(DBG_VERBOSE, "i: %d,Found type: %s tlv[%d]:%s\n", i, tlv_code_list[i].m_name, tlv_code_list[i].m_code, + decode_value.value); + for (j = 0; j < decode_value.length; j++) { + if ((j % 16) == 0) { + DBG_DEBUG(DBG_VERBOSE, "\n"); + } + DBG_DEBUG(DBG_VERBOSE, "%02x ", decode_value.value[j]); + } + DBG_DEBUG(DBG_VERBOSE, "\n\n"); + } + return 0; +} +static int dfd_parse_tlv_eeprom(uint8_t *eeprom, uint32_t size, uint8_t main_type, tlv_decode_value_t *decode_value) +{ + bool ret; + tlvinfo_header_t *eeprom_hdr; + int j; + + eeprom_hdr = (tlvinfo_header_t *) eeprom; + g_eeprom_size = size; /* eeprom real size */ + + if (!is_valid_tlvinfo_header(eeprom_hdr)) { + DBG_DEBUG(DBG_ERROR, "Failed to check tlv header.\n"); + return -1; + } + + if (!is_checksum_valid(eeprom)) { + DBG_DEBUG(DBG_ERROR, "Failed to check tlv crc.\n"); + return -1; + } + + ret = tlvinfo_decode_tlv(eeprom, main_type, decode_value); + if (!ret) { + DBG_DEBUG(DBG_ERROR, "No found type: %d\n", main_type); + return -1; + } + + DBG_DEBUG(DBG_VERBOSE, "Found type: %d, value: %s\n", main_type,decode_value->value); + for (j = 0; j < decode_value->length; j++) { + if ((j % 16) == 0) { + DBG_DEBUG(DBG_VERBOSE, "\n"); + } + DBG_DEBUG(DBG_VERBOSE, "%02x ", decode_value->value[j]); + } + DBG_DEBUG(DBG_VERBOSE, "\n\n"); + + return 0; +} +#if 0 + +static int tlvinfo_find_rg_ext_tlv(tlv_decode_value_t *ext_tlv_value, uint8_t ext_type, + uint8_t *buf, uint32_t *buf_len) +{ + tlvinfo_tlv_t *eeprom_tlv; + int eeprom_end, eeprom_index; + + /* Search through the TLVs, looking for the first one which matches the + * supplied type code.*/ + DBG_DEBUG(DBG_VERBOSE, "ext_tlv_value->length: %d.\n", ext_tlv_value->length); + for (eeprom_index = 0; eeprom_index < ext_tlv_value->length; eeprom_index++) { + if ((eeprom_index % 16) == 0) { + DBG_DEBUG(DBG_VERBOSE, "\n"); + } + DBG_DEBUG(DBG_VERBOSE, "%02x ", ext_tlv_value->value[eeprom_index]); + } + + DBG_DEBUG(DBG_VERBOSE, "\n"); + + eeprom_index = 0; + eeprom_end = ext_tlv_value->length; + while (eeprom_index < eeprom_end) { + eeprom_tlv = (tlvinfo_tlv_t *) &(ext_tlv_value->value[eeprom_index]); + if (!is_valid_tlv(eeprom_tlv)) { + DBG_DEBUG(DBG_ERROR, "tlv is not valid, eeprom_tlv->type 0x%x.\n", eeprom_tlv->type); + return -1; + } + + DBG_DEBUG(DBG_VERBOSE, "eeprom_tlv->length %d.\n", eeprom_tlv->length); + if (eeprom_tlv->type == ext_type) { + if (*buf_len >= eeprom_tlv->length) { + memcpy(buf, eeprom_tlv->value, eeprom_tlv->length); + DBG_DEBUG(DBG_VERBOSE, "eeprom_tlv->length %d.\n", eeprom_tlv->length); + *buf_len = eeprom_tlv->length; + return 0; + } + DBG_DEBUG(DBG_VERBOSE, "buf_len %d small than info_len %d.\n", *buf_len, eeprom_tlv->length); + return -1; + } + + eeprom_index += sizeof(tlvinfo_tlv_t) + eeprom_tlv->length; + } + + DBG_DEBUG(DBG_VERBOSE, "ext_type %d: tlv is not found.\n", ext_type); + return -1; +} +#endif + +int dfd_tlvinfo_get_e2prom_info(uint8_t *eeprom, uint32_t size, dfd_tlv_type_t *tlv_type, uint8_t* buf, uint32_t *buf_len) +{ + tlv_decode_value_t decode_value; + int ret; + + if (eeprom == NULL || tlv_type == NULL || buf == NULL) { + DBG_DEBUG(DBG_ERROR, "Input para invalid.\n"); + return -1; + } + + memset((void *)&decode_value, 0, sizeof(tlv_decode_value_t)); + ret = dfd_parse_tlv_eeprom(eeprom, size, tlv_type->main_type, &decode_value); + if (ret) { + DBG_DEBUG(DBG_ERROR, "dfd_parse_tlv_eeprom failed ret %d.\n", ret); + return ret; + } + + if (*buf_len >= decode_value.length) { + memcpy(buf, decode_value.value, decode_value.length); + *buf_len = decode_value.length; + return 0; + } + DBG_DEBUG(DBG_ERROR, "buf_len %d small than info_len %d.\n", *buf_len, decode_value.length); + return -1; +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_cpld_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_cpld_driver.c new file mode 100644 index 000000000000..999224606060 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_cpld_driver.c @@ -0,0 +1,117 @@ +/* + * Copyright(C) 2001-2012 Ruijie Network. All rights reserved. + */ + +#include + +#include "./include/dfd_module.h" +#include "./include/dfd_cfg.h" +#include "./include/dfd_cfg_adapter.h" +#include "./include/dfd_cfg_info.h" +#include "./include/dfd_frueeprom.h" + +int g_dfd_cpld_dbg_level = 0; +module_param(g_dfd_cpld_dbg_level, int, S_IRUGO | S_IWUSR); + +ssize_t dfd_get_cpld_name(unsigned int cpld_index, char *buf) +{ + int key; + char *cpld_name; + + if (buf == NULL) { + DBG_CPLD_DEBUG(DBG_ERROR, "param error. buf is NULL.cpld index:%d", cpld_index); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, PAGE_SIZE); + + key = DFD_CFG_KEY(DFD_CFG_ITEM_CPLD_NAME, cpld_index, 0); + cpld_name = dfd_ko_cfg_get_item(key); + if (cpld_name == NULL) { + DBG_CPLD_DEBUG(DBG_ERROR, "cpld name config error, key=0x%08x\n", key); + return -DFD_RV_NODE_FAIL; + } + + DBG_CPLD_DEBUG(DBG_VERBOSE, "%s\n", cpld_name); + snprintf(buf, PAGE_SIZE, "%s\n", cpld_name); + return strlen(buf); +} + +ssize_t dfd_get_cpld_type(unsigned int cpld_index, char *buf) +{ + int key; + char *cpld_type; + + if (buf == NULL) { + DBG_CPLD_DEBUG(DBG_ERROR, "param error. buf is NULL.cpld index:%d\n", cpld_index); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, PAGE_SIZE); + + key = DFD_CFG_KEY(DFD_CFG_ITEM_CPLD_TYPE, cpld_index, 0); + cpld_type = dfd_ko_cfg_get_item(key); + if (cpld_type == NULL) { + DBG_CPLD_DEBUG(DBG_ERROR, "cpld type config error, key=0x%08x\n", key); + return -DFD_RV_NODE_FAIL; + } + + DBG_CPLD_DEBUG(DBG_VERBOSE, "%s\n", cpld_type); + snprintf(buf, PAGE_SIZE, "%s\n", cpld_type); + return strlen(buf); +} + +ssize_t dfd_get_cpld_version(unsigned int cpld_index, char *buf) +{ + int key, rv; + uint32_t value; + + if (buf == NULL) { + DBG_CPLD_DEBUG(DBG_ERROR, "param error. buf is NULL."); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, PAGE_SIZE); + + key = DFD_CFG_KEY(DFD_CFG_ITEM_CPLD_VERSION, cpld_index, 0); + rv = dfd_info_get_int(key, &value, NULL); + if (rv < 0) { + DBG_CPLD_DEBUG(DBG_ERROR, "cpld version config error, key=0x%08x\n", key); + return -DFD_RV_NODE_FAIL; + } + + DBG_CPLD_DEBUG(DBG_VERBOSE, "%x\n", value); + snprintf(buf, PAGE_SIZE, "%08x\n", value); + return strlen(buf); +} + +int dfd_set_cpld_testreg(unsigned int cpld_index, int value) +{ + int key, ret; + + if (value < 0 || value > 0xff) { + DBG_CPLD_DEBUG(DBG_ERROR, "can not set cpld test register value = 0x%02x.\n", value); + return -DFD_RV_INVALID_VALUE; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_CPLD_TEST_REG, cpld_index, 0); + ret = dfd_info_set_int(key, value); + if (ret < 0) { + DBG_CPLD_DEBUG(DBG_ERROR, "set cpld test register error, key:0x%x,ret:%d\n",key, ret); + return ret; + } + return DFD_RV_OK; +} + +int dfd_get_cpld_testreg(unsigned int cpld_index, int *value) +{ + int key, ret; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_CPLD_TEST_REG, cpld_index, 0); + ret = dfd_info_get_int(key, value, NULL); + if (ret < 0) { + DBG_CPLD_DEBUG(DBG_ERROR, "get cpld test register error, key:0x%x,ret:%d\n",key, ret); + return ret; + } + return DFD_RV_OK; +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_fan_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_fan_driver.c new file mode 100644 index 000000000000..b56413c8c646 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_fan_driver.c @@ -0,0 +1,487 @@ +/* + * Copyright(C) 2001-2012 Ruijie Network. All rights reserved. + */ + +#include +#include + +#include "./include/dfd_module.h" +#include "./include/dfd_cfg.h" +#include "./include/dfd_cfg_adapter.h" +#include "./include/dfd_cfg_info.h" +#include "./include/dfd_frueeprom.h" +#include "../rg_dev_sysfs/include/rg_sysfs_common.h" + +#define DFD_FAN_EEPROM_MODE_TLV_STRING "tlv" +#define DFD_FAN_EEPROM_MODE_FRU_STRING "fru" +#define FAN_SIZE (256) + +typedef enum fan_status_e { + FAN_ABSENT = 0, + FAN_OK = 1, + FAN_NOT_OK = 2, +} fan_status_t; + +typedef enum fan_present_status_e { + ABSENT = 0, + PRESENT = 1, +} fan_present_status_t; + +typedef enum fan_motor_status_e { + MOTOR_STALL = 0, + MOTOR_ROLL = 1, +} fan_motor_status_t; + +typedef enum fan_eeprom_mode_e { + FAN_EEPROM_MODE_TLV, /* TLV */ + FAN_EEPROM_MODE_FRU, /*FRU*/ +} fan_eeprom_mode_t; + +typedef struct dfd_dev_head_info_s { + uint8_t ver; + uint8_t flag; + uint8_t hw_ver; + uint8_t type; + int16_t tlv_len; +} dfd_dev_head_info_t; + +typedef struct dfd_dev_tlv_info_s { + uint8_t type; + uint8_t len; + uint8_t data[0]; +} dfd_dev_tlv_info_t; + +typedef enum fan_direction_e { + FRONT_TO_BACK = 0, + BACK_TO_FRONT = 1, + FAN_DIRECTION_END = 2, +} fan_direction_t; + +int g_dfd_fan_dbg_level = 0; +module_param(g_dfd_fan_dbg_level, int, S_IRUGO | S_IWUSR); + +static int dfd_get_fan_eeprom_mode(void) +{ + int key, mode; + char *name; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_E2_MODE, 0, 0); + name = dfd_ko_cfg_get_item(key); + if (name == NULL) { + + DFD_FAN_DEBUG(DBG_WARN, "get fan eeprom mode fail, key=0x%08x\n", key); + return FAN_EEPROM_MODE_TLV; + } + + DFD_FAN_DEBUG(DBG_VERBOSE, "fan eeprom mode_name %s.\n", name); + if (!strncmp(name, DFD_FAN_EEPROM_MODE_TLV_STRING, strlen(DFD_FAN_EEPROM_MODE_TLV_STRING))) { + mode = FAN_EEPROM_MODE_TLV; + } else if (!strncmp(name, DFD_FAN_EEPROM_MODE_FRU_STRING, strlen(DFD_FAN_EEPROM_MODE_FRU_STRING))) { + mode = FAN_EEPROM_MODE_FRU; + } else { + + mode = FAN_EEPROM_MODE_TLV; + } + + DFD_FAN_DEBUG(DBG_VERBOSE, "fan eeprom mode %d.\n", mode); + return mode; +} + +static int dfd_fan_tlv_eeprom_read(int bus, int addr, uint8_t cmd, char *buf) +{ + dfd_dev_head_info_t info; + char tmp_tlv_len[sizeof(uint16_t)]; + char *tlv_data; + dfd_dev_tlv_info_t *tlv; + int buf_len; + int rv, match_flag; + + if (buf == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "buf is NULL\n"); + return -DFD_RV_INVALID_VALUE; + } + + rv = dfd_ko_i2c_read(bus, addr, 0, (uint8_t *)&info, sizeof(dfd_dev_head_info_t)); + if (rv < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "fan may not present.\n"); + return -DFD_RV_DEV_NOTSUPPORT; + } + + memcpy(tmp_tlv_len, (uint8_t *)&info.tlv_len, sizeof(uint16_t)); + info.tlv_len = (tmp_tlv_len[0] << 8) + tmp_tlv_len[1]; + + if ((info.tlv_len <= 0 ) || (info.tlv_len > 0xFF)) { + DFD_FAN_DEBUG(DBG_ERROR, "fan maybe not set mac.\n"); + return -DFD_RV_TYPE_ERR; + } + DFD_FAN_DEBUG(DBG_VERBOSE, "info.tlv_len:%d\n", info.tlv_len); + + tlv_data = (uint8_t *)kmalloc(info.tlv_len, GFP_KERNEL); + if (tlv_data == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "tlv_data kmalloc failed \n"); + return -DFD_RV_NO_MEMORY; + } + memset(tlv_data, 0, info.tlv_len); + + rv = dfd_ko_i2c_read(bus, addr, sizeof(dfd_dev_head_info_t), tlv_data, info.tlv_len); + if (rv < 0) { + DFD_FAN_DEBUG(DBG_ERROR,"fan eeprom read failed\n"); + kfree(tlv_data); + return -DFD_RV_DEV_NOTSUPPORT; + } + + buf_len = FAN_SIZE - 1; + match_flag = 0; + for(tlv = (dfd_dev_tlv_info_t *)tlv_data; (ulong)tlv < (ulong)tlv_data + info.tlv_len;) { + DFD_FAN_DEBUG(DBG_VERBOSE, "tlv: %p, tlv->type: 0x%x, tlv->len: 0x%x info->tlv_len: 0x%x\n", + tlv, tlv->type, tlv->len, info.tlv_len); + if (tlv->type == cmd && tlv->len <= buf_len ) { + DFD_FAN_DEBUG(DBG_VERBOSE, "find tlv data, copy...\n"); + memcpy(buf, (uint8_t *)tlv->data, tlv->len); + buf_len = (uint32_t)tlv->len; + match_flag = 1; + break; + } + tlv = (dfd_dev_tlv_info_t *)((uint8_t* )tlv + sizeof(dfd_dev_tlv_info_t) + tlv->len); + } + kfree(tlv_data); + if (match_flag == 0) { + DFD_FAN_DEBUG(DBG_ERROR,"can't find fan tlv date. bus:%d, addr:0x%02x, tlv type:%d.\n", bus, addr, cmd); + return -DFD_RV_TYPE_ERR; + } + return buf_len; +} + +int dfd_get_fan_roll_status(unsigned int fan_index, unsigned int motor_index) +{ + int key, ret; + int status; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_ROLL_STATUS, fan_index, motor_index); + ret = dfd_info_get_int(key, &status, NULL); + if (ret < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan roll status error, fan:%d,motor:%d\n", + fan_index, motor_index); + return ret; + } + + DFD_FAN_DEBUG(DBG_VERBOSE, "fan%u motor%u get fan roll status success, status:%d.\n", + fan_index, motor_index, status); + return status; +} + +int dfd_get_fan_present_status(unsigned int fan_index) +{ + int key, ret; + int status; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_DEV_PRESENT_STATUS, RG_MAIN_DEV_FAN, fan_index); + ret = dfd_info_get_int(key, &status, NULL); + if (ret < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "fan%u get present status error, key:0x%x\n", fan_index, key); + return ret; + } + + DFD_FAN_DEBUG(DBG_VERBOSE, "fan%u get present status success, status:%d.\n", fan_index, status); + return status; +} + +int dfd_get_fan_status(unsigned int fan_index) +{ + int motor_num, motor_index, status, errcnt; + + status = dfd_get_fan_present_status(fan_index); + if(status != PRESENT ) { + DFD_FAN_DEBUG(DBG_ERROR, "fan index:%d, status:%d\n",fan_index, status); + return status; + } + + motor_num = dfd_get_dev_number(RG_MAIN_DEV_FAN, RG_MINOR_DEV_MOTOR); + if(motor_num <= 0 ) { + DFD_FAN_DEBUG(DBG_ERROR, "get motor number error:%d\n",motor_num); + return -DFD_RV_DEV_FAIL; + } + errcnt = 0; + for(motor_index = 0; motor_index < motor_num; motor_index++) { + status = dfd_get_fan_roll_status(fan_index, motor_index); + if(status < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan roll status error, fan index:%d, motor index:%d, status:%d\n", + fan_index, motor_index, status); + return status; + } + if(status != MOTOR_ROLL) { + DFD_FAN_DEBUG(DBG_ERROR, + "stall:fan index:%d, motor index:%d, status:%d\n",fan_index, motor_index, status); + errcnt++; + } + } + if (errcnt > 0) { + return FAN_NOT_OK; + } + return FAN_OK; +} + +ssize_t dfd_get_fan_status_str(unsigned int fan_index, char *buf) +{ + int ret; + + if(buf == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "params error.fan_index:%d.",fan_index); + return -DFD_RV_INVALID_VALUE; + } + + ret = dfd_get_fan_status(fan_index); + if(ret < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan status error,ret:%d, fan_index:%d\n", ret, fan_index); + return ret; + } + memset(buf, 0, PAGE_SIZE); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", ret); +} + +ssize_t dfd_get_fan_info(unsigned int fan_index, uint8_t cmd, char *buf) +{ + int key, rv, eeprom_mode; + char fan_buf[FAN_SIZE]; + dfd_i2c_dev_t *i2c_dev; + + if (buf == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "buf is NULL, fan index:%d, cmd:0x%x.\n", fan_index, cmd); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, PAGE_SIZE); + memset(fan_buf, 0, FAN_SIZE); + + key = DFD_CFG_KEY(DFD_CFG_ITEM_OTHER_I2C_DEV, RG_MAIN_DEV_FAN, fan_index); + i2c_dev = dfd_ko_cfg_get_item(key); + if (i2c_dev == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "fan i2c dev config error, key=0x%08x\n", key); + return -DFD_RV_NODE_FAIL; + } + + eeprom_mode = dfd_get_fan_eeprom_mode(); + if(eeprom_mode == FAN_EEPROM_MODE_TLV) { + rv = dfd_fan_tlv_eeprom_read(i2c_dev->bus, i2c_dev->addr, cmd, fan_buf); + } else { + rv = dfd_get_fru_data(i2c_dev->bus, i2c_dev->addr, cmd, fan_buf, FAN_SIZE); + } + + if (rv < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "fan eeprom read failed"); + return -DFD_RV_DEV_FAIL; + } + + DFD_FAN_DEBUG(DBG_VERBOSE, "%s\n", fan_buf); + snprintf(buf, FAN_SIZE, "%s\n", fan_buf); + return strlen(buf); +} + +ssize_t dfd_get_fan_speed(unsigned int fan_index, unsigned int motor_index,unsigned int *speed) +{ + int key, ret, speed_tmp; + + if (speed == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "param error. fan index:%d, motor index:%d.\n", + fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_SPEED, fan_index, motor_index); + ret = dfd_info_get_int(key, &speed_tmp, NULL); + if (ret < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan speed error, key:0x%x,ret:%d\n",key, ret); + return ret; + } + + if (speed_tmp == 0 || speed_tmp == 0xffff) { + *speed = 0; + } else { + *speed = 15000000 / speed_tmp; + } + return DFD_RV_OK; +} + +int dfd_set_fan_speed_level(unsigned int fan_index, unsigned int motor_index, int level) +{ + int key, ret; + + if (level < 0 || level > 0xff) { + DFD_FAN_DEBUG(DBG_ERROR, "fan:%u, motor:%u, can not set fan speed level: %d.\n", + fan_index, motor_index, level); + return -DFD_RV_INVALID_VALUE; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_RATIO, fan_index, motor_index); + ret = dfd_info_set_int(key, level); + if (ret < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "fan:%u, motor:%u, set fan level 0x%02x error, key:0x%x,ret:%d\n", + fan_index, motor_index, level, key, ret); + return ret; + } + + DFD_FAN_DEBUG(DBG_VERBOSE, "fan:%u, motor:%u, set fan speed level 0x%02x success.\n", + fan_index, motor_index, level); + return DFD_RV_OK; +} + +int dfd_set_fan_pwm(unsigned int fan_index, unsigned int motor_index, int pwm) +{ + int ret, data; + + if (pwm < 0 || pwm > 100) { + DFD_FAN_DEBUG(DBG_ERROR, "fan:%u, motor:%u, can't set pwm: %d.\n", + fan_index, motor_index, pwm); + return -DFD_RV_INVALID_VALUE; + } + + data = pwm * 255 / 100; + ret = dfd_set_fan_speed_level(fan_index, motor_index, data); + if (ret < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "fan:%u, motor:%u, set fan ratio:%d error, ret:%d\n", + fan_index, motor_index, data, ret); + return ret; + } + + DFD_FAN_DEBUG(DBG_VERBOSE, "fan:%u, motor:%u, set fan ratio %d success.\n", + fan_index, motor_index, data); + return DFD_RV_OK; +} + +int dfd_get_fan_speed_level(unsigned int fan_index, unsigned int motor_index, int *level) +{ + int key, ret, speed_level; + + if (level == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "param error. fan index:%d, motor index:%d.\n", + fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_RATIO, fan_index, motor_index); + ret = dfd_info_get_int(key, &speed_level, NULL); + if (ret < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "fan:%u, motor:%u, get fan speed level error, key:0x%x,ret:%d\n", + fan_index, motor_index, key, ret); + return ret; + } + + DFD_FAN_DEBUG(DBG_VERBOSE, "fan:%u, motor:%u, get fan speed level success, value:0x%02x.\n", + fan_index, motor_index, speed_level); + *level = speed_level; + return DFD_RV_OK; +} + +int dfd_get_fan_pwm(unsigned int fan_index, unsigned int motor_index, int *pwm) +{ + int ret, level; + + if (pwm == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "param error. fan index:%d, motor index:%d.\n", + fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + + ret = dfd_get_fan_speed_level(fan_index, motor_index, &level); + if (ret < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "fan:%u, motor:%u, get fan pwm error, ret:%d\n", + fan_index, motor_index, ret); + return ret; + } + + if ((level * 100) % 255 > 0) { + *pwm = level * 100 / 255 + 1; + } else { + *pwm = level * 100 / 255; + } + + DFD_FAN_DEBUG(DBG_VERBOSE, "fan:%u, motor:%u, get fan pwm success, value:%d.\n", + fan_index, motor_index, *pwm); + return DFD_RV_OK; +} + +int dfd_get_fan_speed_tolerance(unsigned int fan_index, unsigned int motor_index, int *value) +{ + int key; + int *p_fan_speed_tolerance; + + if (value == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "param error. fan index:%d, motor index:%d.\n", + fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_SPEED_TOLERANCE, fan_index, motor_index); + p_fan_speed_tolerance = dfd_ko_cfg_get_item(key); + if (p_fan_speed_tolerance == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan speed tolerance failed, key:0x%x\n",key); + return -DFD_RV_DEV_NOTSUPPORT; + } + *value = *p_fan_speed_tolerance; + DFD_FAN_DEBUG(DBG_VERBOSE, "get fan speed tolerance ok, key:0x%x, value:%d\n",key, *value); + return DFD_RV_OK; +} + +int dfd_get_fan_speed_target(unsigned int fan_index, unsigned int motor_index, int *value) +{ + int key; + int *p_fan_speed_target; + + if (value == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "param error. fan index:%d, motor index:%d.\n", + fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_SPEED_TARGET, fan_index, motor_index); + p_fan_speed_target = dfd_ko_cfg_get_item(key); + if (p_fan_speed_target == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan speed target failed, key:0x%x\n",key); + return -DFD_RV_DEV_NOTSUPPORT; + } + *value = *p_fan_speed_target; + DFD_FAN_DEBUG(DBG_VERBOSE, "get fan speed target ok, key:0x%x, value:%d\n",key, *value); + return DFD_RV_OK; +} + +int dfd_get_fan_direction(unsigned int fan_index, unsigned int motor_index, int *value) +{ + int key; + int *p_fan_direction; + + if (value == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "param error. fan index:%d, motor index:%d.\n", + fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_DIRECTION, fan_index, motor_index); + p_fan_direction = dfd_ko_cfg_get_item(key); + if (p_fan_direction == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan direction failed, key:0x%x\n",key); + return -DFD_RV_DEV_NOTSUPPORT; + } + *value = *p_fan_direction; + DFD_FAN_DEBUG(DBG_VERBOSE, "get fan direction ok, key:0x%x, value:%d\n",key, *value); + return DFD_RV_OK; +} + +ssize_t dfd_get_fan_direction_str(unsigned int fan_index, unsigned int motor_index, char *buf) +{ + int ret, value; + + if (buf == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "param error. buf is NULL. fan index:%d, motor index:%d.\n", + fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + + ret = dfd_get_fan_direction(fan_index, motor_index, &value); + if (ret < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan direction string failed, ret:%d, fan_index:%d, motor_index:%d\n", + ret, fan_index, motor_index); + return ret; + } + memset(buf, 0, PAGE_SIZE); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", value); +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_led_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_led_driver.c new file mode 100644 index 000000000000..2e0355ce825c --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_led_driver.c @@ -0,0 +1,86 @@ +/* + * Copyright(C) 2001-2012 Ruijie Network. All rights reserved. + */ + +#include + +#include "./include/dfd_module.h" +#include "./include/dfd_cfg.h" +#include "./include/dfd_cfg_info.h" +#include "./include/dfd_cfg_adapter.h" + +#define LED_STATUS_MEM (9) + +int g_dfd_sysled_dbg_level = 0; +module_param(g_dfd_sysled_dbg_level, int, S_IRUGO | S_IWUSR); + +typedef enum dfd_led_status_e { + DFD_LED_DARK = 0, + DFD_LED_GREEN = 1, + DFD_LED_YELLOW = 2, + DFD_LED_RED = 3, + DFD_LED_GREEN_FLASH = 4, + DFD_LED_YELLOW_FLASH = 5, + DFD_LED_RED_FLASH = 6, + DFD_LED_BLUE = 7, + DFD_LED_END = 8, +} dfd_led_status_t; + +static int g_dfd_rg_led_status[LED_STATUS_MEM] = { + DFD_LED_DARK, + DFD_LED_RED_FLASH, + DFD_LED_RED, + DFD_LED_GREEN_FLASH, + DFD_LED_GREEN, + DFD_LED_YELLOW_FLASH, + DFD_LED_YELLOW, + DFD_LED_DARK, + DFD_LED_BLUE, +}; + +static int dfd_get_led_status_value(uint16_t led_id, uint8_t led_index, int *value) +{ + int key, ori_value, ret, value_tmp; + int *p_decode_value; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_LED_STATUS, led_id, led_index); + ret = dfd_info_get_int(key, &ori_value, NULL); + if (ret < 0) { + DBG_SYSLED_DEBUG(DBG_ERROR, "get led status error, key:0x%x,ret:%d\n", key, ret); + return ret; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_LED_STATUS_DECODE, led_id, ori_value); + p_decode_value = dfd_ko_cfg_get_item(key); + if (p_decode_value == NULL) { + DFD_FAN_DEBUG(DBG_VERBOSE, "led id:%d index:%d, status needn't decode.value:0x%x\n", led_id, led_index, ori_value); + value_tmp = ori_value; + } else { + DFD_FAN_DEBUG(DBG_VERBOSE, "led id:%d index:%d,, ori_value:0x%x,decode value:0x%x\n", led_id, led_index, ori_value, *p_decode_value); + value_tmp = *p_decode_value; + } + if(value_tmp >=0 && value_tmp < LED_STATUS_MEM) { + *value = g_dfd_rg_led_status[value_tmp]; + return DFD_RV_OK; + } + return -DFD_RV_INVALID_VALUE; +} + +ssize_t dfd_get_led_status(uint16_t led_id, uint8_t led_index, char *buf) +{ + int ret, led_value; + + if(buf == NULL) { + DBG_SYSLED_DEBUG(DBG_ERROR, "param error, buf is NULL. led_id:%d, led_index:%d\n", + led_id, led_index); + return -DFD_RV_INVALID_VALUE; + } + + ret = dfd_get_led_status_value(led_id, led_index, &led_value); + if(ret < 0) { + DBG_SYSLED_DEBUG(DBG_ERROR, "get led status error,ret:%d, led_id:%d, led_index:%d\n", ret, led_id, led_index); + return ret; + } + memset(buf, 0 , PAGE_SIZE); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", led_value); +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_module.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_module.c new file mode 100644 index 000000000000..b64663f81737 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_module.c @@ -0,0 +1,134 @@ +/* + * Copyright(C) 2001-2012 Ruijie Network. All rights reserved. + */ + +#include + +#include "../rg_dev_sysfs/include/rg_sysfs_common.h" +#include "./include/dfd_module.h" +#include "./include/dfd_cfg.h" +#include "./include/dfd_fan_driver.h" +#include "./include/dfd_syseeprom_driver.h" +#include "./include/dfd_cpld_driver.h" +#include "./include/dfd_led_driver.h" +#include "./include/dfd_slot_driver.h" +#include "./include/dfd_sensors_driver.h" +#include "./include/dfd_psu_driver.h" +#include "./include/dfd_sff_driver.h" + +typedef enum dfd_dev_init_fail_s { + DFD_KO_INIT_CPLD_FAIL = 1, + DFD_KO_INIT_FPGA_FAIL = 2, + DFD_KO_INIT_IRQ_FAIL = 3, + DFD_KO_INIT_CFG_FAIL = 4, + DFD_KO_INIT_DATA_FAIL = 5, +} dfd_dev_init_fail_t; + +int g_dfd_dbg_level = 0; + +char *g_status_mem_str[STATUS_MEM_END] = { + "ABSENT", + "OK", + "NOT OK", +}; + +int dfd_get_dev_number(unsigned int main_dev_id, unsigned int minor_dev_id) +{ + int key,dev_num; + int *p_dev_num; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_DEV_NUM, main_dev_id, minor_dev_id); + p_dev_num = dfd_ko_cfg_get_item(key); + if (p_dev_num == NULL) { + DBG_DEBUG(DBG_ERROR, "get device number failed, key:0x%x\n",key); + return -DFD_RV_DEV_NOTSUPPORT; + } + dev_num = *p_dev_num; + DBG_DEBUG(DBG_VERBOSE, "get device number ok, number:%d\n",dev_num); + return dev_num; +} + +static struct switch_drivers_t switch_drivers= { + .get_dev_number = dfd_get_dev_number, + /* fan */ + .get_fan_status = dfd_get_fan_status, + .get_fan_info = dfd_get_fan_info, + .get_fan_speed = dfd_get_fan_speed, + .get_fan_pwm = dfd_get_fan_pwm, + .set_fan_pwm = dfd_set_fan_pwm, + .get_fan_speed_tolerance = dfd_get_fan_speed_tolerance, + .get_fan_speed_target = dfd_get_fan_speed_target, + .get_fan_direction = dfd_get_fan_direction, + .get_fan_status_str = dfd_get_fan_status_str, + .get_fan_direction_str = dfd_get_fan_direction_str, + .get_fan_present_status = dfd_get_fan_present_status, + .get_fan_roll_status = dfd_get_fan_roll_status, + .get_fan_speed_level = dfd_get_fan_speed_level, + .set_fan_speed_level = dfd_set_fan_speed_level, + /* syseeprom */ + .get_syseeprom_info = dfd_get_syseeprom_info, + /* cpld */ + .get_cpld_name = dfd_get_cpld_name, + .get_cpld_type = dfd_get_cpld_type, + .get_cpld_version = dfd_get_cpld_version, + .get_cpld_testreg = dfd_get_cpld_testreg, + .set_cpld_testreg = dfd_set_cpld_testreg, + /* led */ + .get_led_status = dfd_get_led_status, + /* slot */ + .get_slot_status_str = dfd_get_slot_status_str, + .get_slot_info = dfd_get_slot_info, + /* sensors */ + .get_temp_info = dfd_get_temp_info, + .get_voltage_info = dfd_get_voltage_info, + /* psu */ + .get_psu_info = dfd_get_psu_info, + .get_psu_status_str = dfd_get_psu_status_str, + .get_psu_sensor_info = dfd_get_psu_sensor_info, + .get_psu_present_status = dfd_get_psu_present_status, + .get_psu_output_status = dfd_get_psu_output_status, + .get_psu_alert_status = dfd_get_psu_alert_status, + /* sff */ + .get_sff_id = dfd_get_sff_id, + .set_sff_cpld_info = dfd_set_sff_cpld_info, + .get_sff_cpld_info = dfd_get_sff_cpld_info, + .get_sff_eeprom_info = dfd_get_sff_eeprom_info, + .get_sff_dir_name = dfd_get_sff_dir_name, + .get_sff_polling_size = dfd_get_sff_polling_size, + .get_sff_polling_data = dfd_get_sff_polling_data, +}; + +struct switch_drivers_t * dfd_plat_driver_get(void) { + return &switch_drivers; +} + +static int32_t __init dfd_dev_init(void) +{ + int ret; + + DBG_DEBUG(DBG_VERBOSE, "Enter.\n"); + + ret = dfd_dev_cfg_init(); + if (ret != 0) { + DBG_DEBUG(DBG_ERROR, "dfd_dev_cfg_init failed ret %d.\n", ret); + ret = -DFD_KO_INIT_CFG_FAIL; + return ret; + } + + DBG_DEBUG(DBG_VERBOSE, "success.\n"); + return 0; +} + +static void __exit dfd_dev_exit(void) +{ + DBG_DEBUG(DBG_VERBOSE, "dfd_dev_exit.\n"); + dfd_dev_cfg_exit(); + return ; +} + +module_init(dfd_dev_init); +module_exit(dfd_dev_exit); +module_param(g_dfd_dbg_level, int, S_IRUGO | S_IWUSR); +EXPORT_SYMBOL(dfd_plat_driver_get); +MODULE_AUTHOR("sonic_rd "); +MODULE_LICENSE("GPL"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_psu_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_psu_driver.c new file mode 100644 index 000000000000..22fc96e3b2d0 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_psu_driver.c @@ -0,0 +1,206 @@ +/* + * Copyright(C) 2001-2012 Ruijie Network. All rights reserved. + */ + +#include +#include + +#include "./include/dfd_module.h" +#include "./include/dfd_cfg.h" +#include "./include/dfd_cfg_adapter.h" +#include "./include/dfd_cfg_info.h" +#include "./include/dfd_frueeprom.h" +#include "../rg_dev_sysfs/include/rg_sysfs_common.h" + +#define PSU_SIZE (256) + +typedef enum dfd_psu_status_e { + DFD_PSU_PRESENT_STATUS = 0, + DFD_PSU_OUTPUT_STATUS = 1, + DFD_PSU_ALERT_STATUS = 2, +} dfd_psu_status_t; + +typedef enum dfd_psu_present_status_e { + ABSENT = 0, + PRESENT = 1, +} dfd_psu_present_status_t; + +typedef enum dfd_psu_output_status_e { + FAULT = 0, + NORMAL = 1, +} dfd_psu_output_status_t; + +int g_dfd_psu_dbg_level = 0; +module_param(g_dfd_psu_dbg_level, int, S_IRUGO | S_IWUSR); + +int dfd_get_psu_present_status(unsigned int psu_index) +{ + int ret, present_key, present_status; + + present_key = DFD_CFG_KEY(DFD_CFG_ITEM_PSU_STATUS, psu_index, DFD_PSU_PRESENT_STATUS); + ret = dfd_info_get_int(present_key, &present_status, NULL); + if (ret < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "dfd_get_psu_present_status error. psu_index:%d, ret:%d\n", + psu_index, ret); + return ret; + } + + DFD_PSU_DEBUG(DBG_VERBOSE, "dfd_get_psu_present_status success. psu_index:%d, status:%d\n", + psu_index, present_status); + return present_status; +} + +int dfd_get_psu_output_status(unsigned int psu_index) +{ + int ret, output_key, output_status; + + output_key = DFD_CFG_KEY(DFD_CFG_ITEM_PSU_STATUS, psu_index, DFD_PSU_OUTPUT_STATUS); + ret = dfd_info_get_int(output_key, &output_status, NULL); + if (ret < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "dfd_get_psu_output_status error. psu_index:%d, ret:%d\n", + psu_index, ret); + return ret; + } + + DFD_PSU_DEBUG(DBG_VERBOSE, "dfd_get_psu_output_status success. psu_index:%d, status:%d\n", + psu_index, output_status); + return output_status; +} + +int dfd_get_psu_alert_status(unsigned int psu_index) +{ + int ret, alert_key, alert_status; + + alert_key = DFD_CFG_KEY(DFD_CFG_ITEM_PSU_STATUS, psu_index, DFD_PSU_ALERT_STATUS); + ret = dfd_info_get_int(alert_key, &alert_status, NULL); + if (ret < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "dfd_get_psu_alert_status error. psu_index:%d, ret:%d\n", + psu_index, ret); + return ret; + } + + DFD_PSU_DEBUG(DBG_VERBOSE, "dfd_get_psu_alert_status success. psu_index:%d, status:%d\n", + psu_index, alert_status); + return alert_status; +} + +int dfd_get_psu_status(unsigned int psu_index) +{ + int present_key, present_status; + int output_key, output__status; + int alert_key, alert_status; + int ret1, ret2; + + present_key = DFD_CFG_KEY(DFD_CFG_ITEM_PSU_STATUS, psu_index, DFD_PSU_PRESENT_STATUS); + ret1 = dfd_info_get_int(present_key, &present_status, NULL); + if (ret1 < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "dfd_get_psu_status error. psu_index:%d, ret:%d\n", psu_index, ret1); + return ret1; + } + if(present_status != PRESENT) { + return STATUS_ABSENT; + } + + output_key = DFD_CFG_KEY(DFD_CFG_ITEM_PSU_STATUS, psu_index, DFD_PSU_OUTPUT_STATUS); + alert_key = DFD_CFG_KEY(DFD_CFG_ITEM_PSU_STATUS, psu_index, DFD_PSU_ALERT_STATUS); + ret1 = dfd_info_get_int(output_key, &output__status, NULL); + ret2 = dfd_info_get_int(alert_key, &alert_status, NULL); + if( ret1 < 0 || ret2 < 0 ||output__status != NORMAL || alert_status != NORMAL) { + return STATUS_NOT_OK; + } + return STATUS_OK; +} + +ssize_t dfd_get_psu_status_str(unsigned int psu_index, char *buf) +{ + int ret; + if(buf == NULL) { + DFD_PSU_DEBUG(DBG_ERROR, "params error.psu_index:%d.",psu_index); + return -DFD_RV_INVALID_VALUE; + } + ret = dfd_get_psu_status(psu_index); + if(ret < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "get psu status error,ret:%d, psu_index:%d\n", ret, psu_index); + return ret; + } + memset(buf, 0 , PAGE_SIZE); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", ret); +} + +static int dfd_psu_product_name_decode(char *psu_buf, int buf_len) +{ + int key, i; + char *p_psu_name, *p_decode_name; + int *psu_type_num; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_DEV_NUM, RG_MAIN_DEV_PSU, RG_MINOR_DEV_PSU); + psu_type_num = dfd_ko_cfg_get_item(key); + if (psu_type_num == NULL) { + DFD_PSU_DEBUG(DBG_ERROR, "get product psu type number error, key:0x%x\n", key); + return -DFD_RV_NO_NODE; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_PSU_NAME, 0, 0); + p_decode_name = dfd_ko_cfg_get_item(key); + if (p_decode_name == NULL) { + DFD_PSU_DEBUG(DBG_ERROR, "config error.psu decode name is NULL., key:0x%x\n", key); + return -DFD_RV_NO_NODE; + } + + for (i = 1; i <= *psu_type_num; i++) { + key = DFD_CFG_KEY(DFD_CFG_ITEM_PSU_NAME, i, 0); + p_psu_name = dfd_ko_cfg_get_item(key); + if (p_psu_name == NULL) { + DFD_PSU_DEBUG(DBG_ERROR, "config error.get psu name error., key:0x%x\n", key); + return -DFD_RV_NO_NODE; + } + if (!strncmp(psu_buf, p_psu_name, strlen(p_psu_name))) { + DFD_PSU_DEBUG(DBG_VERBOSE, "psu name match ok, org name:%s\n", p_psu_name); + memset(psu_buf, 0, buf_len); + strncpy(psu_buf, p_decode_name, buf_len -1); + return DFD_RV_OK; + } + } + DFD_PSU_DEBUG(DBG_ERROR, "psu name:%s error.can't match.\n", psu_buf); + return -DFD_RV_DEV_NOTSUPPORT; +} + +ssize_t dfd_get_psu_info(unsigned int psu_index, uint8_t cmd, char *buf) +{ + int key, rv; + char psu_buf[PSU_SIZE]; + dfd_i2c_dev_t *i2c_dev; + + if (buf == NULL) { + DFD_PSU_DEBUG(DBG_ERROR, "buf is NULL, psu index:%d, cmd:%d\n", psu_index, cmd); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, PAGE_SIZE); + memset(psu_buf, 0, PSU_SIZE); + + key = DFD_CFG_KEY(DFD_CFG_ITEM_OTHER_I2C_DEV, RG_MAIN_DEV_PSU, psu_index); + i2c_dev = dfd_ko_cfg_get_item(key); + if (i2c_dev == NULL) { + DFD_PSU_DEBUG(DBG_ERROR, "psu i2c dev config error, key=0x%08x\n", key); + return -DFD_RV_NODE_FAIL; + } + + rv = dfd_get_fru_data(i2c_dev->bus, i2c_dev->addr, cmd, psu_buf, PSU_SIZE); + + if (rv < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "psu eeprom read failed"); + return -DFD_RV_DEV_FAIL; + } + DFD_PSU_DEBUG(DBG_VERBOSE, "%s\n", psu_buf); + + if (cmd == DFD_DEV_INFO_TYPE_PART_NAME) { + rv = dfd_psu_product_name_decode(psu_buf, PSU_SIZE); + if (rv < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "psu name decode error. rv:%d.\n", rv); + return rv; + } + } + snprintf(buf, PSU_SIZE, "%s\n", psu_buf); + return strlen(buf); +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_sensors_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_sensors_driver.c new file mode 100644 index 000000000000..c0a246c47826 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_sensors_driver.c @@ -0,0 +1,178 @@ +/* + * Copyright(C) 2001-2012 Ruijie Network. All rights reserved. + */ + +#include +#include + +#include "./include/dfd_module.h" +#include "./include/dfd_cfg.h" +#include "./include/dfd_cfg_adapter.h" +#include "./include/dfd_cfg_info.h" +#include "./include/dfd_frueeprom.h" +#include "./include/dfd_cfg_file.h" +#include "../rg_dev_sysfs/include/rg_sysfs_common.h" + +#define DFD_GET_TEMP_SENSOR_KEY1(dev_index, temp_index) \ + (((dev_index & 0xff) << 8) | (temp_index & 0xff)) +#define DFD_GET_TEMP_SENSOR_KEY2(main_dev_id, temp_type) \ + (((main_dev_id & 0x0f) << 4) | (temp_type & 0x0f)) +#define DFD_FORMAT_STR_MAX_LEN (32) + +int g_dfd_sensor_dbg_level = 0; +module_param(g_dfd_sensor_dbg_level, int, S_IRUGO | S_IWUSR); + +static int dfd_deal_hwmon_buf(uint8_t *buf, int buf_len, uint8_t *buf_new, int *buf_len_new, info_ctrl_t *info_ctrl) +{ + int i, tmp_len; + int exp, decimal, divisor; + int org_value, tmp_value; + int div_result, div_mod; + char fmt_str[DFD_FORMAT_STR_MAX_LEN]; + + exp = info_ctrl->int_cons; + decimal = info_ctrl->bit_offset; + + if (exp <= 0) { + DBG_DEBUG(DBG_VERBOSE, "exponent %d, don't need transform. buf_len:%d, buf_len_new:%d\n", + exp, buf_len, *buf_len_new); + snprintf(buf_new, *buf_len_new, "%s", buf); + *buf_len_new = strlen(buf_new); + return DFD_RV_OK; + } + divisor = 1; + for (i = 0; i < exp; i++) { + divisor *= 10; + } + org_value = simple_strtol(buf, NULL, 10); + if (org_value < 0) { + tmp_value = 0 - org_value; + } else { + tmp_value = org_value; + } + div_result = tmp_value / divisor; + div_mod = tmp_value % divisor; + DBG_DEBUG(DBG_VERBOSE, "exp:%d, decimal:%d, original value:%d, divisor:%d, result :%d, mod:%d\n", + exp, decimal, org_value, divisor, div_result, div_mod); + + memset(fmt_str, 0, sizeof(fmt_str)); + if (org_value < 0) { + snprintf(fmt_str, sizeof(fmt_str), "-%%d.%%0%dd\n",exp); + } else { + snprintf(fmt_str, sizeof(fmt_str), "%%d.%%0%dd\n",exp); + } + DBG_DEBUG(DBG_VERBOSE, "format string:%s",fmt_str); + snprintf(buf_new, *buf_len_new, fmt_str, div_result, div_mod); + *buf_len_new = strlen(buf_new); + tmp_len = *buf_len_new; + + if ( decimal > 0) { + for(i = 0; i < *buf_len_new; i++) { + if (buf_new[i] == '.') { + if( i + decimal + 2 <= *buf_len_new ) { + buf_new[i + decimal + 1 ] = '\n'; + buf_new[i + decimal + 2 ] = '\0'; + *buf_len_new = strlen(buf_new); + DBG_DEBUG(DBG_VERBOSE, "deal decimal[%d] ok, str len:%d, value:%s\n", + decimal, *buf_len_new, buf_new); + } + break; + } + } + if (tmp_len == *buf_len_new) { + DBG_DEBUG(DBG_WARN, "deal decimal[%d] failed, use original value:%s\n", decimal, buf_new); + } + } + return DFD_RV_OK; +} + +static int dfd_get_sensor_info(uint8_t main_dev_id, uint8_t dev_index, uint8_t sensor_type, + uint8_t sensor_index, uint8_t sensor_attr, char *buf) +{ + uint32_t key; + uint16_t key_index1; + uint8_t key_index2; + int rv; + info_hwmon_buf_f pfunc; + + key_index1 = DFD_GET_TEMP_SENSOR_KEY1(dev_index, sensor_index); + key_index2 = DFD_GET_TEMP_SENSOR_KEY2(main_dev_id, sensor_attr); + if (sensor_type == RG_MINOR_DEV_TEMP ) { + key = DFD_CFG_KEY(DFD_CFG_ITEM_HWMON_TEMP, key_index1, key_index2); + } else if (sensor_type == RG_MINOR_DEV_IN) { + key = DFD_CFG_KEY(DFD_CFG_ITEM_HWMON_IN, key_index1, key_index2); + } else { + DFD_SENSOR_DEBUG(DBG_ERROR, "unknow sensor type:%d.\n",sensor_type); + return -DFD_RV_INVALID_VALUE; + } + + DFD_SENSOR_DEBUG(DBG_VERBOSE, "get sensor info.main_dev_id:%d, dev_index:0x%x, sensor_index:0x%x, sensor_attr:0x%x, key:0x%x,\n", + main_dev_id, dev_index, sensor_index, sensor_attr, key); + + pfunc = dfd_deal_hwmon_buf; + memset(buf, 0 , PAGE_SIZE); + rv = dfd_info_get_sensor(key, buf, PAGE_SIZE, pfunc); + return rv; +} + +ssize_t dfd_get_temp_info(uint8_t main_dev_id, uint8_t dev_index, + uint8_t temp_index, uint8_t temp_attr, char *buf) +{ + int rv; + + if (buf == NULL) { + DFD_SENSOR_DEBUG(DBG_ERROR, "param error. buf is NULL.\n"); + return -DFD_RV_INVALID_VALUE; + } + + rv = dfd_get_sensor_info(main_dev_id, dev_index, RG_MINOR_DEV_TEMP, temp_index, temp_attr, buf); + if (rv < 0) { + DFD_SENSOR_DEBUG(DBG_ERROR, "get temp info error. rv:%d\n", rv); + } else { + DFD_SENSOR_DEBUG(DBG_VERBOSE, "get temp info ok.value:%s\n", buf); + } + return rv; +} + +ssize_t dfd_get_voltage_info(uint8_t main_dev_id, uint8_t dev_index, + uint8_t in_index, uint8_t in_attr, char *buf) +{ + int rv; + + if (buf == NULL) { + DFD_SENSOR_DEBUG(DBG_ERROR, "param error. buf is NULL.\n"); + return -DFD_RV_INVALID_VALUE; + } + + rv = dfd_get_sensor_info(main_dev_id, dev_index, RG_MINOR_DEV_IN, in_index, in_attr, buf); + if (rv < 0) { + DFD_SENSOR_DEBUG(DBG_ERROR, "get voltage info error. rv:%d\n", rv); + } else { + DFD_SENSOR_DEBUG(DBG_VERBOSE, "get voltage info ok.value:%s\n", buf); + } + return rv; +} + +ssize_t dfd_get_psu_sensor_info(uint8_t psu_index, uint8_t sensor_type, char *buf) +{ + int rv, key; + info_hwmon_buf_f pfunc; + + if (buf == NULL) { + DFD_SENSOR_DEBUG(DBG_ERROR, "param error. buf is NULL.\n"); + return -DFD_RV_INVALID_VALUE; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_HWMON_PSU, psu_index, sensor_type); + DFD_SENSOR_DEBUG(DBG_VERBOSE, "get psu sensor info. psu index:%d, sensor type:%d, key:0x%x,\n", + psu_index, sensor_type, key); + pfunc = dfd_deal_hwmon_buf; + memset(buf, 0 , PAGE_SIZE); + rv = dfd_info_get_sensor(key, buf, PAGE_SIZE, pfunc); + if (rv < 0) { + DFD_SENSOR_DEBUG(DBG_ERROR, "get psu sensor info error. key:0x%x, rv:%d\n", key, rv); + } else { + DFD_SENSOR_DEBUG(DBG_VERBOSE, "get psu sensor info ok.value:%s\n", buf); + } + return rv; +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_sff_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_sff_driver.c new file mode 100644 index 000000000000..ab35f75b855b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_sff_driver.c @@ -0,0 +1,199 @@ +/* + * Copyright(C) 2001-2012 Ruijie Network. All rights reserved. + */ + +#include + +#include "./include/dfd_module.h" +#include "./include/dfd_cfg.h" +#include "./include/dfd_cfg_info.h" +#include "./include/dfd_cfg_adapter.h" +#include "../rg_dev_sysfs/include/rg_sysfs_common.h" + +int g_dfd_sff_dbg_level = 0; +module_param(g_dfd_sff_dbg_level, int, S_IRUGO | S_IWUSR); + +extern ssize_t sfp_show_atrr(int sfp_bus, int sfp_mode, const char *attr_name, char *buf, int buf_len); + +int dfd_get_sff_id(unsigned int sff_index) +{ + int key; + int *p_sff_id; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_SFF_ID, sff_index, 0); + p_sff_id = dfd_ko_cfg_get_item(key); + if (p_sff_id == NULL) { + DFD_SFF_DEBUG(DBG_ERROR, "get sff id error, key:0x%x\n", key); + return -DFD_RV_NO_NODE; + } + DFD_SFF_DEBUG(DBG_VERBOSE, "get sff id ok, sff index:%d, id:0x%x.\n", sff_index, *p_sff_id); + return *p_sff_id; +} + +int dfd_set_sff_cpld_info(unsigned int sff_index, int cpld_reg_type, int value) +{ + int key, ret; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_SFF_CPLD_REG, sff_index, cpld_reg_type); + ret = dfd_info_set_int(key, value); + if (ret < 0) { + DFD_SFF_DEBUG(DBG_ERROR, "set sff cpld reg error, key:0x%x,ret:%d.\n", key, ret); + return ret; + } + + return DFD_RV_OK; +} + +ssize_t dfd_get_sff_cpld_info(unsigned int sff_index, int cpld_reg_type, char *buf, int len) +{ + int key, ret, value; + + if(buf == NULL) { + DFD_SFF_DEBUG(DBG_ERROR, "param error, buf is NULL. sff_index:%d, cpld_reg_type:%d.\n", + sff_index, cpld_reg_type); + return -DFD_RV_INVALID_VALUE; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_SFF_CPLD_REG, sff_index, cpld_reg_type); + ret = dfd_info_get_int(key, &value, NULL); + if (ret < 0) { + DFD_SFF_DEBUG(DBG_ERROR, "get sff cpld reg error, key:0x%x,ret:%d.\n", key, ret); + return ret; + } + + memset(buf, 0 , len); + return (ssize_t)snprintf(buf, len, "%d\n", value); +} + +ssize_t dfd_get_sff_eeprom_info(unsigned int sff_index, const char *attr_name, char *buf, int buf_len) +{ + int ret; + int sff_id, sff_bus, sff_speed; + + if(!buf || !attr_name || buf_len <= 0) { + DFD_SFF_DEBUG(DBG_ERROR, "param error, buf or attr_name is NULL. sff index:%d, buf len:%d.\n", + sff_index, buf_len); + return -DFD_RV_INVALID_VALUE; + } + + sff_id = dfd_get_sff_id(sff_index); + if (sff_id < 0) { + DFD_SFF_DEBUG(DBG_ERROR, "get sff id error, sff_index:%d, ret:%d\n", sff_index, sff_id); + return -DFD_RV_NODE_FAIL; + + } + sff_bus = RG_GET_SFF_I2C_ADAPTER(sff_id); + sff_speed = RG_GET_SFF_SPEED_MODE(sff_id); + + memset(buf, 0 , buf_len); + ret = sfp_show_atrr(sff_bus, sff_speed, attr_name, buf, buf_len); + if (ret < 0) { + DFD_SFF_DEBUG(DBG_ERROR, "prase sff eeprom info error. sff index:%d, bus:%d, speed mode:%d, attr_name:%s.\n", + sff_index, sff_bus, sff_speed, attr_name); + } + + return ret; +} + +ssize_t dfd_get_sff_dir_name(unsigned int sff_index, char *buf, int buf_len) +{ + int key; + char *sff_dir_name; + + if (buf == NULL) { + DFD_SFF_DEBUG(DBG_ERROR, "param error. buf is NULL.sff index:%d", sff_index); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, buf_len); + + key = DFD_CFG_KEY(DFD_CFG_ITEM_SFF_DIR_NAME, sff_index, 0); + sff_dir_name = dfd_ko_cfg_get_item(key); + if (sff_dir_name == NULL) { + DFD_SFF_DEBUG(DBG_ERROR, "sff dir name config error, key=0x%08x\n", key); + return -DFD_RV_NODE_FAIL; + } + + DFD_SFF_DEBUG(DBG_VERBOSE, "%s\n", sff_dir_name); + snprintf(buf, buf_len, "%s", sff_dir_name); + return strlen(buf); + +} + +int dfd_get_sff_polling_size(void) +{ + int key; + int *p_eeprom_size; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_SFF_POLLING_SIZE, 0, 0); + + p_eeprom_size = dfd_ko_cfg_get_item(key); + if (p_eeprom_size == NULL) { + DFD_SFF_DEBUG(DBG_VERBOSE, "get sff polling size error, maybe unsupport sff polling. key:0x%x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + + return *p_eeprom_size; +} + +ssize_t dfd_get_sff_polling_data(unsigned int sff_index, char *buf, loff_t offset, size_t count) +{ + int key, eeprom_size; + ssize_t rd_len; + loff_t rd_addr; + char *logic_dev_path; + int *p_base_addr; + + if(buf == NULL || offset < 0 || count <= 0) { + DFD_SFF_DEBUG(DBG_ERROR, "params error, offset:%lld, count:%lu.\n", offset, count); + return -DFD_RV_INVALID_VALUE; + } + + eeprom_size = dfd_get_sff_polling_size(); + if (eeprom_size < 0) { + DFD_SFF_DEBUG(DBG_ERROR, "get sff polling size error, ret:%d.\n", eeprom_size); + return -DFD_RV_DEV_NOTSUPPORT; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_SFF_POLLING_DATA_BASE_ADDR, sff_index, 0); + p_base_addr = dfd_ko_cfg_get_item(key); + if (p_base_addr == NULL) { + DFD_SFF_DEBUG(DBG_ERROR, "get sff polling data base addr error, sff_index:%u, key:0x%x.\n", + sff_index, key); + return -DFD_RV_DEV_NOTSUPPORT; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_SFF_POLLING_LOGIC_DEV_PATH, sff_index, 0); + logic_dev_path = dfd_ko_cfg_get_item(key); + if (logic_dev_path == NULL) { + DFD_SFF_DEBUG(DBG_ERROR, "get sff polling logic device path error, key=0x%08x.\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + + DFD_SFF_DEBUG(DBG_VERBOSE, "sff:%u, eeprom size:0x%x, base addr:0x%x, path:%s, offset:0x%llx, rd_len:%lu.\n", + sff_index, eeprom_size, *p_base_addr, logic_dev_path, offset, count); + + if (offset >= eeprom_size) { + DFD_SFF_DEBUG(DBG_VERBOSE, "offset:0x%llx, eeprom size:0x%x, EOF.\n", + offset, eeprom_size); + return 0; + } + + if (offset + count > eeprom_size) { + DFD_SFF_DEBUG(DBG_VERBOSE, "read count out of range. input len:%lu, read len:%llu.\n", + count, eeprom_size - offset); + count = eeprom_size - offset; + } + + rd_addr = *p_base_addr + offset; + rd_len = dfd_ko_read_file(logic_dev_path, rd_addr, buf, count); + if (rd_len < 0) { + DFD_SFF_DEBUG(DBG_ERROR, "read sff polling data failed, loc:%s, offset:0x%llx, rd_len:%lu, ret:%ld,\n", + logic_dev_path, rd_addr, count, rd_len); + } else { + DFD_SFF_DEBUG(DBG_VERBOSE, "read sff polling data success, loc:%s, offset:0x%llx, rd_len:%lu, rd_len:%ld,\n", + logic_dev_path, rd_addr, count, rd_len); + } + + return rd_len; +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_sfpbase.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_sfpbase.c new file mode 100644 index 000000000000..4084edcdab79 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_sfpbase.c @@ -0,0 +1,986 @@ +/* + * Copyright(C) 2001-2012 Ruijie Network. All rights reserved. + */ + +#include +#include + +#include "./include/dfd_module.h" +#include "./include/dfd_cfg_adapter.h" +#include "../rg_dev_sysfs/include/rg_sysfs_common.h" +#include "./include/dfd_sfpparse.h" + +#define DFD_TEMP_BUFF_SIZE (128) +#define DFD_SFP_OPTOE_ADDR (0x50) +#define DFD_SFP_PAGE_SIZE (256) +#define DFD_FPATH_MAX_LEN (64) +#define DFD_QSFP_DOM_SIZE (8) +#define SFP_DIAGNOSTIC_MONITORING_TYPE_ADDR (92) + +/* sfp cable length */ +static char *g_sfp_cable_length_type[] = { + "LengthSMFkm-UnitsOfKm", /* byte14 */ + "LengthSMF(UnitsOf100m)", /* byte15 */ + "Length50um(UnitsOf10m)", /* byte16 */ + "Length62.5um(UnitsOfm)", /* byte17 */ + "LengthCable(UnitsOfm)", /* byte18 */ + "LengthOM3(UnitsOf10m)", /* byte19 */ +}; + +/* qsfp cable length */ +static char *g_qsfp_cable_length_type[] = { + "Length(km)", /* byte142 */ + "Length OM3(2m)", /* byte143 */ + "Length OM2(m)", /* byte144 */ + "Length OM1(m)", /* byte145 */ + "Length Cable Assembly(m)", /* byte146 */ +}; + +/* qsfp sepecification compliance*/ +static struct sff_e2_spec_comp_s g_qsfp_spec_comp[] = { + {0, "10/40G Ethernet Compliance Code", qsfp_comp_10_ethcc_bitmap}, /* byte131 */ + {1, "SONET Compliance codes" , qsfp_comp_socc_bitmap}, /* byte132 */ + {2, "SAS/SATA compliance codes", qsfp_comp_sscc_bitmap}, /* byte133 */ + {3, "Gigabit Ethernet Compliant codes", qsfp_comp_gethcc_bitmap}, /* byte134 */ + {4, "Fibre Channel link length", qsfp_comp_fcll_bitmap}, /* byte135 */ + {5, "Transmitter Technology", qsfp_comp_tt_bitmap}, /* byte136 */ + {6, "Fibre Channel transmission media", qsfp_comp_fctm_bitmap}, /* byte137 */ + {7, "Fibre Channel Speed", qsfp_comp_fcs_bitmap}, /* byte138 */ +}; + +/* sfp sepecification compliance*/ +static struct sff_e2_spec_comp_s g_sfp_spec_comp[] = { + {0, "10GEthernetComplianceCode", sfp_comp_10_ethcc_bitmap}, /* byte3 */ + {0, "InfinibandComplianceCode" , sfp_comp_infcc_bitmap}, /* byte3 */ + {1, "ESCONComplianceCodes", sfp_comp_escc_bitmap}, /* byte4 */ + {1, "SONETComplianceCodes", sfp_comp_socc1_bitmap}, /* byte4 */ + {2, "SONETComplianceCodes", sfp_comp_socc2_bitmap}, /* byte5 */ + {3, "EthernetComplianceCodes", sfp_comp_ethcc_bitmap}, /* byte6 */ + {4, "FibreChannelLinkLength", sfp_comp_fcll_bitmap}, /* byte7 */ + {4, "FibreChannelTechnology", sfp_comp_fct1_bitmap}, /* byte7 */ + {5, "FibreChannelTechnology", sfp_comp_fct2_bitmap}, /* byte8 */ + {5, "SFP+CableTechnology", sfp_comp_sfpct_bitmap}, /* byte8 */ + {6, "FibreChannelTransmissionMedia", sfp_comp_fctm_bitmap}, /* byte9 */ + {7, "FibreChannelSpeed", sfp_comp_fcs_bitmap}, /* byte10 */ +}; + +static void dump_date(unsigned char *data, struct rj_eeprom_parse_t *eep_parse) +{ + int i = 0; + DFD_SFF_DEBUG(DBG_VERBOSE, "eeprom return data, addr 0x%x, offset %d, suboff %d, size %d, type %d:\n", + eep_parse->addr, eep_parse->offset, eep_parse->sub_offset, + eep_parse->size, eep_parse->type); + for (i = 0; i < eep_parse->size; i++) { + DFD_SFF_DEBUG(DBG_VERBOSE, " data[%d]=0x%x=\n", i, data[i]); + } +} + +static int twos_comp(int num, int bits) +{ + if ((num & (1 << (bits - 1))) != 0) { + num = num - (1 << bits); + } + return num; +} + +static int read_optoe_eeprom_data(const unsigned int sfp_bus, + const unsigned char sfp_addr, + const unsigned int sfp_offset, char *buf, int read_bytes) +{ + char filename[DFD_FPATH_MAX_LEN]; + int ret; + + memset(filename, 0, sizeof(filename)); + snprintf(filename, sizeof(filename), "/sys/bus/i2c/devices/%d-%04x/eeprom",sfp_bus,sfp_addr); + DFD_SFF_DEBUG(DBG_VERBOSE, "read optoe eeprom, fpath:%s, offset:0x%x, read bytes:%d.\n", filename, sfp_offset, read_bytes); + ret = dfd_ko_read_file(filename, sfp_offset, buf, read_bytes); + if ( ret < 0) { + DFD_SFF_DEBUG(DBG_ERROR, "read optoe eeprom error.\n"); + return ret; + } + DFD_SFF_DEBUG(DBG_VERBOSE, " read_optoe_eeprom_data ok.\n"); + + return ret; +} + +static int read_one_eeprom_data(const unsigned int sfp_bus, + const unsigned char sfp_addr, + const unsigned int sfp_offset) +{ + char filename[DFD_FPATH_MAX_LEN]; + unsigned char data; + int ret; + + memset(filename, 0, sizeof(filename)); + snprintf(filename, sizeof(filename), "/sys/bus/i2c/devices/%d-%04x/eeprom",sfp_bus,sfp_addr); + DFD_SFF_DEBUG(DBG_VERBOSE, "read one eeprom date, fpath:%s, offset:0x%x.\n", filename, sfp_offset); + ret = dfd_ko_read_file(filename, sfp_offset, &data, 1); + if ( ret < 0) { + DFD_SFF_DEBUG(DBG_ERROR, "read one eeprom error.\n"); + return ret; + } + DFD_SFF_DEBUG(DBG_VERBOSE, " read_one_eeprom_data get data 0x%x\n", data); + + return data; + +} + +static int get_calibration_type(const unsigned int sfp_bus, + rj_dom_type_t dom_type) +{ + int calb_type; + int tmp_data; + + if (dom_type == DOM_SFF8436) { + calb_type = 1; + } else { + tmp_data = read_one_eeprom_data(sfp_bus, DFD_SFP_OPTOE_ADDR, SFP_DIAGNOSTIC_MONITORING_TYPE_ADDR); + if ((tmp_data>>5)&1) { + calb_type = 1; + } else if ((tmp_data>>4)&1) { + calb_type = 2; + } else { + calb_type = 0; + } + } + return calb_type; +} + +static int get_dom_ext_calibration_constants(rj_dom_ext_calibration_t dom_ext_type) +{ + int off; + + switch (dom_ext_type) { + case EXTCALB_RX_PWR_4: + off = 56; + break; + case EXTCALB_RX_PWR_3: + off = 60; + break; + case EXTCALB_RX_PWR_2: + off = 64; + break; + case EXTCALB_RX_PWR_1: + off = 68; + break; + case EXTCALB_RX_PWR_0: + off = 72; + break; + case EXTCALB_TX_I_Slope: + off = 76; + break; + case EXTCALB_TX_I_Offset: + off = 78; + break; + case EXTCALB_TX_PWR_Slope: + off = 80; + break; + case EXTCALB_TX_PWR_Offset: + off = 82; + break; + case EXTCALB_T_Slope: + off = 84; + break; + case EXTCALB_T_Offset: + off = 86; + break; + case EXTCALB_V_Slope: + off = 88; + break; + case EXTCALB_V_Offset: + off = 90; + break; + default: + off = 0; + DFD_SFF_DEBUG(DBG_ERROR, "Not support type dom_ext_type\n"); + break; + } + + return off; +} + +static void get_div_mod_4(int idata, int divdata, + int *out_div, int *out_mod) +{ + *out_div = idata/divdata; + *out_mod = (idata*10000/divdata)%10000; +} + +static void power_in_dbm_str(int result, char *out_buf, int buf_len) +{ + int div_result, mod_result; + + if (result == 0) { + snprintf(out_buf, buf_len, "%s\n", "-inf"); + } else if (result < 0) { + snprintf(out_buf, buf_len, "%s\n", "NaN"); + } else { + get_div_mod_4(result, 10000, &div_result, &mod_result); + snprintf(out_buf, buf_len, "%d.%04d\n", div_result, mod_result); + } +} + +static int calc_rx_power_value(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + int msb, int lsb, int *result) +{ + int off, value; + unsigned int cal_type; + int rx_pwr_byte0, rx_pwr_byte1, rx_pwr_byte2, rx_pwr_byte3; + int rx_pwr_4, rx_pwr_3, rx_pwr_2, rx_pwr_1, rx_pwr_0, rx_pwr; + int bus_addr; + + bus_addr = DFD_SFP_OPTOE_ADDR; + cal_type = get_calibration_type(sfp_bus, eep_parse->dom_type); + value = (msb << 8) | (lsb & 0xff); + + if (cal_type == 1) { + /* Internal Calibration */ + *result = value; + return DFD_RV_OK; + } + if (cal_type == 2) { + /* XXX: External Calibration + # RX_PWR(uW) = RX_PWR_4 * RX_PWR_AD + + # RX_PWR_3 * RX_PWR_AD + + # RX_PWR_2 * RX_PWR_AD + + # RX_PWR_1 * RX_PWR_AD + + # RX_PWR(0)*/ + off = get_dom_ext_calibration_constants(EXTCALB_RX_PWR_4); + if (eep_parse->dom_type == DOM_SFF8472) { + off += DFD_SFP_PAGE_SIZE; + } + rx_pwr_byte3 = read_one_eeprom_data(sfp_bus, bus_addr, off); + rx_pwr_byte2 = read_one_eeprom_data(sfp_bus, bus_addr, off+1); + rx_pwr_byte1 = read_one_eeprom_data(sfp_bus, bus_addr, off+2); + rx_pwr_byte0 = read_one_eeprom_data(sfp_bus, bus_addr, off+3); + rx_pwr_4 = (rx_pwr_byte3 << 24) | (rx_pwr_byte2 << 16) | (rx_pwr_byte1 << 8) | (rx_pwr_byte0 & 0xff); + + off = get_dom_ext_calibration_constants(EXTCALB_RX_PWR_3); + if (eep_parse->dom_type == DOM_SFF8472) { + off += DFD_SFP_PAGE_SIZE; + } + rx_pwr_byte3 = read_one_eeprom_data(sfp_bus, bus_addr, off); + rx_pwr_byte2 = read_one_eeprom_data(sfp_bus, bus_addr, off+1); + rx_pwr_byte1 = read_one_eeprom_data(sfp_bus, bus_addr, off+2); + rx_pwr_byte0 = read_one_eeprom_data(sfp_bus, bus_addr, off+3); + rx_pwr_3 = (rx_pwr_byte3 << 24) | (rx_pwr_byte2 << 16) | (rx_pwr_byte1 << 8) | (rx_pwr_byte0 & 0xff); + + off = get_dom_ext_calibration_constants(EXTCALB_RX_PWR_2); + if (eep_parse->dom_type == DOM_SFF8472) { + off += DFD_SFP_PAGE_SIZE; + } + rx_pwr_byte3 = read_one_eeprom_data(sfp_bus, bus_addr, off); + rx_pwr_byte2 = read_one_eeprom_data(sfp_bus, bus_addr, off+1); + rx_pwr_byte1 = read_one_eeprom_data(sfp_bus, bus_addr, off+2); + rx_pwr_byte0 = read_one_eeprom_data(sfp_bus, bus_addr, off+3); + rx_pwr_2 = (rx_pwr_byte3 << 24) | (rx_pwr_byte2 << 16) | (rx_pwr_byte1 << 8) | (rx_pwr_byte0 & 0xff); + + off = get_dom_ext_calibration_constants(EXTCALB_RX_PWR_1); + if (eep_parse->dom_type == DOM_SFF8472) { + off += DFD_SFP_PAGE_SIZE; + } + rx_pwr_byte3 = read_one_eeprom_data(sfp_bus, bus_addr, off); + rx_pwr_byte2 = read_one_eeprom_data(sfp_bus, bus_addr, off+1); + rx_pwr_byte1 = read_one_eeprom_data(sfp_bus, bus_addr, off+2); + rx_pwr_byte0 = read_one_eeprom_data(sfp_bus, bus_addr, off+3); + rx_pwr_1 = (rx_pwr_byte3 << 24) | (rx_pwr_byte2 << 16) | (rx_pwr_byte1 << 8) | (rx_pwr_byte0 & 0xff); + + off = get_dom_ext_calibration_constants(EXTCALB_RX_PWR_0); + if (eep_parse->dom_type == DOM_SFF8472) { + off += DFD_SFP_PAGE_SIZE; + } + rx_pwr_byte3 = read_one_eeprom_data(sfp_bus, bus_addr, off); + rx_pwr_byte2 = read_one_eeprom_data(sfp_bus, bus_addr, off+1); + rx_pwr_byte1 = read_one_eeprom_data(sfp_bus, bus_addr, off+2); + rx_pwr_byte0 = read_one_eeprom_data(sfp_bus, bus_addr, off+3); + rx_pwr_0 = (rx_pwr_byte3 << 24) | (rx_pwr_byte2 << 16) | (rx_pwr_byte1 << 8) | (rx_pwr_byte0 & 0xff); + + rx_pwr = (rx_pwr_4 * value) + (rx_pwr_3 * value) + (rx_pwr_2 * value) + (rx_pwr_1 * value) + rx_pwr_0; + + *result = rx_pwr; + return DFD_RV_OK; + } + return -DFD_RV_TYPE_ERR; +} + +static void sfp_calc_rx_power(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len) +{ + int ret, result; + + ret = calc_rx_power_value(sfp_bus, eep_parse, data[0], data[1], &result); + if(ret < 0) { + snprintf(out_buf, buf_len, "%s\n", "Unknown"); + return ; + } + power_in_dbm_str(result, out_buf, buf_len); + return ; +} + +static void qsfp_calc_rx_power(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len) +{ + int i, ret, result, div_result, mod_result ; + + for (i = 0; i < DFD_QSFP_DOM_SIZE; i += 2) { + ret = calc_rx_power_value(sfp_bus, eep_parse, data[i], data[i + 1], &result); + if (ret < 0) { + snprintf(out_buf, buf_len, "%srx%dpower: Unknown\n", out_buf, (i/2 + 1)); + } else { + if (result == 0) { + snprintf(out_buf, buf_len, "%srx%dpower: -inf\n", out_buf, (i/2 + 1)); + } else if (result < 0) { + snprintf(out_buf, buf_len, "%srx%dpower: NaN\n", out_buf, (i/2 + 1)); + } else { + get_div_mod_4(result, 10000, &div_result, &mod_result); + snprintf(out_buf, buf_len, "%srx%dpower: %d.%04d\n", out_buf, (i/2 + 1), div_result, mod_result); + } + } + } + return ; + +} + +static int calc_tx_power_value(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + int msb, int lsb, int *result) +{ + int off, value; + unsigned int cal_type; + int msb_tx_pwr, lsb_tx_pwr, tx_pwr_slope, tx_pwr_offset; + int bus_addr; + + bus_addr = DFD_SFP_OPTOE_ADDR; + cal_type = get_calibration_type(sfp_bus, eep_parse->dom_type); + value = (msb << 8) | (lsb & 0xff); + DFD_SFF_DEBUG(DBG_VERBOSE, "calc_tx_power. sfp_bus:%d, value:0x%x, cal_type:%d.\n", sfp_bus, value, cal_type); + + if (cal_type == 1) { + *result = value; + return DFD_RV_OK; + } + if (cal_type == 2) { + /* XXX: TX_PWR(uW) = TX_PWR_Slope * TX_PWR_AD + TX_PWR_Offset */ + off = get_dom_ext_calibration_constants(EXTCALB_TX_PWR_Slope); + if (eep_parse->dom_type == DOM_SFF8472) { + off += DFD_SFP_PAGE_SIZE; + } + msb_tx_pwr = read_one_eeprom_data(sfp_bus, bus_addr, off); + lsb_tx_pwr = read_one_eeprom_data(sfp_bus, bus_addr, off+1); + tx_pwr_slope = (msb_tx_pwr << 8) | (lsb_tx_pwr & 0xff); + + off = get_dom_ext_calibration_constants(EXTCALB_TX_PWR_Offset); + if (eep_parse->dom_type == DOM_SFF8472) { + off += DFD_SFP_PAGE_SIZE; + } + msb_tx_pwr = read_one_eeprom_data(sfp_bus, bus_addr, off); + lsb_tx_pwr = read_one_eeprom_data(sfp_bus, bus_addr, off+1); + tx_pwr_offset = (msb_tx_pwr << 8) | (lsb_tx_pwr & 0xff); + tx_pwr_offset = twos_comp(tx_pwr_offset, 16); + + *result = tx_pwr_slope * value + tx_pwr_offset; + return DFD_RV_OK; + } + return -DFD_RV_TYPE_ERR; +} + +static void sfp_calc_tx_power(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len) +{ + int ret, result; + + ret = calc_tx_power_value(sfp_bus, eep_parse, data[0], data[1], &result); + if(ret < 0) { + snprintf(out_buf, buf_len, "%s\n", "Unknown"); + return ; + } + power_in_dbm_str(result, out_buf, buf_len); + return ; +} + +static void qsfp_calc_tx_power(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len) +{ + int i, ret, result, div_result, mod_result ; + + for (i = 0; i < DFD_QSFP_DOM_SIZE; i += 2) { + ret = calc_tx_power_value(sfp_bus, eep_parse, data[i], data[i + 1], &result); + if (ret < 0) { + snprintf(out_buf, buf_len, "%stx%dpower: Unknown\n", out_buf, (i/2 + 1)); + } else { + if (result == 0) { + snprintf(out_buf, buf_len, "%stx%dpower: -inf\n", out_buf, (i/2 + 1)); + } else if (result < 0) { + snprintf(out_buf, buf_len, "%stx%dpower: NaN\n", out_buf, (i/2 + 1)); + } else { + get_div_mod_4(result, 10000, &div_result, &mod_result); + snprintf(out_buf, buf_len, "%stx%dpower: %d.%04d\n", out_buf, (i/2 + 1), div_result, mod_result); + } + } + } + return ; +} + +static int calc_bias_value(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + int msb, int lsb, int *div_result, int *mod_result) +{ + int off; + unsigned int cal_type, result; + int msb_i, lsb_i, i_slope, i_offset; + int bus_addr; + + bus_addr = DFD_SFP_OPTOE_ADDR; + cal_type = get_calibration_type(sfp_bus, eep_parse->dom_type); + result = (msb << 8) | (lsb & 0xff); + + if (cal_type == 1) { + /* Internal Calibration */ + get_div_mod_4(result, 500, div_result, mod_result); + return DFD_RV_OK; + } + if (cal_type == 2) { + /* XXX: External Calibration */ + /* I(uA) = I_Slope * I_AD + I_Offset */ + off = get_dom_ext_calibration_constants(EXTCALB_TX_I_Slope); + if (eep_parse->dom_type == DOM_SFF8472) { + off += DFD_SFP_PAGE_SIZE; + } + msb_i = read_one_eeprom_data(sfp_bus, bus_addr, off); + lsb_i = read_one_eeprom_data(sfp_bus, bus_addr, off+1); + i_slope = (msb_i << 8) | (lsb_i & 0xff); + + off = get_dom_ext_calibration_constants(EXTCALB_TX_I_Offset); + if (eep_parse->dom_type == DOM_SFF8472) { + off += DFD_SFP_PAGE_SIZE; + } + msb_i = read_one_eeprom_data(sfp_bus, bus_addr, off); + lsb_i = read_one_eeprom_data(sfp_bus, bus_addr, off+1); + i_offset = (msb_i << 8) | (lsb_i & 0xff); + i_offset = twos_comp(i_offset, 16); + + result = i_slope * result + i_offset; + get_div_mod_4(result, 500, div_result, mod_result); + return DFD_RV_OK; + } + return -DFD_RV_TYPE_ERR; +} + +static void sfp_calc_tx_bias(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len) +{ + int ret, div_result, mod_result; + + ret = calc_bias_value(sfp_bus, eep_parse, data[0], data[1], &div_result, &mod_result); + if(ret < 0) { + snprintf(out_buf, buf_len, "%s\n", "Unknown"); + return ; + } + snprintf(out_buf, buf_len, "%d.%04d\n", div_result, mod_result); + return ; +} + +static void qsfp_calc_tx_bias(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len) +{ + int i, ret, div_result, mod_result; + + for (i = 0; i < DFD_QSFP_DOM_SIZE; i += 2) { + ret = calc_bias_value(sfp_bus, eep_parse, data[i], data[i + 1], &div_result, &mod_result); + if (ret < 0) { + snprintf(out_buf, buf_len, "%stx%dbias: Unknown\n", out_buf, (i/2 + 1)); + } else { + snprintf(out_buf, buf_len, "%stx%dbias: %d.%04d\n", out_buf, (i/2 + 1), div_result, mod_result); + } + } + return ; +} + +static void calc_temperature(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len) +{ + int off; + unsigned int cal_type, msb, lsb, result; + int msb_t, lsb_t, t_slope, t_offset; + int bus_addr; + int div_result, mod_result; + + bus_addr = DFD_SFP_OPTOE_ADDR; + cal_type = get_calibration_type(sfp_bus, eep_parse->dom_type); + msb = data[0]; + lsb = data[1]; + + result = (msb << 8) | (lsb & 0xff); + result = twos_comp(result, 16); + if (cal_type == 1) { + /* Internal calibration */ + get_div_mod_4(result, 256, &div_result, &mod_result); + snprintf(out_buf, buf_len, "%d.%04d\n", div_result, mod_result); + } else if (cal_type == 2) { + /* XXX:External calibration */ + /* T(C) = T_Slope * T_AD + T_Offset */ + off = get_dom_ext_calibration_constants(EXTCALB_T_Slope); + if (eep_parse->dom_type == DOM_SFF8472) { + off += DFD_SFP_PAGE_SIZE; + } + msb_t = read_one_eeprom_data(sfp_bus, bus_addr, off); + lsb_t = read_one_eeprom_data(sfp_bus, bus_addr, off+1); + t_slope = (msb_t << 8) | (lsb_t & 0xff); + + off = get_dom_ext_calibration_constants(EXTCALB_T_Offset); + if (eep_parse->dom_type == DOM_SFF8472) { + off += DFD_SFP_PAGE_SIZE; + } + msb_t = read_one_eeprom_data(sfp_bus, bus_addr, off); + lsb_t = read_one_eeprom_data(sfp_bus, bus_addr, off+1); + t_offset = (msb_t << 8) | (lsb_t & 0xff); + t_offset = twos_comp(t_offset, 16); + + result = t_slope * result + t_offset; + get_div_mod_4(result, 256, &div_result, &mod_result); + snprintf(out_buf, buf_len, "%d.%04d\n", div_result, mod_result); + } else { + snprintf(out_buf, buf_len, "%s\n", "Unknown"); + } +} + +static void calc_voltage(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len) +{ + int off; + unsigned int cal_type, msb, lsb, result; + int msb_v, lsb_v, v_slope, v_offset; + int bus_addr; + int div_result, mod_result; + + bus_addr = DFD_SFP_OPTOE_ADDR; + cal_type = get_calibration_type(sfp_bus, eep_parse->dom_type); + msb = data[0]; + lsb = data[1]; + result = (msb << 8) | (lsb & 0xff); + + if (cal_type == 1) { + /* Internal Calibration */ + get_div_mod_4(result, 10000, &div_result, &mod_result); + snprintf(out_buf, buf_len, "%d.%04d\n", div_result, mod_result); + } else if (cal_type == 2) { + /* XXX:External Calibration */ + /*V(uV) = V_Slope * VAD + V_Offset */ + off = get_dom_ext_calibration_constants(EXTCALB_V_Slope); + if (eep_parse->dom_type == DOM_SFF8472) { + off += DFD_SFP_PAGE_SIZE; + } + msb_v = read_one_eeprom_data(sfp_bus, bus_addr, off); + lsb_v = read_one_eeprom_data(sfp_bus, bus_addr, off+1); + v_slope = (msb_v << 8) | (lsb_v & 0xff); + + off = get_dom_ext_calibration_constants(EXTCALB_V_Offset); + if (eep_parse->dom_type == DOM_SFF8472) { + off += DFD_SFP_PAGE_SIZE; + } + msb_v = read_one_eeprom_data(sfp_bus, bus_addr, off); + lsb_v = read_one_eeprom_data(sfp_bus, bus_addr, off+1); + v_offset = (msb_v << 8) | (lsb_v & 0xff); + v_offset = twos_comp(v_offset, 16); + + result = v_slope * result + v_offset; + get_div_mod_4(result, 10000, &div_result, &mod_result); + snprintf(out_buf, buf_len, "%d.%04d\n", div_result, mod_result); + } else { + snprintf(out_buf, buf_len, "%s\n", "Unknown"); + } +} + +static void convert_date_to_string(unsigned char *inchar, unsigned char *outtxt) +{ + snprintf(outtxt, DFD_TEMP_BUFF_SIZE, "%s%c%c-%c%c-%c%c %c%c", + "20", inchar[0], inchar[1], inchar[2], inchar[3], + inchar[4], inchar[5], inchar[6], inchar[7]); + DFD_SFF_DEBUG(DBG_VERBOSE, "==outtxt %s\n", outtxt); +} + +static void convert_int_to_str(int idata, unsigned char *outtxt) +{ + snprintf(outtxt, DFD_TEMP_BUFF_SIZE, "%d", idata); + DFD_SFF_DEBUG(DBG_VERBOSE, "==outtxt %s\n", outtxt); +} + +static void convert_hex_to_str(unsigned char *inchar, unsigned int len, unsigned char *outtxt, int need_spc) +{ + unsigned char hbit, lbit; + unsigned int i, cnt; + cnt = 0; + for (i=0; i < len; i++) { + hbit = (*(inchar+i)&0xf0)>>4; + lbit = *(inchar+i)&0x0f; + if (hbit > 9) { + outtxt[cnt] = 'a'+hbit-10; + } else { + outtxt[cnt]='0'+hbit; + } + cnt++; + if (lbit > 9) { + outtxt[cnt]='a'+lbit-10; + } else{ + outtxt[cnt]='0'+lbit; + } + cnt++; + if (need_spc && i != len-1) { + outtxt[cnt]='-'; + cnt++; + } + } + outtxt[cnt] = 0; + + DFD_SFF_DEBUG(DBG_VERBOSE, "hex_to_str outtxt %s\n", outtxt); +} + +static bool test_bitmapvalue(unsigned char inchar, + struct rj_e2_enum_type_s *enum_str, int setoff) +{ + if (strcmp(enum_str[setoff].key, "BITVALUE") == 0) { + return true; + } + if (strcmp(enum_str[setoff].key, "NULL") == 0) { + return false; + } + if (((inchar >> setoff) & 1) == 1) { + return true; + } else { + return false; + } +} + +static void convert_strsplit(char *ibuf, char split_c, char *out_buf_1, char *out_buf_2) +{ + int i; + char *out_buf_p; + + out_buf_p = out_buf_1; + for (i = 0; i < strlen(ibuf); i++) { + if (ibuf[i] == split_c) { + out_buf_p = out_buf_2; + continue; + } + *out_buf_p = ibuf[i]; + out_buf_p++; + } +} + +static void convert_bitmapdate_to_string(unsigned char inchar, + struct rj_e2_enum_type_s *enum_str, char *buf, int buf_len) +{ + char tmp_buf[DFD_TEMP_BUFF_SIZE]; + char split_buf_1[DFD_TEMP_BUFF_SIZE]; + char split_buf_2[DFD_TEMP_BUFF_SIZE]; + char *tmp_buf_p; + int i; + + memset(tmp_buf, 0, sizeof(tmp_buf)); + memset(split_buf_1, 0, sizeof(split_buf_1)); + memset(split_buf_2, 0, sizeof(split_buf_2)); + tmp_buf_p = tmp_buf; + for (i = 0; i < 8; i++) { + if (test_bitmapvalue(inchar, enum_str, i) && ((tmp_buf_p-tmp_buf) < DFD_TEMP_BUFF_SIZE)) { + if (tmp_buf_p != tmp_buf) { + snprintf(tmp_buf_p, 2, "%c", ','); + tmp_buf_p++; + } + if (strcmp(enum_str[i].key, "BITVALUE") == 0) { + convert_strsplit(enum_str[i].value, ':', split_buf_1, split_buf_2); + DFD_SFF_DEBUG(DBG_VERBOSE, "bit 0 value %s , bit 1 value %s \n", split_buf_1, split_buf_2); + if ((inchar>>i & 1) == 0) { + snprintf(tmp_buf_p, strlen(split_buf_1)+1, "%s", split_buf_1); + tmp_buf_p += strlen(split_buf_1); + } else { + snprintf(tmp_buf_p, strlen(split_buf_2)+1, "%s", split_buf_2); + tmp_buf_p += strlen(split_buf_2); + } + } else { + snprintf(tmp_buf_p, strlen(enum_str[i].value)+1, "%s", enum_str[i].value); + tmp_buf_p += strlen(enum_str[i].value); + } + DFD_SFF_DEBUG(DBG_VERBOSE, "====tmp_buf %s \n", tmp_buf); + break; + } + } + snprintf(buf, buf_len, "%s\n", tmp_buf); +} + +static bool eep_parse_decode(struct rj_eeprom_parse_t *eep_parse, unsigned char *data, char *buf, int buf_len) +{ + bool ret; + unsigned char tmp; + struct rj_e2_enum_type_s *tmp_enum_str; + char out_buf[DFD_TEMP_BUFF_SIZE]; + int i; + + ret = true; + memset(out_buf, 0, sizeof(out_buf)); + dump_date(data, eep_parse); + switch (eep_parse->type) { + case E2_STR : + snprintf(buf, buf_len, "%s\n", data); + break; + case E2_ENUM: + convert_hex_to_str(data, eep_parse->size, out_buf, false); + if (eep_parse->enum_str != NULL) { + snprintf(buf, buf_len, "%s\n", "Unknown"); + tmp_enum_str = eep_parse->enum_str; + i = 0; + while (strcmp(tmp_enum_str->key, "NULL") != 0 && i < 100) { + DFD_SFF_DEBUG(DBG_VERBOSE, " key =%s, out_buf %s", tmp_enum_str->key, out_buf); + if (strcmp(tmp_enum_str->key, out_buf) == 0) { + DFD_SFF_DEBUG(DBG_VERBOSE, "====mach==\n"); + snprintf(buf, buf_len, "%s\n", tmp_enum_str->value); + break; + } + i++; + tmp_enum_str++; + } + } else { + snprintf(buf, buf_len, "0x%s\n", out_buf); + } + break; + case E2_INT: + convert_int_to_str(data[0], out_buf); + snprintf(buf, buf_len, "%s\n", out_buf); + break; + case E2_HEX: + convert_hex_to_str(data, eep_parse->size, out_buf, true); + snprintf(buf, buf_len, "%s\n", out_buf); + break; + case E2_DATE: + convert_date_to_string(data, out_buf); + snprintf(buf, buf_len, "%s\n", out_buf); + break; + case E2_BITVALUE: + tmp = data[0]; + if (((tmp >> eep_parse->sub_offset) & 1) == 1) { + snprintf(buf, buf_len, "1\n"); + } else { + snprintf(buf, buf_len, "0\n"); + } + break; + case E2_BITVALUE4: + tmp = data[0]; + if (((tmp >> eep_parse->sub_offset) & 1) == 1) { + snprintf(buf, buf_len, "1\n"); + } else { + snprintf(buf, buf_len, "0\n"); + } + break; + case E2_BITMAP: + tmp = data[0]; + if (eep_parse->enum_str != NULL) { + convert_bitmapdate_to_string(tmp, eep_parse->enum_str, buf, buf_len); + } else { + snprintf(buf, buf_len, "0x%x\n", tmp); + } + break; + default: + ret = false; + DFD_SFF_DEBUG(DBG_ERROR, "Not support type %d \n", eep_parse->type); + break; + } + return ret; +} + +static void sfp_cable_length_display(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len) +{ + int i, c_flag; + + if (eep_parse->size <0 || eep_parse->size > ARRAY_SIZE(g_sfp_cable_length_type)) { + DFD_SFF_DEBUG(DBG_ERROR, "size error. sfp_bus: %d, eeprom parse size:%d.\n", sfp_bus, eep_parse->size); + snprintf(out_buf, buf_len, "%s\n", "Unknown"); + return ; + } + + c_flag = 0; + for(i = 0; i < eep_parse->size; i++) { + if(data[i] != 0) { + c_flag = 1; + snprintf(out_buf, buf_len, "%s%s: %d\n", out_buf, g_sfp_cable_length_type[i], data[i]); + } + } + + if (c_flag == 0) { + snprintf(out_buf, buf_len, "%s\n", "Unspecified"); + } + + return ; +} + +static void qsfp_cable_length_display(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len) +{ + int i, c_flag; + + if (eep_parse->size <0 || eep_parse->size > ARRAY_SIZE(g_qsfp_cable_length_type)) { + DFD_SFF_DEBUG(DBG_ERROR, "size error. sfp_bus: %d, eeprom parse size:%d.\n", sfp_bus, eep_parse->size); + snprintf(out_buf, buf_len, "%s\n", "Unknown"); + return ; + } + c_flag = 0; + for(i = 0; i < eep_parse->size; i++) { + if(data[i] != 0) { + c_flag = 1; + snprintf(out_buf, buf_len, "%s%s: %d\n", out_buf, g_qsfp_cable_length_type[i], data[i]); + } + } + if (c_flag == 0) { + snprintf(out_buf, buf_len, "%s\n", "Unspecified"); + } + return ; +} + +static void sfp_spec_comp_display(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len) +{ + int i, s_flag, reg_offset; + int spec_comp_len; + char buf_tmp[DFD_TEMP_BUFF_SIZE]; + + spec_comp_len = ARRAY_SIZE(g_sfp_spec_comp); + s_flag = 0; + for(i = 0; i < spec_comp_len; i++) { + reg_offset = g_sfp_spec_comp[i].offset; + if (reg_offset < 0 || reg_offset >= eep_parse->size ||g_sfp_spec_comp[i].attr_value == NULL ) { + DFD_SFF_DEBUG(DBG_ERROR, "g_qsfp_spec_comp config error. sfp_bus: %d, g_qsfp_spec_comp index:%d, offset:%d, eeprom parse size:%d.\n", + sfp_bus, i, reg_offset, eep_parse->size); + continue; + } + if(data[reg_offset] != 0) { + memset(buf_tmp, 0, sizeof(buf_tmp)); + convert_bitmapdate_to_string(data[reg_offset], g_sfp_spec_comp[i].attr_value, buf_tmp, sizeof(buf_tmp)); + if (strcmp(buf_tmp, "\n") == 0) { + DFD_SFF_DEBUG(DBG_WARN, "qsfp sepecification_compliance.value reserved. sfp_bus:%d, reg offset:%d, value:0x%x\n", + sfp_bus, eep_parse->addr + i, data[i]); + continue; + } + s_flag = 1; + snprintf(out_buf, buf_len, "%s%s: %s", out_buf, g_sfp_spec_comp[i].attr_name, buf_tmp); + } + } + if (s_flag == 0) { + snprintf(out_buf, buf_len, "%s\n", "Unspecified"); + } + return ; +} + +static void qsfp_spec_comp_display(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len) +{ + int i, s_flag, reg_offset; + int spec_comp_len; + char buf_tmp[DFD_TEMP_BUFF_SIZE]; + + spec_comp_len = ARRAY_SIZE(g_qsfp_spec_comp); + s_flag = 0; + for(i = 0; i < spec_comp_len; i++) { + reg_offset = g_qsfp_spec_comp[i].offset; + if (reg_offset < 0 || reg_offset >= eep_parse->size ||g_qsfp_spec_comp[i].attr_value == NULL ) { + DFD_SFF_DEBUG(DBG_ERROR, "g_qsfp_spec_comp config error. sfp_bus: %d, g_qsfp_spec_comp index:%d, offset:%d, eeprom parse size:%d.\n", + sfp_bus, i, reg_offset, eep_parse->size); + continue; + } + if(data[reg_offset] != 0) { + memset(buf_tmp, 0, sizeof(buf_tmp)); + convert_bitmapdate_to_string(data[reg_offset], g_qsfp_spec_comp[i].attr_value, buf_tmp, sizeof(buf_tmp)); + if (strcmp(buf_tmp, "\n") == 0) { + DFD_SFF_DEBUG(DBG_WARN, "qsfp sepecification_compliance.value reserved. sfp_bus:%d, reg offset:%d, value:0x%x\n", + sfp_bus, eep_parse->addr + i, data[i]); + continue; + } + s_flag = 1; + snprintf(out_buf, buf_len, "%s%s: %s", out_buf, g_qsfp_spec_comp[i].attr_name, buf_tmp); + } + } + if (s_flag == 0) { + snprintf(out_buf, buf_len, "%s\n", "Unspecified"); + } + return ; +} + +ssize_t sfp_show_atrr(int sfp_bus, int sfp_mode, const char *attr_name, char *buf, int buf_len) +{ + struct rj_eeprom_parse_t *eep_parse; + unsigned char data[DFD_TEMP_BUFF_SIZE]; + int i, isqsfp, ret; + char *buf_start; + + if(!attr_name || !buf || buf_len <=0 ) { + DFD_SFF_DEBUG(DBG_ERROR, "param error. attr_name or buf is NULL. sfp_bus:%d,buf_len:%d\n", sfp_bus, buf_len); + return -DFD_RV_INVALID_VALUE; + } + eep_parse = NULL; + if (sfp_mode == RG_SFF_SPEED_100GE) { /* is sff8436 */ + isqsfp = true; + for (i = 0; i < sizeof(ssf8436_interface_id)/sizeof(struct rj_eeprom_parse_t); i++) { + if (strcmp(ssf8436_interface_id[i].attr_name, attr_name) == 0) { + DFD_SFF_DEBUG(DBG_VERBOSE, "match attribute.sfp_bus:%d, speed mode:%d, attr_name:%s.\n", sfp_bus, sfp_mode, attr_name); + eep_parse = &ssf8436_interface_id[i]; + break; + } + } + } else if (sfp_mode == RG_SFF_SPEED_25GE) { + isqsfp = false; + for (i = 0; i < sizeof(ssf8472_interface_id)/sizeof(struct rj_eeprom_parse_t); i++) { + if (strcmp(ssf8472_interface_id[i].attr_name, attr_name) == 0) { + DFD_SFF_DEBUG(DBG_VERBOSE, "match attribute.sfp_bus:%d, speed mode:%d, attr_name:%s.\n", sfp_bus, sfp_mode, attr_name); + eep_parse = &ssf8472_interface_id[i]; + break; + } + } + } else { + DFD_SFF_DEBUG(DBG_ERROR, "sfp attrname:%s, sfp mode:%d, don't support.\n", attr_name, sfp_mode); + return -DFD_RV_DEV_NOTSUPPORT; + } + + if (eep_parse == NULL) { + DFD_SFF_DEBUG(DBG_ERROR, "not define attr(%s) error.\n", attr_name); + return -DFD_RV_NODE_FAIL; + } + if (eep_parse->size > sizeof(data) ) { + DFD_SFF_DEBUG(DBG_ERROR, "date length error.need size:%d, date size:%lud.\n", eep_parse->size, sizeof(data)); + return -DFD_RV_INVALID_VALUE; + } + memset(data, 0, sizeof(data)); + buf_start = buf; + if (eep_parse->type != E2_BITVALUE4) { + ret = read_optoe_eeprom_data(sfp_bus, eep_parse->addr, eep_parse->offset, data, eep_parse->size); + dump_date(data, eep_parse); + if(ret < 0) { + DFD_SFF_DEBUG(DBG_ERROR, "read eeprom error.\n"); + return ret; + } + if (eep_parse->type == E2_FUNC) { + if( !eep_parse->calc_func ) { + DFD_SFF_DEBUG(DBG_ERROR, "eep_parse->calc_func is NULL.\n"); + return -DFD_RV_INVALID_VALUE; + } + eep_parse->calc_func(sfp_bus, eep_parse, data, buf, buf_len); + } else { + if (!eep_parse_decode(eep_parse, data, buf, buf_len)) { + DFD_SFF_DEBUG(DBG_ERROR, "eep_parse_decode error.\n"); + return -DFD_RV_DEV_FAIL; + } + } + } else { + /* XXX */ + for (i = 0; i < eep_parse->ext.subaddr_num; i++) { + ret = read_optoe_eeprom_data(sfp_bus, eep_parse->addr, eep_parse->ext.subaddr[i].offset, data, eep_parse->ext.subaddr[i].size); + if (ret < 0) { + DFD_SFF_DEBUG(DBG_ERROR, "read eeprom error.\n"); + return ret; + } + snprintf(buf, buf_len, "%s-%d:", eep_parse->ext.prefix, i); + eep_parse->sub_offset = eep_parse->ext.subaddr[i].sub_offset; + if (!eep_parse_decode(eep_parse, data, buf+(int)strlen(buf_start), buf_len - (int)strlen(buf_start))) { + DFD_SFF_DEBUG(DBG_ERROR, "eep_parse_decode error.\n"); + return -DFD_RV_DEV_FAIL; + } + } + buf = buf_start; + } + return (ssize_t)strlen(buf); +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_slot_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_slot_driver.c new file mode 100644 index 000000000000..f29bfc5ed9e1 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_slot_driver.c @@ -0,0 +1,81 @@ +/* + * Copyright(C) 2001-2012 Ruijie Network. All rights reserved. + */ + +#include +#include + +#include "./include/dfd_module.h" +#include "./include/dfd_cfg.h" +#include "./include/dfd_cfg_adapter.h" +#include "./include/dfd_cfg_info.h" +#include "./include/dfd_frueeprom.h" +#include "../rg_dev_sysfs/include/rg_sysfs_common.h" + +#define SLOT_SIZE (256) + +int g_dfd_slot_dbg_level = 0; +module_param(g_dfd_slot_dbg_level, int, S_IRUGO | S_IWUSR); + +int dfd_get_slot_status(unsigned int slot_index) +{ + int key, ret; + int status; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_DEV_PRESENT_STATUS, RG_MAIN_DEV_SLOT, slot_index); + ret = dfd_info_get_int(key, &status, NULL); + if (ret < 0) { + DFD_SLOT_DEBUG(DBG_ERROR, "get slot status error, key:0x%x\n",key); + return ret; + } + return status; +} + +ssize_t dfd_get_slot_status_str(unsigned int slot_index, char *buf) +{ + int ret; + if(buf == NULL) { + DFD_SLOT_DEBUG(DBG_ERROR, "params error.slot_index:%d.",slot_index); + return -DFD_RV_INVALID_VALUE; + } + ret = dfd_get_slot_status(slot_index); + if(ret < 0) { + DFD_SLOT_DEBUG(DBG_ERROR, "get slot status error,ret:%d, slot_index:%d\n", ret, slot_index); + return ret; + } + memset(buf, 0 , PAGE_SIZE); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", ret); +} + +ssize_t dfd_get_slot_info(unsigned int slot_index, uint8_t cmd, char *buf) +{ + int key, rv; + char slot_buf[SLOT_SIZE]; + dfd_i2c_dev_t *i2c_dev; + + if (buf == NULL) { + DFD_SLOT_DEBUG(DBG_ERROR, "buf is NULL, slot index:%d, cmd:%d\n", slot_index, cmd); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, PAGE_SIZE); + memset(slot_buf, 0, SLOT_SIZE); + + key = DFD_CFG_KEY(DFD_CFG_ITEM_OTHER_I2C_DEV, RG_MAIN_DEV_SLOT, slot_index); + i2c_dev = dfd_ko_cfg_get_item(key); + if (i2c_dev == NULL) { + DFD_SLOT_DEBUG(DBG_ERROR, "slot i2c dev config error, key=0x%08x\n", key); + return -DFD_RV_NODE_FAIL; + } + + rv = dfd_get_fru_board_data(i2c_dev->bus, i2c_dev->addr, cmd, slot_buf, SLOT_SIZE); + + if (rv < 0) { + DFD_SLOT_DEBUG(DBG_ERROR, "slot eeprom read failed"); + return -DFD_RV_DEV_FAIL; + } + + DFD_SLOT_DEBUG(DBG_VERBOSE, "%s\n", slot_buf); + snprintf(buf, SLOT_SIZE, "%s\n", slot_buf); + return strlen(buf); +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_syseeprom_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_syseeprom_driver.c new file mode 100644 index 000000000000..64ba725f04cb --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_syseeprom_driver.c @@ -0,0 +1,59 @@ +/* + * Copyright(C) 2001-2012 Ruijie Network. All rights reserved. + */ + +#include + +#include "./include/dfd_module.h" +#include "./include/dfd_cfg.h" +#include "./include/dfd_cfg_adapter.h" +#include "./include/dfd_tlveeprom.h" +#include "../rg_dev_sysfs/include/rg_sysfs_common.h" + +#define EEPROM_SIZE (256) + +int g_dfd_syseeprom_dbg_level = 0; +module_param(g_dfd_syseeprom_dbg_level, int, S_IRUGO | S_IWUSR); + +ssize_t dfd_get_syseeprom_info(uint8_t type, char *buf) +{ + int key, rv; + uint32_t len; + uint8_t eeprom[EEPROM_SIZE]; + uint8_t tlv_buf[EEPROM_SIZE]; + dfd_i2c_dev_t *i2c_dev; + dfd_tlv_type_t tlv_type; + + if (buf == NULL) { + DBG_SYSE2_DEBUG(DBG_ERROR, "param error. buf is NULL.\n"); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, PAGE_SIZE); + memset(eeprom, 0, EEPROM_SIZE); + memset(tlv_buf, 0, EEPROM_SIZE); + + key = DFD_CFG_KEY(DFD_CFG_ITEM_OTHER_I2C_DEV, RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE); + i2c_dev = dfd_ko_cfg_get_item(key); + if (i2c_dev == NULL) { + DBG_SYSE2_DEBUG(DBG_ERROR, "syseeprom i2c dev config error, key=0x%08x\n", key); + return -DFD_RV_NODE_FAIL; + } + rv = dfd_ko_i2c_read(i2c_dev->bus, i2c_dev->addr, 0, eeprom, EEPROM_SIZE); + + if (rv < 0) { + DBG_SYSE2_DEBUG(DBG_ERROR, "syseeprom read failed.\n"); + return -DFD_RV_DEV_FAIL; + } + + tlv_type.main_type = type; + tlv_type.ext_type = DFD_TLVINFO_EXT_TLV_TYPE_DEV_TYPE; + len = sizeof(tlv_buf); + rv = dfd_tlvinfo_get_e2prom_info(eeprom, EEPROM_SIZE, &tlv_type, tlv_buf, &len); + if( rv ) { + DBG_SYSE2_DEBUG(DBG_ERROR, "get tlv type :0x%02x error, ret:%d\n", tlv_type.main_type, rv); + return -DFD_RV_TYPE_ERR; + } + snprintf(buf, EEPROM_SIZE, "%s\n", tlv_buf); + return strlen(buf); +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cfg.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cfg.h new file mode 100644 index 000000000000..3971b524f695 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cfg.h @@ -0,0 +1,113 @@ +#ifndef __DFD_CFG_H__ +#define __DFD_CFG_H__ + +#include + +#define DFD_KO_CFG_FILE_NAME "/etc/plat_sysfs_cfg/cfg_file_name" +#define DFD_KO_CFG_FILE_DIR "/etc/plat_sysfs_cfg/" +#define DFD_PUB_CARDTYPE_FILE "/sys/module/ruijie_common/parameters/dfd_my_type" + +#define DFD_CFG_CMDLINE_MAX_LEN (256) +#define DFD_CFG_NAME_MAX_LEN (256) +#define DFD_CFG_VALUE_MAX_LEN (256) +#define DFD_CFG_STR_MAX_LEN (64) +#define DFD_CFG_CPLD_NUM_MAX (16) +#define DFD_PRODUCT_ID_LENGTH (8) +#define DFD_PID_BUF_LEN (32) +#define DFD_TEMP_NAME_BUF_LEN (32) + +#define DFD_CFG_EMPTY_VALUE (-1) +#define DFD_CFG_INVALID_VALUE (0) + +#define DFD_CFG_KEY(item, index1, index2) \ + ((((item) & 0xff) << 24) | (((index1) & 0xffff) << 8) | ((index2) & 0xff)) +#define DFD_CFG_ITEM_ID(key) (((key) >> 24) & 0xff) +#define DFD_CFG_INDEX1(key) (((key) >> 8) & 0xffff) +#define DFD_CFG_INDEX2(key) ((key)& 0xff) + +#define INDEX_NOT_EXIST (-1) +#define INDEX1_MAX (0xffff) +#define INDEX2_MAX (0xff) + +#define DFD_CFG_ITEM_ALL \ + DFD_CFG_ITEM(DFD_CFG_ITEM_NONE, "none", INDEX_NOT_EXIST, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_DEV_NUM, "dev_num", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FAN_SPEED_TOLERANCE, "fan_speed_tolerance", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FAN_SPEED_TARGET, "fan_speed_target", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FAN_DIRECTION, "fan_direction", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_LED_STATUS_DECODE, "led_status_decode", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_CPLD_LPC_DEV, "cpld_lpc_dev", INDEX1_MAX, DFD_CFG_CPLD_NUM_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_SFF_ID, "sff_id", INDEX1_MAX, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_SFF_POLLING_SIZE, "sff_polling_size", INDEX_NOT_EXIST, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_SFF_POLLING_DATA_BASE_ADDR, "sff_polling_data_base_addr", INDEX1_MAX, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_INT_END, "end_int", INDEX_NOT_EXIST, INDEX_NOT_EXIST) \ + \ + DFD_CFG_ITEM(DFD_CFG_ITEM_CPLD_MODE, "mode_cpld", INDEX1_MAX, DFD_CFG_CPLD_NUM_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_CPLD_NAME, "cpld_name", INDEX1_MAX, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_CPLD_TYPE, "cpld_type", INDEX1_MAX, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FAN_E2_MODE, "fan_e2_mode", INDEX_NOT_EXIST, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_PSU_NAME, "psu_name", INDEX1_MAX, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_SFF_DIR_NAME, "sff_dir_name", INDEX1_MAX, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_SFF_POLLING_LOGIC_DEV_PATH, "sff_polling_logic_dev_path", INDEX1_MAX, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_STRING_END, "end_string", INDEX_NOT_EXIST, INDEX_NOT_EXIST) \ + \ + DFD_CFG_ITEM(DFD_CFG_ITEM_CPLD_I2C_DEV, "cpld_i2c_dev", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_OTHER_I2C_DEV, "other_i2c_dev", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_I2C_DEV_END, "end_i2c_dev", INDEX_NOT_EXIST, INDEX_NOT_EXIST) \ + \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FAN_ROLL_STATUS, "fan_roll_status", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FAN_SPEED, "fan_speed", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FAN_RATIO, "fan_ratio", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_LED_STATUS, "led_status", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_CPLD_VERSION, "cpld_version", INDEX1_MAX, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_CPLD_TEST_REG, "cpld_test_reg", INDEX1_MAX, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_DEV_PRESENT_STATUS, "dev_present_status", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_PSU_STATUS, "psu_status", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_HWMON_TEMP, "hwmon_temp", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_HWMON_IN, "hwmon_in", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_HWMON_PSU, "hwmon_psu", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_SFF_CPLD_REG, "sff_cpld_reg", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_INFO_CTRL_END, "end_info_ctrl", INDEX_NOT_EXIST, INDEX_NOT_EXIST) \ + +#ifdef DFD_CFG_ITEM +#undef DFD_CFG_ITEM +#endif +#define DFD_CFG_ITEM(_id, _name, _index_min, _index_max) _id, +typedef enum dfd_cfg_item_id_s { + DFD_CFG_ITEM_ALL +} dfd_cfg_item_id_t; + +#define DFD_CFG_ITEM_IS_INT(item_id) \ + (((item_id) > DFD_CFG_ITEM_NONE) && ((item_id) < DFD_CFG_ITEM_INT_END)) + +#define DFD_CFG_ITEM_IS_STRING(item_id) \ + (((item_id) > DFD_CFG_ITEM_INT_END) && ((item_id) < DFD_CFG_ITEM_STRING_END)) + +#define DFD_CFG_ITEM_IS_I2C_DEV(item_id) \ + (((item_id) > DFD_CFG_ITEM_STRING_END) && ((item_id) < DFD_CFG_ITEM_I2C_DEV_END)) + +#define DFD_CFG_ITEM_IS_INFO_CTRL(item_id) \ + (((item_id) > DFD_CFG_ITEM_I2C_DEV_END) && ((item_id) < DFD_CFG_ITEM_INFO_CTRL_END)) + +typedef struct index_range_s { + int index1_max; + int index2_max; +} index_range_t; + +typedef struct val_convert_node_s { + struct list_head lst; + int int_val; + char str_val[DFD_CFG_STR_MAX_LEN]; + int index1; + int index2; +} val_convert_node_t; + +void *dfd_ko_cfg_get_item(int key); + +void dfd_ko_cfg_show_item(int key); + +int32_t dfd_dev_cfg_init(void); + +void dfd_dev_cfg_exit(void); + +#endif /* __DFD_CFG_H__ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cfg_adapter.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cfg_adapter.h new file mode 100644 index 000000000000..70d8b536c437 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cfg_adapter.h @@ -0,0 +1,46 @@ +#ifndef __DFD_CFG_ADAPTER_H__ +#define __DFD_CFG_ADAPTER_H__ + +#define DFD_KO_CPLD_I2C_RETRY_SLEEP (10) /* ms */ +#define DFD_KO_CPLD_I2C_RETRY_TIMES (50 / DFD_KO_CPLD_I2C_RETRY_SLEEP) + +#define DFD_KO_CPLD_GET_SLOT(addr) ((addr >> 24) & 0xff) +#define DFD_KO_CPLD_GET_ID(addr) ((addr >> 16) & 0xff) +#define DFD_KO_CPLD_GET_INDEX(addr) (addr & 0xffff) +#define DFD_KO_CPLD_MODE_I2C_STRING "i2c" +#define DFD_KO_CPLD_MODE_LPC_STRING "lpc" + +typedef struct dfd_i2c_dev_s { + int bus; + int addr; +} dfd_i2c_dev_t; + +typedef enum dfd_i2c_dev_mem_s { + DFD_I2C_DEV_MEM_BUS, + DFD_I2C_DEV_MEM_ADDR, + DFD_I2C_DEV_MEM_END +} dfd_i2c_dev_mem_t; + +typedef enum cpld_mode_e { + DFD_CPLD_MODE_I2C, + DFD_CPLD_MODE_LPC, +} cpld_mode_t; + +typedef enum i2c_mode_e { + DFD_I2C_MODE_NORMAL_I2C, + DFD_I2C_MODE_SMBUS, +} i2c_mode_t; + +extern char *g_dfd_i2c_dev_mem_str[DFD_I2C_DEV_MEM_END]; + +int32_t dfd_ko_cpld_read(int32_t addr, uint8_t *buf); + +int32_t dfd_ko_cpld_write(int32_t addr, uint8_t val); + +int32_t dfd_ko_i2c_read(int bus, int addr, int offset, uint8_t *buf, uint32_t size); + +int32_t dfd_ko_i2c_write(int bus, int addr, int offset, uint8_t *buf, uint32_t size); + +int32_t dfd_ko_read_file(char *fpath, int32_t addr, uint8_t *val, int32_t read_bytes); + +#endif /* __DFD_CFG_ADAPTER_H__ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cfg_file.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cfg_file.h new file mode 100644 index 000000000000..50d7a42d5564 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cfg_file.h @@ -0,0 +1,37 @@ +#ifndef __DFD_CFG_FILE_H__ +#define __DFD_CFG_FILE_H__ + +#include + +#define KFILE_RV_OK (0) +#define KFILE_RV_INPUT_ERR (-1) +#define KFILE_RV_STAT_FAIL (-2) +#define KFILE_RV_OPEN_FAIL (-3) +#define KFILE_RV_MALLOC_FAIL (-4) +#define KFILE_RV_RD_FAIL (-5) +#define KFILE_RV_ADDR_ERR (-6) +#define KFILE_RV_WR_FAIL (-7) + +#define IS_CR(c) ((c) == '\n') + +typedef struct kfile_ctrl_s { + int32_t size; + int32_t pos; + char *buf; +} kfile_ctrl_t; + +int kfile_open(char *fname, kfile_ctrl_t *kfile_ctrl); + +void kfile_close(kfile_ctrl_t *kfile_ctrl); + +int kfile_gets(char *buf, int buf_size, kfile_ctrl_t *kfile_ctrl); + +int kfile_read(int32_t addr, char *buf, int buf_size, kfile_ctrl_t *kfile_ctrl); + +int kfile_iterate_dir(const char *dir_path, const char *obj_name, char *match_name, int len); + +#if 0 + +int kfile_write(char *fpath, int32_t addr, char *buf, int buf_size); +#endif +#endif /* __DFD_CFG_FILE_H__ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cfg_info.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cfg_info.h new file mode 100644 index 000000000000..dc1ed17651b9 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cfg_info.h @@ -0,0 +1,109 @@ +#ifndef __DFD_CFG_INFO_H__ +#define __DFD_CFG_INFO_H__ + +#include + +typedef int (*info_num_buf_to_value_f)(uint8_t *num_buf, int buf_len, int *num_val); + +typedef int (*info_buf_to_buf_f)(uint8_t *buf, int buf_len, uint8_t *buf_new, int *buf_len_new); + +#define IS_INFO_FRMT_BIT(frmt) ((frmt) == INFO_FRMT_BIT) +#define IS_INFO_FRMT_BYTE(frmt) (((frmt) == INFO_FRMT_BYTE) || ((frmt) == INFO_FRMT_NUM_BYTES)) +#define IS_INFO_FRMT_NUM_STR(frmt) ((frmt) == INFO_FRMT_NUM_STR) +#define IS_INFO_FRMT_NUM_BUF(frmt) ((frmt) == INFO_FRMT_NUM_BUF) +#define IS_INFO_FRMT_BUF(frmt) ((frmt) == INFO_FRMT_BUF) + +#define INFO_INT_MAX_LEN (32) +#define INFO_INT_LEN_VALAID(len) (((len) > 0) && ((len) < INFO_INT_MAX_LEN)) + +#define INFO_BUF_MAX_LEN (128) +#define INFO_BUF_LEN_VALAID(len) (((len) > 0) && ((len) < INFO_BUF_MAX_LEN)) + +#define INFO_BIT_OFFSET_VALID(bit_offset) (((bit_offset) >= 0) && ((bit_offset) < 8)) + +typedef enum info_ctrl_mode_e { + INFO_CTRL_MODE_NONE, + INFO_CTRL_MODE_CFG, + INFO_CTRL_MODE_CONS, + INFO_CTRL_MODE_TLV, + INFO_CTRL_MODE_SRT_CONS, + INFO_CTRL_MODE_END +} info_ctrl_mode_t; + +typedef enum info_frmt_e { + INFO_FRMT_NONE, + INFO_FRMT_BIT, + INFO_FRMT_BYTE, + INFO_FRMT_NUM_BYTES, + INFO_FRMT_NUM_STR, + INFO_FRMT_NUM_BUF, + INFO_FRMT_BUF, + INFO_FRMT_END +} info_frmt_t; + +typedef enum info_src_e { + INFO_SRC_NONE, + INFO_SRC_CPLD, + INFO_SRC_FPGA, + INFO_SRC_OTHER_I2C, + INFO_SRC_FILE, + INFO_SRC_END +} info_src_t; + +typedef enum info_pola_e { + INFO_POLA_NONE, + INFO_POLA_POSI, + INFO_POLA_NEGA, + INFO_POLA_END +} info_pola_t; + +#define INFO_FPATH_MAX_LEN (128) +#define INFO_STR_CONS_MAX_LEN (64) +typedef struct info_ctrl_s { + info_ctrl_mode_t mode; + int32_t int_cons; + info_src_t src; + info_frmt_t frmt; + info_pola_t pola; + char fpath[INFO_FPATH_MAX_LEN]; + int32_t addr; + int32_t len; + int32_t bit_offset; + char str_cons[INFO_STR_CONS_MAX_LEN]; + int32_t int_extra1; + int32_t int_extra2; +} info_ctrl_t; + +typedef enum info_ctrl_mem_s { + INFO_CTRL_MEM_MODE, + INFO_CTRL_MEM_INT_CONS, + INFO_CTRL_MEM_SRC, + INFO_CTRL_MEM_FRMT, + INFO_CTRL_MEM_POLA, + INFO_CTRL_MEM_FPATH, + INFO_CTRL_MEM_ADDR, + INFO_CTRL_MEM_LEN, + INFO_CTRL_MEM_BIT_OFFSET, + INFO_CTRL_MEM_STR_CONS, + INFO_CTRL_MEM_INT_EXTRA1, + INFO_CTRL_MEM_INT_EXTRA2, + INFO_CTRL_MEM_END +} info_ctrl_mem_t; + +typedef int (*info_hwmon_buf_f)(uint8_t *buf, int buf_len, uint8_t *buf_new, int *buf_len_new, info_ctrl_t *info_ctrl); + +extern char *g_info_ctrl_mem_str[INFO_CTRL_MEM_END]; +extern char *g_info_src_str[INFO_SRC_END]; +extern char *g_info_frmt_str[INFO_FRMT_END]; +extern char *g_info_pola_str[INFO_POLA_END]; +extern char *g_info_ctrl_mode_str[INFO_CTRL_MODE_END]; + +int dfd_info_get_int(int key, int *ret, info_num_buf_to_value_f pfun); + +int dfd_info_get_buf(int key, uint8_t *buf, int buf_len, info_buf_to_buf_f pfun); + +int dfd_info_set_int(int key, int val); + +int dfd_info_get_sensor(uint32_t key, char *buf, int buf_len, info_hwmon_buf_f pfun); + +#endif /* __DFD_CFG_INFO_H__ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cfg_listnode.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cfg_listnode.h new file mode 100644 index 000000000000..955dfa96e42e --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cfg_listnode.h @@ -0,0 +1,30 @@ +#ifndef __DFD_CFG_LISTNODE_H__ +#define __DFD_CFG_LISTNODE_H__ + +#include + +#define LNODE_RV_OK (0) +#define LNODE_RV_INPUT_ERR (-1) +#define LNODE_RV_NODE_EXIST (-2) +#define LNODE_RV_NOMEM (-3) + +typedef struct lnode_root_s { + struct list_head root; +} lnode_root_t; + +typedef struct lnode_node_s { + struct list_head lst; + + int key; + void *data; +} lnode_node_t; + +void *lnode_find_node(lnode_root_t *root, int key); + +int lnode_insert_node(lnode_root_t *root, int key, void *data); + +int lnode_init_root(lnode_root_t *root); + +void lnode_free_list(lnode_root_t *root); + +#endif /* __DFD_CFG_LISTNODE_H__ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cpld_driver.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cpld_driver.h new file mode 100644 index 000000000000..f3c7f301168f --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cpld_driver.h @@ -0,0 +1,14 @@ +#ifndef _DFD_CPLD_DRIVER_H_ +#define _DFD_CPLD_DRIVER_H_ + +ssize_t dfd_get_cpld_name(unsigned int cpld_index, char *buf); + +ssize_t dfd_get_cpld_type(unsigned int cpld_index, char *buf); + +ssize_t dfd_get_cpld_version(unsigned int cpld_index, char *buf); + +int dfd_set_cpld_testreg(unsigned int cpld_index, int value); + +int dfd_get_cpld_testreg(unsigned int cpld_index, int *value); + +#endif /* _DFD_CPLD_DRIVER_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_fan_driver.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_fan_driver.h new file mode 100644 index 000000000000..55f99c89bd6a --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_fan_driver.h @@ -0,0 +1,32 @@ +#ifndef _DFD_FAN_DRIVER_H_ +#define _DFD_FAN_DRIVER_H_ + +int dfd_get_fan_status(unsigned int fan_index); + +ssize_t dfd_get_fan_info(unsigned int fan_index, uint8_t cmd, char *buf); + +ssize_t dfd_get_fan_speed(unsigned int fan_index, unsigned int motor_index,unsigned int *speed); + +int dfd_set_fan_pwm(unsigned int fan_index, unsigned int motor_index, int pwm); + +int dfd_get_fan_pwm(unsigned int fan_index, unsigned int motor_index, int *pwm); + +int dfd_get_fan_speed_tolerance(unsigned int fan_index, unsigned int motor_index, int *value); + +int dfd_get_fan_speed_target(unsigned int fan_index, unsigned int motor_index, int *value); + +int dfd_get_fan_direction(unsigned int fan_index, unsigned int motor_index, int *value); + +ssize_t dfd_get_fan_status_str(unsigned int fan_index, char *buf); + +ssize_t dfd_get_fan_direction_str(unsigned int fan_index, unsigned int motor_index, char *buf); + +int dfd_get_fan_present_status(unsigned int fan_index); + +int dfd_get_fan_roll_status(unsigned int fan_index, unsigned int motor_index); + +int dfd_get_fan_speed_level(unsigned int fan_index, unsigned int motor_index, int *level); + +int dfd_set_fan_speed_level(unsigned int fan_index, unsigned int motor_index, int level); + +#endif /* _DFD_FAN_DRIVER_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_frueeprom.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_frueeprom.h new file mode 100644 index 000000000000..1b175154672f --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_frueeprom.h @@ -0,0 +1,67 @@ +#ifndef DFD_FRUEEPROM_H +#define DFD_FRUEEPROM_H + +/* Per IPMI v2.0 FRU specification */ +typedef struct fru_common_header_s +{ + uint8_t fixed; + uint8_t internal_offset; + uint8_t chassis_offset; + uint8_t board_offset; + uint8_t product_offset; + uint8_t multi_offset; + uint8_t pad; + uint8_t crc; +}__attribute__((packed)) fru_common_header_t; + +/* first byte in header is 1h per IPMI V2 spec. */ + +#define IPMI_FRU_HDR_BYTE_ZERO 1 +#define IPMI_EIGHT_BYTES 8 + +#define IPMI_FRU_AREA_TYPE_LENGTH_FIELD_MAX 512 +#define IPMI_FRU_BOARD_INFO_MFG_TIME_LENGTH 3 +#define IPMI_FRU_SENTINEL_VALUE 0xC1 +#define IPMI_FRU_TYPE_LENGTH_TYPE_CODE_MASK 0xC0 +#define IPMI_FRU_TYPE_LENGTH_TYPE_CODE_SHIFT 0x06 +#define IPMI_FRU_TYPE_LENGTH_NUMBER_OF_DATA_BYTES_MASK 0x3F +#define IPMI_FRU_TYPE_LENGTH_TYPE_CODE_LANGUAGE_CODE 0x03 + +struct ipmi_fru_field +{ + uint8_t type_length_field[IPMI_FRU_AREA_TYPE_LENGTH_FIELD_MAX]; + /* store length of data stored in buffer */ + unsigned int type_length_field_length; +}; + +typedef struct ipmi_fru_field ipmi_fru_field_t; + +typedef struct ipmi_product_info_s { + uint8_t *language_code; + ipmi_fru_field_t *product_manufacturer_name; + ipmi_fru_field_t *product_name; + ipmi_fru_field_t *product_part_model_number; + ipmi_fru_field_t *product_version; + ipmi_fru_field_t *product_serial_number; + ipmi_fru_field_t *product_asset_tag; + ipmi_fru_field_t *product_fru_file_id; + ipmi_fru_field_t *product_custom_fields; + ipmi_fru_field_t *product_type_fields; +}ipmi_product_info_t; + +typedef struct ipmi_board_info_s { + uint8_t *language_code; + uint8_t *mfg_time; + ipmi_fru_field_t *board_manufacturer; + ipmi_fru_field_t *board_product_name; + ipmi_fru_field_t *board_serial_number; + ipmi_fru_field_t *board_part_number; + ipmi_fru_field_t *board_fru_file_id; + ipmi_fru_field_t *board_custom_fields; /*hw version */ +}ipmi_board_info_t; + +int dfd_get_fru_data(int bus, int dev_addr, int type, uint8_t *buf, uint32_t buf_len); + +int dfd_get_fru_board_data(int bus, int dev_addr, int type, uint8_t *buf, uint32_t buf_len); + +#endif /* endif DFD_OPENBMC_TLVEEPROM_H */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_led_driver.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_led_driver.h new file mode 100644 index 000000000000..7d9daa8fe952 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_led_driver.h @@ -0,0 +1,6 @@ +#ifndef _DFD_LED_DRIVER_H_ +#define _DFD_LED_DRIVER_H_ + +ssize_t dfd_get_led_status(uint16_t led_id, uint8_t led_index, char *buf); + +#endif /* _DFD_LED_DRIVER_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_module.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_module.h new file mode 100644 index 000000000000..693dea50ce32 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_module.h @@ -0,0 +1,148 @@ +#ifndef __DFD_MODULE_H__ +#define __DFD_MODULE_H__ + +typedef enum dfd_rv_s { + DFD_RV_OK = 0, + DFD_RV_INIT_ERR = 1, + DFD_RV_SLOT_INVALID = 2, + DFD_RV_MODE_INVALID = 3, + DFD_RV_MODE_NOTSUPPORT = 4, + DFD_RV_TYPE_ERR = 5, + DFD_RV_DEV_NOTSUPPORT = 6, + DFD_RV_DEV_FAIL = 7, + DFD_RV_INDEX_INVALID = 8, + DFD_RV_NO_INTF = 9, + DFD_RV_NO_NODE = 10, + DFD_RV_NODE_FAIL = 11, + DFD_RV_INVALID_VALUE = 12, + DFD_RV_NO_MEMORY = 13, +} dfd_rv_t; + +typedef enum { + DBG_VERBOSE = 0x01, + DBG_WARN = 0x02, + DBG_ERROR = 0x04, +} dbg_level_t; + +typedef enum status_mem_e { + STATUS_ABSENT = 0, + STATUS_OK = 1, + STATUS_NOT_OK = 2, + STATUS_MEM_END = 3, +} status_mem_t; + +extern int g_dfd_dbg_level; +extern int g_dfd_fan_dbg_level; +extern int g_dfd_fru_dbg_level; +extern int g_dfd_syseeprom_dbg_level; +extern int g_dfd_cpld_dbg_level; +extern int g_dfd_sysled_dbg_level; +extern int g_dfd_slot_dbg_level; +extern int g_dfd_sensor_dbg_level; +extern int g_dfd_psu_dbg_level; +extern int g_dfd_sff_dbg_level; +extern char *g_status_mem_str[STATUS_MEM_END]; + +#define DBG_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DFD_FAN_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_fan_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DBG_FRU_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_fru_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DBG_SYSE2_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_syseeprom_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DBG_CPLD_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_cpld_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DBG_SYSLED_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_sysled_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DFD_SLOT_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_slot_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DFD_SENSOR_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_sensor_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DFD_PSU_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_psu_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DFD_SFF_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_sff_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +int dfd_get_dev_number(unsigned int main_dev_id, unsigned int minor_dev_id); + +#endif /* __DFD_MODULE_H__ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_psu_driver.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_psu_driver.h new file mode 100644 index 000000000000..d9875e8c54fa --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_psu_driver.h @@ -0,0 +1,14 @@ +#ifndef _DFD_PSU_DRIVER_H_ +#define _DFD_PSU_DRIVER_H_ + +ssize_t dfd_get_psu_info(unsigned int psu_index, uint8_t cmd, char *buf); + +ssize_t dfd_get_psu_status_str(unsigned int psu_index, char *buf); + +int dfd_get_psu_present_status(unsigned int psu_index); + +int dfd_get_psu_output_status(unsigned int psu_index); + +int dfd_get_psu_alert_status(unsigned int psu_index); + +#endif /* _DFD_PSU_DRIVER_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_sensors_driver.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_sensors_driver.h new file mode 100644 index 000000000000..0ad232309564 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_sensors_driver.h @@ -0,0 +1,12 @@ +#ifndef _DFD_SENSORS_DRIVER_H_ +#define _DFD_SENSORS_DRIVER_H_ + +ssize_t dfd_get_temp_info(uint8_t main_dev_id, uint8_t dev_index, + uint8_t temp_index, uint8_t temp_attr, char *buf); + +ssize_t dfd_get_voltage_info(uint8_t main_dev_id, uint8_t dev_index, + uint8_t in_index, uint8_t in_attr, char *buf); + +ssize_t dfd_get_psu_sensor_info(uint8_t psu_index, uint8_t sensor_type, char *buf); + +#endif /* _DFD_SENSORS_DRIVER_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_sff_driver.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_sff_driver.h new file mode 100644 index 000000000000..defbdc4fb77f --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_sff_driver.h @@ -0,0 +1,18 @@ +#ifndef _DFD_SFF_DRIVER_H_ +#define _DFD_SFF_DRIVER_H_ + +int dfd_get_sff_id(unsigned int sff_index); + +int dfd_set_sff_cpld_info(unsigned int sff_index, int cpld_reg_type, int value); + +ssize_t dfd_get_sff_cpld_info(unsigned int sff_index, int cpld_reg_type, char *buf, int len); + +ssize_t dfd_get_sff_eeprom_info(unsigned int sff_index, const char *attr_name, char *buf, int buf_len); + +ssize_t dfd_get_sff_dir_name(unsigned int sff_index, char *buf, int buf_len); + +int dfd_get_sff_polling_size(void); + +ssize_t dfd_get_sff_polling_data(unsigned int sff_index, char *buf, loff_t offset, size_t count); + +#endif /* _DFD_SFF_DRIVER_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_sfpparse.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_sfpparse.h new file mode 100644 index 000000000000..f664259f68ea --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_sfpparse.h @@ -0,0 +1,558 @@ +#ifndef _DFD_SFPPARSE_H_ +#define _DFD_SFPPARSE_H_ + +struct rj_e2_enum_type_s { + char key[32]; + char value[128]; +}; + +struct sff_e2_spec_comp_s { + int offset; + char attr_name[128]; + struct rj_e2_enum_type_s *attr_value; +}; + +typedef enum { + E2_STR, + E2_INT, + E2_HEX, + E2_DATE, + E2_BITVALUE, + E2_BITMAP, + E2_ENUM, + E2_FUNC, + E2_BITVALUE4, +} rj_eeprom_type_t; + +struct rj_e2_enum_type_s sff8472_type_of_transceiver[] = { + {"00","Unknown"}, + {"01","GBIC"}, + {"02", "Module soldered to motherboard"}, + {"03", "SFP or SFP Plus"}, + {"04", "300 pin XBI"}, + {"05", "XENPAK"}, + {"06", "XFP"}, + {"07", "XFF"}, + {"08", "XFP-E"}, + {"09", "XPAK"}, + {"0a", "X2"}, + {"0b", "DWDM-SFP"}, + {"0d", "QSFP"}, + {"NULL", ""} +}; + +struct rj_e2_enum_type_s sff8472_exttypeoftransceiver[] = {{"00", "GBIC def not specified"}, + {"01","GBIC is compliant with MOD_DEF 1"}, + {"02","GBIC is compliant with MOD_DEF 2"}, + {"03","GBIC is compliant with MOD_DEF 3"}, + {"04","GBIC/SFP defined by twowire interface ID"}, + {"05","GBIC is compliant with MOD_DEF 5"}, + {"06","GBIC is compliant with MOD_DEF 6"}, + {"07","GBIC is compliant with MOD_DEF 7"}, + {"NULL", ""} +}; + +struct rj_e2_enum_type_s sff8472_connector[] = {{"00", "Unknown"}, + {"01", "SC"}, + {"02", "Fibre Channel Style 1 copper connector"}, + {"03", "Fibre Channel Style 2 copper connector"}, + {"04", "BNC/TNC"}, + {"05", "Fibre Channel coaxial headers"}, + {"06", "FibreJack"}, + {"07", "LC"}, + {"08", "MT-RJ"}, + {"09", "MU"}, + {"0a", "SG"}, + {"0b", "Optical pigtail"}, + {"0C", "MPO Parallel Optic"}, + {"20", "HSSDCII"}, + {"21", "CopperPigtail"}, + {"22", "RJ45"}, + {"NULL", ""} + }; + +struct rj_e2_enum_type_s sff8472_encoding_codes[] = {{"00","Unspecified"}, + {"01","8B/10B"}, + {"02","4B/5B"}, + {"03","NRZ"}, + {"04","Manchester"}, + {"05", "SONET Scrambled"}, + {"06","64B/66B"}, + {"NULL", ""} + }; + +struct rj_e2_enum_type_s sff8472_rate_identifier[] = {{"00","Unspecified"}, + {"01","Defined for SFF-8079 (4/2/1G Rate_Select & AS0/AS1)"}, + {"02", "Defined for SFF-8431 (8/4/2G Rx Rate_Select only)"}, + {"03","Unspecified"}, + {"04", "Defined for SFF-8431 (8/4/2G Tx Rate_Select only)"}, + {"05","Unspecified"}, + {"06","Defined for SFF-8431 (8/4/2G Independent Rx & Tx Rate_select)"}, + {"07","Unspecified"}, + {"08", "Defined for FC-PI-5 (16/8/4G Rx Rate_select only) High=16G only, Low=8G/4G"}, + {"09", "Unspecified"}, + {"0a", "Defined for FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select) High=16G only, Low=8G/4G"}, + {"NULL", ""} + }; + +struct rj_e2_enum_type_s sff8436_type_of_transceiver[] = { + {"00","Unknown or unspecified"}, + {"01","GBIC"}, + {"02", "Module/connector soldered to motherboard"}, + {"03", "SFP"}, + {"04", "300 pin XBI"}, + {"05", "XENPAK"}, + {"06", "XFP"}, + {"07", "XFF"}, + {"08", "XFP-E"}, + {"09", "XPAK"}, + {"0a", "X2"}, + {"0b", "DWDM-SFP"}, + {"0c", "QSFP"}, + {"0d", "QSFP+"}, + {"11", "QSFP28"}, + {"NULL", ""} +}; + +struct rj_e2_enum_type_s sff8436_ext_type_of_transceiver[] = { + {"00", "Power Class 1(1.5W max)"}, + {"04", "Power Class 1(1.5W max), CDR present in Tx"}, + {"08", "Power Class 1(1.5W max), CDR present in Rx"}, + {"0c", "Power Class 1(1.5W max), CDR present in Rx Tx"}, + {"10", "Power Class 1(1.5W max), CLEI present"}, + {"14", "Power Class 1(1.5W max), CLEI present, CDR present in Tx"}, + {"18", "Power Class 1(1.5W max), CLEI present, CDR present in Rx"}, + {"1c", "Power Class 1(1.5W max), CLEI present, CDR present in Rx Tx"}, + + {"40", "Power Class 2(2.0W max)"}, + {"44", "Power Class 2(2.0W max), CDR present in Rx"}, + {"48", "Power Class 2(2.0W max), CDR present in Tx"}, + {"4c", "Power Class 2(2.0W max), CDR present in Rx Tx"}, + {"50", "Power Class 2(2.0W max), CLEI present"}, + {"54", "Power Class 2(2.0W max), CLEI present, CDR present in Rx"}, + {"58", "Power Class 2(2.0W max), CLEI present, CDR present in Tx"}, + {"5c", "Power Class 2(2.0W max), CLEI present, CDR present in Rx Tx"}, + + {"80", "Power Class 3(2.5W max)"}, + {"84", "Power Class 3(2.5W max), CDR present in Rx"}, + {"88", "Power Class 3(2.5W max), CDR present in Tx"}, + {"8c", "Power Class 3(2.5W max), CDR present in Rx Tx"}, + {"90", "Power Class 3(2.5W max), CLEI present"}, + {"94", "Power Class 3(2.5W max), CLEI present, CDR present in Rx"}, + {"98", "Power Class 3(2.5W max), CLEI present, CDR present in Tx"}, + {"9c", "Power Class 3(2.5W max), CLEI present, CDR present in Rx Tx"}, + + {"c0", "Power Class 4(3.5W max)"}, + {"c4", "Power Class 4(3.5W max), CDR present in Rx"}, + {"c8", "Power Class 4(3.5W max), CDR present in Tx"}, + {"cc", "Power Class 4(3.5W max), CDR present in Rx Tx"}, + {"d0", "Power Class 4(3.5W max), CLEI present"}, + {"d4", "Power Class 4(3.5W max), CLEI present, CDR present in Rx"}, + {"d8", "Power Class 4(3.5W max), CLEI present, CDR present in Tx"}, + {"dc", "Power Class 4(3.5W max), CLEI present, CDR present in Rx Tx"}, + {"NULL", ""} + }; + +struct rj_e2_enum_type_s sff8436_connector[] = { + {"00", "Unknown or unspecified"}, + {"01", "SC"}, + {"02", "FC Style 1 copper connector"}, + {"03", "FC Style 2 copper connector"}, + {"04", "BNC/TNC"}, + {"05", "FC coax headers"}, + {"06", "Fiberjack"}, + {"07", "LC"}, + {"08", "MT-RJ"}, + {"09", "MU"}, + {"0a", "SG"}, + {"0b", "Optical Pigtail"}, + {"0c", "MPOx12"}, + {"0d", "MPOx16"}, + {"20", "HSSDC II"}, + {"21", "Copper pigtail"}, + {"22", "RJ45"}, + {"23", "No separable connector"}, + {"NULL", ""} +}; + +struct rj_e2_enum_type_s sff8436_encoding_codes[] = { + {"00","Unspecified"}, + {"01", "8B10B"}, + {"02", "4B5B"}, + {"03", "NRZ"}, + {"04", "SONET Scrambled"}, + {"05", "64B66B"}, + {"06", "Manchester"}, + {"07", "256B257B"}, + {"NULL", ""} + }; + +struct rj_e2_enum_type_s sff8436_rate_identifier[] = { + {"00","QSFP+ Rate Select Version 1"}, + {"NULL", ""} + }; + +/* qsfp sepecification compliance*/ +/* byte131 10/40G Ethernet Compliance Code */ +struct rj_e2_enum_type_s qsfp_comp_10_ethcc_bitmap[8] = { + {"0", "40G Active Cable (XLPPI)"}, + {"1", "40GBASE-LR4"}, + {"2", "40GBASE-SR4"}, + {"3", "40GBASE-CR4"}, + {"4", "10GBase-SR"}, + {"5", "10GBase-LR"}, + {"6", "10GBase-LRM"}, + {"NULL", ""}, +}; + +/* byte132 SONET Compliance codes */ +struct rj_e2_enum_type_s qsfp_comp_socc_bitmap[8] = { + {"0", "OC 48 short reach"}, + {"1", "OC 48, intermediate reach"}, + {"2", "OC 48, long reach"}, + {"3", "40G OTN (OTU3B/OTU3C)"}, + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, +}; + +/* byte133 SAS/SATA compliance codes */ +struct rj_e2_enum_type_s qsfp_comp_sscc_bitmap[8] = { + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, + {"4", "SAS 3.0G"}, + {"5", "SAS 6.0G"}, + {"NULL", ""}, + {"NULL", ""}, +}; + +/* byte134 Gigabit Ethernet Compliant codes */ +struct rj_e2_enum_type_s qsfp_comp_gethcc_bitmap[8] = { + {"0", "1000BASE-SX"}, + {"1", "1000BASE-LX"}, + {"2", "1000BASE-CX"}, + {"3", "1000BASE-T"}, + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, +}; + +/* byte135 Fibre Channel link length */ +struct rj_e2_enum_type_s qsfp_comp_fcll_bitmap[8] = { + {"0", "Electrical inter-enclosure (EL)"}, + {"1", "Longwave laser (LC)"}, + {"NULL", ""}, + {"3", "Medium (M)"}, + {"4", "Long distance (L)"}, + {"5", "Intermediate distance (I)"}, + {"6", "Short distance (S)"}, + {"7", "Very long distance (V)"}, +}; + +/* byte136 Transmitter Technology */ +struct rj_e2_enum_type_s qsfp_comp_tt_bitmap[8] = { + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, + {"4", "Longwave Laser (LL)"}, + {"5", "Shortwave laser w OFC (SL)"}, + {"6", "Shortwave laser w/o OFC (SN)"}, + {"7", "Electrical intra-enclosure"}, +}; + +/* byte137 Fibre Channel transmission media */ +struct rj_e2_enum_type_s qsfp_comp_fctm_bitmap[8] = { + {"0", "Single Mode (SM)"}, + {"1", "Multi-mode 50um (OM3)"}, + {"2", "Multi-mode 50m (M5)"}, + {"3", "Multi-mode 62.5m (M6)"}, + {"4", "Video Coax (TV)"}, + {"5", "Miniature Coax (MI)"}, + {"6", "Shielded Twisted Pair (TP)"}, + {"7", "Twin Axial Pair (TW)"}, +}; + +/* byte138 Fibre Channel Speed */ +struct rj_e2_enum_type_s qsfp_comp_fcs_bitmap[8] = { + {"0", "100 Mbytes/Sec"}, + {"NULL", ""}, + {"2", "200 Mbytes/Sec"}, + {"NULL", ""}, + {"4", "400 Mbytes/Sec"}, + {"5", "1600 Mbytes/Sec"}, + {"6", "800 Mbytes/Sec"}, + {"7", "1200 Mbytes/Sec"}, +}; + +/* sfp sepecification compliance*/ +/* byte3 10G Ethernet Compliance Codes */ +struct rj_e2_enum_type_s sfp_comp_10_ethcc_bitmap[8] = { + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, + {"4", "10G Base-SR"}, + {"5", "10G Base-LR"}, + {"6", "10G Base-LRM"}, + {"7", "10G Base-ER"}, +}; + +/* byte3 Infiniband Compliance Codes */ +struct rj_e2_enum_type_s sfp_comp_infcc_bitmap[8] = { + {"0", "1X Copper Passive"}, + {"1", "1X Copper Active"}, + {"2", "1X LX"}, + {"3", "1X SX"}, + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, +}; + +/* byte4 ESCON Compliance Codes */ +struct rj_e2_enum_type_s sfp_comp_escc_bitmap[8] = { + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, + {"6", "ESCON SMF, 1310nm Laser"}, + {"7", "ESCON MMF, 1310nm LED"}, +}; + +/* byte4 SONET Compliance Codes */ +struct rj_e2_enum_type_s sfp_comp_socc1_bitmap[8] = { + {"0", "OC-48, short reach"}, + {"1", "OC-48, intermediate reach"}, + {"2", "OC-48, long reach"}, + {"3", "SONET reach specifier bit 2"}, + {"4", "SONET reach specifier bit 1"}, + {"5", "OC-192, short reach"}, + {"NULL", ""}, + {"NULL", ""}, +}; + +/* byte5 SONET Compliance Codes */ +struct rj_e2_enum_type_s sfp_comp_socc2_bitmap[8] = { + {"0", "OC-3, short reach"}, + {"1", "OC-3, single mode, inter reach"}, + {"2", "OC-3, single mode, long reach"}, + {"NULL", ""}, + {"4", "OC-12, short reach"}, + {"5", "OC-12, single mode, inter reach"}, + {"6", "OC-12, single mode, long reach"}, + {"NULL", ""}, +}; + +/* byte6 Ethernet Compliance Codes */ +struct rj_e2_enum_type_s sfp_comp_ethcc_bitmap[8] = { + {"0", "1000BASE-SX"}, + {"1", "1000BASE-LX"}, + {"2", "1000BASE-CX"}, + {"3", "1000BASE-T"}, + {"4", "100BASE-LX/LX10"}, + {"5", "100BASE-FX"}, + {"6", "BASE-BX10"}, + {"7", "BASE-PX"}, +}; + +/* byte7 Fibre Channel Link Length */ +struct rj_e2_enum_type_s sfp_comp_fcll_bitmap[8] = { + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, + {"3", "medium distance (M)"}, + {"4", "Long distance (L)"}, + {"5", "Intermediate distance (I)"}, + {"6", "short distance (S)"}, + {"7", "very long distance (V)"}, +}; + +/* byte7 Fibre Channel Technology */ +struct rj_e2_enum_type_s sfp_comp_fct1_bitmap[8] = { + {"0", "Electrical inter-enclosure (EL)"}, + {"1", "Longwave Laser (LC)"}, + {"2", "Shortwave laser, linear Rx (SA)"}, + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, +}; + +/* byte8 Fibre Channel Technology */ +struct rj_e2_enum_type_s sfp_comp_fct2_bitmap[8] = { + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, + {"4", "Longwave laser (LL)"}, + {"5", "Shortwave laser with OFC (SL)"}, + {"6", "Shortwave laser w/o OFC (SN)"}, + {"7", "Electrical intra-enclosure (EL)"}, +}; + +/* byte8 SFP+ Cable Technology */ +struct rj_e2_enum_type_s sfp_comp_sfpct_bitmap[8] = { + {"NULL", ""}, + {"NULL", ""}, + {"2", "Passive Cable"}, + {"3", "Active Cable"}, + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, +}; + +/* byte9 Fibre Channel Transmission Media */ +struct rj_e2_enum_type_s sfp_comp_fctm_bitmap[8] = { + {"0", "Single Mode (SM)"}, + {"NULL", ""}, + {"2", "Multimode, 50um (M5, M5E)"}, + {"3", "Multimode, 62.5um (M6)"}, + {"4", "Video Coax (TV)"}, + {"5", "Miniature Coax (MI)"}, + {"6", "Twisted Pair (TP)"}, + {"7", "Twin Axial Pair (TW)"}, +}; + +/* byte10 Fibre Channel Speed */ +struct rj_e2_enum_type_s sfp_comp_fcs_bitmap[8] = { + {"0", "100 MBytes/sec"}, + {"NULL", ""}, + {"2", "200 MBytes/sec"}, + {"NULL", ""}, + {"4", "400 MBytes/sec"}, + {"5", "1600 MBytes/sec"}, + {"6", "800 MBytes/sec"}, + {"7", "1200 MBytes/sec"}, +}; + +typedef enum { + DOM_NONE, + DOM_SFF8436, + DOM_SFF8472, +} rj_dom_type_t; + +typedef enum { + EXTCALB_RX_PWR_4, + EXTCALB_RX_PWR_3, + EXTCALB_RX_PWR_2, + EXTCALB_RX_PWR_1, + EXTCALB_RX_PWR_0, + EXTCALB_TX_I_Slope, + EXTCALB_TX_I_Offset, + EXTCALB_TX_PWR_Slope, + EXTCALB_TX_PWR_Offset, + EXTCALB_T_Slope, + EXTCALB_T_Offset, + EXTCALB_V_Slope, + EXTCALB_V_Offset, +} rj_dom_ext_calibration_t; + +struct rj_eeprom_parse_t_subaddr { + int offset; + int sub_offset; + int size; +}; + +struct rj_eeprom_parse_t_ext { + int subaddr_num; + char prefix[10]; + struct rj_eeprom_parse_t_subaddr subaddr[4]; +}; + +struct rj_eeprom_parse_t { + char attr_name[32]; + int addr; + int offset; + int sub_offset; + int size; + rj_eeprom_type_t type; + struct rj_e2_enum_type_s *enum_str; + rj_dom_type_t dom_type; + void (*calc_func) ( int sfp_bus, + struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len); + struct rj_eeprom_parse_t_ext ext; +}; + +static void calc_temperature(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len); +static void calc_voltage(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len); +static void sfp_calc_rx_power(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len); +static void sfp_calc_tx_power(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len); +static void sfp_calc_tx_bias(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len); +static void qsfp_calc_tx_bias(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len); +static void qsfp_calc_rx_power(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len); +static void qsfp_calc_tx_power(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len); +static void sfp_cable_length_display(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len); +static void qsfp_cable_length_display(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len); +static void qsfp_spec_comp_display(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len); +static void sfp_spec_comp_display(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len); + +/* QSFP DOM EEPROM is also at addr 0x50 */ +struct rj_eeprom_parse_t ssf8436_interface_id[] = { + {"type", 0x50, 128, 0, 1, E2_ENUM, sff8436_type_of_transceiver, DOM_NONE, NULL}, + {"hw_version", 0x50, 184, 0, 2, E2_STR, NULL, DOM_NONE, NULL}, + {"serial_num", 0x50, 196, 0, 16, E2_STR, NULL, DOM_NONE, NULL}, + {"manufacture_name", 0x50, 148, 0, 16, E2_STR, NULL, DOM_NONE, NULL}, + {"model_name", 0x50, 168, 0, 16, E2_STR, NULL, DOM_NONE, NULL}, + {"connector", 0x50, 130, 0, 1, E2_ENUM, sff8436_connector, DOM_NONE, NULL}, + {"encoding", 0x50, 139, 0, 1, E2_ENUM, sff8436_encoding_codes, DOM_NONE, NULL}, + {"ext_identifier", 0x50, 129, 0, 1, E2_ENUM, sff8436_ext_type_of_transceiver, DOM_NONE, NULL}, + {"ext_rateselect_compliance", 0x50, 141, 0, 1, E2_ENUM, sff8436_rate_identifier, DOM_NONE, NULL}, + {"cable_length", 0x50, 142, 0, 5, E2_FUNC, NULL, DOM_NONE, qsfp_cable_length_display}, /* 142 - 146*/ + {"nominal_bit_rate", 0x50, 140, 0, 1, E2_INT, NULL, DOM_NONE, NULL}, + {"sepecification_compliance", 0x50, 131, 0, 8, E2_FUNC, NULL, DOM_NONE, qsfp_spec_comp_display}, /* 131 - 138 */ + {"vendor_date", 0x50, 212, 0, 8, E2_DATE, NULL, DOM_NONE, NULL}, + {"vendor_oui", 0x50, 165, 0, 3, E2_HEX, NULL, DOM_NONE, NULL}, + + {"temperature", 0x50, 22, 0, 2, E2_FUNC, NULL, DOM_SFF8436, calc_temperature}, + {"voltage", 0x50, 26, 0, 2, E2_FUNC, NULL, DOM_SFF8436, calc_voltage}, + {"rxpower", 0x50, 34, 0, 8, E2_FUNC, NULL, DOM_SFF8436, qsfp_calc_rx_power}, + {"txbias", 0x50, 42, 0, 8, E2_FUNC, NULL, DOM_SFF8436, qsfp_calc_tx_bias}, + {"txpower", 0x50, 50, 0, 8, E2_FUNC, NULL, DOM_SFF8436, qsfp_calc_tx_power}, +}; + +struct rj_eeprom_parse_t ssf8472_interface_id[] = { + {"type", 0x50, 0, 0, 1, E2_ENUM, sff8472_type_of_transceiver, DOM_NONE, NULL}, + {"hw_version", 0x50, 56, 0, 4, E2_STR, NULL, DOM_NONE, NULL}, + {"serial_num", 0x50, 68, 0, 16, E2_STR, NULL, DOM_NONE, NULL}, + {"manufacture_name", 0x50, 20, 0, 16, E2_STR, NULL, DOM_NONE, NULL}, + {"model_name", 0x50, 40, 0, 16, E2_STR, NULL, DOM_NONE, NULL}, + {"connector", 0x50, 2, 0, 1, E2_ENUM, sff8472_connector, DOM_NONE, NULL}, + {"encoding", 0x50, 11, 0, 1, E2_ENUM, sff8472_encoding_codes, DOM_NONE, NULL}, + {"ext_identifier", 0x50, 1, 0, 1, E2_ENUM, sff8472_exttypeoftransceiver, DOM_NONE, NULL}, + {"ext_rateselect_compliance", 0x50, 13, 0, 1, E2_ENUM, sff8472_rate_identifier, DOM_NONE, NULL}, + {"cable_length", 0x50, 14, 0, 6, E2_FUNC, NULL, DOM_NONE, sfp_cable_length_display}, /* 14~19 */ + {"nominal_bit_rate", 0x50, 12, 0, 1, E2_INT, NULL, DOM_NONE, NULL}, + {"sepecification_compliance", 0x50, 3, 0, 8, E2_FUNC, NULL, DOM_NONE, sfp_spec_comp_display}, /* 3~10 */ + {"vendor_date", 0x50, 84, 0, 8, E2_DATE, NULL, DOM_NONE, NULL}, + {"vendor_oui", 0x50, 37, 0, 3, E2_HEX, NULL, DOM_NONE, NULL}, + + {"temperature", 0x50, 352, 0, 2, E2_FUNC, NULL, DOM_SFF8472, calc_temperature}, + {"voltage", 0x50, 354, 0, 2, E2_FUNC, NULL, DOM_SFF8472, calc_voltage}, + {"rxpower", 0x50, 360, 0, 2, E2_FUNC, NULL, DOM_SFF8472, sfp_calc_rx_power}, + {"txbias", 0x50, 356, 0, 2, E2_FUNC, NULL, DOM_SFF8472, sfp_calc_tx_bias}, + {"txpower", 0x50, 358, 0, 2, E2_FUNC, NULL, DOM_SFF8472, sfp_calc_tx_power}, +}; + +#endif /* _DFD_SFPPARSE_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_slot_driver.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_slot_driver.h new file mode 100644 index 000000000000..0db7e9417182 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_slot_driver.h @@ -0,0 +1,10 @@ +#ifndef _DFD_SLOT_DRIVER_H_ +#define _DFD_SLOT_DRIVER_H_ + +int dfd_get_slot_status(unsigned int slot_index); + +ssize_t dfd_get_slot_info(unsigned int slot_index, uint8_t cmd, char *buf); + +ssize_t dfd_get_slot_status_str(unsigned int slot_index, char *buf); + +#endif /* _DFD_SLOT_DRIVER_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_syseeprom_driver.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_syseeprom_driver.h new file mode 100644 index 000000000000..3996d17cd6eb --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_syseeprom_driver.h @@ -0,0 +1,6 @@ +#ifndef _DFD_SYSEEPROM_DRIVER_H_ +#define _DFD_SYSEEPROM_DRIVER_H_ + +ssize_t dfd_get_syseeprom_info(uint8_t type, char *buf); + +#endif /* _DFD_SYSEEPROM_DRIVER_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_tlveeprom.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_tlveeprom.h new file mode 100644 index 000000000000..742bb44604c7 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_tlveeprom.h @@ -0,0 +1,70 @@ +#ifndef DFD_TLVEEPROM_H +#define DFD_TLVEEPROM_H + +#ifndef be16_to_cpu +#define be16_to_cpu(x) ntohs(x) +#endif + +#ifndef cpu_to_be16 +#define cpu_to_be16(x) htons(x) +#endif + +#define TLV_CODE_NAME_LEN 64 + +/* + * Struct for displaying the TLV codes and names. + */ +struct tlv_code_desc { + uint8_t m_code; + char m_name[TLV_CODE_NAME_LEN]; +}; + +typedef struct dfd_tlv_type_s { + uint8_t main_type; + uint8_t ext_type; +} dfd_tlv_type_t; + +/* Header Field Constants */ +#define TLV_INFO_ID_STRING "TlvInfo" +#define TLV_INFO_VERSION 0x01 + +struct __attribute__ ((__packed__)) tlvinfo_header_s { + char signature[8]; /* 0x00 - 0x07 EEPROM Tag "TlvInfo" */ + uint8_t version; /* 0x08 Structure version */ + uint16_t totallen; /* 0x09 - 0x0A Length of all data which follows */ +}; +typedef struct tlvinfo_header_s tlvinfo_header_t; + +/* + * TlvInfo TLV: Layout of a TLV field + */ +struct __attribute__ ((__packed__)) tlvinfo_tlv_s { + uint8_t type; + uint8_t length; + uint8_t value[0]; +}; +typedef struct tlvinfo_tlv_s tlvinfo_tlv_t; + +#define TLV_VALUE_MAX_LEN 255 +/* + * The max decode value is currently for the 'raw' type or the 'vendor + * extension' type, both of which have the same decode format. The + * max decode string size is computed as follows: + * + * strlen(" 0xFF") * TLV_VALUE_MAX_LEN + 1 + * + */ +#define TLV_DECODE_VALUE_MAX_LEN ((5 * TLV_VALUE_MAX_LEN) + 1) + +typedef struct tlv_decode_value_s { + uint8_t value[TLV_DECODE_VALUE_MAX_LEN]; + uint32_t length; +} tlv_decode_value_t; + +typedef enum dfd_tlvinfo_ext_tlv_type_e { + DFD_TLVINFO_EXT_TLV_TYPE_DEV_TYPE = 1, +} dfd_tlvinfo_ext_tlv_type_t; + +int dfd_tlvinfo_get_e2prom_info(uint8_t *eeprom, uint32_t size, dfd_tlv_type_t *tlv_type, uint8_t* buf, uint32_t *buf_len); + +#endif /* endif DFD_TLVEEPROM_H */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/Makefile b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/Makefile new file mode 100755 index 000000000000..95c041c09eda --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/Makefile @@ -0,0 +1,20 @@ +PWD = $(shell pwd) + +EXTRA_CFLAGS:= -I$(M)/include +EXTRA_CFLAGS+= -Wall +KBUILD_EXTRA_SYMBOLS += $(RG_PLAT_SYSFS_DIR)/rg_dev_cfg/Module.symvers + +obj-m := rg_plat_switch.o +obj-m += rg_plat_fan.o +obj-m += rg_plat_psu.o +obj-m += rg_plat_sff.o +obj-m += rg_plat_sensor.o + +all: + $(MAKE) -C $(KERNEL_SRC)/build M=$(PWD) modules + @if [ ! -d $(module_out_put_dir) ]; then mkdir -p $(module_out_put_dir) ;fi + cp -p $(PWD)/*.ko $(module_out_put_dir) +clean: + rm -f $(PWD)/*.o $(PWD)/*.ko $(PWD)/*.mod.c $(PWD)/.*.cmd $(PWD)/*.mod + rm -f $(PWD)/Module.markers $(PWD)/Module.symvers $(PWD)/modules.order + rm -rf $(PWD)/.tmp_versions diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/include/rg_plat_switch.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/include/rg_plat_switch.h new file mode 100644 index 000000000000..4001940c4321 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/include/rg_plat_switch.h @@ -0,0 +1,86 @@ +#ifndef _RG_PLAT_SWITCH_H_ +#define _RG_PLAT_SWITCH_H_ + +#include +#include +#include +#include +#include +#include +#include +#include + +enum LOG_LEVEL{ + INFO = 0x1, + ERR = 0x2, + DBG = 0x4, + ALL = 0xf +}; + +#define LOG_INFO(_prefix, fmt, args...) \ + do { \ + if (g_loglevel & INFO) \ + { \ + printk( KERN_INFO _prefix "%s "fmt, __FUNCTION__, ##args); \ + } \ + } while (0) + +#define LOG_ERR(_prefix, fmt, args...) \ + do { \ + if (g_loglevel & ERR) \ + { \ + printk( KERN_ERR _prefix "%s "fmt, __FUNCTION__, ##args); \ + } \ + } while (0) + +#define LOG_DBG(_prefix, fmt, args...) \ + do { \ + if (g_loglevel & DBG) \ + { \ + printk( KERN_DEBUG _prefix "%s "fmt, __FUNCTION__, ##args); \ + } \ + } while (0) + +#define check_pfun(p) \ + do { \ + if (p == NULL) { \ + printk( KERN_ERR "%s, %s = NULL.\n", __FUNCTION__, #p); \ + return -ENOSYS; \ + } \ + }while(0) + +#define check_p(p) check_pfun(p) + +#define to_switch_obj(x) container_of(x, struct switch_obj, kobj) +#define to_switch_attr(x) container_of(x, struct switch_attribute, attr) +#define to_switch_device_attr(x) container_of(x, struct switch_device_attribute, switch_attr) + +#define SWITCH_ATTR(_name, _mode, _show, _store, _type) \ + { .switch_attr = __ATTR(_name, _mode, _show, _store), \ + .type = _type } + +#define SWITCH_DEVICE_ATTR(_name, _mode, _show, _store, _type) \ +struct switch_device_attribute switch_dev_attr_##_name \ + = SWITCH_ATTR(_name, _mode, _show, _store, _type) + +struct switch_obj { + struct kobject kobj; + unsigned int index; +}; + +/* a custom attribute that works just for a struct switch_obj. */ +struct switch_attribute { + struct attribute attr; + ssize_t (*show)(struct switch_obj *foo, struct switch_attribute *attr, char *buf); + ssize_t (*store)(struct switch_obj *foo, struct switch_attribute *attr, const char *buf, size_t count); +}; + +struct switch_device_attribute { + struct switch_attribute switch_attr; + int type; +}; + +extern struct switch_obj *rg_plat_kobject_create(const char *name, struct kobject *parent); +extern void rg_plat_kobject_delete(struct switch_obj **obj); + +#endif /* _RG_PLAT_SWITCH_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/include/rg_sysfs_common.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/include/rg_sysfs_common.h new file mode 100644 index 000000000000..cc457c8702f7 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/include/rg_sysfs_common.h @@ -0,0 +1,194 @@ +#ifndef _RG_SYSFS_COMMON_H_ +#define _RG_SYSFS_COMMON_H_ + +#define RG_GET_SFF_SLOT(port) (((port) >> 24) & 0xff) +#define RG_GET_SFF_INDEX(port) (((port) >> 16) & 0xff) +#define RG_GET_SFF_I2C_ADAPTER(port) (((port) >> 8) & 0xff) +#define RG_GET_SFF_SPEED_MODE(port) ((port) & 0xff) + +#define TLV_CODE_PRODUCT_NAME (0x21) +#define TLV_CODE_PART_NUMBER (0x22) +#define TLV_CODE_SERIAL_NUMBER (0x23) +#define TLV_CODE_MAC_BASE (0x24) +#define TLV_CODE_MANUF_DATE (0x25) +#define TLV_CODE_DEVICE_VERSION (0x26) +#define TLV_CODE_LABEL_REVISION (0x27) +#define TLV_CODE_PLATFORM_NAME (0x28) +#define TLV_CODE_ONIE_VERSION (0x29) +#define TLV_CODE_MAC_SIZE (0x2A) +#define TLV_CODE_MANUF_NAME (0x2B) +#define TLV_CODE_MANUF_COUNTRY (0x2C) +#define TLV_CODE_VENDOR_NAME (0x2D) +#define TLV_CODE_DIAG_VERSION (0x2E) +#define TLV_CODE_SERVICE_TAG (0x2F) +#define TLV_CODE_VENDOR_EXT (0xFD) +#define TLV_CODE_CRC_32 (0xFE) + +#define DIR_NAME_MAX_LEN (64) + +#define RG_SYSFS_DEV_ERROR "no_support" +/* sysfs directory name */ +#define RG_FAN_SYSFS_NAME "fan" +#define RG_PSU_SYSFS_NAME "psu" +#define RG_SLOT_SYSFS_NAME "slot" +#define RG_CPLD_SYSFS_NAME "cpld" +#define RG_VOLTAGE_SYSFS_NAME "in" +#define RG_TEMP_SYSFS_NAME "temp" +#define RG_SFF_SYSFS_NAME "sff" +#define RG_SFF_25GE_SYSFS_NAME "Eth25GE" +#define RG_SFF_100GE_SYSFS_NAME "Eth100GE" + +typedef enum dfd_dev_info_type_e { + DFD_DEV_INFO_TYPE_MAC = 1, + DFD_DEV_INFO_TYPE_NAME = 2, + DFD_DEV_INFO_TYPE_SN = 3, + DFD_DEV_INFO_TYPE_PWR_CONS = 4, + DFD_DEV_INFO_TYPE_HW_INFO = 5, + DFD_DEV_INFO_TYPE_DEV_TYPE = 6, + DFD_DEV_INFO_TYPE_PART_NAME = 7, + DFD_DEV_INFO_TYPE_PART_NUMBER = 8, /* part number */ +} dfd_dev_tlv_type_t; + +typedef enum rg_led_e { + RG_SYS_LED_FRONT = 0, + RG_SYS_LED_REAR = 1, + RG_BMC_LED_FRONT = 2, + RG_BMC_LED_REAR = 3, + RG_FAN_LED_FRONT = 4, + RG_FAN_LED_REAR = 5, + RG_PSU_LED_FRONT = 6, + RG_PSU_LED_REAR = 7, + RG_ID_LED_FRONT = 8, + RG_ID_LED_REAR = 9, + RG_FAN_LED_MODULE = 10, + RG_PSU_LED_MODULE = 11, + RG_SLOT_LED_MODULE = 12, +} rg_led_t; + +typedef enum rg_main_dev_type_e { + RG_MAIN_DEV_MAINBOARD = 0, + RG_MAIN_DEV_FAN = 1, + RG_MAIN_DEV_PSU = 2, + RG_MAIN_DEV_SFF = 3, + RG_MAIN_DEV_CPLD = 4, /* CPLD */ + RG_MAIN_DEV_SLOT = 5, +} rg_main_dev_type_t; + +typedef enum rg_minor_dev_type_e { + RG_MINOR_DEV_NONE = 0, /* None */ + RG_MINOR_DEV_TEMP = 1, + RG_MINOR_DEV_IN = 2, + RG_MINOR_DEV_CURR = 3, + RG_MINOR_DEV_POWER = 4, + RG_MINOR_DEV_MOTOR = 5, + RG_MINOR_DEV_PSU = 6, +} rg_minor_dev_type_t; + +typedef enum rg_sensor_type_e { + RG_SENSOR_INPUT = 0, + RG_SENSOR_ALIAS = 1, + RG_SENSOR_TYPE = 2, + RG_SENSOR_MAX = 3, + RG_SENSOR_MAX_HYST = 4, + RG_SENSOR_MIN = 5, + RG_SENSOR_CRIT = 6, +} rg_sensor_type_t; + +typedef enum rg_sff_speed_type_e { + RG_SFF_SPEED_NONE = 0, /* None */ + RG_SFF_SPEED_25GE = 1, + RG_SFF_SPEED_100GE = 2, + RG_SFF_SPEED_50GE = 3, +} rg_sff_speed_type_t; + +typedef enum rg_sff_cpld_attr_e { + RG_SFF_POWER_ON = 0x01, + RG_SFF_TX_FAULT, + RG_SFF_TX_DIS, + RG_SFF_PRE_N, + RG_SFF_RX_LOS, + RG_SFF_RESET, + RG_SFF_LPMODE, + RG_SFF_MODULE_PRESENT, + RG_SFF_INTERRUPT, +} rg_sff_cpld_attr_t; + +typedef enum rg_sff_eeprom_attr_e { + RG_SFF_TYPE = 0x01, + RG_SFF_HW_VERSION, + RG_SFF_SERIAL_NUM, + RG_SFF_MANUFACTURE_NAME, + RG_SFF_MODEL_NAME, + RG_SFF_CONNECTOR, + RG_SFF_ENCODING, + RG_SFF_EXT_IDENTIFIER, + RG_SFF_EXT_RATESELECT_COMPLIANCE, + RG_SFF_CABLE_LENGTH, + RG_SFF_NOMINAL_BIT_RATE, + RG_SFF_SEPECIFICATION_COMPLIANCE, + RG_SFF_VENDOR_DATE, + RG_SFF_VENDOR_OUI, + RG_SFF_TEMPERATURE, + RG_SFF_VOLTAGE, + RG_SFF_RXPOWER, + RG_SFF_TXBIAS, + RG_SFF_TXPOWER, +} rg_sff_eeprom_attr_t; + +struct switch_drivers_t{ + /* device */ + int (*get_dev_number) (unsigned int main_dev_id, unsigned int minor_dev_id); + /* fan */ + int (*get_fan_number) (void); + int (*get_fan_status) (unsigned int fan_index); + ssize_t (*get_fan_info) (unsigned int fan_index, uint8_t cmd, char* buf); + ssize_t (*get_fan_speed) (unsigned int fan_index, unsigned int motor_index, unsigned int *speed); + int (*get_fan_pwm) (unsigned int fan_index, unsigned int motor_index, int *pwm); + int (*set_fan_pwm) (unsigned int fan_index, unsigned int motor_index, int pwm); + int (*get_fan_speed_tolerance) (unsigned int fan_index, unsigned int motor_index, int *value); + int (*get_fan_speed_target) (unsigned int fan_index, unsigned int motor_index, int *value); + int (*get_fan_direction) (unsigned int fan_index, unsigned int motor_index, int *value); + ssize_t (*get_fan_status_str) (unsigned int fan_index, char* buf); + ssize_t (*get_fan_direction_str) (unsigned int fan_index, unsigned int motor_index, char* buf); + int (*get_fan_present_status)(unsigned int fan_index); + int (*get_fan_roll_status)(unsigned int fan_index, unsigned int motor_index); + int (*get_fan_speed_level)(unsigned int fan_index, unsigned int motor_index, int *level); + int (*set_fan_speed_level)(unsigned int fan_index, unsigned int motor_index, int level); + /* syseeprom */ + ssize_t (*get_syseeprom_info) (uint8_t cmd, char* buf); + /* cpld */ + ssize_t (*get_cpld_name) (unsigned int cpld_index, char* buf); + ssize_t (*get_cpld_type) (unsigned int cpld_index, char* buf); + ssize_t (*get_cpld_version) (unsigned int cpld_index, char* buf); + int (*get_cpld_testreg) (unsigned int cpld_index, int *value); + int (*set_cpld_testreg) (unsigned int cpld_index, int value); + /* led */ + ssize_t (*get_led_status) (uint16_t led_id, uint8_t led_index, char *buf); + /* slot */ + ssize_t (*get_slot_status_str) (unsigned int slot_index, char* buf); + ssize_t (*get_slot_info) (unsigned int slot_index, uint8_t cmd, char *buf); + /* sensors */ + ssize_t (*get_temp_info)( uint8_t main_dev_id, uint8_t dev_index, + uint8_t temp_index, uint8_t temp_attr, char *buf); + ssize_t (*get_voltage_info)( uint8_t main_dev_id, uint8_t dev_index, + uint8_t in_index, uint8_t in_attr, char *buf); + /* psu */ + ssize_t (*get_psu_info)( unsigned int psu_index, uint8_t cmd, char *buf); + ssize_t (*get_psu_status_str) (unsigned int psu_index, char *buf); + ssize_t (*get_psu_sensor_info)( uint8_t psu_index, uint8_t sensor_type, char *buf); + int (*get_psu_present_status)(unsigned int psu_index); + int (*get_psu_output_status)(unsigned int psu_index); + int (*get_psu_alert_status)(unsigned int psu_index); + /* sff */ + int (*get_sff_id) (unsigned int sff_index); + int (*set_sff_cpld_info)(unsigned int sff_index, int cpld_reg_type, int value); + ssize_t (*get_sff_cpld_info)( unsigned int sff_index, int cpld_reg_type, char *buf, int len); + ssize_t (*get_sff_eeprom_info)(unsigned int sff_index, const char *attr_name, char *buf, int buf_len); + ssize_t (*get_sff_dir_name)(unsigned int sff_index, char *buf, int buf_len); + int (*get_sff_polling_size) (void); + ssize_t (*get_sff_polling_data)(unsigned int sff_index, char *buf, loff_t offset, size_t count); +}; + +extern struct switch_drivers_t * dfd_plat_driver_get(void); + +#endif /*_RG_SYSFS_COMMON_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/rg_plat_fan.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/rg_plat_fan.c new file mode 100644 index 000000000000..2e48149e4708 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/rg_plat_fan.c @@ -0,0 +1,544 @@ +/* + * Copyright(C) 2001-2012 Ruijie Network. All rights reserved. + */ +/* + * rg_plat_fan.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * This module create fan kobjects and attributes in /sys/rg_plat/fan + * + * History + * [Version] [Author] [Date] [Description] + * * v1.0 sonic_rd@ruijie.com.cn 2020-02-17 Initial version + */ + +#include + +#include "./include/rg_plat_switch.h" +#include "./include/rg_sysfs_common.h" + +#define FAN_INFO(fmt, args...) LOG_INFO("fan: ", fmt, ##args) +#define FAN_ERR(fmt, args...) LOG_ERR("fan: ", fmt, ##args) +#define FAN_DBG(fmt, args...) LOG_DBG("fan: ", fmt, ##args) + +struct motor_obj_t{ + struct switch_obj *obj; +}; + +struct fan_obj_t{ + unsigned int motor_number; + struct motor_obj_t *motor; + struct switch_obj *obj; +}; + +struct fan_t{ + unsigned int fan_number; + struct fan_obj_t *fan; +}; + +static int g_loglevel = 0; +static struct fan_t g_fan; +static struct switch_obj *g_fan_obj = NULL; +static struct switch_drivers_t *g_drv = NULL; + +static ssize_t fan_number_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", g_fan.fan_number); +} + +static ssize_t fan_motor_number_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int index; + + index = obj->index; + FAN_DBG("fan_motor_number_show,fan index:%d\n",index); + + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", g_fan.fan[index-1].motor_number); +} + +static ssize_t fan_roll_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int fan_index, motor_index; + struct switch_obj *p_obj; + int ret; + + check_p(g_drv); + check_p(g_drv->get_fan_roll_status); + + p_obj = to_switch_obj(obj->kobj.parent); + check_p(p_obj); + + fan_index = p_obj->index; + motor_index = obj->index; + + ret = g_drv->get_fan_roll_status(fan_index, motor_index); + if (ret < 0 ) { + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", RG_SYSFS_DEV_ERROR); + } + + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", ret); +} + +static ssize_t fan_present_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int fan_index; + int ret; + + fan_index = obj->index; + FAN_DBG("fan_present_status_show, fan index:%d\n",fan_index); + check_p(g_drv); + check_p(g_drv->get_fan_present_status); + + ret = g_drv->get_fan_present_status(fan_index); + if(ret < 0) { + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", RG_SYSFS_DEV_ERROR); + } + + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", ret); +} + +static ssize_t fan_speed_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int fan_index, motor_index, speed; + int ret; + struct switch_obj *p_obj; + + check_p(g_drv); + check_p(g_drv->get_fan_speed); + + p_obj = to_switch_obj(obj->kobj.parent); + check_p(p_obj); + + fan_index = p_obj->index; + motor_index = obj->index; + + ret = g_drv->get_fan_speed(fan_index, motor_index, &speed); + if(ret < 0) { + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", RG_SYSFS_DEV_ERROR); + } + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", speed); +} + +static ssize_t fan_motor_ratio_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int fan_index, motor_index; + struct switch_obj *p_obj; + int ret, pwm; + + check_p(g_drv); + check_p(g_drv->get_fan_pwm); + + p_obj = to_switch_obj(obj->kobj.parent); + check_p(p_obj); + fan_index = p_obj->index; + motor_index = obj->index; + ret = g_drv->get_fan_pwm(fan_index, motor_index, &pwm); + + if (ret < 0 ) { + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", RG_SYSFS_DEV_ERROR); + } + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", pwm); +} + +static ssize_t fan_motor_ratio_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int fan_index, motor_index; + struct switch_obj *p_obj; + int ret, pwm; + + check_p(g_drv); + check_p(g_drv->set_fan_pwm); + + p_obj = to_switch_obj(obj->kobj.parent); + check_p(p_obj); + + fan_index = p_obj->index; + motor_index = obj->index; + sscanf(buf, "%d", &pwm); + + if (pwm < 0 || pwm > 100) { + FAN_ERR("can not set pwm = %d.\n", pwm); + return -EINVAL; + } + ret = g_drv->set_fan_pwm(fan_index, motor_index, pwm); + if (ret < 0) { + FAN_ERR("can not set pwm = %d.\n", pwm); + return -EIO; + } + return count; +} + +/************************************fan dir and attrs*******************************************/ +static struct switch_attribute fan_number_att = __ATTR(num_fans, S_IRUGO, fan_number_show, NULL); + +static struct attribute *fan_dir_attrs[] = { + &fan_number_att.attr, + NULL, +}; + +static struct attribute_group fan_root_attr_group = { + .attrs = fan_dir_attrs, +}; + +/*******************************fan1 fan2 dir and attrs*******************************************/ +static struct switch_attribute fan_num_motors_att = __ATTR(num_motors, S_IRUGO, fan_motor_number_show, NULL); +static struct switch_attribute fan_present_att = __ATTR(present, S_IRUGO, fan_present_status_show, NULL); + +static struct attribute *fan_attrs[] = { + &fan_num_motors_att.attr, + &fan_present_att.attr, + NULL, +}; + +static struct attribute_group fan_attr_group = { + .attrs = fan_attrs, +}; + +/*******************************motor0 motor1 dir and attrs*******************************************/ +static struct switch_attribute motor_speed_att = __ATTR(speed, S_IRUGO, fan_speed_show, NULL); +static struct switch_attribute motor_status_att = __ATTR(status, S_IRUGO, fan_roll_status_show, NULL); +static struct switch_attribute motor_ratio_att = __ATTR(ratio, S_IRUGO | S_IWUSR, fan_motor_ratio_show, fan_motor_ratio_store); + +static struct attribute *motor_attrs[] = { + &motor_speed_att.attr, + &motor_status_att.attr, + &motor_ratio_att.attr, + NULL, +}; + +static struct attribute_group motor_attr_group = { + .attrs = motor_attrs, +}; + +static void fanindex_single_motor_remove_kobj_and_attrs(struct fan_obj_t * curr_fan, unsigned int motor_index) +{ + + struct motor_obj_t * curr_motor; /* point to motor0 motor1...*/ + + if (curr_fan == NULL) { + FAN_ERR("fan remove attrs failed, curr_fan is NULL.\n"); + return ; + } + + if (motor_index + 1 > curr_fan->motor_number) { + FAN_ERR("params error. motor index:%d.\n", motor_index); + return ; + } + curr_motor = &curr_fan->motor[motor_index]; + + if (curr_motor->obj) { + sysfs_remove_group(&curr_motor->obj->kobj, &motor_attr_group); + rg_plat_kobject_delete(&curr_motor->obj); + } + + FAN_DBG("delete fan:%d motor%d.\n", curr_fan->obj->index, motor_index); + return ; +} + +static int fanindex_single_motor_create_kobj_and_attrs(struct fan_obj_t * curr_fan, unsigned int motor_index) +{ + char name[8]; + struct motor_obj_t * curr_motor; /* point to motor0 motor1...*/ + + check_p(curr_fan); + + if (motor_index + 1 > curr_fan->motor_number) { + FAN_ERR("motor number = %d, motor%d error.\n", curr_fan->motor_number, motor_index); + return -EINVAL; + } + FAN_DBG("create fan_index:%d, motor%d ...\n", curr_fan->obj->index, motor_index); + + curr_motor = &curr_fan->motor[motor_index]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "motor%d", motor_index); + curr_motor->obj = rg_plat_kobject_create(name, &curr_fan->obj->kobj); + if (!curr_motor->obj) { + FAN_ERR("create fan_index:%d, motor%d object error!\n", curr_fan->obj->index, motor_index); + return -EBADRQC; + } + curr_motor->obj->index = motor_index; + if (sysfs_create_group(&curr_motor->obj->kobj, &motor_attr_group) != 0) { + FAN_ERR("create fan_index:%d, motor%d attrs error.\n", curr_fan->obj->index, motor_index); + rg_plat_kobject_delete(&curr_motor->obj); + return -EBADRQC; + } + FAN_DBG("create fan_index:%d, motor%d ok.\n", curr_fan->obj->index, motor_index); + return 0; +} + +static int fanindex_motor_create_kobj_and_attrs(struct fan_obj_t * curr_fan, int motor_num) +{ + int motor_index, i; + + check_p(curr_fan); + + curr_fan->motor = kzalloc(sizeof(struct motor_obj_t) * motor_num, GFP_KERNEL); + if (!curr_fan->motor) { + FAN_ERR("kzalloc motor error, fan index = %d, motor number = %d.\n", curr_fan->obj->index, motor_num); + return -ENOMEM; + } + curr_fan->motor_number = motor_num; + for(motor_index = 0; motor_index < motor_num; motor_index++) { + if(fanindex_single_motor_create_kobj_and_attrs(curr_fan, motor_index) != 0 ) { + goto motor_error; + } + } + return 0; +motor_error: + for(i = 0; i < motor_index; i++) { + fanindex_single_motor_remove_kobj_and_attrs(curr_fan, i); + } + if(curr_fan->motor) { + kfree(curr_fan->motor); + curr_fan->motor = NULL; + } + return -EBADRQC; +} + +static void fanindex_motor_remove_kobj_and_attrs(struct fan_obj_t * curr_fan, int motor_num) +{ + unsigned int motor_index; + + if (motor_num < 0 || curr_fan == NULL) { + FAN_ERR("params error.motor number = %d \n", motor_num); + return ; + } + + for(motor_index = 0; motor_index < motor_num; motor_index++) { + fanindex_single_motor_remove_kobj_and_attrs(curr_fan, motor_index); + } + return ; +} + +static int fan_motor_create(void) +{ + int fan_num, motor_num; + unsigned int fan_index, i; + struct fan_obj_t * curr_fan; /* point to fan1 fan2...*/ + + check_p(g_drv->get_dev_number); + + motor_num = g_drv->get_dev_number(RG_MAIN_DEV_FAN, RG_MINOR_DEV_MOTOR); + if (motor_num <= 0) { + FAN_ERR("get fan motor number error, motor_num:%d error.\n", motor_num); + return -ENODEV; + } + + fan_num = g_fan.fan_number; + for(fan_index = 1; fan_index <= fan_num; fan_index++) { + curr_fan = &g_fan.fan[fan_index - 1]; + if(fanindex_motor_create_kobj_and_attrs(curr_fan, motor_num) != 0) { + goto error; + } + } + return 0; +error: + for(i = 1; i < fan_index; i++) { + curr_fan = &g_fan.fan[i - 1]; + motor_num = curr_fan->motor_number; + fanindex_motor_remove_kobj_and_attrs(curr_fan, motor_num); + } + return -EBADRQC; +} + +static void fan_motor_remove(void) +{ + unsigned int fan_index; + struct fan_obj_t * curr_fan; + if (g_fan.fan) { + for(fan_index = 1; fan_index <= g_fan.fan_number; fan_index++) { + curr_fan = &g_fan.fan[fan_index - 1]; + if (curr_fan->motor) { + fanindex_motor_remove_kobj_and_attrs(curr_fan,curr_fan->motor_number); + kfree(curr_fan->motor); + curr_fan->motor = NULL; + curr_fan->motor_number = 0; + } + } + } + return ; +} + +static int fan_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct fan_obj_t * curr_fan; + + if (index > g_fan.fan_number) { + FAN_ERR("fan number = %d, fan%d error.\n", g_fan.fan_number, index); + return -EINVAL; + } + curr_fan = &g_fan.fan[index-1]; + if (curr_fan->obj) { + sysfs_remove_group(&curr_fan->obj->kobj, &fan_attr_group); + rg_plat_kobject_delete(&curr_fan->obj); + } + + FAN_DBG("delete fan%d.\n", index); + return 0; +} + +static int fan_sub_single_create_kobj_and_attrs(struct kobject *parent, unsigned int index) +{ + char name[8]; + struct fan_obj_t * curr_fan; + + if (index > g_fan.fan_number) { + FAN_ERR("fan number = %d, fan%d error.\n", g_fan.fan_number, index); + return -EINVAL; + } + curr_fan = &g_fan.fan[index-1]; + FAN_DBG("create fan%d ...\n", index); + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "fan%d", index); + curr_fan->obj = rg_plat_kobject_create(name, parent); + if (!curr_fan->obj) { + FAN_ERR("create fan%d object error!\n", index); + return -EBADRQC; + } + curr_fan->obj->index = index; + if (sysfs_create_group(&curr_fan->obj->kobj, &fan_attr_group) != 0) { + FAN_ERR("create fan%d attrs error.\n", index); + rg_plat_kobject_delete(&curr_fan->obj); + return -EBADRQC; + } + FAN_DBG("create fan%d ok.\n", index); + return 0; +} + +static int fan_sub_create_kobj_and_attrs(struct kobject *parent, int fan_num) +{ + unsigned int fan_index, i; + + if(fan_num < 0) { + FAN_ERR("fan number = %d error.\n", fan_num); + return -EINVAL; + } + g_fan.fan = kzalloc(sizeof(struct fan_obj_t) * fan_num, GFP_KERNEL); + if (!g_fan.fan) { + FAN_ERR("kzalloc fan.fan error, fan number = %d.\n", fan_num); + return -ENOMEM; + } + + for(fan_index = 1; fan_index <= fan_num; fan_index++) { + if(fan_sub_single_create_kobj_and_attrs(parent, fan_index) != 0 ) { + goto error; + } + } + return 0; +error: + for(i = 1; i < fan_index; i++) { + fan_sub_single_remove_kobj_and_attrs(i); + } + if(g_fan.fan) { + kfree(g_fan.fan); + g_fan.fan = NULL; + } + return -EBADRQC; +} + +static int fan_sub_create(void) +{ + int ret, fan_num; + + check_p(g_drv->get_dev_number); + fan_num = g_drv->get_dev_number(RG_MAIN_DEV_FAN, RG_MINOR_DEV_NONE); + if (fan_num < 0) { + FAN_ERR("fan number = %d error.\n", fan_num); + return -EINVAL; + } + g_fan.fan_number = fan_num; + ret = fan_sub_create_kobj_and_attrs(&g_fan_obj->kobj, fan_num); + return ret; +} + +static void fan_sub_remove(void) +{ + unsigned int fan_index; + + if (g_fan.fan) { + for (fan_index = 1; fan_index <= g_fan.fan_number; fan_index++) { + if (g_fan.fan[fan_index-1].obj) { + fan_sub_single_remove_kobj_and_attrs(fan_index); + } + } + kfree(g_fan.fan); + } + memset(&g_fan, 0, sizeof(struct fan_t)); + return ; +} + +static int fan_root_create(void) +{ + g_fan_obj = rg_plat_kobject_create("fan", NULL); + if (!g_fan_obj) + return -ENOMEM; + + if (sysfs_create_group(&g_fan_obj->kobj, &fan_root_attr_group) != 0) { + rg_plat_kobject_delete(&g_fan_obj); + FAN_ERR("create fan dir attrs error!\n"); + return -EBADRQC; + } + return 0; + +} + +static void fan_root_remove(void) +{ + if (g_fan_obj) { + sysfs_remove_group(&g_fan_obj->kobj, &fan_root_attr_group); + rg_plat_kobject_delete(&g_fan_obj); + } + + return ; +} + +static int fan_init(void) +{ + int ret; + + FAN_INFO("fan_init...\n"); + g_drv = dfd_plat_driver_get(); + check_p(g_drv); + + ret = fan_root_create(); + if (ret < 0) { + goto fan_root_error; + } + + ret = fan_sub_create(); + if (ret < 0) { + goto fan_sub_error; + } + + ret = fan_motor_create(); + if (ret < 0) { + goto fan_motor_error; + } + + FAN_INFO("fan_init ok.\n"); + return 0; +fan_motor_error: + fan_sub_remove(); +fan_sub_error: + fan_root_remove(); +fan_root_error: + return ret; +} + +static void fan_exit(void) +{ + fan_motor_remove(); + fan_sub_remove(); + fan_root_remove(); + FAN_INFO("fan_exit ok.\n"); + return ; +} + +module_init(fan_init); +module_exit(fan_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd "); +MODULE_DESCRIPTION("RUIJIE fan sysfs driver"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/rg_plat_psu.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/rg_plat_psu.c new file mode 100644 index 000000000000..e5a04be1aeed --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/rg_plat_psu.c @@ -0,0 +1,458 @@ +/* + * Copyright(C) 2001-2012 Ruijie Network. All rights reserved. + */ +/* + * rg_plat_psu.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * This module create psu kobjects and attributes in /sys/rg_plat/psu + * + * History + * [Version] [Author] [Date] [Description] + * * v1.0 sonic_rd@ruijie.com.cn 2020-02-17 Initial version + */ + +#include + +#include "./include/rg_plat_switch.h" +#include "./include/rg_sysfs_common.h" + +#define PSU_INFO(fmt, args...) LOG_INFO("psu: ", fmt, ##args) +#define PSU_ERR(fmt, args...) LOG_ERR("psu: ", fmt, ##args) +#define PSU_DBG(fmt, args...) LOG_DBG("psu: ", fmt, ##args) + +struct temp_obj_t{ + struct switch_obj *obj; +}; + +struct psu_obj_t{ + unsigned int temp_number; + struct temp_obj_t *temp; + struct switch_obj *obj; +}; + +struct psu_t{ + unsigned int psu_number; + struct psu_obj_t *psu; +}; + +static int g_loglevel = 0; +static struct psu_t g_psu; +static struct switch_obj *g_psu_obj = NULL; +static struct switch_drivers_t *g_drv = NULL; + +static ssize_t psu_number_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", g_psu.psu_number); +} + +static ssize_t psu_present_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + psu_index = obj->index; + PSU_DBG("psu_present_status_show, psu index:%d\n",psu_index); + check_p(g_drv); + check_p(g_drv->get_psu_present_status); + + ret = g_drv->get_psu_present_status(psu_index); + if(ret < 0) { + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", RG_SYSFS_DEV_ERROR); + } + + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", ret); +} + +static ssize_t psu_output_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + psu_index = obj->index; + PSU_DBG("psu_output_status_show, psu index:%d\n",psu_index); + check_p(g_drv); + check_p(g_drv->get_psu_output_status); + + ret = g_drv->get_psu_output_status(psu_index); + if(ret < 0) { + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", RG_SYSFS_DEV_ERROR); + } + + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", ret); +} + +static ssize_t psu_alert_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + psu_index = obj->index; + PSU_DBG("psu_alert_status_show, psu index:%d\n",psu_index); + check_p(g_drv); + check_p(g_drv->get_psu_alert_status); + + ret = g_drv->get_psu_alert_status(psu_index); + if(ret < 0) { + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", RG_SYSFS_DEV_ERROR); + } + + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", ret); +} + +/************************************psu dir and attrs*******************************************/ +static struct switch_attribute psu_number_att = __ATTR(num_psus, S_IRUGO, psu_number_show, NULL); + +static struct attribute *psu_dir_attrs[] = { + &psu_number_att.attr, + NULL, +}; + +static struct attribute_group psu_root_attr_group = { + .attrs = psu_dir_attrs, +}; + +/*******************************psu1 psu2 dir and attrs*******************************************/ +static struct switch_attribute psu_present_status_att = __ATTR(present, S_IRUGO, psu_present_status_show, NULL); +static struct switch_attribute psu_output_status_att = __ATTR(output, S_IRUGO, psu_output_status_show, NULL); +static struct switch_attribute psu_alert_status_att = __ATTR(alert, S_IRUGO, psu_alert_status_show, NULL); + +static struct attribute *psu_attrs[] = { + &psu_present_status_att.attr, + &psu_output_status_att.attr, + &psu_alert_status_att.attr, + NULL, +}; + +static struct attribute_group psu_attr_group = { + .attrs = psu_attrs, +}; + +/*******************************psu temp0 temp1 dir and attrs*******************************************/ +static struct attribute *psu_temp_attrs[] = { + NULL, +}; + +static struct attribute_group psu_temp_attr_group = { + .attrs = psu_temp_attrs, +}; + +static void psuindex_single_temp_remove_kobj_and_attrs(struct psu_obj_t * curr_psu, unsigned int temp_index) +{ + + struct temp_obj_t * curr_temp; /* point to temp0 temp1...*/ + + if (curr_psu == NULL) { + PSU_ERR("psu remove attrs failed, curr_psu is NULL.\n"); + return ; + } + + if (temp_index + 1 > curr_psu->temp_number) { + PSU_ERR("params error. temp index:%d.\n", temp_index); + return ; + } + curr_temp = &curr_psu->temp[temp_index]; + + if (curr_temp->obj) { + sysfs_remove_group(&curr_temp->obj->kobj, &psu_temp_attr_group); + rg_plat_kobject_delete(&curr_temp->obj); + } + + PSU_DBG("delete psu:%d temp%d.\n", curr_psu->obj->index, temp_index); + return ; +} + +static int psuindex_single_temp_create_kobj_and_attrs(struct psu_obj_t * curr_psu, unsigned int temp_index) +{ + char name[DIR_NAME_MAX_LEN]; + struct temp_obj_t * curr_temp; /* point to temp0 temp1...*/ + + check_p(curr_psu); + + PSU_DBG("create psu_index:%d, temp%d ...\n", curr_psu->obj->index, temp_index); + + curr_temp = &curr_psu->temp[temp_index]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "temp%d", temp_index); + curr_temp->obj = rg_plat_kobject_create(name, &curr_psu->obj->kobj); + if (!curr_temp->obj) { + PSU_ERR("create psu_index:%d, temp%d object error!\n", curr_psu->obj->index, temp_index); + return -EBADRQC; + } + curr_temp->obj->index = temp_index; + if (sysfs_create_group(&curr_temp->obj->kobj, &psu_temp_attr_group) != 0) { + PSU_ERR("create psu_index:%d, temp%d attrs error.\n", curr_psu->obj->index, temp_index); + rg_plat_kobject_delete(&curr_temp->obj); + return -EBADRQC; + } + PSU_DBG("create psu_index:%d, temp%d ok.\n", curr_psu->obj->index, temp_index); + return 0; +} + +static int psuindex_temp_create_kobj_and_attrs(struct psu_obj_t * curr_psu, int temp_num) +{ + int temp_index, i; + + check_p(curr_psu); + + curr_psu->temp = kzalloc(sizeof(struct temp_obj_t) * temp_num, GFP_KERNEL); + if (!curr_psu->temp) { + PSU_ERR("kzalloc temp error, psu index = %d, temp number = %d.\n", curr_psu->obj->index, temp_num); + return -ENOMEM; + } + curr_psu->temp_number = temp_num; + for(temp_index = 0; temp_index < temp_num; temp_index++) { + if(psuindex_single_temp_create_kobj_and_attrs(curr_psu, temp_index) != 0 ) { + goto temp_error; + } + } + return 0; +temp_error: + for(i = 0; i < temp_index; i++) { + psuindex_single_temp_remove_kobj_and_attrs(curr_psu, i); + } + if(curr_psu->temp) { + kfree(curr_psu->temp); + curr_psu->temp = NULL; + } + return -EBADRQC; +} + +static void psuindex_temp_remove_kobj_and_attrs(struct psu_obj_t * curr_psu, int temp_num) +{ + unsigned int temp_index; + + if (temp_num < 0 || curr_psu == NULL) { + PSU_ERR("params error.temp number = %d \n", temp_num); + return ; + } + + for(temp_index = 0; temp_index < temp_num; temp_index++) { + psuindex_single_temp_remove_kobj_and_attrs(curr_psu, temp_index); + } + return ; +} + +static int psu_temp_create(void) +{ + int psu_num, temp_num; + unsigned int psu_index, i; + struct psu_obj_t * curr_psu; /* point to psu1 psu2...*/ + + check_p(g_drv->get_dev_number); + + temp_num = g_drv->get_dev_number(RG_MAIN_DEV_PSU, RG_MINOR_DEV_TEMP); + if (temp_num <= 0) { + PSU_INFO("psu temp_num:%d, don't need creat temp directory.\n", temp_num); + return 0; + } + + psu_num = g_psu.psu_number; + for(psu_index = 1; psu_index <= psu_num; psu_index++) { + curr_psu = &g_psu.psu[psu_index - 1]; + if(psuindex_temp_create_kobj_and_attrs(curr_psu, temp_num) != 0) { + goto error; + } + } + return 0; +error: + for(i = 1; i < psu_index; i++) { + curr_psu = &g_psu.psu[i - 1]; + temp_num = curr_psu->temp_number; + psuindex_temp_remove_kobj_and_attrs(curr_psu, temp_num); + } + return -EBADRQC; +} + +static void psu_temp_remove(void) +{ + unsigned int psu_index; + struct psu_obj_t * curr_psu; + if (g_psu.psu) { + for(psu_index = 1; psu_index <= g_psu.psu_number; psu_index++) { + curr_psu = &g_psu.psu[psu_index - 1]; + if (curr_psu->temp) { + psuindex_temp_remove_kobj_and_attrs(curr_psu,curr_psu->temp_number); + kfree(curr_psu->temp); + curr_psu->temp = NULL; + curr_psu->temp_number = 0; + } + } + } + return ; +} + +static int psu_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct psu_obj_t * curr_psu; + + if (index > g_psu.psu_number) { + PSU_ERR("psu number = %d, psu%d error.\n", g_psu.psu_number, index); + return -EINVAL; + } + curr_psu = &g_psu.psu[index-1]; + if (curr_psu->obj) { + sysfs_remove_group(&curr_psu->obj->kobj, &psu_attr_group); + rg_plat_kobject_delete(&curr_psu->obj); + } + + PSU_DBG("delete psu%d.\n", index); + return 0; +} + +static int psu_sub_single_create_kobj_and_attrs(struct kobject *parent, unsigned int index) +{ + char name[DIR_NAME_MAX_LEN]; + struct psu_obj_t * curr_psu; + + curr_psu = &g_psu.psu[index-1]; + PSU_DBG("create psu%d ...\n", index); + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "%s%d",RG_PSU_SYSFS_NAME, index); + curr_psu->obj = rg_plat_kobject_create(name, parent); + if (!curr_psu->obj) { + PSU_ERR("create psu%d object error!\n", index); + return -EBADRQC; + } + curr_psu->obj->index = index; + if (sysfs_create_group(&curr_psu->obj->kobj, &psu_attr_group) != 0) { + PSU_ERR("create psu%d attrs error.\n", index); + rg_plat_kobject_delete(&curr_psu->obj); + return -EBADRQC; + } + PSU_DBG("create psu%d ok.\n", index); + return 0; +} + +static int psu_sub_create_kobj_and_attrs(struct kobject *parent, int psu_num) +{ + unsigned int psu_index, i; + + g_psu.psu = kzalloc(sizeof(struct psu_obj_t) * psu_num, GFP_KERNEL); + if (!g_psu.psu) { + PSU_ERR("kzalloc psu.psu error, psu number = %d.\n", psu_num); + return -ENOMEM; + } + + for(psu_index = 1; psu_index <= psu_num; psu_index++) { + if(psu_sub_single_create_kobj_and_attrs(parent, psu_index) != 0 ) { + goto error; + } + } + return 0; +error: + for(i = 1; i < psu_index; i++) { + psu_sub_single_remove_kobj_and_attrs(i); + } + if(g_psu.psu) { + kfree(g_psu.psu); + g_psu.psu = NULL; + } + return -EBADRQC; +} + +static int psu_sub_create(void) +{ + int ret, psu_num; + + check_p(g_drv->get_dev_number); + psu_num = g_drv->get_dev_number(RG_MAIN_DEV_PSU, RG_MINOR_DEV_NONE); + if (psu_num < 0) { + PSU_ERR("psu number = %d error.\n", psu_num); + return -EINVAL; + } + g_psu.psu_number = psu_num; + ret = psu_sub_create_kobj_and_attrs(&g_psu_obj->kobj, psu_num); + return ret; +} + +static void psu_sub_remove(void) +{ + unsigned int psu_index; + + if (g_psu.psu) { + for (psu_index = 1; psu_index <= g_psu.psu_number; psu_index++) { + if (g_psu.psu[psu_index-1].obj) { + psu_sub_single_remove_kobj_and_attrs(psu_index); + } + } + kfree(g_psu.psu); + } + memset(&g_psu, 0, sizeof(struct psu_t)); + return ; +} + +static int psu_root_create(void) +{ + g_psu_obj = rg_plat_kobject_create(RG_PSU_SYSFS_NAME, NULL); + if (!g_psu_obj) + return -ENOMEM; + + if (sysfs_create_group(&g_psu_obj->kobj, &psu_root_attr_group) != 0) { + rg_plat_kobject_delete(&g_psu_obj); + PSU_ERR("create psu dir attrs error!\n"); + return -EBADRQC; + } + return 0; + +} + +static void psu_root_remove(void) +{ + if (g_psu_obj) { + sysfs_remove_group(&g_psu_obj->kobj, &psu_root_attr_group); + rg_plat_kobject_delete(&g_psu_obj); + } + + return ; +} + +static int rg_psu_init(void) +{ + int ret; + + PSU_INFO("rg_psu_init...\n"); + g_drv = dfd_plat_driver_get(); + check_p(g_drv); + + ret = psu_root_create(); + if (ret < 0) { + goto psu_root_error; + } + + ret = psu_sub_create(); + if (ret < 0) { + goto psu_sub_error; + } + + ret = psu_temp_create(); + if (ret < 0) { + goto psu_temp_error; + } + + PSU_INFO("rg_psu_init ok.\n"); + return 0; +psu_temp_error: + psu_sub_remove(); +psu_sub_error: + psu_root_remove(); +psu_root_error: + return ret; +} + +static void rg_psu_exit(void) +{ + psu_temp_remove(); + psu_sub_remove(); + psu_root_remove(); + PSU_INFO("rg_psu_exit ok.\n"); + return ; +} + +module_init(rg_psu_init); +module_exit(rg_psu_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd "); +MODULE_DESCRIPTION("RUIJIE psu sysfs driver"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/rg_plat_sensor.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/rg_plat_sensor.c new file mode 100644 index 000000000000..8514d871ac91 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/rg_plat_sensor.c @@ -0,0 +1,494 @@ +/* + * Copyright(C) 2001-2012 Ruijie Network. All rights reserved. + */ +/* + * rg_plat_sensor.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * This module create sensor kobjects and attributes in /sys/rg_plat/sensor + * + * History + * [Version] [Author] [Date] [Description] + * * v1.0 sonic_rd@ruijie.com.cn 2020-02-17 Initial version + */ + +#include + +#include "./include/rg_plat_switch.h" +#include "./include/rg_sysfs_common.h" + +#define SENSOR_INFO(fmt, args...) LOG_INFO("sensor: ", fmt, ##args) +#define SENSOR_ERR(fmt, args...) LOG_ERR("sensor: ", fmt, ##args) +#define SENSOR_DBG(fmt, args...) LOG_DBG("sensor: ", fmt, ##args) + +struct sensor_t { + unsigned int in_number; + unsigned int temp_number; + struct sensor_in_t *in; + struct sensor_temp_t *temp; +}; + +struct sensor_temp_t { + struct switch_obj *obj; +}; + +struct sensor_in_t { + struct switch_obj *obj; +}; + +static int g_loglevel = 0; +static struct switch_drivers_t *g_drv = NULL; +static struct sensor_t g_sensor; +static struct switch_obj *g_sensor_obj = NULL; + +static ssize_t sensor_temp_number_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", g_sensor.temp_number); +} + +static ssize_t sensor_in_number_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", g_sensor.in_number); +} + +static ssize_t sensor_voltage_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int in_index; + int ret; + struct switch_device_attribute *in_attr; + + check_p(g_drv); + check_p(g_drv->get_voltage_info); + in_index = obj->index; + + in_attr = to_switch_device_attr(attr); + check_p(in_attr); + SENSOR_DBG("sensor_in_show, in index:0x%x, in type:0x%x\n",in_index, in_attr->type); + ret = g_drv->get_voltage_info(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE, in_index, in_attr->type, buf); + if (ret < 0) { + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", RG_SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t sensor_temp_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int temp_index; + int ret; + struct switch_device_attribute *temp_attr; + + check_p(g_drv); + check_p(g_drv->get_temp_info); + temp_index = obj->index; + + temp_attr = to_switch_device_attr(attr); + check_p(temp_attr); + SENSOR_DBG("sensor_temp_show, temp index:0x%x, temp type:0x%x\n", temp_index, temp_attr->type); + ret = g_drv->get_temp_info(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE, temp_index, temp_attr->type, buf); + if (ret < 0) { + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", RG_SYSFS_DEV_ERROR); + } + return ret; +} + +/************************************sensor dir and attrs*******************************************/ +static struct switch_attribute num_temp_att = __ATTR(num_temp_sensors, S_IRUGO, sensor_temp_number_show, NULL); +static struct switch_attribute num_in_att = __ATTR(num_in_sensors, S_IRUGO, sensor_in_number_show, NULL); + +static struct attribute *sensor_dir_attrs[] = { + &num_temp_att.attr, + &num_in_att.attr, + NULL, +}; + +static struct attribute_group sensor_root_attr_group = { + .attrs = sensor_dir_attrs, +}; + +/*******************************temp0 temp1 dir and attrs*******************************************/ +static SWITCH_DEVICE_ATTR(temp_input, S_IRUGO, sensor_temp_show, NULL, RG_SENSOR_INPUT); +static SWITCH_DEVICE_ATTR(temp_alias, S_IRUGO, sensor_temp_show, NULL, RG_SENSOR_ALIAS); +static SWITCH_DEVICE_ATTR(temp_type, S_IRUGO, sensor_temp_show, NULL, RG_SENSOR_TYPE); +static SWITCH_DEVICE_ATTR(temp_max, S_IRUGO, sensor_temp_show, NULL, RG_SENSOR_MAX); +static SWITCH_DEVICE_ATTR(temp_max_hyst, S_IRUGO, sensor_temp_show, NULL, RG_SENSOR_MAX_HYST); +static SWITCH_DEVICE_ATTR(temp_min, S_IRUGO, sensor_temp_show, NULL, RG_SENSOR_MIN); + +static struct attribute *sensor_temp_attrs[] = { + &switch_dev_attr_temp_input.switch_attr.attr, + &switch_dev_attr_temp_alias.switch_attr.attr, + &switch_dev_attr_temp_type.switch_attr.attr, + &switch_dev_attr_temp_max.switch_attr.attr, + &switch_dev_attr_temp_max_hyst.switch_attr.attr, + &switch_dev_attr_temp_min.switch_attr.attr, + NULL, +}; + +static struct attribute_group sensor_temp_attr_group = { + .attrs = sensor_temp_attrs, +}; + +/*******************************in0 in1 dir and attrs*******************************************/ +static SWITCH_DEVICE_ATTR(in_input, S_IRUGO, sensor_voltage_show, NULL, RG_SENSOR_INPUT); +static SWITCH_DEVICE_ATTR(in_alias, S_IRUGO, sensor_voltage_show, NULL, RG_SENSOR_ALIAS); +static SWITCH_DEVICE_ATTR(in_type, S_IRUGO, sensor_voltage_show, NULL, RG_SENSOR_TYPE); +static SWITCH_DEVICE_ATTR(in_max, S_IRUGO, sensor_voltage_show, NULL, RG_SENSOR_MAX); +static SWITCH_DEVICE_ATTR(in_min, S_IRUGO, sensor_voltage_show, NULL, RG_SENSOR_MIN); +static SWITCH_DEVICE_ATTR(in_crit, S_IRUGO, sensor_voltage_show, NULL, RG_SENSOR_CRIT); + +static struct attribute *sensor_in_attrs[] = { + &switch_dev_attr_in_input.switch_attr.attr, + &switch_dev_attr_in_alias.switch_attr.attr, + &switch_dev_attr_in_type.switch_attr.attr, + &switch_dev_attr_in_max.switch_attr.attr, + &switch_dev_attr_in_min.switch_attr.attr, + &switch_dev_attr_in_crit.switch_attr.attr, + NULL, +}; + +static struct attribute_group sensor_in_attr_group = { + .attrs = sensor_in_attrs, +}; + +static int sensor_root_create(void) +{ + g_sensor_obj = rg_plat_kobject_create("sensor", NULL); + if (!g_sensor_obj) { + return -ENOMEM; + } + if (sysfs_create_group(&g_sensor_obj->kobj, &sensor_root_attr_group) != 0) { + rg_plat_kobject_delete(&g_sensor_obj); + SENSOR_ERR("create sensor dir attrs error!\n"); + return -EBADRQC; + } + return 0; +} + +static int sensor_in_sub_single_create_kobj_and_attrs(struct kobject *parent, unsigned int index) +{ + char name[DIR_NAME_MAX_LEN]; + struct sensor_in_t *curr_sensor; + + if (index >= g_sensor.in_number) { + SENSOR_ERR("sensor in number = %d, in%d error.\n", g_sensor.in_number, index); + return -EINVAL; + } + curr_sensor = &g_sensor.in[index]; + SENSOR_DBG("create sensor in%d ...\n", index); + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "in%d", index); + curr_sensor->obj = rg_plat_kobject_create(name, parent); + if (!curr_sensor->obj) { + SENSOR_ERR("create sensor in%d object error!\n", index); + return -EBADRQC; + } + curr_sensor->obj->index = index; + if (sysfs_create_group(&curr_sensor->obj->kobj, &sensor_in_attr_group) != 0) { + SENSOR_ERR("create sensor in%d attrs error.\n", index); + rg_plat_kobject_delete(&curr_sensor->obj); + return -EBADRQC; + } + SENSOR_DBG("create sensor in%d ok.\n", index); + return 0; + +} + +static int sensor_in_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct sensor_in_t *curr_in; + + if (index >= g_sensor.in_number) { + SENSOR_ERR("in number = %d, in%d error.\n", g_sensor.in_number, index); + return -EINVAL; + } + curr_in = &g_sensor.in[index]; + if (curr_in->obj) { + sysfs_remove_group(&curr_in->obj->kobj, &sensor_in_attr_group); + rg_plat_kobject_delete(&curr_in->obj); + } + + SENSOR_DBG("delete in%d.\n", index); + return 0; +} + +static int sensor_temp_sub_single_create_kobj_and_attrs(struct kobject *parent, unsigned int index) +{ + char name[DIR_NAME_MAX_LEN]; + struct sensor_temp_t *curr_sensor; + + if (index >= g_sensor.temp_number) { + SENSOR_ERR("sensor temp number = %d, temp%d error.\n", g_sensor.temp_number, index); + return -EINVAL; + } + curr_sensor = &g_sensor.temp[index]; + SENSOR_DBG("create sensor temp%d ...\n", index); + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "temp%d", index); + curr_sensor->obj = rg_plat_kobject_create(name, parent); + if (!curr_sensor->obj) { + SENSOR_ERR("create sensor temp%d object error!\n", index); + return -EBADRQC; + } + curr_sensor->obj->index = index; + if (sysfs_create_group(&curr_sensor->obj->kobj, &sensor_temp_attr_group) != 0) { + SENSOR_ERR("create sensor temp%d attrs error.\n", index); + rg_plat_kobject_delete(&curr_sensor->obj); + return -EBADRQC; + } + SENSOR_DBG("create sensor temp%d ok.\n", index); + return 0; + +} + +static int sensor_temp_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct sensor_temp_t *curr_temp; + + if (index >= g_sensor.temp_number) { + SENSOR_ERR("temp number = %d, temp%d error.\n", g_sensor.temp_number, index); + return -EINVAL; + } + curr_temp = &g_sensor.temp[index]; + if (curr_temp->obj) { + sysfs_remove_group(&curr_temp->obj->kobj, &sensor_temp_attr_group); + rg_plat_kobject_delete(&curr_temp->obj); + } + + SENSOR_DBG("delete temp%d.\n", index); + return 0; +} + +static int sensor_temp_sub_create_kobj_and_attrs(struct kobject *parent, int temp_num) +{ + unsigned int temp_index, i; + if (temp_num <= 0) { + SENSOR_ERR("sensor number = %d error.\n", temp_num); + return -EINVAL; + } + g_sensor.temp = kzalloc(sizeof(struct sensor_temp_t) * temp_num, GFP_KERNEL); + if (!g_sensor.temp ) { + SENSOR_ERR("kzalloc g_sensor.temp error, temp number = %d.\n", temp_num); + return -ENOMEM; + } + for (temp_index = 0; temp_index < temp_num; temp_index++) { + if (sensor_temp_sub_single_create_kobj_and_attrs(parent, temp_index) != 0 ) { + goto error; + } + } + return 0; +error: + for (i = 0; i < temp_index; i++) { + sensor_temp_sub_single_remove_kobj_and_attrs(i); + } + + if (g_sensor.temp) { + kfree(g_sensor.temp); + g_sensor.temp = NULL; + } + return -EBADRQC; +} + +static int sensor_in_sub_create_kobj_and_attrs(struct kobject *parent, int in_num) +{ + unsigned int in_index, i; + if (in_num <= 0) { + SENSOR_ERR("sensor number = %d error.\n", in_num); + return -EINVAL; + } + g_sensor.in = kzalloc(sizeof(struct sensor_in_t) * in_num, GFP_KERNEL); + if (!g_sensor.in ) { + SENSOR_ERR("kzalloc g_sensor.in error, in number = %d.\n", in_num); + return -ENOMEM; + } + + for (in_index = 0; in_index < in_num; in_index++) { + if (sensor_in_sub_single_create_kobj_and_attrs(parent, in_index) != 0 ) { + goto error; + } + } + return 0; +error: + for (i = 0; i < in_index; i++) { + sensor_in_sub_single_remove_kobj_and_attrs(i); + } + + if (g_sensor.in) { + kfree(g_sensor.in); + g_sensor.in = NULL; + } + return -EBADRQC; +} + +static int sensor_temp_sub_create(void) +{ + int ret, temp_num; + + check_p(g_drv->get_dev_number); + temp_num = g_drv->get_dev_number(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_TEMP); + g_sensor.temp_number = temp_num; + + if (temp_num <= 0) { + SENSOR_DBG("Warning:sensor temp number = %d \n", temp_num); + return 0; + } + ret = sensor_temp_sub_create_kobj_and_attrs(&g_sensor_obj->kobj, temp_num); + return ret; +} + +static int sensor_in_sub_create(void) +{ + int ret, in_num; + + check_p(g_drv->get_dev_number); + in_num = g_drv->get_dev_number(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_IN); + g_sensor.in_number = in_num; + + if (in_num <= 0) { + SENSOR_DBG("Warning:sensor in number = %d \n", in_num); + return 0; + } + ret = sensor_in_sub_create_kobj_and_attrs(&g_sensor_obj->kobj, in_num); + return ret; +} + +static int temp_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct sensor_temp_t * curr_temp; + + if (index >= g_sensor.temp_number) { + SENSOR_ERR("temp number = %d, temp%d error.\n", g_sensor.temp_number, index); + return -EINVAL; + } + curr_temp = &g_sensor.temp[index]; + if (curr_temp->obj) { + sysfs_remove_group(&curr_temp->obj->kobj, &sensor_temp_attr_group); + rg_plat_kobject_delete(&curr_temp->obj); + } + + SENSOR_DBG("delete sensor temp%d.\n", index); + return 0; +} + +static int in_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct sensor_in_t * curr_in; + + if (index >= g_sensor.in_number) { + SENSOR_ERR("in number = %d, in%d error.\n", g_sensor.in_number, index); + return -EINVAL; + } + curr_in = &g_sensor.in[index]; + if (curr_in->obj) { + sysfs_remove_group(&curr_in->obj->kobj, &sensor_in_attr_group); + rg_plat_kobject_delete(&curr_in->obj); + } + + SENSOR_DBG("delete sensor in%d.\n", index); + return 0; +} + +static void sensor_temp_sub_remove(void) +{ + unsigned int temp_index; + if (g_sensor.temp) { + for (temp_index = 0; temp_index < g_sensor.temp_number; temp_index++) { + if (g_sensor.temp[temp_index].obj) { + temp_sub_single_remove_kobj_and_attrs(temp_index); + } + } + kfree(g_sensor.temp); + } + g_sensor.temp = NULL; + return ; +} + +static void sensor_in_sub_remove(void) +{ + unsigned int in_index; + if (g_sensor.in) { + for (in_index = 0; in_index < g_sensor.in_number; in_index++) { + if (g_sensor.in[in_index].obj) { + in_sub_single_remove_kobj_and_attrs(in_index); + } + } + kfree(g_sensor.in); + } + g_sensor.in = NULL; + return ; +} + +static void sensor_sub_remove(void) +{ + sensor_temp_sub_remove(); + sensor_in_sub_remove(); +} + +static void sensor_root_remove(void) +{ + if (g_sensor_obj) { + sysfs_remove_group(&g_sensor_obj->kobj, &sensor_root_attr_group); + rg_plat_kobject_delete(&g_sensor_obj); + } + + return ; +} + +static int sensor_sub_create(void) +{ + int ret; + /* temp creat */ + ret = sensor_temp_sub_create(); + if (ret < 0) { + goto temp_err; + } + /* Voltage creat */ + ret = sensor_in_sub_create(); + if (ret < 0) { + goto in_err; + } + return 0; +in_err: + sensor_temp_sub_remove(); +temp_err: + return ret; +} + +static int rg_sensor_init(void) +{ + int ret; + + SENSOR_INFO("rg_sensor_init...\n"); + g_drv = dfd_plat_driver_get(); + check_p(g_drv); + + ret = sensor_root_create(); + if (ret < 0) { + goto sensor_root_error; + } + + ret = sensor_sub_create(); + if (ret < 0) { + goto sensor_sub_error; + } + SENSOR_INFO("sensor_init ok.\n"); + return 0; +sensor_sub_error: + sensor_root_remove(); +sensor_root_error: + return ret; +} + +static void rg_sensor_exit(void) +{ + sensor_sub_remove(); + sensor_root_remove(); + SENSOR_INFO("sensor_exit ok.\n"); + return ; +} + +module_init(rg_sensor_init); +module_exit(rg_sensor_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd "); +MODULE_DESCRIPTION("RUIJIE sensors sysfs driver"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/rg_plat_sff.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/rg_plat_sff.c new file mode 100644 index 000000000000..ca2d5ae3be1a --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/rg_plat_sff.c @@ -0,0 +1,391 @@ +/* + * Copyright(C) 2001-2012 Ruijie Network. All rights reserved. + */ +/* + * rg_plat_sff.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * This module create sff kobjects and attributes in /sys/rg_plat/xcvr + * + * History + * [Version] [Author] [Date] [Description] + * * v1.0 sonic_rd@ruijie.com.cn 2020-02-17 Initial version + */ + +#include + +#include "./include/rg_plat_switch.h" +#include "./include/rg_sysfs_common.h" + +#define SFF_INFO(fmt, args...) LOG_INFO("sff: ", fmt, ##args) +#define SFF_ERR(fmt, args...) LOG_ERR("sff: ", fmt, ##args) +#define SFF_DBG(fmt, args...) LOG_DBG("sff: ", fmt, ##args) + +struct sff_obj_t{ + struct switch_obj *sff_obj; + struct bin_attribute bin; + int sff_creat_bin_flag; +}; + +struct sff_t{ + unsigned int sff_number; + struct sff_obj_t *sff; +}; + +static int g_loglevel = 0; +static struct sff_t g_sff; +static struct switch_obj *g_sff_obj = NULL; +static struct switch_drivers_t *g_drv = NULL; + +static ssize_t sff_cpld_info_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int sff_index; + int ret; + struct switch_device_attribute *sff_cpld_attr; + + check_p(g_drv); + check_p(g_drv->get_sff_cpld_info); + + sff_index = obj->index; + sff_cpld_attr = to_switch_device_attr(attr); + check_p(sff_cpld_attr); + SFF_DBG("sff_cpld_info_show, sff index:0x%x, sff cpld attr type:0x%x\n", sff_index, sff_cpld_attr->type); + ret = g_drv->get_sff_cpld_info(sff_index, sff_cpld_attr->type, buf, PAGE_SIZE); + if(ret < 0) { + SFF_ERR("sff_cpld_info_show error. sff index:0x%x, sff cpld attr type:0x%x, ret:%d\n", + sff_index, sff_cpld_attr->type,ret ); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", RG_SYSFS_DEV_ERROR); + } + SFF_DBG("sff_cpld_info_show ok. sff index:0x%x, sff cpld attr type:0x%x, ret:%d\n", sff_index, sff_cpld_attr->type, ret); + return ret; +} + +static ssize_t sff_polling_read(struct file *filp, struct kobject *kobj, struct bin_attribute *attr, + char *buf, loff_t offset, size_t count) +{ + struct switch_obj *sff_obj; + ssize_t rd_len; + unsigned int sff_index; + + check_p(g_drv); + check_p(g_drv->get_sff_polling_data); + + sff_obj = to_switch_obj(kobj); + sff_index = sff_obj->index; + + memset(buf, 0, count); + + rd_len = g_drv->get_sff_polling_data(sff_index, buf, offset, count); + if (rd_len < 0) { + SFF_ERR("sff_polling_read error. sff index:%u, offset:0x%llx, read len:%lu, ret:%ld.\n", + sff_index, offset,count, rd_len); + return -EIO; + } + + SFF_DBG("sff_polling_read, sff index:%u, offset:0x%llx, read len:%lu, really read len:%ld.\n", + sff_index, offset, count, rd_len); + + return rd_len; +} + +#if 0 +static ssize_t sff_cpld_info_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int sff_index; + int ret, value; + struct switch_device_attribute *sff_cpld_attr; + + check_p(g_drv); + check_p(g_drv->set_sff_cpld_info); + + sscanf(buf, "%d", &value); + if (value < 0 || value > 1) { + SFF_DBG(" invalid value:%d, can't set.\n", value); + return -EINVAL; + } + + sff_index = obj->index; + sff_cpld_attr = to_switch_device_attr(attr); + check_p(sff_cpld_attr); + SFF_DBG("sff_cpld_info_show, sff index:%d, sff cpld attr type:0x%x, set value:%d.\n", sff_index, sff_cpld_attr->type, value); + + ret = g_drv->set_sff_cpld_info(sff_index, sff_cpld_attr->type, value); + if(ret < 0) { + SFF_DBG("can not set cpld register = %d. sff index:%d, sff cpld attr type:0x%x,\n", value, sff_index, sff_cpld_attr->type); + return -EIO; + } + + return count; +} +#endif + +static ssize_t sff_number_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", g_sff.sff_number); +} + +/************************************sff attrs*******************************************/ +static struct switch_attribute sff_number_att = __ATTR(num_sffs, S_IRUGO, sff_number_show, NULL); +static SWITCH_DEVICE_ATTR(present, S_IRUGO, sff_cpld_info_show, NULL, RG_SFF_MODULE_PRESENT); + +/*******************************xcvr dir and attrs*******************************************/ +static struct attribute *xcvr_dir_attrs[] = { + &sff_number_att.attr, + NULL, +}; + +static struct attribute_group sff_xcvr_attr_group = { + .attrs = xcvr_dir_attrs, +}; + +/*******************************sff dir and attrs*******************************************/ +static struct attribute *sff_attrs[] = { + &switch_dev_attr_present.switch_attr.attr, + NULL, +}; + +static struct attribute_group sff_attr_group = { + .attrs = sff_attrs, +}; + +static int sff_sub_single_create_attrs(unsigned int index) +{ + struct sff_obj_t * curr_sff; + + curr_sff = &g_sff.sff[index-1]; + if (sysfs_create_group(&curr_sff->sff_obj->kobj, &sff_attr_group) != 0) { + rg_plat_kobject_delete(&curr_sff->sff_obj); + return -EBADRQC; + } + + return 0; +} + +static int sff_sub_single_create_kobj(struct kobject *parent, unsigned int index) +{ + struct sff_obj_t * curr_sff; + char sff_dir_name[DIR_NAME_MAX_LEN]; + int ret; + + check_p(g_drv->get_sff_dir_name); + ret = g_drv->get_sff_dir_name(index, sff_dir_name, sizeof(sff_dir_name)); + if (ret < 0) { + SFF_ERR("sff index:%d, get sff dir name error. please check sff config.\n", index); + return -ENOSYS; + } + + curr_sff = &g_sff.sff[index-1]; + + curr_sff->sff_obj = rg_plat_kobject_create(sff_dir_name, parent); + if (!curr_sff->sff_obj) { + SFF_ERR("sff index:%d, create %s object error! \n", index, sff_dir_name); + return -EBADRQC; + } + + SFF_DBG("create sff kobj ok. sff index:%d, dir name:%s\n",index, sff_dir_name); + curr_sff->sff_obj->index = index; + + return 0; +} + +static void sff_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct sff_obj_t * curr_sff; + + curr_sff = &g_sff.sff[index-1]; + /* remove sff dir and attr */ + if (curr_sff->sff_obj) { + SFF_DBG("delete sff%d attrs.\n", curr_sff->sff_obj->index); + curr_sff->sff_obj->index = 0; + if (curr_sff->sff_creat_bin_flag) { + sysfs_remove_bin_file(&curr_sff->sff_obj->kobj, &curr_sff->bin); + } + sysfs_remove_group(&curr_sff->sff_obj->kobj, &sff_attr_group); + rg_plat_kobject_delete(&curr_sff->sff_obj); + } + + return; +} + +static int sff_sub_single_create_eeprom_attrs(unsigned int index) +{ + int ret, eeprom_size; + struct sff_obj_t * curr_sff; + + check_p(g_drv->get_sff_polling_size); + + eeprom_size = g_drv->get_sff_polling_size(); + if (eeprom_size < 0) { + SFF_INFO("sff index:%u, don't support sff polling, ret:%d.\n", index, eeprom_size); + return 0; + } + + curr_sff = &g_sff.sff[index-1]; + + sysfs_bin_attr_init(&curr_sff->bin); + curr_sff->bin.attr.name = "eeprom"; + curr_sff->bin.attr.mode = 0444; + curr_sff->bin.read = sff_polling_read; + curr_sff->bin.size = eeprom_size; + + ret = sysfs_create_bin_file(&curr_sff->sff_obj->kobj, &curr_sff->bin); + if (ret) { + SFF_ERR("sff index:%d, create eeprom bin error, ret:%d. \n", index, ret); + sysfs_remove_group(&curr_sff->sff_obj->kobj, &sff_attr_group); + rg_plat_kobject_delete(&curr_sff->sff_obj); + return -EBADRQC; + } + + SFF_DBG("sff index:%u, create bin file success, eeprom size:%d.\n", index, eeprom_size); + curr_sff->sff_creat_bin_flag = 1; + + return 0; +} + +static int sff_sub_single_create_kobj_and_attrs(struct kobject *parent, unsigned int index) +{ + int ret; + + ret = sff_sub_single_create_kobj(parent, index); + if (ret < 0) { + SFF_ERR("sff index:%d, create sff dir error.\n", index); + return ret; + } + + ret = sff_sub_single_create_attrs(index); + if (ret < 0) { + SFF_ERR("sff index:%d, create sff attr error.\n", index); + return ret; + } + + ret = sff_sub_single_create_eeprom_attrs(index); + + return ret; +} + +static int sff_sub_create_kobj_and_attrs(struct kobject *parent, int sff_num) +{ + unsigned int sff_index, i; + + g_sff.sff = kzalloc(sizeof(struct sff_obj_t) * sff_num, GFP_KERNEL); + if (!g_sff.sff) { + SFF_ERR("kzalloc g_sff.sff error, sff number = %d.\n", sff_num); + return -ENOMEM; + } + + for (sff_index = 1; sff_index <= sff_num; sff_index++) { + if (sff_sub_single_create_kobj_and_attrs(parent, sff_index) != 0 ) { + goto error; + } + } + return 0; +error: + for (i = 1; i < sff_index; i++) { + sff_sub_single_remove_kobj_and_attrs(i); + } + if (g_sff.sff) { + kfree(g_sff.sff); + g_sff.sff = NULL; + } + return -EBADRQC; +} + +static int sff_sub_create(void) +{ + int ret, sff_num; + + check_p(g_drv->get_dev_number); + sff_num = g_drv->get_dev_number(RG_MAIN_DEV_SFF, RG_MINOR_DEV_NONE); + g_sff.sff_number = sff_num; + if (sff_num <= 0) { + SFF_ERR("ERROR. port number:%d\n", sff_num); + return -EINVAL; + } + + ret = sff_sub_create_kobj_and_attrs(&g_sff_obj->kobj, sff_num); + + return ret; +} + +static void sff_sub_remove(void) +{ + unsigned int sff_index; + + if (g_sff.sff) { + for (sff_index = 1; sff_index <= g_sff.sff_number; sff_index++) { + sff_sub_single_remove_kobj_and_attrs(sff_index); + } + kfree(g_sff.sff); + } + memset(&g_sff, 0, sizeof(struct sff_t)); + return ; +} + +static int sff_xcvr_create(void) +{ + g_sff_obj = rg_plat_kobject_create(RG_SFF_SYSFS_NAME, NULL); + if (!g_sff_obj) { + return -ENOMEM; + } + + g_sff_obj->index = 0; + if (sysfs_create_group(&g_sff_obj->kobj, &sff_xcvr_attr_group) != 0) { + rg_plat_kobject_delete(&g_sff_obj); + SFF_ERR("create sff dir attrs error!\n"); + return -EBADRQC; + } + return 0; +} + +static void sff_xcvr_remove(void) +{ + if (g_sff_obj) { + sysfs_remove_group(&g_sff_obj->kobj, &sff_xcvr_attr_group); + rg_plat_kobject_delete(&g_sff_obj); + } + + return ; +} + +static int rg_sff_init(void) +{ + int ret; + + SFF_INFO("rg_sff_init...\n"); + g_drv = dfd_plat_driver_get(); + check_p(g_drv); + + ret = sff_xcvr_create(); + if (ret < 0) { + goto sff_root_error; + } + + ret = sff_sub_create(); + if (ret < 0) { + goto sff_sub_error; + } + SFF_INFO("rg_sff_init ok.\n"); + return 0; + +sff_sub_error: + sff_xcvr_remove(); +sff_root_error: + return ret; +} + +static void rg_sff_exit(void) +{ + sff_sub_remove(); + sff_xcvr_remove(); + SFF_INFO("rg_sff_exit ok.\n"); + return ; +} + +module_init(rg_sff_init); +module_exit(rg_sff_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd "); +MODULE_DESCRIPTION("RUIJIE sff sysfs driver"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/rg_plat_switch.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/rg_plat_switch.c new file mode 100644 index 000000000000..9f4b6aef6876 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/rg_plat_switch.c @@ -0,0 +1,141 @@ +/* + * Copyright(C) 2001-2012 Ruijie Network. All rights reserved. + */ +/* + * rg_plat_switch.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * This module create a kset in sysfs called /sys/rg_plat + * Then other switch kobjects are created and assigned to this kset, + * such as "board", "cpld", "fan", "psu", "sff", ... + * + * History + * [Version] [Author] [Date] [Description] + * * v1.0 sonic_rd@ruijie.com.cn 2020-02-17 Initial version + */ + +#include "./include/rg_plat_switch.h" + +#define SWITCH_INFO(fmt, args...) LOG_INFO("switch: ", fmt, ##args) +#define SWITCH_ERR(fmt, args...) LOG_ERR("switch: ", fmt, ##args) +#define SWITCH_DBG(fmt, args...) LOG_DBG("switch: ", fmt, ##args) + +static int g_loglevel = 0; + +static ssize_t switch_attr_show(struct kobject *kobj, + struct attribute *attr, + char *buf) +{ + struct switch_attribute *attribute; + struct switch_obj *device; + + attribute = to_switch_attr(attr); + device = to_switch_obj(kobj); + + if (!attribute->show) + return -ENOSYS; + + return attribute->show(device, attribute, buf); +} + +static ssize_t switch_attr_store(struct kobject *kobj, + struct attribute *attr, + const char *buf, size_t len) +{ + struct switch_attribute *attribute; + struct switch_obj *obj; + + attribute = to_switch_attr(attr); + obj = to_switch_obj(kobj); + + if (!attribute->store) + return -ENOSYS; + + return attribute->store(obj, attribute, buf, len); +} + +static const struct sysfs_ops switch_sysfs_ops = { + .show = switch_attr_show, + .store = switch_attr_store, +}; + +static void switch_obj_release(struct kobject *kobj) +{ + struct switch_obj *obj; + + obj = to_switch_obj(kobj); + kfree(obj); +} + +static struct kobj_type switch_ktype = { + .sysfs_ops = &switch_sysfs_ops, + .release = switch_obj_release, + .default_attrs = NULL, +}; + +static struct kset *switch_kset; + +struct switch_obj *rg_plat_kobject_create(const char *name, struct kobject *parent) +{ + struct switch_obj *obj = NULL; + int ret = 0; + + obj = kzalloc(sizeof(*obj), GFP_KERNEL); + if (!obj) { + SWITCH_DBG("rg_plat_kobject_create %s kzalloc error", name); + return NULL; + } + + obj->kobj.kset = switch_kset; + + ret = kobject_init_and_add(&obj->kobj, &switch_ktype, parent, "%s", name); + if (ret) { + kobject_put(&obj->kobj); + SWITCH_DBG("kobject_init_and_add %s error", name); + return NULL; + } + + return obj; +} + +void rg_plat_kobject_delete(struct switch_obj **obj) +{ + if (*obj) { + SWITCH_DBG("%s delete %s.\n", (*obj)->kobj.parent->name, (*obj)->kobj.name); + kobject_put(&((*obj)->kobj)); + *obj = NULL; + } +} + +static int __init switch_init(void) +{ + SWITCH_INFO("...\n"); + + switch_kset = kset_create_and_add("rg_plat", NULL, NULL); + if (!switch_kset) { + SWITCH_ERR("create switch_kset error.\n"); + return -ENOMEM; + } + + SWITCH_INFO("ok.\n"); + return 0; +} + +static void __exit switch_exit(void) +{ + if (switch_kset) { + kset_unregister(switch_kset); + } + + SWITCH_INFO("ok.\n"); +} + +module_init(switch_init); +module_exit(switch_exit); +EXPORT_SYMBOL(rg_plat_kobject_create); +EXPORT_SYMBOL(rg_plat_kobject_delete); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd "); +MODULE_DESCRIPTION("RUIJIE Switch driver"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_pmbus.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_pmbus.h new file mode 100644 index 000000000000..a714bbb99056 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_pmbus.h @@ -0,0 +1,466 @@ +/* + * pmbus.h - Common defines and structures for PMBus devices + * + * Copyright (c) 2010, 2011 Ericsson AB. + * Copyright (c) 2012 Guenter Roeck + * + * 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. + */ + +#ifndef RG_PMBUS_H +#define RG_PMBUS_H + +#include +#include + +/* + * Registers + */ +enum pmbus_regs { + PMBUS_PAGE = 0x00, + PMBUS_OPERATION = 0x01, + PMBUS_ON_OFF_CONFIG = 0x02, + PMBUS_CLEAR_FAULTS = 0x03, + PMBUS_PHASE = 0x04, + + PMBUS_CAPABILITY = 0x19, + PMBUS_QUERY = 0x1A, + + PMBUS_VOUT_MODE = 0x20, + PMBUS_VOUT_COMMAND = 0x21, + PMBUS_VOUT_TRIM = 0x22, + PMBUS_VOUT_CAL_OFFSET = 0x23, + PMBUS_VOUT_MAX = 0x24, + PMBUS_VOUT_MARGIN_HIGH = 0x25, + PMBUS_VOUT_MARGIN_LOW = 0x26, + PMBUS_VOUT_TRANSITION_RATE = 0x27, + PMBUS_VOUT_DROOP = 0x28, + PMBUS_VOUT_SCALE_LOOP = 0x29, + PMBUS_VOUT_SCALE_MONITOR = 0x2A, + + PMBUS_COEFFICIENTS = 0x30, + PMBUS_POUT_MAX = 0x31, + + PMBUS_FAN_CONFIG_12 = 0x3A, + PMBUS_FAN_COMMAND_1 = 0x3B, + PMBUS_FAN_COMMAND_2 = 0x3C, + PMBUS_FAN_CONFIG_34 = 0x3D, + PMBUS_FAN_COMMAND_3 = 0x3E, + PMBUS_FAN_COMMAND_4 = 0x3F, + + PMBUS_VOUT_OV_FAULT_LIMIT = 0x40, + PMBUS_VOUT_OV_FAULT_RESPONSE = 0x41, + PMBUS_VOUT_OV_WARN_LIMIT = 0x42, + PMBUS_VOUT_UV_WARN_LIMIT = 0x43, + PMBUS_VOUT_UV_FAULT_LIMIT = 0x44, + PMBUS_VOUT_UV_FAULT_RESPONSE = 0x45, + PMBUS_IOUT_OC_FAULT_LIMIT = 0x46, + PMBUS_IOUT_OC_FAULT_RESPONSE = 0x47, + PMBUS_IOUT_OC_LV_FAULT_LIMIT = 0x48, + PMBUS_IOUT_OC_LV_FAULT_RESPONSE = 0x49, + PMBUS_IOUT_OC_WARN_LIMIT = 0x4A, + PMBUS_IOUT_UC_FAULT_LIMIT = 0x4B, + PMBUS_IOUT_UC_FAULT_RESPONSE = 0x4C, + + PMBUS_OT_FAULT_LIMIT = 0x4F, + PMBUS_OT_FAULT_RESPONSE = 0x50, + PMBUS_OT_WARN_LIMIT = 0x51, + PMBUS_UT_WARN_LIMIT = 0x52, + PMBUS_UT_FAULT_LIMIT = 0x53, + PMBUS_UT_FAULT_RESPONSE = 0x54, + PMBUS_VIN_OV_FAULT_LIMIT = 0x55, + PMBUS_VIN_OV_FAULT_RESPONSE = 0x56, + PMBUS_VIN_OV_WARN_LIMIT = 0x57, + PMBUS_VIN_UV_WARN_LIMIT = 0x58, + PMBUS_VIN_UV_FAULT_LIMIT = 0x59, + + PMBUS_IIN_OC_FAULT_LIMIT = 0x5B, + PMBUS_IIN_OC_WARN_LIMIT = 0x5D, + + PMBUS_POUT_OP_FAULT_LIMIT = 0x68, + PMBUS_POUT_OP_WARN_LIMIT = 0x6A, + PMBUS_PIN_OP_WARN_LIMIT = 0x6B, + + PMBUS_STATUS_BYTE = 0x78, + PMBUS_STATUS_WORD = 0x79, + PMBUS_STATUS_VOUT = 0x7A, + PMBUS_STATUS_IOUT = 0x7B, + PMBUS_STATUS_INPUT = 0x7C, + PMBUS_STATUS_TEMPERATURE = 0x7D, + PMBUS_STATUS_CML = 0x7E, + PMBUS_STATUS_OTHER = 0x7F, + PMBUS_STATUS_MFR_SPECIFIC = 0x80, + PMBUS_STATUS_FAN_12 = 0x81, + PMBUS_STATUS_FAN_34 = 0x82, + + PMBUS_READ_VIN = 0x88, + PMBUS_READ_IIN = 0x89, + PMBUS_READ_VCAP = 0x8A, + PMBUS_READ_VOUT = 0x8B, + PMBUS_READ_IOUT = 0x8C, + PMBUS_READ_TEMPERATURE_1 = 0x8D, + PMBUS_READ_TEMPERATURE_2 = 0x8E, + PMBUS_READ_TEMPERATURE_3 = 0x8F, + PMBUS_READ_FAN_SPEED_1 = 0x90, + PMBUS_READ_FAN_SPEED_2 = 0x91, + PMBUS_READ_FAN_SPEED_3 = 0x92, + PMBUS_READ_FAN_SPEED_4 = 0x93, + PMBUS_READ_DUTY_CYCLE = 0x94, + PMBUS_READ_FREQUENCY = 0x95, + PMBUS_READ_POUT = 0x96, + PMBUS_READ_PIN = 0x97, + + PMBUS_REVISION = 0x98, + PMBUS_MFR_ID = 0x99, + PMBUS_MFR_MODEL = 0x9A, + PMBUS_MFR_REVISION = 0x9B, + PMBUS_MFR_LOCATION = 0x9C, + PMBUS_MFR_DATE = 0x9D, + PMBUS_MFR_SERIAL = 0x9E, + +/* + * Virtual registers. + * Useful to support attributes which are not supported by standard PMBus + * registers but exist as manufacturer specific registers on individual chips. + * Must be mapped to real registers in device specific code. + * + * Semantics: + * Virtual registers are all word size. + * READ registers are read-only; writes are either ignored or return an error. + * RESET registers are read/write. Reading reset registers returns zero + * (used for detection), writing any value causes the associated history to be + * reset. + * Virtual registers have to be handled in device specific driver code. Chip + * driver code returns non-negative register values if a virtual register is + * supported, or a negative error code if not. The chip driver may return + * -ENODATA or any other error code in this case, though an error code other + * than -ENODATA is handled more efficiently and thus preferred. Either case, + * the calling PMBus core code will abort if the chip driver returns an error + * code when reading or writing virtual registers. + */ + PMBUS_VIRT_BASE = 0x100, + PMBUS_VIRT_READ_TEMP_AVG, + PMBUS_VIRT_READ_TEMP_MIN, + PMBUS_VIRT_READ_TEMP_MAX, + PMBUS_VIRT_RESET_TEMP_HISTORY, + PMBUS_VIRT_READ_VIN_AVG, + PMBUS_VIRT_READ_VIN_MIN, + PMBUS_VIRT_READ_VIN_MAX, + PMBUS_VIRT_RESET_VIN_HISTORY, + PMBUS_VIRT_READ_IIN_AVG, + PMBUS_VIRT_READ_IIN_MIN, + PMBUS_VIRT_READ_IIN_MAX, + PMBUS_VIRT_RESET_IIN_HISTORY, + PMBUS_VIRT_READ_PIN_AVG, + PMBUS_VIRT_READ_PIN_MIN, + PMBUS_VIRT_READ_PIN_MAX, + PMBUS_VIRT_RESET_PIN_HISTORY, + PMBUS_VIRT_READ_POUT_AVG, + PMBUS_VIRT_READ_POUT_MIN, + PMBUS_VIRT_READ_POUT_MAX, + PMBUS_VIRT_RESET_POUT_HISTORY, + PMBUS_VIRT_READ_VOUT_AVG, + PMBUS_VIRT_READ_VOUT_MIN, + PMBUS_VIRT_READ_VOUT_MAX, + PMBUS_VIRT_RESET_VOUT_HISTORY, + PMBUS_VIRT_READ_IOUT_AVG, + PMBUS_VIRT_READ_IOUT_MIN, + PMBUS_VIRT_READ_IOUT_MAX, + PMBUS_VIRT_RESET_IOUT_HISTORY, + PMBUS_VIRT_READ_TEMP2_AVG, + PMBUS_VIRT_READ_TEMP2_MIN, + PMBUS_VIRT_READ_TEMP2_MAX, + PMBUS_VIRT_RESET_TEMP2_HISTORY, + + PMBUS_VIRT_READ_VMON, + PMBUS_VIRT_VMON_UV_WARN_LIMIT, + PMBUS_VIRT_VMON_OV_WARN_LIMIT, + PMBUS_VIRT_VMON_UV_FAULT_LIMIT, + PMBUS_VIRT_VMON_OV_FAULT_LIMIT, + PMBUS_VIRT_STATUS_VMON, + + /* + * RPM and PWM Fan control + * + * Drivers wanting to expose PWM control must define the behaviour of + * PMBUS_VIRT_PWM_[1-4] and PMBUS_VIRT_PWM_ENABLE_[1-4] in the + * {read,write}_word_data callback. + * + * pmbus core provides a default implementation for + * PMBUS_VIRT_FAN_TARGET_[1-4]. + * + * TARGET, PWM and PWM_ENABLE members must be defined sequentially; + * pmbus core uses the difference between the provided register and + * it's _1 counterpart to calculate the FAN/PWM ID. + */ + PMBUS_VIRT_FAN_TARGET_1, + PMBUS_VIRT_FAN_TARGET_2, + PMBUS_VIRT_FAN_TARGET_3, + PMBUS_VIRT_FAN_TARGET_4, + PMBUS_VIRT_PWM_1, + PMBUS_VIRT_PWM_2, + PMBUS_VIRT_PWM_3, + PMBUS_VIRT_PWM_4, + PMBUS_VIRT_PWM_ENABLE_1, + PMBUS_VIRT_PWM_ENABLE_2, + PMBUS_VIRT_PWM_ENABLE_3, + PMBUS_VIRT_PWM_ENABLE_4, +}; + +/* + * OPERATION + */ +#define PB_OPERATION_CONTROL_ON BIT(7) + +/* + * CAPABILITY + */ +#define PB_CAPABILITY_SMBALERT BIT(4) +#define PB_CAPABILITY_ERROR_CHECK BIT(7) + +/* + * VOUT_MODE + */ +#define PB_VOUT_MODE_MODE_MASK 0xe0 +#define PB_VOUT_MODE_PARAM_MASK 0x1f + +#define PB_VOUT_MODE_LINEAR 0x00 +#define PB_VOUT_MODE_VID 0x20 +#define PB_VOUT_MODE_DIRECT 0x40 + +/* + * Fan configuration + */ +#define PB_FAN_2_PULSE_MASK (BIT(0) | BIT(1)) +#define PB_FAN_2_RPM BIT(2) +#define PB_FAN_2_INSTALLED BIT(3) +#define PB_FAN_1_PULSE_MASK (BIT(4) | BIT(5)) +#define PB_FAN_1_RPM BIT(6) +#define PB_FAN_1_INSTALLED BIT(7) + +enum pmbus_fan_mode { percent = 0, rpm }; + +/* + * STATUS_BYTE, STATUS_WORD (lower) + */ +#define PB_STATUS_NONE_ABOVE BIT(0) +#define PB_STATUS_CML BIT(1) +#define PB_STATUS_TEMPERATURE BIT(2) +#define PB_STATUS_VIN_UV BIT(3) +#define PB_STATUS_IOUT_OC BIT(4) +#define PB_STATUS_VOUT_OV BIT(5) +#define PB_STATUS_OFF BIT(6) +#define PB_STATUS_BUSY BIT(7) + +/* + * STATUS_WORD (upper) + */ +#define PB_STATUS_UNKNOWN BIT(8) +#define PB_STATUS_OTHER BIT(9) +#define PB_STATUS_FANS BIT(10) +#define PB_STATUS_POWER_GOOD_N BIT(11) +#define PB_STATUS_WORD_MFR BIT(12) +#define PB_STATUS_INPUT BIT(13) +#define PB_STATUS_IOUT_POUT BIT(14) +#define PB_STATUS_VOUT BIT(15) + +/* + * STATUS_IOUT + */ +#define PB_POUT_OP_WARNING BIT(0) +#define PB_POUT_OP_FAULT BIT(1) +#define PB_POWER_LIMITING BIT(2) +#define PB_CURRENT_SHARE_FAULT BIT(3) +#define PB_IOUT_UC_FAULT BIT(4) +#define PB_IOUT_OC_WARNING BIT(5) +#define PB_IOUT_OC_LV_FAULT BIT(6) +#define PB_IOUT_OC_FAULT BIT(7) + +/* + * STATUS_VOUT, STATUS_INPUT + */ +#define PB_VOLTAGE_UV_FAULT BIT(4) +#define PB_VOLTAGE_UV_WARNING BIT(5) +#define PB_VOLTAGE_OV_WARNING BIT(6) +#define PB_VOLTAGE_OV_FAULT BIT(7) + +/* + * STATUS_INPUT + */ +#define PB_PIN_OP_WARNING BIT(0) +#define PB_IIN_OC_WARNING BIT(1) +#define PB_IIN_OC_FAULT BIT(2) + +/* + * STATUS_TEMPERATURE + */ +#define PB_TEMP_UT_FAULT BIT(4) +#define PB_TEMP_UT_WARNING BIT(5) +#define PB_TEMP_OT_WARNING BIT(6) +#define PB_TEMP_OT_FAULT BIT(7) + +/* + * STATUS_FAN + */ +#define PB_FAN_AIRFLOW_WARNING BIT(0) +#define PB_FAN_AIRFLOW_FAULT BIT(1) +#define PB_FAN_FAN2_SPEED_OVERRIDE BIT(2) +#define PB_FAN_FAN1_SPEED_OVERRIDE BIT(3) +#define PB_FAN_FAN2_WARNING BIT(4) +#define PB_FAN_FAN1_WARNING BIT(5) +#define PB_FAN_FAN2_FAULT BIT(6) +#define PB_FAN_FAN1_FAULT BIT(7) + +/* + * CML_FAULT_STATUS + */ +#define PB_CML_FAULT_OTHER_MEM_LOGIC BIT(0) +#define PB_CML_FAULT_OTHER_COMM BIT(1) +#define PB_CML_FAULT_PROCESSOR BIT(3) +#define PB_CML_FAULT_MEMORY BIT(4) +#define PB_CML_FAULT_PACKET_ERROR BIT(5) +#define PB_CML_FAULT_INVALID_DATA BIT(6) +#define PB_CML_FAULT_INVALID_COMMAND BIT(7) + +enum pmbus_sensor_classes { + PSC_VOLTAGE_IN = 0, + PSC_VOLTAGE_OUT, + PSC_CURRENT_IN, + PSC_CURRENT_OUT, + PSC_POWER, + PSC_TEMPERATURE, + PSC_FAN, + PSC_PWM, + PSC_NUM_CLASSES /* Number of power sensor classes */ +}; + +#define PMBUS_PAGES 32 /* Per PMBus specification */ + +/* Functionality bit mask */ +#define PMBUS_HAVE_VIN BIT(0) +#define PMBUS_HAVE_VCAP BIT(1) +#define PMBUS_HAVE_VOUT BIT(2) +#define PMBUS_HAVE_IIN BIT(3) +#define PMBUS_HAVE_IOUT BIT(4) +#define PMBUS_HAVE_PIN BIT(5) +#define PMBUS_HAVE_POUT BIT(6) +#define PMBUS_HAVE_FAN12 BIT(7) +#define PMBUS_HAVE_FAN34 BIT(8) +#define PMBUS_HAVE_TEMP BIT(9) +#define PMBUS_HAVE_TEMP2 BIT(10) +#define PMBUS_HAVE_TEMP3 BIT(11) +#define PMBUS_HAVE_STATUS_VOUT BIT(12) +#define PMBUS_HAVE_STATUS_IOUT BIT(13) +#define PMBUS_HAVE_STATUS_INPUT BIT(14) +#define PMBUS_HAVE_STATUS_TEMP BIT(15) +#define PMBUS_HAVE_STATUS_FAN12 BIT(16) +#define PMBUS_HAVE_STATUS_FAN34 BIT(17) +#define PMBUS_HAVE_VMON BIT(18) +#define PMBUS_HAVE_STATUS_VMON BIT(19) +#define PMBUS_HAVE_PWM12 BIT(20) +#define PMBUS_HAVE_PWM34 BIT(21) + +#define PMBUS_PAGE_VIRTUAL BIT(31) + +enum pmbus_data_format { linear = 0, direct, vid }; +enum vrm_version { vr11 = 0, vr12, vr13, imvp9, amd625mv }; + +struct pmbus_driver_info { + int pages; /* Total number of pages */ + enum pmbus_data_format format[PSC_NUM_CLASSES]; + enum vrm_version vrm_version[PMBUS_PAGES]; /* vrm version per page */ + /* + * Support one set of coefficients for each sensor type + * Used for chips providing data in direct mode. + */ + int m[PSC_NUM_CLASSES]; /* mantissa for direct data format */ + int b[PSC_NUM_CLASSES]; /* offset */ + int R[PSC_NUM_CLASSES]; /* exponent */ + + u32 func[PMBUS_PAGES]; /* Functionality, per page */ + /* + * The following functions map manufacturing specific register values + * to PMBus standard register values. Specify only if mapping is + * necessary. + * Functions return the register value (read) or zero (write) if + * successful. A return value of -ENODATA indicates that there is no + * manufacturer specific register, but that a standard PMBus register + * may exist. Any other negative return value indicates that the + * register does not exist, and that no attempt should be made to read + * the standard register. + */ + int (*read_byte_data)(struct i2c_client *client, int page, int reg); + int (*read_word_data)(struct i2c_client *client, int page, int reg); + int (*write_word_data)(struct i2c_client *client, int page, int reg, + u16 word); + int (*write_byte)(struct i2c_client *client, int page, u8 value); + /* + * The identify function determines supported PMBus functionality. + * This function is only necessary if a chip driver supports multiple + * chips, and the chip functionality is not pre-determined. + */ + int (*identify)(struct i2c_client *client, + struct pmbus_driver_info *info); + + /* Regulator functionality, if supported by this chip driver. */ + int num_regulators; + const struct regulator_desc *reg_desc; +}; + +/* Regulator ops */ + +extern const struct regulator_ops rg_pmbus_regulator_ops; + +/* Macro for filling in array of struct regulator_desc */ +#define PMBUS_REGULATOR(_name, _id) \ + [_id] = { \ + .name = (_name # _id), \ + .id = (_id), \ + .of_match = of_match_ptr(_name # _id), \ + .regulators_node = of_match_ptr("regulators"), \ + .ops = &rg_pmbus_regulator_ops, \ + .type = REGULATOR_VOLTAGE, \ + .owner = THIS_MODULE, \ + } + +/* Function declarations */ + +void rg_pmbus_clear_cache(struct i2c_client *client); +int rg_pmbus_set_page(struct i2c_client *client, int page); +int rg_pmbus_read_word_data(struct i2c_client *client, int page, u8 reg); +int rg_pmbus_write_word_data(struct i2c_client *client, int page, u8 reg, u16 word); +int rg_pmbus_read_byte_data(struct i2c_client *client, int page, u8 reg); +int rg_pmbus_write_byte(struct i2c_client *client, int page, u8 value); +int rg_pmbus_write_byte_data(struct i2c_client *client, int page, u8 reg, + u8 value); +int rg_pmbus_update_byte_data(struct i2c_client *client, int page, u8 reg, + u8 mask, u8 value); +void rg_pmbus_clear_faults(struct i2c_client *client); +bool rg_pmbus_check_byte_register(struct i2c_client *client, int page, int reg); +bool rg_pmbus_check_word_register(struct i2c_client *client, int page, int reg); +int rg_pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id, + struct pmbus_driver_info *info); +int rg_pmbus_do_remove(struct i2c_client *client); +const struct pmbus_driver_info *rg_pmbus_get_driver_info(struct i2c_client + *client); +int rg_pmbus_get_fan_rate_device(struct i2c_client *client, int page, int id, + enum pmbus_fan_mode mode); +int rg_pmbus_get_fan_rate_cached(struct i2c_client *client, int page, int id, + enum pmbus_fan_mode mode); +int rg_pmbus_update_fan(struct i2c_client *client, int page, int id, + u8 config, u8 mask, u16 command); +struct dentry *rg_pmbus_get_debugfs_dir(struct i2c_client *client); + +#endif /* RG_PMBUS_H */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_pmbus_core.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_pmbus_core.c new file mode 100644 index 000000000000..825b03b67792 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_pmbus_core.c @@ -0,0 +1,2570 @@ +/* + * Hardware monitoring driver for PMBus devices + * + * Copyright (c) 2010, 2011 Ericsson AB. + * Copyright (c) 2012 Guenter Roeck + * + * 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 +#include +#include +#include +#include "rg_pmbus.h" +#include + +/* + * Number of additional attribute pointers to allocate + * with each call to krealloc + */ +#define PMBUS_ATTR_ALLOC_SIZE 32 + +/* + * Index into status register array, per status register group + */ +#define PB_STATUS_BASE 0 +#define PB_STATUS_VOUT_BASE (PB_STATUS_BASE + PMBUS_PAGES) +#define PB_STATUS_IOUT_BASE (PB_STATUS_VOUT_BASE + PMBUS_PAGES) +#define PB_STATUS_FAN_BASE (PB_STATUS_IOUT_BASE + PMBUS_PAGES) +#define PB_STATUS_FAN34_BASE (PB_STATUS_FAN_BASE + PMBUS_PAGES) +#define PB_STATUS_TEMP_BASE (PB_STATUS_FAN34_BASE + PMBUS_PAGES) +#define PB_STATUS_INPUT_BASE (PB_STATUS_TEMP_BASE + PMBUS_PAGES) +#define PB_STATUS_VMON_BASE (PB_STATUS_INPUT_BASE + 1) + +#define PB_NUM_STATUS_REG (PB_STATUS_VMON_BASE + 1) + +#define PMBUS_NAME_SIZE 24 + +#define PMBUS_RETRY_SLEEP_TIME (10000) /* 10ms */ +#define PMBUS_RETRY_TIME (3) + +struct pmbus_sensor { + struct pmbus_sensor *next; + char name[PMBUS_NAME_SIZE]; /* sysfs sensor name */ + struct device_attribute attribute; + u8 page; /* page number */ + u16 reg; /* register */ + enum pmbus_sensor_classes class; /* sensor class */ + bool update; /* runtime sensor update needed */ + bool convert; /* Whether or not to apply linear/vid/direct */ + int data; /* Sensor data. + Negative if there was a read error */ +}; +#define to_pmbus_sensor(_attr) \ + container_of(_attr, struct pmbus_sensor, attribute) + +struct pmbus_boolean { + char name[PMBUS_NAME_SIZE]; /* sysfs boolean name */ + struct sensor_device_attribute attribute; + struct pmbus_sensor *s1; + struct pmbus_sensor *s2; +}; +#define to_pmbus_boolean(_attr) \ + container_of(_attr, struct pmbus_boolean, attribute) + +struct pmbus_label { + char name[PMBUS_NAME_SIZE]; /* sysfs label name */ + struct device_attribute attribute; + char label[PMBUS_NAME_SIZE]; /* label */ +}; +#define to_pmbus_label(_attr) \ + container_of(_attr, struct pmbus_label, attribute) + +struct pmbus_attr_status { + char name[PMBUS_NAME_SIZE]; /* sysfs label name */ + struct device_attribute attribute; +}; +#define to_pmbus_attr_status(_attr) \ + container_of(_attr, struct pmbus_attr_status, attribute) + +struct pmbus_data { + struct device *dev; + struct device *hwmon_dev; + + u32 flags; /* from platform data */ + + int exponent[PMBUS_PAGES]; + /* linear mode: exponent for output voltages */ + + const struct pmbus_driver_info *info; + + int max_attributes; + int num_attributes; + struct attribute_group group; + const struct attribute_group *groups[2]; + struct dentry *debugfs; /* debugfs device directory */ + + struct pmbus_sensor *sensors; + + struct mutex update_lock; + bool valid; + unsigned long last_updated; /* in jiffies */ + + /* + * A single status register covers multiple attributes, + * so we keep them all together. + */ + u16 status[PB_NUM_STATUS_REG]; + + bool has_status_word; /* device uses STATUS_WORD register */ + int (*read_status)(struct i2c_client *client, int page); + + u8 currpage; +}; + +struct pmbus_debugfs_entry { + struct i2c_client *client; + u8 page; + u8 reg; +}; + +static const int pmbus_fan_rpm_mask[] = { + PB_FAN_1_RPM, + PB_FAN_2_RPM, + PB_FAN_1_RPM, + PB_FAN_2_RPM, +}; + +static const int pmbus_fan_config_registers[] = { + PMBUS_FAN_CONFIG_12, + PMBUS_FAN_CONFIG_12, + PMBUS_FAN_CONFIG_34, + PMBUS_FAN_CONFIG_34 +}; + +static const int pmbus_fan_command_registers[] = { + PMBUS_FAN_COMMAND_1, + PMBUS_FAN_COMMAND_2, + PMBUS_FAN_COMMAND_3, + PMBUS_FAN_COMMAND_4, +}; + +void rg_pmbus_clear_cache(struct i2c_client *client) +{ + struct pmbus_data *data = i2c_get_clientdata(client); + + data->valid = false; +} +EXPORT_SYMBOL_GPL(rg_pmbus_clear_cache); + +int rg_pmbus_set_page(struct i2c_client *client, int page) +{ + struct pmbus_data *data = i2c_get_clientdata(client); + int rv; + + if (page < 0 || page == data->currpage) + return 0; + + if (!(data->info->func[page] & PMBUS_PAGE_VIRTUAL)) { + rv = i2c_smbus_write_byte_data(client, PMBUS_PAGE, page); + if (rv < 0) + return rv; + + rv = i2c_smbus_read_byte_data(client, PMBUS_PAGE); + if (rv < 0) + return rv; + + if (rv != page) + return -EIO; + } + + data->currpage = page; + + return 0; +} +EXPORT_SYMBOL_GPL(rg_pmbus_set_page); + +int rg_pmbus_write_byte(struct i2c_client *client, int page, u8 value) +{ + int rv; + + rv = rg_pmbus_set_page(client, page); + if (rv < 0) + return rv; + + return i2c_smbus_write_byte(client, value); +} +EXPORT_SYMBOL_GPL(rg_pmbus_write_byte); + +/* + * _pmbus_write_byte() is similar to rg_pmbus_write_byte(), but checks if + * a device specific mapping function exists and calls it if necessary. + */ +static int _pmbus_write_byte(struct i2c_client *client, int page, u8 value) +{ + struct pmbus_data *data = i2c_get_clientdata(client); + const struct pmbus_driver_info *info = data->info; + int status; + + if (info->write_byte) { + status = info->write_byte(client, page, value); + if (status != -ENODATA) + return status; + } + return rg_pmbus_write_byte(client, page, value); +} + +int rg_pmbus_write_word_data(struct i2c_client *client, int page, u8 reg, + u16 word) +{ + int rv; + + rv = rg_pmbus_set_page(client, page); + if (rv < 0) + return rv; + + return i2c_smbus_write_word_data(client, reg, word); +} +EXPORT_SYMBOL_GPL(rg_pmbus_write_word_data); + +static int pmbus_write_virt_reg(struct i2c_client *client, int page, int reg, + u16 word) +{ + int bit; + int id; + int rv; + + switch (reg) { + case PMBUS_VIRT_FAN_TARGET_1 ... PMBUS_VIRT_FAN_TARGET_4: + id = reg - PMBUS_VIRT_FAN_TARGET_1; + bit = pmbus_fan_rpm_mask[id]; + rv = rg_pmbus_update_fan(client, page, id, bit, bit, word); + break; + default: + rv = -ENXIO; + break; + } + + return rv; +} + +/* + * _pmbus_write_word_data() is similar to rg_pmbus_write_word_data(), but checks if + * a device specific mapping function exists and calls it if necessary. + */ +static int _pmbus_write_word_data(struct i2c_client *client, int page, int reg, + u16 word) +{ + struct pmbus_data *data = i2c_get_clientdata(client); + const struct pmbus_driver_info *info = data->info; + int status; + + if (info->write_word_data) { + status = info->write_word_data(client, page, reg, word); + if (status != -ENODATA) + return status; + } + + if (reg >= PMBUS_VIRT_BASE) + return pmbus_write_virt_reg(client, page, reg, word); + + return rg_pmbus_write_word_data(client, page, reg, word); +} + +int rg_pmbus_update_fan(struct i2c_client *client, int page, int id, + u8 config, u8 mask, u16 command) +{ + int from; + int rv; + u8 to; + + from = rg_pmbus_read_byte_data(client, page, + pmbus_fan_config_registers[id]); + if (from < 0) + return from; + + to = (from & ~mask) | (config & mask); + if (to != from) { + rv = rg_pmbus_write_byte_data(client, page, + pmbus_fan_config_registers[id], to); + if (rv < 0) + return rv; + } + + return _pmbus_write_word_data(client, page, + pmbus_fan_command_registers[id], command); +} +EXPORT_SYMBOL_GPL(rg_pmbus_update_fan); + +static int pmbus_read_word_data_tmp(struct i2c_client *client, int page, u8 reg) +{ + int rv; + + rv = rg_pmbus_set_page(client, page); + if (rv < 0) + return rv; + + return i2c_smbus_read_word_data(client, reg); +} + +int rg_pmbus_read_word_data(struct i2c_client *client, int page, u8 reg) +{ + int rv, i; + struct device *dev = &client->dev; + for(i = 0; i < PMBUS_RETRY_TIME; i++) { + rv = pmbus_read_word_data_tmp(client, page, reg); + if(rv >= 0){ + return rv; + } + if ((i + 1) < PMBUS_RETRY_TIME) { + usleep_range(PMBUS_RETRY_SLEEP_TIME, PMBUS_RETRY_SLEEP_TIME + 1); + } + } + dev_info(dev, "rg_pmbus_read_word_data, page=%d, reg=0x%x, value=%d\r\n", page, reg, rv); + return rv; +} +EXPORT_SYMBOL_GPL(rg_pmbus_read_word_data); + +static int pmbus_read_virt_reg(struct i2c_client *client, int page, int reg) +{ + int rv; + int id; + + switch (reg) { + case PMBUS_VIRT_FAN_TARGET_1 ... PMBUS_VIRT_FAN_TARGET_4: + id = reg - PMBUS_VIRT_FAN_TARGET_1; + rv = rg_pmbus_get_fan_rate_device(client, page, id, rpm); + break; + default: + rv = -ENXIO; + break; + } + + return rv; +} + +/* + * _pmbus_read_word_data() is similar to rg_pmbus_read_word_data(), but checks if + * a device specific mapping function exists and calls it if necessary. + */ +static int _pmbus_read_word_data(struct i2c_client *client, int page, int reg) +{ + struct pmbus_data *data = i2c_get_clientdata(client); + const struct pmbus_driver_info *info = data->info; + int status; + + if (info->read_word_data) { + status = info->read_word_data(client, page, reg); + if (status != -ENODATA) + return status; + } + + if (reg >= PMBUS_VIRT_BASE) + return pmbus_read_virt_reg(client, page, reg); + + return rg_pmbus_read_word_data(client, page, reg); +} + +static int pmbus_read_byte_data_tmp(struct i2c_client *client, int page, u8 reg) +{ + int rv; + + rv = rg_pmbus_set_page(client, page); + if (rv < 0) + return rv; + + return i2c_smbus_read_byte_data(client, reg); +} + +int rg_pmbus_read_byte_data(struct i2c_client *client, int page, u8 reg) +{ + int rv, i; + struct device *dev = &client->dev; + for(i = 0; i < PMBUS_RETRY_TIME; i++) { + rv = pmbus_read_byte_data_tmp(client, page, reg); + if(rv >= 0){ + return rv; + } + if ((i + 1) < PMBUS_RETRY_TIME) { + usleep_range(PMBUS_RETRY_SLEEP_TIME, PMBUS_RETRY_SLEEP_TIME + 1); + } + } + dev_info(dev, "rg_pmbus_read_byte_data, page=%d, reg=0x%x, value=%d\r\n", page, reg, rv); + return rv;; +} +EXPORT_SYMBOL_GPL(rg_pmbus_read_byte_data); + +int rg_pmbus_write_byte_data(struct i2c_client *client, int page, u8 reg, u8 value) +{ + int rv; + + rv = rg_pmbus_set_page(client, page); + if (rv < 0) + return rv; + + return i2c_smbus_write_byte_data(client, reg, value); +} +EXPORT_SYMBOL_GPL(rg_pmbus_write_byte_data); + +int rg_pmbus_update_byte_data(struct i2c_client *client, int page, u8 reg, + u8 mask, u8 value) +{ + unsigned int tmp; + int rv; + + rv = rg_pmbus_read_byte_data(client, page, reg); + if (rv < 0) + return rv; + + tmp = (rv & ~mask) | (value & mask); + + if (tmp != rv) + rv = rg_pmbus_write_byte_data(client, page, reg, tmp); + + return rv; +} +EXPORT_SYMBOL_GPL(rg_pmbus_update_byte_data); + +/* + * _pmbus_read_byte_data() is similar to rg_pmbus_read_byte_data(), but checks if + * a device specific mapping function exists and calls it if necessary. + */ +static int _pmbus_read_byte_data(struct i2c_client *client, int page, int reg) +{ + struct pmbus_data *data = i2c_get_clientdata(client); + const struct pmbus_driver_info *info = data->info; + int status; + + if (info->read_byte_data) { + status = info->read_byte_data(client, page, reg); + if (status != -ENODATA) + return status; + } + return rg_pmbus_read_byte_data(client, page, reg); +} + +static struct pmbus_sensor *pmbus_find_sensor(struct pmbus_data *data, int page, + int reg) +{ + struct pmbus_sensor *sensor; + + for (sensor = data->sensors; sensor; sensor = sensor->next) { + if (sensor->page == page && sensor->reg == reg) + return sensor; + } + + return ERR_PTR(-EINVAL); +} + +static int pmbus_get_fan_rate(struct i2c_client *client, int page, int id, + enum pmbus_fan_mode mode, + bool from_cache) +{ + struct pmbus_data *data = i2c_get_clientdata(client); + bool want_rpm, have_rpm; + struct pmbus_sensor *s; + int config; + int reg; + + want_rpm = (mode == rpm); + + if (from_cache) { + reg = want_rpm ? PMBUS_VIRT_FAN_TARGET_1 : PMBUS_VIRT_PWM_1; + s = pmbus_find_sensor(data, page, reg + id); + if (IS_ERR(s)) + return PTR_ERR(s); + + return s->data; + } + + config = rg_pmbus_read_byte_data(client, page, + pmbus_fan_config_registers[id]); + if (config < 0) + return config; + + have_rpm = !!(config & pmbus_fan_rpm_mask[id]); + if (want_rpm == have_rpm) + return rg_pmbus_read_word_data(client, page, + pmbus_fan_command_registers[id]); + + /* Can't sensibly map between RPM and PWM, just return zero */ + return 0; +} + +int rg_pmbus_get_fan_rate_device(struct i2c_client *client, int page, int id, + enum pmbus_fan_mode mode) +{ + return pmbus_get_fan_rate(client, page, id, mode, false); +} +EXPORT_SYMBOL_GPL(rg_pmbus_get_fan_rate_device); + +int rg_pmbus_get_fan_rate_cached(struct i2c_client *client, int page, int id, + enum pmbus_fan_mode mode) +{ + return pmbus_get_fan_rate(client, page, id, mode, true); +} +EXPORT_SYMBOL_GPL(rg_pmbus_get_fan_rate_cached); + +static void pmbus_clear_fault_page(struct i2c_client *client, int page) +{ + _pmbus_write_byte(client, page, PMBUS_CLEAR_FAULTS); +} + +void rg_pmbus_clear_faults(struct i2c_client *client) +{ + struct pmbus_data *data = i2c_get_clientdata(client); + int i; + + for (i = 0; i < data->info->pages; i++) + pmbus_clear_fault_page(client, i); +} +EXPORT_SYMBOL_GPL(rg_pmbus_clear_faults); + +static int pmbus_check_status_cml(struct i2c_client *client) +{ + struct pmbus_data *data = i2c_get_clientdata(client); + int status, status2; + + status = data->read_status(client, -1); + if (status < 0 || (status & PB_STATUS_CML)) { + status2 = _pmbus_read_byte_data(client, -1, PMBUS_STATUS_CML); + if (status2 < 0 || (status2 & PB_CML_FAULT_INVALID_COMMAND)) + return -EIO; + } + return 0; +} + +static bool pmbus_check_register(struct i2c_client *client, + int (*func)(struct i2c_client *client, + int page, int reg), + int page, int reg) +{ + int rv; + struct pmbus_data *data = i2c_get_clientdata(client); + + rv = func(client, page, reg); + if (rv >= 0 && !(data->flags & PMBUS_SKIP_STATUS_CHECK)) + rv = pmbus_check_status_cml(client); + pmbus_clear_fault_page(client, -1); + return rv >= 0; +} + +static bool pmbus_check_status_register(struct i2c_client *client, int page) +{ + int status; + struct pmbus_data *data = i2c_get_clientdata(client); + + status = data->read_status(client, page); + if (status >= 0 && !(data->flags & PMBUS_SKIP_STATUS_CHECK) && + (status & PB_STATUS_CML)) { + status = _pmbus_read_byte_data(client, -1, PMBUS_STATUS_CML); + if (status < 0 || (status & PB_CML_FAULT_INVALID_COMMAND)) + status = -EIO; + } + + pmbus_clear_fault_page(client, -1); + return status >= 0; +} + +bool rg_pmbus_check_byte_register(struct i2c_client *client, int page, int reg) +{ + return pmbus_check_register(client, _pmbus_read_byte_data, page, reg); +} +EXPORT_SYMBOL_GPL(rg_pmbus_check_byte_register); + +bool rg_pmbus_check_word_register(struct i2c_client *client, int page, int reg) +{ + return pmbus_check_register(client, _pmbus_read_word_data, page, reg); +} +EXPORT_SYMBOL_GPL(rg_pmbus_check_word_register); + +const struct pmbus_driver_info *rg_pmbus_get_driver_info(struct i2c_client *client) +{ + struct pmbus_data *data = i2c_get_clientdata(client); + + return data->info; +} +EXPORT_SYMBOL_GPL(rg_pmbus_get_driver_info); + +static struct _pmbus_status { + u32 func; + u16 base; + u16 reg; +} pmbus_status[] = { + { PMBUS_HAVE_STATUS_VOUT, PB_STATUS_VOUT_BASE, PMBUS_STATUS_VOUT }, + { PMBUS_HAVE_STATUS_IOUT, PB_STATUS_IOUT_BASE, PMBUS_STATUS_IOUT }, + { PMBUS_HAVE_STATUS_TEMP, PB_STATUS_TEMP_BASE, + PMBUS_STATUS_TEMPERATURE }, + { PMBUS_HAVE_STATUS_FAN12, PB_STATUS_FAN_BASE, PMBUS_STATUS_FAN_12 }, + { PMBUS_HAVE_STATUS_FAN34, PB_STATUS_FAN34_BASE, PMBUS_STATUS_FAN_34 }, +}; + +static struct pmbus_data *pmbus_update_device(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev->parent); + struct pmbus_data *data = i2c_get_clientdata(client); + const struct pmbus_driver_info *info = data->info; + struct pmbus_sensor *sensor; + + mutex_lock(&data->update_lock); + if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { + int i, j; + + for (i = 0; i < info->pages; i++) { + data->status[PB_STATUS_BASE + i] + = data->read_status(client, i); + for (j = 0; j < ARRAY_SIZE(pmbus_status); j++) { + struct _pmbus_status *s = &pmbus_status[j]; + + if (!(info->func[i] & s->func)) + continue; + data->status[s->base + i] + = _pmbus_read_byte_data(client, i, + s->reg); + } + } + + if (info->func[0] & PMBUS_HAVE_STATUS_INPUT) + data->status[PB_STATUS_INPUT_BASE] + = _pmbus_read_byte_data(client, 0, + PMBUS_STATUS_INPUT); + + if (info->func[0] & PMBUS_HAVE_STATUS_VMON) + data->status[PB_STATUS_VMON_BASE] + = _pmbus_read_byte_data(client, 0, + PMBUS_VIRT_STATUS_VMON); + + for (sensor = data->sensors; sensor; sensor = sensor->next) { + if (!data->valid || sensor->update) + sensor->data + = _pmbus_read_word_data(client, + sensor->page, + sensor->reg); + } + rg_pmbus_clear_faults(client); + data->last_updated = jiffies; + data->valid = 1; + } + mutex_unlock(&data->update_lock); + return data; +} + +/* + * Convert linear sensor values to milli- or micro-units + * depending on sensor type. + */ +static long pmbus_reg2data_linear(struct pmbus_data *data, + struct pmbus_sensor *sensor) +{ + s16 exponent; + s32 mantissa; + long val; + + if (sensor->class == PSC_VOLTAGE_OUT) { /* LINEAR16 */ + exponent = data->exponent[sensor->page]; + mantissa = (u16) sensor->data; + } else { /* LINEAR11 */ + exponent = ((s16)sensor->data) >> 11; + mantissa = ((s16)((sensor->data & 0x7ff) << 5)) >> 5; + } + + val = mantissa; + + /* scale result to milli-units for all sensors except fans */ + if (sensor->class != PSC_FAN) + val = val * 1000L; + + /* scale result to micro-units for power sensors */ + if (sensor->class == PSC_POWER) + val = val * 1000L; + + if (exponent >= 0) + val <<= exponent; + else + val >>= -exponent; + + return val; +} + +/* + * Convert direct sensor values to milli- or micro-units + * depending on sensor type. + */ +static long pmbus_reg2data_direct(struct pmbus_data *data, + struct pmbus_sensor *sensor) +{ + s64 b, val = (s16)sensor->data; + s32 m, R; + + m = data->info->m[sensor->class]; + b = data->info->b[sensor->class]; + R = data->info->R[sensor->class]; + + if (m == 0) + return 0; + + /* X = 1/m * (Y * 10^-R - b) */ + R = -R; + /* scale result to milli-units for everything but fans */ + if (!(sensor->class == PSC_FAN || sensor->class == PSC_PWM)) { + R += 3; + b *= 1000; + } + + /* scale result to micro-units for power sensors */ + if (sensor->class == PSC_POWER) { + R += 3; + b *= 1000; + } + + while (R > 0) { + val *= 10; + R--; + } + while (R < 0) { + val = div_s64(val + 5LL, 10L); /* round closest */ + R++; + } + + val = div_s64(val - b, m); + return clamp_val(val, LONG_MIN, LONG_MAX); +} + +/* + * Convert VID sensor values to milli- or micro-units + * depending on sensor type. + */ +static long pmbus_reg2data_vid(struct pmbus_data *data, + struct pmbus_sensor *sensor) +{ + long val = sensor->data; + long rv = 0; + + switch (data->info->vrm_version[sensor->page]) { + case vr11: + if (val >= 0x02 && val <= 0xb2) + rv = DIV_ROUND_CLOSEST(160000 - (val - 2) * 625, 100); + break; + case vr12: + if (val >= 0x01) + rv = 250 + (val - 1) * 5; + break; + case vr13: + if (val >= 0x01) + rv = 500 + (val - 1) * 10; + break; + case imvp9: + if (val >= 0x01) + rv = 200 + (val - 1) * 10; + break; + case amd625mv: + if (val >= 0x0 && val <= 0xd8) + rv = DIV_ROUND_CLOSEST(155000 - val * 625, 100); + break; + } + return rv; +} + +static long pmbus_reg2data(struct pmbus_data *data, struct pmbus_sensor *sensor) +{ + long val; + + if (!sensor->convert) + return sensor->data; + + switch (data->info->format[sensor->class]) { + case direct: + val = pmbus_reg2data_direct(data, sensor); + break; + case vid: + val = pmbus_reg2data_vid(data, sensor); + break; + case linear: + default: + val = pmbus_reg2data_linear(data, sensor); + break; + } + return val; +} + +#define MAX_MANTISSA (1023 * 1000) +#define MIN_MANTISSA (511 * 1000) + +static u16 pmbus_data2reg_linear(struct pmbus_data *data, + struct pmbus_sensor *sensor, long val) +{ + s16 exponent = 0, mantissa; + bool negative = false; + + /* simple case */ + if (val == 0) + return 0; + + if (sensor->class == PSC_VOLTAGE_OUT) { + /* LINEAR16 does not support negative voltages */ + if (val < 0) + return 0; + + /* + * For a static exponents, we don't have a choice + * but to adjust the value to it. + */ + if (data->exponent[sensor->page] < 0) + val <<= -data->exponent[sensor->page]; + else + val >>= data->exponent[sensor->page]; + val = DIV_ROUND_CLOSEST(val, 1000); + return val & 0xffff; + } + + if (val < 0) { + negative = true; + val = -val; + } + + /* Power is in uW. Convert to mW before converting. */ + if (sensor->class == PSC_POWER) + val = DIV_ROUND_CLOSEST(val, 1000L); + + /* + * For simplicity, convert fan data to milli-units + * before calculating the exponent. + */ + if (sensor->class == PSC_FAN) + val = val * 1000; + + /* Reduce large mantissa until it fits into 10 bit */ + while (val >= MAX_MANTISSA && exponent < 15) { + exponent++; + val >>= 1; + } + /* Increase small mantissa to improve precision */ + while (val < MIN_MANTISSA && exponent > -15) { + exponent--; + val <<= 1; + } + + /* Convert mantissa from milli-units to units */ + mantissa = DIV_ROUND_CLOSEST(val, 1000); + + /* Ensure that resulting number is within range */ + if (mantissa > 0x3ff) + mantissa = 0x3ff; + + /* restore sign */ + if (negative) + mantissa = -mantissa; + + /* Convert to 5 bit exponent, 11 bit mantissa */ + return (mantissa & 0x7ff) | ((exponent << 11) & 0xf800); +} + +static u16 pmbus_data2reg_direct(struct pmbus_data *data, + struct pmbus_sensor *sensor, long val) +{ + s64 b, val64 = val; + s32 m, R; + + m = data->info->m[sensor->class]; + b = data->info->b[sensor->class]; + R = data->info->R[sensor->class]; + + /* Power is in uW. Adjust R and b. */ + if (sensor->class == PSC_POWER) { + R -= 3; + b *= 1000; + } + + /* Calculate Y = (m * X + b) * 10^R */ + if (!(sensor->class == PSC_FAN || sensor->class == PSC_PWM)) { + R -= 3; /* Adjust R and b for data in milli-units */ + b *= 1000; + } + val64 = val64 * m + b; + + while (R > 0) { + val64 *= 10; + R--; + } + while (R < 0) { + val64 = div_s64(val64 + 5LL, 10L); /* round closest */ + R++; + } + + return (u16)clamp_val(val64, S16_MIN, S16_MAX); +} + +static u16 pmbus_data2reg_vid(struct pmbus_data *data, + struct pmbus_sensor *sensor, long val) +{ + val = clamp_val(val, 500, 1600); + + return 2 + DIV_ROUND_CLOSEST((1600 - val) * 100, 625); +} + +static u16 pmbus_data2reg(struct pmbus_data *data, + struct pmbus_sensor *sensor, long val) +{ + u16 regval; + + if (!sensor->convert) + return val; + + switch (data->info->format[sensor->class]) { + case direct: + regval = pmbus_data2reg_direct(data, sensor, val); + break; + case vid: + regval = pmbus_data2reg_vid(data, sensor, val); + break; + case linear: + default: + regval = pmbus_data2reg_linear(data, sensor, val); + break; + } + return regval; +} + +/* + * Return boolean calculated from converted data. + * defines a status register index and mask. + * The mask is in the lower 8 bits, the register index is in bits 8..23. + * + * The associated pmbus_boolean structure contains optional pointers to two + * sensor attributes. If specified, those attributes are compared against each + * other to determine if a limit has been exceeded. + * + * If the sensor attribute pointers are NULL, the function returns true if + * (status[reg] & mask) is true. + * + * If sensor attribute pointers are provided, a comparison against a specified + * limit has to be performed to determine the boolean result. + * In this case, the function returns true if v1 >= v2 (where v1 and v2 are + * sensor values referenced by sensor attribute pointers s1 and s2). + * + * To determine if an object exceeds upper limits, specify = . + * To determine if an object exceeds lower limits, specify = . + * + * If a negative value is stored in any of the referenced registers, this value + * reflects an error code which will be returned. + */ +static int pmbus_get_boolean(struct pmbus_data *data, struct pmbus_boolean *b, + int index) +{ + struct pmbus_sensor *s1 = b->s1; + struct pmbus_sensor *s2 = b->s2; + u16 reg = (index >> 16) & 0xffff; + u16 mask = index & 0xffff; + int ret, status; + u16 regval; + + status = data->status[reg]; + if (status < 0) + return status; + + regval = status & mask; + if (!s1 && !s2) { + ret = !!regval; + } else if (!s1 || !s2) { + WARN(1, "Bad boolean descriptor %p: s1=%p, s2=%p\n", b, s1, s2); + return 0; + } else { + long v1, v2; + + if (s1->data < 0) + return s1->data; + if (s2->data < 0) + return s2->data; + + v1 = pmbus_reg2data(data, s1); + v2 = pmbus_reg2data(data, s2); + ret = !!(regval && v1 >= v2); + } + return ret; +} + +static ssize_t pmbus_show_boolean(struct device *dev, + struct device_attribute *da, char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct pmbus_boolean *boolean = to_pmbus_boolean(attr); + struct pmbus_data *data = pmbus_update_device(dev); + int val; + + val = pmbus_get_boolean(data, boolean, attr->index); + if (val < 0) + return val; + return snprintf(buf, PAGE_SIZE, "%d\n", val); +} + +static ssize_t pmbus_show_sensor(struct device *dev, + struct device_attribute *devattr, char *buf) +{ + struct pmbus_data *data = pmbus_update_device(dev); + struct pmbus_sensor *sensor = to_pmbus_sensor(devattr); + + if (sensor->data < 0) + return sensor->data; + + return snprintf(buf, PAGE_SIZE, "%ld\n", pmbus_reg2data(data, sensor)); +} + +static ssize_t pmbus_set_sensor(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) +{ + struct i2c_client *client = to_i2c_client(dev->parent); + struct pmbus_data *data = i2c_get_clientdata(client); + struct pmbus_sensor *sensor = to_pmbus_sensor(devattr); + ssize_t rv = count; + long val = 0; + int ret; + u16 regval; + + if (kstrtol(buf, 10, &val) < 0) + return -EINVAL; + + mutex_lock(&data->update_lock); + regval = pmbus_data2reg(data, sensor, val); + ret = _pmbus_write_word_data(client, sensor->page, sensor->reg, regval); + if (ret < 0) + rv = ret; + else + sensor->data = regval; + mutex_unlock(&data->update_lock); + return rv; +} + +static ssize_t pmbus_show_label(struct device *dev, + struct device_attribute *da, char *buf) +{ + struct pmbus_label *label = to_pmbus_label(da); + + return snprintf(buf, PAGE_SIZE, "%s\n", label->label); +} + +static ssize_t pmbus_show_status(struct device *dev, + struct device_attribute *da, char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct pmbus_data *data = pmbus_update_device(dev); + u16 reg; + int index, status; + + index = attr->index; + reg = (index >> 16) & 0xffff; + status = data->status[reg]; + + return snprintf(buf, PAGE_SIZE, "0x%04x\n", status); +} + +static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr) +{ + if (data->num_attributes >= data->max_attributes - 1) { + int new_max_attrs = data->max_attributes + PMBUS_ATTR_ALLOC_SIZE; + void *new_attrs = krealloc(data->group.attrs, + new_max_attrs * sizeof(void *), + GFP_KERNEL); + if (!new_attrs) + return -ENOMEM; + data->group.attrs = new_attrs; + data->max_attributes = new_max_attrs; + } + + data->group.attrs[data->num_attributes++] = attr; + data->group.attrs[data->num_attributes] = NULL; + return 0; +} + +static void pmbus_dev_attr_init(struct device_attribute *dev_attr, + const char *name, + umode_t mode, + ssize_t (*show)(struct device *dev, + struct device_attribute *attr, + char *buf), + ssize_t (*store)(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count)) +{ + sysfs_attr_init(&dev_attr->attr); + dev_attr->attr.name = name; + dev_attr->attr.mode = mode; + dev_attr->show = show; + dev_attr->store = store; +} + +static void pmbus_attr_init(struct sensor_device_attribute *a, + const char *name, + umode_t mode, + ssize_t (*show)(struct device *dev, + struct device_attribute *attr, + char *buf), + ssize_t (*store)(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count), + int idx) +{ + pmbus_dev_attr_init(&a->dev_attr, name, mode, show, store); + a->index = idx; +} + +static int pmbus_add_boolean(struct pmbus_data *data, + const char *name, const char *type, int seq, + struct pmbus_sensor *s1, + struct pmbus_sensor *s2, + u16 reg, u16 mask) +{ + struct pmbus_boolean *boolean; + struct sensor_device_attribute *a; + + boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL); + if (!boolean) + return -ENOMEM; + + a = &boolean->attribute; + + snprintf(boolean->name, sizeof(boolean->name), "%s%d_%s", + name, seq, type); + boolean->s1 = s1; + boolean->s2 = s2; + pmbus_attr_init(a, boolean->name, S_IRUGO, pmbus_show_boolean, NULL, + (reg << 16) | mask); + + return pmbus_add_attribute(data, &a->dev_attr.attr); +} + +static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data, + const char *name, const char *type, + int seq, int page, int reg, + enum pmbus_sensor_classes class, + bool update, bool readonly, + bool convert) +{ + struct pmbus_sensor *sensor; + struct device_attribute *a; + + sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL); + if (!sensor) + return NULL; + a = &sensor->attribute; + + if (type) + snprintf(sensor->name, sizeof(sensor->name), "%s%d_%s", + name, seq, type); + else + snprintf(sensor->name, sizeof(sensor->name), "%s%d", + name, seq); + + sensor->page = page; + sensor->reg = reg; + sensor->class = class; + sensor->update = update; + sensor->convert = convert; + pmbus_dev_attr_init(a, sensor->name, + readonly ? S_IRUGO : S_IRUGO | S_IWUSR, + pmbus_show_sensor, pmbus_set_sensor); + + if (pmbus_add_attribute(data, &a->attr)) + return NULL; + + sensor->next = data->sensors; + data->sensors = sensor; + + return sensor; +} + +static int pmbus_add_label(struct pmbus_data *data, + const char *name, int seq, + const char *lstring, int index) +{ + struct pmbus_label *label; + struct device_attribute *a; + + label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL); + if (!label) + return -ENOMEM; + + a = &label->attribute; + + snprintf(label->name, sizeof(label->name), "%s%d_label", name, seq); + if (!index) + strncpy(label->label, lstring, sizeof(label->label) - 1); + else + snprintf(label->label, sizeof(label->label), "%s%d", lstring, + index); + + pmbus_dev_attr_init(a, label->name, S_IRUGO, pmbus_show_label, NULL); + return pmbus_add_attribute(data, &a->attr); +} + +static int pmbus_add_status(struct pmbus_data *data, int page) +{ + struct pmbus_attr_status *attr_status; + struct device_attribute *a; + + attr_status = devm_kzalloc(data->dev, sizeof(*attr_status), GFP_KERNEL); + if (!attr_status) + return -ENOMEM; + + snprintf(attr_status->name, sizeof(attr_status->name), "status%d", page); + a = &attr_status->attribute; + + pmbus_dev_attr_init(a, attr_status->name, S_IRUGO, pmbus_show_status, NULL); + return pmbus_add_attribute(data, &a->attr); +} + +/* + * Search for attributes. Allocate sensors, booleans, and labels as needed. + */ + +/* + * The pmbus_limit_attr structure describes a single limit attribute + * and its associated alarm attribute. + */ +struct pmbus_limit_attr { + u16 reg; /* Limit register */ + u16 sbit; /* Alarm attribute status bit */ + bool update; /* True if register needs updates */ + bool low; /* True if low limit; for limits with compare + functions only */ + const char *attr; /* Attribute name */ + const char *alarm; /* Alarm attribute name */ +}; + +/* + * The pmbus_sensor_attr structure describes one sensor attribute. This + * description includes a reference to the associated limit attributes. + */ +struct pmbus_sensor_attr { + u16 reg; /* sensor register */ + u16 gbit; /* generic status bit */ + u8 nlimit; /* # of limit registers */ + enum pmbus_sensor_classes class;/* sensor class */ + const char *label; /* sensor label */ + bool paged; /* true if paged sensor */ + bool update; /* true if update needed */ + bool compare; /* true if compare function needed */ + u32 func; /* sensor mask */ + u32 sfunc; /* sensor status mask */ + int sbase; /* status base register */ + const struct pmbus_limit_attr *limit;/* limit registers */ +}; + +/* + * Add a set of limit attributes and, if supported, the associated + * alarm attributes. + * returns 0 if no alarm register found, 1 if an alarm register was found, + * < 0 on errors. + */ +static int pmbus_add_limit_attrs(struct i2c_client *client, + struct pmbus_data *data, + const struct pmbus_driver_info *info, + const char *name, int index, int page, + struct pmbus_sensor *base, + const struct pmbus_sensor_attr *attr) +{ + const struct pmbus_limit_attr *l = attr->limit; + int nlimit = attr->nlimit; + int have_alarm = 0; + int i, ret; + struct pmbus_sensor *curr; + + for (i = 0; i < nlimit; i++) { + if (rg_pmbus_check_word_register(client, page, l->reg)) { + curr = pmbus_add_sensor(data, name, l->attr, index, + page, l->reg, attr->class, + attr->update || l->update, + false, true); + if (!curr) + return -ENOMEM; + if (l->sbit && (info->func[page] & attr->sfunc)) { + ret = pmbus_add_boolean(data, name, + l->alarm, index, + attr->compare ? l->low ? curr : base + : NULL, + attr->compare ? l->low ? base : curr + : NULL, + attr->sbase + page, l->sbit); + if (ret) + return ret; + have_alarm = 1; + } + } + l++; + } + return have_alarm; +} + +static int pmbus_add_sensor_attrs_one(struct i2c_client *client, + struct pmbus_data *data, + const struct pmbus_driver_info *info, + const char *name, + int index, int page, + const struct pmbus_sensor_attr *attr, + bool paged) +{ + struct pmbus_sensor *base; + bool upper = !!(attr->gbit & 0xff00); /* need to check STATUS_WORD */ + int ret; + + if (attr->label) { + ret = pmbus_add_label(data, name, index, attr->label, + paged ? page + 1 : 0); + if (ret) + return ret; + } + base = pmbus_add_sensor(data, name, "input", index, page, attr->reg, + attr->class, true, true, true); + if (!base) + return -ENOMEM; + if (attr->sfunc) { + ret = pmbus_add_limit_attrs(client, data, info, name, + index, page, base, attr); + if (ret < 0) + return ret; + /* + * Add generic alarm attribute only if there are no individual + * alarm attributes, if there is a global alarm bit, and if + * the generic status register (word or byte, depending on + * which global bit is set) for this page is accessible. + */ + if (!ret && attr->gbit && + (!upper || (upper && data->has_status_word)) && + pmbus_check_status_register(client, page)) { + ret = pmbus_add_boolean(data, name, "alarm", index, + NULL, NULL, + PB_STATUS_BASE + page, + attr->gbit); + if (ret) + return ret; + } + } + return 0; +} + +static bool pmbus_sensor_is_paged(const struct pmbus_driver_info *info, + const struct pmbus_sensor_attr *attr) +{ + int p; + + if (attr->paged) + return true; + + /* + * Some attributes may be present on more than one page despite + * not being marked with the paged attribute. If that is the case, + * then treat the sensor as being paged and add the page suffix to the + * attribute name. + * We don't just add the paged attribute to all such attributes, in + * order to maintain the un-suffixed labels in the case where the + * attribute is only on page 0. + */ + for (p = 1; p < info->pages; p++) { + if (info->func[p] & attr->func) + return true; + } + return false; +} + +static int pmbus_add_status_attrs(struct i2c_client *client, struct pmbus_data *data) +{ + const struct pmbus_driver_info *info = data->info; + int i; + int ret; + + for (i = 0; i < info->pages; i++) { + ret = pmbus_add_status(data, i); + if (ret) { + return ret; + } + } + + return 0; +} + +static int pmbus_add_sensor_attrs(struct i2c_client *client, + struct pmbus_data *data, + const char *name, + const struct pmbus_sensor_attr *attrs, + int nattrs) +{ + const struct pmbus_driver_info *info = data->info; + int index, i; + int ret; + + index = 1; + for (i = 0; i < nattrs; i++) { + int page, pages; + bool paged = pmbus_sensor_is_paged(info, attrs); + + pages = paged ? info->pages : 1; + for (page = 0; page < pages; page++) { + if (!(info->func[page] & attrs->func)) + continue; + ret = pmbus_add_sensor_attrs_one(client, data, info, + name, index, page, + attrs, paged); + if (ret) + return ret; + index++; + } + attrs++; + } + return 0; +} + +static const struct pmbus_limit_attr vin_limit_attrs[] = { + { + .reg = PMBUS_VIN_UV_WARN_LIMIT, + .attr = "min", + .alarm = "min_alarm", + .sbit = PB_VOLTAGE_UV_WARNING, + }, { + .reg = PMBUS_VIN_UV_FAULT_LIMIT, + .attr = "lcrit", + .alarm = "lcrit_alarm", + .sbit = PB_VOLTAGE_UV_FAULT, + }, { + .reg = PMBUS_VIN_OV_WARN_LIMIT, + .attr = "max", + .alarm = "max_alarm", + .sbit = PB_VOLTAGE_OV_WARNING, + }, { + .reg = PMBUS_VIN_OV_FAULT_LIMIT, + .attr = "crit", + .alarm = "crit_alarm", + .sbit = PB_VOLTAGE_OV_FAULT, + }, { + .reg = PMBUS_VIRT_READ_VIN_AVG, + .update = true, + .attr = "average", + }, { + .reg = PMBUS_VIRT_READ_VIN_MIN, + .update = true, + .attr = "lowest", + }, { + .reg = PMBUS_VIRT_READ_VIN_MAX, + .update = true, + .attr = "highest", + }, { + .reg = PMBUS_VIRT_RESET_VIN_HISTORY, + .attr = "reset_history", + }, +}; + +static const struct pmbus_limit_attr vmon_limit_attrs[] = { + { + .reg = PMBUS_VIRT_VMON_UV_WARN_LIMIT, + .attr = "min", + .alarm = "min_alarm", + .sbit = PB_VOLTAGE_UV_WARNING, + }, { + .reg = PMBUS_VIRT_VMON_UV_FAULT_LIMIT, + .attr = "lcrit", + .alarm = "lcrit_alarm", + .sbit = PB_VOLTAGE_UV_FAULT, + }, { + .reg = PMBUS_VIRT_VMON_OV_WARN_LIMIT, + .attr = "max", + .alarm = "max_alarm", + .sbit = PB_VOLTAGE_OV_WARNING, + }, { + .reg = PMBUS_VIRT_VMON_OV_FAULT_LIMIT, + .attr = "crit", + .alarm = "crit_alarm", + .sbit = PB_VOLTAGE_OV_FAULT, + } +}; + +static const struct pmbus_limit_attr vout_limit_attrs[] = { + { + .reg = PMBUS_VOUT_UV_WARN_LIMIT, + .attr = "min", + .alarm = "min_alarm", + .sbit = PB_VOLTAGE_UV_WARNING, + }, { + .reg = PMBUS_VOUT_UV_FAULT_LIMIT, + .attr = "lcrit", + .alarm = "lcrit_alarm", + .sbit = PB_VOLTAGE_UV_FAULT, + }, { + .reg = PMBUS_VOUT_OV_WARN_LIMIT, + .attr = "max", + .alarm = "max_alarm", + .sbit = PB_VOLTAGE_OV_WARNING, + }, { + .reg = PMBUS_VOUT_OV_FAULT_LIMIT, + .attr = "crit", + .alarm = "crit_alarm", + .sbit = PB_VOLTAGE_OV_FAULT, + }, { + .reg = PMBUS_VIRT_READ_VOUT_AVG, + .update = true, + .attr = "average", + }, { + .reg = PMBUS_VIRT_READ_VOUT_MIN, + .update = true, + .attr = "lowest", + }, { + .reg = PMBUS_VIRT_READ_VOUT_MAX, + .update = true, + .attr = "highest", + }, { + .reg = PMBUS_VIRT_RESET_VOUT_HISTORY, + .attr = "reset_history", + } +}; + +static const struct pmbus_sensor_attr voltage_attributes[] = { + { + .reg = PMBUS_READ_VIN, + .class = PSC_VOLTAGE_IN, + .label = "vin", + .func = PMBUS_HAVE_VIN, + .sfunc = PMBUS_HAVE_STATUS_INPUT, + .sbase = PB_STATUS_INPUT_BASE, + .gbit = PB_STATUS_VIN_UV, + .limit = vin_limit_attrs, + .nlimit = 0, + }, { + .reg = PMBUS_VIRT_READ_VMON, + .class = PSC_VOLTAGE_IN, + .label = "vmon", + .func = PMBUS_HAVE_VMON, + .sfunc = PMBUS_HAVE_STATUS_VMON, + .sbase = PB_STATUS_VMON_BASE, + .limit = vmon_limit_attrs, + .nlimit = 0, + }, { + .reg = PMBUS_READ_VCAP, + .class = PSC_VOLTAGE_IN, + .label = "vcap", + .func = PMBUS_HAVE_VCAP, + }, { + .reg = PMBUS_READ_VOUT, + .class = PSC_VOLTAGE_OUT, + .label = "vout", + .paged = true, + .func = PMBUS_HAVE_VOUT, + .sfunc = PMBUS_HAVE_STATUS_VOUT, + .sbase = PB_STATUS_VOUT_BASE, + .gbit = PB_STATUS_VOUT_OV, + .limit = vout_limit_attrs, + .nlimit = 0, + } +}; + +/* Current attributes */ + +static const struct pmbus_limit_attr iin_limit_attrs[] = { + { + .reg = PMBUS_IIN_OC_WARN_LIMIT, + .attr = "max", + .alarm = "max_alarm", + .sbit = PB_IIN_OC_WARNING, + }, { + .reg = PMBUS_IIN_OC_FAULT_LIMIT, + .attr = "crit", + .alarm = "crit_alarm", + .sbit = PB_IIN_OC_FAULT, + }, { + .reg = PMBUS_VIRT_READ_IIN_AVG, + .update = true, + .attr = "average", + }, { + .reg = PMBUS_VIRT_READ_IIN_MIN, + .update = true, + .attr = "lowest", + }, { + .reg = PMBUS_VIRT_READ_IIN_MAX, + .update = true, + .attr = "highest", + }, { + .reg = PMBUS_VIRT_RESET_IIN_HISTORY, + .attr = "reset_history", + } +}; + +static const struct pmbus_limit_attr iout_limit_attrs[] = { + { + .reg = PMBUS_IOUT_OC_WARN_LIMIT, + .attr = "max", + .alarm = "max_alarm", + .sbit = PB_IOUT_OC_WARNING, + }, { + .reg = PMBUS_IOUT_UC_FAULT_LIMIT, + .attr = "lcrit", + .alarm = "lcrit_alarm", + .sbit = PB_IOUT_UC_FAULT, + }, { + .reg = PMBUS_IOUT_OC_FAULT_LIMIT, + .attr = "crit", + .alarm = "crit_alarm", + .sbit = PB_IOUT_OC_FAULT, + }, { + .reg = PMBUS_VIRT_READ_IOUT_AVG, + .update = true, + .attr = "average", + }, { + .reg = PMBUS_VIRT_READ_IOUT_MIN, + .update = true, + .attr = "lowest", + }, { + .reg = PMBUS_VIRT_READ_IOUT_MAX, + .update = true, + .attr = "highest", + }, { + .reg = PMBUS_VIRT_RESET_IOUT_HISTORY, + .attr = "reset_history", + } +}; + +static const struct pmbus_sensor_attr current_attributes[] = { + { + .reg = PMBUS_READ_IIN, + .class = PSC_CURRENT_IN, + .label = "iin", + .func = PMBUS_HAVE_IIN, + .sfunc = PMBUS_HAVE_STATUS_INPUT, + .sbase = PB_STATUS_INPUT_BASE, + .gbit = PB_STATUS_INPUT, + .limit = iin_limit_attrs, + .nlimit = 0, + }, { + .reg = PMBUS_READ_IOUT, + .class = PSC_CURRENT_OUT, + .label = "iout", + .paged = true, + .func = PMBUS_HAVE_IOUT, + .sfunc = PMBUS_HAVE_STATUS_IOUT, + .sbase = PB_STATUS_IOUT_BASE, + .gbit = PB_STATUS_IOUT_OC, + .limit = iout_limit_attrs, + .nlimit = 0, + } +}; + +/* Power attributes */ + +static const struct pmbus_limit_attr pin_limit_attrs[] = { + { + .reg = PMBUS_PIN_OP_WARN_LIMIT, + .attr = "max", + .alarm = "alarm", + .sbit = PB_PIN_OP_WARNING, + }, { + .reg = PMBUS_VIRT_READ_PIN_AVG, + .update = true, + .attr = "average", + }, { + .reg = PMBUS_VIRT_READ_PIN_MIN, + .update = true, + .attr = "input_lowest", + }, { + .reg = PMBUS_VIRT_READ_PIN_MAX, + .update = true, + .attr = "input_highest", + }, { + .reg = PMBUS_VIRT_RESET_PIN_HISTORY, + .attr = "reset_history", + } +}; + +static const struct pmbus_limit_attr pout_limit_attrs[] = { + { + .reg = PMBUS_POUT_MAX, + .attr = "cap", + .alarm = "cap_alarm", + .sbit = PB_POWER_LIMITING, + }, { + .reg = PMBUS_POUT_OP_WARN_LIMIT, + .attr = "max", + .alarm = "max_alarm", + .sbit = PB_POUT_OP_WARNING, + }, { + .reg = PMBUS_POUT_OP_FAULT_LIMIT, + .attr = "crit", + .alarm = "crit_alarm", + .sbit = PB_POUT_OP_FAULT, + }, { + .reg = PMBUS_VIRT_READ_POUT_AVG, + .update = true, + .attr = "average", + }, { + .reg = PMBUS_VIRT_READ_POUT_MIN, + .update = true, + .attr = "input_lowest", + }, { + .reg = PMBUS_VIRT_READ_POUT_MAX, + .update = true, + .attr = "input_highest", + }, { + .reg = PMBUS_VIRT_RESET_POUT_HISTORY, + .attr = "reset_history", + } +}; + +static const struct pmbus_sensor_attr power_attributes[] = { + { + .reg = PMBUS_READ_PIN, + .class = PSC_POWER, + .label = "pin", + .func = PMBUS_HAVE_PIN, + .sfunc = PMBUS_HAVE_STATUS_INPUT, + .sbase = PB_STATUS_INPUT_BASE, + .gbit = PB_STATUS_INPUT, + .limit = pin_limit_attrs, + .nlimit = 0, + }, { + .reg = PMBUS_READ_POUT, + .class = PSC_POWER, + .label = "pout", + .paged = true, + .func = PMBUS_HAVE_POUT, + .sfunc = PMBUS_HAVE_STATUS_IOUT, + .sbase = PB_STATUS_IOUT_BASE, + .limit = pout_limit_attrs, + .nlimit = 0, + } +}; + +/* Temperature atributes */ + +static const struct pmbus_limit_attr temp_limit_attrs[] = { + { + .reg = PMBUS_UT_WARN_LIMIT, + .low = true, + .attr = "min", + .alarm = "min_alarm", + .sbit = PB_TEMP_UT_WARNING, + }, { + .reg = PMBUS_UT_FAULT_LIMIT, + .low = true, + .attr = "lcrit", + .alarm = "lcrit_alarm", + .sbit = PB_TEMP_UT_FAULT, + }, { + .reg = PMBUS_OT_WARN_LIMIT, + .attr = "max", + .alarm = "max_alarm", + .sbit = PB_TEMP_OT_WARNING, + }, { + .reg = PMBUS_OT_FAULT_LIMIT, + .attr = "crit", + .alarm = "crit_alarm", + .sbit = PB_TEMP_OT_FAULT, + }, { + .reg = PMBUS_VIRT_READ_TEMP_MIN, + .attr = "lowest", + }, { + .reg = PMBUS_VIRT_READ_TEMP_AVG, + .attr = "average", + }, { + .reg = PMBUS_VIRT_READ_TEMP_MAX, + .attr = "highest", + }, { + .reg = PMBUS_VIRT_RESET_TEMP_HISTORY, + .attr = "reset_history", + } +}; + +static const struct pmbus_limit_attr temp_limit_attrs2[] = { + { + .reg = PMBUS_UT_WARN_LIMIT, + .low = true, + .attr = "min", + .alarm = "min_alarm", + .sbit = PB_TEMP_UT_WARNING, + }, { + .reg = PMBUS_UT_FAULT_LIMIT, + .low = true, + .attr = "lcrit", + .alarm = "lcrit_alarm", + .sbit = PB_TEMP_UT_FAULT, + }, { + .reg = PMBUS_OT_WARN_LIMIT, + .attr = "max", + .alarm = "max_alarm", + .sbit = PB_TEMP_OT_WARNING, + }, { + .reg = PMBUS_OT_FAULT_LIMIT, + .attr = "crit", + .alarm = "crit_alarm", + .sbit = PB_TEMP_OT_FAULT, + }, { + .reg = PMBUS_VIRT_READ_TEMP2_MIN, + .attr = "lowest", + }, { + .reg = PMBUS_VIRT_READ_TEMP2_AVG, + .attr = "average", + }, { + .reg = PMBUS_VIRT_READ_TEMP2_MAX, + .attr = "highest", + }, { + .reg = PMBUS_VIRT_RESET_TEMP2_HISTORY, + .attr = "reset_history", + } +}; + +static const struct pmbus_limit_attr temp_limit_attrs3[] = { + { + .reg = PMBUS_UT_WARN_LIMIT, + .low = true, + .attr = "min", + .alarm = "min_alarm", + .sbit = PB_TEMP_UT_WARNING, + }, { + .reg = PMBUS_UT_FAULT_LIMIT, + .low = true, + .attr = "lcrit", + .alarm = "lcrit_alarm", + .sbit = PB_TEMP_UT_FAULT, + }, { + .reg = PMBUS_OT_WARN_LIMIT, + .attr = "max", + .alarm = "max_alarm", + .sbit = PB_TEMP_OT_WARNING, + }, { + .reg = PMBUS_OT_FAULT_LIMIT, + .attr = "crit", + .alarm = "crit_alarm", + .sbit = PB_TEMP_OT_FAULT, + } +}; + +static const struct pmbus_sensor_attr temp_attributes[] = { + { + .reg = PMBUS_READ_TEMPERATURE_1, + .class = PSC_TEMPERATURE, + .paged = true, + .update = true, + .compare = true, + .func = PMBUS_HAVE_TEMP, + .sfunc = PMBUS_HAVE_STATUS_TEMP, + .sbase = PB_STATUS_TEMP_BASE, + .gbit = PB_STATUS_TEMPERATURE, + .limit = temp_limit_attrs, + .nlimit = 0, + }, { + .reg = PMBUS_READ_TEMPERATURE_2, + .class = PSC_TEMPERATURE, + .paged = true, + .update = true, + .compare = true, + .func = PMBUS_HAVE_TEMP2, + .sfunc = PMBUS_HAVE_STATUS_TEMP, + .sbase = PB_STATUS_TEMP_BASE, + .gbit = PB_STATUS_TEMPERATURE, + .limit = temp_limit_attrs2, + .nlimit = 0, + }, { + .reg = PMBUS_READ_TEMPERATURE_3, + .class = PSC_TEMPERATURE, + .paged = true, + .update = true, + .compare = true, + .func = PMBUS_HAVE_TEMP3, + .sfunc = PMBUS_HAVE_STATUS_TEMP, + .sbase = PB_STATUS_TEMP_BASE, + .gbit = PB_STATUS_TEMPERATURE, + .limit = temp_limit_attrs3, + .nlimit = 0, + } +}; + +static const int pmbus_fan_registers[] = { + PMBUS_READ_FAN_SPEED_1, + PMBUS_READ_FAN_SPEED_2, + PMBUS_READ_FAN_SPEED_3, + PMBUS_READ_FAN_SPEED_4 +}; + +static const int pmbus_fan_status_registers[] = { + PMBUS_STATUS_FAN_12, + PMBUS_STATUS_FAN_12, + PMBUS_STATUS_FAN_34, + PMBUS_STATUS_FAN_34 +}; + +static const u32 pmbus_fan_flags[] = { + PMBUS_HAVE_FAN12, + PMBUS_HAVE_FAN12, + PMBUS_HAVE_FAN34, + PMBUS_HAVE_FAN34 +}; + +static const u32 pmbus_fan_status_flags[] = { + PMBUS_HAVE_STATUS_FAN12, + PMBUS_HAVE_STATUS_FAN12, + PMBUS_HAVE_STATUS_FAN34, + PMBUS_HAVE_STATUS_FAN34 +}; + +/* Fans */ + +/* Precondition: FAN_CONFIG_x_y and FAN_COMMAND_x must exist for the fan ID */ +static int pmbus_add_fan_ctrl(struct i2c_client *client, + struct pmbus_data *data, int index, int page, int id, + u8 config) +{ + struct pmbus_sensor *sensor; + + sensor = pmbus_add_sensor(data, "fan", "target", index, page, + PMBUS_VIRT_FAN_TARGET_1 + id, PSC_FAN, + false, false, true); + + if (!sensor) + return -ENOMEM; + + if (!((data->info->func[page] & PMBUS_HAVE_PWM12) || + (data->info->func[page] & PMBUS_HAVE_PWM34))) + return 0; + + sensor = pmbus_add_sensor(data, "pwm", NULL, index, page, + PMBUS_VIRT_PWM_1 + id, PSC_PWM, + false, false, true); + + if (!sensor) + return -ENOMEM; + + sensor = pmbus_add_sensor(data, "pwm", "enable", index, page, + PMBUS_VIRT_PWM_ENABLE_1 + id, PSC_PWM, + true, false, false); + + if (!sensor) + return -ENOMEM; + + return 0; +} + +static int pmbus_add_fan_attributes(struct i2c_client *client, + struct pmbus_data *data) +{ + const struct pmbus_driver_info *info = data->info; + int index = 1; + int page; + int ret; + + for (page = 0; page < info->pages; page++) { + int f; + + for (f = 0; f < ARRAY_SIZE(pmbus_fan_registers); f++) { + int regval; + + if (!(info->func[page] & pmbus_fan_flags[f])) + break; + + if (!rg_pmbus_check_word_register(client, page, + pmbus_fan_registers[f])) + break; + + /* + * Skip fan if not installed. + * Each fan configuration register covers multiple fans, + * so we have to do some magic. + */ + regval = _pmbus_read_byte_data(client, page, + pmbus_fan_config_registers[f]); + if (regval < 0 || + (!(regval & (PB_FAN_1_INSTALLED >> ((f & 1) * 4))))) + continue; + + if (pmbus_add_sensor(data, "fan", "input", index, + page, pmbus_fan_registers[f], + PSC_FAN, true, true, true) == NULL) + return -ENOMEM; + + /* Fan control */ + if (rg_pmbus_check_word_register(client, page, + pmbus_fan_command_registers[f])) { + ret = pmbus_add_fan_ctrl(client, data, index, + page, f, regval); + if (ret < 0) + return ret; + } + + /* + * Each fan status register covers multiple fans, + * so we have to do some magic. + */ + if ((info->func[page] & pmbus_fan_status_flags[f]) && + rg_pmbus_check_byte_register(client, + page, pmbus_fan_status_registers[f])) { + int base; + + if (f > 1) /* fan 3, 4 */ + base = PB_STATUS_FAN34_BASE + page; + else + base = PB_STATUS_FAN_BASE + page; + ret = pmbus_add_boolean(data, "fan", + "alarm", index, NULL, NULL, base, + PB_FAN_FAN1_WARNING >> (f & 1)); + if (ret) + return ret; + ret = pmbus_add_boolean(data, "fan", + "fault", index, NULL, NULL, base, + PB_FAN_FAN1_FAULT >> (f & 1)); + if (ret) + return ret; + } + index++; + } + } + return 0; +} + +static int pmbus_find_attributes(struct i2c_client *client, + struct pmbus_data *data) +{ + int ret; + + /* status attrs */ + ret = pmbus_add_status_attrs(client, data); + if (ret) + return ret; + + /* Voltage sensors */ + ret = pmbus_add_sensor_attrs(client, data, "in", voltage_attributes, + ARRAY_SIZE(voltage_attributes)); + if (ret) + return ret; + + /* Current sensors */ + ret = pmbus_add_sensor_attrs(client, data, "curr", current_attributes, + ARRAY_SIZE(current_attributes)); + if (ret) + return ret; + + /* Power sensors */ + ret = pmbus_add_sensor_attrs(client, data, "power", power_attributes, + ARRAY_SIZE(power_attributes)); + if (ret) + return ret; + + /* Temperature sensors */ + ret = pmbus_add_sensor_attrs(client, data, "temp", temp_attributes, + ARRAY_SIZE(temp_attributes)); + if (ret) + return ret; + + /* Fans */ + ret = pmbus_add_fan_attributes(client, data); + return ret; +} + +/* + * Identify chip parameters. + * This function is called for all chips. + */ +static int pmbus_identify_common(struct i2c_client *client, + struct pmbus_data *data, int page) +{ + int vout_mode = -1; + + if (rg_pmbus_check_byte_register(client, page, PMBUS_VOUT_MODE)) + vout_mode = _pmbus_read_byte_data(client, page, + PMBUS_VOUT_MODE); + if (vout_mode >= 0 && vout_mode != 0xff) { + /* + * Not all chips support the VOUT_MODE command, + * so a failure to read it is not an error. + */ + switch (vout_mode >> 5) { + case 0: /* linear mode */ + if (data->info->format[PSC_VOLTAGE_OUT] != linear) + return -ENODEV; + + data->exponent[page] = ((s8)(vout_mode << 3)) >> 3; + break; + case 1: /* VID mode */ + if (data->info->format[PSC_VOLTAGE_OUT] != vid) + return -ENODEV; + break; + case 2: /* direct mode */ + if (data->info->format[PSC_VOLTAGE_OUT] != direct) + return -ENODEV; + break; + default: + return -ENODEV; + } + } + + pmbus_clear_fault_page(client, page); + return 0; +} + +static int pmbus_read_status_byte(struct i2c_client *client, int page) +{ + return _pmbus_read_byte_data(client, page, PMBUS_STATUS_BYTE); +} + +static int pmbus_read_status_word(struct i2c_client *client, int page) +{ + return _pmbus_read_word_data(client, page, PMBUS_STATUS_WORD); +} + +static int pmbus_init_common(struct i2c_client *client, struct pmbus_data *data, + struct pmbus_driver_info *info) +{ + struct device *dev = &client->dev; + int page, ret, i; + + /* + * Some PMBus chips don't support PMBUS_STATUS_WORD, so try + * to use PMBUS_STATUS_BYTE instead if that is the case. + * Bail out if both registers are not supported. + */ + data->read_status = pmbus_read_status_word; + /* retry read PMBUS_STATUS_WORD */ + for(i = 0; i < PMBUS_RETRY_TIME; i++) { + ret = i2c_smbus_read_word_data(client, PMBUS_STATUS_WORD); + if (ret < 0 || ret == 0xffff) { + usleep_range(PMBUS_RETRY_SLEEP_TIME, PMBUS_RETRY_SLEEP_TIME + 1); + continue; + } + break; + } + + /* retry read PMBUS_STATUS_WORD fail, instead of retrying read PMBUS_STATUS_BYTE */ + if(i == PMBUS_RETRY_TIME) { + dev_info(dev, "pmbus read status word failed, next retry read status byte.\n"); + data->read_status = pmbus_read_status_byte; + for(i = 0; i < PMBUS_RETRY_TIME; i++) { + ret = i2c_smbus_read_byte_data(client, PMBUS_STATUS_BYTE); + if (ret < 0 || ret == 0xff) { + usleep_range(PMBUS_RETRY_SLEEP_TIME, PMBUS_RETRY_SLEEP_TIME + 1); + continue; + } + break; + } + } + + if(i == PMBUS_RETRY_TIME) { + dev_err(dev, "PMBus status register not found\n"); + return -ENODEV; + } + data->has_status_word = true; + + /* Enable PEC if the controller supports it */ + for(i = 0; i < PMBUS_RETRY_TIME; i++) { + ret = i2c_smbus_read_byte_data(client, PMBUS_CAPABILITY); + if(ret < 0) { + usleep_range(PMBUS_RETRY_SLEEP_TIME, PMBUS_RETRY_SLEEP_TIME + 1); + continue; + } else if (ret & PB_CAPABILITY_ERROR_CHECK) { + client->flags |= I2C_CLIENT_PEC; + } + break; + } + + if (data->info->pages) + rg_pmbus_clear_faults(client); + else + pmbus_clear_fault_page(client, -1); + + if (info->identify) { + ret = (*info->identify)(client, info); + if (ret < 0) { + dev_err(dev, "Chip identification failed\n"); + return ret; + } + } + + if (info->pages <= 0 || info->pages > PMBUS_PAGES) { + dev_err(dev, "Bad number of PMBus pages: %d\n", info->pages); + return -ENODEV; + } + + for (page = 0; page < info->pages; page++) { + ret = pmbus_identify_common(client, data, page); + if (ret < 0) { + dev_err(dev, "Failed to identify chip capabilities\n"); + return ret; + } + } + return 0; +} + +#if IS_ENABLED(CONFIG_REGULATOR) +static int pmbus_regulator_is_enabled(struct regulator_dev *rdev) +{ + struct device *dev = rdev_get_dev(rdev); + struct i2c_client *client = to_i2c_client(dev->parent); + u8 page = rdev_get_id(rdev); + int ret; + + ret = rg_pmbus_read_byte_data(client, page, PMBUS_OPERATION); + if (ret < 0) + return ret; + + return !!(ret & PB_OPERATION_CONTROL_ON); +} + +static int _pmbus_regulator_on_off(struct regulator_dev *rdev, bool enable) +{ + struct device *dev = rdev_get_dev(rdev); + struct i2c_client *client = to_i2c_client(dev->parent); + u8 page = rdev_get_id(rdev); + + return rg_pmbus_update_byte_data(client, page, PMBUS_OPERATION, + PB_OPERATION_CONTROL_ON, + enable ? PB_OPERATION_CONTROL_ON : 0); +} + +static int pmbus_regulator_enable(struct regulator_dev *rdev) +{ + return _pmbus_regulator_on_off(rdev, 1); +} + +static int pmbus_regulator_disable(struct regulator_dev *rdev) +{ + return _pmbus_regulator_on_off(rdev, 0); +} + +const struct regulator_ops rg_pmbus_regulator_ops = { + .enable = pmbus_regulator_enable, + .disable = pmbus_regulator_disable, + .is_enabled = pmbus_regulator_is_enabled, +}; +EXPORT_SYMBOL_GPL(rg_pmbus_regulator_ops); + +static int pmbus_regulator_register(struct pmbus_data *data) +{ + struct device *dev = data->dev; + const struct pmbus_driver_info *info = data->info; + const struct pmbus_platform_data *pdata = dev_get_platdata(dev); + struct regulator_dev *rdev; + int i; + + for (i = 0; i < info->num_regulators; i++) { + struct regulator_config config = { }; + + config.dev = dev; + config.driver_data = data; + + if (pdata && pdata->reg_init_data) + config.init_data = &pdata->reg_init_data[i]; + + rdev = devm_regulator_register(dev, &info->reg_desc[i], + &config); + if (IS_ERR(rdev)) { + dev_err(dev, "Failed to register %s regulator\n", + info->reg_desc[i].name); + return PTR_ERR(rdev); + } + } + + return 0; +} +#else +static int pmbus_regulator_register(struct pmbus_data *data) +{ + return 0; +} +#endif + +static struct dentry *pmbus_debugfs_dir; /* pmbus debugfs directory */ + +/* #if IS_ENABLED(CONFIG_DEBUG_FS) */ +#if 0 +static int pmbus_debugfs_get(void *data, u64 *val) +{ + int rc; + struct pmbus_debugfs_entry *entry = data; + + rc = _pmbus_read_byte_data(entry->client, entry->page, entry->reg); + if (rc < 0) + return rc; + + *val = rc; + + return 0; +} +DEFINE_DEBUGFS_ATTRIBUTE(pmbus_debugfs_ops, pmbus_debugfs_get, NULL, + "0x%02llx\n"); + +static int pmbus_debugfs_get_status(void *data, u64 *val) +{ + int rc; + struct pmbus_debugfs_entry *entry = data; + struct pmbus_data *pdata = i2c_get_clientdata(entry->client); + + rc = pdata->read_status(entry->client, entry->page); + if (rc < 0) + return rc; + + *val = rc; + + return 0; +} +DEFINE_DEBUGFS_ATTRIBUTE(pmbus_debugfs_ops_status, pmbus_debugfs_get_status, + NULL, "0x%04llx\n"); + +static int pmbus_init_debugfs(struct i2c_client *client, + struct pmbus_data *data) +{ + int i, idx = 0; + char name[PMBUS_NAME_SIZE]; + struct pmbus_debugfs_entry *entries; + + if (!pmbus_debugfs_dir) + return -ENODEV; + + /* + * Create the debugfs directory for this device. Use the hwmon device + * name to avoid conflicts (hwmon numbers are globally unique). + */ + data->debugfs = debugfs_create_dir(dev_name(data->hwmon_dev), + pmbus_debugfs_dir); + if (IS_ERR_OR_NULL(data->debugfs)) { + data->debugfs = NULL; + return -ENODEV; + } + + /* Allocate the max possible entries we need. */ + entries = devm_kcalloc(data->dev, + data->info->pages * 10, sizeof(*entries), + GFP_KERNEL); + if (!entries) + return -ENOMEM; + + for (i = 0; i < data->info->pages; ++i) { + /* Check accessibility of status register if it's not page 0 */ + if (!i || pmbus_check_status_register(client, i)) { + /* No need to set reg as we have special read op. */ + entries[idx].client = client; + entries[idx].page = i; + scnprintf(name, PMBUS_NAME_SIZE, "status%d", i); + debugfs_create_file(name, 0444, data->debugfs, + &entries[idx++], + &pmbus_debugfs_ops_status); + } + + if (data->info->func[i] & PMBUS_HAVE_STATUS_VOUT) { + entries[idx].client = client; + entries[idx].page = i; + entries[idx].reg = PMBUS_STATUS_VOUT; + scnprintf(name, PMBUS_NAME_SIZE, "status%d_vout", i); + debugfs_create_file(name, 0444, data->debugfs, + &entries[idx++], + &pmbus_debugfs_ops); + } + + if (data->info->func[i] & PMBUS_HAVE_STATUS_IOUT) { + entries[idx].client = client; + entries[idx].page = i; + entries[idx].reg = PMBUS_STATUS_IOUT; + scnprintf(name, PMBUS_NAME_SIZE, "status%d_iout", i); + debugfs_create_file(name, 0444, data->debugfs, + &entries[idx++], + &pmbus_debugfs_ops); + } + + if (data->info->func[i] & PMBUS_HAVE_STATUS_INPUT) { + entries[idx].client = client; + entries[idx].page = i; + entries[idx].reg = PMBUS_STATUS_INPUT; + scnprintf(name, PMBUS_NAME_SIZE, "status%d_input", i); + debugfs_create_file(name, 0444, data->debugfs, + &entries[idx++], + &pmbus_debugfs_ops); + } + + if (data->info->func[i] & PMBUS_HAVE_STATUS_TEMP) { + entries[idx].client = client; + entries[idx].page = i; + entries[idx].reg = PMBUS_STATUS_TEMPERATURE; + scnprintf(name, PMBUS_NAME_SIZE, "status%d_temp", i); + debugfs_create_file(name, 0444, data->debugfs, + &entries[idx++], + &pmbus_debugfs_ops); + } + + if (rg_pmbus_check_byte_register(client, i, PMBUS_STATUS_CML)) { + entries[idx].client = client; + entries[idx].page = i; + entries[idx].reg = PMBUS_STATUS_CML; + scnprintf(name, PMBUS_NAME_SIZE, "status%d_cml", i); + debugfs_create_file(name, 0444, data->debugfs, + &entries[idx++], + &pmbus_debugfs_ops); + } + + if (rg_pmbus_check_byte_register(client, i, PMBUS_STATUS_OTHER)) { + entries[idx].client = client; + entries[idx].page = i; + entries[idx].reg = PMBUS_STATUS_OTHER; + scnprintf(name, PMBUS_NAME_SIZE, "status%d_other", i); + debugfs_create_file(name, 0444, data->debugfs, + &entries[idx++], + &pmbus_debugfs_ops); + } + + if (rg_pmbus_check_byte_register(client, i, + PMBUS_STATUS_MFR_SPECIFIC)) { + entries[idx].client = client; + entries[idx].page = i; + entries[idx].reg = PMBUS_STATUS_MFR_SPECIFIC; + scnprintf(name, PMBUS_NAME_SIZE, "status%d_mfr", i); + debugfs_create_file(name, 0444, data->debugfs, + &entries[idx++], + &pmbus_debugfs_ops); + } + + if (data->info->func[i] & PMBUS_HAVE_STATUS_FAN12) { + entries[idx].client = client; + entries[idx].page = i; + entries[idx].reg = PMBUS_STATUS_FAN_12; + scnprintf(name, PMBUS_NAME_SIZE, "status%d_fan12", i); + debugfs_create_file(name, 0444, data->debugfs, + &entries[idx++], + &pmbus_debugfs_ops); + } + + if (data->info->func[i] & PMBUS_HAVE_STATUS_FAN34) { + entries[idx].client = client; + entries[idx].page = i; + entries[idx].reg = PMBUS_STATUS_FAN_34; + scnprintf(name, PMBUS_NAME_SIZE, "status%d_fan34", i); + debugfs_create_file(name, 0444, data->debugfs, + &entries[idx++], + &pmbus_debugfs_ops); + } + } + + return 0; +} +#else +static int pmbus_init_debugfs(struct i2c_client *client, + struct pmbus_data *data) +{ + return 0; +} +#endif /* IS_ENABLED(CONFIG_DEBUG_FS) */ + +int rg_pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id, + struct pmbus_driver_info *info) +{ + struct device *dev = &client->dev; + const struct pmbus_platform_data *pdata = dev_get_platdata(dev); + struct pmbus_data *data; + int ret; + + if (!info) + return -ENODEV; + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WRITE_BYTE + | I2C_FUNC_SMBUS_BYTE_DATA + | I2C_FUNC_SMBUS_WORD_DATA)) + return -ENODEV; + + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + data->dev = dev; + + if (pdata) + data->flags = pdata->flags; + data->info = info; + + ret = pmbus_init_common(client, data, info); + if (ret < 0) + return ret; + + ret = pmbus_find_attributes(client, data); + if (ret) + goto out_kfree; + + /* + * If there are no attributes, something is wrong. + * Bail out instead of trying to register nothing. + */ + if (!data->num_attributes) { + dev_err(dev, "No attributes found\n"); + ret = -ENODEV; + goto out_kfree; + } + + data->groups[0] = &data->group; + data->hwmon_dev = hwmon_device_register_with_groups(dev, client->name, + data, data->groups); + if (IS_ERR(data->hwmon_dev)) { + ret = PTR_ERR(data->hwmon_dev); + dev_err(dev, "Failed to register hwmon device\n"); + goto out_kfree; + } + + ret = pmbus_regulator_register(data); + if (ret) + goto out_unregister; + + ret = pmbus_init_debugfs(client, data); + if (ret) + dev_warn(dev, "Failed to register debugfs\n"); + + return 0; + +out_unregister: + hwmon_device_unregister(data->hwmon_dev); +out_kfree: + kfree(data->group.attrs); + return ret; +} +EXPORT_SYMBOL_GPL(rg_pmbus_do_probe); + +int rg_pmbus_do_remove(struct i2c_client *client) +{ + struct pmbus_data *data = i2c_get_clientdata(client); + + debugfs_remove_recursive(data->debugfs); + + hwmon_device_unregister(data->hwmon_dev); + kfree(data->group.attrs); + return 0; +} +EXPORT_SYMBOL_GPL(rg_pmbus_do_remove); + +struct dentry *rg_pmbus_get_debugfs_dir(struct i2c_client *client) +{ + struct pmbus_data *data = i2c_get_clientdata(client); + + return data->debugfs; +} +EXPORT_SYMBOL_GPL(rg_pmbus_get_debugfs_dir); + +static int __init pmbus_core_init(void) +{ + pmbus_debugfs_dir = debugfs_create_dir("pmbus", NULL); + if (IS_ERR(pmbus_debugfs_dir)) + pmbus_debugfs_dir = NULL; + + return 0; +} + +static void __exit pmbus_core_exit(void) +{ + debugfs_remove_recursive(pmbus_debugfs_dir); +} + +module_init(pmbus_core_init); +module_exit(pmbus_core_exit); + +MODULE_AUTHOR("Guenter Roeck"); +MODULE_DESCRIPTION("PMBus core driver"); +MODULE_LICENSE("GPL"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_spi_93xx46.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_spi_93xx46.c new file mode 100644 index 000000000000..d1e7ce6e84a2 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_spi_93xx46.c @@ -0,0 +1,111 @@ +/* + * EEPROMs access control driver for display configuration EEPROMs + * on DigsyMTC board. + * + * (C) 2011 DENX Software Engineering, Anatolij Gustschin + * + * 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 + +#define DEFAULT_SPI_BUS_NUM (0) +#define DEFAULT_SPI_CS_NUM (0) +#define DEFAULT_SPI_HZ (100000) + +#define GPIO_EEPROM_CS (-1) + +int g_rg_spi_93xx46_debug = 0; +int g_rg_spi_93xx46_error = 0; +int spi_bus_num = DEFAULT_SPI_BUS_NUM; +int spi_cs_gpio = GPIO_EEPROM_CS; + +module_param(g_rg_spi_93xx46_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_spi_93xx46_error, int, S_IRUGO | S_IWUSR); +module_param(spi_bus_num, int, S_IRUGO | S_IWUSR); +module_param(spi_cs_gpio, int, S_IRUGO | S_IWUSR); + +#define SPI_93xx46_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_rg_spi_93xx46_debug) { \ + printk(KERN_INFO "[SPI-93xx46][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define SPI_93xx46_DEBUG_ERROR(fmt, args...) do { \ + if (g_rg_spi_93xx46_error) { \ + printk(KERN_ERR "[SPI-93xx46][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +struct eeprom_93xx46_platform_data eeprom_data = { + .flags = EE_ADDR16, + .quirks = EEPROM_93XX46_QUIRK_SINGLE_WORD_READ, +}; + +struct spi_board_info eeprom_93xx46_info __initdata = { + .modalias = "rg_93xx46", + .max_speed_hz = DEFAULT_SPI_HZ, + .bus_num = DEFAULT_SPI_BUS_NUM, + .chip_select = DEFAULT_SPI_CS_NUM, + .mode = SPI_MODE_0 | SPI_CS_HIGH, + .controller_data = (void *)GPIO_EEPROM_CS, + .platform_data = &eeprom_data, +}; + +static struct spi_device *g_spi_device; + +static int __init rg_spi_93xx46_init(void) +{ + struct spi_master *master; + + SPI_93xx46_DEBUG_VERBOSE("Enter.\n"); + + eeprom_93xx46_info.bus_num = spi_bus_num; + eeprom_93xx46_info.controller_data = (void *)(long)spi_cs_gpio; + master = spi_busnum_to_master(eeprom_93xx46_info.bus_num); + if (!master) { + SPI_93xx46_DEBUG_ERROR("get bus_num %u spi master failed.\n", + eeprom_93xx46_info.bus_num); + return -EINVAL; + } + + g_spi_device = spi_new_device(master, &eeprom_93xx46_info); + put_device(&master->dev); + if (!g_spi_device) { + SPI_93xx46_DEBUG_ERROR("register spi new device failed.\n"); + return -EPERM; + } + + if (g_rg_spi_93xx46_debug) { + dev_info(&g_spi_device->dev, "register %u bus_num spi 93xx46 eeprom success\n", + eeprom_93xx46_info.bus_num); + } + + return 0; +} + +static void __exit rg_spi_93xx46_exit(void) +{ + spi_unregister_device(g_spi_device); + + if (g_rg_spi_93xx46_debug) { + dev_info(&g_spi_device->dev, "unregister spi 93xx46 eeprom success\n"); + } + + return; +} + +module_init(rg_spi_93xx46_init); +module_exit(rg_spi_93xx46_exit); + +MODULE_AUTHOR("sonic_rd "); +MODULE_DESCRIPTION("create 93xx46 eeprom device"); +MODULE_LICENSE("GPL"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_spi_gpio.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_spi_gpio.c new file mode 100644 index 000000000000..0deb57b06eb9 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_spi_gpio.c @@ -0,0 +1,477 @@ +/* + * SPI master driver using generic bitbanged GPIO + * + * Copyright (C) 2006,2008 David Brownell + * Copyright (C) 2017 Linus Walleij + * + * 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. + */ +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +/* + * This bitbanging SPI master driver should help make systems usable + * when a native hardware SPI engine is not available, perhaps because + * its driver isn't yet working or because the I/O pins it requires + * are used for other purposes. + * + * platform_device->driver_data ... points to spi_gpio + * + * spi->controller_state ... reserved for bitbang framework code + * spi->controller_data ... holds chipselect GPIO + * + * spi->master->dev.driver_data ... points to spi_gpio->bitbang + */ + +struct spi_gpio { + struct spi_bitbang bitbang; + struct spi_gpio_platform_data pdata; + struct platform_device *pdev; + struct gpio_desc *sck; + struct gpio_desc *miso; + struct gpio_desc *mosi; + struct gpio_desc **cs_gpios; + bool has_cs; +}; + +/*----------------------------------------------------------------------*/ + +/* + * Because the overhead of going through four GPIO procedure calls + * per transferred bit can make performance a problem, this code + * is set up so that you can use it in either of two ways: + * + * - The slow generic way: set up platform_data to hold the GPIO + * numbers used for MISO/MOSI/SCK, and issue procedure calls for + * each of them. This driver can handle several such busses. + * + * - The quicker inlined way: only helps with platform GPIO code + * that inlines operations for constant GPIOs. This can give + * you tight (fast!) inner loops, but each such bus needs a + * new driver. You'll define a new C file, with Makefile and + * Kconfig support; the C code can be a total of six lines: + * + * #define DRIVER_NAME "myboard_spi2" + * #define SPI_MISO_GPIO 119 + * #define SPI_MOSI_GPIO 120 + * #define SPI_SCK_GPIO 121 + * #define SPI_N_CHIPSEL 4 + * #include "spi-gpio.c" + */ + +#ifndef DRIVER_NAME +#define DRIVER_NAME "rg_spi_gpio" + +#define GENERIC_BITBANG /* vs tight inlines */ + +#endif + +/*----------------------------------------------------------------------*/ + +static inline struct spi_gpio *__pure +spi_to_spi_gpio(const struct spi_device *spi) +{ + const struct spi_bitbang *bang; + struct spi_gpio *spi_gpio; + + bang = spi_master_get_devdata(spi->master); + spi_gpio = container_of(bang, struct spi_gpio, bitbang); + return spi_gpio; +} + +static inline struct spi_gpio_platform_data *__pure +spi_to_pdata(const struct spi_device *spi) +{ + return &spi_to_spi_gpio(spi)->pdata; +} + +/* These helpers are in turn called by the bitbang inlines */ +static inline void setsck(const struct spi_device *spi, int is_on) +{ + struct spi_gpio *spi_gpio = spi_to_spi_gpio(spi); + + gpiod_set_value_cansleep(spi_gpio->sck, is_on); +} + +static inline void setmosi(const struct spi_device *spi, int is_on) +{ + struct spi_gpio *spi_gpio = spi_to_spi_gpio(spi); + + gpiod_set_value_cansleep(spi_gpio->mosi, is_on); +} + +static inline int getmiso(const struct spi_device *spi) +{ + struct spi_gpio *spi_gpio = spi_to_spi_gpio(spi); + + if (spi->mode & SPI_3WIRE) + return !!gpiod_get_value_cansleep(spi_gpio->mosi); + else + return !!gpiod_get_value_cansleep(spi_gpio->miso); +} + +/* + * NOTE: this clocks "as fast as we can". It "should" be a function of the + * requested device clock. Software overhead means we usually have trouble + * reaching even one Mbit/sec (except when we can inline bitops), so for now + * we'll just assume we never need additional per-bit slowdowns. + */ +#define spidelay(nsecs) do {} while (0) + +#include "spi-bitbang-txrx.h" + +/* + * These functions can leverage inline expansion of GPIO calls to shrink + * costs for a txrx bit, often by factors of around ten (by instruction + * count). That is particularly visible for larger word sizes, but helps + * even with default 8-bit words. + * + * REVISIT overheads calling these functions for each word also have + * significant performance costs. Having txrx_bufs() calls that inline + * the txrx_word() logic would help performance, e.g. on larger blocks + * used with flash storage or MMC/SD. There should also be ways to make + * GCC be less stupid about reloading registers inside the I/O loops, + * even without inlined GPIO calls; __attribute__((hot)) on GCC 4.3? + */ + +static u32 spi_gpio_txrx_word_mode0(struct spi_device *spi, + unsigned nsecs, u32 word, u8 bits, unsigned flags) +{ + return bitbang_txrx_be_cpha0(spi, nsecs, 0, flags, word, bits); +} + +static u32 spi_gpio_txrx_word_mode1(struct spi_device *spi, + unsigned nsecs, u32 word, u8 bits, unsigned flags) +{ + return bitbang_txrx_be_cpha1(spi, nsecs, 0, flags, word, bits); +} + +static u32 spi_gpio_txrx_word_mode2(struct spi_device *spi, + unsigned nsecs, u32 word, u8 bits, unsigned flags) +{ + return bitbang_txrx_be_cpha0(spi, nsecs, 1, flags, word, bits); +} + +static u32 spi_gpio_txrx_word_mode3(struct spi_device *spi, + unsigned nsecs, u32 word, u8 bits, unsigned flags) +{ + return bitbang_txrx_be_cpha1(spi, nsecs, 1, flags, word, bits); +} + +/* + * These functions do not call setmosi or getmiso if respective flag + * (SPI_MASTER_NO_RX or SPI_MASTER_NO_TX) is set, so they are safe to + * call when such pin is not present or defined in the controller. + * A separate set of callbacks is defined to get highest possible + * speed in the generic case (when both MISO and MOSI lines are + * available), as optimiser will remove the checks when argument is + * constant. + */ + +static u32 spi_gpio_spec_txrx_word_mode0(struct spi_device *spi, + unsigned nsecs, u32 word, u8 bits, unsigned flags) +{ + flags = spi->master->flags; + return bitbang_txrx_be_cpha0(spi, nsecs, 0, flags, word, bits); +} + +static u32 spi_gpio_spec_txrx_word_mode1(struct spi_device *spi, + unsigned nsecs, u32 word, u8 bits, unsigned flags) +{ + flags = spi->master->flags; + return bitbang_txrx_be_cpha1(spi, nsecs, 0, flags, word, bits); +} + +static u32 spi_gpio_spec_txrx_word_mode2(struct spi_device *spi, + unsigned nsecs, u32 word, u8 bits, unsigned flags) +{ + flags = spi->master->flags; + return bitbang_txrx_be_cpha0(spi, nsecs, 1, flags, word, bits); +} + +static u32 spi_gpio_spec_txrx_word_mode3(struct spi_device *spi, + unsigned nsecs, u32 word, u8 bits, unsigned flags) +{ + flags = spi->master->flags; + return bitbang_txrx_be_cpha1(spi, nsecs, 1, flags, word, bits); +} + +/*----------------------------------------------------------------------*/ + +static void spi_gpio_chipselect(struct spi_device *spi, int is_active) +{ + struct spi_gpio *spi_gpio = spi_to_spi_gpio(spi); + + /* set initial clock line level */ + if (is_active) + gpiod_set_value_cansleep(spi_gpio->sck, spi->mode & SPI_CPOL); + + /* Drive chip select line, if we have one */ + if (spi_gpio->has_cs) { + struct gpio_desc *cs = spi_gpio->cs_gpios[spi->chip_select]; + + /* SPI chip selects are normally active-low */ + gpiod_set_value_cansleep(cs, (spi->mode & SPI_CS_HIGH) ? is_active : !is_active); + } +} + +static int spi_gpio_setup(struct spi_device *spi) +{ + struct gpio_desc *cs; + int status = 0; + struct spi_gpio *spi_gpio = spi_to_spi_gpio(spi); + + /* + * The CS GPIOs have already been + * initialized from the descriptor lookup. + */ + cs = spi_gpio->cs_gpios[spi->chip_select]; + if (!spi->controller_state && cs) + status = gpiod_direction_output(cs, + !(spi->mode & SPI_CS_HIGH)); + + if (!status) + status = spi_bitbang_setup(spi); + + return status; +} + +static int spi_gpio_set_direction(struct spi_device *spi, bool output) +{ + struct spi_gpio *spi_gpio = spi_to_spi_gpio(spi); + + if (output) + return gpiod_direction_output(spi_gpio->mosi, 1); + else + return gpiod_direction_input(spi_gpio->mosi); +} + +static void spi_gpio_cleanup(struct spi_device *spi) +{ + spi_bitbang_cleanup(spi); +} + +/* + * It can be convenient to use this driver with pins that have alternate + * functions associated with a "native" SPI controller if a driver for that + * controller is not available, or is missing important functionality. + * + * On platforms which can do so, configure MISO with a weak pullup unless + * there's an external pullup on that signal. That saves power by avoiding + * floating signals. (A weak pulldown would save power too, but many + * drivers expect to see all-ones data as the no slave "response".) + */ +static int spi_gpio_request(struct device *dev, + struct spi_gpio *spi_gpio, + unsigned int num_chipselects, + u16 *mflags) +{ + int i; + + spi_gpio->mosi = devm_gpiod_get_optional(dev, "mosi", GPIOD_OUT_LOW); + if (IS_ERR(spi_gpio->mosi)) + return PTR_ERR(spi_gpio->mosi); + if (!spi_gpio->mosi) + /* HW configuration without MOSI pin */ + *mflags |= SPI_MASTER_NO_TX; + + spi_gpio->miso = devm_gpiod_get_optional(dev, "miso", GPIOD_IN); + if (IS_ERR(spi_gpio->miso)) + return PTR_ERR(spi_gpio->miso); + /* + * No setting SPI_MASTER_NO_RX here - if there is only a MOSI + * pin connected the host can still do RX by changing the + * direction of the line. + */ + + spi_gpio->sck = devm_gpiod_get(dev, "sck", GPIOD_OUT_LOW); + if (IS_ERR(spi_gpio->sck)) + return PTR_ERR(spi_gpio->sck); + + for (i = 0; i < num_chipselects; i++) { + spi_gpio->cs_gpios[i] = devm_gpiod_get_index(dev, "cs", + i, GPIOD_OUT_HIGH); + if (IS_ERR(spi_gpio->cs_gpios[i])) + return PTR_ERR(spi_gpio->cs_gpios[i]); + } + + return 0; +} + +#ifdef CONFIG_OF +static const struct of_device_id spi_gpio_dt_ids[] = { + { .compatible = "rg-spi-gpio" }, + {} +}; +MODULE_DEVICE_TABLE(of, spi_gpio_dt_ids); + +static int spi_gpio_probe_dt(struct platform_device *pdev) +{ + int ret; + u32 tmp; + struct spi_gpio_platform_data *pdata; + struct device_node *np = pdev->dev.of_node; + const struct of_device_id *of_id = + of_match_device(spi_gpio_dt_ids, &pdev->dev); + + if (!of_id) + return 0; + + pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + return -ENOMEM; + + ret = of_property_read_u32(np, "num-chipselects", &tmp); + if (ret < 0) { + dev_err(&pdev->dev, "num-chipselects property not found\n"); + goto error_free; + } + + pdata->num_chipselect = tmp; + pdev->dev.platform_data = pdata; + + return 1; + +error_free: + devm_kfree(&pdev->dev, pdata); + return ret; +} +#else +static inline int spi_gpio_probe_dt(struct platform_device *pdev) +{ + return 0; +} +#endif + +static int spi_gpio_probe(struct platform_device *pdev) +{ + int status; + struct spi_master *master; + struct spi_gpio *spi_gpio; + struct spi_gpio_platform_data *pdata; + u16 master_flags = 0; + bool use_of = 0; + + status = spi_gpio_probe_dt(pdev); + if (status < 0) + return status; + if (status > 0) + use_of = 1; + + pdata = dev_get_platdata(&pdev->dev); +#ifdef GENERIC_BITBANG + if (!pdata || (!use_of && !pdata->num_chipselect)) + return -ENODEV; +#endif + + master = spi_alloc_master(&pdev->dev, sizeof(*spi_gpio)); + if (!master) + return -ENOMEM; + + spi_gpio = spi_master_get_devdata(master); + + spi_gpio->cs_gpios = devm_kcalloc(&pdev->dev, + pdata->num_chipselect, + sizeof(*spi_gpio->cs_gpios), + GFP_KERNEL); + if (!spi_gpio->cs_gpios) + return -ENOMEM; + + platform_set_drvdata(pdev, spi_gpio); + + /* Determine if we have chip selects connected */ + spi_gpio->has_cs = !!pdata->num_chipselect; + + spi_gpio->pdev = pdev; + if (pdata) + spi_gpio->pdata = *pdata; + + status = spi_gpio_request(&pdev->dev, spi_gpio, + pdata->num_chipselect, &master_flags); + if (status) + return status; + + master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32); + master->mode_bits = SPI_3WIRE | SPI_CPHA | SPI_CPOL | SPI_CS_HIGH; + master->flags = master_flags; + master->bus_num = pdev->id; + /* The master needs to think there is a chipselect even if not connected */ + master->num_chipselect = spi_gpio->has_cs ? pdata->num_chipselect : 1; + master->setup = spi_gpio_setup; + master->cleanup = spi_gpio_cleanup; + + if (pdev->dev.of_node) { + master->dev.of_node = pdev->dev.of_node; + } + + spi_gpio->bitbang.master = master; + spi_gpio->bitbang.chipselect = spi_gpio_chipselect; + spi_gpio->bitbang.set_line_direction = spi_gpio_set_direction; + + if ((master_flags & SPI_MASTER_NO_TX) == 0) { + spi_gpio->bitbang.txrx_word[SPI_MODE_0] = spi_gpio_txrx_word_mode0; + spi_gpio->bitbang.txrx_word[SPI_MODE_1] = spi_gpio_txrx_word_mode1; + spi_gpio->bitbang.txrx_word[SPI_MODE_2] = spi_gpio_txrx_word_mode2; + spi_gpio->bitbang.txrx_word[SPI_MODE_3] = spi_gpio_txrx_word_mode3; + } else { + spi_gpio->bitbang.txrx_word[SPI_MODE_0] = spi_gpio_spec_txrx_word_mode0; + spi_gpio->bitbang.txrx_word[SPI_MODE_1] = spi_gpio_spec_txrx_word_mode1; + spi_gpio->bitbang.txrx_word[SPI_MODE_2] = spi_gpio_spec_txrx_word_mode2; + spi_gpio->bitbang.txrx_word[SPI_MODE_3] = spi_gpio_spec_txrx_word_mode3; + } + spi_gpio->bitbang.setup_transfer = spi_bitbang_setup_transfer; + + status = spi_bitbang_start(&spi_gpio->bitbang); + if (status) + spi_master_put(master); + + return status; +} + +static int spi_gpio_remove(struct platform_device *pdev) +{ + struct spi_gpio *spi_gpio; + struct spi_gpio_platform_data *pdata; + + spi_gpio = platform_get_drvdata(pdev); + pdata = dev_get_platdata(&pdev->dev); + + /* stop() unregisters child devices too */ + spi_bitbang_stop(&spi_gpio->bitbang); + + spi_master_put(spi_gpio->bitbang.master); + + return 0; +} + +MODULE_ALIAS("platform:" DRIVER_NAME); + +static struct platform_driver spi_gpio_driver = { + .driver = { + .name = DRIVER_NAME, + .of_match_table = of_match_ptr(spi_gpio_dt_ids), + }, + .probe = spi_gpio_probe, + .remove = spi_gpio_remove, +}; +module_platform_driver(spi_gpio_driver); + +MODULE_DESCRIPTION("SPI master driver using generic bitbanged GPIO "); +MODULE_AUTHOR("David Brownell"); +MODULE_LICENSE("GPL"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_spi_gpio_device.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_spi_gpio_device.c new file mode 100644 index 000000000000..0c5adfaa2f4e --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_spi_gpio_device.c @@ -0,0 +1,150 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#define DEFAULT_GPIO_SCK (67) +#define DEFAULT_GPIO_MISO (32) +#define DEFAULT_GPIO_MOSI (65) +#define DEFAULT_GPIO_CS (6) +#define DEFAULT_SPI_BUS (0) + +static int sck = DEFAULT_GPIO_SCK; +module_param(sck, int, S_IRUGO | S_IWUSR); + +static int miso = DEFAULT_GPIO_MISO; +module_param(miso, int, S_IRUGO | S_IWUSR); + +static int mosi = DEFAULT_GPIO_MOSI; +module_param(mosi, int, S_IRUGO | S_IWUSR); + +static int cs = DEFAULT_GPIO_CS; +module_param(cs, int, S_IRUGO | S_IWUSR); + +static int bus = DEFAULT_SPI_BUS; +module_param(bus, int, S_IRUGO | S_IWUSR); + +static int g_rg_spi_gpio_device_debug = 0; +static int g_rg_spi_gpio_device_error = 0; + +module_param(g_rg_spi_gpio_device_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_spi_gpio_device_error, int, S_IRUGO | S_IWUSR); + +static char gpiod_lookup_table_devid[64]; + +#define RG_SPI_GPIO_DEVICE_VERBOSE(fmt, args...) do { \ + if (g_rg_spi_gpio_device_debug) { \ + printk(KERN_INFO "[RG_SPI_GPIO_DEVICE][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RG_SPI_GPIO_DEVICE_ERROR(fmt, args...) do { \ + if (g_rg_spi_gpio_device_error) { \ + printk(KERN_ERR "[RG_SPI_GPIO_DEVICE][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static struct gpiod_lookup_table rg_spi_gpio_table = { + .table = { + GPIO_LOOKUP("rg_gpio_d1500", DEFAULT_GPIO_SCK, + "sck", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("rg_gpio_d1500", DEFAULT_GPIO_MOSI, + "mosi", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("rg_gpio_d1500", DEFAULT_GPIO_MISO, + "miso", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("rg_gpio_d1500", DEFAULT_GPIO_CS, + "cs", GPIO_ACTIVE_HIGH), + { }, + }, +}; + +static struct spi_gpio_platform_data spi_pdata = { + .num_chipselect = 1, +}; + +static void spi_gpio_release(struct device *dev) +{ + return; +} + +static struct platform_device rg_spi_gpio_device = { + .name = "rg_spi_gpio", + .num_resources = 0, + .id = -1, + + .dev = { + .platform_data = &spi_pdata, + .release = spi_gpio_release, + } +}; + +static void rg_spi_gpio_table_devid_name_set(void) { + int size; + + size = sizeof(gpiod_lookup_table_devid); + rg_spi_gpio_device.id = bus; + + memset(gpiod_lookup_table_devid, 0, size); + switch (bus) { + case PLATFORM_DEVID_NONE: + snprintf(gpiod_lookup_table_devid, size, "%s", rg_spi_gpio_device.name); + break; + case PLATFORM_DEVID_AUTO: + snprintf(gpiod_lookup_table_devid, size, "%s.%d.auto", rg_spi_gpio_device.name, bus); + break; + default: + snprintf(gpiod_lookup_table_devid, size, "%s.%d", rg_spi_gpio_device.name, bus); + break; + } + + rg_spi_gpio_table.dev_id = gpiod_lookup_table_devid; + return ; +} +static int __init rg_spi_gpio_device_init(void) +{ + int err; + struct gpiod_lookup *p; + + RG_SPI_GPIO_DEVICE_VERBOSE("enter!\n"); + rg_spi_gpio_table.table[0].chip_hwnum = sck; + rg_spi_gpio_table.table[1].chip_hwnum = mosi; + rg_spi_gpio_table.table[2].chip_hwnum = miso; + rg_spi_gpio_table.table[3].chip_hwnum = cs; + rg_spi_gpio_table_devid_name_set(); + RG_SPI_GPIO_DEVICE_VERBOSE("spi gpi device table bus[%d] dev id[%s]\n", bus, rg_spi_gpio_table.dev_id); + for (p = &rg_spi_gpio_table.table[0]; p->key; p++) { + RG_SPI_GPIO_DEVICE_VERBOSE("con_id:%s gpio:%d\n", p->con_id, p->chip_hwnum); + } + + gpiod_add_lookup_table(&rg_spi_gpio_table); + err = platform_device_register(&rg_spi_gpio_device); + if (err < 0) { + printk(KERN_ERR "register spi gpio device fail(%d). \n", err); + gpiod_remove_lookup_table(&rg_spi_gpio_table); + return -1; + } + + return 0; +} + +static void __exit rg_spi_gpio_device_exit(void) +{ + RG_SPI_GPIO_DEVICE_VERBOSE("enter!\n"); + platform_device_unregister(&rg_spi_gpio_device); + gpiod_remove_lookup_table(&rg_spi_gpio_table); +} + +module_init(rg_spi_gpio_device_init); +module_exit(rg_spi_gpio_device_exit); +MODULE_DESCRIPTION("SPI GPIO Devices"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd@ruijie.com.cn"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_tps53622.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_tps53622.c new file mode 100644 index 000000000000..8a14e3a8d114 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_tps53622.c @@ -0,0 +1,120 @@ +/* + * Hardware monitoring driver for Texas Instruments TPS53622 + * + * Copyright (c) 2017 Ruijie Networks. All rights reserved. + * + * 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. + */ + +#include +#include +#include +#include +#include +#include "rg_pmbus.h" + +#define TPS53622_PROT_VR12_5MV 0x01 /* VR12.0 mode, 5-mV DAC */ +#define TPS53622_PROT_VR12_5_10MV 0x02 /* VR12.5 mode, 10-mV DAC */ +#define TPS53622_PROT_VR13_10MV 0x04 /* VR13.0 mode, 10-mV DAC */ +#define TPS53622_PROT_IMVP8_5MV 0x05 /* IMVP8 mode, 5-mV DAC */ +#define TPS53622_PROT_VR13_5MV 0x07 /* VR13.0 mode, 5-mV DAC */ +#define TPS53622_PAGE_NUM 2 + +static int tps53622_identify(struct i2c_client *client, + struct pmbus_driver_info *info) +{ + u8 vout_params; + int ret, i; + + /* Read the register with VOUT scaling value.*/ + for (i = 0; i < TPS53622_PAGE_NUM; i++) { + ret = rg_pmbus_read_byte_data(client, i, PMBUS_VOUT_MODE); + if (ret < 0) + return ret; + + vout_params = ret & GENMASK(4, 0); + + switch (vout_params) { + case TPS53622_PROT_VR13_10MV: + case TPS53622_PROT_VR12_5_10MV: + info->vrm_version[i] = vr13; + break; + case TPS53622_PROT_VR13_5MV: + case TPS53622_PROT_VR12_5MV: + case TPS53622_PROT_IMVP8_5MV: + info->vrm_version[i] = vr12; + break; + default: + return -EINVAL; + } + } + + return 0; + +} + +static struct pmbus_driver_info tps53622_info = { + .pages = TPS53622_PAGE_NUM, + .format[PSC_VOLTAGE_IN] = linear, + .format[PSC_VOLTAGE_OUT] = vid, + .format[PSC_TEMPERATURE] = linear, + .format[PSC_CURRENT_OUT] = linear, + .format[PSC_POWER] = linear, + .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT | + PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | + PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP | + PMBUS_HAVE_POUT, + .func[1] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT | + PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | + PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP | + PMBUS_HAVE_POUT, + .identify = tps53622_identify, +}; + +static int tps53622_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct pmbus_driver_info *info; + + info = devm_kmemdup(&client->dev, &tps53622_info, sizeof(*info), GFP_KERNEL); + if (!info) + return -ENOMEM; + return rg_pmbus_do_probe(client, id, info); +} + +static const struct i2c_device_id tps53622_id[] = { + {"rg_tps53622", 0}, + {} +}; + +MODULE_DEVICE_TABLE(i2c, tps53622_id); + +static const struct of_device_id tps53622_of_match[] = { + {.compatible = "ruijie,rg_tps53622"}, + {} +}; +MODULE_DEVICE_TABLE(of, tps53622_of_match); + +static struct i2c_driver tps53622_driver = { + .driver = { + .name = "rg_tps53622", + .of_match_table = of_match_ptr(tps53622_of_match), + }, + .probe = tps53622_probe, + .remove = rg_pmbus_do_remove, + .id_table = tps53622_id, +}; + +module_i2c_driver(tps53622_driver); + +MODULE_AUTHOR("sonic_rd "); +MODULE_DESCRIPTION("PMBus driver for Texas Instruments TPS53622"); +MODULE_LICENSE("GPL"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_ucd9000.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_ucd9000.c new file mode 100644 index 000000000000..44821c5db7ba --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_ucd9000.c @@ -0,0 +1,294 @@ +/* + * Hardware monitoring driver for UCD90xxx Sequencer and System Health + * Controller series + * + * Copyright (C) 2011 Ericsson AB. + * + * 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 +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,19,152) +#include +#else +#include +#endif +#include +#include "rg_pmbus.h" + +enum chips { ucd9000, ucd90120, ucd90124, ucd90160, ucd9090, ucd90910 }; + +#define UCD9000_MONITOR_CONFIG 0xd5 +#define UCD9000_NUM_PAGES 0xd6 +#define UCD9000_FAN_CONFIG_INDEX 0xe7 +#define UCD9000_FAN_CONFIG 0xe8 +#define UCD9000_DEVICE_ID 0xfd + +#define UCD9000_MON_TYPE(x) (((x) >> 5) & 0x07) +#define UCD9000_MON_PAGE(x) ((x) & 0x0f) + +#define UCD9000_MON_VOLTAGE 1 +#define UCD9000_MON_TEMPERATURE 2 +#define UCD9000_MON_CURRENT 3 +#define UCD9000_MON_VOLTAGE_HW 4 + +#define UCD9000_NUM_FAN 4 +#define UCD9000_RETRY_SLEEP_TIME (10000) /* 10ms */ +#define UCD9000_RETRY_TIME (10) +#define RG_DEV_NAME_MAX_LEN (64) + +int g_rg_ucd9000_debug = 0; +int g_rg_ucd9000_error = 0; + +module_param(g_rg_ucd9000_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_ucd9000_error, int, S_IRUGO | S_IWUSR); + +#define RG_UDC9000_VERBOSE(fmt, args...) do { \ + if (g_rg_ucd9000_debug) { \ + printk(KERN_INFO "[RG_UCD9000][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RG_UDC9000_ERROR(fmt, args...) do { \ + if (g_rg_ucd9000_error) { \ + printk(KERN_ERR "[RG_UCD9000][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +struct ucd9000_data { + u8 fan_data[UCD9000_NUM_FAN][I2C_SMBUS_BLOCK_MAX]; + struct pmbus_driver_info info; +}; +#define to_ucd9000_data(_info) container_of(_info, struct ucd9000_data, info) + +static int rg_i2c_smbus_read_block_data(const struct i2c_client *client, u8 command, u8 *values) +{ + int rv, i; + for(i = 0; i < UCD9000_RETRY_TIME; i++) { + rv = i2c_smbus_read_block_data(client, command, values); + if(rv >= 0){ + return rv; + } + usleep_range(UCD9000_RETRY_SLEEP_TIME, UCD9000_RETRY_SLEEP_TIME + 1); + } + RG_UDC9000_ERROR("read_block_data failed. nr:%d, addr:0x%x, reg:0x%x, rv:%d.", + client->adapter->nr, client->addr, command, rv); + return rv; +} + +static int ucd9000_get_fan_config(struct i2c_client *client, int fan) +{ + int fan_config = 0; + struct ucd9000_data *data + = to_ucd9000_data(rg_pmbus_get_driver_info(client)); + + if (data->fan_data[fan][3] & 1) + fan_config |= PB_FAN_2_INSTALLED; /* Use lower bit position */ + + /* Pulses/revolution */ + fan_config |= (data->fan_data[fan][3] & 0x06) >> 1; + + return fan_config; +} + +static int ucd9000_read_byte_data(struct i2c_client *client, int page, int reg) +{ + int ret = 0; + int fan_config; + + switch (reg) { + case PMBUS_FAN_CONFIG_12: + if (page > 0) + return -ENXIO; + + ret = ucd9000_get_fan_config(client, 0); + if (ret < 0) + return ret; + fan_config = ret << 4; + ret = ucd9000_get_fan_config(client, 1); + if (ret < 0) + return ret; + fan_config |= ret; + ret = fan_config; + break; + case PMBUS_FAN_CONFIG_34: + if (page > 0) + return -ENXIO; + + ret = ucd9000_get_fan_config(client, 2); + if (ret < 0) + return ret; + fan_config = ret << 4; + ret = ucd9000_get_fan_config(client, 3); + if (ret < 0) + return ret; + fan_config |= ret; + ret = fan_config; + break; + default: + ret = -ENODATA; + break; + } + return ret; +} + +static const struct i2c_device_id ucd9000_id[] = { + {"rg_ucd9000", ucd9000}, + {"rg_ucd90120", ucd90120}, + {"rg_ucd90124", ucd90124}, + {"rg_ucd90160", ucd90160}, + {"rg_ucd9090", ucd9090}, + {"rg_ucd90910", ucd90910}, + {} +}; +MODULE_DEVICE_TABLE(i2c, ucd9000_id); + +static int ucd9000_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + u8 block_buffer[I2C_SMBUS_BLOCK_MAX + 1]; + u8 rg_device_name[RG_DEV_NAME_MAX_LEN]; + struct ucd9000_data *data; + struct pmbus_driver_info *info; + const struct i2c_device_id *mid; + int i, ret; + + if (!i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_BYTE_DATA | + I2C_FUNC_SMBUS_BLOCK_DATA)) + return -ENODEV; + + ret = rg_i2c_smbus_read_block_data(client, UCD9000_DEVICE_ID, + block_buffer); + if (ret < 0) { + dev_err(&client->dev, "Failed to read device ID\n"); + return ret; + } + block_buffer[ret] = '\0'; + dev_info(&client->dev, "Device ID %s\n", block_buffer); + + memset(rg_device_name, 0, sizeof(rg_device_name)); + snprintf(rg_device_name, sizeof(rg_device_name), "rg_%s", block_buffer); + + for (mid = ucd9000_id; mid->name[0]; mid++) { + if (!strncasecmp(mid->name, rg_device_name, strlen(mid->name))) + break; + } + if (!mid->name[0]) { + dev_err(&client->dev, "Unsupported device\n"); + return -ENODEV; + } + + if (id->driver_data != ucd9000 && id->driver_data != mid->driver_data) + dev_notice(&client->dev, + "Device mismatch: Configured %s, detected %s\n", + id->name, mid->name); + + data = devm_kzalloc(&client->dev, sizeof(struct ucd9000_data), + GFP_KERNEL); + if (!data) + return -ENOMEM; + info = &data->info; + + ret = i2c_smbus_read_byte_data(client, UCD9000_NUM_PAGES); + if (ret < 0) { + dev_err(&client->dev, + "Failed to read number of active pages\n"); + return ret; + } + info->pages = ret; + if (!info->pages) { + dev_err(&client->dev, "No pages configured\n"); + return -ENODEV; + } + + /* The internal temperature sensor is always active */ + + /* info->func[0] = PMBUS_HAVE_TEMP; */ + + /* Everything else is configurable */ + ret = rg_i2c_smbus_read_block_data(client, UCD9000_MONITOR_CONFIG, + block_buffer); + if (ret <= 0) { + dev_err(&client->dev, "Failed to read configuration data\n"); + return -ENODEV; + } + for (i = 0; i < ret; i++) { + int page = UCD9000_MON_PAGE(block_buffer[i]); + + if (page >= info->pages) + continue; + + switch (UCD9000_MON_TYPE(block_buffer[i])) { + case UCD9000_MON_VOLTAGE: + case UCD9000_MON_VOLTAGE_HW: + info->func[page] |= PMBUS_HAVE_VOUT + | PMBUS_HAVE_STATUS_VOUT; + break; + case UCD9000_MON_TEMPERATURE: + info->func[page] |= PMBUS_HAVE_TEMP2 + | PMBUS_HAVE_STATUS_TEMP; + break; + case UCD9000_MON_CURRENT: + info->func[page] |= PMBUS_HAVE_IOUT + | PMBUS_HAVE_STATUS_IOUT; + break; + default: + break; + } + } + + /* Fan configuration */ + if (mid->driver_data == ucd90124) { + for (i = 0; i < UCD9000_NUM_FAN; i++) { + i2c_smbus_write_byte_data(client, + UCD9000_FAN_CONFIG_INDEX, i); + ret = rg_i2c_smbus_read_block_data(client, + UCD9000_FAN_CONFIG, + data->fan_data[i]); + if (ret < 0) + return ret; + } + i2c_smbus_write_byte_data(client, UCD9000_FAN_CONFIG_INDEX, 0); + + info->read_byte_data = ucd9000_read_byte_data; + info->func[0] |= PMBUS_HAVE_FAN12 | PMBUS_HAVE_STATUS_FAN12 + | PMBUS_HAVE_FAN34 | PMBUS_HAVE_STATUS_FAN34; + } + + return rg_pmbus_do_probe(client, mid, info); +} + +/* This is the driver that will be inserted */ +static struct i2c_driver ucd9000_driver = { + .driver = { + .name = "rg_ucd9000", + }, + .probe = ucd9000_probe, + .remove = rg_pmbus_do_remove, + .id_table = ucd9000_id, +}; + +module_i2c_driver(ucd9000_driver); + +MODULE_AUTHOR("Guenter Roeck"); +MODULE_DESCRIPTION("PMBus driver for TI UCD90xxx"); +MODULE_LICENSE("GPL"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_wdt.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_wdt.c new file mode 100644 index 000000000000..5e00621a97d1 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_wdt.c @@ -0,0 +1,1041 @@ +/* + * Copyright(C) 2016 Ruijie Network. All rights reserved. + * + * rg_wdt.c + * ko for watchdog function + * Original Author: sonic_rd@ruijie.com.cn 2020-09-28 + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "rg_wdt.h" + +#define GPIO_FEED_WDT_MODE (1) +#define LOGIC_FEED_WDT_MODE (2) + +#define SYMBOL_I2C_DEV_MODE (1) +#define SYMBOL_PCIE_DEV_MODE (2) +#define SYMBOL_IO_DEV_MODE (3) +#define FILE_MODE (4) + +#define ONE_BYTE (1) + +#define WDT_OFF (0) +#define WDT_ON (1) + +#define MS_TO_S (1000) +#define MS_TO_NS (1000 * 1000) + +#define MAX_REG_VAL (255) + +extern int i2c_device_func_write(const char *path, uint32_t offset, uint8_t *buf, size_t count); +extern int i2c_device_func_read(const char *path, uint32_t offset, uint8_t *buf, size_t count); +extern int pcie_device_func_write(const char *path, uint32_t offset, uint8_t *buf, size_t count); +extern int pcie_device_func_read(const char *path, uint32_t offset, uint8_t *buf, size_t count); +extern int io_device_func_write(const char *path, uint32_t offset, uint8_t *buf, size_t count); +extern int io_device_func_read(const char *path, uint32_t offset, uint8_t *buf, size_t count); + +int g_rg_wdt_debug = 0; +int g_rg_wdt_error = 0; + +module_param(g_rg_wdt_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_wdt_error, int, S_IRUGO | S_IWUSR); + +#define WDT_VERBOSE(fmt, args...) do { \ + if (g_rg_wdt_debug) { \ + printk(KERN_INFO "[WDT][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define WDT_ERROR(fmt, args...) do { \ + if (g_rg_wdt_error) { \ + printk(KERN_ERR "[WDT][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +enum { + HW_ALGO_TOGGLE, + HW_ALGO_LEVEL, +}; + +enum { + WATCHDOG_DEVICE_TYPE = 0, + HRTIMER_TYPE, + THREAD_TYPE, +}; + +typedef struct rg_wdt_priv_s { + + struct task_struct *thread; + struct hrtimer hrtimer; + ktime_t m_kt; + const char *config_dev_name; + uint8_t config_mode; + uint8_t hw_algo; + uint8_t enable_val; + uint8_t disable_val; + uint8_t enable_mask; + uint8_t priv_func_mode; + uint8_t feed_wdt_type; + uint32_t enable_reg; + uint32_t timeout_cfg_reg; + uint32_t timeleft_cfg_reg; + uint32_t hw_margin; + uint32_t feed_time; + uint32_t timer_accuracy; + gpio_wdt_info_t gpio_wdt; + logic_wdt_info_t logic_wdt; + struct device *dev; + const struct attribute_group *sysfs_group; + uint8_t sysfs_index; + struct mutex update_lock; + struct watchdog_device wdd; +}rg_wdt_priv_t; + +static int wdt_file_read(const char *path, uint32_t pos, uint8_t *val, size_t size) +{ + int ret; + struct file *filp; + loff_t tmp_pos; + + filp = filp_open(path, O_RDONLY, 0); + if (IS_ERR(filp)) { + WDT_ERROR("read open failed errno = %ld\r\n", -PTR_ERR(filp)); + filp = NULL; + goto exit; + } + + tmp_pos = (loff_t)pos; + ret = kernel_read(filp, val, size, &tmp_pos); + if (ret < 0) { + WDT_ERROR("kernel_read failed, path=%s, addr=0x%x, size=%ld, ret=%d\r\n", path, pos, size, ret); + goto exit; + } + + filp_close(filp, NULL); + + return ret; + +exit: + if (filp != NULL) { + filp_close(filp, NULL); + } + + return -1; +} + +static int wdt_file_write(const char *path, uint32_t pos, uint8_t *val, size_t size) +{ + int ret; + struct file *filp; + loff_t tmp_pos; + + filp = filp_open(path, O_RDWR, 777); + if (IS_ERR(filp)) { + WDT_ERROR("write open failed errno = %ld\r\n", -PTR_ERR(filp)); + filp = NULL; + goto exit; + } + + tmp_pos = (loff_t)pos; + ret = kernel_write(filp, val, size, &tmp_pos); + if (ret < 0) { + WDT_ERROR("kernel_write failed, path=%s, addr=0x%x, size=%ld, ret=%d\r\n", path, pos, size, ret); + goto exit; + } + + vfs_fsync(filp, 1); + filp_close(filp, NULL); + + return ret; + +exit: + if (filp != NULL) { + filp_close(filp, NULL); + } + + return -1; +} + +static int rg_wdt_read(uint8_t mode, const char *path, + uint32_t offset, uint8_t *buf, size_t count) +{ + int ret; + + switch (mode) { + case SYMBOL_I2C_DEV_MODE: + ret = i2c_device_func_read(path, offset, buf, count); + break; + case SYMBOL_PCIE_DEV_MODE: + ret = pcie_device_func_read(path, offset, buf, count); + break; + case SYMBOL_IO_DEV_MODE: + ret = io_device_func_read(path, offset, buf, count); + break; + case FILE_MODE: + ret = wdt_file_read(path, offset, buf, count); + break; + default: + WDT_ERROR("mode %u error, wdt func read failed.\n", mode); + return -EINVAL; + } + + WDT_VERBOSE("wdt func read mode:%u,dev_nam:%s, offset:0x%x, read_val:0x%x, size:%lu.\n", + mode, path, offset, *buf, count); + + return ret; +} + +static int rg_wdt_write(uint8_t mode, const char *path, + uint32_t offset, uint8_t *buf, size_t count) +{ + int ret; + + switch (mode) { + case SYMBOL_I2C_DEV_MODE: + ret = i2c_device_func_write(path, offset, buf, count); + break; + case SYMBOL_PCIE_DEV_MODE: + ret = pcie_device_func_write(path, offset, buf, count); + break; + case SYMBOL_IO_DEV_MODE: + ret = io_device_func_write(path, offset, buf, count); + break; + case FILE_MODE: + ret = wdt_file_write(path, offset, buf, count); + break; + default: + WDT_ERROR("mode %u error, wdt func write failed.\n", mode); + return -EINVAL; + } + + WDT_VERBOSE("wdt func write mode:%u, dev_nam:%s, offset:0x%x, write_val:0x%x, size:%lu.\n", + mode, path, offset, *buf, count); + + return ret; +} + +static int rg_wdt_enable_ctrl(rg_wdt_priv_t *priv, uint8_t flag) +{ + int ret; + uint8_t val; + uint8_t ctrl_val; + + switch (flag) { + case WDT_ON: + ctrl_val = priv->enable_val; + break; + case WDT_OFF: + ctrl_val = priv->disable_val; + break; + default: + WDT_ERROR("unsupport wdt enable ctrl:%u.\n", flag); + return -EINVAL; + } + + ret = rg_wdt_read(priv->priv_func_mode, priv->config_dev_name, + priv->enable_reg, &val, ONE_BYTE); + if (ret < 0) { + dev_err(priv->dev, "read wdt control reg error.\n"); + return ret; + } + + val &= ~priv->enable_mask; + + val |= ctrl_val & priv->enable_mask; + + ret = rg_wdt_write(priv->priv_func_mode, priv->config_dev_name, + priv->enable_reg, &val, ONE_BYTE); + if (ret < 0) { + dev_err(priv->dev, "write wdt control reg error.\n"); + return ret; + } + + return 0; +} + +static void wdt_hwping(rg_wdt_priv_t *priv) +{ + gpio_wdt_info_t *gpio_wdt; + logic_wdt_info_t *logic_wdt; + uint8_t tmp_val; + int ret; + + if (priv->config_mode == GPIO_FEED_WDT_MODE) { + gpio_wdt = &priv->gpio_wdt; + switch (priv->hw_algo) { + case HW_ALGO_TOGGLE: + gpio_wdt = &priv->gpio_wdt; + gpio_wdt->state = !gpio_wdt->state; + gpio_set_value_cansleep(gpio_wdt->gpio, gpio_wdt->state); + WDT_VERBOSE("gpio toggle wdt work. val:%u\n", gpio_wdt->state); + break; + case HW_ALGO_LEVEL: + gpio_wdt = &priv->gpio_wdt; + /* Pulse */ + gpio_set_value_cansleep(gpio_wdt->gpio, !gpio_wdt->active_low); + udelay(1); + gpio_set_value_cansleep(gpio_wdt->gpio, gpio_wdt->active_low); + WDT_VERBOSE("gpio level wdt work.\n"); + break; + } + } else { + logic_wdt = &priv->logic_wdt; + switch (priv->hw_algo) { + case HW_ALGO_TOGGLE: + logic_wdt->active_val = !logic_wdt->active_val; + ret = rg_wdt_write(logic_wdt->logic_func_mode, logic_wdt->feed_dev_name, + logic_wdt->feed_reg, &logic_wdt->active_val, ONE_BYTE); + if (ret < 0) { + WDT_ERROR("logic toggle wdt write failed.ret = %d\n", ret); + } + WDT_VERBOSE("logic toggle wdt work.\n"); + break; + case HW_ALGO_LEVEL: + tmp_val = !logic_wdt->active_val; + ret = rg_wdt_write(logic_wdt->logic_func_mode, logic_wdt->feed_dev_name, + logic_wdt->feed_reg, &tmp_val, ONE_BYTE); + if (ret < 0) { + WDT_ERROR("logic level wdt write first failed.ret = %d\n", ret); + } + udelay(1); + ret = rg_wdt_write(logic_wdt->logic_func_mode, logic_wdt->feed_dev_name, + logic_wdt->feed_reg, &logic_wdt->active_val, ONE_BYTE); + if (ret < 0) { + WDT_ERROR("logic level wdt write second failed.ret = %d\n", ret); + } + WDT_VERBOSE("logic level wdt work.\n"); + break; + } + } + return; +} + +static enum hrtimer_restart hrtimer_hwping(struct hrtimer *timer) +{ + rg_wdt_priv_t *priv = container_of(timer, rg_wdt_priv_t, hrtimer); + + wdt_hwping(priv); + hrtimer_forward(timer, timer->base->get_time(), priv->m_kt); + return HRTIMER_RESTART; +} + +static int thread_timer_cfg(rg_wdt_priv_t *priv, rg_wdt_device_t *rg_wdt_device) +{ + struct device *dev; + uint32_t hw_margin; + uint32_t feed_time; + uint32_t accuracy; + uint8_t set_time_val; + int ret; + + dev = priv->dev; + + ret = 0; + if (dev->of_node) { + ret += of_property_read_u32(dev->of_node, "feed_time", &priv->feed_time); + if (ret != 0) { + dev_err(dev, "thread Failed to priv dts.\n"); + return -ENXIO; + } + } else { + priv->feed_time = rg_wdt_device->feed_time; + } + WDT_VERBOSE("thread priv->feed_time: %u.\n", priv->feed_time); + + hw_margin = priv->hw_margin; + feed_time = priv->feed_time; + accuracy = priv->timer_accuracy; + + if ((feed_time > (hw_margin / 2)) || (feed_time == 0)) { + dev_err(dev, "thread timer feed_time[%d] should be less than half hw_margin or zero.\n", feed_time); + return -EINVAL; + } + + set_time_val = hw_margin / accuracy; + ret = rg_wdt_write(priv->priv_func_mode, priv->config_dev_name, + priv->timeout_cfg_reg, &set_time_val, ONE_BYTE); + if (ret < 0) { + dev_err(dev, "set wdt thread timer reg error.\n"); + return ret; + } + return 0; +} + +static int wdt_thread_timer(void *data) +{ + rg_wdt_priv_t *priv = data; + + while (!kthread_should_stop()) { + schedule_timeout_uninterruptible(msecs_to_jiffies(priv->feed_time)); + wdt_hwping(priv); + } + return 0; +} + +static int thread_timer_create(rg_wdt_priv_t *priv, rg_wdt_device_t *rg_wdt_device) +{ + struct task_struct *p; + int ret; + + ret = thread_timer_cfg(priv, rg_wdt_device); + if (ret < 0) { + dev_err(priv->dev, "set wdt thread timer failed.\n"); + return ret; + } + + p = kthread_create(wdt_thread_timer, (void *)priv, "%s", "rg_wdt"); + if (!IS_ERR(p)) { + WDT_VERBOSE("timer thread create success.\n"); + priv->thread = p; + wake_up_process(p); + } else { + dev_err(priv->dev, "timer thread create failed.\n"); + return -ENXIO; + } + + ret = rg_wdt_enable_ctrl(priv, WDT_ON); + if (ret < 0) { + dev_err(priv->dev, "thread enable wdt failed.\n"); + return -ENXIO; + } + + return 0; +} + +static int hrtimer_cfg(rg_wdt_priv_t *priv, rg_wdt_device_t *rg_wdt_device) +{ + struct device *dev; + struct hrtimer *hrtimer; + uint8_t set_time_val; + uint8_t hrtimer_s; + uint32_t hrtimer_ns; + int ret; + uint32_t hw_margin; + uint32_t feed_time; + uint32_t accuracy; + uint32_t max_timeout; + + dev = priv->dev; + + ret = 0; + if (dev->of_node) { + ret += of_property_read_u32(dev->of_node, "feed_time", &priv->feed_time); + if (ret != 0) { + dev_err(dev, "hrtimer Failed to priv dts.\n"); + return -ENXIO; + } + } else { + priv->feed_time = rg_wdt_device->feed_time; + } + WDT_VERBOSE("hrtimer priv->feed_time: %u.\n", priv->feed_time); + + hrtimer = &priv->hrtimer; + hw_margin = priv->hw_margin; + feed_time = priv->feed_time; + accuracy = priv->timer_accuracy; + max_timeout = accuracy * 255; + + if (hw_margin < accuracy || hw_margin > max_timeout) { + dev_err(dev, "hrtimer_hw_margin should be between %u and %u.\n", + accuracy, max_timeout); + return -EINVAL; + } + if ((feed_time > (hw_margin / 2)) || (feed_time == 0)) { + dev_err(dev, "feed_time[%d] should be less than half hw_margin or zeor.\n", feed_time); + return -EINVAL; + } + + hrtimer_s = feed_time / MS_TO_S; + hrtimer_ns = (feed_time % MS_TO_S) * MS_TO_NS; + set_time_val = hw_margin / accuracy; + + ret = rg_wdt_write(priv->priv_func_mode, priv->config_dev_name, + priv->timeout_cfg_reg, &set_time_val, ONE_BYTE); + if (ret < 0) { + dev_err(dev, "set wdt time reg error.\n"); + return ret; + } + + priv->m_kt = ktime_set(hrtimer_s, hrtimer_ns); + hrtimer_init(hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); + hrtimer->function = hrtimer_hwping; + hrtimer_start(hrtimer, priv->m_kt, HRTIMER_MODE_REL); + + ret = rg_wdt_enable_ctrl(priv, WDT_ON); + if (ret < 0) { + dev_err(dev, "hrtimer enable wdt failed.\n"); + return -ENXIO; + } + + return 0; +} + +static int rg_wdt_ping(struct watchdog_device *wdd) +{ + rg_wdt_priv_t *priv = watchdog_get_drvdata(wdd); + + wdt_hwping(priv); + return 0; +} + +static int rg_wdt_start(struct watchdog_device *wdd) +{ + rg_wdt_priv_t *priv = watchdog_get_drvdata(wdd); + int ret; + + ret = rg_wdt_enable_ctrl(priv, WDT_ON); + if (ret < 0) { + WDT_ERROR("start wdt enable failed.\n"); + return -ENXIO; + } + set_bit(WDOG_HW_RUNNING, &wdd->status); + return 0; +} + +static int rg_wdt_stop(struct watchdog_device *wdd) +{ + rg_wdt_priv_t *priv = watchdog_get_drvdata(wdd); + int ret; + + ret = rg_wdt_enable_ctrl(priv, WDT_OFF); + if (ret < 0) { + WDT_ERROR("stop wdt enable failed.\n"); + return -ENXIO; + } + clear_bit(WDOG_HW_RUNNING, &wdd->status); + return 0; +} + +static int rg_wdt_set_timeout(struct watchdog_device *wdd, unsigned int t) +{ + rg_wdt_priv_t *priv = watchdog_get_drvdata(wdd); + uint32_t timeout_ms; + uint32_t accuracy; + uint8_t set_time_val; + int ret; + + accuracy = priv->timer_accuracy; + timeout_ms = t * 1000; + if (timeout_ms > accuracy * 255) { + WDT_ERROR("set wdt timeout too larger error.timeout_ms:%u\n", timeout_ms); + return -EINVAL; + } + + set_time_val = timeout_ms / accuracy; + ret = rg_wdt_write(priv->priv_func_mode, priv->config_dev_name, + priv->timeout_cfg_reg, &set_time_val, ONE_BYTE); + if (ret < 0) { + WDT_ERROR("set wdt timeout reg error, set_time_val:%u ret:%d\n", set_time_val, ret); + return ret; + } + wdd->timeout = t; + + return 0; +} + +static unsigned int rg_wdt_get_timeleft(struct watchdog_device *wdd) +{ + rg_wdt_priv_t *priv = watchdog_get_drvdata(wdd); + unsigned int time_left; + uint32_t accuracy; + uint8_t get_time_val; + int ret; + + accuracy = priv->timer_accuracy; + + ret = rg_wdt_read(priv->priv_func_mode, priv->config_dev_name, + priv->timeleft_cfg_reg, &get_time_val, ONE_BYTE); + if (ret < 0) { + WDT_ERROR("get wdt timeout reg error.ret:%d\n", ret); + return ret; + } + time_left = get_time_val * accuracy / MS_TO_S; + + WDT_VERBOSE("get wdt timeleft %d get_time_val %d accuracy=%d\n", + time_left, get_time_val, accuracy); + return time_left; +} + +static const struct watchdog_info rg_wdt_ident = { + .options = WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT, + .firmware_version = 0, + .identity = "CPLD Watchdog", +}; + +static const struct watchdog_ops rg_wdt_ops = { + .owner = THIS_MODULE, + .start = rg_wdt_start, + .stop = rg_wdt_stop, + .ping = rg_wdt_ping, + .set_timeout = rg_wdt_set_timeout, + .get_timeleft = rg_wdt_get_timeleft, +}; + +static int watchdog_device_cfg(rg_wdt_priv_t *priv) +{ + int ret; + uint8_t set_time_val; + + ret = rg_wdt_enable_ctrl(priv, WDT_OFF); + if (ret < 0) { + dev_err(priv->dev, "probe disable wdt failed.\n"); + return -ENXIO; + } + + set_time_val = priv->hw_margin / priv->timer_accuracy; + ret = rg_wdt_write(priv->priv_func_mode, priv->config_dev_name, + priv->timeout_cfg_reg, &set_time_val, ONE_BYTE); + if (ret < 0) { + dev_err(priv->dev, "set wdt time reg error.\n"); + return ret; + } + + watchdog_set_drvdata(&priv->wdd, priv); + + priv->wdd.info = &rg_wdt_ident; + priv->wdd.ops = &rg_wdt_ops; + priv->wdd.bootstatus = 0; + priv->wdd.timeout = priv->hw_margin / MS_TO_S; + priv->wdd.min_timeout = priv->timer_accuracy / MS_TO_S; + priv->wdd.max_timeout = priv->timer_accuracy * MAX_REG_VAL / MS_TO_S; + priv->wdd.parent = priv->dev; + + watchdog_stop_on_reboot(&priv->wdd); + + ret = devm_watchdog_register_device(priv->dev, &priv->wdd); + if (ret != 0) { + dev_err(priv->dev, "cannot register watchdog device (err=%d)\n", ret); + return -ENXIO; + } + + return 0; +} + +static int logic_wdt_init(rg_wdt_priv_t *priv, rg_wdt_device_t *rg_wdt_device) +{ + struct device *dev; + logic_wdt_info_t *logic_wdt; + int ret; + + dev = priv->dev; + logic_wdt = &priv->logic_wdt; + + ret = 0; + if (dev->of_node) { + ret += of_property_read_string(dev->of_node, "feed_dev_name", &logic_wdt->feed_dev_name); + ret += of_property_read_u32(dev->of_node, "feed_reg", &logic_wdt->feed_reg); + ret += of_property_read_u8(dev->of_node, "active_val", &logic_wdt->active_val); + ret += of_property_read_u8(dev->of_node, "logic_func_mode", &logic_wdt->logic_func_mode); + if (ret != 0) { + dev_err(dev, "Failed to logic_wdt dts.\n"); + return -ENXIO; + } + } else { + logic_wdt->feed_dev_name = rg_wdt_device->wdt_config_mode.logic_wdt.feed_dev_name; + logic_wdt->feed_reg = rg_wdt_device->wdt_config_mode.logic_wdt.feed_reg; + logic_wdt->active_val = rg_wdt_device->wdt_config_mode.logic_wdt.active_val; + logic_wdt->logic_func_mode = rg_wdt_device->wdt_config_mode.logic_wdt.logic_func_mode; + } + + logic_wdt->state_val = logic_wdt->active_val; + + WDT_VERBOSE("feed_dev_name:%s, feed_reg:0x%x, active_val:%u, logic_func_mode:%u\n", + logic_wdt->feed_dev_name, logic_wdt->feed_reg, + logic_wdt->active_val, logic_wdt->logic_func_mode); + + return 0; +} + +static int gpio_wdt_init(rg_wdt_priv_t *priv, rg_wdt_device_t *rg_wdt_device) +{ + struct device *dev; + gpio_wdt_info_t *gpio_wdt; + enum of_gpio_flags flags; + uint32_t f = 0; + int ret; + + dev = priv->dev; + gpio_wdt = &priv->gpio_wdt; + + if (dev->of_node) { + gpio_wdt->gpio = of_get_gpio_flags(dev->of_node, 0, &flags); + } else { + gpio_wdt->gpio = rg_wdt_device->wdt_config_mode.gpio_wdt.gpio; + flags = rg_wdt_device->wdt_config_mode.gpio_wdt.flags; + } + if (!gpio_is_valid(gpio_wdt->gpio)) { + dev_err(dev, "gpio is invalid.\n"); + return gpio_wdt->gpio; + } + + gpio_wdt->active_low = flags & OF_GPIO_ACTIVE_LOW; + + if(priv->hw_algo == HW_ALGO_TOGGLE) { + f = GPIOF_IN; + } else { + f = gpio_wdt->active_low ? GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW; + } + + ret = devm_gpio_request_one(dev, gpio_wdt->gpio, f, + dev_name(dev)); + if (ret) { + dev_err(dev, "devm_gpio_request_one failed.\n"); + return ret; + } + + gpio_wdt->state = gpio_wdt->active_low; + gpio_direction_output(gpio_wdt->gpio, gpio_wdt->state); + + WDT_VERBOSE("active_low:%d\n", gpio_wdt->active_low); + return 0; +} + +static ssize_t set_wdt_sysfs_value(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + rg_wdt_priv_t *priv = dev_get_drvdata(dev); + int ret, val; + + val = 0; + sscanf(buf, "%d", &val); + WDT_VERBOSE("set wdt, val:%d.\n", val); + + if (val < 0 || val > 255) { + WDT_ERROR("set wdt val %d failed.\n", val); + return -EINVAL; + } + + mutex_lock(&priv->update_lock); + + ret = rg_wdt_enable_ctrl(priv, val); + if (ret < 0) { + WDT_ERROR("set wdt sysfs value:%u failed.\n", val); + goto fail; + } + + WDT_VERBOSE("set wdt sysfs value:%u successed.\n", val); + mutex_unlock(&priv->update_lock); + return count; + +fail: + mutex_unlock(&priv->update_lock); + return ret; +} + +static ssize_t show_wdt_sysfs_value(struct device *dev, + struct device_attribute *da, char *buf) +{ + rg_wdt_priv_t *priv = dev_get_drvdata(dev); + uint8_t val, status; + int ret; + + mutex_lock(&priv->update_lock); + + ret = rg_wdt_read(priv->priv_func_mode, priv->config_dev_name, + priv->enable_reg, &val, ONE_BYTE); + if (ret < 0) { + dev_err(priv->dev, "read wdt enable reg val error.\n"); + goto fail; + } + + val &= priv->enable_mask; + if (val == priv->enable_val) { + status = WDT_ON; + } else if(val == priv->disable_val) { + status = WDT_OFF; + } else { + WDT_ERROR("enable reg read val not match set val, read val:%u, mask:%u, enable_val:%u, disable_val:%u", + val, priv->enable_mask, priv->enable_val, priv->disable_val); + ret = -EIO; + goto fail; + } + + WDT_VERBOSE("read_val:%u, mask:%u, enable_val:%u, disable_val:%u, status:%u", + val, priv->enable_mask, priv->enable_val, priv->disable_val, status); + + mutex_unlock(&priv->update_lock); + return sprintf(buf, "%u\n", status); + +fail: + mutex_unlock(&priv->update_lock); + return ret; +} + +static SENSOR_DEVICE_ATTR(wdt_status, S_IRUGO | S_IWUSR, show_wdt_sysfs_value, set_wdt_sysfs_value, 0); + +static struct attribute *wdt_sysfs_attrs[] = { + &sensor_dev_attr_wdt_status.dev_attr.attr, + NULL +}; + +static const struct attribute_group wdt_sysfs_group = { + .attrs = wdt_sysfs_attrs, +}; + +struct wdt_attr_match_group { + uint8_t index; + const struct attribute_group *attr_group_ptr; +}; + +static struct wdt_attr_match_group g_wdt_attr_match[] = { + {0, &wdt_sysfs_group}, +}; + +static const struct attribute_group *wdt_get_attr_group(uint32_t index) +{ + int i; + struct wdt_attr_match_group *group; + + for (i = 0; i < ARRAY_SIZE(g_wdt_attr_match); i++) { + group = &g_wdt_attr_match[i]; + if (index == group->index) { + WDT_VERBOSE("get wdt attr, index:%u.\n", index); + return group->attr_group_ptr; + } + } + + return NULL; +} + +static int rg_wdt_probe(struct platform_device *pdev) +{ + rg_wdt_priv_t *priv; + int ret; + const char *algo; + rg_wdt_device_t *rg_wdt_device; + + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); + if (!priv) { + dev_err(&pdev->dev, "devm_kzalloc failed.\n"); + return -ENOMEM; + } + + platform_set_drvdata(pdev, priv); + + if (pdev->dev.of_node) { + ret = 0; + ret += of_property_read_string(pdev->dev.of_node, "config_dev_name", &priv->config_dev_name); + ret += of_property_read_string(pdev->dev.of_node, "hw_algo", &algo); + ret += of_property_read_u8(pdev->dev.of_node, "config_mode", &priv->config_mode); + ret += of_property_read_u8(pdev->dev.of_node, "priv_func_mode", &priv->priv_func_mode); + ret += of_property_read_u8(pdev->dev.of_node, "enable_val", &priv->enable_val); + ret += of_property_read_u8(pdev->dev.of_node, "disable_val", &priv->disable_val); + ret += of_property_read_u8(pdev->dev.of_node, "enable_mask", &priv->enable_mask); + ret += of_property_read_u32(pdev->dev.of_node, "enable_reg", &priv->enable_reg); + ret += of_property_read_u32(pdev->dev.of_node, "timeout_cfg_reg", &priv->timeout_cfg_reg); + ret += of_property_read_u32(pdev->dev.of_node,"hw_margin_ms", &priv->hw_margin); + ret += of_property_read_u8(pdev->dev.of_node,"feed_wdt_type", &priv->feed_wdt_type); + ret += of_property_read_u32(pdev->dev.of_node,"timer_accuracy", &priv->timer_accuracy); + if (ret != 0) { + dev_err(&pdev->dev, "Failed to priv dts.\n"); + return -ENXIO; + } + + priv->sysfs_index = SYSFS_NO_CFG; + of_property_read_u8(pdev->dev.of_node,"sysfs_index", &priv->sysfs_index); + + priv->timeleft_cfg_reg = priv->timeout_cfg_reg; + of_property_read_u32(pdev->dev.of_node,"timeleft_cfg_reg", &priv->timeleft_cfg_reg); + } else { + if (pdev->dev.platform_data == NULL) { + dev_err(&pdev->dev, "Failed to get platform data config.\n"); + return -ENXIO; + } + rg_wdt_device = pdev->dev.platform_data; + priv->config_dev_name = rg_wdt_device->config_dev_name; + algo = rg_wdt_device->hw_algo; + priv->config_mode = rg_wdt_device->config_mode; + priv->priv_func_mode = rg_wdt_device->priv_func_mode; + priv->enable_val = rg_wdt_device->enable_val; + priv->disable_val = rg_wdt_device->disable_val; + priv->enable_mask = rg_wdt_device->enable_mask; + priv->enable_reg = rg_wdt_device->enable_reg; + priv->timeout_cfg_reg = rg_wdt_device->timeout_cfg_reg; + priv->hw_margin = rg_wdt_device->hw_margin; + priv->timer_accuracy = rg_wdt_device->timer_accuracy; + priv->feed_wdt_type = rg_wdt_device->feed_wdt_type; + priv->sysfs_index = rg_wdt_device->sysfs_index; + priv->timeleft_cfg_reg = rg_wdt_device->timeleft_cfg_reg; + } + + if (!strcmp(algo, "toggle")) { + priv->hw_algo = HW_ALGO_TOGGLE; + } else if (!strcmp(algo, "level")) { + priv->hw_algo = HW_ALGO_LEVEL; + } else { + dev_err(&pdev->dev, "hw_algo config error.must be toggle or level.\n"); + return -EINVAL; + } + + WDT_VERBOSE("config_dev_name:%s, config_mode:%u, priv_func_mode:%u, enable_reg:0x%x, timeout_cfg_reg:0x%x\n", + priv->config_dev_name, priv->config_mode, priv->priv_func_mode, priv->enable_reg, priv->timeout_cfg_reg); + WDT_VERBOSE("timeout_cfg_reg:0x%x, enable_val:%u, disable_val:%u, enable_mask:%u, hw_margin:%u, feed_wdt_type:%u\n", + priv->timeleft_cfg_reg, priv->enable_val, priv->disable_val, priv->enable_mask, priv->hw_margin, priv->feed_wdt_type); + + priv->dev = &pdev->dev; + if (priv->config_mode == GPIO_FEED_WDT_MODE) { + ret = gpio_wdt_init(priv, rg_wdt_device); + if (ret < 0) { + dev_err(&pdev->dev, "init gpio mode wdt failed.\n"); + return -ENXIO; + } + } else if (priv->config_mode == LOGIC_FEED_WDT_MODE) { + ret = logic_wdt_init(priv, rg_wdt_device); + if (ret < 0) { + dev_err(&pdev->dev, "init func mode wdt failed.\n"); + return -ENXIO; + } + } else { + dev_err(&pdev->dev, "unsupport %u config_mode, dts configure error.\n", + priv->config_mode); + return -ENXIO; + } + + switch (priv->feed_wdt_type) { + case WATCHDOG_DEVICE_TYPE: + ret = watchdog_device_cfg(priv); + break; + case HRTIMER_TYPE: + ret = hrtimer_cfg(priv, rg_wdt_device); + break; + case THREAD_TYPE: + ret = thread_timer_create(priv, rg_wdt_device); + break; + default: + dev_err(&pdev->dev, "timer type %u unsupport.\n", priv->feed_wdt_type); + return -EINVAL; + } + if (ret < 0) { + dev_err(&pdev->dev, "init timer feed_wdt_type %u failed.\n", priv->feed_wdt_type); + return -ENXIO; + } + + dev_info(&pdev->dev, "register %s mode, config_mode %u, func_mode %u, %u ms overtime wdt success\n", + algo, priv->config_mode, priv->priv_func_mode, priv->hw_margin); + + if (priv->sysfs_index != SYSFS_NO_CFG) { + + priv->sysfs_group = wdt_get_attr_group(priv->sysfs_index); + if (priv->sysfs_group) { + ret = sysfs_create_group(&pdev->dev.kobj, priv->sysfs_group); + if (ret != 0) { + dev_err(&pdev->dev, "sysfs_create_group failed. ret:%d.\n", ret); + return -ENOMEM; + } + dev_info(&pdev->dev, "sysfs create group success\n"); + } else { + dev_err(&pdev->dev, "failed to find %u index wdt, return NULL.\n", priv->sysfs_index); + return -ENOMEM; + } + + mutex_init(&priv->update_lock); + + dev_info(&pdev->dev, "register %u index wdt sysfs success." ,priv->sysfs_index); + } + + return 0; +} + +static void unregister_action(struct platform_device *pdev) +{ + rg_wdt_priv_t *priv = platform_get_drvdata(pdev); + gpio_wdt_info_t *gpio_wdt; + logic_wdt_info_t *logic_wdt; + int ret; + + ret = rg_wdt_enable_ctrl(priv, WDT_OFF); + if (ret < 0) { + dev_err(&pdev->dev, "remove disable wdt failed.\n"); + } + + if (priv->sysfs_index != SYSFS_NO_CFG) { + sysfs_remove_group(&pdev->dev.kobj, priv->sysfs_group); + } + + if (priv->feed_wdt_type == HRTIMER_TYPE) { + hrtimer_cancel(&priv->hrtimer); + } else if (priv->feed_wdt_type == THREAD_TYPE) { + kthread_stop(priv->thread); + priv->thread = NULL; + } else { + WDT_VERBOSE("wdd type, do nothing.\n"); + } + + if (priv->config_mode == GPIO_FEED_WDT_MODE) { + gpio_wdt = &priv->gpio_wdt; + gpio_set_value_cansleep(gpio_wdt->gpio, !gpio_wdt->active_low); + + if (priv->hw_algo == HW_ALGO_TOGGLE) { + gpio_direction_input(gpio_wdt->gpio); + } + } else { + logic_wdt = &priv->logic_wdt; + logic_wdt->state_val = !logic_wdt->state_val; + ret = rg_wdt_write(logic_wdt->logic_func_mode, logic_wdt->feed_dev_name, + logic_wdt->feed_reg, &logic_wdt->state_val, ONE_BYTE); + if (ret < 0) { + dev_err(&pdev->dev, "set wdt control reg error.\n"); + } + } + + return; +} + +static int rg_wdt_remove(struct platform_device *pdev) +{ + WDT_VERBOSE("enter remove wdt.\n"); + unregister_action(pdev); + dev_info(&pdev->dev, "remove wdt finish.\n"); + + return 0; +} + +static void rg_wdt_shutdown(struct platform_device *pdev) +{ + WDT_VERBOSE("enter shutdown wdt.\n"); + unregister_action(pdev); + dev_info(&pdev->dev, "shutdown wdt finish.\n"); + + return; +} + +static const struct of_device_id rg_wdt_dt_ids[] = { + { .compatible = "ruijie,rg_wdt", }, + { } +}; +MODULE_DEVICE_TABLE(of, rg_wdt_dt_ids); + +static struct platform_driver rg_wdt_driver = { + .driver = { + .name = "rg_wdt", + .of_match_table = rg_wdt_dt_ids, + }, + .probe = rg_wdt_probe, + .remove = rg_wdt_remove, + .shutdown = rg_wdt_shutdown, +}; + +#ifdef CONFIG_GPIO_WATCHDOG_ARCH_INITCALL +static int __init rg_wdt_init(void) +{ + return platform_driver_register(&rg_wdt_driver); +} +arch_initcall(rg_wdt_init); +#else +module_platform_driver(rg_wdt_driver); +#endif + +MODULE_AUTHOR("sonic_rd "); +MODULE_DESCRIPTION("watchdog driver"); +MODULE_LICENSE("GPL"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_wdt.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_wdt.h new file mode 100644 index 000000000000..9c00a27c2838 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_wdt.h @@ -0,0 +1,46 @@ +#ifndef __RG_WDT_H__ +#define __RG_WDT_H__ + +#include + +#define SYSFS_NO_CFG (0xff) + +typedef struct gpio_wdt_info_s { + int gpio; + enum of_gpio_flags flags; + bool active_low; + bool state; +}gpio_wdt_info_t; + +typedef struct logic_wdt_info_s { + const char *feed_dev_name; + uint8_t logic_func_mode; + uint32_t feed_reg; + uint8_t active_val; + uint8_t state_val; +}logic_wdt_info_t; + +typedef struct rg_wdt_device_s { + int device_flag; + const char *config_dev_name; + uint8_t config_mode; + const char *hw_algo; + uint8_t enable_val; + uint8_t disable_val; + uint8_t enable_mask; + uint8_t priv_func_mode; + uint8_t feed_wdt_type; + uint32_t enable_reg; + uint32_t timeout_cfg_reg; + uint32_t timeleft_cfg_reg; + uint32_t hw_margin; + uint32_t feed_time; + uint32_t timer_accuracy; + union { + gpio_wdt_info_t gpio_wdt; + logic_wdt_info_t logic_wdt; + } wdt_config_mode; + uint8_t sysfs_index; +} rg_wdt_device_t; + +#endif diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_xdpe132g5c.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_xdpe132g5c.c new file mode 100644 index 000000000000..4ae5faf4c544 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_xdpe132g5c.c @@ -0,0 +1,574 @@ +/* + * xdpe132g5c_i2c_drv.c + * + * This module create sysfs to set AVS and create hwmon to get out power + * through xdpe132g5c I2C address. + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-09-17 Initial version + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define RG_I2C_RETRY_SLEEP_TIME (10000) /* 10ms */ +#define RG_I2C_RETRY_TIME (10) +#define RG_XDPE_I2C_PAGE_ADDR (0xff) +#define RG_XDPE_I2C_VOUT_MODE (0x40) +#define RG_XDPE_I2C_VOUT_COMMAND (0x42) +#define RG_XDPE_I2C_VOUT_PAGE (0x06) +#define RG_XDPE_VOUT_MAX_THRESHOLD ((0xFFFF * 1000L * 1000L) / (256)) +#define RG_XDPE_VOUT_MIN_THRESHOLD (0) + +static int g_rg_xdpe_debug = 0; +static int g_rg_xdpe_error = 0; + +module_param(g_rg_xdpe_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_xdpe_error, int, S_IRUGO | S_IWUSR); + +#define RG_XDPE_VERBOSE(fmt, args...) do { \ + if (g_rg_xdpe_debug) { \ + printk(KERN_INFO "[RG_XDPE][VER][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RG_XDPE_ERROR(fmt, args...) do { \ + if (g_rg_xdpe_error) { \ + printk(KERN_ERR "[RG_XDPE][ERR][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +struct xdpe_data { + struct i2c_client *client; + struct device *hwmon_dev; + struct mutex update_lock; + long vout_max; + long vout_min; +}; + +typedef struct xdpe_vout_data_s { + u8 vout_mode; + int vout_precision; +} xdpe_vout_data_t; + +static xdpe_vout_data_t g_xdpe_vout_group[] = { + {.vout_mode = 0x18, .vout_precision = 256}, + {.vout_mode = 0x17, .vout_precision = 512}, + {.vout_mode = 0x16, .vout_precision = 1024}, + {.vout_mode = 0x15, .vout_precision = 2048}, + {.vout_mode = 0x14, .vout_precision = 4096}, +}; + +static s32 rg_i2c_smbus_read_byte_data(const struct i2c_client *client, u8 command) +{ + int i; + s32 ret; + + for (i = 0; i < RG_I2C_RETRY_TIME; i++) { + ret = i2c_smbus_read_byte_data(client, command); + if (ret >= 0) { + return ret; + } + usleep_range(RG_I2C_RETRY_SLEEP_TIME, RG_I2C_RETRY_SLEEP_TIME + 1); + } + return ret; +} + +static s32 rg_i2c_smbus_write_byte_data(const struct i2c_client *client, u8 command, u8 value) +{ + int i; + s32 ret; + + for (i = 0; i < RG_I2C_RETRY_TIME; i++) { + ret = i2c_smbus_write_byte_data(client, command, value); + if (ret >= 0) { + return ret; + } + usleep_range(RG_I2C_RETRY_SLEEP_TIME, RG_I2C_RETRY_SLEEP_TIME + 1); + } + return ret; +} + +static s32 rg_i2c_smbus_read_word_data(const struct i2c_client *client, u8 command) +{ + int i; + s32 ret; + + for (i = 0; i < RG_I2C_RETRY_TIME; i++) { + ret = i2c_smbus_read_word_data(client, command); + if (ret >= 0) { + return ret; + } + usleep_range(RG_I2C_RETRY_SLEEP_TIME, RG_I2C_RETRY_SLEEP_TIME + 1); + } + return ret; +} + +static s32 rg_i2c_smbus_write_word_data(const struct i2c_client *client, u8 command, + u16 value) +{ + int i; + s32 ret; + + for (i = 0; i < RG_I2C_RETRY_TIME; i++) { + ret = i2c_smbus_write_word_data(client, command, value); + if (ret >= 0) { + return ret; + } + usleep_range(RG_I2C_RETRY_SLEEP_TIME, RG_I2C_RETRY_SLEEP_TIME + 1); + } + return ret; +} + +static long calc_power_linear11_data(int data) +{ + s16 exponent; + s32 mantissa; + long val; + + exponent = ((s16)data) >> 11; + mantissa = ((s16)((data & 0x7ff) << 5)) >> 5; + val = mantissa; + val = val * 1000L * 1000L; + + if (exponent >= 0) { + val <<= exponent; + } else { + val >>= -exponent; + } + return val; +} + +static int read_xdpe_power_value(const struct i2c_client *client, u8 page, u8 reg, long *value) +{ + int ret, data; + + ret = rg_i2c_smbus_write_byte_data(client, RG_XDPE_I2C_PAGE_ADDR, page); + if (ret < 0) { + RG_XDPE_ERROR("%d-%04x: set xdpe page%u failed, ret: %d\n", client->adapter->nr, + client->addr, page, ret); + return ret; + } + data = rg_i2c_smbus_read_word_data(client, reg); + if (data < 0) { + RG_XDPE_ERROR("%d-%04x: read xdpe page%u reg: 0x%x failed, ret: %d\n", + client->adapter->nr, client->addr, page, reg, data); + return data; + } + *value = calc_power_linear11_data(data); + RG_XDPE_VERBOSE("%d-%04x: page%u reg: 0x%x rd_data: 0x%x, decode linear11 value: %ld\n", + client->adapter->nr, client->addr, page, reg, data, *value); + return 0; +} + +static ssize_t xdpe_power_value_show(struct device *dev, struct device_attribute *da, + char *buf) +{ + int ret, ori_page; + u16 sensor_h, sensor_l; + u8 page, reg; + struct sensor_device_attribute *attr; + struct i2c_client *client; + struct xdpe_data *data; + long value1, value2; + + data = dev_get_drvdata(dev); + client = data->client; + attr = to_sensor_dev_attr(da); + sensor_h = ((attr->index) >> 16) & 0xffff; + sensor_l = (attr->index) & 0xffff; + + mutex_lock(&data->update_lock); + + ori_page = rg_i2c_smbus_read_byte_data(client, RG_XDPE_I2C_PAGE_ADDR); + if (ori_page < 0) { + RG_XDPE_ERROR("%d-%04x: read xdpe origin page failed, ret: %d\n", client->adapter->nr, + client->addr, ori_page); + mutex_unlock(&data->update_lock); + return ori_page; + } + value1 = 0; + value2 = 0; + + if (sensor_h) { + page = (sensor_h >> 8) & 0xff; + reg = sensor_h & 0xff; + ret = read_xdpe_power_value(client, page, reg, &value1); + if (ret < 0) { + RG_XDPE_ERROR("%d-%04x: read xdpe sensor high sensor page%u reg: 0x%x failed, ret: %d\n", + client->adapter->nr, client->addr, page, reg, ret); + goto error; + } + RG_XDPE_VERBOSE("%d-%04x: read xdpe sensor high sensor page%u reg: 0x%x success, value: %ld\n", + client->adapter->nr, client->addr, page, reg, value1); + } + + page = (sensor_l >> 8) & 0xff; + reg = sensor_l & 0xff; + ret = read_xdpe_power_value(client, page, reg, &value2); + if (ret < 0) { + RG_XDPE_ERROR("%d-%04x: read xdpe sensor low sensor page%u reg: 0x%x failed, ret: %d\n", + client->adapter->nr, client->addr, page, reg, ret); + goto error; + } + RG_XDPE_VERBOSE("%d-%04x: read xdpe sensor low sensor page%u reg: 0x%x success, value: %ld\n", + client->adapter->nr, client->addr, page, reg, value2); + + rg_i2c_smbus_write_byte_data(client, RG_XDPE_I2C_PAGE_ADDR, ori_page); + mutex_unlock(&data->update_lock); + return snprintf(buf, PAGE_SIZE, "%ld\n", value1 + value2); +error: + rg_i2c_smbus_write_byte_data(client, RG_XDPE_I2C_PAGE_ADDR, ori_page); + mutex_unlock(&data->update_lock); + return ret; +} + +static int xdpe_get_vout_precision(const struct i2c_client *client, int *vout_precision) +{ + int i, vout_mode, a_size; + + vout_mode = rg_i2c_smbus_read_byte_data(client, RG_XDPE_I2C_VOUT_MODE); + if (vout_mode < 0) { + RG_XDPE_ERROR("%d-%04x: read xdpe vout mode reg: 0x%x failed, ret: %d\n", + client->adapter->nr, client->addr, RG_XDPE_I2C_VOUT_MODE, vout_mode); + return vout_mode; + } + + a_size = ARRAY_SIZE(g_xdpe_vout_group); + for (i = 0; i < a_size; i++) { + if (g_xdpe_vout_group[i].vout_mode == vout_mode) { + *vout_precision = g_xdpe_vout_group[i].vout_precision; + RG_XDPE_VERBOSE("%d-%04x: match, vout mode: 0x%x, precision: %d\n", + client->adapter->nr, client->addr, vout_mode, *vout_precision); + break; + } + } + if (i == a_size) { + RG_XDPE_ERROR("%d-%04x: invalid vout mode: 0x%x\n",client->adapter->nr, client->addr, + vout_mode); + return -EINVAL; + } + return 0; +} + +static ssize_t xdpe_avs_vout_show(struct device *dev, struct device_attribute *da, char *buf) +{ + int ret, ori_page, vout_cmd, vout_precision; + struct i2c_client *client; + struct xdpe_data *data; + long vout; + + client = to_i2c_client(dev); + data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + ori_page = rg_i2c_smbus_read_byte_data(client, RG_XDPE_I2C_PAGE_ADDR); + if (ori_page < 0) { + RG_XDPE_ERROR("%d-%04x: read xdpe origin page failed, ret: %d\n", client->adapter->nr, + client->addr, ori_page); + mutex_unlock(&data->update_lock); + return ori_page; + } + + ret = rg_i2c_smbus_write_byte_data(client, RG_XDPE_I2C_PAGE_ADDR, RG_XDPE_I2C_VOUT_PAGE); + if (ret < 0) { + RG_XDPE_ERROR("%d-%04x: set xdpe avs vout page%u failed, ret: %d\n", client->adapter->nr, + client->addr, RG_XDPE_I2C_VOUT_PAGE, ret); + goto error; + } + + ret = xdpe_get_vout_precision(client, &vout_precision); + if (ret < 0) { + RG_XDPE_ERROR("%d-%04x: get xdpe avs vout precision failed, ret: %d\n", + client->adapter->nr, client->addr, ret); + goto error; + } + + vout_cmd = rg_i2c_smbus_read_word_data(client, RG_XDPE_I2C_VOUT_COMMAND); + if (vout_cmd < 0) { + ret = vout_cmd; + RG_XDPE_ERROR("%d-%04x: read xdpe vout command reg: 0x%x failed, ret: %d\n", + client->adapter->nr, client->addr, RG_XDPE_I2C_VOUT_COMMAND, ret); + goto error; + } + + rg_i2c_smbus_write_byte_data(client, RG_XDPE_I2C_PAGE_ADDR, ori_page); + mutex_unlock(&data->update_lock); + + vout = vout_cmd * 1000L * 1000L / vout_precision; + RG_XDPE_VERBOSE("%d-%04x: vout: %ld, vout_cmd: 0x%x, precision: %d\n", client->adapter->nr, + client->addr, vout, vout_cmd, vout_precision); + return snprintf(buf, PAGE_SIZE, "%ld\n", vout); +error: + rg_i2c_smbus_write_byte_data(client, RG_XDPE_I2C_PAGE_ADDR, ori_page); + mutex_unlock(&data->update_lock); + return ret; +} + +static ssize_t xdpe_avs_vout_store(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + int ret, ori_page, vout_cmd, vout_cmd_set, vout_precision; + struct i2c_client *client; + struct xdpe_data *data; + long vout, vout_max, vout_min; + + client = to_i2c_client(dev); + ret = kstrtol(buf, 10, &vout); + if (ret) { + RG_XDPE_ERROR("%d-%04x: invalid value: %s \n", client->adapter->nr, client->addr, buf); + return -EINVAL; + } + + data = i2c_get_clientdata(client); + vout_max = data->vout_max; + vout_min = data->vout_min; + if ((vout > vout_max) || (vout < vout_min)) { + RG_XDPE_ERROR("%d-%04x: vout value: %ld, out of range [%ld, %ld] \n", client->adapter->nr, + client->addr, vout, vout_min, vout_max); + return -EINVAL; + } + + mutex_lock(&data->update_lock); + + ori_page = rg_i2c_smbus_read_byte_data(client, RG_XDPE_I2C_PAGE_ADDR); + if (ori_page < 0) { + RG_XDPE_ERROR("%d-%04x: read xdpe origin page failed, ret: %d\n", client->adapter->nr, + client->addr, ori_page); + mutex_unlock(&data->update_lock); + return ori_page; + } + + ret = rg_i2c_smbus_write_byte_data(client, RG_XDPE_I2C_PAGE_ADDR, RG_XDPE_I2C_VOUT_PAGE); + if (ret < 0) { + RG_XDPE_ERROR("%d-%04x: set xdpe avs vout page%u failed, ret: %d\n", client->adapter->nr, + client->addr, RG_XDPE_I2C_VOUT_PAGE, ret); + goto error; + } + + ret = xdpe_get_vout_precision(client, &vout_precision); + if (ret < 0) { + RG_XDPE_ERROR("%d-%04x: get xdpe avs vout precision failed, ret: %d\n", + client->adapter->nr, client->addr, ret); + goto error; + } + + vout_cmd_set = (vout * vout_precision) / (1000L * 1000L); + if (vout_cmd_set > 0xffff) { + RG_XDPE_ERROR("%d-%04x: invalid value, vout %ld, vout_precision: %d, vout_cmd_set: 0x%x\n", + client->adapter->nr, client->addr, vout, vout_precision, vout_cmd_set); + ret = -EINVAL; + goto error; + } + ret = rg_i2c_smbus_write_word_data(client, RG_XDPE_I2C_VOUT_COMMAND, vout_cmd_set); + if (ret < 0) { + RG_XDPE_ERROR("%d-%04x: set xdpe vout cmd reg: 0x%x, value: 0x%x failed, ret: %d\n", + client->adapter->nr, client->addr, RG_XDPE_I2C_VOUT_COMMAND, vout_cmd_set, ret); + goto error; + } + + vout_cmd = rg_i2c_smbus_read_word_data(client, RG_XDPE_I2C_VOUT_COMMAND); + if (vout_cmd < 0) { + ret = vout_cmd; + RG_XDPE_ERROR("%d-%04x: read xdpe vout command reg: 0x%x failed, ret: %d\n", + client->adapter->nr, client->addr, RG_XDPE_I2C_VOUT_COMMAND, ret); + goto error; + } + if (vout_cmd != vout_cmd_set) { + ret = -EIO; + RG_XDPE_ERROR("%d-%04x: vout cmd value check error, vout cmd read: 0x%x, vout cmd set: 0x%x\n", + client->adapter->nr, client->addr, vout_cmd, vout_cmd_set); + goto error; + + } + + rg_i2c_smbus_write_byte_data(client, RG_XDPE_I2C_PAGE_ADDR, ori_page); + mutex_unlock(&data->update_lock); + RG_XDPE_VERBOSE("%d-%04x: set vout cmd success, vout %ld, vout_precision: %d, vout_cmd_set: 0x%x\n", + client->adapter->nr, client->addr, vout, vout_precision, vout_cmd_set); + return count; +error: + rg_i2c_smbus_write_byte_data(client, RG_XDPE_I2C_PAGE_ADDR, ori_page); + mutex_unlock(&data->update_lock); + return ret; +} + +static ssize_t xdpe_avs_vout_max_show(struct device *dev, struct device_attribute *da, char *buf) +{ + struct i2c_client *client; + struct xdpe_data *data; + long vout_max; + + client = to_i2c_client(dev); + data = i2c_get_clientdata(client); + vout_max = data->vout_max; + return snprintf(buf, PAGE_SIZE, "%ld\n", vout_max); +} + +static ssize_t xdpe_avs_vout_max_store(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + int ret; + struct i2c_client *client; + struct xdpe_data *data; + long vout_max; + + client = to_i2c_client(dev); + ret = kstrtol(buf, 10, &vout_max); + if (ret) { + RG_XDPE_ERROR("%d-%04x: invalid value: %s \n", client->adapter->nr, client->addr, buf); + return -EINVAL; + } + RG_XDPE_VERBOSE("%d-%04x: vout max threshold: %ld", client->adapter->nr, client->addr, + vout_max); + data = i2c_get_clientdata(client); + data->vout_max = vout_max; + return count; +} + +static ssize_t xdpe_avs_vout_min_show(struct device *dev, struct device_attribute *da, char *buf) +{ + struct i2c_client *client; + struct xdpe_data *data; + long vout_min; + + client = to_i2c_client(dev); + data = i2c_get_clientdata(client); + vout_min = data->vout_min; + return snprintf(buf, PAGE_SIZE, "%ld\n", vout_min); +} + +static ssize_t xdpe_avs_vout_min_store(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + int ret; + struct i2c_client *client; + struct xdpe_data *data; + long vout_min; + + client = to_i2c_client(dev); + ret = kstrtol(buf, 10, &vout_min); + if (ret) { + RG_XDPE_ERROR("%d-%04x: invalid value: %s \n", client->adapter->nr, client->addr, buf); + return -EINVAL; + } + RG_XDPE_VERBOSE("%d-%04x: vout min threshold: %ld", client->adapter->nr, client->addr, + vout_min); + data = i2c_get_clientdata(client); + data->vout_min = vout_min; + return count; +} + +/* xdpe hwmon */ +static SENSOR_DEVICE_ATTR(power1_input, S_IRUGO ,xdpe_power_value_show, NULL, 0x072c); +static SENSOR_DEVICE_ATTR(power2_input, S_IRUGO ,xdpe_power_value_show, NULL, 0x0b2c); +static SENSOR_DEVICE_ATTR(power3_input, S_IRUGO ,xdpe_power_value_show, NULL, 0x072c0b2c); + +static struct attribute *xdpe_hwmon_attrs[] = { + &sensor_dev_attr_power1_input.dev_attr.attr, + &sensor_dev_attr_power2_input.dev_attr.attr, + &sensor_dev_attr_power3_input.dev_attr.attr, + NULL +}; +ATTRIBUTE_GROUPS(xdpe_hwmon); + +/* xdpe sysfs */ +static SENSOR_DEVICE_ATTR(avs_vout, S_IRUGO | S_IWUSR, xdpe_avs_vout_show, xdpe_avs_vout_store, 0); +static SENSOR_DEVICE_ATTR(avs_vout_max, S_IRUGO | S_IWUSR, xdpe_avs_vout_max_show, xdpe_avs_vout_max_store, 0); +static SENSOR_DEVICE_ATTR(avs_vout_min, S_IRUGO | S_IWUSR, xdpe_avs_vout_min_show, xdpe_avs_vout_min_store, 0); + +static struct attribute *xdpe132g5c_sysfs_attrs[] = { + &sensor_dev_attr_avs_vout.dev_attr.attr, + &sensor_dev_attr_avs_vout_max.dev_attr.attr, + &sensor_dev_attr_avs_vout_min.dev_attr.attr, + NULL, +}; + +static const struct attribute_group xdpe132g5c_sysfs_attrs_group = { + .attrs = xdpe132g5c_sysfs_attrs, +}; + +static int xdpe132g5c_probe(struct i2c_client *client, const struct i2c_device_id *id) +{ + struct xdpe_data *data; + int ret; + + RG_XDPE_VERBOSE("bus: %d, addr: 0x%02x do probe.\n", client->adapter->nr, client->addr); + data = devm_kzalloc(&client->dev, sizeof(struct xdpe_data), GFP_KERNEL); + if (!data) { + dev_err(&client->dev, "devm_kzalloc failed.\n"); + return -ENOMEM; + } + + data->client = client; + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + + ret = sysfs_create_group(&client->dev.kobj, &xdpe132g5c_sysfs_attrs_group); + if (ret != 0) { + dev_err(&client->dev, "Create xdpe132g5c sysfs failed, ret: %d\n", ret); + return ret; + } + data->hwmon_dev = hwmon_device_register_with_groups(&client->dev, client->name, data, + xdpe_hwmon_groups); + if (IS_ERR(data->hwmon_dev)) { + ret = PTR_ERR(data->hwmon_dev); + sysfs_remove_group(&client->dev.kobj, &xdpe132g5c_sysfs_attrs_group); + dev_err(&client->dev, "Failed to register xdpe hwmon device, ret: %d\n", ret); + return ret; + } + data->vout_max = RG_XDPE_VOUT_MAX_THRESHOLD; + data->vout_min = RG_XDPE_VOUT_MIN_THRESHOLD; + dev_info(&client->dev, "xdpe132g5c probe success\n"); + return 0; +} + +static int xdpe132g5c_remove(struct i2c_client *client) +{ + struct xdpe_data *data; + + RG_XDPE_VERBOSE("bus: %d, addr: 0x%02x do remove\n", client->adapter->nr, client->addr); + data = i2c_get_clientdata(client); + hwmon_device_unregister(data->hwmon_dev); + sysfs_remove_group(&client->dev.kobj, &xdpe132g5c_sysfs_attrs_group); + return 0; +} + +static const struct i2c_device_id xdpe132g5c_id[] = { + {"rg_xdpe132g5c", 0}, + {} +}; + +MODULE_DEVICE_TABLE(i2c, xdpe132g5c_id); + +static const struct of_device_id __maybe_unused xdpe132g5c_of_match[] = { + {.compatible = "infineon,rg_xdpe132g5c"}, + {} +}; +MODULE_DEVICE_TABLE(of, xdpe132g5c_of_match); + +static struct i2c_driver rg_xdpe132g5c_driver = { + .driver = { + .name = "rg_xdpe132g5c", + .of_match_table = of_match_ptr(xdpe132g5c_of_match), + }, + .probe = xdpe132g5c_probe, + .remove = xdpe132g5c_remove, + .id_table = xdpe132g5c_id, +}; + +module_i2c_driver(rg_xdpe132g5c_driver); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd "); +MODULE_DESCRIPTION("I2C driver for Infineon XDPE132 family"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/ruijie.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/ruijie.h new file mode 100644 index 000000000000..bd2fd8bfa663 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/ruijie.h @@ -0,0 +1,71 @@ +#ifndef __RUIJIE_H__ +#define __RUIJIE_H__ + +#include +#include +#include + +typedef enum { + DBG_START, + DBG_VERBOSE, + DBG_KEY, + DBG_WARN, + DBG_ERROR, + DBG_END, +} dbg_level_t; + + typedef struct dfd_i2c_dev_s { + int bus; + int addr; + } dfd_i2c_dev_t; + +typedef struct dfd_dev_head_info_s { + uint8_t ver; + uint8_t flag; + uint8_t hw_ver; + uint8_t type; + int16_t tlv_len; +} dfd_dev_head_info_t; + +typedef struct dfd_dev_tlv_info_s { + uint8_t type; + uint8_t len; + uint8_t data[0]; +} dfd_dev_tlv_info_t; + +typedef enum dfd_dev_info_type_e { + DFD_DEV_INFO_TYPE_MAC = 1, + DFD_DEV_INFO_TYPE_NAME = 2, + DFD_DEV_INFO_TYPE_SN = 3, + DFD_DEV_INFO_TYPE_PWR_CONS = 4, + DFD_DEV_INFO_TYPE_HW_INFO = 5, + DFD_DEV_INFO_TYPE_DEV_TYPE = 6, +} dfd_dev_tlv_type_t; + +extern int debuglevel; +extern s32 platform_i2c_smbus_read_byte_data(const struct i2c_client *client, u8 command); +extern s32 platform_i2c_smbus_read_i2c_block_data(const struct i2c_client *client, + u8 command, u8 length, u8 *values); +extern s32 platform_i2c_smbus_read_word_data(const struct i2c_client *client, u8 command); + +#define DBG_DEBUG(fmt, arg...) do { \ + if ( debuglevel > DBG_START && debuglevel < DBG_ERROR) { \ + printk(KERN_INFO "[DEBUG]:<%s, %d>:"fmt, __FUNCTION__, __LINE__, ##arg); \ + } else if ( debuglevel >= DBG_ERROR ) { \ + printk(KERN_ERR "[DEBUG]:<%s, %d>:"fmt, __FUNCTION__, __LINE__, ##arg); \ + } else { } \ +} while (0) + +#define DBG_INFO(fmt, arg...) do { \ + if ( debuglevel > DBG_KEY) { \ + printk(KERN_INFO "[INFO]:<%s, %d>:"fmt, __FUNCTION__, __LINE__, ##arg); \ + } \ + } while (0) + +#define DBG_ERROR(fmt, arg...) do { \ + if ( debuglevel > DBG_START) { \ + printk(KERN_ERR "[ERROR]:<%s, %d>:"fmt, __FUNCTION__, __LINE__, ##arg); \ + } \ + } while (0) + +#endif diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/ruijie_common_module.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/ruijie_common_module.c new file mode 100644 index 000000000000..3c2046febd70 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/ruijie_common_module.c @@ -0,0 +1,210 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,19,152) +#include +#else +#include +#endif +#include +#include +#include +#include +#include "ruijie.h" +#include "dfd_tlveeprom.h" + +#define PLATFORM_I2C_RETRY_TIMES 3 + +#define DFD_TLVEEPROM_I2C_BUS (0) +#define DFD_TLVEEPROM_I2C_ADDR (0x56) +#define DFD_E2PROM_MAX_LEN (256) +#define DFD_CARDTYPE_EXT_TLVLEN (4) + +#define PLATFORM_CARDTYPE_RETRY_CNT (10) +#define PLATFORM_CARDTYPE_RETRY_TIMES (1000) + +int debuglevel = 0; +module_param(debuglevel, int, S_IRUGO | S_IWUSR); + +static int dfd_my_type = 0; +module_param(dfd_my_type, int, S_IRUGO | S_IWUSR); + +int g_common_debug_error = 0; +module_param(g_common_debug_error, int, S_IRUGO | S_IWUSR); + +int g_common_debug_verbose = 0; +module_param(g_common_debug_verbose, int, S_IRUGO | S_IWUSR); + +uint32_t dfd_my_type_i2c_bus = 0; +module_param(dfd_my_type_i2c_bus, int, S_IRUGO | S_IWUSR); + +uint32_t dfd_my_type_i2c_addr = 0; +module_param(dfd_my_type_i2c_addr, int, S_IRUGO | S_IWUSR); + +#define RUJIE_COMMON_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_common_debug_verbose) { \ + printk(KERN_ERR "[RUIJIE_COMMON][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RUJIE_COMMON_DEBUG_ERROR(fmt, args...) do { \ + if (g_common_debug_error) { \ + printk(KERN_ERR "[RUIJIE_COMMON][ERROR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static int32_t dfd_i2c_read(char *dev, uint32_t addr, uint32_t offset_addr, unsigned char * +buf, int32_t size) +{ + struct file *fp; + struct i2c_client client; + int i ,j; + int rv; + s32 val_t; + + val_t = -1; + rv = 0; + fp = filp_open(dev, O_RDWR, S_IRUSR | S_IWUSR); + if (IS_ERR(fp)) { + DBG_ERROR("i2c open fail.\n"); + RUJIE_COMMON_DEBUG_ERROR("i2c open fail.\n"); + return -1; + } + memcpy(&client, fp->private_data, sizeof(struct i2c_client)); + client.addr = addr; + for (j = 0 ;j < size ;j++){ + for (i = 0; i < PLATFORM_I2C_RETRY_TIMES; i++) { + if ((val_t = i2c_smbus_read_byte_data(&client, (offset_addr + j)))< 0) { + DBG_DEBUG("read try(%d)time offset_addr:%x \n", i, offset_addr); + continue; + } else { + * (buf + j) = val_t; + break; + } + } + if (val_t < 0) { + rv = -1; + break; + } + } + filp_close(fp, NULL); + return rv; +} + +static int dfd_tlvinfo_get_cardtype(void) +{ + char i2c_path[16] = {0}; + int ret; + int cardtype; + u_int8_t eeprom[DFD_E2PROM_MAX_LEN]; + dfd_i2c_dev_t i2c_dev; + uint8_t buf[DFD_CARDTYPE_EXT_TLVLEN]; + uint8_t len; + dfd_tlv_type_t tlv_type; + + if (dfd_my_type_i2c_bus != 0) { + i2c_dev.bus = dfd_my_type_i2c_bus; + } else { + i2c_dev.bus = DFD_TLVEEPROM_I2C_BUS; + } + + if (dfd_my_type_i2c_addr != 0) { + i2c_dev.addr = dfd_my_type_i2c_addr; + } else { + i2c_dev.addr = DFD_TLVEEPROM_I2C_ADDR; + } + snprintf(i2c_path, sizeof(i2c_path), "/dev/i2c-%d", i2c_dev.bus); + RUJIE_COMMON_DEBUG_VERBOSE("Read device eeprom info:(dev:%s, addr:%02x).\n", i2c_path, i2c_dev.addr); + + ret = dfd_i2c_read(i2c_path, i2c_dev.addr, 0, eeprom, DFD_E2PROM_MAX_LEN); + if (ret != 0) { + DBG_ERROR("Read eeprom info error(dev: %s, addr: %02x).\n", i2c_path, i2c_dev.addr); + RUJIE_COMMON_DEBUG_ERROR("Read eeprom info error(dev: %s, addr: %02x).\n", i2c_path, i2c_dev.addr); + return ret; + } + + tlv_type.main_type = TLV_CODE_VENDOR_EXT; + tlv_type.ext_type = DFD_TLVINFO_EXT_TLV_TYPE_DEV_TYPE; + len = sizeof(buf); + memset(buf, 0, len); + ret = dfd_tlvinfo_get_e2prom_info(eeprom, DFD_E2PROM_MAX_LEN, &tlv_type, buf, &len); + if (ret) { + DBG_ERROR("dfd_tlvinfo_get_e2prom_info failed ret %d.\n", ret); + return -1; + } + for (ret = 0; ret < 4; ret++) { + DBG_DEBUG("buf 0x%02x.\n", buf[ret]); + } + + cardtype = ntohl(*((uint32_t *)buf)); + DBG_DEBUG("cardtype 0x%x.\n", cardtype); + return cardtype; +} + +static int __dfd_get_my_card_type(void) +{ + return dfd_tlvinfo_get_cardtype(); +} + +int dfd_get_my_card_type(void) +{ + int type; + int cnt; + + if (dfd_my_type != 0) { + DBG_DEBUG("my_type = 0x%x\r\n", dfd_my_type); + return dfd_my_type; + } + + cnt = PLATFORM_CARDTYPE_RETRY_CNT; + while (cnt--) { + type = __dfd_get_my_card_type(); + if (type < 0) { + RUJIE_COMMON_DEBUG_ERROR("__dfd_get_my_card_type fail cnt %d, ret %d.\n", cnt, type); + msleep(PLATFORM_CARDTYPE_RETRY_TIMES); + continue; + } + RUJIE_COMMON_DEBUG_VERBOSE("success to get type 0x%x.\n", type); + break; + } + + dfd_my_type = type; + return dfd_my_type; +} +EXPORT_SYMBOL(dfd_get_my_card_type); + +static int __init ruijie_common_init(void) +{ + int ret; + + RUJIE_COMMON_DEBUG_VERBOSE("Enter.\n"); + ret = dfd_get_my_card_type(); + if (ret <= 0) { + RUJIE_COMMON_DEBUG_ERROR("dfd_get_my_card_type failed, ret %d.\n", ret); + printk(KERN_ERR "Warning: Device type get failed, please check the TLV-EEPROM!\n"); + return -1; + } + + RUJIE_COMMON_DEBUG_VERBOSE("Leave success type 0x%x.\n", ret); + return 0; +} + +static void __exit ruijie_common_exit(void) +{ + RUJIE_COMMON_DEBUG_VERBOSE("Exit.\n"); +} + +module_init(ruijie_common_init); +module_exit(ruijie_common_exit); + +MODULE_DESCRIPTION("ruijie Platform Support"); +MODULE_AUTHOR("sonic_rd "); +MODULE_LICENSE("GPL"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/spi-bitbang-txrx.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/spi-bitbang-txrx.h new file mode 100644 index 000000000000..47bb9b898dfd --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/spi-bitbang-txrx.h @@ -0,0 +1,107 @@ +/* + * Mix this utility code with some glue code to get one of several types of + * simple SPI master driver. Two do polled word-at-a-time I/O: + * + * - GPIO/parport bitbangers. Provide chipselect() and txrx_word[](), + * expanding the per-word routines from the inline templates below. + * + * - Drivers for controllers resembling bare shift registers. Provide + * chipselect() and txrx_word[](), with custom setup()/cleanup() methods + * that use your controller's clock and chipselect registers. + * + * Some hardware works well with requests at spi_transfer scope: + * + * - Drivers leveraging smarter hardware, with fifos or DMA; or for half + * duplex (MicroWire) controllers. Provide chipselect() and txrx_bufs(), + * and custom setup()/cleanup() methods. + */ + +/* + * The code that knows what GPIO pins do what should have declared four + * functions, ideally as inlines, before including this header: + * + * void setsck(struct spi_device *, int is_on); + * void setmosi(struct spi_device *, int is_on); + * int getmiso(struct spi_device *); + * void spidelay(unsigned); + * + * setsck()'s is_on parameter is a zero/nonzero boolean. + * + * setmosi()'s is_on parameter is a zero/nonzero boolean. + * + * getmiso() is required to return 0 or 1 only. Any other value is invalid + * and will result in improper operation. + * + * A non-inlined routine would call bitbang_txrx_*() routines. The + * main loop could easily compile down to a handful of instructions, + * especially if the delay is a NOP (to run at peak speed). + * + * Since this is software, the timings may not be exactly what your board's + * chips need ... there may be several reasons you'd need to tweak timings + * in these routines, not just to make it faster or slower to match a + * particular CPU clock rate. + */ + +static inline u32 +bitbang_txrx_be_cpha0(struct spi_device *spi, + unsigned nsecs, unsigned cpol, unsigned flags, + u32 word, u8 bits) +{ + /* if (cpol == 0) this is SPI_MODE_0; else this is SPI_MODE_2 */ + + u32 oldbit = (!(word & (1<<(bits-1)))) << 31; + /* clock starts at inactive polarity */ + for (word <<= (32 - bits); likely(bits); bits--) { + + /* setup MSB (to slave) on trailing edge */ + if ((flags & SPI_MASTER_NO_TX) == 0) { + if ((word & (1 << 31)) != oldbit) { + setmosi(spi, word & (1 << 31)); + oldbit = word & (1 << 31); + } + } + spidelay(nsecs); /* T(setup) */ + + setsck(spi, !cpol); + spidelay(nsecs); + + /* sample MSB (from slave) on leading edge */ + word <<= 1; + if ((flags & SPI_MASTER_NO_RX) == 0) + word |= getmiso(spi); + setsck(spi, cpol); + } + return word; +} + +static inline u32 +bitbang_txrx_be_cpha1(struct spi_device *spi, + unsigned nsecs, unsigned cpol, unsigned flags, + u32 word, u8 bits) +{ + /* if (cpol == 0) this is SPI_MODE_1; else this is SPI_MODE_3 */ + + u32 oldbit = (!(word & (1<<(bits-1)))) << 31; + /* clock starts at inactive polarity */ + for (word <<= (32 - bits); likely(bits); bits--) { + + /* setup MSB (to slave) on leading edge */ + setsck(spi, !cpol); + if ((flags & SPI_MASTER_NO_TX) == 0) { + if ((word & (1 << 31)) != oldbit) { + setmosi(spi, word & (1 << 31)); + oldbit = word & (1 << 31); + } + } + spidelay(nsecs); /* T(setup) */ + + setsck(spi, cpol); + spidelay(nsecs); + + /* sample MSB (from slave) on trailing edge */ + word <<= 1; + if ((flags & SPI_MASTER_NO_RX) == 0) + word |= getmiso(spi); + } + return word; +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/script/dev_monitor.py b/platform/broadcom/sonic-platform-modules-tencent/common/script/dev_monitor.py new file mode 100755 index 000000000000..7fbfe144b2c4 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/script/dev_monitor.py @@ -0,0 +1,345 @@ +#!/usr/bin/env python3 +import click +import os +import time +from ruijieconfig import DEV_MONITOR_PARAM +from ruijieutil import waitForDocker +from platform_util import io_rd, rji2cget, rji2cset, rjpciwr +import syslog +import traceback + + +CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help']) + + +class AliasedGroup(click.Group): + def get_command(self, ctx, cmd_name): + rv = click.Group.get_command(self, ctx, cmd_name) + if rv is not None: + return rv + matches = [x for x in self.list_commands(ctx) + if x.startswith(cmd_name)] + if not matches: + return None + elif len(matches) == 1: + return click.Group.get_command(self, ctx, matches[0]) + ctx.fail('Too many matches: %s' % ', '.join(sorted(matches))) + return None + + +DEVMONITOR_DEBUG_FILE = "/etc/.devmonitor_debug_flag" + +debuglevel = 0 + + +def debug_init(): + global debuglevel + if os.path.exists(DEVMONITOR_DEBUG_FILE): + debuglevel = 1 + else: + debuglevel = 0 + + +def devwarninglog(s): + #s = s.decode('utf-8').encode('gb2312') + syslog.openlog("DEVMONITOR", syslog.LOG_PID) + syslog.syslog(syslog.LOG_WARNING, s) + + +def devcriticallog(s): + #s = s.decode('utf-8').encode('gb2312') + syslog.openlog("DEVMONITOR", syslog.LOG_PID) + syslog.syslog(syslog.LOG_CRIT, s) + + +def deverror(s): + #s = s.decode('utf-8').encode('gb2312') + syslog.openlog("DEVMONITOR", syslog.LOG_PID) + syslog.syslog(syslog.LOG_ERR, s) + + +def devinfo(s): + #s = s.decode('utf-8').encode('gb2312') + syslog.openlog("DEVMONITOR", syslog.LOG_PID) + syslog.syslog(syslog.LOG_INFO, s) + + +def devdebuglog(s): + #s = s.decode('utf-8').encode('gb2312') + if debuglevel == 1: + syslog.openlog("DEVMONITOR", syslog.LOG_PID) + syslog.syslog(syslog.LOG_DEBUG, s) + + +class DevMonitor(): + + def getpresentstatus(self, param): + try: + ret = {} + ret["status"] = '' + totalerr = 0 + gettype = param.get('gettype') + presentbit = param.get('presentbit') + okval = param.get('okval') + if gettype == "io": + io_addr = param.get('io_addr') + val = io_rd(io_addr) + if val is not None: + retval = val + else: + totalerr -= 1 + else: + bus = param.get('bus') + loc = param.get('loc') + offset = param.get('offset') + ind, val = rji2cget(bus, loc, offset) + if ind == True: + retval = val + else: + totalerr -= 1 + if totalerr < 0: + ret["status"] = "NOT OK" + return ret + val_t = (int(retval, 16) & (1 << presentbit)) >> presentbit + if val_t != okval: + ret["status"] = "ABSENT" + else: + ret["status"] = "PRESENT" + except Exception as e: + ret["status"] = "NOT OK" + deverror("getpresentstatus error") + deverror(str(e)) + return ret + + def removeDev(self, bus, loc): + cmd = "echo 0x%02x > /sys/bus/i2c/devices/i2c-%d/delete_device" % (loc, bus) + devpath = "/sys/bus/i2c/devices/%d-%04x" % (bus, loc) + if os.path.exists(devpath): + os.system(cmd) + + def addDev(self, name, bus, loc): + if name == "lm75": + time.sleep(0.1) + cmd = "echo %s 0x%02x > /sys/bus/i2c/devices/i2c-%d/new_device" % (name, loc, bus) + devpath = "/sys/bus/i2c/devices/%d-%04x" % (bus, loc) + if os.path.exists(devpath) == False: + os.system(cmd) + + def checkattr(self, bus, loc, attr): + try: + attrpath = "/sys/bus/i2c/devices/%d-%04x/%s" % (bus, loc, attr) + if os.path.exists(attrpath): + return True + except Exception as e: + deverror("checkattr error") + deverror(str(e)) + return False + + def monitor(self, ret): + totalerr = 0 + for item in ret: + try: + name = item.get('name') + itemattr = '%sattr' % name + val_t = getattr(DevMonitor, itemattr, None) + if val_t == 'OK': + continue + present = item.get('present', None) + devices = item.get('device') + err_t = 0 + for item_dev in devices: + item_devattr = '%s' % (item_dev['id']) + val_t = getattr(DevMonitor, item_devattr, None) + if val_t == 'OK': + continue + devname = item_dev.get('name') + bus = item_dev.get('bus') + loc = item_dev.get('loc') + attr = item_dev.get('attr') + if self.checkattr(bus, loc, attr) == False: + err_t -= 1 + setattr(DevMonitor, item_devattr, 'NOT OK') + if present is not None: + presentstatus = self.getpresentstatus(present) + devdebuglog("%s present status:%s" % (name, presentstatus.get('status'))) + if presentstatus.get('status') == 'PRESENT': + self.removeDev(bus, loc) + time.sleep(0.1) + self.addDev(devname, bus, loc) + else: + self.removeDev(bus, loc) + time.sleep(0.1) + self.addDev(devname, bus, loc) + else: + setattr(DevMonitor, item_devattr, 'OK') + val_t = getattr(DevMonitor, item_devattr, None) + devdebuglog("%s status %s" % (item_devattr, val_t)) + if err_t == 0: + setattr(DevMonitor, itemattr, 'OK') + else: + totalerr -= 1 + setattr(DevMonitor, itemattr, 'NOT OK') + val_t = getattr(DevMonitor, itemattr, None) + devdebuglog("%s status %s" % (itemattr, val_t)) + except Exception as e: + totalerr -= 1 + deverror("monitor error") + deverror(str(e)) + return totalerr + + def psusmonitor(self): + psus_conf = DEV_MONITOR_PARAM.get('psus') + if psus_conf is None: + return 0 + psusattr = 'psusattr' + val_t = getattr(DevMonitor, psusattr, None) + if val_t == 'OK': + return 0 + ret = self.monitor(psus_conf) + if ret == 0: + setattr(DevMonitor, psusattr, 'OK') + else: + setattr(DevMonitor, psusattr, 'NOT OK') + val_t = getattr(DevMonitor, psusattr, None) + devdebuglog("psusattr:value:%s" % (val_t)) + return ret + + def fansmonitor(self): + fans_conf = DEV_MONITOR_PARAM.get('fans') + if fans_conf is None: + return 0 + fansattr = 'fansattr' + val_t = getattr(DevMonitor, fansattr, None) + if val_t == 'OK': + return 0 + ret = self.monitor(fans_conf) + if ret == 0: + setattr(DevMonitor, fansattr, 'OK') + else: + setattr(DevMonitor, fansattr, 'NOT OK') + val_t = getattr(DevMonitor, fansattr, None) + devdebuglog("fansattr:value:%s" % (val_t)) + return ret + + def slotsmonitor(self): + slots_conf = DEV_MONITOR_PARAM.get('slots') + if slots_conf is None: + return 0 + slotsattr = 'slotsattr' + val_t = getattr(DevMonitor, slotsattr, None) + if val_t == 'OK': + return 0 + ret = self.monitor(slots_conf) + if ret == 0: + setattr(DevMonitor, slotsattr, 'OK') + else: + setattr(DevMonitor, slotsattr, 'NOT OK') + val_t = getattr(DevMonitor, slotsattr, None) + devdebuglog("slotsattr:value:%s" % (val_t)) + return ret + + def sdkmonitor(self): + sdk_conf = DEV_MONITOR_PARAM.get('sdk') + ret = 0 + if sdk_conf is None: + return ret + sdkattr = 'sdkattr' + val_t = getattr(DevMonitor, sdkattr, None) + if val_t == 'OK': + return ret + if waitForDocker(timeout=0) == True: + setattr(DevMonitor, sdkattr, 'OK') + acts = sdk_conf.get("act", []) + for item in acts: + if item.get('gettype') == 'i2c': + bus = item.get('bus') + loc = item.get('loc') + offset = item.get('offset') + value = item.get('value') + rji2cset(bus, loc, offset, value) + elif item.get('gettype') == 'pci': + pcibus = item.get("pcibus") + slot = item.get("slot") + fn = item.get("fn") + bar = item.get("bar") + offset = item.get("offset") + data = item.get("data") + rjpciwr(pcibus, slot, fn, bar, offset, data) + + else: + ret = -1 + setattr(DevMonitor, sdkattr, 'NOT OK') + val_t = getattr(DevMonitor, sdkattr, None) + devdebuglog("sdkattr:value:%s" % (val_t)) + return ret + + def othersmonitor(self): + others_conf = DEV_MONITOR_PARAM.get('others') + if others_conf is None: + return 0 + othersattr = 'othersattr' + val_t = getattr(DevMonitor, othersattr, None) + if val_t == 'OK': + return 0 + ret = self.monitor(others_conf) + if ret == 0: + setattr(DevMonitor, othersattr, 'OK') + else: + setattr(DevMonitor, othersattr, 'NOT OK') + val_t = getattr(DevMonitor, othersattr, None) + devdebuglog("othersattr:value:%s" % (val_t)) + return ret + + +def doDevMonitor(devMonitor): + ret_t = 0 + ret_t += devMonitor.psusmonitor() + ret_t += devMonitor.fansmonitor() + ret_t += devMonitor.slotsmonitor() + # SDK + ret_t += devMonitor.sdkmonitor() + ret_t += devMonitor.othersmonitor() + return ret_t + + +def run(interval, devMonitor): + # devMonitor.devattrinit() + while True: + try: + debug_init() + ret = doDevMonitor(devMonitor) + except Exception as e: + traceback.print_exc() + deverror(str(e)) + ret = -1 + if ret == 0: + time.sleep(5) + devinfo("dev_monitor finished!") + exit(0) + time.sleep(interval) + + +@click.group(cls=AliasedGroup, context_settings=CONTEXT_SETTINGS) +def main(): + '''device operator''' + pass + + +@main.command() +def start(): + '''start device monitor''' + devinfo("dev_monitor start") + devMonitor = DevMonitor() + interval = DEV_MONITOR_PARAM.get('polling_time', 10) + run(interval, devMonitor) + + +@main.command() +def stop(): + '''stop device monitor ''' + devinfo("stop") + + +# device_i2c operation +if __name__ == '__main__': + main() diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/script/hal_fanctrl.py b/platform/broadcom/sonic-platform-modules-tencent/common/script/hal_fanctrl.py new file mode 100755 index 000000000000..cfd3da7602e9 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/script/hal_fanctrl.py @@ -0,0 +1,1012 @@ +#!/usr/bin/env python3 +import os +import subprocess +import time +import syslog +import traceback +from plat_hal.interface import interface +from plat_hal.baseutil import baseutil +from algorithm.pid import pid +from algorithm.openloop import openloop +from algorithm.hysteresis import hysteresis + + +SWITCH_TEMP = "SWITCH_TEMP" +INLET_TEMP = "INLET_TEMP" +BOARD_TEMP = "BOARD_TEMP" +OUTLET_TEMP = "OUTLET_TEMP" +CPU_TEMP = "CPU_TEMP" + +FANCTROL_DEBUG_FILE = "/etc/.fancontrol_debug_flag" +OTP_REBOOT_JUDGE_FILE = "/etc/.otp_reboot_flag" #coordination with REBOOT_CAUSE_PARA + +FANCTROLERROR = 1 +FANCTROLDEBUG = 2 +FANAIRFLOWDEBUG = 4 + +debuglevel = 0 + +F2B_AIR_FLOW = "F2B" +B2F_AIR_FLOW = "B2F" +ONIE_E2_NAME = "ONIE_E2" + + +def fancontrol_debug(s): + if FANCTROLDEBUG & debuglevel: + syslog.openlog("FANCONTROL", syslog.LOG_PID) + syslog.syslog(syslog.LOG_DEBUG, s) + + +def fancontrol_error(s): + if FANCTROLERROR & debuglevel: + syslog.openlog("FANCONTROL", syslog.LOG_PID) + syslog.syslog(syslog.LOG_ERR, s) + + +def fanairflow_debug(s): + if FANAIRFLOWDEBUG & debuglevel: + syslog.openlog("AIR_FLOW_MONITOR", syslog.LOG_PID) + syslog.syslog(syslog.LOG_DEBUG, s) + + +def exec_os_cmd(cmd): + status, output = subprocess.getstatusoutput(cmd) + if status: + print(output) + return status, output + + +def debug_init(): + global debuglevel + try: + with open(FANCTROL_DEBUG_FILE, "r") as fd: + value = fd.read() + debuglevel = int(value) + except Exception as e: + debuglevel = 0 + + +error_temp = -9999 # get temp error +invalid_temp = -10000 # get temp invalid +PRE_FAN_NOK_UNKNOWN = "UNKNOWN" + + +class DevFan(object): + + def __init__(self, name, interface): + self.__name = name + self.origin_name = None + self.display_name = None + self.air_flow = None + self.air_flow_inconsistent = False + self.int_case = interface + + @property + def name(self): + return self.__name + + def get_fan_rotor_number(self): + return self.int_case.get_fan_rotor_number(self.name) + + def get_fan_presence(self): + return self.int_case.get_fan_presence(self.name) + + def get_fan_rotor_status(self, rotor_name): + return self.int_case.get_fan_rotor_status(self.name, rotor_name) + + def get_fan_fru_info(self): + return self.int_case.get_fan_fru_info(self.name) + + @property + def na_ret(self): + return self.int_case.na_ret + + def update_fru_info(self): + try: + dic = self.get_fan_fru_info() + self.origin_name = dic["PN"] + self.air_flow = dic["AirFlow"] + self.display_name = dic["DisplayName"] + except Exception as e: + fanairflow_debug("update %s fru info error, msg: %s" % (self.name, str(e))) + self.origin_name = self.na_ret + self.air_flow = self.na_ret + self.display_name = self.na_ret + + +class fancontrol(object): + __int_case = None + + __pwm = 0x80 + + def __init__(self): + self.int_case = interface() + self.__config = baseutil.get_monitor_config() + self.__pid_config = self.__config["pid"] + self.__hyst_config = self.__config.get("hyst", {}) + self.__temps_threshold_config = self.__config["temps_threshold"] + for temp_threshold in self.__temps_threshold_config.values(): + temp_threshold['temp'] = 0 + temp_threshold['fail_num'] = 0 + temp_threshold['warning_num'] = 0 # temp warning times + temp_threshold['critical_num'] = 0 # temp critical times + temp_threshold['emergency_num'] = 0 # temp emergency times + temp_threshold.setdefault('ignore_threshold', 0) # default temp threshold on + temp_threshold.setdefault('invalid', invalid_temp) + temp_threshold.setdefault('error', error_temp) + + self.__fan_rotor_error_num = {} + self.__fan_present_status = {} # {"FAN1":0, "FAN2":1...} 1:present, 0:absent + self.__fan_rotate_status = {} # {"FAN1":0, "FAN2":1...} 1:OK, 0:NOT OK + self.__fan_repair_flag = {} # {"FAN1":0, "FAN2":1...} 1:repair, 0:give up + fan_num = self.get_fan_total_number() + for i in range(fan_num): + fan_name = "FAN" + str(i + 1) + self.__fan_present_status[fan_name] = 1 # present + self.__fan_rotate_status[fan_name] = 1 # OK + self.__fan_repair_flag[fan_name] = 1 # repair + rotor_num = self.get_rotor_number(fan_name) + tmp_fan = {} + for j in range(rotor_num): + rotor_name = "Rotor" + str(j + 1) + tmp_fan[rotor_name] = 0 # not error + self.__fan_rotor_error_num[fan_name] = tmp_fan + + self.__fancontrol_para = self.__config["fancontrol_para"] + self.__interval = self.__fancontrol_para.get("interval", 5) + self.__fan_status_interval = self.__fancontrol_para.get("fan_status_interval", 0) + self.__max_pwm = self.__fancontrol_para.get("max_pwm", 0xff) + self.__min_pwm = self.__fancontrol_para.get("min_pwm", 0x80) + self.__abnormal_pwm = self.__fancontrol_para.get("abnormal_pwm", 0xbb) + self.__warning_pwm = self.__fancontrol_para.get("warning_pwm", 0xff) + self.__temp_invalid_pid_pwm = self.__fancontrol_para.get("temp_invalid_pid_pwm", 0x80) + self.__temp_error_pid_pwm = self.__fancontrol_para.get("temp_error_pid_pwm", 0x80) + self.__temp_fail_num = self.__fancontrol_para.get("temp_fail_num", 3) + self.__check_temp_fail = self.__fancontrol_para.get("check_temp_fail", []) + self.__temp_warning_num = self.__fancontrol_para.get("temp_warning_num", 3) + self.__temp_critical_num = self.__fancontrol_para.get("temp_critical_num", 3) + self.__temp_emergency_num = self.__fancontrol_para.get("temp_emergency_num", 3) + self.__temp_warning_countdown = self.__fancontrol_para.get("temp_warning_countdown", 60) + self.__temp_critical_countdown = self.__fancontrol_para.get("temp_critical_countdown", 60) + self.__temp_emergency_countdown = self.__fancontrol_para.get("temp_emergency_countdown", 60) + self.__rotor_error_count = self.__fancontrol_para.get("rotor_error_count", 6) + self.__inlet_mac_diff = self.__fancontrol_para.get("inlet_mac_diff", 50) + self.__check_crit_reboot_flag = self.__fancontrol_para.get("check_crit_reboot_flag", 1) + self.__check_emerg_reboot_flag = self.__fancontrol_para.get("check_emerg_reboot_flag", 1) + self.__check_crit_reboot_num = self.__fancontrol_para.get("check_crit_reboot_num", 3) + self.__check_crit_sleep_time = self.__fancontrol_para.get("check_crit_sleep_time", 20) + self.__check_emerg_reboot_num = self.__fancontrol_para.get("check_emerg_reboot_num", 3) + self.__check_emerg_sleep_time = self.__fancontrol_para.get("check_emerg_sleep_time", 20) + self.__check_temp_emergency = self.__fancontrol_para.get("check_temp_emergency", 0) + self.__check_temp_critical = self.__fancontrol_para.get("check_temp_critical", 1) + self.__check_temp_warning = self.__fancontrol_para.get("check_temp_warning", 1) + self.__check_temp_emergency_reboot = self.__fancontrol_para.get("check_temp_emergency_reboot", []) + self.__psu_absent_fullspeed_num = self.__fancontrol_para.get("psu_absent_fullspeed_num", 1) + self.__fan_absent_fullspeed_num = self.__fancontrol_para.get("fan_absent_fullspeed_num", 1) + self.__rotor_error_fullspeed_num = self.__fancontrol_para.get("rotor_error_fullspeed_num", 1) + self.__psu_fan_control = self.__fancontrol_para.get("psu_fan_control", 1) # default control psu fan + self.__fan_plug_in_pwm = self.__fancontrol_para.get("fan_plug_in_pwm", 0x80) + self.__fan_plug_in_default_countdown = self.__fancontrol_para.get("fan_plug_in_default_countdown", 0) + self.__deal_fan_error_policy = self.__fancontrol_para.get("deal_fan_error", 0) + self.__deal_fan_error_conf = self.__fancontrol_para.get("deal_fan_error_conf", {}) + self.__deal_fan_error_default_countdown = self.__deal_fan_error_conf.get("countdown", 0) + + self.__warning_countdown = 0 # temp warning flag for normal fancontrol + self.__critical_countdown = 0 # temp critical flag for normal fancontrol + self.__emergency_countdown = 0 # temp emergency flag for normal fancontrol + self.__fan_plug_in_countdown = 0 # fan plug in flag for normal fancontrol + self.__deal_fan_error_countdown = 0 + self.__fan_absent_num = 0 + self.__fan_nok_num = 0 + self.__pre_fan_nok = PRE_FAN_NOK_UNKNOWN + self.openloop = openloop() + self.pid = pid() + self.hyst = hysteresis() + self.__pwm = self.__min_pwm + + self.__board_air_flow = "" + self.__fan_air_flow_monitor = self.__fancontrol_para.get("fan_air_flow_monitor", 0) + self.__air_flow_correct_fan_pwm = self.__fancontrol_para.get("air_flow_correct_fan_pwm", 0xff) + self.__air_flow_error_fan_pwm = self.__fancontrol_para.get("air_flow_error_fan_pwm", 0) + self.__air_flow_error_psu_pwm = self.__fancontrol_para.get("air_flow_error_psu_pwm", 0xff) + self.air_flow_inconsistent_flag = False + self.fan_obj_list = [] + + @property + def na_ret(self): + return self.int_case.na_ret + + def get_onie_e2_obj(self, name): + return self.int_case.get_onie_e2_obj(name) + + @property + def board_air_flow(self): + if self.__board_air_flow != F2B_AIR_FLOW and self.__board_air_flow != B2F_AIR_FLOW: + onie_e2_obj = self.get_onie_e2_obj(ONIE_E2_NAME) + if onie_e2_obj is not None: + fanairflow_debug("onie_e2 servicetag: %s" % onie_e2_obj.servicetag) + if isinstance(onie_e2_obj.servicetag, str) and onie_e2_obj.servicetag.startswith("F2B"): + self.__board_air_flow = F2B_AIR_FLOW + elif isinstance(onie_e2_obj.servicetag, str) and onie_e2_obj.servicetag.startswith("B2F"): + self.__board_air_flow = B2F_AIR_FLOW + else: + self.__board_air_flow = onie_e2_obj.servicetag + fanairflow_debug("board_air_flow: %s" % self.__board_air_flow) + return self.__board_air_flow + + @property + def fan_air_flow_monitor(self): + return self.__fan_air_flow_monitor + + @property + def air_flow_correct_fan_pwm(self): + return self.__air_flow_correct_fan_pwm + + @property + def air_flow_error_fan_pwm(self): + return self.__air_flow_error_fan_pwm + + @property + def air_flow_error_psu_pwm(self): + return self.__air_flow_error_psu_pwm + + def get_para(self, type): + para = self.__pid_config.get(type) + return para + + def update_over_temp_threshold_num(self): + for temp_threshold in self.__temps_threshold_config.values(): + if temp_threshold['ignore_threshold']: + continue + emergency_threshold = temp_threshold.get('emergency', None) + critical_threshold = temp_threshold.get('critical', None) + warning_threshold = temp_threshold.get('warning', None) + fancontrol_debug("%s warning = %s, critical = %s, emergency = %s" % + (temp_threshold['name'], warning_threshold, critical_threshold, emergency_threshold)) + + if emergency_threshold is not None and temp_threshold['temp'] >= emergency_threshold: + temp_threshold['emergency_num'] += 1 + else: + temp_threshold['emergency_num'] = 0 + + if critical_threshold is not None and temp_threshold['temp'] >= critical_threshold: + temp_threshold['critical_num'] += 1 + else: + temp_threshold['critical_num'] = 0 + + if warning_threshold is not None and temp_threshold['temp'] >= warning_threshold: + temp_threshold['warning_num'] += 1 + else: + temp_threshold['warning_num'] = 0 + + fancontrol_debug("%s warning_num = %d, critical_num = %d, emergency_num = %d" % + (temp_threshold['name'], temp_threshold['warning_num'], temp_threshold['critical_num'], temp_threshold.get("emergency_num"))) + return + + def get_monitor_temp(self): + sensorlist = self.int_case.get_temp_info() + + for temp_threshold in self.__temps_threshold_config.values(): + sensor = sensorlist.get(temp_threshold['name']) + if sensor["Value"] is None or int(sensor["Value"]) == self.int_case.error_ret: + temp_threshold['fail_num'] += 1 + fancontrol_error("get %s failed, fail_num = %d" % (temp_threshold['name'], temp_threshold['fail_num'])) + else: + temp_threshold['fail_num'] = 0 + temp_threshold.setdefault('fix', 0) + temp_threshold['temp'] = sensor["Value"] + temp_threshold['fix'] + fancontrol_debug("%s = %d" % (temp_threshold['name'], temp_threshold['temp'])) + self.update_over_temp_threshold_num() + + def is_temp_warning(self): + warning_flag = False + for temp_threshold in self.__temps_threshold_config.values(): + if temp_threshold['ignore_threshold']: + continue + if temp_threshold['warning_num'] >= self.__temp_warning_num: + warning_flag = True + fancontrol_debug("%s is over warning" % temp_threshold['name']) + fancontrol_debug("%s = %d, warning = %s" % + (temp_threshold['name'], temp_threshold['temp'], temp_threshold.get('warning'))) + return warning_flag + + def checkTempWarning(self): + try: + if self.is_temp_warning(): + self.__warning_countdown = self.__temp_warning_countdown + fancontrol_debug("temp is over warning") + return True + else: + if self.__warning_countdown > 0: + self.__warning_countdown -= 1 + return False + except Exception as e: + fancontrol_error("%%policy: checkTempWarning failed") + fancontrol_error(str(e)) + return False + + def checkTempWarningCountdown(self): + if self.__warning_countdown > 0: + return True + return False + + def is_temp_critical(self): + critical_flag = False + for temp_threshold in self.__temps_threshold_config.values(): + temp_threshold['critical_flag'] = False + if temp_threshold['ignore_threshold']: + continue + if temp_threshold['critical_num'] >= self.__temp_critical_num: + critical_flag = True + temp_threshold['critical_flag'] = True + fancontrol_debug("%s is over critical" % temp_threshold['name']) + fancontrol_debug("%s = %d, critical = %s" % + (temp_threshold['name'], temp_threshold['temp'], temp_threshold.get('critical'))) + return critical_flag + + def checkTempCritical(self): + try: + if self.is_temp_critical(): + self.__critical_countdown = self.__temp_critical_countdown + fancontrol_debug("temp is over critical") + return True + else: + if self.__critical_countdown > 0: + self.__critical_countdown -= 1 + return False + except Exception as e: + fancontrol_error("%%policy: checkTempCrit failed") + fancontrol_error(str(e)) + return False + + def is_temp_emergency(self): + emergency_flag = False + for temp_threshold in self.__temps_threshold_config.values(): + temp_threshold['emergency_flag'] = False + if temp_threshold['ignore_threshold']: + continue + if temp_threshold['emergency_num'] >= self.__temp_emergency_num: + emergency_flag = True + temp_threshold['emergency_flag'] = True + fancontrol_debug("%s is over emergency" % temp_threshold['name']) + fancontrol_debug("%s = %d, emergency = %s" % + (temp_threshold['name'], temp_threshold['temp'], temp_threshold.get('emergency'))) + return emergency_flag + + + def checkTempEmergency(self): + try: + if self.is_temp_emergency(): + self.__emergency_countdown = self.__temp_emergency_countdown + fancontrol_debug("temp is over emergency") + return True + else: + if self.__emergency_countdown > 0: + self.__emergency_countdown -= 1 + return False + except Exception as e: + fancontrol_error("%%policy: checkTempEmergency failed") + fancontrol_error(str(e)) + return False + + def checkTempCriticalCountdown(self): + if self.__critical_countdown > 0: + return True + return False + + def checkTempEmergencyCountdown(self): + if self.__emergency_countdown > 0: + return True + return False + + def checkTempRebootCrit(self): + try: + if self.is_temp_critical(): + temp_dict = dict(self.__temps_threshold_config) + tmp = temp_dict.get(SWITCH_TEMP) + if tmp['critical_flag'] == True: + fancontrol_debug("switch temp is over reboot critical") + return True + del temp_dict[SWITCH_TEMP] + for temp_items in temp_dict.values(): + if temp_items['ignore_threshold']: + continue + if temp_items['critical_flag'] == False: + return False + + fancontrol_debug("other temp is over reboot critical") + return True + except Exception as e: + fancontrol_error("%%policy: checkTempRebootCrit failed") + fancontrol_error(str(e)) + return False + + def checkCritReboot(self): + try: + reboot_flag = False + if self.checkTempRebootCrit() == True: + self.set_all_fan_speed_pwm(self.__max_pwm) + for i in range(self.__check_crit_reboot_num): + time.sleep(self.__check_crit_sleep_time) + self.get_monitor_temp() + if self.checkTempRebootCrit() == True: + fancontrol_debug("The temperature of device is over reboot critical value.") + reboot_flag = True + continue + else: + fancontrol_debug("The temperature of device is not over reboot critical value.") + reboot_flag = False + break + if reboot_flag is True: + reboot_log = "The temperature of device is over critical value." + reboot_log_cmd = "echo '%s' > /dev/ttyS0" % reboot_log + fancontrol_error(reboot_log) + exec_os_cmd(reboot_log_cmd) + reboot_log = "The system is going to reboot now." + reboot_log_cmd = "echo '%s' > /dev/ttyS0" % reboot_log + fancontrol_error(reboot_log) + exec_os_cmd(reboot_log_cmd) + for temp_threshold in self.__temps_threshold_config.values(): + fancontrol_error("%s = %d" % (temp_threshold['name'], temp_threshold['temp'])) + create_judge_file = "touch %s" % OTP_REBOOT_JUDGE_FILE + exec_os_cmd(create_judge_file) + exec_os_cmd("sync") + time.sleep(3) + os.system("/sbin/reboot") + except Exception as e: + fancontrol_error("%%policy: checkCritReboot failed") + fancontrol_error(str(e)) + + def checkTempRebootEmerg(self): + try: + if self.is_temp_emergency(): + temp_emerg_reboot_flag = False + for temp_list in self.__check_temp_emergency_reboot: + for temp in temp_list: + tmp = self.__temps_threshold_config.get(temp) + if tmp['emergency_flag'] is False: + fancontrol_debug("temp_list %s, temp: %s not emergency" % (temp_list, temp)) + temp_emerg_reboot_flag = False + break + temp_emerg_reboot_flag = True + if temp_emerg_reboot_flag is True: + fancontrol_debug("temp_list %s, all temp is over emergency reboot" % temp_list) + return True + except Exception as e: + fancontrol_error("%%policy: checkTempRebootEmerg failed") + fancontrol_error(str(e)) + return False + + def checkEmergReboot(self): + try: + reboot_flag = False + if self.checkTempRebootEmerg() is True: + self.set_all_fan_speed_pwm(self.__max_pwm) + for i in range(self.__check_emerg_reboot_num): + time.sleep(self.__check_emerg_sleep_time) + self.get_monitor_temp() + if self.checkTempRebootEmerg() is True: + fancontrol_debug("The temperature of device is over reboot emergency value, i = %d" % (i+1)) + reboot_flag = True + continue + else: + fancontrol_debug("The temperature of device is not over reboot emergency value.") + reboot_flag = False + break + if reboot_flag is True: + reboot_log = "The temperature of device is over emergency value." + reboot_log_cmd = "echo '%s' > /dev/ttyS0" % reboot_log + fancontrol_error(reboot_log) + exec_os_cmd(reboot_log_cmd) + reboot_log = "The system is going to reboot now." + reboot_log_cmd = "echo '%s' > /dev/ttyS0" % reboot_log + fancontrol_error(reboot_log) + exec_os_cmd(reboot_log_cmd) + for temp_threshold in self.__temps_threshold_config.values(): + fancontrol_error("%s = %d" % (temp_threshold['name'], temp_threshold['temp'])) + create_judge_file = "touch %s" % OTP_REBOOT_JUDGE_FILE + exec_os_cmd(create_judge_file) + exec_os_cmd("sync") + time.sleep(3) + os.system("/sbin/reboot") + except Exception as e: + fancontrol_error("%%policy: checkEmergReboot failed") + fancontrol_error(str(e)) + + def get_fan_total_number(self): + return self.int_case.get_fan_total_number() + + def get_rotor_number(self, fan_name): + return self.int_case.get_fan_rotor_number(fan_name) + + def get_fan_presence(self, fan_name): + return self.int_case.get_fan_presence(fan_name) + + def get_fan_rotor_status(self, fan_name, rotor_name): + return self.int_case.get_fan_rotor_status(fan_name, rotor_name) + + def get_psu_total_number(self): + return self.int_case.get_psu_total_number() + + def get_psu_presence(self, psu_name): + return self.int_case.get_psu_presence(psu_name) + + def get_psu_input_output_status(self, psu_name): + return self.int_case.get_psu_input_output_status(psu_name) + + def checkFanPresence(self): + absent_num = 0 + + fan_num = self.get_fan_total_number() + for i in range(fan_num): + fan_name = "FAN" + str(i + 1) + rotor_num = self.get_rotor_number(fan_name) + tmp_fan = self.__fan_rotor_error_num.get(fan_name) + status = self.get_fan_presence(fan_name) + if status == False: + absent_num = absent_num + 1 + self.__fan_present_status[fan_name] = 0 + fancontrol_debug("%s absent" % fan_name) + else: + if self.__fan_present_status[fan_name] == 0: # absent -> present + self.__pre_fan_nok = PRE_FAN_NOK_UNKNOWN + self.__fan_plug_in_countdown = self.__fan_plug_in_default_countdown + self.__fan_repair_flag[fan_name] = 1 + for j in range(rotor_num): + rotor_name = "Rotor" + str(j + 1) + tmp_fan[rotor_name] = 0 + self.__fan_present_status[fan_name] = 1 + fancontrol_debug("%s presence" % fan_name) + return absent_num + + def checkFanRotorStatus(self): + err_num = 0 + self.__fan_nok_num = 0 + fan_num = self.get_fan_total_number() + for i in range(fan_num): + fan_name = "FAN" + str(i + 1) + rotor_num = self.get_rotor_number(fan_name) + tmp_fan = self.__fan_rotor_error_num.get(fan_name) + fan_rotor_err_cnt = 0 + for j in range(rotor_num): + rotor_name = "Rotor" + str(j + 1) + status = self.get_fan_rotor_status(fan_name, rotor_name) + if status == True: + tmp_fan[rotor_name] = 0 + fancontrol_debug("%s %s ok" % (fan_name, rotor_name)) + else: + tmp_fan[rotor_name] += 1 + if tmp_fan[rotor_name] >= self.__rotor_error_count: + err_num = err_num + 1 + fan_rotor_err_cnt += 1 + fancontrol_debug("%s %s error" % (fan_name, rotor_name)) + fancontrol_debug("%s %s error %d times" % (fan_name, rotor_name, tmp_fan[rotor_name])) + if fan_rotor_err_cnt == 0: + self.__fan_rotate_status[fan_name] = 1 # FAN is ok + else: + self.__fan_rotate_status[fan_name] = 0 # FAN is not ok + self.__fan_nok_num += 1 + fancontrol_debug("fan not ok number:%d." % self.__fan_nok_num) + return err_num + + def checkPsuPresence(self): + absent_num = 0 + psu_num = self.get_psu_total_number() + for i in range(psu_num): + psu_name = "PSU" + str(i + 1) + status = self.get_psu_presence(psu_name) + if status == False: + absent_num = absent_num + 1 + fancontrol_debug("%s absent" % psu_name) + else: + fancontrol_debug("%s presence" % psu_name) + return absent_num + + def checkPsuStatus(self): + err_num = 0 + psu_num = self.get_psu_total_number() + for i in range(psu_num): + psu_name = "PSU" + str(i + 1) + status = self.get_psu_input_output_status(psu_name) + if status == False: + err_num = err_num + 1 + fancontrol_debug("%s error" % psu_name) + else: + fancontrol_debug("%s ok" % psu_name) + return err_num + + def checkDevError(self): + pwm = self.__min_pwm + switchtemp = self.__temps_threshold_config.get(SWITCH_TEMP)['temp'] + inlettemp = self.__temps_threshold_config.get(INLET_TEMP)['temp'] + temp_diff = abs(switchtemp - inlettemp) + fancontrol_debug("|switchtemp - inlettemp| = %d" % temp_diff) + if temp_diff >= self.__inlet_mac_diff: + fancontrol_debug("temp_diff is over than inlet_mac_diff(%d)" % self.__inlet_mac_diff) + if self.__pwm > self.__abnormal_pwm: + pwm = self.__max_pwm + else: + pwm = self.__abnormal_pwm + return pwm + + def checktempfail(self): + pwm = self.__min_pwm + for temp in self.__check_temp_fail: + temp_name = temp.get("temp_name") + temp_fail_num = self.__temps_threshold_config.get(temp_name)['fail_num'] + if temp_fail_num >= self.__temp_fail_num: + pwm = self.__abnormal_pwm + fancontrol_debug("%s temp_fail_num = %d" % (temp_name, temp_fail_num)) + fancontrol_debug("self.__temp_fail_num = %d" % self.__temp_fail_num) + return pwm + + def abnormal_check(self): + pwm_list = [] + pwm_min = self.__min_pwm + pwm_list.append(pwm_min) + + if self.__check_temp_emergency == 1: + status = self.checkTempEmergency() + if status is True: + over_emerg_pwm = self.__max_pwm + pwm_list.append(over_emerg_pwm) + fancontrol_debug("over_emerg_pwm = 0x%x" % over_emerg_pwm) + # do reset check + if self.__check_emerg_reboot_flag == 1: + self.checkEmergReboot() + else: + if self.checkTempEmergencyCountdown() == True: # temp lower than emergency in 5 min + over_emerg_countdown_pwm = self.__max_pwm + pwm_list.append(over_emerg_countdown_pwm) + fancontrol_debug("TempEmergencyCountdown: %d, over_emerg_countdown_pwm = 0x%x" % + (self.__emergency_countdown, over_emerg_countdown_pwm)) + + if self.__check_temp_critical == 1: + status = self.checkTempCritical() + if status == True: + over_crit_pwm = self.__max_pwm + pwm_list.append(over_crit_pwm) + fancontrol_debug("over_crit_pwm = 0x%x" % over_crit_pwm) + # do reset check + if self.__check_crit_reboot_flag == 1: + self.checkCritReboot() + else: + if self.checkTempCriticalCountdown() == True: # temp lower than critical in 5 min + over_crit_countdown_pwm = self.__max_pwm + pwm_list.append(over_crit_countdown_pwm) + fancontrol_debug("TempCriticalCountdown: %d, over_crit_countdown_pwm = 0x%x" % + (self.__critical_countdown, over_crit_countdown_pwm)) + + if self.__check_temp_warning == 1: + status = self.checkTempWarning() + if status == True: + over_warn_pwm = self.__warning_pwm + pwm_list.append(over_warn_pwm) + fancontrol_debug("over_warn_pwm = 0x%x" % over_warn_pwm) + else: + if self.checkTempWarningCountdown() == True: # temp lower than warning in 5 min + over_warn_countdown_pwm = self.__warning_pwm + pwm_list.append(over_warn_countdown_pwm) + fancontrol_debug("TempWarningCountdown: %d, over_warn_countdown_pwm = 0x%x" % + (self.__warning_countdown, over_warn_countdown_pwm)) + + self.__fan_absent_num = self.checkFanPresence() + if self.__fan_absent_num >= self.__fan_absent_fullspeed_num: + fan_absent_pwm = self.__max_pwm + pwm_list.append(fan_absent_pwm) + fancontrol_debug("fan_absent_pwm = 0x%x" % fan_absent_pwm) + + rotor_err_num = self.checkFanRotorStatus() + if rotor_err_num >= self.__rotor_error_fullspeed_num: + rotor_err_pwm = self.__max_pwm + pwm_list.append(rotor_err_pwm) + fancontrol_debug("rotor_err_pwm = 0x%x" % rotor_err_pwm) + + psu_absent_num = self.checkPsuPresence() + if psu_absent_num >= self.__psu_absent_fullspeed_num: + psu_absent_pwm = self.__max_pwm + pwm_list.append(psu_absent_pwm) + fancontrol_debug("psu_absent_pwm = 0x%x" % psu_absent_pwm) + + dev_err_pwm = self.checkDevError() + pwm_list.append(dev_err_pwm) + fancontrol_debug("dev_err_pwm = 0x%x" % dev_err_pwm) + + temp_fail_pwm = self.checktempfail() + pwm_list.append(temp_fail_pwm) + fancontrol_debug("temp_fail_pwm = 0x%x" % temp_fail_pwm) + + pwm = max(pwm_list) + return pwm + + def get_error_fan(self): + fan_num = self.get_fan_total_number() + for i in range(fan_num): + fan_name = "FAN" + str(i + 1) + if self.__fan_rotate_status[fan_name] == 0: + return fan_name + return None + + def fan_error_update_pwm(self, fan_pwm_dict): + try: + fancontrol_debug("enter deal fan error policy") + ori_fan_pwm_dict = fan_pwm_dict.copy() + + err_fan_name = self.get_error_fan() + if err_fan_name is None: + fancontrol_debug("fan name is None, do nothing.") + return ori_fan_pwm_dict + + if self.__fan_repair_flag[err_fan_name] == 0: + fancontrol_debug("%s already repaired, do nothing." % err_fan_name) + return ori_fan_pwm_dict + + if self.__pre_fan_nok != err_fan_name: + fancontrol_debug( + "not ok fan change from %s to %s, update countdown." % + (self.__pre_fan_nok, err_fan_name)) + self.__deal_fan_error_countdown = self.__deal_fan_error_default_countdown + if self.__pre_fan_nok != PRE_FAN_NOK_UNKNOWN: + fancontrol_debug( + "%s repaire success, %s NOT OK, try to repaire." % + (self.__pre_fan_nok, err_fan_name)) + self.__fan_repair_flag[self.__pre_fan_nok] = 0 + self.__pre_fan_nok = err_fan_name + + if self.__deal_fan_error_countdown > 0: + self.__deal_fan_error_countdown -= 1 + fancontrol_debug("%s repaire, countdown %d." % (err_fan_name, self.__deal_fan_error_countdown)) + + if self.__deal_fan_error_countdown == 0: + self.__fan_repair_flag[err_fan_name] = 0 + fancontrol_debug("%s set repaire fail flag, use origin pwm." % err_fan_name) + return ori_fan_pwm_dict + + fan_err_pwm_conf_list = self.__deal_fan_error_conf[err_fan_name] + for item in fan_err_pwm_conf_list: + fan_pwm_dict[item["name"]] = item["pwm"] + fancontrol_debug("fan pwm update, fan pwm dict:%s" % fan_pwm_dict) + + return fan_pwm_dict + except Exception as e: + fancontrol_error("%%policy: deal_fan_error raise Exception:%s" % str(e)) + self.__pre_fan_nok = PRE_FAN_NOK_UNKNOWN + return ori_fan_pwm_dict + + def get_fan_pwm_dict(self, default_pwm): + fan_pwm_dict = {} + fan_num = self.get_fan_total_number() + for i in range(fan_num): + fan_name = "FAN" + str(i + 1) + fan_pwm_dict[fan_name] = default_pwm + if self.__deal_fan_error_policy: + if self.__fan_absent_num == 0 and self.__fan_nok_num == 1: + fan_pwm_dict = self.fan_error_update_pwm(fan_pwm_dict) + else: + if self.__pre_fan_nok != PRE_FAN_NOK_UNKNOWN and self.__fan_rotate_status[self.__pre_fan_nok] == 1: + fancontrol_debug("%s repaire success." % (self.__pre_fan_nok)) + self.__fan_repair_flag[self.__pre_fan_nok] = 0 + self.__pre_fan_nok = PRE_FAN_NOK_UNKNOWN + return fan_pwm_dict + + def check_board_air_flow(self): + board_air_flow = self.board_air_flow + if board_air_flow != F2B_AIR_FLOW and board_air_flow != B2F_AIR_FLOW: + fanairflow_debug("get board air flow error, value [%s]" % board_air_flow) + return False + fanairflow_debug("board air flow check ok: %s" % board_air_flow) + return True + + def check_fan_air_flow(self): + if self.fan_air_flow_monitor: + fanairflow_debug("open air flow monitor, check fan air flow") + ret = self.check_board_air_flow() + if ret is False: + fanairflow_debug("get board air flow error, set air_flow_inconsistent_flag False") + self.air_flow_inconsistent_flag = False + return + air_flow_inconsistent_flag_tmp = False + for fan_obj in self.fan_obj_list: + fan_obj.update_fru_info() + fanairflow_debug("%s origin name: [%s], display name: [%s] air flow [%s]" % + (fan_obj.name, fan_obj.origin_name, fan_obj.display_name, fan_obj.air_flow)) + if fan_obj.air_flow == self.na_ret: + fanairflow_debug("%s get air flow failed, set air_flow_inconsistent flag False" % fan_obj.name) + fan_obj.air_flow_inconsistent = False + continue + if fan_obj.air_flow != self.board_air_flow: + fanairflow_debug("%s air flow error, origin name: [%s], display name: [%s], fan air flow [%s], board air flow [%s]" % + (fan_obj.name, fan_obj.origin_name, fan_obj.display_name, fan_obj.air_flow, self.board_air_flow)) + air_flow_inconsistent_flag_tmp = True + fan_obj.air_flow_inconsistent = True + else: + fanairflow_debug("%s air flow check ok, origin name: [%s], display name: [%s], fan air flow: [%s], board air flow: [%s]" % + (fan_obj.name, fan_obj.origin_name, fan_obj.display_name, fan_obj.air_flow, self.board_air_flow)) + fan_obj.air_flow_inconsistent = False + self.air_flow_inconsistent_flag = air_flow_inconsistent_flag_tmp + else: + fanairflow_debug("air flow monitor not open, set air_flow_inconsistent_flag False") + self.air_flow_inconsistent_flag = False + return + + def do_fancontrol(self): + pwm_list = [] + pwm_min = self.__min_pwm + pwm_list.append(pwm_min) + + # first check fan air flow + self.check_fan_air_flow() + fanairflow_debug("check_fan_air_flow, air_flow_inconsistent_flag: %s" % self.air_flow_inconsistent_flag) + # get_monitor_temp + self.get_monitor_temp() + fancontrol_debug("last_pwm = 0x%x" % self.__pwm) + # openloop + inlettemp = self.__temps_threshold_config.get(INLET_TEMP)['temp'] + linear_value = self.openloop.linear_cacl(inlettemp) + if linear_value is None: + linear_value = self.__min_pwm + pwm_list.append(linear_value) + fancontrol_debug("linear_value = 0x%x" % linear_value) + + curve_value = self.openloop.curve_cacl(inlettemp) + if curve_value is None: + curve_value = self.__min_pwm + pwm_list.append(curve_value) + fancontrol_debug("curve_value = 0x%x" % curve_value) + + # hyst + for hyst_index in self.__hyst_config.values(): + temp_name = hyst_index['name'] + tmp_temp = int(self.__temps_threshold_config.get(temp_name)['temp']) # make sure temp is int + hyst_value = self.hyst.cacl(temp_name, tmp_temp) + if hyst_value is None: + hyst_value = self.__min_pwm + pwm_list.append(hyst_value) + fancontrol_debug("%s hyst_value = 0x%x" % (temp_name, hyst_value)) + + # pid + for pid_index in self.__pid_config.values(): + temp_name = pid_index['name'] + tmp_temp = self.__temps_threshold_config.get(temp_name)['temp'] + if tmp_temp is not None: + tmp_temp = int(tmp_temp) # make sure temp is int + invalid_temp = self.__temps_threshold_config.get(temp_name)['invalid'] + error_temp = self.__temps_threshold_config.get(temp_name)['error'] + if tmp_temp == invalid_temp: # temp is invalid + temp = None + self.pid.cacl(self.__pwm, temp_name, temp) # temp invalid, PID need to record None + pid_value = self.__temp_invalid_pid_pwm + fancontrol_debug("%s is invalid, pid_value = 0x%x" % (temp_name, pid_value)) + fancontrol_debug("temp = %d, invalid_temp = %d" % (tmp_temp, invalid_temp)) + elif tmp_temp == error_temp: # temp is error + temp = None + self.pid.cacl(self.__pwm, temp_name, temp) # temp error, PID need to record None + pid_value = self.__temp_error_pid_pwm + fancontrol_debug("%s is error, pid_value = 0x%x" % (temp_name, pid_value)) + fancontrol_debug("temp = %d, error_temp = %d" % (tmp_temp, error_temp)) + else: + pid_value = self.pid.cacl(self.__pwm, temp_name, tmp_temp) + else: # temp get failed + pid_value = self.pid.cacl(self.__pwm, temp_name, tmp_temp) + if pid_value is None: + pid_value = self.__min_pwm + pwm_list.append(pid_value) + fancontrol_debug("%s pid_value = 0x%x" % (temp_name, pid_value)) + + # abnormal + abnormal_value = self.abnormal_check() + pwm_list.append(abnormal_value) + fancontrol_debug("abnormal_value = 0x%x" % abnormal_value) + + if self.__fan_plug_in_countdown > 0 and self.__fan_absent_num == 0: + fancontrol_debug("fan plug in countdown %d, set plug in pwm: 0x%x" % + (self.__fan_plug_in_countdown, self.__fan_plug_in_pwm)) + self.__pwm = self.__fan_plug_in_pwm + self.__fan_plug_in_countdown -= 1 + else: + self.__pwm = max(pwm_list) + fancontrol_debug("__pwm = 0x%x\n" % self.__pwm) + if self.air_flow_inconsistent_flag is True: + fanairflow_debug("air flow inconsistent, set all fan speed pwm") + self.set_all_fan_speed_pwm(self.__pwm) + else: + fanairflow_debug("air flow consistent, deal fan error policy") + fan_pwm_dict = self.get_fan_pwm_dict(self.__pwm) + self.set_fan_pwm_independent(fan_pwm_dict, self.__pwm) + + def run(self): + start_time = time.time() + while True: + try: + debug_init() + if self.__fan_status_interval > 0 and self.__fan_status_interval < self.__interval: + delta_time = time.time() - start_time + if delta_time >= self.__interval or delta_time < 0: + self.do_fancontrol() + start_time = time.time() + else: + self.checkFanPresence() + time.sleep(self.__fan_status_interval) + else: + self.do_fancontrol() + time.sleep(self.__interval) + except Exception as e: + traceback.print_exc() + fancontrol_error(str(e)) + + def set_all_fan_speed_pwm(self, pwm): + fan_pwm_dict = {} + fan_num = self.get_fan_total_number() + for i in range(fan_num): + fan_name = "FAN" + str(i + 1) + fan_pwm_dict[fan_name] = pwm + self.set_fan_pwm_independent(fan_pwm_dict, pwm) + + def set_fan_pwm_independent(self, fan_pwm_dict, psu_fan_pwm): + if self.air_flow_inconsistent_flag is True: + psu_fan_pwm = self.air_flow_error_psu_pwm + fancontrol_debug("air flow inconsistent, set psu fan pwm: 0x%x" % psu_fan_pwm) + for fan_obj in self.fan_obj_list: + if fan_obj.air_flow_inconsistent is True: + fan_pwm_dict[fan_obj.name] = self.air_flow_error_fan_pwm + fanairflow_debug("%s air flow error, origin name: [%s], display name: [%s], fan air flow: [%s], board air flow: [%s], set fan pwm: 0x%x" % + (fan_obj.name, fan_obj.origin_name, fan_obj.display_name, fan_obj.air_flow, self.board_air_flow, self.air_flow_error_fan_pwm)) + else: + fan_pwm_dict[fan_obj.name] = self.air_flow_correct_fan_pwm + fanairflow_debug("%s air flow correct, origin name: [%s], display name: [%s], fan air flow: [%s], board air flow: [%s], set fan pwm: 0x%x" % + (fan_obj.name, fan_obj.origin_name, fan_obj.display_name, fan_obj.air_flow, self.board_air_flow, self.air_flow_correct_fan_pwm)) + fan_num = self.get_fan_total_number() + for i in range(fan_num): + fan_name = "FAN" + str(i + 1) + self.fan_set_speed_pwm_by_name(fan_name, fan_pwm_dict[fan_name]) + if self.__psu_fan_control == 1: + self.set_psu_fan_speed_pwm(psu_fan_pwm) + + def get_fans(self): + return self.int_case.get_fans() + + def get_speed(self, fan_name, rotor_index): + return self.int_case.get_fan_speed(fan_name, rotor_index) + + def get_speed_pwm(self, fan_name, rotor_index): + return self.int_case.get_fan_speed_pwm(fan_name, rotor_index) + + def fan_get_speed_pwm(self): + fans = self.get_fans() + for fan in fans: + rotor_len = self.get_rotor_number(fan.name) + for i in range(rotor_len): + fancontrol_debug("%s rotor%d: %d" % (fan.name, i + 1, self.get_speed_pwm(fan.name, i + 1))) + + def fan_set_speed_pwm_by_name(self, fan_name, pwm): + duty = round(pwm * 100 / 255) + rotor_len = self.get_rotor_number(fan_name) + for i in range(rotor_len): + val = self.int_case.set_fan_speed_pwm(fan_name, i + 1, duty) + if val != 0: + fancontrol_error("%s rotor%d: %d" % (fan_name, i + 1, val)) + + def set_psu_fan_speed_pwm(self, pwm): + duty = round(pwm * 100 / 255) + psu_num = self.get_psu_total_number() + for i in range(psu_num): + psu_name = "PSU" + str(i + 1) + status = self.int_case.set_psu_fan_speed_pwm(psu_name, int(duty)) + if status != True: + fancontrol_error("set %s speed fail" % psu_name) + + def fan_obj_init(self): + fan_num = self.get_fan_total_number() + for i in range(fan_num): + fan_name = "FAN" + str(i + 1) + fan_obj = DevFan(fan_name, self.int_case) + self.fan_obj_list.append(fan_obj) + fanairflow_debug("fan object initialize success") + + +if __name__ == '__main__': + debug_init() + fancontrol_debug("enter main") + fan_control = fancontrol() + fan_control.fan_obj_init() + fan_control.run() diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/script/hal_ledctrl.py b/platform/broadcom/sonic-platform-modules-tencent/common/script/hal_ledctrl.py new file mode 100755 index 000000000000..223b4e2ba437 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/script/hal_ledctrl.py @@ -0,0 +1,792 @@ +#!/usr/bin/env python3 +import time +import syslog +import traceback +from plat_hal.interface import interface +from plat_hal.baseutil import baseutil +try: + import abc +except ImportError as e: + raise ImportError (str(e) + " - required module not found") + +SWITCH_TEMP = "SWITCH_TEMP" +F2B_AIR_FLOW = "F2B" +B2F_AIR_FLOW = "B2F" +ONIE_E2_NAME = "ONIE_E2" + +# status +STATUS_PRESENT = "PRESENT" +STATUS_ABSENT = "ABSENT" +STATUS_OK = "OK" +STATUS_NOT_OK = "NOT OK" +STATUS_FAILED = "FAILED" +STATUS_UNKNOWN = "UNKNOWN" + +LEDCTROL_DEBUG_FILE = "/etc/.ledcontrol_debug_flag" + +LEDCTROLERROR = 1 +LEDCTROLDEBUG = 2 + +debuglevel = 0 +# led status defined +COLOR_GREEN = 1 +COLOR_YELLOW = 2 +COLOR_RED = 3 +LED_STATUS_DICT = {COLOR_GREEN: "green", COLOR_YELLOW: "yellow", COLOR_RED: "red"} + + +def ledcontrol_debug(s): + if LEDCTROLDEBUG & debuglevel: + syslog.openlog("LEDCONTROL", syslog.LOG_PID) + syslog.syslog(syslog.LOG_DEBUG, s) + + +def ledcontrol_error(s): + if LEDCTROLERROR & debuglevel: + syslog.openlog("LEDCONTROL", syslog.LOG_PID) + syslog.syslog(syslog.LOG_ERR, s) + + +def air_flow_warn(s): + syslog.openlog("AIR_FLOW_MONITOR", syslog.LOG_PID) + syslog.syslog(syslog.LOG_WARNING, s) + + +def air_flow_error(s): + syslog.openlog("AIR_FLOW_MONITOR", syslog.LOG_PID) + syslog.syslog(syslog.LOG_ERR, s) + + +def debug_init(): + global debuglevel + try: + with open(LEDCTROL_DEBUG_FILE, "r") as fd: + value = fd.read() + debuglevel = int(value) + except Exception as e: + debuglevel = 0 + + +class DevBase(object): + __metaclass__ = abc.ABCMeta + + def __init__(self, name, air_flow_monitor): + self.__name = name + self.__air_flow_monitor = air_flow_monitor + self.present = STATUS_UNKNOWN + self.status = STATUS_UNKNOWN + self.status_summary = STATUS_UNKNOWN + self.origin_name = STATUS_UNKNOWN + self.display_name = STATUS_UNKNOWN + self.air_flow = STATUS_UNKNOWN + self.led_status = COLOR_GREEN + + @property + def name(self): + return self.__name + + @property + def air_flow_monitor(self): + return self.__air_flow_monitor + + @abc.abstractmethod + def get_present(self): + """ + Gets the present status of PSU/FAN + + Returns: + A string, e.g. 'PRESENT, ABSENT, FAILED' + """ + raise NotImplementedError + + @abc.abstractmethod + def get_status(self): + """ + Gets the status of PSU/FAN + + Returns: + A string, e.g. 'OK, NOT OK, FAILED' + """ + raise NotImplementedError + + @abc.abstractmethod + def update_dev_info(self): + """ + update status and fru info of PSU/FAN + + include present, status, status_summary, part_model_name, product_name, air_flow + """ + raise NotImplementedError + + @abc.abstractmethod + def set_module_led(self, color): + """ + set PSU/FAN module LED status + + Args: + color: A string representing the color with which to set the + PSU/FAN module LED status + + Returns: + bool: True if status LED state is set successfully, False if not + """ + raise NotImplementedError + + +class DevPsu(DevBase): + + def __init__(self, name, air_flow_monitor, interface): + super(DevPsu, self).__init__(name, air_flow_monitor) + self.int_case = interface + + def get_psu_presence(self): + return self.int_case.get_psu_presence(self.name) + + def get_psu_input_output_status(self): + return self.int_case.get_psu_input_output_status(self.name) + + def get_psu_fru_info(self): + return self.int_case.get_psu_fru_info(self.name) + + @property + def na_ret(self): + return self.int_case.na_ret + + def get_present(self): + try: + status = self.get_psu_presence() + if status is True: + return STATUS_PRESENT + if status is False: + return STATUS_ABSENT + except Exception as e: + ledcontrol_error("get %s present status error, msg: %s" % (self.name, str(e))) + return STATUS_FAILED + + def get_status(self): + try: + status = self.get_psu_input_output_status() + if status is True: + return STATUS_OK + if status is False: + return STATUS_NOT_OK + except Exception as e: + ledcontrol_error("get %s status error, msg: %s" % (self.name, str(e))) + return STATUS_FAILED + + def update_dev_info(self): + try: + # update status + self.present = self.get_present() + if self.present != STATUS_PRESENT: + self.status = STATUS_UNKNOWN + self.status_summary = self.present + else: + self.status = self.get_status() + self.status_summary = self.status + # update fru info if need air flow monitor + if self.air_flow_monitor: + dic = self.get_psu_fru_info() + self.origin_name = dic["PN"] + self.air_flow = dic["AirFlow"] + self.display_name = dic["DisplayName"] + except Exception as e: + ledcontrol_error("update %s info error, msg: %s" % (self.name, str(e))) + self.present = STATUS_FAILED + self.status = STATUS_FAILED + self.status_summary = STATUS_FAILED + self.origin_name = self.na_ret + self.air_flow = self.na_ret + self.display_name = self.na_ret + + def set_module_led(self, color): + """ + set PSU module LED is not support, always return True + """ + return True + + +class DevFan(DevBase): + + def __init__(self, name, air_flow_monitor, interface): + super(DevFan, self).__init__(name, air_flow_monitor) + self.int_case = interface + + def get_fan_rotor_number(self): + return self.int_case.get_fan_rotor_number(self.name) + + def get_fan_presence(self): + return self.int_case.get_fan_presence(self.name) + + def get_fan_rotor_status(self, rotor_name): + return self.int_case.get_fan_rotor_status(self.name, rotor_name) + + def get_fan_fru_info(self): + return self.int_case.get_fan_fru_info(self.name) + + @property + def na_ret(self): + return self.int_case.na_ret + + def get_present(self): + try: + status = self.get_fan_presence() + if status is True: + return STATUS_PRESENT + if status is False: + return STATUS_ABSENT + except Exception as e: + ledcontrol_error("get %s present status error, msg: %s" % (self.name, str(e))) + return STATUS_FAILED + + def get_status(self): + try: + rotor_num = self.get_fan_rotor_number() + err_motor_num = 0 + for j in range(rotor_num): + rotor_name = "Rotor" + str(j + 1) + roll_status = self.get_fan_rotor_status(rotor_name) + if roll_status is not True: + err_motor_num += 1 + ledcontrol_debug("%s %s error, status %s" % (self.name, rotor_name, roll_status)) + else: + ledcontrol_debug("%s %s ok" % (self.name, rotor_name)) + if err_motor_num > 0: + return STATUS_NOT_OK + return STATUS_OK + except Exception as e: + ledcontrol_error("get %s status error, msg: %s" % (self.name, str(e))) + return STATUS_FAILED + + def update_dev_info(self): + try: + # update status + self.present = self.get_present() + if self.present != STATUS_PRESENT: + self.status = STATUS_UNKNOWN + self.status_summary = self.present + else: + self.status = self.get_status() + self.status_summary = self.status + # update fru info if need air flow monitor + if self.air_flow_monitor: + dic = self.get_fan_fru_info() + self.origin_name = dic["PN"] + self.air_flow = dic["AirFlow"] + self.display_name = dic["DisplayName"] + except Exception as e: + ledcontrol_error("update %s fru info error, msg: %s" % (self.name, str(e))) + self.present = STATUS_FAILED + self.status = STATUS_FAILED + self.status_summary = STATUS_FAILED + self.origin_name = self.na_ret + self.air_flow = self.na_ret + self.display_name = self.na_ret + + def set_module_led(self, color): + ret = self.int_case.set_fan_led(self.name, color) + if ret == 0: + return True + return False + + +class ledcontrol(object): + + def __init__(self): + self.fan_obj_list = [] + self.psu_obj_list = [] + self.board_psu_led_status = COLOR_GREEN + self.board_fan_led_status = COLOR_GREEN + self.__board_air_flow = "" + self.int_case = interface() + self.__config = baseutil.get_monitor_config() + self.__temps_threshold_config = self.__config["temps_threshold"] + for temp_threshold in self.__temps_threshold_config.values(): + temp_threshold['temp'] = 0 + temp_threshold['fail_num'] = 0 + self.__ledcontrol_para = self.__config["ledcontrol_para"] + self.__interval = self.__ledcontrol_para.get("interval", 5) + self.__checkpsu = self.__ledcontrol_para.get("checkpsu", 0) + self.__checkfan = self.__ledcontrol_para.get("checkfan", 0) + self.__psu_yellow_num = self.__ledcontrol_para.get("psu_yellow_num") + self.__fan_yellow_num = self.__ledcontrol_para.get("fan_yellow_num") + self.__board_sys_led = self.__ledcontrol_para.get("board_sys_led", []) + self.__board_psu_led = self.__ledcontrol_para.get("board_psu_led", []) + self.__board_fan_led = self.__ledcontrol_para.get("board_fan_led", []) + self.__psu_air_flow_monitor = self.__ledcontrol_para.get("psu_air_flow_monitor", 0) + self.__fan_air_flow_monitor = self.__ledcontrol_para.get("fan_air_flow_monitor", 0) + self.__fan_mix_list = self.__ledcontrol_para.get("fan_mix_list", []) + + @property + def na_ret(self): + return self.int_case.na_ret + + @property + def checkpsu(self): + return self.__checkpsu + + @property + def checkfan(self): + return self.__checkfan + + @property + def psu_yellow_num(self): + return self.__psu_yellow_num + + @property + def fan_yellow_num(self): + return self.__fan_yellow_num + + @property + def psu_air_flow_monitor(self): + return self.__psu_air_flow_monitor + + @property + def fan_air_flow_monitor(self): + return self.__fan_air_flow_monitor + + @property + def board_sys_led(self): + return self.__board_sys_led + + @property + def board_psu_led(self): + return self.__board_psu_led + + @property + def board_fan_led(self): + return self.__board_fan_led + + @property + def fan_mix_list(self): + return self.__fan_mix_list + + @property + def interval(self): + return self.__interval + + def get_fan_total_number(self): + return self.int_case.get_fan_total_number() + + def get_psu_total_number(self): + return self.int_case.get_psu_total_number() + + def get_onie_e2_obj(self, name): + return self.int_case.get_onie_e2_obj(name) + + def set_led_color(self, led_name, color): + try: + ret = self.int_case.set_led_color(led_name, color) + except Exception as e: + ledcontrol_error("set %s led %s error, msg: %s" % (led_name, color, str(e))) + ret = False + return ret + + def set_sys_led(self, color): + for led in self.board_sys_led: + led_name = led.get("led_name") + ret = self.set_led_color(led_name, color) + if ret is True: + ledcontrol_debug("set %s success, color:%s," % (led_name, color)) + else: + ledcontrol_debug("set %s failed, color:%s," % (led_name, color)) + + def set_psu_led(self, color): + for led in self.board_psu_led: + led_name = led.get("led_name") + ret = self.set_led_color(led_name, color) + if ret is True: + ledcontrol_debug("set %s success, color:%s," % (led_name, color)) + else: + ledcontrol_debug("set %s failed, color:%s," % (led_name, color)) + + def set_fan_led(self, color): + for led in self.board_fan_led: + led_name = led.get("led_name") + ret = self.set_led_color(led_name, color) + if ret is True: + ledcontrol_debug("set %s success, color:%s," % (led_name, color)) + else: + ledcontrol_debug("set %s failed, color:%s," % (led_name, color)) + + def set_fan_module_led(self): + for fan_obj in self.fan_obj_list: + color = LED_STATUS_DICT.get(fan_obj.led_status) + ret = fan_obj.set_module_led(color) + if ret is True: + ledcontrol_debug("set %s module led success, color: %s," % (fan_obj.name, color)) + else: + ledcontrol_debug("set %s module led failed, color: %s," % (fan_obj.name, color)) + + @property + def board_air_flow(self): + if self.__board_air_flow != F2B_AIR_FLOW and self.__board_air_flow != B2F_AIR_FLOW: + onie_e2_obj = self.get_onie_e2_obj(ONIE_E2_NAME) + if onie_e2_obj is not None: + ledcontrol_debug("onie_e2 servicetag: %s" % onie_e2_obj.servicetag) + if isinstance(onie_e2_obj.servicetag, str) and onie_e2_obj.servicetag.startswith("F2B"): + self.__board_air_flow = F2B_AIR_FLOW + elif isinstance(onie_e2_obj.servicetag, str) and onie_e2_obj.servicetag.startswith("B2F"): + self.__board_air_flow = B2F_AIR_FLOW + else: + self.__board_air_flow = onie_e2_obj.servicetag + ledcontrol_debug("board_air_flow: %s" % self.__board_air_flow) + return self.__board_air_flow + + def update_psu_info(self): + for psu_obj in self.psu_obj_list: + psu_obj.update_dev_info() + ledcontrol_debug("%s present: [%s], status: [%s] status_summary [%s]" % + (psu_obj.name, psu_obj.present, psu_obj.status, psu_obj.status_summary)) + if psu_obj.air_flow_monitor: + ledcontrol_debug("%s origin name: [%s], display name: [%s] air flow [%s]" % + (psu_obj.name, psu_obj.origin_name, psu_obj.display_name, psu_obj.air_flow)) + + def update_fan_info(self): + for fan_obj in self.fan_obj_list: + fan_obj.update_dev_info() + ledcontrol_debug("%s present: [%s], status: [%s] status_summary [%s]" % + (fan_obj.name, fan_obj.present, fan_obj.status, fan_obj.status_summary)) + if fan_obj.air_flow_monitor: + ledcontrol_debug("%s origin name: [%s], display name: [%s] air flow [%s]" % + (fan_obj.name, fan_obj.origin_name, fan_obj.display_name, fan_obj.air_flow)) + + def get_monitor_temp(self): + sensorlist = self.int_case.get_temp_info() + + for temp_threshold in self.__temps_threshold_config.values(): + sensor = sensorlist.get(temp_threshold['name']) + if sensor["Value"] is None: + temp_threshold['fail_num'] += 1 + ledcontrol_error("get %s failed, fail_num = %d" % (temp_threshold['name'], temp_threshold['fail_num'])) + else: + temp_threshold['fail_num'] = 0 + temp_threshold.setdefault('fix', 0) + temp_threshold['temp'] = sensor["Value"] + temp_threshold['fix'] + ledcontrol_debug("%s = %d" % (temp_threshold['name'], temp_threshold['temp'])) + ledcontrol_debug("warning = %d, critical = %d" % (temp_threshold['warning'], temp_threshold['critical'])) + + def is_temp_warning(self): + warning_flag = False + for temp_threshold in self.__temps_threshold_config.values(): + if temp_threshold['temp'] >= temp_threshold['warning']: + warning_flag = True + ledcontrol_debug("%s is over warning" % temp_threshold['name']) + ledcontrol_debug( + "%s = %d, warning = %d" % + (temp_threshold['name'], + temp_threshold['temp'], + temp_threshold['warning'])) + return warning_flag + + def checkTempWarning(self): + try: + if self.is_temp_warning(): + ledcontrol_debug("temp is over warning") + return True + except Exception as e: + ledcontrol_error("%%policy: checkTempWarning failed") + ledcontrol_error(str(e)) + return False + + def is_temp_critical(self): + critical_flag = False + for temp_threshold in self.__temps_threshold_config.values(): + temp_threshold['critical_flag'] = False + if temp_threshold['temp'] >= temp_threshold['critical']: + critical_flag = True + temp_threshold['critical_flag'] = True + ledcontrol_debug("%s is over critical" % temp_threshold['name']) + ledcontrol_debug( + "%s = %d, critical = %d" % + (temp_threshold['name'], + temp_threshold['temp'], + temp_threshold['critical'])) + return critical_flag + + def checkTempCrit(self): + try: + if self.is_temp_critical(): + temp_dict = dict(self.__temps_threshold_config) + tmp = temp_dict.get(SWITCH_TEMP) + if tmp['critical_flag'] == True: + ledcontrol_debug("temp is over critical") + return True + + del temp_dict[SWITCH_TEMP] + for temp_items in temp_dict.values(): + if temp_items['critical_flag'] == False: + return False + + ledcontrol_debug("temp is over critical") + return True + except Exception as e: + ledcontrol_error("%%policy: checkTempCrit failed") + ledcontrol_error(str(e)) + return False + + def check_board_air_flow(self): + board_air_flow = self.board_air_flow + if board_air_flow != F2B_AIR_FLOW and board_air_flow != B2F_AIR_FLOW: + air_flow_error("%%AIR_FLOW_MONITOR-3-ERROR: get board air flow error, value [%s]" % board_air_flow) + return False + ledcontrol_debug("board air flow check ok: %s" % board_air_flow) + return True + + def get_monitor_fan_status(self): + fanerrnum = 0 + for fan_obj in self.fan_obj_list: + status = fan_obj.status_summary + ledcontrol_debug("%s status: %s" % (fan_obj.name, status)) + if status != STATUS_OK: + fan_obj.led_status = COLOR_RED + fanerrnum += 1 + else: + fan_obj.led_status = COLOR_GREEN + ledcontrol_debug("fan error number: %d" % fanerrnum) + + if fanerrnum == 0: + fan_led_status = COLOR_GREEN + elif fanerrnum <= self.fan_yellow_num: + fan_led_status = COLOR_YELLOW + else: + fan_led_status = COLOR_RED + ledcontrol_debug("monitor fan status, set fan led: %s" % LED_STATUS_DICT.get(fan_led_status)) + return fan_led_status + + def get_monitor_psu_status(self): + psuerrnum = 0 + for psu_obj in self.psu_obj_list: + status = psu_obj.status_summary + ledcontrol_debug("%s status: %s" % (psu_obj.name, status)) + if status != STATUS_OK: + psu_obj.led_status = COLOR_RED + psuerrnum += 1 + else: + psu_obj.led_status = COLOR_GREEN + ledcontrol_debug("psu error number: %d" % psuerrnum) + + if psuerrnum == 0: + psu_led_status = COLOR_GREEN + elif psuerrnum <= self.psu_yellow_num: + psu_led_status = COLOR_YELLOW + else: + psu_led_status = COLOR_RED + ledcontrol_debug("monitor psu status, set psu led: %s" % LED_STATUS_DICT.get(psu_led_status)) + return psu_led_status + + def get_monitor_fan_air_flow(self): + if self.fan_air_flow_monitor == 0: + ledcontrol_debug("fan air flow monitor not open, default green") + return COLOR_GREEN + + ret = self.check_board_air_flow() + if ret is False: + ledcontrol_debug("check board air flow error, skip fan air flow monitor.") + return COLOR_GREEN + + fan_led_status_list = [] + fan_air_flow_ok_obj_list = [] + fan_air_flow_ok_set = set() + fan_module_led_list = [] + for fan_obj in self.fan_obj_list: + if fan_obj.present != STATUS_PRESENT: + fan_module_led_list.append(COLOR_GREEN) + continue + if fan_obj.air_flow == self.na_ret: + air_flow_warn("%%AIR_FLOW_MONITOR-4-WARN: %s get air flow failed, origin name: [%s], display name: [%s], air flow [%s]" % + (fan_obj.name, fan_obj.origin_name, fan_obj.display_name, fan_obj.air_flow)) + led_status = COLOR_YELLOW + elif fan_obj.air_flow != self.board_air_flow: + air_flow_error("%%AIR_FLOW_MONITOR-3-ERROR: %s air flow error, origin name: [%s], display name: [%s], fan air flow [%s], board air flow [%s]" % + (fan_obj.name, fan_obj.origin_name, fan_obj.display_name, fan_obj.air_flow, self.board_air_flow)) + led_status = COLOR_RED + else: + fan_air_flow_ok_obj_list.append(fan_obj) + fan_air_flow_ok_set.add(fan_obj.origin_name) + ledcontrol_debug("%s air flow check ok, origin name: [%s], display name: [%s], fan air flow: [%s], board air flow: [%s]" % + (fan_obj.name, fan_obj.origin_name, fan_obj.display_name, fan_obj.air_flow, self.board_air_flow)) + led_status = COLOR_GREEN + fan_module_led_list.append(led_status) + if led_status > fan_obj.led_status: + fan_obj.led_status = led_status + + fan_led_status = max(fan_module_led_list) + fan_led_status_list.append(fan_led_status) + if len(fan_air_flow_ok_set) > 1 and fan_air_flow_ok_set not in self.fan_mix_list: + for fan_obj in fan_air_flow_ok_obj_list: + air_flow_warn("%%AIR_FLOW_MONITOR-4-WARN: %s mixing, origin name: [%s], display name: [%s], air flow [%s]" % + (fan_obj.name, fan_obj.origin_name, fan_obj.display_name, fan_obj.air_flow)) + fan_led_status = COLOR_YELLOW + fan_led_status_list.append(fan_led_status) + + fan_led_status = max(fan_led_status_list) + ledcontrol_debug("monitor fan air flow, set fan led: %s" % LED_STATUS_DICT.get(fan_led_status)) + return fan_led_status + + def get_monitor_psu_air_flow(self): + if self.psu_air_flow_monitor == 0: + ledcontrol_debug("psu air flow monitor not open, default green") + return COLOR_GREEN + + ret = self.check_board_air_flow() + if ret is False: + ledcontrol_debug("check board air flow error, skip psu air flow monitor.") + return COLOR_GREEN + + psu_module_led_list = [] + for psu_obj in self.psu_obj_list: + if psu_obj.present != STATUS_PRESENT: + psu_module_led_list.append(COLOR_GREEN) + continue + if psu_obj.air_flow == self.na_ret: + air_flow_warn("%%AIR_FLOW_MONITOR-4-WARN: %s get air flow failed, origin name: [%s], display name: [%s], air flow [%s]" % + (psu_obj.name, psu_obj.origin_name, psu_obj.display_name, psu_obj.air_flow)) + led_status = COLOR_YELLOW + elif psu_obj.air_flow != self.board_air_flow: + air_flow_error("%%AIR_FLOW_MONITOR-3-ERROR: %s air flow error, origin name: [%s], display name: [%s], psu air flow [%s], board air flow [%s]" % + (psu_obj.name, psu_obj.origin_name, psu_obj.display_name, psu_obj.air_flow, self.board_air_flow)) + led_status = COLOR_RED + else: + ledcontrol_debug("%s psu air flow check ok, origin name: [%s], display name: [%s], psu air flow: [%s], board air flow: [%s]" % + (psu_obj.name, psu_obj.origin_name, psu_obj.display_name, psu_obj.air_flow, self.board_air_flow)) + led_status = COLOR_GREEN + psu_module_led_list.append(led_status) + if led_status > psu_obj.led_status: + psu_obj.led_status = led_status + + psu_led_status = max(psu_module_led_list) + ledcontrol_debug("monitor psu air flow, set psu led: %s" % LED_STATUS_DICT.get(psu_led_status)) + return psu_led_status + + def get_temp_sys_led_status(self): + if self.checkTempCrit() is True: + sys_led_status = COLOR_RED + elif self.checkTempWarning() is True: + sys_led_status = COLOR_YELLOW + else: + sys_led_status = COLOR_GREEN + ledcontrol_debug("monitor temperature, set sys led: %s" % LED_STATUS_DICT.get(sys_led_status)) + return sys_led_status + + def get_sys_led_follow_fan_status(self): + + if self.checkfan: + sys_led_status = self.board_fan_led_status + ledcontrol_debug("sys led follow fan led, set sys led: %s" % LED_STATUS_DICT.get(sys_led_status)) + else: + sys_led_status = COLOR_GREEN + ledcontrol_debug("sys led don't follow fan led, set default green") + return sys_led_status + + def get_sys_led_follow_psu_status(self): + if self.checkpsu: + sys_led_status = self.board_psu_led_status + ledcontrol_debug("sys led follow psu led, set sys led: %s" % LED_STATUS_DICT.get(sys_led_status)) + else: + sys_led_status = COLOR_GREEN + ledcontrol_debug("sys led don't follow psu led, set default green") + return sys_led_status + + def dealSysLedStatus(self): + sys_led_status_list = [] + # get_monitor_temp + self.get_monitor_temp() + + # monitor temp get sys led status + sys_led_status = self.get_temp_sys_led_status() + sys_led_status_list.append(sys_led_status) + + # check sys led follow fan led status + sys_led_status = self.get_sys_led_follow_fan_status() + sys_led_status_list.append(sys_led_status) + + # check sys led follow psu led status + sys_led_status = self.get_sys_led_follow_psu_status() + sys_led_status_list.append(sys_led_status) + + sys_led_status = max(sys_led_status_list) + sys_led_color = LED_STATUS_DICT.get(sys_led_status) + + # set sys led + self.set_sys_led(sys_led_color) + + def dealFanLedStatus(self): + fan_led_status_list = [] + # update fan info + self.update_fan_info() + + # monitor fan status first + fan_led_status = self.get_monitor_fan_status() + fan_led_status_list.append(fan_led_status) + + # monitor fan air flow + fan_led_status = self.get_monitor_fan_air_flow() + fan_led_status_list.append(fan_led_status) + + self.board_fan_led_status = max(fan_led_status_list) + fan_led_color = LED_STATUS_DICT.get(self.board_fan_led_status) + + # set fan led + self.set_fan_led(fan_led_color) + # set fan module led + self.set_fan_module_led() + + def dealPsuLedStatus(self): + psu_led_status_list = [] + # update psu info + self.update_psu_info() + + # monitor psu status first + psu_led_status = self.get_monitor_psu_status() + psu_led_status_list.append(psu_led_status) + + # monitor psu air flow + psu_led_status = self.get_monitor_psu_air_flow() + psu_led_status_list.append(psu_led_status) + + self.board_psu_led_status = max(psu_led_status_list) + psu_led_color = LED_STATUS_DICT.get(self.board_psu_led_status) + + # set psu led + self.set_psu_led(psu_led_color) + + def do_ledcontrol(self): + self.dealPsuLedStatus() + self.dealFanLedStatus() + self.dealSysLedStatus() + + def fan_obj_init(self): + fan_num = self.get_fan_total_number() + for i in range(fan_num): + fan_name = "FAN" + str(i + 1) + fan_obj = DevFan(fan_name, self.fan_air_flow_monitor, self.int_case) + self.fan_obj_list.append(fan_obj) + ledcontrol_debug("fan object initialize success") + + def psu_obj_init(self): + psu_num = self.get_psu_total_number() + for i in range(psu_num): + psu_name = "PSU" + str(i + 1) + psu_obj = DevPsu(psu_name, self.psu_air_flow_monitor, self.int_case) + self.psu_obj_list.append(psu_obj) + ledcontrol_debug("psu object initialize success") + + def run(self): + while True: + try: + debug_init() + self.do_ledcontrol() + time.sleep(self.interval) + except Exception as e: + traceback.print_exc() + ledcontrol_error(str(e)) + + +if __name__ == '__main__': + debug_init() + ledcontrol_debug("enter main") + led_control = ledcontrol() + led_control.fan_obj_init() + led_control.psu_obj_init() + led_control.run() diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/script/platform_intf.py b/platform/broadcom/sonic-platform-modules-tencent/common/script/platform_intf.py new file mode 100755 index 000000000000..cb8101fb181e --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/script/platform_intf.py @@ -0,0 +1,252 @@ +#!/usr/bin/env python3 +import os +import syslog +import importlib.machinery +from platform_util import getplatform_name, dev_file_read, dev_file_write, write_sysfs, read_sysfs + +__all__ = [ + "platform_reg_read", + "platform_reg_write", + "platform_set_optoe_type", + "platform_get_optoe_type", + "platform_sfp_read", + "platform_sfp_write", +] + +CPLD = 0 +FPGA = 1 +CPLD_PATH = "/dev/cpld%d" +FPGA_PATH = "/dev/fpga%d" + + +OPTOE_PATH = "/sys/bus/i2c/devices/%d-0050/" +OPTOE_DEV_CLASS = "dev_class" +OPTOE_EEPROM = "eeprom" + + +PLATFORM_INTF_DEBUG_FILE = "/etc/.platform_intf_debug_flag" + + +CONFIG_FILE_LIST = ["/usr/local/bin/", "/usr/local/lib/python3/dist-packages/config/", "/usr/local/lib/python3.7/dist-packages/config/", "/usr/local/lib/python3.9/dist-packages/config/"] + + +def platform_intf_debug(s): + if os.path.exists(PLATFORM_INTF_DEBUG_FILE): + syslog.openlog("PLATFORM_INTF_DEBUG", syslog.LOG_PID) + syslog.syslog(syslog.LOG_DEBUG, s) + + +def platform_intf_error(s): + if os.path.exists(PLATFORM_INTF_DEBUG_FILE): + syslog.openlog("PLATFORM_INTF_ERROR", syslog.LOG_PID) + syslog.syslog(syslog.LOG_ERR, s) + + +class IntfPlatform: + CONFIG_NAME = 'PLATFORM_INTF_OPTOE' + __port_optoe_dict = {} + def __init__(self): + real_path = None + platform = (getplatform_name()).replace("-", "_") + for configfile_path in CONFIG_FILE_LIST: + configfile = (configfile_path + platform + "_port_config.py") + if os.path.exists(configfile): + real_path = configfile + break + if real_path is None: + raise Exception("get port config error") + config = importlib.machinery.SourceFileLoader(self.CONFIG_NAME, real_path).load_module() + self.__port_optoe_dict = config.PLATFORM_INTF_OPTOE + + def get_dev_path(self, dev_type, dev_id): + if dev_type == CPLD: + path = CPLD_PATH % dev_id + elif dev_type == FPGA: + path = FPGA_PATH % dev_id + else: + msg = "dev_type error!" + return False, msg + platform_intf_debug("path:%s" % path) + return True, path + + def get_port_path(self, port): + port_num = self.__port_optoe_dict.get("port_num", 0) + optoe_start_bus = self.__port_optoe_dict.get("optoe_start_bus", 0) + if port_num <= 0 or optoe_start_bus <= 0: + msg = "PLATFORM_INTF_OPTOE config error!" + return False, msg + if port <= 0 or port > port_num: + msg = "port out of range !" + return False, msg + path = OPTOE_PATH % (port + optoe_start_bus - 1) + platform_intf_debug("path:%s" % path) + return True, path + + def reg_read(self, dev_type, dev_id, offset, size): + ret, path = self.get_dev_path(dev_type, dev_id) + if ret == False: + return False, path + ret, info = dev_file_read(path, offset, size) + return ret, info + + def reg_write(self, dev_type, dev_id, offset, val_list): + ret, path = self.get_dev_path(dev_type, dev_id) + if ret == False: + return False, path + ret, info = dev_file_write(path, offset, val_list) + return ret, info + + def set_optoe_type(self, port, optoe_type): + ret, path = self.get_port_path(port) + if ret == False: + return False, path + optoe_type_path = path + OPTOE_DEV_CLASS + ret, info = write_sysfs(optoe_type_path, "%d" % optoe_type) + if ret == False: + return False, info + return True, None + + def get_optoe_type(self, port): + ret, path = self.get_port_path(port) + if ret == False: + return False, path + optoe_type_path = path + OPTOE_DEV_CLASS + ret, info = read_sysfs(optoe_type_path) + if ret == False: + return False, info + return True, int(info) + + def sfp_read(self, port_id, offset, size): + ret, path = self.get_port_path(port_id) + if ret == False: + return False, path + optoe_eeprom_path = path + OPTOE_EEPROM + ret, info = dev_file_read(optoe_eeprom_path, offset, size) + return ret, info + + def sfp_write(self, port_id, offset, val_list): + ret, path = self.get_port_path(port_id) + if ret == False: + return False, path + optoe_eeprom_path = path + OPTOE_EEPROM + ret, info = dev_file_write(optoe_eeprom_path, offset, val_list) + return ret, info + + +platform = IntfPlatform() + + +def platform_reg_read(dev_type, dev_id, offset, size): + ret = False + info = None + + '''1. params check + ''' + if (isinstance(dev_type, int) is False or isinstance(dev_id, int) is False or + isinstance(offset, int) is False or isinstance(size, int) is False): + info = "params type check fail in platform_reg_read" + return ret, info + if dev_id < 0 or offset < 0 or size <= 0: + info = "params value check fail in platform_reg_read" + return ret, info + if dev_type != CPLD and dev_type != FPGA: + info = "dev_type match erro, fail in platform_reg_read" + return ret, info + + '''2. call the solve func + ''' + return platform.reg_read(dev_type, dev_id, offset, size) + + +def platform_reg_write(dev_type, dev_id, offset, val_list): + ret = False + info = None + + '''1. params check + ''' + if (isinstance(dev_type, int) is False or isinstance(dev_id, int) is False or + isinstance(offset, int) is False or isinstance(val_list, list) is False): + info = "params type check fail in platform_reg_write" + return ret, info + if dev_id < 0 or offset < 0 or len(val_list) <= 0: + info = "params value check fail in platform_reg_write" + return ret, info + if dev_type != CPLD and dev_type != FPGA: + info = "dev_type match erro, fail in platform_reg_write" + return ret, info + + '''2. call the solve func + ''' + return platform.reg_write(dev_type, dev_id, offset, val_list) + + +def platform_set_optoe_type(port, optoe_type): + ret = False + info = None + + '''1. params check + ''' + if isinstance(port, int) is False or isinstance(optoe_type, int) is False: + info = "params type check fail in platform_set_optoe_type" + return ret, info + if port < 0 or optoe_type < 1 or optoe_type > 3: + info = "params value check fail in platform_set_optoe_type" + return ret, info + + '''2. call the solve func + ''' + return platform.set_optoe_type(port, optoe_type) + + +def platform_get_optoe_type(port): + ret = False + info = None + + '''1. params check + ''' + if isinstance(port, int) is False: + info = "params type check fail in platform_get_optoe_type" + return ret, info + if port < 0: + info = "params value check fail in platform_get_optoe_type" + return ret, info + + '''2. call the solve func + ''' + return platform.get_optoe_type(port) + + +def platform_sfp_read(port_id, offset, size): + ret = False + info = None + + '''1. params check + ''' + if isinstance(port_id, int) is False or isinstance(offset, int) is False or isinstance(size, int) is False: + info = "params type check fail in platform_sfp_read" + return ret, info + if port_id < 0 or offset < 0 or size <= 0: + info = "params value check fail in platform_sfp_read" + return ret, info + + '''2. call the solve func + ''' + return platform.sfp_read(port_id, offset, size) + + +def platform_sfp_write(port_id, offset, val_list): + ret = False + info = None + + '''1. params check + ''' + if isinstance(port_id, int) is False or isinstance(offset, int) is False or isinstance(val_list, list) is False: + info = "params type check fail in platform_sfp_write" + return ret, info + if port_id < 0 or offset < 0 or len(val_list) <= 0: + info = "params value check fail in platform_sfp_write" + return ret, info + + '''2. call the solve func + ''' + return platform.sfp_write(port_id, offset, val_list) \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/script/platform_manufacturer.py b/platform/broadcom/sonic-platform-modules-tencent/common/script/platform_manufacturer.py new file mode 100755 index 000000000000..fe6084fd05a7 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/script/platform_manufacturer.py @@ -0,0 +1,609 @@ +#!/usr/bin/env python3 + +import re +from sys import exit, stderr +from ruijieconfig import MANUINFO_CONF +from monitor import status +import mmap +import fcntl +import subprocess +import signal +import os +import time +from platform_util import byteTostr + + +INDENT = 4 + + +def printerr(vchar): + stderr.write(vchar + '\n') + + +g_extra_cache = dict() +g_meminfo_cache = dict() +g_exphy_cache = dict() + + +def exec_os_cmd(cmd, timeout=10): + try: + start_time = time.time() + proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True, stderr=subprocess.STDOUT, + close_fds=True, preexec_fn=os.setsid) + while True: + if proc.poll() is not None: + break + if timeout <= 0: + continue + if (time.time() - start_time) > timeout: + try: + os.killpg(os.getpgid(proc.pid), signal.SIGTERM) + except Exception as e: + return -1, "run command %s %d sec timeout, msg: %s" % (cmd, timeout, str(e)) + return -1, "run command %s %d sec timeout" % (cmd, timeout) + time.sleep(0.01) + return proc.returncode, byteTostr(proc.stdout.read()).strip() + except Exception as e: + return -1, str(e) + + +def exphyfwsplit(): + # improve performance + global g_exphy_cache + if g_exphy_cache: + return + cmd = "bcmcmd -t 1 \"phy control xe,ce fw_get\" |grep fw_version" + status, output = exec_os_cmd(cmd) + if status or len(output) == 0: + raise Exception("run cmd: {} error, status: {}, msg: {}".format(cmd, status, output)) + exphyfwstr = output.strip() + portlist = exphyfwstr.split("\n") + for port in portlist: + phy_addr_str = get_regular_val(port, r"phy_addr\s*=\s*\w+", 0) + if phy_addr_str.startswith("ERR"): + continue + phy_addr_key = phy_addr_str.replace(" ", "") + if phy_addr_key in g_exphy_cache: + continue + + g_exphy_cache[phy_addr_key] = {} + + fw_version_str = get_regular_val(port, r"fw_version\s*=\s*\w+", 0) + if fw_version_str.startswith("ERR"): + del g_exphy_cache[phy_addr_key] + continue + + fw_version = fw_version_str.split("=")[1].strip() + g_exphy_cache[phy_addr_key]["fw_version"] = fw_version + + if "success" in port: + status = "OK" + else: + status = "Unexpected" + g_exphy_cache[phy_addr_key]["status"] = status + return + + +def get_exphy_fw(phyid): + exphyfwsplit() + if phyid not in g_exphy_cache: + return "ERR %s not found." % phyid + fw_version = g_exphy_cache.get(phyid).get("fw_version") + status = g_exphy_cache.get(phyid).get("status") + msg = "%s %s" % (fw_version, status) + return msg + + +def lshwmemorysplit(): + # improve performance + global g_meminfo_cache + if g_meminfo_cache: + return + cmd = "lshw -c memory" + status, output = exec_os_cmd(cmd) + if status or len(output) == 0: + raise Exception("run cmd: {} error, status: {}, msg: {}".format(cmd, status, output)) + memstr = output.strip() + memlist = memstr.split("*-") + for item in memlist: + if item.strip().startswith("memory") and "System Memory" not in item: + continue + line_index = 0 + for line in item.splitlines(): + line_index += 1 + if line_index == 1: + memdict_key = line + g_meminfo_cache[memdict_key] = {} + else: + if ":" not in line: + continue + key = line.split(":", 1)[0].strip() + value = line.split(":", 1)[1].strip() + g_meminfo_cache[memdict_key][key] = value + if "empty" in item: + break + return + + +def run_extra_func(funcname): + # improve performance + if funcname in g_extra_cache: + return g_extra_cache.get(funcname) + func = getattr(status, funcname) + ret = [] + func(ret) + if ret: + g_extra_cache[funcname] = ret + return ret + + +def get_extra_value(funcname, itemid, key): + for item in run_extra_func(funcname): + if item.get("id") == itemid: + return item.get(key, "NA") + return "NA" + + +def get_memory_value(params): + global g_meminfo_cache + root_key = params.get("root_key") + sub_key = params.get("sub_key") + lshwmemorysplit() + return g_meminfo_cache.get(root_key, {}).get(sub_key, "NA") + + +def get_memory_bank_value(params): + global g_meminfo_cache + lshwmemorysplit() + bank = params.get("bankid") + if g_meminfo_cache.get(bank, {}): + return True + return False + + +def io_wr(reg_addr, reg_data): + try: + regdata = 0 + regaddr = 0 + if isinstance(reg_addr, int): + regaddr = reg_addr + else: + regaddr = int(reg_addr, 16) + if isinstance(reg_data, int): + regdata = reg_data + else: + regdata = int(reg_data, 16) + devfile = "/dev/port" + fd = os.open(devfile, os.O_RDWR | os.O_CREAT) + os.lseek(fd, regaddr, os.SEEK_SET) + os.write(fd, regdata.to_bytes(1, 'little')) + return True + except ValueError as e: + print(e) + return False + except Exception as e: + print(e) + return False + finally: + os.close(fd) + + +def checksignaldriver(name): + modisexistcmd = "lsmod | grep -w %s | wc -l" % name + status, output = exec_os_cmd(modisexistcmd) + if status: + return False + if output.isdigit() and int(output) > 0: + return True + else: + return False + + +def adddriver(name): + cmd = "modprobe %s" % name + if checksignaldriver(name) != True: + ret, log = exec_os_cmd(cmd) + if ret != 0 or len(log) > 0: + return False + return True + return True + + +def removedriver(name): + cmd = "rmmod %s" % name + if checksignaldriver(name): + exec_os_cmd(cmd) + + +def add_5387_driver(): + errmsg = "" + spi_gpio = "rg_spi_gpio" + ret = adddriver(spi_gpio) + if ret is False: + errmsg = "modprobe rg_spi_gpio driver failed." + return False, errmsg + spi_5387_device = "rg_spi_93xx46 spi_bus_num=0" + ret = adddriver(spi_5387_device) + if ret is False: + errmsg = "modprobe rg_spi_93xx46 driver failed." + return ret, errmsg + return True, "" + + +def remove_5387_driver(): + spi_5387_device = "rg_spi_93xx46" + removedriver(spi_5387_device) + spi_gpio = "rg_spi_gpio" + removedriver(spi_gpio) + + +def deal_itmes(item_list): + for item in item_list: + dealtype = item.get("dealtype") + if dealtype == "shell": + cmd = item.get("cmd") + timeout = item.get("timeout", 10) + exec_os_cmd(cmd, timeout) + elif dealtype == "io_wr": + io_addr = item.get("io_addr") + wr_value = item.get("value") + io_wr(io_addr, wr_value) + else: + pass + + +def get_bcm5387_version(params): + version = "" + try: + status, msg = add_5387_driver() + if status is False: + raise Exception(msg) + + before_deal_list = params.get("before", []) + deal_itmes(before_deal_list) + + ret, version = exec_os_cmd(params["get_version"]) + if ret != 0: + version = "ERR " + version + + after_deal_list = params.get("after", []) + deal_itmes(after_deal_list) + + except Exception as e: + version = "ERR %s" % (str(e)) + finally: + finally_deal_list = params.get("finally", []) + deal_itmes(finally_deal_list) + remove_5387_driver() + return version + + +def get_func_value(funcname, params): + ret = eval(funcname)(params) + return ret + + +def read_pci_reg(pcibus, slot, fn, bar, offset): + '''read pci register''' + if offset % 4 != 0: + return "ERR offset: %d not 4 bytes align" + filename = "/sys/bus/pci/devices/0000:%02x:%02x.%x/resource%d" % (int(pcibus), int(slot), int(fn), int(bar)) + size = os.path.getsize(filename) + with open(filename, "r+") as file: + data = mmap.mmap(file.fileno(), size) + result = data[offset: offset + 4] + s = result[::-1] + val = 0 + for i in range(0, len(s)): + val = val << 8 | s[i] + data.close() + return "0x%08x" % val + + +def devfileread(path, offset, len, bit_width): + ret = "" + val_str = '' + val_list = [] + fd = -1 + if not os.path.exists(path): + return ("%s not found !" % path) + if len % bit_width != 0: + return "only support read by bit_width" + if len < bit_width: + return "len needs to greater than or equal to bit_width" + + try: + fd = os.open(path, os.O_RDONLY) + os.lseek(fd, offset, os.SEEK_SET) + ret = os.read(fd, len) + for item in ret: + val_list.append(item) + + for i in range(0, len, bit_width): + val_str += " 0x" + for j in range(0, bit_width): + val_str += "%02x" % val_list[i + bit_width - j - 1] + except Exception as e: + return str(e) + finally: + if fd > 0: + os.close(fd) + return val_str + + +def read_reg(loc, offset, size): + with open(loc, 'rb') as file: + file.seek(offset) + return ' '.join(["%02x" % item for item in file.read(size)]) + + +def std_match(stdout, pattern): + if pattern is None: + return stdout.strip() + for line in stdout.splitlines(): + if re.match(pattern, line): + return line.strip() + raise EOFError("pattern: {} does not match anything in stdout {}".format( + pattern, stdout)) + + +def i2c_rd(bus, loc, offset): + ''' + read i2c with i2cget command + ''' + cmd = "i2cget -f -y {} {} {}".format(bus, loc, offset) + # TODO: add retry + retrytime = 6 + for i in range(retrytime): + ret, stdout = subprocess.getstatusoutput(cmd) + if ret == 0: + return stdout + time.sleep(0.1) + raise RuntimeError("run cmd: {} error, status {}".format(cmd, ret)) + + +def i2c_rd_bytes(bus, loc, offset, size): + blist = [] + for i in range(size): + ret = i2c_rd(bus, loc, offset + i) + blist.append(ret) + + return blist + + +def get_pair_val(source, separator): + try: + value = source.split(separator, 1)[1] + except (ValueError, IndexError) as e: + # printerr(e.message) + return ("ERR separator: {} does not match in source: {}".format(separator, source)) + return value.strip() + + +def get_regular_val(source, pattern, group): + try: + value = re.findall(pattern, source)[group] + except Exception as e: + # printerr(str(e)) + return ("ERR pattern: {} does not match in source: {} with group: {}".format(pattern, source, group)) + return value.strip() + + +def find_match(file2read, pattern): + with open(file2read, 'r') as file: + for line in file: + if not re.match(pattern, line): + continue + return line.strip() + return "ERR pattern %s not match in %s" % (pattern, file2read) + + +def readaline(file2read): + with open(file2read, 'r') as file: + return file.readline() + + +def sort_key(e): + return e.arrt_index + + +class CallbackSet: + def cpld_format(self, blist): + if isinstance(blist, str): + blist = blist.split() + elif not isinstance(blist, list) or len(blist) != 4: + raise ValueError("cpld format: wrong parameter: {}".format(blist)) + + return "{}{}{}{}".format(*blist).replace("0x", "") + + +class VersionHunter: + call = CallbackSet() + + def __init__(self, entires): + self.head = None + self.next = None + self.key = None + self.cmd = None + self.file = None + self.reg = None + self.i2c = None + self.extra = None + self.pattern = None + self.separator = None + self.parent = None + self.ignore = False + self.children = [] + self.level = 0 + self.callback = None + self.delspace = None + self.arrt_index = None + self.config = None + self.precheck = None + self.func = None + self.regular = None + self.group = 0 + self.pci = None + self.devfile = None + self.decode = None + self.timeout = 10 + self.__dict__.update(entires) + + def check_para(self): + if self.pattern is None: + return False + if self.cmd is None or self.file is None: + return False + return True + + def get_version(self): + ret = "NA" + try: + if self.cmd is not None: + status, output = exec_os_cmd(self.cmd, self.timeout) + if status or len(output) == 0: + raise RuntimeError("run cmd: {} error, status: {}, msg: {}".format(self.cmd, status, output)) + ret = std_match(output, self.pattern) + elif self.file is not None: + ret = self.read_file() + elif self.reg is not None: + ret = read_reg(self.reg.get("loc"), self.reg.get("offset"), + self.reg.get("size")) + elif self.extra: + ret = get_extra_value(self.extra.get("funcname"), + self.extra.get("id"), + self.extra.get("key")) + elif self.i2c: + ret = i2c_rd_bytes(self.i2c.get("bus"), self.i2c.get("loc"), + self.i2c.get("offset"), + self.i2c.get("size")) + elif self.config: + ret = self.config + elif self.func: + ret = get_func_value(self.func.get("funcname"), + self.func.get("params")) + elif self.pci: + ret = read_pci_reg(self.pci.get("bus"), self.pci.get("slot"), + self.pci.get("fn"), self.pci.get("bar"), self.pci.get("offset")) + elif self.devfile: + ret = devfileread(self.devfile.get("loc"), self.devfile.get("offset"), + self.devfile.get("len"), self.devfile.get("bit_width")) + + except Exception as e: + # printerr(e.message) + return "ERR %s" % str(e) + return self.exe_callback(ret) + + def exe_callback(self, data): + try: + if self.callback: + method = getattr(self.call, self.callback) + return method(data) + except Exception as e: + # printerr("run callback method: {} error, data: {}".format(self.callback, data)) + # printerr(e.message) + return "ERR run callback method: {} error, data: {}".format(self.callback, data) + return data + + def read_file(self): + if self.pattern is not None: + return find_match(self.file, self.pattern) + else: + return readaline(self.file) + + def hunt(self): + if self.ignore: + return + indent = self.level * INDENT * " " + + if self.precheck: + try: + ret = eval(self.precheck.get("funcname"))(self.precheck.get("params")) + if ret is not True: + return + except Exception as e: + err_msg = "ERR %s" % str(e) + format_str = "{}{:<{}}{}".format(indent, self.key + ':', + (30 - len(indent)), err_msg) + print(format_str) + return + # has children + if self.children: + self.children.sort(key=sort_key) + format_str = "{}{}:".format(indent, self.key) + print(format_str) + for child in self.children: + if not isinstance(child, VersionHunter): + continue + child.level = self.level + 1 + child.hunt() + else: + version = self.get_version() or "" + if not version.startswith("ERR"): + version = version.replace("\x00", "").strip() + if self.separator is not None: + version = get_pair_val(version, self.separator) + if self.delspace is not None: + version = version.replace(" ", "") + if self.regular is not None: + version = get_regular_val(version, self.regular, self.group) + if self.decode is not None: + tmp_version = self.decode.get(version) + if tmp_version is None: + version = "ERR decode %s failed" % version + else: + version = tmp_version + format_str = "{}{:<{}}{}".format(indent, self.key + ':', + (30 - len(indent)), version) + print(format_str) + + if self.next: + print("") + self.next.hunt() + + +pidfile = 0 + + +def ApplicationInstance(): + global pidfile + pidfile = open(os.path.realpath(__file__), "r") + try: + fcntl.flock(pidfile, fcntl.LOCK_EX | fcntl.LOCK_NB) + return True + except Exception as e: + return False + + +if __name__ == "__main__": + start_time = time.time() + while True: + ret = ApplicationInstance() + if ret == True: + break + if time.time() - start_time > 10: + printerr("manufacturer is running.") + exit(1) + time.sleep(0.5) + + objmap = dict() + + try: + target = {} + target.update(MANUINFO_CONF) + for objname, value in target.items(): + objmap[objname] = VersionHunter(value) + except Exception as e: + printerr(e.message) + exit(-1) + + head = None + for objname, obj in objmap.items(): + if head is None and obj.head: + head = obj + if obj.parent: + objmap.get(obj.parent).children.append(obj) + if obj.next: + obj.next = objmap.get(obj.next) + + head.hunt() diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/script/platform_sensors.py b/platform/broadcom/sonic-platform-modules-tencent/common/script/platform_sensors.py new file mode 100755 index 000000000000..c42db7e874bd --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/script/platform_sensors.py @@ -0,0 +1,262 @@ +#!/usr/bin/python3 + +# On S6100, the Platform Management Controller runs the +# thermal algorithm. It provides a mailbox for the Host +# to query relevant thermals. The dell_mailbox module +# provides the sysfs support for the following objects: +# * onboard temperature sensors +# * FAN trays +# * PSU +# +import os +import sys +import importlib.machinery + + +def get_machine_info(): + if not os.path.isfile('/host/machine.conf'): + return None + machine_vars = {} + with open('/host/machine.conf') as machine_file: + for line in machine_file: + tokens = line.split('=') + if len(tokens) < 2: + continue + machine_vars[tokens[0]] = tokens[1].strip() + return machine_vars + + +def get_platform_info(machine_info): + if machine_info is not None: + if 'onie_platform' in machine_info: + return machine_info['onie_platform'] + elif 'aboot_platform' in machine_info: + return machine_info['aboot_platform'] + return None + + +PLATFORM_ROOT_PATH = '/usr/share/sonic/device' +PLATFORM_SPECIFIC_MODULE_NAME = 'monitor' +PLATFORM_SPECIFIC_CLASS_NAME = 'status' +platform_status_class = None +platform = None + + +def get_platform_name(): + global platform + platform = get_platform_info(get_machine_info()) + return platform + + +val = get_platform_name() +sys.path.append("/".join([PLATFORM_ROOT_PATH, platform])) + +# Loads platform specific sfputil module from source + + +def load_platform_monitor(): + global platform_status_class + platform = get_platform_info(get_machine_info()) + platform_path = "/".join([PLATFORM_ROOT_PATH, platform]) + try: + module_file = "/".join([platform_path, PLATFORM_SPECIFIC_MODULE_NAME + ".py"]) + module = importlib.machinery.SourceFileLoader(PLATFORM_SPECIFIC_MODULE_NAME, module_file).load_module() + except IOError as e: + return -1 + try: + platform_status_class = getattr(module, PLATFORM_SPECIFIC_CLASS_NAME) + except AttributeError as e: + return -2 + return 0 + + +def printerr(str): + print("\033[0;31m%s\033[0m" % str) + + +def print_console(str): + print(str) + + +val_t = load_platform_monitor() +if val_t != 0: + raise Exception("load monitor.py error") + + +def print_platform(): + platform_info = get_platform_name() + print_console(platform_info) + print_console('Adapter: Ruijie Platform Management Controller') + print_console("") + + +def print_cputemp_sensors(): + val_ret = get_call_value_by_function("getcputemp") + print_info_str = "" + toptile = "Onboard coretemp Sensors:" + formatstr = " {name:<20} : {temp} C (high = {max} C , crit = {crit} C )" + + if len(val_ret) != 0: + print_info_str += toptile + '\n' + for item in val_ret: + print_info_str += formatstr.format(**item) + '\n' + print_console(print_info_str) + + +def print_boardtemp(): + val_ret = get_call_value_by_function("getTemp") + print_info_str = "" + toptile = "Onboard Temperature Sensors:" + errformat = " {id:<20} : {errmsg}" + formatstr = " {id:<20} : {temp1_input} C (high = {temp1_max} C, hyst = {temp1_max_hyst} C)" + + if len(val_ret) != 0: + print_info_str += toptile + '\n' + for item in val_ret: + realformat = formatstr if item.get('errcode', 0) == 0 else errformat + print_info_str += realformat.format(**item) + '\n' + print_console(print_info_str) + + +def print_mactemp_sensors(): + val_ret = get_call_value_by_function("getmactemp") + print_info_str = "" + toptile = "Onboard MAC Temperature Sensors:" + errformat = " {id:<20} : {errmsg}" + formatstr = " {id:<20} : {temp_input} C" + + if len(val_ret) != 0: + print_info_str += toptile + '\n' + for item in val_ret: + realformat = formatstr if item.get('errcode', 0) == 0 else errformat + print_info_str += realformat.format(**item) + '\n' + print_console(print_info_str) + + +def print_macpower_sensors(): + val_ret = get_call_value_by_function("getmacpower") + print_info_str = "" + toptile = "Onboard MAC Power Sensors:" + errformat = " {id:<20} : {errmsg}" + formatstr = " {id:<20} : {power_input} W" + + if len(val_ret) != 0: + print_info_str += toptile + '\n' + for item in val_ret: + realformat = formatstr if item.get('errcode', 0) == 0 else errformat + print_info_str += realformat.format(**item) + '\n' + print_console(print_info_str) + + +def print_fan_sensor(): + val_ret = get_call_value_by_function("checkFan") + print_info_str = "" + toptile = "Onboard fan Sensors:" + errformat = " {id} : {errmsg}\n" # " {id:<20} : {errmsg}" + fan_signle_rotor_format = " {id} : \n" \ + " fan_type :{fan_type}\n" \ + " sn :{sn}\n" \ + " hw_version:{hw_version}\n" \ + " Speed :{Speed} RPM\n" \ + " status :{errmsg} \n" + fan_double_rotor_format = " {id} : \n" \ + " fan_type :{fan_type}\n" \ + " sn :{sn}\n" \ + " hw_version:{hw_version}\n" \ + " Speed :\n" \ + " speed_front :{rotor1_speed:<5} RPM\n" \ + " speed_rear :{rotor2_speed:<5} RPM\n" \ + " status :{errmsg} \n" + + if len(val_ret) != 0: + print_info_str += toptile + '\n' + for item in val_ret: + if item.get('Speed', None) is None: + realformat = fan_double_rotor_format if item.get('errcode', 0) == 0 else errformat + else: + realformat = fan_signle_rotor_format if item.get('errcode', 0) == 0 else errformat + print_info_str += realformat.format(**item) + print_console(print_info_str) + + +def print_psu_sensor(): + val_ret = get_call_value_by_function("getPsu") + print_info_str = "" + toptile = "Onboard Power Supply Unit Sensors:" + errformat = " {id} : {errmsg}\n" # " {id:<20} : {errmsg}" + psuformat = " {id} : \n" \ + " type :{type1}\n" \ + " sn :{sn}\n" \ + " in_current :{in_current} A\n" \ + " in_voltage :{in_voltage} V\n" \ + " out_current:{out_current} A\n" \ + " out_voltage:{out_voltage} V\n" \ + " temp :{temp} C \n" \ + " fan_speed :{fan_speed} RPM\n" \ + " in_power :{in_power} W\n" \ + " out_power :{out_power} W\n" + + if len(val_ret) != 0: + print_info_str += toptile + '\r\n' + for item in val_ret: + realformat = psuformat if item.get('errcode', 0) == 0 else errformat + print_info_str += realformat.format(**item) + print_console(print_info_str) + + +def print_slot_sensor(): + val_ret = get_call_value_by_function("checkSlot") + print_info_str = "" + toptile = "Onboard slot Sensors:" + errformat = " {id} : {errmsg}\n" # " {id:<20} : {errmsg}" + psuformat = " {id} : \n" \ + " slot_type :{slot_type}\n" \ + " sn :{sn}\n" \ + " hw_version :{hw_version} \n" \ + " status :{errmsg}\n" + + if len(val_ret) != 0: + print_info_str += toptile + '\r\n' + for item in val_ret: + realformat = psuformat if item.get('errcode', 0) == 0 else errformat + print_info_str += realformat.format(**item) + print_console(print_info_str) + + +def print_boarddcdc(): + val_ret = get_call_value_by_function("getDcdc") + print_info_str = "" + toptile = "Onboard DCDC Sensors:" + errformat = " {id:<26} : {errmsg}" + formatstr = " {id:<26} : {dcdc_input:<6} V (Min = {dcdc_min:<6} V, Max = {dcdc_max:<6} V)" + + if len(val_ret) != 0: + print_info_str += toptile + '\n' + for item in val_ret: + realformat = formatstr if item.get('errcode', 0) == 0 else errformat + print_info_str += realformat.format(**item) + '\n' + print_console(print_info_str) + + +def get_call_value_by_function(function_name): + valtemp = [] + if hasattr(platform_status_class, function_name): + test2_func = getattr(platform_status_class, function_name) + test2_func(valtemp) + return valtemp + + +def getsensors(): + print_platform() + print_cputemp_sensors() + print_boardtemp() + print_mactemp_sensors() + print_macpower_sensors() + print_fan_sensor() + print_psu_sensor() + print_slot_sensor() + print_boarddcdc() + + +if __name__ == "__main__": + getsensors() diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/script/platform_util.py b/platform/broadcom/sonic-platform-modules-tencent/common/script/platform_util.py new file mode 100755 index 000000000000..b0593b40cdf7 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/script/platform_util.py @@ -0,0 +1,539 @@ +#!/usr/bin/python3 +# ------------------------------------------------------------------------- +# +# Author: sonic_rd +# +# Created: 02/07/2018 +# Copyright: (c) sonic_rd 2018 +# ------------------------------------------------------------------------- +import sys +import os +import subprocess +import time +import mmap +import glob + + +CONFIG_DB_PATH = "/etc/sonic/config_db.json" + + +__all__ = [ + "byteTostr", + "getplatform_name", + "rji2cget", + "rji2cset", + "rjpcird", + "rjpciwr", + "rji2cgetWord", + "rji2csetWord", + "dev_file_read", + "dev_file_write", + "rj_os_system", + "io_rd", + "io_wr", + "exec_os_cmd", + "exec_os_cmd_log", + "write_sysfs", + "read_sysfs", + "get_value", + "set_value", +] + +def inttostr(vl, len): + if not isinstance(vl, int): + raise Exception(" type error") + index = 0 + ret_t = "" + while index < len: + ret = 0xff & (vl >> index * 8) + ret_t += chr(ret) + index += 1 + return ret_t + + +def byteTostr(val): + strtmp = '' + for i in range(len(val)): + strtmp += chr(val[i]) + return strtmp + + +def typeTostr(val): + strtmp = '' + if isinstance(val, bytes): + strtmp = byteTostr(val) + return strtmp + + +def getonieplatform(path): + if not os.path.isfile(path): + return "" + machine_vars = {} + with open(path) as machine_file: + for line in machine_file: + tokens = line.split('=') + if len(tokens) < 2: + continue + machine_vars[tokens[0]] = tokens[1].strip() + return machine_vars.get("onie_platform") + + +def getplatform_config_db(): + if not os.path.isfile(CONFIG_DB_PATH): + return "" + val = os.popen("sonic-cfggen -j %s -v DEVICE_METADATA.localhost.platform" % CONFIG_DB_PATH).read().strip() + if len(val) <= 0: + return "" + else: + return val + + +def getplatform_name(): + if os.path.isfile('/host/machine.conf'): + return getonieplatform('/host/machine.conf') + elif os.path.isfile('/usr/share/sonic/hwsku/machine.conf'): + return getonieplatform('/usr/share/sonic/hwsku/machine.conf') + else: + return getplatform_config_db() + + +def rji2cget(bus, devno, address, word=None): + if word is None: + command_line = "i2cget -f -y %d 0x%02x 0x%02x " % (bus, devno, address) + else: + command_line = "i2cget -f -y %d 0x%02x 0x%02x %s" % (bus, devno, address, word) + retrytime = 6 + ret_t = "" + for i in range(retrytime): + ret, ret_t = rj_os_system(command_line) + if ret == 0: + return True, ret_t + time.sleep(0.1) + return False, ret_t + + +def rji2cset(bus, devno, address, byte): + command_line = "i2cset -f -y %d 0x%02x 0x%02x 0x%02x" % ( + bus, devno, address, byte) + retrytime = 6 + ret_t = "" + for i in range(retrytime): + ret, ret_t = rj_os_system(command_line) + if ret == 0: + return True, ret_t + return False, ret_t + + +def rjpcird(pcibus, slot, fn, bar, offset): + '''read pci register''' + if offset % 4 != 0: + return "ERR offset: %d not 4 bytes align" + filename = "/sys/bus/pci/devices/0000:%02x:%02x.%x/resource%d" % (int(pcibus), int(slot), int(fn), int(bar)) + with open(filename, "r+") as file: + size = os.path.getsize(filename) + data = mmap.mmap(file.fileno(), size) + result = data[offset: offset + 4] + s = result[::-1] + val = 0 + for i in range(0, len(s)): + val = val << 8 | s[i] + data.close() + return "0x%08x" % val + + +def rjpciwr(pcibus, slot, fn, bar, offset, data): + '''write pci register''' + ret = inttostr(data, 4) + filename = "/sys/bus/pci/devices/0000:%02x:%02x.%x/resource%d" % (int(pcibus), int(slot), int(fn), int(bar)) + with open(filename, "r+") as file: + size = os.path.getsize(filename) + data = mmap.mmap(file.fileno(), size) + data[offset: offset + 4] = ret + result = data[offset: offset + 4] + s = result[::-1] + val = 0 + for i in range(0, len(s)): + val = val << 8 | ord(s[i]) + data.close() + + +def rji2cgetWord(bus, devno, address): + command_line = "i2cget -f -y %d 0x%02x 0x%02x w" % (bus, devno, address) + retrytime = 3 + ret_t = "" + for i in range(retrytime): + ret, ret_t = rj_os_system(command_line) + if ret == 0: + return True, ret_t + return False, ret_t + + +def rji2csetWord(bus, devno, address, byte): + command_line = "i2cset -f -y %d 0x%02x 0x%02x 0x%x w" % ( + bus, devno, address, byte) + retrytime = 6 + ret_t = "" + for i in range(retrytime): + ret, ret_t = rj_os_system(command_line) + if ret == 0: + return True, ret_t + return False, ret_t + + +def dev_file_read(path, offset, read_len): + val_list = [] + msg = "" + ret = "" + fd = -1 + + if not os.path.exists(path): + msg = path + " not found !" + return False, msg + + try: + fd = os.open(path, os.O_RDONLY) + os.lseek(fd, offset, os.SEEK_SET) + ret = os.read(fd, read_len) + for item in ret: + val_list.append(item) + except Exception as e: + msg = str(e) + return False, msg + finally: + if fd > 0: + os.close(fd) + return True, val_list + + +def dev_file_write(path, offset, buf_list): + msg = "" + fd = -1 + + if not isinstance(buf_list, list) or len(buf_list) == 0: + msg = "buf:%s is not list type or is NONE !" % buf_list + return False, msg + + if not os.path.exists(path): + msg = path + " not found !" + return False, msg + + try: + fd = os.open(path, os.O_WRONLY) + os.lseek(fd, offset, os.SEEK_SET) + ret = os.write(fd, bytes(buf_list)) + except Exception as e: + msg = str(e) + return False, msg + finally: + if fd > 0: + os.close(fd) + + return True, ret + + +def rj_os_system(cmd): + status, output = subprocess.getstatusoutput(cmd) + return status, output + + +def io_rd(reg_addr, read_len=1): + try: + regaddr = 0 + if isinstance(reg_addr, int): + regaddr = reg_addr + else: + regaddr = int(reg_addr, 16) + devfile = "/dev/port" + fd = os.open(devfile, os.O_RDWR | os.O_CREAT) + os.lseek(fd, regaddr, os.SEEK_SET) + str = os.read(fd, read_len) + return "".join(["%02x" % item for item in str]) + except ValueError: + return None + except Exception as e: + print(e) + return None + finally: + os.close(fd) + + +def io_wr(reg_addr, reg_data): + try: + regdata = 0 + regaddr = 0 + if isinstance(reg_addr, int): + regaddr = reg_addr + else: + regaddr = int(reg_addr, 16) + if isinstance(reg_data, int): + regdata = reg_data + else: + regdata = int(reg_data, 16) + devfile = "/dev/port" + fd = os.open(devfile, os.O_RDWR | os.O_CREAT) + os.lseek(fd, regaddr, os.SEEK_SET) + os.write(fd, regdata.to_bytes(1, 'little')) + return True + except ValueError as e: + print(e) + return False + except Exception as e: + print(e) + return False + finally: + os.close(fd) + + +def exec_os_cmd(cmd): + proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True, stderr=subprocess.STDOUT) + stdout = proc.communicate()[0] + proc.wait() + stdout = typeTostr(stdout) + return proc.returncode, stdout + + +def exec_os_cmd_log(cmd): + proc = subprocess.Popen((cmd), stdin=subprocess.PIPE, shell=True, stderr=sys.stderr, close_fds=True, + stdout=sys.stdout, universal_newlines=True, bufsize=1) + + stdout = proc.communicate()[0] + stdout = typeTostr(stdout) + return proc.returncode, stdout + + +def write_sysfs(location, value): + try: + if not os.path.isfile(location): + return False, ("location[%s] not found !" % location) + with open(location, 'w') as fd1: + fd1.write(value) + except Exception as e: + return False, (str(e) + " location[%s]" % location) + return True, ("set location[%s] %s success !" % (location, value)) + + +def read_sysfs(location): + try: + locations = glob.glob(location) + with open(locations[0], 'rb') as fd1: + retval = fd1.read() + retval = typeTostr(retval) + retval = retval.rstrip('\r\n') + retval = retval.lstrip(" ") + except Exception as e: + return False, (str(e) + "location[%s]" % location) + return True, retval + + +def get_value_once(config): + try: + way = config.get("gettype") + int_decode = config.get("int_decode", 16) + if way == 'sysfs': + loc = config.get("loc") + ret, val = read_sysfs(loc) + if ret == True: + return True, int(val, int_decode) + else: + return False, ("sysfs read %s failed. log:%s" % (loc, val)) + elif way == "i2c": + bus = config.get("bus") + addr = config.get("loc") + offset = config.get("offset", 0) + ret, val = rji2cget(bus, addr, offset) + if ret == True: + return True, int(val, int_decode) + else: + return False, ("i2c read failed. bus:%d , addr:0x%x, offset:0x%x" % (bus, addr, offset)) + elif way == "io": + io_addr = config.get('io_addr') + val = io_rd(io_addr) + if len(val) != 0: + return True, int(val, int_decode) + else: + return False, ("io_addr read 0x%x failed" % io_addr) + elif way == "i2cword": + bus = config.get("bus") + addr = config.get("loc") + offset = config.get("offset") + ret, val = rji2cgetWord(bus, addr, offset) + if ret == True: + return True, int(val, int_decode) + else: + return False, ("i2cword read failed. bus:%d, addr:0x%x, offset:0x%x" % (bus, addr, offset)) + elif way == "devfile": + path = config.get("path") + offset = config.get("offset") + read_len = config.get("read_len") + ret, val_list = dev_file_read(path, offset, read_len) + if ret == True: + return True, val_list + else: + return False, ("devfile read failed. path:%s, offset:0x%x, read_len:%d" % (path, offset, read_len)) + elif way == 'cmd': + cmd = config.get("cmd") + ret, val = exec_os_cmd(cmd) + if ret: + return False, ("cmd read exec %s failed, log: %s" % (cmd, val)) + else: + return True, int(val, int_decode) + elif way == 'file_exist': + judge_file = config.get('judge_file', None) + if os.path.exists(judge_file): + return True, True + return True, False + else: + return False, "not support read type" + except Exception as e: + return False, ("get_value_once exception:%s happen" % str(e)) + + +def set_value_once(config): + try: + delay_time = config.get("delay", None) + if delay_time is not None: + time.sleep(delay_time) + + way = config.get("gettype") + if way == 'sysfs': + loc = config.get("loc") + value = config.get("value") + mask = config.get("mask", 0xff) + if mask != 0xff and mask != 0: + ret, read_value = read_sysfs(loc) + if ret == True: + read_value = int(read_value, base=16) + value = (read_value & mask) | value + else: + return False, ("sysfs read %s failed. log:%s" % (loc, read_value)) + ret, log = write_sysfs(loc, "0x%02x" % value) + if ret != True: + return False, ("sysfs %s write 0x%x failed" % (loc, value)) + else: + return True, ("sysfs write 0x%x success" % value) + elif way == "i2c": + bus = config.get("bus") + addr = config.get("loc") + offset = config.get("offset") + value = config.get("value") + mask = config.get("mask", 0xff) + if mask != 0xff and mask != 0: + ret, read_value = rji2cget(bus, addr, offset) + if ret == True: + read_value = int(read_value, base=16) + value = (read_value & mask) | value + else: + return False, ("i2c read failed. bus:%d , addr:0x%x, offset:0x%x" % (bus, addr, offset)) + ret, log = rji2cset(bus, addr, offset, value) + if ret != True: + return False, ("i2c write bus:%d, addr:0x%x, offset:0x%x, value:0x%x failed" % + (bus, addr, offset, value)) + else: + return True, ("i2c write bus:%d, addr:0x%x, offset:0x%x, value:0x%x success" % + (bus, addr, offset, value)) + elif way == "io": + io_addr = config.get('io_addr') + value = config.get('value') + mask = config.get("mask", 0xff) + if mask != 0xff and mask != 0: + read_value = io_rd(io_addr) + if read_value is None: + return False, ("io_addr 0x%x read failed" % (io_addr)) + read_value = int(read_value, base=16) + value = (read_value & mask) | value + ret = io_wr(io_addr, value) + if ret != True: + return False, ("io_addr 0x%x write 0x%x failed" % (io_addr, value)) + else: + return True, ("io_addr 0x%x write 0x%x success" % (io_addr, value)) + elif way == 'i2cword': + bus = config.get("bus") + addr = config.get("loc") + offset = config.get("offset") + value = config.get("value") + mask = config.get("mask", 0xff) + if mask != 0xff and mask != 0: + ret, read_value = rji2cgetWord(bus, addr, offset) + if ret == True: + read_value = int(read_value, base=16) + value = (read_value & mask) | value + else: + return False, ("i2c read word failed. bus:%d , addr:0x%x, offset:0x%x" % (bus, addr, offset)) + ret, log = rji2csetWord(bus, addr, offset, value) + if ret != True: + return False, ("i2cword write bus:%d, addr:0x%x, offset:0x%x, value:0x%x failed" % + (bus, addr, offset, value)) + else: + return True, ("i2cword write bus:%d, addr:0x%x, offset:0x%x, value:0x%x success" % + (bus, addr, offset, value)) + elif way == "devfile": + path = config.get("path") + offset = config.get("offset") + buf_list = config.get("value") + ret, log = dev_file_write(path, offset, buf_list) + if ret == True: + return True, ("devfile write path:%s, offset:0x%x, buf_list:%s success." % (path, offset, buf_list)) + else: + return False, ("devfile read path:%s, offset:0x%x, buf_list:%s failed.log:%s" % + (path, offset, buf_list, log)) + elif way == 'cmd': + cmd = config.get("cmd") + ret, log = exec_os_cmd(cmd) + if ret: + return False, ("cmd write exec %s failed, log: %s" % (cmd, log)) + else: + return True, ("cmd write exec %s success" % cmd) + elif way == 'bit_wr': + mask = config.get("mask") + bit_val = config.get("value") + val_config = config.get("val_config") + ret, rd_value = get_value_once(val_config) + if ret is False: + return False, ("bit_wr read failed, log: %s" % rd_value) + wr_val = (rd_value & mask) | bit_val + val_config["value"] = wr_val + ret, log = set_value_once(val_config) + if ret is False: + return False, ("bit_wr failed, log: %s" % log) + return True, ("bit_wr success, log: %s" % log) + elif way == 'creat_file': + file_name = config.get("file") + ret, log = exec_os_cmd("touch %s" % file_name) + if ret: + return False, ("creat file %s failed, log: %s" % (file_name, log)) + exec_os_cmd("sync") + return True, ("creat file %s success" % file_name) + elif way == 'remove_file': + file_name = config.get("file") + ret, log = exec_os_cmd("rm -rf %s" % file_name) + if ret: + return False, ("remove file %s failed, log: %s" % (file_name, log)) + exec_os_cmd("sync") + return True, ("remove file %s success" % file_name) + else: + return False, "not support write type" + except Exception as e: + return False, ("set_value_once exception:%s happen" % str(e)) + + +def get_value(config): + retrytime = 6 + for i in range(retrytime): + ret, val = get_value_once(config) + if ret == True: + return True, val + time.sleep(0.1) + return False, val + + +def set_value(config): + retrytime = 6 + ignore_result_flag = config.get("ignore_result", 0) + for i in range(retrytime): + ret, log = set_value_once(config) + if ret == True: + return True, log + if ignore_result_flag == 1: + return True, log + time.sleep(0.1) + return False, log diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/script/rg_platform_driver.py b/platform/broadcom/sonic-platform-modules-tencent/common/script/rg_platform_driver.py new file mode 100755 index 000000000000..92e18c0525b9 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/script/rg_platform_driver.py @@ -0,0 +1,244 @@ +#!/usr/bin/env python3 +import click +import os +import subprocess +import time +from ruijieconfig import GLOBALCONFIG + +CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help']) + + +class AliasedGroup(click.Group): + def get_command(self, ctx, cmd_name): + rv = click.Group.get_command(self, ctx, cmd_name) + if rv is not None: + return rv + matches = [x for x in self.list_commands(ctx) + if x.startswith(cmd_name)] + if not matches: + return None + elif len(matches) == 1: + return click.Group.get_command(self, ctx, matches[0]) + ctx.fail('Too many matches: %s' % ', '.join(sorted(matches))) + return None + +def log_os_system(cmd): + status, output = subprocess.getstatusoutput(cmd) + if status: + print(output) + return status, output + + +def check_driver(): + status, output = log_os_system("lsmod | grep rg | wc -l") + if status: + return False + if output.isdigit() and int(output) > 0: + return True + else: + return False + + +def removeDev(bus, loc): + cmd = "echo 0x%02x > /sys/bus/i2c/devices/i2c-%d/delete_device" % (loc, bus) + devpath = "/sys/bus/i2c/devices/%d-%04x" % (bus, loc) + if os.path.exists(devpath): + log_os_system(cmd) + + +def addDev(name, bus, loc): + if name == "lm75": + time.sleep(0.1) + pdevpath = "/sys/bus/i2c/devices/i2c-%d/" % (bus) + for i in range(1, 100): + if os.path.exists(pdevpath) == True: + break + time.sleep(0.1) + if i % 10 == 0: + click.echo("%%RG_PLATFORM_DRIVER-INIT: %s not found, wait 0.1 second ! i %d " % (pdevpath, i)) + + cmd = "echo %s 0x%02x > /sys/bus/i2c/devices/i2c-%d/new_device" % (name, loc, bus) + devpath = "/sys/bus/i2c/devices/%d-%04x" % (bus, loc) + if os.path.exists(devpath) == False: + os.system(cmd) + + +def removeOPTOE(name, startbus, endbus): + for bus in range(endbus, startbus - 1, -1): + removeDev(bus, 0x50) + + +def addOPTOE(name, startbus, endbus): + for bus in range(startbus, endbus + 1): + addDev(name, bus, 0x50) + + +def removeoptoes(): + optoes = GLOBALCONFIG["OPTOE"] + for index in range(len(optoes) - 1, -1, -1): + removeOPTOE(optoes[index]["name"], optoes[index]["startbus"], optoes[index]["endbus"]) + + +def addoptoes(): + optoes = GLOBALCONFIG["OPTOE"] + for index in range(0, len(optoes)): + addOPTOE(optoes[index]["name"], optoes[index]["startbus"], optoes[index]["endbus"]) + + +def removedevs(): + devs = GLOBALCONFIG["DEVS"] + for index in range(len(devs) - 1, -1, -1): + removeDev(devs[index]["bus"], devs[index]["loc"]) + + +def adddevs(): + devs = GLOBALCONFIG["DEVS"] + for dev in range(0, devs.__len__()): + addDev(devs[dev]["name"], devs[dev]["bus"], devs[dev]["loc"]) + + +def checksignaldriver(name): + modisexistcmd = "lsmod | grep -w %s | wc -l" % name + status, output = log_os_system(modisexistcmd) + if status: + return False + if output.isdigit() and int(output) > 0: + return True + else: + return False + + +def adddriver(name, delay): + cmd = "modprobe %s" % name + if delay != 0: + time.sleep(delay) + if checksignaldriver(name) != True: + log_os_system(cmd) + + +def removedriver(name, delay, removeable=1): + realname = name.lstrip().split(" ")[0] + cmd = "rmmod -f %s" % realname + if checksignaldriver(realname) and removeable: + log_os_system(cmd) + + +def removedrivers(): + if GLOBALCONFIG is None: + click.echo("%%RG_PLATFORM_DRIVER-INIT: load global config failed.") + return + drivers = GLOBALCONFIG.get("DRIVERLISTS", None) + if drivers is None: + click.echo("%%RG_PLATFORM_DRIVER-INIT: load driver list failed.") + return + for index in range(len(drivers) - 1, -1, -1): + delay = 0 + name = "" + removeable = drivers[index].get("removable", 1) + if isinstance(drivers[index], dict) and "delay" in drivers[index]: + name = drivers[index].get("name") + delay = drivers[index]["delay"] + else: + name = drivers[index] + removedriver(name, delay, removeable) + + +def adddrivers(): + if GLOBALCONFIG is None: + click.echo("%%RG_PLATFORM_DRIVER-INIT: load global config failed.") + return + drivers = GLOBALCONFIG.get("DRIVERLISTS", None) + if drivers is None: + click.echo("%%RG_PLATFORM_DRIVER-INIT: load driver list failed.") + return + for index in range(0, len(drivers)): + delay = 0 + name = "" + if isinstance(drivers[index], dict) and "delay" in drivers[index]: + name = drivers[index].get("name") + delay = drivers[index]["delay"] + else: + name = drivers[index] + adddriver(name, delay) + + +def blacklist_driver_remove(): + if GLOBALCONFIG is None: + click.echo("%%RG_PLATFORM_DRIVER-INIT: load global config failed.") + return + blacklist_drivers = GLOBALCONFIG.get("BLACKLIST_DRIVERS", []) + for index in range(len(blacklist_drivers)): + delay = 0 + name = "" + if isinstance(blacklist_drivers[index], dict) and "delay" in blacklist_drivers[index]: + name = blacklist_drivers[index].get("name") + delay = blacklist_drivers[index]["delay"] + else: + name = blacklist_drivers[index] + removedriver(name, delay) + + +def unload_driver(): + removeoptoes() + removedevs() + removedrivers() + + +def reload_driver(): + removedevs() + removedrivers() + time.sleep(1) + adddrivers() + adddevs() + + +def i2c_check(bus, retrytime=6): + try: + i2cpath = "/sys/bus/i2c/devices/" + bus + while retrytime and not os.path.exists(i2cpath): + click.echo("%%RG_PLATFORM_DRIVER-HA: i2c bus abnormal, last bus %s is not exist." % i2cpath) + reload_driver() + retrytime -= 1 + time.sleep(1) + except Exception as e: + click.echo("%%RG_PLATFORM_DRIVER-HA: %s" % str(e)) + return + + +def load_driver(): + adddrivers() + adddevs() + addoptoes() + + +@click.group(cls=AliasedGroup, context_settings=CONTEXT_SETTINGS) +def main(): + '''device operator''' + pass + + +@main.command() +def start(): + '''load drivers and device ''' + blacklist_driver_remove() + if check_driver(): + unload_driver() + load_driver() + + +@main.command() +def stop(): + '''stop drivers device ''' + unload_driver() + + +@main.command() +def restart(): + '''restart drivers and device''' + unload_driver() + load_driver() + + +if __name__ == '__main__': + u'''platform drivers and device init operation''' + main() diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/script/rg_platform_process.py b/platform/broadcom/sonic-platform-modules-tencent/common/script/rg_platform_process.py new file mode 100755 index 000000000000..2c581fa0672c --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/script/rg_platform_process.py @@ -0,0 +1,227 @@ +#!/usr/bin/env python3 +import click +import os +import subprocess +from ruijieconfig import STARTMODULE, GLOBALINITPARAM, GLOBALINITCOMMAND, GLOBALINITPARAM_PRE, GLOBALINITCOMMAND_PRE + + +CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help']) + + +class AliasedGroup(click.Group): + def get_command(self, ctx, cmd_name): + rv = click.Group.get_command(self, ctx, cmd_name) + if rv is not None: + return rv + matches = [x for x in self.list_commands(ctx) + if x.startswith(cmd_name)] + if not matches: + return None + elif len(matches) == 1: + return click.Group.get_command(self, ctx, matches[0]) + ctx.fail('Too many matches: %s' % ', '.join(sorted(matches))) + return None + + +def log_os_system(cmd): + status, output = subprocess.getstatusoutput(cmd) + if status: + print(output) + return status, output + + +def write_sysfs_value(reg_name, value): + mb_reg_file = "/sys/bus/i2c/devices/" + reg_name + if (not os.path.isfile(mb_reg_file)): + print(mb_reg_file, 'not found !') + return False + try: + with open(mb_reg_file, 'w') as fd: + fd.write(value) + except Exception as error: + return False + return True + + +def getPid(name): + ret = [] + for dirname in os.listdir('/proc'): + if dirname == 'curproc': + continue + try: + with open('/proc/{}/cmdline'.format(dirname), mode='r') as fd: + content = fd.read() + except Exception: + continue + if name in content: + ret.append(dirname) + return ret + + +def startxdpe_avscontrol(): + if STARTMODULE.get('xdpe_avscontrol', 0) == 1: + cmd = "nohup xdpe_avscontrol.py start >/dev/null 2>&1 &" + rets = getPid("xdpe_avscontrol.py") + if len(rets) == 0: + os.system(cmd) + return + +def starthal_fanctrl(): + if STARTMODULE.get('hal_fanctrl', 0) == 1: + cmd = "nohup hal_fanctrl.py start >/dev/null 2>&1 &" + rets = getPid("hal_fanctrl.py") + if len(rets) == 0: + os.system(cmd) + return + +def starthal_ledctrl(): + if STARTMODULE.get('hal_ledctrl', 0) == 1: + cmd = "nohup hal_ledctrl.py start >/dev/null 2>&1 &" + rets = getPid("hal_ledctrl.py") + if len(rets) == 0: + os.system(cmd) + return + +def startDevmonitor(): + if STARTMODULE.get('dev_monitor', 0) == 1: + cmd = "nohup dev_monitor.py start >/dev/null 2>&1 &" + rets = getPid("dev_monitor.py") + if len(rets) == 0: + os.system(cmd) + return + +def startSff_temp_polling(): + if STARTMODULE.get('sff_temp_polling', 0) == 1: + cmd = "nohup sfp_highest_temperatue.py >/dev/null 2>&1 &" + rets = getPid("sfp_highest_temperatue.py") + if len(rets) == 0: + os.system(cmd) + return + +def startPMON_sys(): + if STARTMODULE.get('rg_pmon_syslog', 0) == 1: + cmd = "nohup rg_pmon_syslog.py >/dev/null 2>&1 &" + rets = getPid("rg_pmon_syslog.py") + if len(rets) == 0: + os.system(cmd) + return + +def stopxdpe_avscontrol(): + if STARTMODULE.get('xdpe_avscontrol', 0) == 1: + rets = getPid("xdpe_avscontrol.py") + for ret in rets: + cmd = "kill " + ret + os.system(cmd) + return + + +def stophal_fanctrl(): + if STARTMODULE.get('hal_fanctrl', 0) == 1: + rets = getPid("hal_fanctrl.py") + for ret in rets: + cmd = "kill " + ret + os.system(cmd) + return + + +def stophal_ledctrl(): + if STARTMODULE.get('hal_ledctrl', 0) == 1: + rets = getPid("hal_ledctrl.py") + for ret in rets: + cmd = "kill " + ret + os.system(cmd) + return + + +def stopDevmonitor(): + if STARTMODULE.get('dev_monitor', 0) == 1: + rets = getPid("dev_monitor.py") # + for ret in rets: + cmd = "kill " + ret + os.system(cmd) + return + + +def stopSff_temp_polling(): + if STARTMODULE.get('sff_temp_polling', 0) == 1: + rets = getPid("sfp_highest_temperatue.py") + for ret in rets: + cmd = "kill " + ret + os.system(cmd) + return + + +def stopPMON_sys(): + if STARTMODULE.get('rg_pmon_syslog', 0) == 1: + rets = getPid("rg_pmon_syslog.py") + for ret in rets: + cmd = "kill " + ret + os.system(cmd) + return + + +def otherinit(): + for index in GLOBALINITPARAM: + write_sysfs_value(index["loc"], index["value"]) + + for index in GLOBALINITCOMMAND: + log_os_system(index) + return + + +def otherinit_pre(): + for index in GLOBALINITPARAM_PRE: + write_sysfs_value(index["loc"], index["value"]) + + for index in GLOBALINITCOMMAND_PRE: + log_os_system(index) + + +def unload_apps(): + stopPMON_sys() + stopDevmonitor() + stopxdpe_avscontrol() + stophal_ledctrl() + stophal_fanctrl() + stopSff_temp_polling() + + +def load_apps(): + otherinit_pre() + startSff_temp_polling() + starthal_fanctrl() + starthal_ledctrl() + startxdpe_avscontrol() + startDevmonitor() + startPMON_sys() + otherinit() + + +@click.group(cls=AliasedGroup, context_settings=CONTEXT_SETTINGS) +def main(): + '''device operator''' + pass + + +@main.command() +def start(): + '''load process ''' + load_apps() + + +@main.command() +def stop(): + '''stop process ''' + unload_apps() + + +@main.command() +def restart(): + '''restart process''' + unload_apps() + load_apps() + + +if __name__ == '__main__': + u'''process init operation''' + main() diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/script/rg_pmon_syslog.py b/platform/broadcom/sonic-platform-modules-tencent/common/script/rg_pmon_syslog.py new file mode 100755 index 000000000000..ff19078c9e9f --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/script/rg_pmon_syslog.py @@ -0,0 +1,518 @@ +#!/usr/bin/python3 +# * onboard interval check +# * FAN trays +# * PSU +# * SFF +import time +import platform +import syslog +import traceback +import glob +from ruijieconfig import PMON_SYSLOG_STATUS + +PMON_DEBUG_FILE = "/etc/.pmon_syslog_debug_flag" +debuglevel = 0 +PMONERROR = 1 +PMONDEBUG = 2 + + +def pmon_debug(s): + if PMONDEBUG & debuglevel: + syslog.openlog("PMON_SYSLOG", syslog.LOG_PID) + syslog.syslog(syslog.LOG_DEBUG, s) + + +def pmon_error(s): + if PMONERROR & debuglevel: + syslog.openlog("PMON_SYSLOG", syslog.LOG_PID) + syslog.syslog(syslog.LOG_ERR, s) + + +def dev_syslog(s): + syslog.openlog("PMON_SYSLOG", syslog.LOG_PID) + syslog.syslog(syslog.LOG_NOTICE, s) + + +# status +STATUS_PRESENT = 'PRESENT' +STATUS_ABSENT = 'ABSENT' +STATUS_OK = 'OK' +STATUS_NOT_OK = 'NOT OK' +STATUS_FAILED = 'FAILED' + + +class checkBase(object): + def __init__(self, path, name, config): + self._peroid_syslog = None + self._peroid_failed_syslog = None # exception + self._preDevStatus = None + self._path = path + self._name = name + self._config = config + + def getCurstatus(self): + # get ok/not ok/absent status + status, log = self.getPresent() + if status == STATUS_PRESENT: + # check status + property_status, log = self.getStatus() + if property_status is not None: + status = property_status + return status, log + + def getPresent(self): + presentFilepath = self.getPath() + try: + # get ok/not ok/absent status + presentConfig = self._config["present"] + mask = presentConfig.get("mask", 0xff) + absent_val = presentConfig.get("ABSENT", None) + absent_val = absent_val & mask + with open(presentFilepath, "r") as fd: + retval = fd.read() + if int(retval) == absent_val: + return STATUS_ABSENT, None + else: + return STATUS_PRESENT, None + except Exception as e: + return STATUS_FAILED, (str(e) + " location[%s]" % presentFilepath) + + def getStatus(self): + if "status" in self._config: + statusConfig = self._config["status"] + for itemConfig in statusConfig: + mask = itemConfig.get("mask", 0xff) + ok_val = itemConfig.get("okval", None) + ok_val = ok_val & mask + Filepath = itemConfig["path"] % self._name + try: + with open(Filepath, "r") as fd1: + retval = fd1.read() + if int(retval) != ok_val: + return STATUS_NOT_OK, None + except Exception as e: + return STATUS_FAILED, (str(e) + " location[%s]" % Filepath) + return STATUS_OK, None + return None, None + + def getPath(self): + pass + + def getName(self): + pass + + def getType(self): + pass + + def getnochangedMsgFlag(self): + return self._config["nochangedmsgflag"] + + def getnochangedMsgTime(self): + return self._config["nochangedmsgtime"] + + def getnoprintFirstTimeFlag(self): + return self._config["noprintfirsttimeflag"] + + def checkStatus(self): + # syslog msg + dev_type = self.getType() + dev_name = self.getName() + nochangedMsgTime = self.getnochangedMsgTime() + getnochangedMsgFlag = self.getnochangedMsgFlag() + noprintFirstTimeFlag = self.getnoprintFirstTimeFlag() + MSG_IN = '%%PMON-5-' + dev_type + '_PLUG_IN: %s is PRESENT.' + MSG_OUT = '%%PMON-5-' + dev_type + '_PLUG_OUT: %s is ABSENT.' + MSG_OK = '%%PMON-5-' + dev_type + '_OK: %s is OK.' + MSG_NOT_OK = '%%PMON-5-' + dev_type + '_FAILED: %s is NOT OK.' + MSG_ABSENT = '%%PMON-5-' + dev_type + '_ABSENT: %s is ABSENT.' + MSG_UNKNOWN = '%%PMON-5-' + dev_type + '_UNKNOWN: %s is UNKNOWN.%s' + MSG_RECOVER = '%%PMON-5-' + dev_type + '_OK: %s is OK. Recover from ' + dev_type + ' FAILED.' + + curStatus, log = self.getCurstatus() + pmon_debug("%s: current status %s" % (dev_name, curStatus)) + pmon_debug("%s: pre status %s" % (dev_name, self._preDevStatus)) + pmon_debug("%s: peroid_syslog %s" % (dev_name, self._peroid_syslog)) + + if curStatus == STATUS_FAILED: + # get status failed + if self._peroid_failed_syslog is not None: + if getnochangedMsgFlag and time.time() - self._peroid_failed_syslog >= nochangedMsgTime: + # absent as before for some time, notice + dev_syslog(MSG_UNKNOWN % (dev_name, log)) + self._peroid_failed_syslog = time.time() + else: # first time failed + dev_syslog(MSG_UNKNOWN % (dev_name, log)) + self._peroid_failed_syslog = time.time() + return + self._peroid_failed_syslog = time.time() + + if self._preDevStatus is None: + # 1st time + if noprintFirstTimeFlag == 1: + self._peroid_syslog = time.time() + else: + if curStatus == STATUS_PRESENT: + # present + dev_syslog(MSG_IN % dev_name) + elif curStatus == STATUS_OK: + # ok + dev_syslog(MSG_OK % dev_name) + elif curStatus == STATUS_NOT_OK: + # not ok + dev_syslog(MSG_NOT_OK % dev_name) + self._peroid_syslog = time.time() + else: + # absent + dev_syslog(MSG_ABSENT % dev_name) + self._peroid_syslog = time.time() + else: + # from 2nd time... + if self._preDevStatus == curStatus: + # status not changed + if self._preDevStatus == STATUS_ABSENT: + if self._peroid_syslog is not None: + if getnochangedMsgFlag and time.time() - self._peroid_syslog >= nochangedMsgTime: + # absent as before for some time, notice + dev_syslog(MSG_ABSENT % dev_name) + self._peroid_syslog = time.time() + elif self._preDevStatus == STATUS_NOT_OK: + if self._peroid_syslog is not None: + if getnochangedMsgFlag and time.time() - self._peroid_syslog >= nochangedMsgTime: + # not ok as before for some time, notice + dev_syslog(MSG_NOT_OK % dev_name) + self._peroid_syslog = time.time() + else: + pass + else: + # status changed + if self._preDevStatus == STATUS_ABSENT: + if curStatus == STATUS_NOT_OK: + # absent -> not ok + dev_syslog(MSG_IN % dev_name) + dev_syslog(MSG_NOT_OK % dev_name) + self._peroid_syslog = time.time() + elif curStatus == STATUS_OK: + # absent -> ok + dev_syslog(MSG_IN % dev_name) + dev_syslog(MSG_OK % dev_name) + else: + # absent -> prsent + dev_syslog(MSG_IN % dev_name) + + elif self._preDevStatus == STATUS_OK: + if(curStatus == STATUS_NOT_OK): + # ok -> not ok + dev_syslog(MSG_NOT_OK % dev_name) + self._peroid_syslog = time.time() + elif curStatus == STATUS_ABSENT: + # ok -> absent + dev_syslog(MSG_OUT % dev_name) + self._peroid_syslog = time.time() + else: + pass + elif self._preDevStatus == STATUS_PRESENT: + # present -> absent + dev_syslog(MSG_OUT % dev_name) + self._peroid_syslog = time.time() + else: # not ok + if curStatus == STATUS_OK: + # not ok -> ok + dev_syslog(MSG_RECOVER % dev_name) + dev_syslog(MSG_OK % dev_name) + else: + # not ok -> absent + dev_syslog(MSG_OUT % dev_name) + self._peroid_syslog = time.time() + self._preDevStatus = curStatus + + +class checkSfp(checkBase): + def __init__(self, path, name, config): + super(checkSfp, self).__init__(path, name, config) + + def getPath(self): + super(checkSfp, self).getPath() + return self._path + + def getName(self): + super(checkSfp, self).getName() + return self._name + + def getType(self): + super(checkSfp, self).getType() + return 'XCVR' + + +class checkSlot(checkBase): + def __init__(self, path, name, config): + super(checkSlot, self).__init__(path, name, config) + + def getPath(self): + super(checkSlot, self).getPath() + return self._path + + def getName(self): + super(checkSlot, self).getName() + return self._name + + def getType(self): + super(checkSlot, self).getType() + return 'SLOT' + + +class checkPSU(checkBase): + def __init__(self, path, name, config): + super(checkPSU, self).__init__(path, name, config) + + def getPath(self): + super(checkPSU, self).getPath() + return self._path + + def getName(self): + super(checkPSU, self).getName() + return self._name + + def getType(self): + super(checkPSU, self).getType() + return 'PSU' + + +class checkFAN(checkBase): + def __init__(self, path, name, config): + super(checkFAN, self).__init__(path, name, config) + + def getPath(self): + super(checkFAN, self).getPath() + return self._path + + def getName(self): + super(checkFAN, self).getName() + return self._name + + def getType(self): + super(checkFAN, self).getType() + return 'FAN' + + +class platformSyslog(): + def __init__(self): + self.__sfp_checklist = list() + self.__fan_checklist = list() + self.__psu_checklist = list() + self.__slot_checklist = list() + self.__temp_checklist = list() + self.temps_peroid_syslog = {} + self.normal_status = 0 + self.warning_status = 1 + self.critical_status = 2 + self.poweron_flag = 0 + + self.pmon_syslog_config = PMON_SYSLOG_STATUS.copy() + self.__pollingtime = self.pmon_syslog_config.get('polling_time', 3) + + tmpconfig = self.pmon_syslog_config.get('sffs', None) + if tmpconfig is not None: + preset_item = tmpconfig.get("present", {}) + path = preset_item.get("path", []) + for location in path: + if '*' not in location: + pmon_error("sff location config error: %s" % location) + continue + dev_name_index = 0 + loc_split_list = location.split('/') + for i in range(len(loc_split_list)): + if '*' in loc_split_list[i]: + dev_name_index = i + break + locations = glob.glob(location) + for dev_path in locations: + dev_name_list = dev_path.split('/') + dev_name = dev_name_list[dev_name_index] # explame:get eth1 from /sys_switch/transceiver/eth1/present + dev_name_alias = tmpconfig.get("alias", {}) + dev_name = dev_name_alias.get(dev_name, dev_name) + dev = checkSfp(dev_path, dev_name, tmpconfig) + self.__sfp_checklist.append(dev) + + tmpconfig = self.pmon_syslog_config.get('fans', None) + if tmpconfig is not None: + preset_item = tmpconfig.get("present", {}) + path = preset_item.get("path", []) + for location in path: + if '*' not in location: + pmon_error("fan location config error: %s" % location) + continue + dev_name_index = 0 + loc_split_list = location.split('/') + for i in range(len(loc_split_list)): + if '*' in loc_split_list[i]: + dev_name_index = i + break + locations = glob.glob(location) + for dev_path in locations: + dev_name_list = dev_path.split('/') + dev_name = dev_name_list[dev_name_index] + dev_name_alias = tmpconfig.get("alias", {}) + dev_name = dev_name_alias.get(dev_name, dev_name) + dev = checkFAN(dev_path, dev_name, tmpconfig) + self.__fan_checklist.append(dev) + + tmpconfig = self.pmon_syslog_config.get('psus', None) + if tmpconfig is not None: + preset_item = tmpconfig.get("present", {}) + path = preset_item.get("path", []) + for location in path: + if '*' not in location: + pmon_error("psu location config error: %s" % location) + continue + dev_name_index = 0 + loc_split_list = location.split('/') + for i in range(len(loc_split_list)): + if '*' in loc_split_list[i]: + dev_name_index = i + break + locations = glob.glob(location) + for dev_path in locations: + dev_name_list = dev_path.split('/') + dev_name = dev_name_list[dev_name_index] + dev_name_alias = tmpconfig.get("alias", {}) + dev_name = dev_name_alias.get(dev_name, dev_name) + dev = checkPSU(dev_path, dev_name, tmpconfig) + self.__psu_checklist.append(dev) + + tmpconfig = self.pmon_syslog_config.get('slots', None) + if tmpconfig is not None: + preset_item = tmpconfig.get("present", {}) + path = preset_item.get("path", []) + for location in path: + if '*' not in location: + pmon_error("slot location config error: %s" % location) + continue + dev_name_index = 0 + loc_split_list = location.split('/') + for i in range(len(loc_split_list)): + if '*' in loc_split_list[i]: + dev_name_index = i + break + locations = glob.glob(location) + for dev_path in locations: + dev_name_list = dev_path.split('/') + dev_name = dev_name_list[dev_name_index] + dev_name_alias = tmpconfig.get("alias", {}) + dev_name = dev_name_alias.get(dev_name, dev_name) + dev = checkSlot(dev_path, dev_name, tmpconfig) + self.__slot_checklist.append(dev) + + tmpconfig = self.pmon_syslog_config.get('temps', None) + if tmpconfig is not None: + self.__temp_checklist = tmpconfig.get('temps_list', []) + self.__temps_pollingseconds = tmpconfig.get('over_temps_polling_seconds', None) + + def checkTempStaus(self, temp_item): + temp_name = temp_item.get('name', None) + input_path = temp_item.get('input_path', None) + warning_temp = temp_item.get('warning', None) + critical_temp = temp_item.get('critical', None) + input_accuracy = temp_item.get('input_accuracy', None) + if temp_name is None or input_path is None or warning_temp is None or critical_temp is None: + dev_syslog('%%PMON-5-TEMP_NOTICE: get temperature config parament failed.') + return + try: + locations = glob.glob(input_path) + with open(locations[0], "r") as fd: + input_temp = fd.read() + input_temp = float(input_temp) / float(input_accuracy) + + if 'time' not in temp_item: + temp_item['time'] = time.time() + temp_item['status'] = self.normal_status + if float(input_temp) >= float(warning_temp): + if float(input_temp) >= float(critical_temp): + if time.time() - temp_item['time'] >= self.__temps_pollingseconds or temp_item['status'] != self.critical_status: + dev_syslog('%%PMON-5-TEMP_HIGH: %s temperature %sC is larger than max critical threshold %sC.' + % (temp_name, input_temp, critical_temp)) + temp_item['status'] = self.critical_status + temp_item['time'] = time.time() + else: + if time.time() - temp_item['time'] >= self.__temps_pollingseconds or temp_item['status'] != self.warning_status: + dev_syslog('%%PMON-5-TEMP_HIGH: %s temperature %sC is larger than max warning threshold %sC.' + % (temp_name, input_temp, warning_temp)) + temp_item['status'] = self.warning_status + temp_item['time'] = time.time() + else: + pmon_debug("%s temperature %sC is in range [%s, %s]" % (temp_name, input_temp, warning_temp, critical_temp)) + temp_item['status'] = self.normal_status + temp_item['time'] = time.time() + except Exception as e: + dev_syslog('%%PMON-5-TEMP_NOTICE: Cannot get %s temperature. Exception log: %s' % (temp_name, str(e))) + return + + def sysfs_precondition_check(self, check_module, check_project): + try: + tmpconfig = self.pmon_syslog_config.get(check_module, None) + if tmpconfig is not None: + check_list = tmpconfig.get(check_project, []) + for check_item in check_list: + location = check_item.get("path", None) + ok_val = check_item.get("ok_val", None) + mask = check_item.get("mask", 0xff) + ok_val = ok_val & mask + locations = glob.glob(location) + for power_path in locations: + with open(power_path, "r") as fd: + retval = fd.read() + if int(retval) == ok_val: + continue + else: + return + self.poweron_flag = 1 + except Exception as e: + dev_syslog('%%PMON-5-TEMP_NOTICE: Cannot check power status. Exception log: %s' % str(e)) + return + + def updateSysDeviceStatus(self): + if self.poweron_flag == 1: + for dev in self.__sfp_checklist: + dev.checkStatus() + else: + self.sysfs_precondition_check('sffs', 'power') + + for dev in self.__fan_checklist: + dev.checkStatus() + for dev in self.__psu_checklist: + dev.checkStatus() + for dev in self.__slot_checklist: + dev.checkStatus() + for temp_item in self.__temp_checklist: + self.checkTempStaus(temp_item) + + def getPollingtime(self): + return self.__pollingtime + + def debug_init(self): + global debuglevel + try: + with open(PMON_DEBUG_FILE, "r") as fd: + value = fd.read() + debuglevel = int(value) + except Exception as e: + debuglevel = 0 + return + + def doWork(self): + try: + self.debug_init() + self.updateSysDeviceStatus() + except Exception as e: + MSG_EXCEPTION = '%%PMON-5-NOTICE: Exception happened! info:{%s}' + pmon_error(MSG_EXCEPTION % traceback.format_exc()) + + +def run(platform): + while True: + platform.doWork() + time.sleep(platform.getPollingtime()) + + +if __name__ == '__main__': + platform = platformSyslog() + run(platform) diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/script/ruijiecommon.py b/platform/broadcom/sonic-platform-modules-tencent/common/script/ruijiecommon.py new file mode 100755 index 000000000000..539a1a3ff7db --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/script/ruijiecommon.py @@ -0,0 +1,43 @@ +#!/usr/bin/python3 +# ------------------------------------------------------------------------------- +# Author: sonic_rd@ruijie.com.cn +# +# Created: 02/07/2018 +# Copyright: 2001-2022 Ruijie Network. All rights reserved. +# ------------------------------------------------------------------------------- +__all__ = [ + "GLOBALCONFIG", + "STARTMODULE", + "MAC_AVS_PARAM", + "MAC_DEFAULT_PARAM", + "DEV_MONITOR_PARAM", + "MANUINFO_CONF", + "AVS_VOUT_MODE_PARAM", + "PMON_SYSLOG_STATUS", + "OPTOE", + "BLACKLIST_DRIVERS", + "INIT_PARAM_PRE", + "INIT_COMMAND_PRE", + "INIT_PARAM", + "INIT_COMMAND", + "DRIVERLISTS", + "DEVICE", +] + + +GLOBALCONFIG = {} +STARTMODULE = {} +MAC_AVS_PARAM = {} +MAC_DEFAULT_PARAM = {} +DEV_MONITOR_PARAM = {} +MANUINFO_CONF = {} +AVS_VOUT_MODE_PARAM = {} +PMON_SYSLOG_STATUS = {} +OPTOE = [] +BLACKLIST_DRIVERS = [] +INIT_PARAM_PRE = [] +INIT_COMMAND_PRE = [] +INIT_PARAM = [] +INIT_COMMAND = [] +DRIVERLISTS = [] +DEVICE = [] diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/script/ruijieconfig.py b/platform/broadcom/sonic-platform-modules-tencent/common/script/ruijieconfig.py new file mode 100755 index 000000000000..4559d2201dfb --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/script/ruijieconfig.py @@ -0,0 +1,86 @@ +#!/usr/bin/python3 +#------------------------------------------------------------------------------- +# Name: ruijieconfig.py +# +# Author: sonic_rd@ruijie.com.cn +# +# Created: 02/07/2018 +# Copyright: 2001-2022 Ruijie Network. All rights reserved. +#------------------------------------------------------------------------------- +import sys +import os +from rjutil.baseutil import get_machine_info +from rjutil.baseutil import get_platform_info +from rjutil.baseutil import get_board_id + + +def getdeviceplatform(): + x = get_platform_info(get_machine_info()) + if x is not None: + filepath = "/usr/share/sonic/device/" + x + return filepath + return None + + +platform = get_platform_info(get_machine_info()) +board_id = get_board_id(get_machine_info()) +platformpath = getdeviceplatform() +MAILBOX_DIR = "/sys/bus/i2c/devices/" +grtd_productfile = (platform + "_config").replace("-", "_") +common_productfile = "ruijiecommon" +platform_configfile = (platform + "_" + board_id + "_config").replace("-", "_") # platfrom + board_id +configfile_pre = "/usr/local/bin/" +sys.path.append(platformpath) +sys.path.append(configfile_pre) + + +def get_rjconfig_info(attr_key): + rjconf_filename = platformpath + "/plugins" + "/rj.conf" + if not os.path.isfile(rjconf_filename): + return None + with open(rjconf_filename) as rjconf_file: + for line in rjconf_file: + tokens = line.split('=') + if len(tokens) < 2: + continue + if tokens[0] == attr_key: + return tokens[1].strip() + return None + + +############################################################################################ +if os.path.exists(configfile_pre + platform_configfile + ".py"): + module_product = __import__(platform_configfile, globals(), locals(), [], 0) +elif os.path.exists(configfile_pre + grtd_productfile + ".py"): + module_product = __import__(grtd_productfile, globals(), locals(), [], 0) +elif os.path.exists(configfile_pre + common_productfile + ".py"): + module_product = __import__(common_productfile, globals(), locals(), [], 0) +else: + print("config file not exist") + exit(-1) +############################################################################################ + +DEVICE = module_product.DEVICE + +RUIJIE_GLOBALCONFIG ={ + "DRIVERLISTS":module_product.DRIVERLISTS, + "OPTOE": module_product.OPTOE, + "DEVS": DEVICE, + "BLACKLIST_DRIVERS": module_product.BLACKLIST_DRIVERS +} +GLOBALCONFIG = RUIJIE_GLOBALCONFIG +GLOBALINITPARAM = module_product.INIT_PARAM +GLOBALINITCOMMAND = module_product.INIT_COMMAND +GLOBALINITPARAM_PRE = module_product.INIT_PARAM_PRE +GLOBALINITCOMMAND_PRE = module_product.INIT_COMMAND_PRE + +STARTMODULE = module_product.STARTMODULE + +DEV_MONITOR_PARAM = module_product.DEV_MONITOR_PARAM +PMON_SYSLOG_STATUS = module_product.PMON_SYSLOG_STATUS + +MAC_AVS_PARAM = module_product.MAC_AVS_PARAM +MAC_DEFAULT_PARAM = module_product.MAC_DEFAULT_PARAM + +MANUINFO_CONF = module_product.MANUINFO_CONF +AVS_VOUT_MODE_PARAM = module_product.AVS_VOUT_MODE_PARAM diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/script/ruijieutil.py b/platform/broadcom/sonic-platform-modules-tencent/common/script/ruijieutil.py new file mode 100755 index 000000000000..13bcbf7ba036 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/script/ruijieutil.py @@ -0,0 +1,72 @@ +#!/usr/bin/python3 +# ------------------------------------------------------------------------- +# +# Author: sonic_rd +# +# Created: 02/07/2018 +# Copyright: 2001-2022 Ruijie Network. All rights reserved. +# ------------------------------------------------------------------------- +import sys +import os +import re +import time +from ruijieconfig import STARTMODULE +from platform_util import rj_os_system + + +def getSdkReg(reg): + try: + cmd = "bcmcmd -t 1 'getr %s ' < /dev/null" % reg + ret, result = rj_os_system(cmd) + result_t = result.strip().replace("\r", "").replace("\n", "") + if ret != 0 or "Error:" in result_t: + return False, result + patt = r"%s.(.*):(.*)>drivshell" % reg + rt = re.findall(patt, result_t, re.S) + test = re.findall("=(.*)", rt[0][0])[0] + except Exception as e: + return False, 'getsdk register error' + return True, test + + +def waitForDhcp(timeout): + time_cnt = 0 + while True: + try: + ret, status = rj_os_system("systemctl status dhcp_relay.service") + if (ret == 0 and "running" in status) or "SUCCESS" in status: + break + else: + sys.stdout.write(".") + sys.stdout.flush() + time_cnt = time_cnt + 1 + if time_cnt > timeout: + raise Exception("waitForDhcp timeout") + time.sleep(1) + except Exception as e: + return False + return True + +def waitForSdk(sdk_fpath ,timeout): + time_cnt = 0 + while True: + try: + if os.path.exists(sdk_fpath): + break + else: + #sys.stdout.write(".") + #sys.stdout.flush() + time_cnt = time_cnt + 1 + if time_cnt > timeout: + raise Exception("waitForSdk timeout") + time.sleep(1) + except Exception as e: + return False + return True + +def waitForDocker(need_restart=False,timeout=180): + sdkcheck_params = STARTMODULE.get("sdkcheck",{}) + if sdkcheck_params.get("checktype") == "file": + sdk_fpath = sdkcheck_params.get("sdk_fpath") + return waitForSdk(sdk_fpath,timeout) + return waitForDhcp(timeout) diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/script/sensors b/platform/broadcom/sonic-platform-modules-tencent/common/script/sensors new file mode 100755 index 000000000000..a2c72b123a43 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/script/sensors @@ -0,0 +1,8 @@ +#!/bin/bash +#docker exec -i pmon sensors "$@" + + +#To probe sensors not part of lm-sensors +if [ -r /usr/local/bin/platform_sensors.py ]; then + python /usr/local/bin/platform_sensors.py +fi diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/script/sfp_highest_temperatue.py b/platform/broadcom/sonic-platform-modules-tencent/common/script/sfp_highest_temperatue.py new file mode 100755 index 000000000000..be1960a131ea --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/script/sfp_highest_temperatue.py @@ -0,0 +1,150 @@ +#!/usr/bin/python3 +import os +import importlib.machinery +import time +import syslog +import subprocess +import fcntl + +sfp_temperature_file = "/tmp/highest_sff_temp" + +SFP_TEMP_DEBUG_FILE = "/etc/.sfp_temp_debug_flag" +SFP_TEMP_RECORD_DEBUG = 1 +SFP_TEMP_RECORD_ERROR = 2 +debuglevel = 0 + + +def sfp_temp_debug(s): + if SFP_TEMP_RECORD_DEBUG & debuglevel: + syslog.openlog("SFP_TEMP_DEBUG", syslog.LOG_PID) + syslog.syslog(syslog.LOG_DEBUG, s) + + +def sfp_temp_error(s): + if SFP_TEMP_RECORD_ERROR & debuglevel: + syslog.openlog("SFP_TEMP_ERROR", syslog.LOG_PID) + syslog.syslog(syslog.LOG_ERR, s) + + +pidfile = -1 + + +def file_rw_lock(): + global pidfile + pidfile = open(sfp_temperature_file, "r") + try: + fcntl.flock(pidfile, fcntl.LOCK_EX | fcntl.LOCK_NB) + sfp_temp_debug("file lock success") + return True + except Exception as e: + pidfile.close() + pidfile = -1 + return False + + +def file_rw_unlock(): + try: + global pidfile + + if pidfile != -1: + fcntl.flock(pidfile, fcntl.LOCK_UN) + pidfile.close() + pidfile = -1 + sfp_temp_debug("file unlock success") + else: + sfp_temp_debug("pidfile is invalid, do nothing") + return True + except Exception as e: + sfp_temp_error("file unlock err, msg:%s" % (str(e))) + return False + + +def get_sfp_highest_temperature(): + highest_temperature = 0 + platform_sfputil = None + + sfputil_dir = "/usr/share/sonic/device/" + try: + if not os.path.exists(sfputil_dir): + sfputil_dir = "/usr/share/sonic/platform/" + sfputil_path = sfputil_dir + "/plugins/sfputil.py" + else: + cmd = "cat /host/machine.conf | grep onie_build_platform" + ret, output = subprocess.getstatusoutput(cmd) + if ret != 0: + sfp_temp_error("cmd: %s execution fail, output: %s" % (cmd, output)) + + onie_platform = output.split("=")[1] + sfputil_path = sfputil_dir + onie_platform + "/plugins/sfputil.py" + + module = importlib.machinery.SourceFileLoader("sfputil", sfputil_path).load_module() + platform_sfputil_class = getattr(module, "SfpUtil") + platform_sfputil = platform_sfputil_class() + + temperature = platform_sfputil.get_highest_temperature() + highest_temperature = int(temperature) * 1000 + except Exception as e: + sfp_temp_error("get sfp temperature error, msg:%s" % str(e)) + highest_temperature = -9999000 + + return highest_temperature + + +def write_sfp_highest_temperature(temperature): + + loop = 1000 + ret = False + try: + if os.path.exists(sfp_temperature_file) is False: + with open(sfp_temperature_file, 'w') as sfp_f: + pass + for i in range(0, loop): + ret = file_rw_lock() + if ret is True: + break + time.sleep(0.001) + + if ret is False: + sfp_temp_error("take file lock timeout") + return + + with open(sfp_temperature_file, 'w') as sfp_f: + sfp_f.write("%s\n" % str(temperature)) + + file_rw_unlock() + return + except Exception as e: + sfp_temp_error("write sfp temperature error, msg:%s" % str(e)) + file_rw_unlock() + return + + +def debug_init(): + global debuglevel + + try: + with open(SFP_TEMP_DEBUG_FILE, "r") as fd: + value = fd.read() + debuglevel = int(value) + except Exception as e: + debuglevel = 0 + return + + +def main(): + with open(sfp_temperature_file, 'w') as sfp_f: + pass + while True: + debug_init() + temperature = 0 + try: + temperature = get_sfp_highest_temperature() + write_sfp_highest_temperature(temperature) + except Exception as e: + sfp_temp_error("get/write sfp temperature error, msg:%s" % str(e)) + write_sfp_highest_temperature(-9999000) + time.sleep(5) + + +if __name__ == '__main__': + main() diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/script/xdpe_avscontrol.py b/platform/broadcom/sonic-platform-modules-tencent/common/script/xdpe_avscontrol.py new file mode 100755 index 000000000000..515a8aa01c74 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/script/xdpe_avscontrol.py @@ -0,0 +1,217 @@ +#!/usr/bin/env python3 +import click +import os +import time +import syslog +from ruijieconfig import MAC_DEFAULT_PARAM, MAC_AVS_PARAM, AVS_VOUT_MODE_PARAM +from ruijieutil import getSdkReg +from platform_util import rji2cget, rji2cset, rji2csetWord, rji2cgetWord, write_sysfs, get_value + + +AVSCTROL_DEBUG_FILE = "/etc/.avscontrol_debug_flag" + +AVSCTROLERROR = 1 +AVSCTROLDEBUG = 2 + +debuglevel = 0 + +CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help']) + + +class AliasedGroup(click.Group): + def get_command(self, ctx, cmd_name): + rv = click.Group.get_command(self, ctx, cmd_name) + if rv is not None: + return rv + matches = [x for x in self.list_commands(ctx) + if x.startswith(cmd_name)] + if not matches: + return None + elif len(matches) == 1: + return click.Group.get_command(self, ctx, matches[0]) + ctx.fail('Too many matches: %s' % ', '.join(sorted(matches))) + return None + + +def avscontrol_debug(s): + if AVSCTROLDEBUG & debuglevel: + syslog.openlog("AVSCONTROL", syslog.LOG_PID) + syslog.syslog(syslog.LOG_DEBUG, s) + + +def avscontrol_error(s): + if AVSCTROLERROR & debuglevel: + syslog.openlog("AVSCONTROL", syslog.LOG_PID) + syslog.syslog(syslog.LOG_ERR, s) + + +def avserror(s): + # s = s.decode('utf-8').encode('gb2312') + syslog.openlog("AVSCONTROL", syslog.LOG_PID) + syslog.syslog(syslog.LOG_ERR, s) + + +def avsinfo(s): + syslog.openlog("AVSCONTROL", syslog.LOG_PID) + syslog.syslog(syslog.LOG_INFO, s) + + +def debug_init(): + global debuglevel + if os.path.exists(AVSCTROL_DEBUG_FILE): + debuglevel = debuglevel | AVSCTROLDEBUG | AVSCTROLERROR + else: + debuglevel = debuglevel & ~(AVSCTROLDEBUG | AVSCTROLERROR) + + +def set_avs_value_i2c(dcdc_value): + avs_bus = MAC_DEFAULT_PARAM["bus"] + avs_addr = MAC_DEFAULT_PARAM["devno"] + avs_loop_addr = MAC_DEFAULT_PARAM["loopaddr"] + avs_loop_val = MAC_DEFAULT_PARAM["loop"] + vout_mode_addr = MAC_DEFAULT_PARAM["vout_mode_addr"] + vout_cmd_addr = MAC_DEFAULT_PARAM["vout_cmd_addr"] + org_loop_value = None + try: + status, val = rji2cget(avs_bus, avs_addr, avs_loop_addr) + if status is not True: + raise Exception("get original loop value failed.") + org_loop_value = int(val, 16) + + status, val = rji2cset(avs_bus, avs_addr, avs_loop_addr, avs_loop_val) + if status is not True: + raise Exception("set loop value failed.") + + status, val = rji2cget(avs_bus, avs_addr, vout_mode_addr) + if status is not True: + raise Exception("get vout mode failed.") + vout_mode_value = int(val, 16) + if vout_mode_value not in AVS_VOUT_MODE_PARAM.keys(): + raise Exception("invalid vout mode.") + + vout_cmd_val = int(dcdc_value * AVS_VOUT_MODE_PARAM[vout_mode_value]) + avscontrol_debug("org_loop:0x%x, dcdc_value:%s, vout_mode:0x%x, vout_cmd_val:0x%x." % + (org_loop_value, dcdc_value, vout_mode_value, vout_cmd_val)) + rji2csetWord(avs_bus, avs_addr, vout_cmd_addr, vout_cmd_val) + status, val = rji2cgetWord(avs_bus, avs_addr, vout_cmd_addr) + if status is not True or strtoint(val) != vout_cmd_val: + raise Exception("set vout command data failed. status:%s, write value:0x%x, read value:0x%x" % + (status, vout_cmd_val, strtoint(val))) + avscontrol_debug("set vout command data success.") + + except Exception as e: + avscontrol_error(str(e)) + status = False + + if org_loop_value is not None: + rji2cset(avs_bus, avs_addr, avs_loop_addr, org_loop_value) + return status + + +def set_avs_value_sysfs(conf, dcdc_value): + loc = conf.get("loc") + formula = conf.get("formula", None) + avscontrol_debug("set_avs_value_sysfs, loc: %s, origin dcdc value: %s, formula: %s" % + (loc, dcdc_value, formula)) + if formula is not None: + dcdc_value = eval(formula % (dcdc_value)) + wr_val = str(dcdc_value) + avscontrol_debug("set_avs_value_sysfs, write val: %s" % wr_val) + ret, msg = write_sysfs(loc, wr_val) + if ret is False: + avscontrol_error("set_avs_value_sysfs failed, msg: %s" % msg) + return ret + + +def set_avs_value(dcdc_value): + set_avs_way = MAC_DEFAULT_PARAM.get("set_avs", {}).get("gettype") + if set_avs_way == "sysfs": + ret = set_avs_value_sysfs(MAC_DEFAULT_PARAM["set_avs"], dcdc_value) + else: + ret = set_avs_value_i2c(dcdc_value) + return ret + +def get_dcdc_value(rov_value): + if rov_value not in MAC_AVS_PARAM.keys(): + if MAC_DEFAULT_PARAM["type"] == 0: + avsinfo("VID:0x%x out of range, voltage regulate stop." % rov_value) + return False, None + dcdc_value = MAC_AVS_PARAM[MAC_DEFAULT_PARAM["default"]] + avsinfo("VID:0x%x out of range, use default VID:0x%x." % (rov_value, dcdc_value)) + else: + dcdc_value = MAC_AVS_PARAM[rov_value] + return True, dcdc_value + + +def get_rov_value_cpld(): + cpld_avs_config = MAC_DEFAULT_PARAM["cpld_avs"] + return get_value(cpld_avs_config) + + +def get_rov_value_sdk(): + name = MAC_DEFAULT_PARAM["sdkreg"] + ret, status = getSdkReg(name) + if ret == False: + return False, None + status = strtoint(status) + # shift operation + if MAC_DEFAULT_PARAM["sdktype"] != 0: + status = ( + status >> MAC_DEFAULT_PARAM["macregloc"]) & MAC_DEFAULT_PARAM["mask"] + macavs = status + return True, macavs + + +def doAvsCtrol(): + try: + rov_source = MAC_DEFAULT_PARAM["rov_source"] + if rov_source == 0: + ret, rov_value = get_rov_value_cpld() # get rov from cpld reg + else: + ret, rov_value = get_rov_value_sdk() # get rov from sdk reg + if ret is False: + return False + avscontrol_debug("rov_value:0x%x." % rov_value) + ret, dcdc_value = get_dcdc_value(rov_value) + if ret is False: + return False + ret = set_avs_value(dcdc_value) + return ret + except Exception as e: + avscontrol_error(str(e)) + return False + + +def run(): + index = 0 + # wait 30s for device steady + time.sleep(30) + while True: + debug_init() + ret = doAvsCtrol() + if ret is True: + avsinfo("%%AVSCONTROL success") + time.sleep(5) + exit(0) + index += 1 + if index >= 10: + avserror("%%DEV_MONITOR-AVS: MAC Voltage adjust failed.") + exit(-1) + time.sleep(1) + + +@click.group(cls=AliasedGroup, context_settings=CONTEXT_SETTINGS) +def main(): + '''device operator''' + pass + + +@main.command() +def start(): + '''start AVS control''' + avsinfo("%%AVSCONTROL start") + run() + + +if __name__ == '__main__': + main() diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/service/rg_platform_driver.service b/platform/broadcom/sonic-platform-modules-tencent/common/service/rg_platform_driver.service new file mode 100755 index 000000000000..ad10dcad87e0 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/service/rg_platform_driver.service @@ -0,0 +1,15 @@ +[Unit] +Description= Ruijie Global Initialize platform drivers. +After=local-fs.target +Before=pmon.service rg_platform_process.service swss.service syncd.service +#DefaultDependencies=no + +[Service] +Type=oneshot +ExecStart=/usr/local/bin/rg_platform_driver.py start +ExecStop=/usr/local/bin/rg_platform_driver.py stop +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target + diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/service/rg_platform_process.service b/platform/broadcom/sonic-platform-modules-tencent/common/service/rg_platform_process.service new file mode 100755 index 000000000000..18c911bd48e5 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/service/rg_platform_process.service @@ -0,0 +1,15 @@ +[Unit] +Description= Ruijie Global Load process. +After=rg_platform_driver.service s3ip_sysfs.service +Requires=rg_platform_driver.service +#DefaultDependencies=no + +[Service] +Type=oneshot +ExecStart=/usr/local/bin/rg_platform_process.py start +ExecStop=/usr/local/bin/rg_platform_process.py stop +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target + diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/__init__.py b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/__init__.py new file mode 100755 index 000000000000..052dab2e8797 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/__init__.py @@ -0,0 +1,2 @@ +__all__ = ["platform", "chassis", "sfp", "eeprom", "component", "thermal", "psu", "fan", "fan_drawer", "watchdog"] +from . import platform \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/chassis.py new file mode 100755 index 000000000000..1ac10917c738 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/chassis.py @@ -0,0 +1,577 @@ +#!/usr/bin/env python3 + +############################################################################# +# +# +# Module contains an implementation of SONiC Platform Base API and +# provides the platform information +# +############################################################################# + +try: + import time + from sonic_platform_base.chassis_base import ChassisBase + from sonic_platform.sfp import Sfp + from sonic_platform.psu import Psu + from sonic_platform.fan import Fan + from sonic_platform.fan_drawer import FanDrawer + from sonic_platform.thermal import Thermal + from sonic_platform.component import Component + from sonic_platform.eeprom import Eeprom + from sonic_platform.logger import logger + from sonic_platform.dcdc import Dcdc + + from plat_hal.interface import interface + from plat_hal.baseutil import baseutil +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +class Chassis(ChassisBase): + """ + Platform-specific Chassis class + """ + # List of Dcdc objects representing all dcdc + # available on the chassis + _dcdc_list = None + + STATUS_INSERTED = "1" + STATUS_REMOVED = "0" + STATUS_NORMAL = "0" + STATUS_ABNORMAL = "1" + port_dict = {} + fan_present_dict = {} + voltage_status_dict = {} + + + def __init__(self): + ChassisBase.__init__(self) + self._dcdc_list = [] + self.int_case = interface() + conf = None + conf = baseutil.get_config() + port_cfg = conf.get("sfps", None) + self.port_start = port_cfg.get("port_start", 0) + self.port_end = port_cfg.get("port_end", 0) + + sfp_node = Sfp(self.port_start) + if sfp_node._get_config("port_index_start") == 1: + self._sfp_list.append(sfp_node) + # Initialize SFP list + + # sfp.py will read eeprom contents and retrive the eeprom data. + # It will also provide support sfp controls like reset and setting + # low power mode. + # We pass the eeprom path and sfp control path from chassis.py + # So that sfp.py implementation can be generic to all platforms + for index in range(self.port_start, self.port_end + 1): + sfp_node = Sfp(index) + self._sfp_list.append(sfp_node) + if sfp_node.get_presence(): + self.port_dict[index] = self.STATUS_INSERTED + # sfp_node.check_sfp_optoe_type() + else: + self.port_dict[index] = self.STATUS_REMOVED + + self._eeprom = Eeprom(self.int_case) + + fan_num = self.int_case.get_fan_total_number() + drawer_fan_list = [] + for index in range(fan_num): + fanobj = Fan(self.int_case, index + 1) + self._fan_list.append(fanobj) + drawer_fan_list.append(fanobj) + if drawer_fan_list: + fan_drawer = FanDrawer(0, fan_list=drawer_fan_list) + self._fan_drawer_list.append(fan_drawer) + + psu_num = self.int_case.get_psu_total_number() + for index in range(psu_num): + psuobj = Psu(self.int_case, index + 1) + self._psu_list.append(psuobj) + + thermal_num = self.int_case.get_temp_id_number() + for index in range(thermal_num): + thermalobj = Thermal(self.int_case, index + 1) + self._thermal_list.append(thermalobj) + + component_num = self.int_case.get_cpld_total_number() + for index in range(component_num): + componentobj = Component(self.int_case, index + 1) + self._component_list.append(componentobj) + + dcdc_num = self.int_case.get_dcdc_total_number() + for index in range(dcdc_num): + dcdcobj = Dcdc(self.int_case, index + 1) + self._dcdc_list.append(dcdcobj) + ''' + # init fan present status + for index in range(0, len(self._fan_list)): + if self._fan_list[index].get_presence() is True: + self.fan_present_dict[index] = self.STATUS_INSERTED + else: + self.fan_present_dict[index] = self.STATUS_REMOVED + + # init voltage status + for index in range(0, len(self._dcdc_list)): + name = self._dcdc_list[index].get_name() + value = self._dcdc_list[index].get_value() + high = self._dcdc_list[index].get_high_threshold() + low = self._dcdc_list[index].get_low_threshold() + if (value is None) or (value > high) or (value < low): + self.voltage_status_dict[name] = self.STATUS_ABNORMAL + else: + self.voltage_status_dict[name] = self.STATUS_NORMAL + ''' + + def get_name(self): + """ + Retrieves the name of the chassis + Returns: + string: The name of the chassis + """ + name = '' + sys_eeprom = self.get_eeprom() + if sys_eeprom is None: + self.log_error('syseeprom is not inited.') + return '' + + e = sys_eeprom.read_eeprom() + name = sys_eeprom.modelstr(e) + if name is None: + self.log_error('syseeprom name is error.') + return '' + return name + + def get_presence(self): + """ + Retrieves the presence of the chassis + Returns: + bool: True if chassis is present, False if not + """ + return True + + def get_model(self): + """ + Retrieves the model number (or part number) of the chassis + Returns: + string: Model/part number of chassis + """ + model = '' + sys_eeprom = self.get_eeprom() + if sys_eeprom is None: + self.log_error('syseeprom is not inited.') + return '' + + e = sys_eeprom.read_eeprom() + model = sys_eeprom.modelnumber(e) + if model is None: + self.log_error('syseeprom model number is error.') + return '' + return model + + def get_serial_number(self): + """ + Retrieves the hardware serial number for the chassis + + Returns: + A string containing the hardware serial number for this chassis. + """ + serial_number = '' + sys_eeprom = self.get_eeprom() + if sys_eeprom is None: + self.log_error('syseeprom is not inited.') + return '' + + e = sys_eeprom.read_eeprom() + serial_number = sys_eeprom.serial_number_str(e) + if serial_number is None: + self.log_error('syseeprom serial number is error.') + return '' + + return serial_number + + def get_revision(self): + """ + Retrieves the hardware revision of the device + + Returns: + string: Revision value of device + """ + device_version = '' + sys_eeprom = self.get_eeprom() + if sys_eeprom is None: + self.log_error('syseeprom is not inited.') + return '' + + e = sys_eeprom.read_eeprom() + device_version = sys_eeprom.deviceversion(e) + if device_version is None: + self.log_error('syseeprom serial number is error.') + return '' + + return device_version + + def get_serial(self): + """ + Retrieves the serial number of the chassis (Service tag) + Returns: + string: Serial number of chassis + """ + return self.get_serial_number() + + def get_status(self): + """ + Retrieves the operational status of the chassis + Returns: + bool: A boolean value, True if chassis is operating properly + False if not + """ + return True + + def get_position_in_parent(self): + """ + Retrieves 1-based relative physical position in parent device. If the agent cannot determine the parent-relative position + for some reason, or if the associated value of entPhysicalContainedIn is '0', then the value '-1' is returned + Returns: + integer: The 1-based relative physical position in parent device or -1 if cannot determine the position + """ + return -1 + + def is_replaceable(self): + """ + Indicate whether this device is replaceable. + Returns: + bool: True if it is replaceable. + """ + return False + + def get_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. + """ + ret, color = self.int_case.get_led_color_by_type('SYS_LED') + if ret is True: + return color + else: + return 'N/A' + + 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' + """ + base_mac = '' + sys_eeprom = self.get_eeprom() + if sys_eeprom is None: + self.log_error('syseeprom is not inited.') + return '' + + e = sys_eeprom.read_eeprom() + base_mac = sys_eeprom.base_mac_addr(e) + if base_mac is None: + self.log_error('syseeprom base mac is error.') + return '' + + return base_mac.upper() + + def get_system_eeprom_info(self): + """ + Retrieves the full content of system EEPROM information for the chassis + + Returns: + A dictionary where keys are the type code defined in + OCP ONIE TlvInfo EEPROM format and values are their corresponding + values. + Ex. { '0x21':'AG9064', '0x22':'V1.0', '0x23':'AG9064-0109867821', + '0x24':'001c0f000fcd0a', '0x25':'02/03/2018 16:22:00', + '0x26':'01', '0x27':'REV01', '0x28':'AG9064-C2358-16G'} + """ + sys_eeprom_dict = dict() + sys_eeprom = self.get_eeprom() + if sys_eeprom is None: + self.log_error('syseeprom is not inited.') + return {} + + e = sys_eeprom.read_eeprom() + if sys_eeprom._TLV_HDR_ENABLED: + if not sys_eeprom.is_valid_tlvinfo_header(e): + self.log_error('syseeprom tlv header error.') + return {} + total_len = (e[9] << 8) | e[10] + tlv_index = sys_eeprom._TLV_INFO_HDR_LEN + tlv_end = sys_eeprom._TLV_INFO_HDR_LEN + total_len + else: + tlv_index = sys_eeprom.eeprom_start + tlv_end = sys_eeprom._TLV_INFO_MAX_LEN + + while (tlv_index + 2) < len(e) and tlv_index < tlv_end: + if not sys_eeprom.is_valid_tlv(e[tlv_index:]): + self.log_error("Invalid TLV field starting at EEPROM offset %d" % tlv_index) + break + + tlv = e[tlv_index:tlv_index + 2 + e[tlv_index + 1]] + name, value = sys_eeprom.decoder(None, tlv) + sys_eeprom_dict[name] = value + + if e[tlv_index] == sys_eeprom._TLV_CODE_QUANTA_CRC or \ + e[tlv_index] == sys_eeprom._TLV_CODE_CRC_32: + break + tlv_index += e[tlv_index + 1] + 2 + + return sys_eeprom_dict + + def get_thermal_manager(self): + """ + Retrieves thermal manager class on this chassis + :return: A class derived from ThermalManagerBase representing the + specified thermal manager. ThermalManagerBase is returned as default + """ + return False + + 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. + """ + reset_num = self.int_case.get_cpu_reset_num() + # cold reboot + if reset_num == 0: + return(self.REBOOT_CAUSE_POWER_LOSS, None) + + return (self.REBOOT_CAUSE_NON_HARDWARE, None) + + def get_module(self, index): + """ + Retrieves module represented by (0-based) index + + Args: + index: An integer, the index (0-based) of the module to + retrieve + + Returns: + An object dervied from ModuleBase representing the specified + module + """ + module = None + + try: + if self.get_num_modules(): + module = self._module_list[index] + except IndexError: + sys.stderr.write("Module index {} out of range (0-{})\n".format( + index, len(self._module_list)-1)) + + return module + + def get_fan_drawer(self, index): + """ + Retrieves fan drawers represented by (0-based) index + + Args: + index: An integer, the index (0-based) of the fan drawer to + retrieve + + Returns: + An object dervied from FanDrawerBase representing the specified fan + drawer + """ + fan_drawer = None + + try: + if self.get_num_fan_drawers(): + fan_drawer = self._fan_drawer_list[index] + except IndexError: + sys.stderr.write("Fan drawer index {} out of range (0-{})\n".format( + index, len(self._fan_drawer_list)-1)) + + return fan_drawer + + 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): + - bool: True if call successful, False if not; + - dict: 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. + The known devices's device_id and device_event was defined as table below. + ----------------------------------------------------------------- + device | device_id | device_event | annotate + ----------------------------------------------------------------- + 'fan' '' '0' Fan removed + '1' Fan inserted + + 'sfp' '' '0' Sfp removed + '1' Sfp inserted + '2' I2C bus stuck + '3' Bad eeprom + '4' Unsupported cable + '5' High Temperature + '6' Bad cable + + 'voltage' '' '0' Vout normal + '1' Vout abnormal + -------------------------------------------------------------------- + Ex. {'fan':{'0':'0', '2':'1'}, 'sfp':{'11':'0', '12':'1'}, + 'voltage':{'U20':'0', 'U21':'1'}} + Indicates that: + fan 0 has been removed, fan 2 has been inserted. + sfp 11 has been removed, sfp 12 has been inserted. + monitored voltage U20 became normal, voltage U21 became abnormal. + Note: For sfp, when event 3-6 happened, the module will not be avalaible, + XCVRD shall stop to read eeprom before SFP recovered from error status. + """ + + change_event_dict = {"fan": {}, "sfp": {}, "voltage": {}} + + start_time = time.time() + forever = False + + if timeout == 0: + forever = True + elif timeout > 0: + timeout = timeout / float(1000) # Convert to secs + else: + print("get_change_event:Invalid timeout value", timeout) + return False, change_event_dict + + end_time = start_time + timeout + if start_time > end_time: + print( + "get_change_event:" "time wrap / invalid timeout value", + timeout, + ) + return False, change_event_dict # Time wrap or possibly incorrect timeout + try: + while timeout >= 0: + # check for sfp + sfp_change_dict = self.get_transceiver_change_event() + # check for fan + fan_change_dict = self.get_fan_change_event() + # check for voltage + voltage_change_dict = self.get_voltage_change_event() + + if sfp_change_dict or fan_change_dict or voltage_change_dict: + change_event_dict["sfp"] = sfp_change_dict + change_event_dict["fan"] = fan_change_dict + change_event_dict["voltage"] = voltage_change_dict + return True, change_event_dict + if forever: + time.sleep(1) + else: + timeout = end_time - time.time() + if timeout >= 1: + time.sleep(1) # We poll at 1 second granularity + else: + if timeout > 0: + time.sleep(timeout) + return True, change_event_dict + except Exception as e: + logger.error(str(e)) + print(e) + print("get_change_event: Should not reach here.") + return False, change_event_dict + + def get_transceiver_change_event(self): + current_port_dict = {} + ret_dict = {} + + # Check for OIR events and return ret_dict + for index in range(self.port_start, self.port_end + 1): + if self._sfp_list[index].get_presence(): + current_port_dict[index] = self.STATUS_INSERTED + else: + current_port_dict[index] = self.STATUS_REMOVED + + if len(self.port_dict) == 0: # first time + self.port_dict = current_port_dict + return {} + + if current_port_dict == self.port_dict: + return {} + + # Update reg value + for index, status in current_port_dict.items(): + if self.port_dict[index] != status: + ret_dict[index] = status + #ret_dict[str(index)] = status + self.port_dict = current_port_dict + for index, status in ret_dict.items(): + if int(status) == 1: + pass + #self._sfp_list[int(index)].check_sfp_optoe_type() + return ret_dict + + def get_fan_change_event(self): + currernt_fan_present_dict = {} + ret_dict = {} + + # Check for OIR events and return ret_dict + for index in range(0, len(self._fan_list)): + if self._fan_list[index].get_presence() is True: + currernt_fan_present_dict[index] = self.STATUS_INSERTED + else: + currernt_fan_present_dict[index] = self.STATUS_REMOVED + + if len(self.fan_present_dict) == 0: # first time + self.fan_present_dict = currernt_fan_present_dict + return {} + + if currernt_fan_present_dict == self.fan_present_dict: + return {} + + # updated fan_present_dict + for index, status in currernt_fan_present_dict.items(): + if self.fan_present_dict[index] != status: + ret_dict[str(index)] = status + self.fan_present_dict = currernt_fan_present_dict + return ret_dict + + def get_voltage_change_event(self): + currernt_voltage_status_dict = {} + ret_dict = {} + + # Check for OIR events and return ret_dict + for index in range(0, len(self._dcdc_list)): + name = self._dcdc_list[index].get_name() + value = self._dcdc_list[index].get_value() + high = self._dcdc_list[index].get_high_threshold() + low = self._dcdc_list[index].get_low_threshold() + if (value is None) or (value > high) or (value < low): + currernt_voltage_status_dict[name] = self.STATUS_ABNORMAL + else: + currernt_voltage_status_dict[name] = self.STATUS_NORMAL + + if len(self.voltage_status_dict) == 0: # first time + self.voltage_status_dict = currernt_voltage_status_dict + return {} + + if currernt_voltage_status_dict == self.voltage_status_dict: + return {} + + # updated voltage_status_dict + for name, status in currernt_voltage_status_dict.items(): + if self.voltage_status_dict[name] != status: + ret_dict[name] = status + self.voltage_status_dict = currernt_voltage_status_dict + return ret_dict diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/component.py b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/component.py new file mode 100755 index 000000000000..4fb655540ce2 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/component.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python3 + +######################################################################## +# Ruijie B6510-48VS8CQ +# +# Module contains an implementation of SONiC Platform Base API and +# provides the Components' (e.g., BIOS, CPLD, FPGA, etc.) available in +# the platform +# +######################################################################## + +try: + import time + from sonic_platform_base.component_base import ComponentBase + from sonic_platform.logger import logger +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class Component(ComponentBase): + """Ruijie Platform-specific Component class""" + + def __init__(self, interface_obj, index): + self.cpld_dict = {} + self.int_case = interface_obj + self.index = index + self.update_time = 0 + self.cpld_id = "CPLD" + str(index) + + def cpld_dict_update(self): + local_time = time.time() + if not self.cpld_dict or (local_time - self.update_time) >= 1: # update data every 1 seconds + self.update_time = local_time + self.cpld_dict = self.int_case.get_cpld_version_by_id(self.cpld_id) + + def get_name(self): + """ + Retrieves the name of the component + + Returns: + A string containing the name of the component + """ + self.cpld_dict_update() + return self.cpld_dict["Name"] + + def get_description(self): + """ + Retrieves the description of the component + + Returns: + A string containing the description of the component + """ + self.cpld_dict_update() + return self.cpld_dict["Desc"] + + def get_firmware_version(self): + """ + Retrieves the firmware version of the component + + Returns: + A string containing the firmware version of the component + """ + self.cpld_dict_update() + return self.cpld_dict["Version"] + + def install_firmware(self, image_path): + """ + Installs firmware to the component + + Args: + image_path: A string, path to firmware image + + Returns: + A boolean, True if install was successful, False if not + """ + # not supported + return False + diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/dcdc.py b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/dcdc.py new file mode 100755 index 000000000000..9500b3a6a79f --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/dcdc.py @@ -0,0 +1,94 @@ +#!/usr/bin/env python3 + +######################################################################## +# RUIJIE +# +# Module contains an implementation of SONiC Platform Base API and +# provides the Thermals' information which are available in the platform +# +######################################################################## + + +try: + import time + from sonic_platform.logger import logger +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class Dcdc(object): + + def __init__(self, interface_obj, index): + self.dcdc_dict = {} + self.int_case = interface_obj + self.index = index + self.update_time = 0 + self.dcdc_id = "DCDC" + str(index) + + #self.dcdc_dict = self.int_case.get_dcdc_by_id(self.dcdc_id) + + def dcdc_dict_update(self): + local_time = time.time() + if not self.dcdc_dict or (local_time - self.update_time) >= 1: # update data every 1 seconds + self.update_time = local_time + self.dcdc_dict = self.int_case.get_dcdc_by_id(self.dcdc_id) + + def get_name(self): + """ + Retrieves the name of the sensor + + Returns: + string: The name of the sensor + """ + self.dcdc_dict_update() + return self.dcdc_dict["Name"] + + def get_value(self): + """ + Retrieves current value reading from sensor + """ + self.dcdc_dict_update() + value = self.dcdc_dict["Value"] + if value is None: + value = 0 + return round(float(value), 3) + + def get_high_threshold(self): + """ + Retrieves the high threshold temperature of sensor + """ + self.dcdc_dict_update() + value = self.dcdc_dict["High"] + if value is None: + value = 0 + return round(float(value), 3) + + def get_low_threshold(self): + """ + Retrieves the low threshold temperature of sensor + """ + self.dcdc_dict_update() + value = self.dcdc_dict["Low"] + if value is None: + value = 0 + return round(float(value), 3) + + def get_high_critical_threshold(self): + """ + Retrieves the high critical threshold temperature of sensor + """ + self.dcdc_dict_update() + value = self.dcdc_dict["Max"] + if value is None: + value = 0 + return round(float(value), 3) + + def get_low_critical_threshold(self): + """ + Retrieves the low critical threshold temperature of sensor + """ + self.dcdc_dict_update() + value = self.dcdc_dict["Min"] + if value is None: + value = 0 + return round(float(value), 3) diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/eeprom.py b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/eeprom.py new file mode 100755 index 000000000000..16dbd76fb150 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/eeprom.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python3 +######################################################################## +# Ruijie +# +# Module contains platform specific implementation of SONiC Platform +# Base API and provides the EEPROMs' information. +# +# 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. +######################################################################## + +try: + from sonic_eeprom import eeprom_tlvinfo +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +class Eeprom(eeprom_tlvinfo.TlvInfoDecoder): + + def __init__(self, interface_obj): + self.int_case = interface_obj + self.name = "ONIE_E2" + + eeprom_path = self.int_case.get_onie_e2_path(self.name) + if eeprom_path is None: + raise ValueError("get eeprom path failed") + + super(Eeprom, self).__init__(eeprom_path, 0, "", True) + + + def modelnumber(self, e): + ''' + Returns the value field of the model(part) number TLV as a string + ''' + (is_valid, t) = self.get_tlv_field(e, self._TLV_CODE_PART_NUMBER) + if not is_valid: + return super(TlvInfoDecoder, self).part_number_str(e) + + return t[2].decode("ascii") + + def deviceversion(self, e): + ''' + Returns the value field of the Device Version as a string + ''' + (is_valid, t) = self.get_tlv_field(e, self._TLV_CODE_DEVICE_VERSION) + if not is_valid: + return "N/A" + + return str(ord(t[2])) + diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/fan.py b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/fan.py new file mode 100755 index 000000000000..27bd3ff47986 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/fan.py @@ -0,0 +1,310 @@ +#!/usr/bin/env python3 +######################################################################## +# Ruijie +# +# Module contains an implementation of SONiC Platform Base API and +# provides the Fans' information which are available in the platform. +# +######################################################################## + +try: + import time + from sonic_platform_base.fan_base import FanBase + from sonic_platform.logger import logger +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class Fan(FanBase): + """Ruijie Platform-specific Fan class""" + + def __init__(self, interface_obj, index, psu_fan=False, psu_index=0): + self.fan_dict = {} + self.int_case = interface_obj + self.index = index + self.psu_index = psu_index + self.is_psu_fan = psu_fan + + if not self.is_psu_fan: + self.name = "FAN" + str(index) + else: + self.name = "PSU" + str(psu_index) + + def fan_dict_update(self): + local_time = time.time() + if not self.fan_dict or (local_time - self.update_time) >= 1: # update data every 1 seconds + self.update_time = local_time + if not self.is_psu_fan: + self.fan_dict = self.int_case.get_fan_info(self.name) + else: + self.fan_dict = self.int_case.get_psu_fru_info(self.name) + + def get_name(self): + """ + Retrieves the fan name + Returns: + string: The name of the device + """ + if not self.is_psu_fan: + return "Fan{}".format(self.index) + else: + return "Psu{}-Fan{}".format(self.psu_index, self.index) + + def get_model(self): + """ + Retrieves the part number of the FAN + Returns: + string: Part number of FAN + """ + if not self.is_psu_fan: + self.fan_dict_update() + return self.fan_dict["NAME"] + else: + return 'N/A' + + def get_serial(self): + """ + Retrieves the serial number of the FAN + Returns: + string: Serial number of FAN + """ + if not self.is_psu_fan: + self.fan_dict_update() + return self.fan_dict["SN"] + else: + return 'N/A' + + def get_presence(self): + """ + Retrieves the presence of the FAN + Returns: + bool: True if fan is present, False if not + """ + if not self.is_psu_fan: + return self.int_case.get_fan_presence(self.name) + else: + return self.int_case.get_psu_presence(self.name) + + def checkFanRotorStatus(self): + err_num = 0 + rotor_num = self.int_case.get_fan_rotor_number(self.name) + for i in range(rotor_num): + rotor_name = "Rotor" + str(i + 1) + status = self.int_case.get_fan_rotor_status(self.name, rotor_name) + if status == False: + err_num = err_num + 1 + if (err_num == 0): + return True + else: + return False + + def get_status(self): + """ + Retrieves the operational status of the FAN + Returns: + bool: True if FAN is operating properly, False if not + """ + if not self.get_presence(): + return False + + speed = self.get_speed() + tolerance = self.get_speed_tolerance() + target = self.get_target_speed() + if (speed - target) > target * tolerance / 100: + return False + if (target - speed) > target * tolerance / 100: + return False + + return True + + 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 True + + def get_direction(self): + """ + Retrieves the fan airflow direction + Returns: + A string, either FAN_DIRECTION_INTAKE or FAN_DIRECTION_EXHAUST + depending on fan direction + + Notes: + - Forward/Exhaust : Air flows from Port side to Fan side. + - Reverse/Intake : Air flows from Fan side to Port side. + """ + self.fan_dict_update() + air_flow = self.fan_dict["AirFlow"] + if air_flow == "F2B": + return self.FAN_DIRECTION_INTAKE + elif air_flow == "B2F": + return self.FAN_DIRECTION_EXHAUST + else: + return self.FAN_DIRECTION_NOT_APPLICABLE + + 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) + """ + if not self.get_presence(): + return 0 + + if not self.is_psu_fan: + fan_dir = {} + fan_dir = self.int_case.get_fan_info_rotor(self.name) + # get fan rotor1 pwm + value = fan_dir["Rotor1"]["Speed"] + max = fan_dir["Rotor1"]["SpeedMax"] + else: + psu_status_dict = self.int_case.get_psu_status(self.name) + value = psu_status_dict["FanSpeed"]["Value"] + max = psu_status_dict["FanSpeed"]["Max"] + + if isinstance(value, str) or value is None: + return 0 + pwm = value * 100 / max + if pwm > 100: + pwm = 100 + elif pwm < 0: + pwm = 0 + return int(pwm) + + 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 + """ + # The default tolerance value is fixed as 30% for all the Ruijie platform + if not self.is_psu_fan: + fan_dir = {} + fan_dir = self.int_case.get_fan_info_rotor(self.name) + # get fan rotor1 tolerance + tolerance = fan_dir["Rotor1"]["Tolerance"] + else: + psu_status_dict = self.int_case.get_psu_status(self.name) + tolerance = psu_status_dict["FanSpeed"]["Tolerance"] + + if isinstance(tolerance, str) or tolerance is None: + return 30 + return tolerance + + def fan_set_speed_pwm(self, pwm): + err_num = 0 + rotor_num = self.int_case.get_fan_rotor_number(self.name) + for i in range(rotor_num): + status = self.int_case.set_fan_speed_pwm(self.name, i + 1, pwm) + if status == -1: + err_num = err_num + 1 + if err_num == 0: + return True + else: + return False + + def set_speed(self, speed): + """ + Set fan speed to expected value + Args: + speed: An integer, the percentage of full fan speed to set fan to, + in the range 0 (off) to 100 (full speed) + Returns: + bool: True if set success, False if fail. + """ + if not self.is_psu_fan: + return self.fan_set_speed_pwm(speed) + else: + return self.int_case.set_psu_fan_speed_pwm(self.name, int(speed)) + + 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. + """ + # not supported + return False + + 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.is_psu_fan: + # No LED available for PSU Fan + return 'N/A' + + ret, color = self.int_case.get_fan_led(self.name) + if ret is True: + return color + else: + return 'N/A' + + def get_target_speed(self): + """ + Retrieves the target (expected) speed of the fan + Returns: + An integer, the percentage of full fan speed, in the range 0 (off) + to 100 (full speed) + """ + if not self.is_psu_fan: + # get fan rotor1 pwm + pwm = int(self.int_case.get_fan_speed_pwm(self.name, 0)) + else: + psu_status_dict = self.int_case.get_psu_status(self.name) + if psu_status_dict["InputStatus"] is False: + pwm = 0 + else: + psu_pwm = int(self.int_case.get_psu_fan_speed_pwm(self.name)) + if psu_pwm == 0: # psu fan not control + pwm = self.get_speed() # target equal to real pwm, to avoid alarm + else: + pwm = psu_pwm + return int(pwm) + + def get_vendor(self): + """ + Retrieves the vendor name of the fan + + Returns: + string: Vendor name of fan + """ + if not self.is_psu_fan: + return "Ruijie" + else: + return 'N/A' + + def get_revision(self): + """ + Retrieves the hardware revision of the device + + Returns: + string: Revision value of device + """ + if not self.is_psu_fan: + self.fan_dict_update() + return self.fan_dict["HW"] + else: + return 'N/A' + diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/fan_drawer.py b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/fan_drawer.py new file mode 100755 index 000000000000..a99ec6ae0705 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/fan_drawer.py @@ -0,0 +1,99 @@ +#!/usr/bin/env python3 +# +# fan_drawer_base.py +# +# Abstract base class for implementing a platform-specific class with which +# to interact with a fan drawer module in SONiC +# + +try: + from sonic_platform_base.fan_drawer_base import FanDrawerBase +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class FanDrawer(FanDrawerBase): + """ + Abstract base class for interfacing with a fan drawer + """ + # Device type definition. Note, this is a constant. + DEVICE_TYPE = "fan_drawer" + + def __init__(self, index, fan_list): + FanDrawerBase.__init__(self) + + self._fan_list = fan_list + self._index = index + + def get_name(self): + """ + Retrieves the name of the device + Returns: + string: The name of the device + """ + return "fan {}".format(self._index) + + def get_num_fans(self): + """ + Retrieves the number of fans available on this fan drawer + Returns: + An integer, the number of fan modules available on this fan drawer + """ + return len(self._fan_list) + + def get_all_fans(self): + """ + Retrieves all fan modules available on this fan drawer + Returns: + A list of objects derived from FanBase representing all fan + modules available on this fan drawer + """ + return self._fan_list + + def set_status_led(self, color): + """ + Sets the state of the fan drawer status LED + Args: + color: A string representing the color with which to set the + fan drawer status LED + Returns: + bool: True if status LED state is set successfully, False if not + """ + # not supported + return False + + def get_status_led(self, color): + """ + Gets the state of the fan drawer LED + Returns: + A string, one of the predefined STATUS_LED_COLOR_* strings above + """ + # not supported + return False + + def get_revision(self): + """ + Retrieves the hardware revision of the device + + Returns: + string: Revision value of device + """ + return 'N/A' + + def get_position_in_parent(self): + """ + Retrieves 1-based relative physical position in parent device. If the agent cannot determine the parent-relative position + for some reason, or if the associated value of entPhysicalContainedIn is '0', then the value '-1' is returned + Returns: + integer: The 1-based relative physical position in parent device or -1 if cannot determine the position + """ + return -1 + + 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-tencent/common/sonic_platform/logger.py b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/logger.py new file mode 100755 index 000000000000..61ef1647e5f2 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/logger.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 +import logging + + +def _init_logger(): + formatter = logging.Formatter( + "%(asctime)s %(levelname)s %(filename)s[%(funcName)s][%(lineno)s]: %(message)s" + ) + handler = logging.FileHandler("/var/log/syslog") + handler.setFormatter(formatter) + + logger = logging.getLogger(__name__) + logger.setLevel(logging.DEBUG) + logger.addHandler(handler) + return logger + + +logger = _init_logger() diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/platform.py b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/platform.py new file mode 100755 index 000000000000..ddf670369226 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/platform.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python3 + +############################################################################# +# Ruijie +# +# 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): + """ + Ruijie Platform-specific class + """ + + def __init__(self): + PlatformBase.__init__(self) + self._chassis = Chassis() diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/psu.py b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/psu.py new file mode 100755 index 000000000000..70e8fb588387 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/psu.py @@ -0,0 +1,360 @@ +#!/usr/bin/env python3 +######################################################################## +# Ruijie +# +# Module contains an implementation of SONiC Platform Base API and +# provides the PSUs' information which are available in the platform +# +######################################################################## + + +try: + import time + from sonic_platform_base.psu_base import PsuBase + from sonic_platform.fan import Fan + from sonic_platform.logger import logger +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class Psu(PsuBase): + """Ruijie Platform-specific PSU class""" + + def __init__(self, interface_obj, index): + self.psu_dict = {} + self.psu_status_dict = {} + self.psu_power_dict = {} + self._fan_list = [] + self._thermal_list = [] + self.int_case = interface_obj + self.index = index + self.name = "PSU" + str(index) + + self.psu_dict_update_time = 0 + self.psu_status_dict_update_time = 0 + self.psu_power_dict_update_time = 0 + + self._fan_list.append(Fan(self.int_case, 1, psu_fan=True, psu_index=index)) + + def psu_dict_update(self): + local_time = time.time() + if not self.psu_dict or (local_time - self.psu_dict_update_time) >= 1: # update data every 1 seconds + self.psu_dict_update_time = local_time + self.psu_dict = self.int_case.get_psu_fru_info(self.name) + + def psu_status_dict_update(self): + local_time = time.time() + if not self.psu_status_dict or ( + local_time - self.psu_status_dict_update_time) >= 1: # update data every 1 seconds + self.psu_status_dict_update_time = local_time + self.psu_status_dict = self.int_case.get_psu_status(self.name) + + def psu_power_dict_update(self): + local_time = time.time() + if not self.psu_power_dict or ( + local_time - self.psu_power_dict_update_time) >= 1: # update data every 1 seconds + self.psu_power_dict_update_time = local_time + self.psu_power_dict = self.int_case.get_psu_power_status(self.name) + + def get_name(self): + """ + Retrieves the name of the device + + Returns: + string: The name of the device + """ + return "Psu{}".format(self.index) + + def get_presence(self): + """ + Retrieves the presence of the Power Supply Unit (PSU) + + Returns: + bool: True if PSU is present, False if not + """ + return self.int_case.get_psu_presence(self.name) + + def get_model(self): + """ + Retrieves the part number of the PSU + + Returns: + string: Part number of PSU + """ + self.psu_dict_update() + return self.psu_dict["DisplayName"] + + def get_serial(self): + """ + Retrieves the serial number of the PSU + + Returns: + string: Serial number of PSU + """ + self.psu_dict_update() + return self.psu_dict["SN"] + + def get_status(self): + """ + Retrieves the operational status of the PSU + + Returns: + bool: True if PSU is operating properly, False if not + """ + return self.int_case.get_psu_input_output_status(self.name) + + 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 True + + def get_voltage(self): + """ + Retrieves current PSU voltage output + + Returns: + A float number, the output voltage in volts, + e.g. 12.1 + """ + self.psu_status_dict_update() + if self.psu_status_dict["InputStatus"] is False: + value = 0 + else: + self.psu_power_dict_update() + value = self.psu_power_dict["Outputs"]["Voltage"]["Value"] + if value is None: + value = 0 + return round(float(value), 1) + + def get_current(self): + """ + Retrieves present electric current supplied by PSU + + Returns: + A float number, electric current in amperes, + e.g. 15.4 + """ + self.psu_status_dict_update() + if self.psu_status_dict["InputStatus"] is False: + value = 0 + else: + self.psu_power_dict_update() + value = self.psu_power_dict["Outputs"]["Current"]["Value"] + if value is None: + value = 0 + return round(float(value), 1) + + def get_power(self): + """ + Retrieves current energy supplied by PSU + + Returns: + A float number, the power in watts, + e.g. 302.6 + """ + self.psu_status_dict_update() + if self.psu_status_dict["InputStatus"] is False: + value = 0 + else: + self.psu_power_dict_update() + value = self.psu_power_dict["Outputs"]["Power"]["Value"] + if value is None: + value = 0 + return round(float(value), 1) + + 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.int_case.get_psu_input_output_status(self.name) + + def get_status_led(self): + """ + Gets the state of the PSU status LED + + Returns: + A string, one of the predefined STATUS_LED_COLOR_* strings. + """ + if self.int_case.get_psu_input_output_status(self.name): + return self.STATUS_LED_COLOR_GREEN + else: + return self.STATUS_LED_COLOR_RED + + def set_status_led(self, color): + """ + Sets the state of the PSU status LED + Args: + color: A string representing the color with which to set the + PSU status LED + Returns: + bool: True if status LED state is set successfully, False if + not + """ + # not supported + 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 + """ + self.psu_status_dict_update() + value = self.psu_status_dict["Temperature"]["Value"] + if value is None: + value = 0 + return round(float(value), 1) + + 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 + """ + self.psu_status_dict_update() + value = self.psu_status_dict["Temperature"]["Max"] + if value is None: + value = 0 + return round(float(value), 1) + + 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 + """ + self.psu_power_dict_update() + value = self.psu_power_dict["Outputs"]["Voltage"]["HighAlarm"] + if value is None: + value = 0 + return round(float(value), 1) + + 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 + """ + self.psu_power_dict_update() + value = self.psu_power_dict["Outputs"]["Voltage"]["LowAlarm"] + if value is None: + value = 0 + return round(float(value), 1) + + def get_input_voltage(self): + """ + Get the input voltage of the PSU + + Returns: + A float number, the input voltage in volts, + """ + self.psu_status_dict_update() + if self.psu_status_dict["InputStatus"] is False: + value = 0 + else: + self.psu_power_dict_update() + value = self.psu_power_dict["Inputs"]["Voltage"]["Value"] + if value is None: + value = 0 + return round(float(value), 1) + + def get_input_current(self): + """ + Get the input electric current of the PSU + + Returns: + A float number, the input current in amperes, e.g 220.3 + """ + self.psu_status_dict_update() + if self.psu_status_dict["InputStatus"] is False: + value = 0 + else: + self.psu_power_dict_update() + value = self.psu_power_dict["Inputs"]["Current"]["Value"] + if value is None: + value = 0 + return round(float(value), 1) + + def get_input_power(self): + """ + Get the input current energy of the PSU + + Returns: + A float number, the input power in watts, e.g. 302.6 + """ + self.psu_status_dict_update() + if self.psu_status_dict["InputStatus"] is False: + value = 0 + else: + self.psu_power_dict_update() + value = self.psu_power_dict["Inputs"]["Power"]["Value"] + if value is None: + value = 0 + return round(float(value), 1) + + def get_revision(self): + """ + Retrieves the hardware revision of the device + + Returns: + string: Revision value of device + """ + self.psu_dict_update() + return self.psu_dict["HW"] + + def get_vendor(self): + """ + Retrieves the vendor name of the psu + + Returns: + string: Vendor name of psu + """ + self.psu_dict_update() + return self.psu_dict["VENDOR"] + + def get_maximum_supplied_power(self): + """ + Retrieves the maximum supplied power by PSU + + Returns: + A float number, the maximum power output in Watts. + e.g. 1200.1 + """ + return False + + def get_thermal(self, index): + """ + Retrieves thermal unit represented by (0-based) index + + Args: + index: An integer, the index (0-based) of the thermal to + retrieve + + Returns: + An object dervied from ThermalBase representing the specified thermal + """ + return False diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/sfp.py b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/sfp.py new file mode 100755 index 000000000000..60115886ee8e --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/sfp.py @@ -0,0 +1,301 @@ +#!/usr/bin/python3 +############################################################################# +# +# Module contains an implementation of SONiC Platform Base API and +# provides the platform information +# +############################################################################# +import time +import syslog +import traceback + +try: + from platform_intf import platform_get_optoe_type, platform_set_optoe_type + from sonic_platform_base.sonic_xcvr.sfp_optoe_base import SfpOptoeBase + +except ImportError as e: + raise ImportError (str(e) + "- required module not found") + +LOG_DEBUG_LEVEL = 1 +LOG_WARNING_LEVEL = 2 +LOG_ERROR_LEVEL = 3 + +EEPROM_RETRY = 5 +EEPROM_RETRY_BREAK_SEC = 0.2 + +SYSFS_VAL_IS_PRESENT = 1 +SYSFS_VAL_IS_RESET = 1 +SYSFS_VAL_IS_LPMODE = 1 + +class Sfp(SfpOptoeBase): + + QSFP_DEVICE_TYPE = 1 + SFP_DEVICE_TYPE = 2 + CMIS_DEVICE_TYPE = 3 + + def __init__(self, index): + SfpOptoeBase.__init__(self) + self._port_id = index + 1 if self._get_config("port_index_start") == 0 else index + self._device_type = None + self.log_level = 1 + self.sfp_type = None + # self._set_log_level(self._get_config("sfp_log_level")) + + def get_eeprom_path(self): + return self._get_config("eeprom_path") % self._port_id + + def read_eeprom(self, offset, num_bytes): + eeprom_raw = None + try: + for i in range(EEPROM_RETRY): + eeprom_raw = SfpOptoeBase.read_eeprom(self, offset, num_bytes) + if eeprom_raw is None: + time.sleep(EEPROM_RETRY_BREAK_SEC) + continue + break + except Exception as e: + self._log_error(traceback.format_exc(e)) + return eeprom_raw + + def write_eeprom(self, offset, num_bytes, write_buffer): + try: + for i in range(EEPROM_RETRY): + ret = SfpOptoeBase.write_eeprom(self, offset, num_bytes, write_buffer) + if ret is False: + time.sleep(EEPROM_RETRY_BREAK_SEC) + continue + break + except Exception as e: + self._log_error(traceback.format_exc(e)) + ret = False + + return ret + + def get_presence(self): + try: + presence_sysfs_path = self._get_config("presence_path") % self._port_id + ret, result = self._read_sysfs(presence_sysfs_path) + if ret is False: + return False + return result == SYSFS_VAL_IS_PRESENT + except Exception as err: + self._log_error(traceback.format_exc(err)) + + return False + + def reset(self): + if self.get_presence() is False: + return False + + if self.sfp_type is None: + self.refresh_xcvr_api() + + if self.sfp_type == 'SFP': + self._log_warning('SFP does not support reset') + return False + + self._log_debug('port_num:%d resetting...' % self._port_id) + ret = self._set_reset(True) + if ret: + time.sleep(0.5) + ret = self._set_reset(False) + + return ret + + def get_lpmode(self): + if not self.get_presence(): + return False + + if self.sfp_type is None: + self.refresh_xcvr_api() + + if self.sfp_type == 'SFP': + self._log_warning('SFP does not support reset') + return False + + try: + lpmode_sysfs_path = self._get_config("lpmode_path") % self._port_id + ret, result = self._read_sysfs(lpmode_sysfs_path) + if ret is False: + return False + return result == SYSFS_VAL_IS_LPMODE + except Exception as err: + self._log_error(traceback.format_exc(err)) + + return False + + def set_lpmode(self, lpmode): + if not self.get_presence(): + return False + + if self.sfp_type is None or self._xcvr_api is None: + self.refresh_xcvr_api() + + if self.sfp_type == 'QSFP-DD': + return SfpOptoeBase.set_lpmode(self, lpmode) + elif self.sfp_type == 'QSFP': + if lpmode: + return self._xcvr_api.set_power_override(True, lpmode) + else: + return self._xcvr_api.set_power_override(False, lpmode) + else: + self._log_warning('SFP does not support reset') + return False + + def set_optoe_write_max(self, write_max): + """ + This func is declared and implemented by SONiC but we're not supported + so override it as NotImplemented + """ + self._log_debug("set_optoe_write_max NotImplemented") + return + + def refresh_xcvr_api(self): + """ + Updates the XcvrApi associated with this SFP + """ + self._xcvr_api = self._xcvr_api_factory.create_xcvr_api() + + class_name = self._xcvr_api.__class__.__name__ + self._set_optoe_driver(class_name) + +#################### inner api #################### + + def _get_device_type(self, class_name): + if (class_name == 'CmisApi'): + self._device_type = self.CMIS_DEVICE_TYPE + self.sfp_type = 'QSFP-DD' + elif (class_name == 'Sff8472Api'): + self._device_type = self.SFP_DEVICE_TYPE + self.sfp_type = 'SFP' + elif (class_name == 'Sff8636Api'): + self._device_type = self.QSFP_DEVICE_TYPE + self.sfp_type = 'QSFP' + else: + self._log_error("get_device_type error, class_name not supported:%s" % class_name) + self._device_type = None + self.sfp_type = None + + def _set_reset(self, reset): + try: + reset_sysfs_path = self._get_config("reset_path") % self._port_id + ret, result = self._read_sysfs(reset_sysfs_path) + if ret is False: + return False + if reset: + result = SYSFS_VAL_IS_RESET + else: + result = 0 + + ret = self._write_sysfs(reset_sysfs_path, result) + if ret is False: + return False + except Exception as err: + self._log_error(traceback.format_exc()) + return False + return True + + def _read_sysfs(self, sysfs_path): + val = 0 + if sysfs_path is None: + self._log_error("sysfs_path is None") + return False, 0 + + try: + with open(sysfs_path, "rb") as data: + sysfs_data = data.read(2) + if sysfs_data != "": + val = int(sysfs_data, 16) + except Exception as err: + self._log_error(traceback.format_exc(err)) + return False, 0 + + return True, val + + def _write_sysfs(self, sysfs_path, val): + if sysfs_path is None: + self._log_error("sysfs_path is None") + return False + + try: + with open(sysfs_path, "r+") as data: + data.seek(0) + sres = hex(val)[2:] + data.write(sres) + except Exception as err: + self._log_error(traceback.format_exc(err)) + return False + + self._log_debug("write sysfs_path:%s success, val:%d" % (sysfs_path, val)) + return True + + def _set_optoe_driver(self, class_name): + self._get_device_type(class_name) + if self._device_type is None: + return + try: + ret, output = platform_get_optoe_type(self._port_id) + if ret is False: + self._log_error("port %s get optoe type fail, output:%s" % (self._port_id, output)) + if int(output) != self._device_type: + ret, output = platform_set_optoe_type(self._port_id, self._device_type) + if ret is False: + self._log_error("port %s set optoe type fail, output:%s" % (self._port_id, output)) + self._log_debug("port_num:%d optoe_type:%s set success" % (self._port_id, self._device_type)) + except Exception as err: + print("Set optoe err %s" % err) + return + + def _get_config(self, key=None, default_val=None): + config = { + "port_index_start": 1, + "sfp_log_level": 1, + "presence_path": "/sys/s3ip/transceiver/eth%d/present", + "eeprom_path": "/sys/s3ip/transceiver/eth%d/eeprom", + "lpmode_path": "/sys/s3ip/transceiver/eth%d/low_power_mode", + "reset_path": "/sys/s3ip/transceiver/eth%d/reset", + } + return config.get(key, default_val) + + ####### SfpLog class ##### + + def _set_log_level(self, level): + if (level == LOG_DEBUG_LEVEL + or level == LOG_ERROR_LEVEL): + self.log_level = level + else: + self.log_error("unavailable loglevel:%d" % level) + + def _log_debug(self, msg): + if self.log_level <= LOG_DEBUG_LEVEL: + try: + syslog.openlog("Sfp") + syslog.syslog(syslog.LOG_DEBUG, msg) + syslog.closelog() + + except Exception as e: + msg = traceback.format_exc(e) + print("Exception_info:\n%s" % msg) + + def _log_warning(self, msg): + if self.log_level <= LOG_WARNING_LEVEL: + try: + syslog.openlog("Sfp") + syslog.syslog(syslog.LOG_WARNING, msg) + syslog.closelog() + + except Exception as e: + msg = traceback.format_exc(e) + print("Exception_info:\n%s" % msg) + + def _log_error(self, msg): + if self.log_level <= LOG_ERROR_LEVEL: + try: + syslog.openlog("Sfp") + syslog.syslog(syslog.LOG_ERR, msg) + syslog.closelog() + + except Exception as e: + msg = traceback.format_exc(e) + print("Exception_info:\n%s" % msg) + diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/thermal.py b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/thermal.py new file mode 100755 index 000000000000..a02f0bc06dab --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/thermal.py @@ -0,0 +1,237 @@ +#!/usr/bin/env python3 + +######################################################################## +# Ruijie +# +# Module contains an implementation of SONiC Platform Base API and +# provides the Thermals' information which are available in the platform +# +######################################################################## + + +try: + import time + from sonic_platform_base.thermal_base import ThermalBase + from sonic_platform.logger import logger +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class Thermal(ThermalBase): + + def __init__(self, interface_obj, index): + self.temp_dict = {} + self.temperature_list = [] + self.int_case = interface_obj + self.index = index + self.update_time = 0 + self.temp_id = "TEMP" + str(index) + + def temp_dict_update(self): + local_time = time.time() + if not self.temp_dict or (local_time - self.update_time) >= 1: # update data every 1 seconds + self.update_time = local_time + self.temp_dict = self.int_case.get_monitor_temp_by_id(self.temp_id) + + def get_name(self): + """ + Retrieves the name of the thermal + + Returns: + string: The name of the thermal + """ + self.temp_dict_update() + return self.temp_dict["Api_name"] + + def get_presence(self): + """ + Retrieves the presence of the thermal + + Returns: + bool: True if thermal is present, False if not + """ + return True + + def get_model(self): + """ + Retrieves the model number (or part number) of the Thermal + + Returns: + string: Model/part number of Thermal + """ + return "N/A" + + def get_serial(self): + """ + Retrieves the serial number of the Thermal + + Returns: + string: Serial number of Thermal + """ + return "N/A" + + def get_revision(self): + """ + Retrieves the hardware revision of the device + + Returns: + string: Revision value of device + """ + return "N/A" + + def get_status(self): + """ + Retrieves the operational status of the thermal + + Returns: + A boolean value, True if thermal is operating properly, + False if not + """ + self.temp_dict_update() + if (self.temp_dict["Value"] >= self.temp_dict["High"]) or (self.temp_dict["Value"] <= self.temp_dict["Low"]): + return False + + return True + + def get_position_in_parent(self): + """ + Retrieves 1-based relative physical position in parent device. If the agent cannot determine the parent-relative position + for some reason, or if the associated value of entPhysicalContainedIn is '0', then the value '-1' is returned + Returns: + integer: The 1-based relative physical position in parent device or -1 if cannot determine the position + """ + return -1 + + def is_replaceable(self): + """ + Indicate whether this device is replaceable. + Returns: + bool: True if it is replaceable. + """ + return False + + def get_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 + """ + self.temp_dict_update() + value = self.temp_dict["Value"] + if value is None: + value = 0 + if (len(self.temperature_list) >= 1000): + del self.temperature_list[0] + self.temperature_list.append(float(value)) + return round(float(value), 1) + + 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 + """ + self.temp_dict_update() + value = self.temp_dict["High"] + if value is None: + value = 0 + return round(float(value), 1) + + 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 + """ + self.temp_dict_update() + value = self.temp_dict["Low"] + if value is None: + value = 0 + return round(float(value), 1) + + 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 + """ + # not supported + return False + + 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 + """ + # not supported + 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 + """ + self.temp_dict_update() + value = self.temp_dict["Max"] + if value is None: + value = 0 + return round(float(value), 1) + + 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 + """ + self.temp_dict_update() + value = self.temp_dict["Min"] + if value is None: + value = 0 + return round(float(value), 1) + + def get_minimum_recorded(self): + """ + Retrieves the minimum recorded temperature of thermal + + Returns: + A float number, the minimum recorded temperature of thermal in Celsius + up to nearest thousandth of one degree Celsius, e.g. 30.125 + """ + if len(self.temperature_list) == 0: + self.get_temperature() + return round(float(min(self.temperature_list)), 1) + + def get_maximum_recorded(self): + """ + Retrieves the maximum recorded temperature of thermal + + Returns: + A float number, the maximum recorded temperature of thermal in Celsius + up to nearest thousandth of one degree Celsius, e.g. 30.125 + """ + if len(self.temperature_list) == 0: + self.get_temperature() + return round(float(max(self.temperature_list)), 1) + diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/watchdog.py b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/watchdog.py new file mode 100755 index 000000000000..59440492f730 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/watchdog.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python3 + +######################################################################## +# +# Ruijie +# +# Abstract base class for implementing a platform-specific class with +# which to interact with a hardware watchdog module in SONiC +# +######################################################################## + +try: + from sonic_platform_base.watchdog_base import WatchdogBase +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class Watchdog(WatchdogBase): + """ + Abstract base class for interfacing with a hardware watchdog module + """ + + def __init__(self): + print("INFO: Watchdog __init__") + + def arm(self, seconds): + """ + Arm the hardware watchdog with a timeout of seconds. + If the watchdog is currently armed, calling this function will + simply reset the timer to the provided value. If the underlying + hardware does not support the value provided in , this + method should arm the watchdog with the *next greater* available + value. + + Returns: + An integer specifying the *actual* number of seconds the watchdog + was armed with. On failure returns -1. + """ + print("ERROR: Platform did not implement arm()") + raise NotImplementedError + + def disarm(self): + """ + Disarm the hardware watchdog + + Returns: + A boolean, True if watchdog is disarmed successfully, False if not + """ + print("ERROR: Platform did not implement disarm()") + raise NotImplementedError + + def is_armed(self): + """ + Retrieves the armed state of the hardware watchdog. + + Returns: + A boolean, True if watchdog is armed, False if not + """ + print("ERROR: Platform did not implement is_armed()") + raise NotImplementedError + + def get_remaining_time(self): + """ + If the watchdog is armed, retrieve the number of seconds remaining on + the watchdog timer + + Returns: + An integer specifying the number of seconds remaining on thei + watchdog timer. If the watchdog is not armed, returns -1. + """ + print("ERROR: Platform did not implement get_remaining_time()") + raise NotImplementedError diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/Makefile b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/Makefile new file mode 100755 index 000000000000..2f3a7ccaddd8 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/Makefile @@ -0,0 +1,39 @@ +PWD = $(shell pwd) +CC ?=gcc +INSTALL_MOD_DIR ?=extra +KVERSION ?= $(shell uname -r) +KERNEL_SRC ?= /lib/modules/$(KVERSION) +EXTRA_CFLAGS:= -I$(M)/include +EXTRA_CFLAGS+= -Wall +SUB_BUILD_DIR = $(PWD)/build +SERVICE_DIR = $(PWD)/service +SYSFS_DIR = $(PWD)/S3IP_sysfs +SYSFS_BUILD_DIR = $(SYSFS_DIR)/build +INSTALL_MODULE_DIR = $(SUB_BUILD_DIR)/$(KERNEL_SRC)/$(INSTALL_MOD_DIR) +INSTALL_SCRIPT_DIR = $(SUB_BUILD_DIR)/usr/local/bin +INSTALL_LIB_DIR = $(SUB_BUILD_DIR)/usr/lib/python3/dist-packages +INSTALL_SERVICE_DIR = $(SUB_BUILD_DIR)/lib/systemd/system +INSTALL_CFG_DIR = $(SUB_BUILD_DIR)/etc/dfd_cfg +COMMON_TX_OUTPUT := $(shell pwd)/build +export SUB_BUILD_DIR COMMON_TX_OUTPUT + +all : SUBDIRS_OBJ CHECK +CHECK : + @if [ ! -d ${INSTALL_LIB_DIR} ]; then mkdir -p ${INSTALL_LIB_DIR} ;fi + @if [ -d $(PWD)/lib/ ]; then cp -r $(PWD)/lib/* ${INSTALL_LIB_DIR} ;fi + @if [ ! -d ${COMMON_TX_OUTPUT} ]; then mkdir -p ${COMMON_TX_OUTPUT} ;fi + @if [ ! -d ${INSTALL_SCRIPT_DIR} ]; then mkdir -p ${INSTALL_SCRIPT_DIR} ;fi + @if [ -d $(PWD)/script/ ]; then cp -r $(PWD)/script/* ${INSTALL_SCRIPT_DIR} ;fi + @if [ -d $(INSTALL_SCRIPT_DIR) ]; then chmod +x $(INSTALL_SCRIPT_DIR)/* ;fi + @if [ ! -d ${INSTALL_SERVICE_DIR} ]; then mkdir -p ${INSTALL_SERVICE_DIR} ;fi + cp -r $(SERVICE_DIR)/* $(INSTALL_SERVICE_DIR) + @if [ ! -d ${INSTALL_MODULE_DIR} ]; then mkdir -p ${INSTALL_MODULE_DIR} ;fi + cp -r $(SYSFS_BUILD_DIR)/S3IP_sysfs/*.ko $(INSTALL_MODULE_DIR) + @if [ ! -d ${INSTALL_CFG_DIR} ]; then mkdir -p ${INSTALL_CFG_DIR} ;fi + cp -r $(SYSFS_BUILD_DIR)/dfd_cfg/* $(INSTALL_CFG_DIR) + +SUBDIRS_OBJ : + make -C $(SYSFS_DIR) + +clean: + rm -rf $(SUB_BUILD_DIR) \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/Makefile b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/Makefile new file mode 100755 index 000000000000..b509ad28c715 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/Makefile @@ -0,0 +1,19 @@ +PWD = $(shell pwd) +SYSFS_OUT_PUT := $(PWD)/build +sysfs_out_put_dir := $(SYSFS_OUT_PUT)/S3IP_sysfs/ +sysfs_cfg_dir := $(SYSFS_OUT_PUT)/dfd_cfg/ +export sysfs_out_put_dir sysfs_cfg_dir + +SYSFS_DRIVER_DIR = $(PWD)/sysfs_driver +SWITCH_DRIVER_DIR = $(PWD)/switch_driver +DEVICE_DRIVER_DIR = $(PWD)/device_driver + +export SYSFS_DRIVER_DIR SWITCH_DRIVER_DIR + +all : + $(MAKE) -C $(SYSFS_DRIVER_DIR) + $(MAKE) -C $(SWITCH_DRIVER_DIR) + $(MAKE) -C $(DEVICE_DRIVER_DIR) + +clean : + -rm -rf $(SYSFS_OUT_PUT) diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/Makefile b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/Makefile new file mode 100755 index 000000000000..a17be3f17dd7 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/Makefile @@ -0,0 +1,34 @@ +PWD = $(shell pwd) + +MAKEFILE_FILE_PATH = $(abspath $(lastword $(MAKEFILE_LIST))) +DEV_SYSFS_HEADER_DIR = $(abspath $(MAKEFILE_FILE_PATH)/../../sysfs_driver/include) +SWITCH_DVR_HEADER_DIR = $(abspath $(MAKEFILE_FILE_PATH)/../../switch_driver/include) +EXTRA_CFLAGS:= -I$(M)/include +EXTRA_CFLAGS+= -I$(DEV_SYSFS_HEADER_DIR) +EXTRA_CFLAGS+= -I$(SWITCH_DVR_HEADER_DIR) +EXTRA_CFLAGS+= -Wall + +KBUILD_EXTRA_SYMBOLS += $(SYSFS_DRIVER_DIR)/Module.symvers +KBUILD_EXTRA_SYMBOLS += $(SWITCH_DRIVER_DIR)/Module.symvers + +obj-m := syseeprom_device_driver.o +obj-m += fan_device_driver.o +obj-m += cpld_device_driver.o +obj-m += sysled_device_driver.o +obj-m += slot_device_driver.o +obj-m += psu_device_driver.o +obj-m += transceiver_device_driver.o +obj-m += temp_sensor_device_driver.o +obj-m += vol_sensor_device_driver.o +obj-m += curr_sensor_device_driver.o +obj-m += fpga_device_driver.o +obj-m += watchdog_device_driver.o + +all: + $(MAKE) -C $(KERNEL_SRC)/build M=$(PWD) modules + @if [ ! -d $(sysfs_out_put_dir) ]; then mkdir -p $(sysfs_out_put_dir) ;fi + cp -p $(PWD)/*.ko $(sysfs_out_put_dir) +clean: + rm -f $(PWD)/*.o $(PWD)/*.ko $(PWD)/*.mod.c $(PWD)/.*.cmd $(PWD)/*.mod + rm -f $(PWD)/Module.markers $(PWD)/Module.symvers $(PWD)/modules.order + rm -rf $(PWD)/.tmp_versions diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/cpld_device_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/cpld_device_driver.c new file mode 100644 index 000000000000..b8fee8e2748d --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/cpld_device_driver.c @@ -0,0 +1,207 @@ +/* + * cpld_device_driver.c + * + * This module realize /sys/s3ip/cpld attributes read and write functions + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "device_driver_common.h" +#include "cpld_sysfs.h" +#include "dfd_sysfs_common.h" + +#define CPLD_INFO(fmt, args...) LOG_INFO("cpld: ", fmt, ##args) +#define CPLD_ERR(fmt, args...) LOG_ERR("cpld: ", fmt, ##args) +#define CPLD_DBG(fmt, args...) LOG_DBG("cpld: ", fmt, ##args) + +static int g_loglevel = 0; +static struct switch_drivers_s *g_drv = NULL; + +/******************************************CPLD***********************************************/ +static int rg_get_main_board_cpld_number(void) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_cpld_number); + + ret = g_drv->get_main_board_cpld_number(); + return ret; +} + +/* + * rg_get_main_board_cpld_alias - Used to identify the location of cpld, + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_cpld_alias(unsigned int cpld_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_cpld_alias); + + ret = g_drv->get_main_board_cpld_alias(cpld_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_cpld_type - Used to get cpld model name + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_cpld_type(unsigned int cpld_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_cpld_type); + + ret = g_drv->get_main_board_cpld_type(cpld_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_cpld_firmware_version - Used to get cpld firmware version, + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_cpld_firmware_version(unsigned int cpld_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_cpld_firmware_version); + + ret = g_drv->get_main_board_cpld_firmware_version(cpld_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_cpld_board_version - Used to get cpld board version, + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_cpld_board_version(unsigned int cpld_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_cpld_board_version); + + ret = g_drv->get_main_board_cpld_board_version(cpld_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_cpld_test_reg - Used to test cpld register read + * filled the value to buf, value is hexadecimal, start with 0x + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_cpld_test_reg(unsigned int cpld_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_cpld_test_reg); + + ret = g_drv->get_main_board_cpld_test_reg(cpld_index, buf, count); + return ret; +} + +/* + * rg_set_main_board_cpld_test_reg - Used to test cpld register write + * @cpld_index: start with 1 + * @value: value write to cpld + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int rg_set_main_board_cpld_test_reg(unsigned int cpld_index, unsigned int value) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->set_main_board_cpld_test_reg); + + ret = g_drv->set_main_board_cpld_test_reg(cpld_index, value); + return ret; +} +/***************************************end of CPLD*******************************************/ + +static struct s3ip_sysfs_cpld_drivers_s drivers = { + /* + * set ODM CPLD drivers to /sys/s3ip/cpld, + * if not support the function, set corresponding hook to NULL. + */ + .get_main_board_cpld_number = rg_get_main_board_cpld_number, + .get_main_board_cpld_alias = rg_get_main_board_cpld_alias, + .get_main_board_cpld_type = rg_get_main_board_cpld_type, + .get_main_board_cpld_firmware_version = rg_get_main_board_cpld_firmware_version, + .get_main_board_cpld_board_version = rg_get_main_board_cpld_board_version, + .get_main_board_cpld_test_reg = rg_get_main_board_cpld_test_reg, + .set_main_board_cpld_test_reg = rg_set_main_board_cpld_test_reg, +}; + +static int __init cpld_device_driver_init(void) +{ + int ret; + + CPLD_INFO("cpld_init...\n"); + g_drv = switch_driver_get(); + check_p(g_drv); + + ret = s3ip_sysfs_cpld_drivers_register(&drivers); + if (ret < 0) { + CPLD_ERR("cpld drivers register err, ret %d.\n", ret); + return ret; + } + + CPLD_INFO("cpld_init success.\n"); + return 0; +} + +static void __exit cpld_device_driver_exit(void) +{ + s3ip_sysfs_cpld_drivers_unregister(); + CPLD_INFO("cpld_exit success.\n"); + return; +} + +module_init(cpld_device_driver_init); +module_exit(cpld_device_driver_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4, all=0xf).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_DESCRIPTION("cpld device driver"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/curr_sensor_device_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/curr_sensor_device_driver.c new file mode 100644 index 000000000000..99021e633664 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/curr_sensor_device_driver.c @@ -0,0 +1,188 @@ +/* + * curr_sensor_device_driver.c + * + * This module realize /sys/s3ip/curr_sensor attributes read and write functions + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "device_driver_common.h" +#include "curr_sensor_sysfs.h" +#include "dfd_sysfs_common.h" + +#define CURR_SENSOR_INFO(fmt, args...) LOG_INFO("curr_sensor: ", fmt, ##args) +#define CURR_SENSOR_ERR(fmt, args...) LOG_ERR("curr_sensor: ", fmt, ##args) +#define CURR_SENSOR_DBG(fmt, args...) LOG_DBG("curr_sensor: ", fmt, ##args) + +static int g_loglevel = 0; +static struct switch_drivers_s *g_drv = NULL; + +/*************************************main board current***************************************/ +static int rg_get_main_board_curr_number(void) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_curr_number); + + ret = g_drv->get_main_board_curr_number(); + return ret; +} + +/* + * rg_get_main_board_curr_alias - Used to identify the location of the current sensor, + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_curr_alias(unsigned int curr_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_curr_alias); + + ret = g_drv->get_main_board_curr_alias(curr_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_curr_type - Used to get the model of current sensor, + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_curr_type(unsigned int curr_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_curr_type); + + ret = g_drv->get_main_board_curr_type(curr_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_curr_max - Used to get the maximum threshold of current sensor + * filled the value to buf, the value is integer with mA + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_curr_max(unsigned int curr_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_curr_max); + + ret = g_drv->get_main_board_curr_max(curr_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_curr_min - Used to get the minimum threshold of current sensor + * filled the value to buf, the value is integer with mA + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_curr_min(unsigned int curr_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_curr_min); + + ret = g_drv->get_main_board_curr_min(curr_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_curr_value - Used to get the input value of current sensor + * filled the value to buf, the value is integer with mA + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_curr_value(unsigned int curr_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_curr_value); + + ret = g_drv->get_main_board_curr_value(curr_index, buf, count); + return ret; +} +/*********************************end of main board current************************************/ + +static struct s3ip_sysfs_curr_sensor_drivers_s drivers = { + /* + * set ODM current sensor drivers to /sys/s3ip/curr_sensor, + * if not support the function, set corresponding hook to NULL. + */ + .get_main_board_curr_number = rg_get_main_board_curr_number, + .get_main_board_curr_alias = rg_get_main_board_curr_alias, + .get_main_board_curr_type = rg_get_main_board_curr_type, + .get_main_board_curr_max = rg_get_main_board_curr_max, + .get_main_board_curr_min = rg_get_main_board_curr_min, + .get_main_board_curr_value = rg_get_main_board_curr_value, +}; + +static int __init curr_sensor_dev_drv_init(void) +{ + int ret; + + CURR_SENSOR_INFO("curr_sensor_init...\n"); + g_drv = switch_driver_get(); + check_p(g_drv); + + ret = s3ip_sysfs_curr_sensor_drivers_register(&drivers); + if (ret < 0) { + CURR_SENSOR_ERR("curr sensor drivers register err, ret %d.\n", ret); + return ret; + } + + CURR_SENSOR_INFO("curr_sensor_init success.\n"); + return 0; +} + +static void __exit curr_sensor_dev_drv_exit(void) +{ + s3ip_sysfs_curr_sensor_drivers_unregister(); + CURR_SENSOR_INFO("curr_sensor_exit success.\n"); + return; +} + +module_init(curr_sensor_dev_drv_init); +module_exit(curr_sensor_dev_drv_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4, all=0xf).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_DESCRIPTION("current sensors device driver"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/fan_device_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/fan_device_driver.c new file mode 100644 index 000000000000..f4d30b5fb563 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/fan_device_driver.c @@ -0,0 +1,459 @@ +/* + * fan_device_driver.c + * + * This module realize /sys/s3ip/fan attributes read and write functions + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "device_driver_common.h" +#include "fan_sysfs.h" +#include "dfd_sysfs_common.h" + +#define FAN_INFO(fmt, args...) LOG_INFO("fan: ", fmt, ##args) +#define FAN_ERR(fmt, args...) LOG_ERR("fan: ", fmt, ##args) +#define FAN_DBG(fmt, args...) LOG_DBG("fan: ", fmt, ##args) + +static int g_loglevel = 0; +static struct switch_drivers_s *g_drv = NULL; + +/********************************************fan**********************************************/ +static int rg_get_fan_number(void) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_fan_number); + + ret = g_drv->get_fan_number(); + return ret; +} + +static int rg_get_fan_motor_number(unsigned int fan_index) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_fan_motor_number); + + ret = g_drv->get_fan_motor_number(fan_index); + return ret; +} + +/* + * rg_get_fan_model_name - Used to get fan model name, + * @fan_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_fan_model_name(unsigned int fan_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_fan_model_name); + + ret = g_drv->get_fan_model_name(fan_index, buf, count); + return ret; +} + +/* + * rg_get_fan_serial_number - Used to get fan serial number, + * @fan_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_fan_serial_number(unsigned int fan_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_fan_serial_number); + + ret = g_drv->get_fan_serial_number(fan_index, buf, count); + return ret; +} + +/* + * rg_get_fan_part_number - Used to get fan part number, + * @fan_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_fan_part_number(unsigned int fan_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_fan_part_number); + + ret = g_drv->get_fan_part_number(fan_index, buf, count); + return ret; +} + +/* + * rg_get_fan_hardware_version - Used to get fan hardware version, + * @fan_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_fan_hardware_version(unsigned int fan_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_fan_hardware_version); + + ret = g_drv->get_fan_hardware_version(fan_index, buf, count); + return ret; +} + +/* + * rg_get_fan_status - Used to get fan status, + * filled the value to buf, fan status define as below: + * 0: ABSENT + * 1: OK + * 2: NOT OK + * + * @fan_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_fan_status(unsigned int fan_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_fan_status); + + ret = g_drv->get_fan_status(fan_index, buf, count); + return ret; +} + +/* + * rg_get_fan_led_status - Used to get fan led status + * filled the value to buf, led status value define as below: + * 0: dark + * 1: green + * 2: yellow + * 3: red + * 4: blue + * 5: green light flashing + * 6: yellow light flashing + * 7: red light flashing + * 8: blue light flashing + * + * @fan_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_fan_led_status(unsigned int fan_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_fan_led_status); + + ret = g_drv->get_fan_led_status(fan_index, buf, count); + return ret; +} + +/* + * rg_set_fan_led_status - Used to set fan led status + * @fan_index: start with 1 + * @status: led status, led status value define as below: + * 0: dark + * 1: green + * 2: yellow + * 3: red + * 4: blue + * 5: green light flashing + * 6: yellow light flashing + * 7: red light flashing + * 8: blue light flashing + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int rg_set_fan_led_status(unsigned int fan_index, int status) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->set_fan_led_status); + + ret = g_drv->set_fan_led_status(fan_index, status); + return ret; +} + +/* + * rg_get_fan_direction - Used to get fan air flow direction, + * filled the value to buf, air flow direction define as below: + * 0: F2B + * 1: B2F + * + * @fan_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_fan_direction(unsigned int fan_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_fan_direction); + + ret = g_drv->get_fan_direction(fan_index, buf, count); + return ret; +} + +/* + * rg_get_fan_motor_speed - Used to get fan motor speed + * filled the value to buf + * @fan_index: start with 1 + * @motor_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_fan_motor_speed(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_fan_motor_speed); + + ret = g_drv->get_fan_motor_speed(fan_index, motor_index, buf, count); + return ret; +} + +/* + * rg_get_fan_motor_speed_tolerance - Used to get fan motor speed tolerance + * filled the value to buf + * @fan_index: start with 1 + * @motor_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_fan_motor_speed_tolerance(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_fan_motor_speed_tolerance); + + ret = g_drv->get_fan_motor_speed_tolerance(fan_index, motor_index, buf, count); + return ret; +} + +/* + * rg_get_fan_motor_speed_target - Used to get fan motor speed target + * filled the value to buf + * @fan_index: start with 1 + * @motor_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_fan_motor_speed_target(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_fan_motor_speed_target); + + ret = g_drv->get_fan_motor_speed_target(fan_index, motor_index, buf, count); + return ret; +} + +/* + * rg_get_fan_motor_speed_max - Used to get the maximum threshold of fan motor + * filled the value to buf + * @fan_index: start with 1 + * @motor_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_fan_motor_speed_max(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_fan_motor_speed_max); + + ret = g_drv->get_fan_motor_speed_max(fan_index, motor_index, buf, count); + return ret; +} + +/* + * rg_get_fan_motor_speed_min - Used to get the minimum threshold of fan motor + * filled the value to buf + * @fan_index: start with 1 + * @motor_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_fan_motor_speed_min(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_fan_motor_speed_min); + + ret = g_drv->get_fan_motor_speed_min(fan_index, motor_index, buf, count); + return ret; +} + +/* + * rg_get_fan_ratio - Used to get the ratio of fan + * filled the value to buf + * @fan_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_fan_ratio(unsigned int fan_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_fan_ratio); + + ret = g_drv->get_fan_ratio(fan_index, buf, count); + return ret; +} + +/* + * rg_set_fan_ratio - Used to set the ratio of fan + * @fan_index: start with 1 + * @ratio: motor speed ratio, from 0 to 100 + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int rg_set_fan_ratio(unsigned int fan_index, int ratio) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->set_fan_ratio); + + ret = g_drv->set_fan_ratio(fan_index, ratio); + return ret; +} +/****************************************end of fan*******************************************/ + +static struct s3ip_sysfs_fan_drivers_s drivers = { + /* + * set ODM fan drivers to /sys/s3ip/fan, + * if not support the function, set corresponding hook to NULL. + */ + .get_fan_number = rg_get_fan_number, + .get_fan_motor_number = rg_get_fan_motor_number, + .get_fan_model_name = rg_get_fan_model_name, + .get_fan_serial_number = rg_get_fan_serial_number, + .get_fan_part_number = rg_get_fan_part_number, + .get_fan_hardware_version = rg_get_fan_hardware_version, + .get_fan_status = rg_get_fan_status, + .get_fan_led_status = rg_get_fan_led_status, + .set_fan_led_status = rg_set_fan_led_status, + .get_fan_direction = rg_get_fan_direction, + .get_fan_motor_speed = rg_get_fan_motor_speed, + .get_fan_motor_speed_tolerance = rg_get_fan_motor_speed_tolerance, + .get_fan_motor_speed_target = rg_get_fan_motor_speed_target, + .get_fan_motor_speed_max = rg_get_fan_motor_speed_max, + .get_fan_motor_speed_min = rg_get_fan_motor_speed_min, + .get_fan_ratio = rg_get_fan_ratio, + .set_fan_ratio = rg_set_fan_ratio +}; + +static int __init fan_dev_drv_init(void) +{ + int ret; + + FAN_INFO("fan_init...\n"); + g_drv = switch_driver_get(); + check_p(g_drv); + + ret = s3ip_sysfs_fan_drivers_register(&drivers); + if (ret < 0) { + FAN_ERR("fan drivers register err, ret %d.\n", ret); + return ret; + } + + FAN_INFO("fan_init success.\n"); + return 0; +} + +static void __exit fan_dev_drv_exit(void) +{ + s3ip_sysfs_fan_drivers_unregister(); + FAN_INFO("fan_exit success.\n"); + return; +} + +module_init(fan_dev_drv_init); +module_exit(fan_dev_drv_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4, all=0xf).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_DESCRIPTION("fan device driver"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/fpga_device_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/fpga_device_driver.c new file mode 100644 index 000000000000..b9b75a9a671b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/fpga_device_driver.c @@ -0,0 +1,206 @@ +/* + * fpga_device_driver.c + * + * This module realize /sys/s3ip/fpga attributes read and write functions + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "device_driver_common.h" +#include "fpga_sysfs.h" +#include "dfd_sysfs_common.h" + +#define FPGA_INFO(fmt, args...) LOG_INFO("fpga: ", fmt, ##args) +#define FPGA_ERR(fmt, args...) LOG_ERR("fpga: ", fmt, ##args) +#define FPGA_DBG(fmt, args...) LOG_DBG("fpga: ", fmt, ##args) + +static int g_loglevel = 0; +static struct switch_drivers_s *g_drv = NULL; + +/******************************************FPGA***********************************************/ +static int rg_get_main_board_fpga_number(void) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_fpga_number); + + ret = g_drv->get_main_board_fpga_number(); + return ret; +} + +/* + * rg_get_main_board_fpga_alias - Used to identify the location of fpga, + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_fpga_alias(unsigned int fpga_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_fpga_alias); + + ret = g_drv->get_main_board_fpga_alias(fpga_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_fpga_type - Used to get fpga model name + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_fpga_type(unsigned int fpga_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_fpga_type); + + ret = g_drv->get_main_board_fpga_type(fpga_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_fpga_firmware_version - Used to get fpga firmware version, + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_fpga_firmware_version(unsigned int fpga_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_fpga_firmware_version); + + ret = g_drv->get_main_board_fpga_firmware_version(fpga_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_fpga_board_version - Used to get fpga board version, + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_fpga_board_version(unsigned int fpga_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_fpga_board_version); + + ret = g_drv->get_main_board_fpga_board_version(fpga_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_fpga_test_reg - Used to test fpga register read + * filled the value to buf, value is hexadecimal, start with 0x + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_fpga_test_reg(unsigned int fpga_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_fpga_test_reg); + + ret = g_drv->get_main_board_fpga_test_reg(fpga_index, buf, count); + return ret; +} + +/* + * rg_set_main_board_fpga_test_reg - Used to test fpga register write + * @fpga_index: start with 1 + * @value: value write to fpga + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int rg_set_main_board_fpga_test_reg(unsigned int fpga_index, unsigned int value) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->set_main_board_fpga_test_reg); + + ret = g_drv->set_main_board_fpga_test_reg(fpga_index, value); + return ret; +} +/***************************************end of FPGA*******************************************/ + +static struct s3ip_sysfs_fpga_drivers_s drivers = { + /* + * set ODM FPGA drivers to /sys/s3ip/fpga, + * if not support the function, set corresponding hook to NULL. + */ + .get_main_board_fpga_number = rg_get_main_board_fpga_number, + .get_main_board_fpga_alias = rg_get_main_board_fpga_alias, + .get_main_board_fpga_type = rg_get_main_board_fpga_type, + .get_main_board_fpga_firmware_version = rg_get_main_board_fpga_firmware_version, + .get_main_board_fpga_board_version = rg_get_main_board_fpga_board_version, + .get_main_board_fpga_test_reg = rg_get_main_board_fpga_test_reg, + .set_main_board_fpga_test_reg = rg_set_main_board_fpga_test_reg, +}; + +static int __init fpga_dev_drv_init(void) +{ + int ret; + + FPGA_INFO("fpga_init...\n"); + g_drv = switch_driver_get(); + check_p(g_drv); + + ret = s3ip_sysfs_fpga_drivers_register(&drivers); + if (ret < 0) { + FPGA_ERR("fpga drivers register err, ret %d.\n", ret); + return ret; + } + FPGA_INFO("fpga_init success.\n"); + return 0; +} + +static void __exit fpga_dev_drv_exit(void) +{ + s3ip_sysfs_fpga_drivers_unregister(); + FPGA_INFO("fpga_exit success.\n"); + return; +} + +module_init(fpga_dev_drv_init); +module_exit(fpga_dev_drv_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4, all=0xf).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_DESCRIPTION("fpga device driver"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/include/device_driver_common.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/include/device_driver_common.h new file mode 100644 index 000000000000..6386d88fafe9 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/include/device_driver_common.h @@ -0,0 +1,49 @@ +#ifndef _DEVICE_DRIVER_COMMON_H_ +#define _DEVICE_DRIVER_COMMON_H_ + +#include +#include +#include +#include +#include +#include +#include +#include + +enum LOG_LEVEL{ + INFO = 0x1, + ERR = 0x2, + DBG = 0x4, + ALL = 0xf +}; + +#define LOG_INFO(_prefix, fmt, args...) do { \ + if (g_loglevel & INFO) { \ + printk( KERN_INFO _prefix "%s "fmt, __FUNCTION__, ##args); \ + } \ +} while (0) + +#define LOG_ERR(_prefix, fmt, args...) do { \ + if (g_loglevel & ERR) { \ + printk( KERN_ERR _prefix "%s "fmt, __FUNCTION__, ##args); \ + } \ +} while (0) + +#define LOG_DBG(_prefix, fmt, args...) do { \ + if (g_loglevel & DBG) { \ + printk( KERN_DEBUG _prefix "%s "fmt, __FUNCTION__, ##args); \ + } \ +} while (0) + +#define check_pfun(p) do { \ + if (p == NULL) { \ + if (g_loglevel & ERR) { \ + printk( KERN_ERR "%s, %s is NULL.\n", __FUNCTION__, #p); \ + } \ + return -ENOSYS; \ + } \ +} while(0) + +#define check_p(p) check_pfun(p) + +#endif /* _DEVICE_DRIVER_COMMON_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/psu_device_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/psu_device_driver.c new file mode 100644 index 000000000000..1147ed3a2786 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/psu_device_driver.c @@ -0,0 +1,737 @@ +/* + * psu_device_driver.c + * + * This module realize /sys/s3ip/psu attributes read and write functions + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "device_driver_common.h" +#include "psu_sysfs.h" +#include "dfd_sysfs_common.h" + +#define PSU_INFO(fmt, args...) LOG_INFO("psu: ", fmt, ##args) +#define PSU_ERR(fmt, args...) LOG_ERR("psu: ", fmt, ##args) +#define PSU_DBG(fmt, args...) LOG_DBG("psu: ", fmt, ##args) + +static int g_loglevel = 0; +static struct switch_drivers_s *g_drv = NULL; + +/********************************************psu**********************************************/ +static int rg_get_psu_number(void) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_psu_number); + + ret = g_drv->get_psu_number(); + return ret; +} + +static int rg_get_psu_temp_number(unsigned int psu_index) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_psu_temp_number); + + ret = g_drv->get_psu_temp_number(psu_index); + return ret; +} + +/* + * rg_get_psu_model_name - Used to get psu model name, + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_model_name(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_model_name); + + ret = g_drv->get_psu_model_name(psu_index, buf, count); + return ret; +} + +/* + * rg_get_psu_serial_number - Used to get psu serial number, + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_serial_number(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_serial_number); + + ret = g_drv->get_psu_serial_number(psu_index, buf, count); + return ret; +} + +/* + * rg_get_psu_part_number - Used to get psu part number, + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_part_number(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_part_number); + + ret = g_drv->get_psu_part_number(psu_index, buf, count); + return ret; +} + +/* + * rg_get_psu_hardware_version - Used to get psu hardware version, + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_hardware_version(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_hardware_version); + + ret = g_drv->get_psu_hardware_version(psu_index, buf, count); + return ret; +} + +/* + * rg_get_psu_type - Used to get the input type of psu + * filled the value to buf, input type value define as below: + * 0: DC + * 1: AC + * + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_type(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_type); + + ret = g_drv->get_psu_type(psu_index, buf, count); + return ret; +} + +/* + * rg_get_psu_in_curr - Used to get the input current of psu + * filled the value to buf, the value is integer with mA + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_in_curr(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_in_curr); + + ret = g_drv->get_psu_in_curr(psu_index, buf, count); + return ret; +} + +/* + * rg_get_psu_in_vol - Used to get the input voltage of psu + * filled the value to bu, the value is integer with mV + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_in_vol(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_in_vol); + + ret = g_drv->get_psu_in_vol(psu_index, buf, count); + return ret; +} + +/* + * rg_get_psu_in_power - Used to get the input power of psu + * filled the value to buf, the value is integer with uW + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_in_power(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_in_power); + + ret = g_drv->get_psu_in_power(psu_index, buf, count); + return ret; +} + +/* + * rg_get_psu_out_curr - Used to get the output current of psu + * filled the value to buf, the value is integer with mA + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_out_curr(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_out_curr); + + ret = g_drv->get_psu_out_curr(psu_index, buf, count); + return ret; +} + +/* + * rg_get_psu_out_vol - Used to get the output voltage of psu + * filled the value to buf, the value is integer with mV + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_out_vol(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_out_vol); + + ret = g_drv->get_psu_out_vol(psu_index, buf, count); + return ret; +} + +/* + * rg_get_psu_out_power - Used to get the output power of psu + * filled the value to buf, the value is integer with uW + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_out_power(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_out_power); + + ret = g_drv->get_psu_out_power(psu_index, buf, count); + return ret; +} + +/* + * rg_get_psu_out_max_power - Used to get the output max power of psu + * filled the value to buf, the value is integer with uW + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_out_max_power(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_out_max_power); + + ret = g_drv->get_psu_out_max_power(psu_index, buf, count); + return ret; +} + +/* + * rg_get_psu_present_status - Used to get psu present status + * filled the value to buf, psu present status define as below: + * 0: ABSENT + * 1: PRESENT + * + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_present_status(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_present_status); + + ret = g_drv->get_psu_present_status(psu_index, buf, count); + return ret; +} + +/* + * rg_get_psu_in_status - Used to get psu input status + * filled the value to buf, psu input status define as below: + * 0: NOT OK + * 1: OK + * + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_in_status(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_in_status); + + ret = g_drv->get_psu_in_status(psu_index, buf, count); + return ret; +} + +/* + * rg_get_psu_out_status - Used to get psu output status + * filled the value to buf, psu output status define as below: + * 0: NOT OK + * 1: OK + * + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_out_status(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_out_status); + + ret = g_drv->get_psu_out_status(psu_index, buf, count); + return ret; +} + +/* + * rg_get_psu_fan_speed - Used to get psu fan speed + * filled the value to buf + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_fan_speed(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_fan_speed); + + ret = g_drv->get_psu_fan_speed(psu_index, buf, count); + return ret; +} + +/* + * rg_get_psu_fan_ratio - Used to get the ratio of psu fan + * filled the value to buf + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_fan_ratio(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_fan_ratio); + + ret = g_drv->get_psu_fan_ratio(psu_index, buf, count); + return ret; +} + +/* + * rg_set_psu_fan_ratio - Used to set the ratio of psu fan + * @psu_index: start with 1 + * @ratio: from 0 to 100 + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int rg_set_psu_fan_ratio(unsigned int psu_index, int ratio) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->set_psu_fan_ratio); + + ret = g_drv->set_psu_fan_ratio(psu_index, ratio); + return ret; +} + +/* + * rg_get_psu_fan_direction - Used to get psu air flow direction, + * filled the value to buf, air flow direction define as below: + * 0: F2B + * 1: B2F + * + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_fan_direction(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_fan_direction); + + ret = g_drv->get_psu_fan_direction(psu_index, buf, count); + return ret; +} + +/* + * rg_get_psu_led_status - Used to get psu led status + * filled the value to buf, led status value define as below: + * 0: dark + * 1: green + * 2: yellow + * 3: red + * 4: blue + * 5: green light flashing + * 6: yellow light flashing + * 7: red light flashing + * 8: blue light flashing + * + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_led_status(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_led_status); + + ret = g_drv->get_psu_led_status(psu_index, buf, count); + return ret; +} + +/* + * rg_get_psu_temp_alias - Used to identify the location of the temperature sensor of psu, + * @psu_index: start with 1 + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_temp_alias(unsigned int psu_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_temp_alias); + + ret = g_drv->get_psu_temp_alias(psu_index, temp_index, buf, count); + return ret; +} + +/* + * rg_get_psu_temp_type - Used to get the model of temperature sensor of psu, + * @psu_index: start with 1 + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_temp_type(unsigned int psu_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_temp_type); + + ret = g_drv->get_psu_temp_type(psu_index, temp_index, buf, count); + return ret; + +} + +/* + * rg_get_psu_temp_max - Used to get the maximum threshold of temperature sensor of psu, + * filled the value to buf, the value is integer with millidegree Celsius + * @psu_index: start with 1 + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_temp_max(unsigned int psu_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_temp_max); + + ret = g_drv->get_psu_temp_max(psu_index, temp_index, buf, count); + return ret; +} + +/* + * rg_set_psu_temp_max - Used to set the maximum threshold of temperature sensor of psu, + * get value from buf and set it to maximum threshold of psu temperature sensor + * @psu_index: start with 1 + * @temp_index: start with 1 + * @buf: the buf store the data to be set, eg '80.000' + * @count: length of buf + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int rg_set_psu_temp_max(unsigned int psu_index, unsigned int temp_index, + const char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->set_psu_temp_max); + + ret = g_drv->set_psu_temp_max(psu_index, temp_index, buf, count); + return ret; +} + +/* + * rg_get_psu_temp_min - Used to get the minimum threshold of temperature sensor of psu, + * filled the value to buf, the value is integer with millidegree Celsius + * @psu_index: start with 1 + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_temp_min(unsigned int psu_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_temp_min); + + ret = g_drv->get_psu_temp_min(psu_index, temp_index, buf, count); + return ret; +} + +/* + * rg_set_psu_temp_min - Used to set the minimum threshold of temperature sensor of psu, + * get value from buf and set it to minimum threshold of psu temperature sensor + * @psu_index: start with 1 + * @temp_index: start with 1 + * @buf: the buf store the data to be set, eg '50.000' + * @count: length of buf + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int rg_set_psu_temp_min(unsigned int psu_index, unsigned int temp_index, + const char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->set_psu_temp_min); + + ret = g_drv->set_psu_temp_min(psu_index, temp_index, buf, count); + return ret; +} + +/* + * rg_get_psu_temp_value - Used to get the input value of temperature sensor of psu + * filled the value to buf, the value is integer with millidegree Celsius + * @psu_index: start with 1 + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_temp_value(unsigned int psu_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_temp_value); + + ret = g_drv->get_psu_temp_value(psu_index, temp_index, buf, count); + return ret; +} +/****************************************end of psu*******************************************/ + +static struct s3ip_sysfs_psu_drivers_s drivers = { + /* + * set ODM psu drivers to /sys/s3ip/psu, + * if not support the function, set corresponding hook to NULL. + */ + .get_psu_number = rg_get_psu_number, + .get_psu_temp_number = rg_get_psu_temp_number, + .get_psu_model_name = rg_get_psu_model_name, + .get_psu_serial_number = rg_get_psu_serial_number, + .get_psu_part_number = rg_get_psu_part_number, + .get_psu_hardware_version = rg_get_psu_hardware_version, + .get_psu_type = rg_get_psu_type, + .get_psu_in_curr = rg_get_psu_in_curr, + .get_psu_in_vol = rg_get_psu_in_vol, + .get_psu_in_power = rg_get_psu_in_power, + .get_psu_out_curr = rg_get_psu_out_curr, + .get_psu_out_vol = rg_get_psu_out_vol, + .get_psu_out_power = rg_get_psu_out_power, + .get_psu_out_max_power = rg_get_psu_out_max_power, + .get_psu_present_status = rg_get_psu_present_status, + .get_psu_in_status = rg_get_psu_in_status, + .get_psu_out_status = rg_get_psu_out_status, + .get_psu_fan_speed = rg_get_psu_fan_speed, + .get_psu_fan_ratio = rg_get_psu_fan_ratio, + .set_psu_fan_ratio = rg_set_psu_fan_ratio, + .get_psu_fan_direction = rg_get_psu_fan_direction, + .get_psu_led_status = rg_get_psu_led_status, + .get_psu_temp_alias = rg_get_psu_temp_alias, + .get_psu_temp_type = rg_get_psu_temp_type, + .get_psu_temp_max = rg_get_psu_temp_max, + .set_psu_temp_max = rg_set_psu_temp_max, + .get_psu_temp_min = rg_get_psu_temp_min, + .set_psu_temp_min = rg_set_psu_temp_min, + .get_psu_temp_value = rg_get_psu_temp_value, +}; + +static int __init psu_dev_drv_init(void) +{ + int ret; + + PSU_INFO("psu_init...\n"); + g_drv = switch_driver_get(); + check_p(g_drv); + + ret = s3ip_sysfs_psu_drivers_register(&drivers); + if (ret < 0) { + PSU_ERR("psu drivers register err, ret %d.\n", ret); + return ret; + } + PSU_INFO("psu_init success.\n"); + return 0; +} + +static void __exit psu_dev_drv_exit(void) +{ + s3ip_sysfs_psu_drivers_unregister(); + PSU_INFO("psu_exit ok.\n"); + + return; +} + +module_init(psu_dev_drv_init); +module_exit(psu_dev_drv_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4, all=0xf).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_DESCRIPTION("psu device driver"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/slot_device_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/slot_device_driver.c new file mode 100644 index 000000000000..f59515a20422 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/slot_device_driver.c @@ -0,0 +1,1016 @@ +/* + * slot_device_driver.c + * + * This module realize /sys/s3ip/slot attributes read and write functions + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "device_driver_common.h" +#include "slot_sysfs.h" +#include "dfd_sysfs_common.h" + +#define SLOT_INFO(fmt, args...) LOG_INFO("slot: ", fmt, ##args) +#define SLOT_ERR(fmt, args...) LOG_ERR("slot: ", fmt, ##args) +#define SLOT_DBG(fmt, args...) LOG_DBG("slot: ", fmt, ##args) + +static int g_loglevel = 0; +static struct switch_drivers_s *g_drv = NULL; + +/******************************************slot***********************************************/ +static int rg_get_slot_number(void) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_slot_number); + + ret = g_drv->get_slot_number(); + return ret; +} + +static int rg_get_slot_temp_number(unsigned int slot_index) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_slot_temp_number); + + ret = g_drv->get_slot_temp_number(slot_index); + return ret; +} + +static int rg_get_slot_vol_number(unsigned int slot_index) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_slot_vol_number); + + ret = g_drv->get_slot_vol_number(slot_index); + return ret; +} + +static int rg_get_slot_curr_number(unsigned int slot_index) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_slot_curr_number); + + ret = g_drv->get_slot_curr_number(slot_index); + return ret; +} + +static int rg_get_slot_fpga_number(unsigned int slot_index) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_slot_fpga_number); + + ret = g_drv->get_slot_fpga_number(slot_index); + return ret; +} + +static int rg_get_slot_cpld_number(unsigned int slot_index) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_slot_cpld_number); + + ret = g_drv->get_slot_cpld_number(slot_index); + return ret; +} + +/* + * rg_get_slot_model_name - Used to get slot model name, + * @slot_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_model_name(unsigned int slot_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_model_name); + + ret = g_drv->get_slot_model_name(slot_index, buf, count); + return ret; +} + +/* + * rg_get_slot_serial_number - Used to get slot serial number, + * @slot_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_serial_number(unsigned int slot_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_serial_number); + + ret = g_drv->get_slot_serial_number(slot_index, buf, count); + return ret; +} + +/* + * rg_get_slot_part_number - Used to get slot part number, + * @slot_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_part_number(unsigned int slot_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_part_number); + + ret = g_drv->get_slot_part_number(slot_index, buf, count); + return ret; +} + +/* + * rg_get_slot_hardware_version - Used to get slot hardware version, + * @slot_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_hardware_version(unsigned int slot_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_hardware_version); + + ret = g_drv->get_slot_hardware_version(slot_index, buf, count); + return ret; +} + +/* + * rg_get_slot_status - Used to get slot status, + * filled the value to buf, slot status define as below: + * 0: ABSENT + * 1: OK + * 2: NOT OK + * + * @slot_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_status(unsigned int slot_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_status); + + ret = g_drv->get_slot_status(slot_index, buf, count); + return ret; +} + +/* + * rg_get_slot_led_status - Used to get slot led status + * filled the value to buf, led status value define as below: + * 0: dark + * 1: green + * 2: yellow + * 3: red + * 4: blue + * 5: green light flashing + * 6: yellow light flashing + * 7: red light flashing + * 8: blue light flashing + * + * @slot_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_led_status(unsigned int slot_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_led_status); + + ret = g_drv->get_slot_led_status(slot_index, buf, count); + return ret; +} + +/* + * rg_set_slot_led_status - Used to set slot led status + * @slot_index: start with 1 + * @status: led status, led status value define as below: + * 0: dark + * 1: green + * 2: yellow + * 3: red + * 4: blue + * 5: green light flashing + * 6: yellow light flashing + * 7: red light flashing + * 8: blue light flashing + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int rg_set_slot_led_status(unsigned int slot_index, int status) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->set_slot_led_status); + + ret = g_drv->set_slot_led_status(slot_index, status); + return ret; +} + +/* + * rg_get_slot_temp_alias - Used to identify the location of the temperature sensor of slot, + * @slot_index: start with 1 + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_temp_alias(unsigned int slot_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_temp_alias); + + ret = g_drv->get_slot_temp_alias(slot_index, temp_index, buf, count); + return ret; +} + +/* + * rg_get_slot_temp_type - Used to get the model of temperature sensor of slot, + * @slot_index: start with 1 + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_temp_type(unsigned int slot_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_temp_type); + + ret = g_drv->get_slot_temp_type(slot_index, temp_index, buf, count); + return ret; +} + +/* + * rg_get_slot_temp_max - Used to get the maximum threshold of temperature sensor of slot, + * filled the value to buf, the value is integer with millidegree Celsius + * @slot_index: start with 1 + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_temp_max(unsigned int slot_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_temp_max); + + ret = g_drv->get_slot_temp_max(slot_index, temp_index, buf, count); + return ret; +} + +/* + * rg_get_slot_temp_min - Used to get the minimum threshold of temperature sensor of slot, + * filled the value to buf, the value is integer with millidegree Celsius + * @slot_index: start with 1 + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_temp_min(unsigned int slot_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_temp_min); + + ret = g_drv->get_slot_temp_min(slot_index, temp_index, buf, count); + return ret; +} + +/* + * rg_get_slot_temp_value - Used to get the input value of temperature sensor of slot, + * filled the value to buf, the value is integer with millidegree Celsius + * @slot_index: start with 1 + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_temp_value(unsigned int slot_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_temp_value); + + ret = g_drv->get_slot_temp_value(slot_index, temp_index, buf, count); + return ret; +} + +/* + * rg_get_slot_vol_alias - Used to identify the location of the voltage sensor of slot, + * @slot_index: start with 1 + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_vol_alias(unsigned int slot_index, unsigned int vol_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_vol_alias); + + ret = g_drv->get_slot_vol_alias(slot_index, vol_index, buf, count); + return ret; +} + +/* + * rg_get_slot_vol_type - Used to get the model of voltage sensor of slot, + * such as udc90160, tps53622 and so on + * @slot_index: start with 1 + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_vol_type(unsigned int slot_index, unsigned int vol_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_vol_type); + + ret = g_drv->get_slot_vol_type(slot_index, vol_index, buf, count); + return ret; +} + +/* + * rg_get_slot_vol_max - Used to get the maximum threshold of voltage sensor of slot, + * filled the value to buf, the value is integer with mV + * @slot_index: start with 1 + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_vol_max(unsigned int slot_index, unsigned int vol_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_vol_max); + + ret = g_drv->get_slot_vol_max(slot_index, vol_index, buf, count); + return ret; +} + +/* + * rg_get_slot_vol_min - Used to get the minimum threshold of voltage sensor of slot, + * filled the value to buf, the value is integer with mV + * @slot_index: start with 1 + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_vol_min(unsigned int slot_index, unsigned int vol_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_vol_min); + + ret = g_drv->get_slot_vol_min(slot_index, vol_index, buf, count); + return ret; +} + +/* + * rg_get_slot_vol_range - Used to get the output error value of voltage sensor of slot, + * filled the value to buf + * @slot_index: start with 1 + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_vol_range(unsigned int slot_index, unsigned int vol_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_vol_range); + + ret = g_drv->get_slot_vol_range(slot_index, vol_index, buf, count); + return ret; +} + +/* + * rg_get_slot_vol_nominal_value - Used to get the nominal value of voltage sensor of slot, + * filled the value to buf + * @slot_index: start with 1 + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_vol_nominal_value(unsigned int slot_index, + unsigned int vol_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_vol_nominal_value); + + ret = g_drv->get_slot_vol_nominal_value(slot_index, vol_index, buf, count); + return ret; +} + +/* + * rg_get_slot_vol_value - Used to get the input value of voltage sensor of slot, + * filled the value to buf, the value is integer with mV + * @slot_index: start with 1 + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_vol_value(unsigned int slot_index, unsigned int vol_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_vol_value); + + ret = g_drv->get_slot_vol_value(slot_index, vol_index, buf, count); + return ret; +} + +/* + * rg_get_slot_curr_alias - Used to identify the location of the current sensor of slot, + * @slot_index: start with 1 + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_curr_alias(unsigned int slot_index, unsigned int curr_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_curr_alias); + + ret = g_drv->get_slot_curr_alias(slot_index, curr_index, buf, count); + return ret; +} + +/* + * rg_get_slot_curr_type - Used to get the model of current sensor of slot, + * @slot_index: start with 1 + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_curr_type(unsigned int slot_index, unsigned int curr_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_curr_type); + + ret = g_drv->get_slot_curr_type(slot_index, curr_index, buf, count); + return ret; +} + +/* + * rg_get_slot_curr_max - Used to get the maximum threshold of current sensor of slot, + * filled the value to buf, the value is integer with mA + * @slot_index: start with 1 + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_curr_max(unsigned int slot_index, unsigned int curr_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_curr_max); + + ret = g_drv->get_slot_curr_max(slot_index, curr_index, buf, count); + return ret; +} + +/* + * rg_get_slot_curr_min - Used to get the minimum threshold of current sensor of slot, + * filled the value to buf, the value is integer with mA + * @slot_index: start with 1 + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_curr_min(unsigned int slot_index, unsigned int curr_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_curr_min); + + ret = g_drv->get_slot_curr_min(slot_index, curr_index, buf, count); + return ret; +} + +/* + * rg_get_slot_curr_value - Used to get the input value of current sensor of slot, + * filled the value to buf, the value is integer with mA + * @slot_index: start with 1 + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_curr_value(unsigned int slot_index, unsigned int curr_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_curr_value); + + ret = g_drv->get_slot_curr_value(slot_index, curr_index, buf, count); + return ret; +} + +/* + * rg_get_slot_fpga_alias - Used to identify the location of slot fpga, + * @slot_index: start with 1 + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_fpga_alias(unsigned int slot_index, unsigned int fpga_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_fpga_alias); + + ret = g_drv->get_slot_fpga_alias(slot_index, fpga_index, buf, count); + return ret; +} + +/* + * rg_get_slot_fpga_type - Used to get slot fpga model name + * @slot_index: start with 1 + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_fpga_type(unsigned int slot_index, unsigned int fpga_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_fpga_type); + + ret = g_drv->get_slot_fpga_type(slot_index, fpga_index, buf, count); + return ret; +} + +/* + * rg_get_slot_fpga_firmware_version - Used to get slot fpga firmware version, + * @slot_index: start with 1 + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_fpga_firmware_version(unsigned int slot_index, unsigned int fpga_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_fpga_firmware_version); + + ret = g_drv->get_slot_fpga_firmware_version(slot_index, fpga_index, buf, count); + return ret; +} + +/* + * rg_get_slot_fpga_board_version - Used to get slot fpga board version, + * @slot_index: start with 1 + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_fpga_board_version(unsigned int slot_index, unsigned int fpga_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_fpga_board_version); + + ret = g_drv->get_slot_fpga_board_version(slot_index, fpga_index, buf, count); + return ret; +} + +/* + * rg_get_slot_fpga_test_reg - Used to test slot fpga register read + * filled the value to buf, value is hexadecimal, start with 0x + * @slot_index: start with 1 + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_fpga_test_reg(unsigned int slot_index, unsigned int fpga_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_fpga_test_reg); + + ret = g_drv->get_slot_fpga_test_reg(slot_index, fpga_index, buf, count); + return ret; +} + +/* + * rg_set_slot_fpga_test_reg - Used to test slot fpga register write + * @slot_index: start with 1 + * @fpga_index: start with 1 + * @value: value write to slot fpga + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int rg_set_slot_fpga_test_reg(unsigned int slot_index, unsigned int fpga_index, + unsigned int value) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->set_slot_fpga_test_reg); + + ret = g_drv->set_slot_fpga_test_reg(slot_index, fpga_index, value); + return ret; +} + +/* + * rg_get_slot_cpld_alias - Used to identify the location of slot cpld, + * @slot_index: start with 1 + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_cpld_alias(unsigned int slot_index, unsigned int cpld_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_cpld_alias); + + ret = g_drv->get_slot_cpld_alias(slot_index, cpld_index, buf, count); + return ret; +} + +/* + * rg_get_slot_cpld_type - Used to get slot cpld model name + * @slot_index: start with 1 + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_cpld_type(unsigned int slot_index, unsigned int cpld_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_cpld_type); + + ret = g_drv->get_slot_cpld_type(slot_index, cpld_index, buf, count); + return ret; +} + +/* + * rg_get_slot_cpld_firmware_version - Used to get slot cpld firmware version, + * @slot_index: start with 1 + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_cpld_firmware_version(unsigned int slot_index, unsigned int cpld_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_cpld_firmware_version); + + ret = g_drv->get_slot_cpld_firmware_version(slot_index, cpld_index, buf, count); + return ret; +} + +/* + * rg_get_slot_cpld_board_version - Used to get slot cpld board version, + * @slot_index: start with 1 + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_cpld_board_version(unsigned int slot_index, unsigned int cpld_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_cpld_board_version); + + ret = g_drv->get_slot_cpld_board_version(slot_index, cpld_index, buf, count); + return ret; +} + +/* + * rg_get_slot_cpld_test_reg - Used to test slot cpld register read + * filled the value to buf, value is hexadecimal, start with 0x + * @slot_index: start with 1 + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_cpld_test_reg(unsigned int slot_index, unsigned int cpld_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_cpld_test_reg); + + ret = g_drv->get_slot_cpld_test_reg(slot_index, cpld_index, buf, count); + return ret; +} + +/* + * rg_set_slot_cpld_test_reg - Used to test slot cpld register write + * @slot_index: start with 1 + * @cpld_index: start with 1 + * @value: value write to slot cpld + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int rg_set_slot_cpld_test_reg(unsigned int slot_index, unsigned int cpld_index, + unsigned int value) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->set_slot_cpld_test_reg); + + ret = g_drv->set_slot_cpld_test_reg(slot_index, cpld_index, value); + return ret; +} +/***************************************end of slot*******************************************/ + +static struct s3ip_sysfs_slot_drivers_s drivers = { + /* + * set ODM slot drivers to /sys/s3ip/slot, + * if not support the function, set corresponding hook to NULL. + */ + .get_slot_number = rg_get_slot_number, + .get_slot_temp_number = rg_get_slot_temp_number, + .get_slot_vol_number = rg_get_slot_vol_number, + .get_slot_curr_number = rg_get_slot_curr_number, + .get_slot_cpld_number = rg_get_slot_cpld_number, + .get_slot_fpga_number = rg_get_slot_fpga_number, + .get_slot_model_name = rg_get_slot_model_name, + .get_slot_serial_number = rg_get_slot_serial_number, + .get_slot_part_number = rg_get_slot_part_number, + .get_slot_hardware_version = rg_get_slot_hardware_version, + .get_slot_status = rg_get_slot_status, + .get_slot_led_status = rg_get_slot_led_status, + .set_slot_led_status = rg_set_slot_led_status, + .get_slot_temp_alias = rg_get_slot_temp_alias, + .get_slot_temp_type = rg_get_slot_temp_type, + .get_slot_temp_max = rg_get_slot_temp_max, + .get_slot_temp_min = rg_get_slot_temp_min, + .get_slot_temp_value = rg_get_slot_temp_value, + .get_slot_vol_alias = rg_get_slot_vol_alias, + .get_slot_vol_type = rg_get_slot_vol_type, + .get_slot_vol_max = rg_get_slot_vol_max, + .get_slot_vol_min = rg_get_slot_vol_min, + .get_slot_vol_range = rg_get_slot_vol_range, + .get_slot_vol_nominal_value = rg_get_slot_vol_nominal_value, + .get_slot_vol_value = rg_get_slot_vol_value, + .get_slot_curr_alias = rg_get_slot_curr_alias, + .get_slot_curr_type = rg_get_slot_curr_type, + .get_slot_curr_max = rg_get_slot_curr_max, + .get_slot_curr_min = rg_get_slot_curr_min, + .get_slot_curr_value = rg_get_slot_curr_value, + .get_slot_fpga_alias = rg_get_slot_fpga_alias, + .get_slot_fpga_alias = rg_get_slot_fpga_alias, + .get_slot_fpga_type = rg_get_slot_fpga_type, + .get_slot_fpga_firmware_version = rg_get_slot_fpga_firmware_version, + .get_slot_fpga_board_version = rg_get_slot_fpga_board_version, + .get_slot_fpga_test_reg = rg_get_slot_fpga_test_reg, + .set_slot_fpga_test_reg = rg_set_slot_fpga_test_reg, + .get_slot_cpld_alias = rg_get_slot_cpld_alias, + .get_slot_cpld_type = rg_get_slot_cpld_type, + .get_slot_cpld_firmware_version = rg_get_slot_cpld_firmware_version, + .get_slot_cpld_board_version = rg_get_slot_cpld_board_version, + .get_slot_cpld_test_reg = rg_get_slot_cpld_test_reg, + .set_slot_cpld_test_reg = rg_set_slot_cpld_test_reg, +}; + +static int __init slot_dev_drv_init(void) +{ + int ret; + + SLOT_INFO("slot_init...\n"); + g_drv = switch_driver_get(); + check_p(g_drv); + + ret = s3ip_sysfs_slot_drivers_register(&drivers); + if (ret < 0) { + SLOT_ERR("slot drivers register err, ret %d.\n", ret); + return ret; + } + SLOT_INFO("slot_init success.\n"); + return 0; +} + +static void __exit slot_dev_drv_exit(void) +{ + s3ip_sysfs_slot_drivers_unregister(); + SLOT_INFO("slot_exit success.\n"); + return; +} + +module_init(slot_dev_drv_init); +module_exit(slot_dev_drv_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4, all=0xf).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_DESCRIPTION("slot device driver"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/syseeprom_device_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/syseeprom_device_driver.c new file mode 100644 index 000000000000..b92acb40d75f --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/syseeprom_device_driver.c @@ -0,0 +1,125 @@ +/* + * syseeprom_device_driver.c + * + * This module realize /sys/s3ip/syseeprom attributes read and write functions + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "device_driver_common.h" +#include "syseeprom_sysfs.h" +#include "dfd_sysfs_common.h" + +#define SYSE2_INFO(fmt, args...) LOG_INFO("syseeprom: ", fmt, ##args) +#define SYSE2_ERR(fmt, args...) LOG_ERR("syseeprom: ", fmt, ##args) +#define SYSE2_DBG(fmt, args...) LOG_DBG("syseeprom: ", fmt, ##args) + +static int g_loglevel = 0; +static struct switch_drivers_s *g_drv = NULL; + +/*****************************************syseeprom*******************************************/ +/* + * rg_get_syseeprom_size - Used to get syseeprom size + * + * This function returns the size of syseeprom by your switch, + * otherwise it returns a negative value on failed. + */ +static int rg_get_syseeprom_size(void) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_syseeprom_size); + + ret = g_drv->get_syseeprom_size(); + return ret; +} + +/* + * rg_read_syseeprom_data - Used to read syseeprom data, + * @buf: Data read buffer + * @offset: offset address to read syseeprom data + * @count: length of buf + * + * This function returns the length of the filled buffer, + * returns 0 means EOF, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_read_syseeprom_data(char *buf, loff_t offset, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->read_syseeprom_data); + + ret = g_drv->read_syseeprom_data(buf, offset, count); + return ret; +} + +/* + * rg_write_syseeprom_data - Used to write syseeprom data + * @buf: Data write buffer + * @offset: offset address to write syseeprom data + * @count: length of buf + * + * This function returns the written length of syseeprom, + * returns 0 means EOF, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_write_syseeprom_data(char *buf, loff_t offset, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->write_syseeprom_data); + + ret = g_drv->write_syseeprom_data(buf, offset, count); + return ret; +} +/*************************************end of syseeprom****************************************/ + +static struct s3ip_sysfs_syseeprom_drivers_s drivers = { + /* + * set ODM syseeprom drivers to /sys/s3ip/syseeprom, + * if not support the function, set corresponding hook to NULL. + */ + .get_syseeprom_size = rg_get_syseeprom_size, + .read_syseeprom_data = rg_read_syseeprom_data, + .write_syseeprom_data = rg_write_syseeprom_data, +}; + +static int __init syseeprom_dev_drv_init(void) +{ + int ret; + + SYSE2_INFO("syseeprom_dev_drv_init...\n"); + g_drv = switch_driver_get(); + check_p(g_drv); + + ret = s3ip_sysfs_syseeprom_drivers_register(&drivers); + if (ret < 0) { + SYSE2_ERR("syseeprom drivers register err, ret %d.\n", ret); + return ret; + } + SYSE2_INFO("syseeprom_dev_drv_init success.\n"); + return 0; +} + +static void __exit syseeprom_dev_drv_exit(void) +{ + s3ip_sysfs_syseeprom_drivers_unregister(); + SYSE2_INFO("syseeprom_exit success.\n"); + return; +} + +module_init(syseeprom_dev_drv_init); +module_exit(syseeprom_dev_drv_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4, all=0xf).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_DESCRIPTION("syseeprom device driver"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/sysled_device_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/sysled_device_driver.c new file mode 100644 index 000000000000..6f6ab3f280aa --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/sysled_device_driver.c @@ -0,0 +1,229 @@ +/* + * sysled_device_driver.c + * + * This module realize /sys/s3ip/sysled attributes read and write functions + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "device_driver_common.h" +#include "sysled_sysfs.h" +#include "dfd_sysfs_common.h" + +#define SYSLED_INFO(fmt, args...) LOG_INFO("sysled: ", fmt, ##args) +#define SYSLED_ERR(fmt, args...) LOG_ERR("sysled: ", fmt, ##args) +#define SYSLED_DBG(fmt, args...) LOG_DBG("sysled: ", fmt, ##args) + +static int g_loglevel = 0; +static struct switch_drivers_s *g_drv = NULL; + +/*****************************************sysled**********************************************/ +/* + * rg_get_sys_led_status - Used to get sys led status + * filled the value to buf, led status value define as below: + * 0: dark + * 1: green + * 2: yellow + * 3: red + * 4: blue + * 5: green light flashing + * 6: yellow light flashing + * 7: red light flashing + * 8: blue light flashing + * + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_sys_led_status(char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_sys_led_status); + + ret = g_drv->get_sys_led_status(buf, count); + return ret; +} + +/* + * rg_set_sys_led_status - Used to set sys led status + * @status: led status, led status value define as below: + * 0: dark + * 1: green + * 2: yellow + * 3: red + * 4: blue + * 5: green light flashing + * 6: yellow light flashing + * 7: red light flashing + * 8: blue light flashing + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int rg_set_sys_led_status(int status) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->set_sys_led_status); + + ret = g_drv->set_sys_led_status(status); + return ret; +} + +/* Similar to rg_get_sys_led_status */ +static ssize_t rg_get_bmc_led_status(char *buf, size_t count) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_bmc_led_status); + + ret = g_drv->get_bmc_led_status(buf, count); + return ret; +} + +/* Similar to rg_set_sys_led_status */ +static int rg_set_bmc_led_status(int status) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->set_bmc_led_status); + + ret = g_drv->set_bmc_led_status(status); + return ret; +} + +/* Similar to rg_get_sys_led_status */ +static ssize_t rg_get_sys_fan_led_status(char *buf, size_t count) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_sys_fan_led_status); + + ret = g_drv->get_sys_fan_led_status(buf, count); + return ret; +} + +/* Similar to rg_set_sys_led_status */ +static int rg_set_sys_fan_led_status(int status) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->set_sys_fan_led_status); + + ret = g_drv->set_sys_fan_led_status(status); + return ret; +} + +/* Similar to rg_get_sys_led_status */ +static ssize_t rg_get_sys_psu_led_status(char *buf, size_t count) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_sys_psu_led_status); + + ret = g_drv->get_sys_psu_led_status(buf, count); + return ret; +} + +/* Similar to rg_set_sys_led_status */ +static int rg_set_sys_psu_led_status(int status) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->set_sys_psu_led_status); + + ret = g_drv->set_sys_psu_led_status(status); + return ret; +} + +/* Similar to rg_get_sys_led_status */ +static ssize_t rg_get_id_led_status(char *buf, size_t count) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_id_led_status); + + ret = g_drv->get_id_led_status(buf, count); + return ret; +} + +/* Similar to rg_set_sys_led_status */ +static int rg_set_id_led_status(int status) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->set_id_led_status); + + ret = g_drv->set_id_led_status(status); + return ret; +} + +/**************************************end of sysled******************************************/ + +static struct s3ip_sysfs_sysled_drivers_s drivers = { + /* + * set ODM sysled drivers to /sys/s3ip/sysled, + * if not support the function, set corresponding hook to NULL. + */ + .get_sys_led_status = rg_get_sys_led_status, + .set_sys_led_status = rg_set_sys_led_status, + .get_bmc_led_status = rg_get_bmc_led_status, + .set_bmc_led_status = rg_set_bmc_led_status, + .get_sys_fan_led_status = rg_get_sys_fan_led_status, + .set_sys_fan_led_status = rg_set_sys_fan_led_status, + .get_sys_psu_led_status = rg_get_sys_psu_led_status, + .set_sys_psu_led_status = rg_set_sys_psu_led_status, + .get_id_led_status = rg_get_id_led_status, + .set_id_led_status = rg_set_id_led_status, +}; + +static int __init sysled_init(void) +{ + int ret; + + SYSLED_INFO("sysled_init...\n"); + g_drv = switch_driver_get(); + check_p(g_drv); + + ret = s3ip_sysfs_sysled_drivers_register(&drivers); + if (ret < 0) { + SYSLED_ERR("sysled drivers register err, ret %d.\n", ret); + return ret; + } + + SYSLED_INFO("sysled create success.\n"); + return 0; +} + +static void __exit sysled_exit(void) +{ + s3ip_sysfs_sysled_drivers_unregister(); + SYSLED_INFO("sysled_exit ok.\n"); + return; +} + +module_init(sysled_init); +module_exit(sysled_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4, all=0xf).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_DESCRIPTION("sysled device driver"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/temp_sensor_device_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/temp_sensor_device_driver.c new file mode 100644 index 000000000000..65b70009ac44 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/temp_sensor_device_driver.c @@ -0,0 +1,196 @@ +/* + * temp_sensor_device_driver.c + * + * This module realize /sys/s3ip/temp_sensor attributes read and write functions + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "device_driver_common.h" +#include "temp_sensor_sysfs.h" +#include "dfd_sysfs_common.h" + +#define TEMP_SENSOR_INFO(fmt, args...) LOG_INFO("temp_sensor: ", fmt, ##args) +#define TEMP_SENSOR_ERR(fmt, args...) LOG_ERR("temp_sensor: ", fmt, ##args) +#define TEMP_SENSOR_DBG(fmt, args...) LOG_DBG("temp_sensor: ", fmt, ##args) + +static int g_loglevel = 0; +static struct switch_drivers_s *g_drv = NULL; + +/***************************************main board temp*****************************************/ +/* + * rg_get_main_board_temp_number - Used to get main board temperature sensors number, + * + * This function returns main board temperature sensors by your switch, + * If there is no main board temperature sensors, returns 0, + * otherwise it returns a negative value on failed. + */ +static int rg_get_main_board_temp_number(void) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_temp_number); + + ret = g_drv->get_main_board_temp_number(); + return ret; +} + +/* + * rg_get_main_board_temp_alias - Used to identify the location of the temperature sensor, + * such as air_inlet, air_outlet and so on. + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_temp_alias(unsigned int temp_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_temp_alias); + + ret = g_drv->get_main_board_temp_alias(temp_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_temp_type - Used to get the model of temperature sensor, + * such as lm75, tmp411 and so on + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_temp_type(unsigned int temp_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_temp_type); + + ret = g_drv->get_main_board_temp_type(temp_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_temp_max - Used to get the maximum threshold of temperature sensor + * filled the value to buf, the value is integer with millidegree Celsius + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_temp_max(unsigned int temp_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_temp_max); + + ret = g_drv->get_main_board_temp_max(temp_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_temp_min - Used to get the minimum threshold of temperature sensor + * filled the value to buf, the value is integer with millidegree Celsius + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_temp_min(unsigned int temp_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_temp_min); + + ret = g_drv->get_main_board_temp_min(temp_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_temp_value - Used to get the input value of temperature sensor + * filled the value to buf, the value is integer with millidegree Celsius + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_temp_value(unsigned int temp_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_temp_value); + + ret = g_drv->get_main_board_temp_value(temp_index, buf, count); + return ret; +} +/***********************************end of main board temp*************************************/ + +static struct s3ip_sysfs_temp_sensor_drivers_s drivers = { + /* + * set ODM temperature sensor drivers to /sys/s3ip/temp_sensor, + * if not support the function, set corresponding hook to NULL. + */ + .get_main_board_temp_number = rg_get_main_board_temp_number, + .get_main_board_temp_alias = rg_get_main_board_temp_alias, + .get_main_board_temp_type = rg_get_main_board_temp_type, + .get_main_board_temp_max = rg_get_main_board_temp_max, + .get_main_board_temp_min = rg_get_main_board_temp_min, + .get_main_board_temp_value = rg_get_main_board_temp_value, +}; + +static int __init temp_sensor_dev_drv_init(void) +{ + int ret; + + TEMP_SENSOR_INFO("temp_sensor_init...\n"); + g_drv = switch_driver_get(); + check_p(g_drv); + + ret = s3ip_sysfs_temp_sensor_drivers_register(&drivers); + if (ret < 0) { + TEMP_SENSOR_ERR("temp sensor drivers register err, ret %d.\n", ret); + return ret; + } + TEMP_SENSOR_INFO("temp_sensor_init success.\n"); + return 0; +} + +static void __exit temp_sensor_dev_drv_exit(void) +{ + s3ip_sysfs_temp_sensor_drivers_unregister(); + TEMP_SENSOR_INFO("temp_sensor_exit success.\n"); + return; +} + +module_init(temp_sensor_dev_drv_init); +module_exit(temp_sensor_dev_drv_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4, all=0xf).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_DESCRIPTION("temperature sensors device driver"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/transceiver_device_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/transceiver_device_driver.c new file mode 100644 index 000000000000..81edd935fc99 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/transceiver_device_driver.c @@ -0,0 +1,424 @@ +/* + * transceiver_device_driver.c + * + * This module realize /sys/s3ip/transceiver attributes read and write functions + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "device_driver_common.h" +#include "transceiver_sysfs.h" +#include "dfd_sysfs_common.h" + +#define SFF_INFO(fmt, args...) LOG_INFO("sff: ", fmt, ##args) +#define SFF_ERR(fmt, args...) LOG_ERR("sff: ", fmt, ##args) +#define SFF_DBG(fmt, args...) LOG_DBG("sff: ", fmt, ##args) + +static int g_loglevel = 0; +static struct switch_drivers_s *g_drv = NULL; + +/****************************************transceiver******************************************/ +static int rg_get_eth_number(void) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_eth_number); + + ret = g_drv->get_eth_number(); + return ret; +} + +/* + * rg_get_transceiver_power_on_status - Used to get the whole machine port power on status, + * filled the value to buf, 0: power off, 1: power on + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_transceiver_power_on_status(char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_transceiver_power_on_status); + + ret = g_drv->get_transceiver_power_on_status(buf, count); + return ret; +} + +/* + * rg_set_transceiver_power_on_status - Used to set the whole machine port power on status, + * @status: power on status, 0: power off, 1: power on + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int rg_set_transceiver_power_on_status(int status) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->set_transceiver_power_on_status); + + ret = g_drv->set_transceiver_power_on_status(status); + return ret; +} + +/* + * rg_get_eth_power_on_status - Used to get single port power on status, + * filled the value to buf, 0: power off, 1: power on + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_eth_power_on_status(unsigned int eth_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_eth_power_on_status); + + ret = g_drv->get_eth_power_on_status(eth_index, buf, count); + return ret; +} + +/* + * rg_set_eth_power_on_status - Used to set single port power on status, + * @eth_index: start with 1 + * @status: power on status, 0: power off, 1: power on + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int rg_set_eth_power_on_status(unsigned int eth_index, int status) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->set_eth_power_on_status); + + ret = g_drv->set_eth_power_on_status(eth_index, status); + return ret; +} + +/* + * rg_get_eth_tx_fault_status - Used to get port tx_fault status, + * filled the value to buf, 0: normal, 1: abnormal + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_eth_tx_fault_status(unsigned int eth_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_eth_tx_fault_status); + + ret = g_drv->get_eth_tx_fault_status(eth_index, buf, count); + return ret; +} + +/* + * rg_get_eth_tx_disable_status - Used to get port tx_disable status, + * filled the value to buf, 0: tx_enable, 1: tx_disable + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_eth_tx_disable_status(unsigned int eth_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_eth_tx_disable_status); + + ret = g_drv->get_eth_tx_disable_status(eth_index, buf, count); + return ret; +} + +/* + * rg_set_eth_tx_disable_status - Used to set port tx_disable status, + * @eth_index: start with 1 + * @status: tx_disable status, 0: tx_enable, 1: tx_disable + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int rg_set_eth_tx_disable_status(unsigned int eth_index, int status) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->set_eth_tx_disable_status); + + ret = g_drv->set_eth_tx_disable_status(eth_index, status); + return ret; +} + +/* + * rg_get_eth_present_status - Used to get port present status, + * filled the value to buf, 1: present, 0: absent + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_eth_present_status(unsigned int eth_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_eth_present_status); + + ret = g_drv->get_eth_present_status(eth_index, buf, count); + return ret; +} + +/* + * rg_get_eth_rx_los_status - Used to get port rx_los status, + * filled the value to buf, 0: normal, 1: abnormal + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_eth_rx_los_status(unsigned int eth_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_eth_rx_los_status); + + ret = g_drv->get_eth_rx_los_status(eth_index, buf, count); + return ret; +} + +/* + * rg_get_eth_reset_status - Used to get port reset status, + * filled the value to buf, 0: unreset, 1: reset + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_eth_reset_status(unsigned int eth_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_eth_reset_status); + + ret = g_drv->get_eth_reset_status(eth_index, buf, count); + return ret; +} + +/* + * rg_set_eth_reset_status - Used to set port reset status, + * @eth_index: start with 1 + * @status: reset status, 0: unreset, 1: reset + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int rg_set_eth_reset_status(unsigned int eth_index, int status) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->set_eth_reset_status); + + ret = g_drv->set_eth_reset_status(eth_index, status); + return ret; +} + +/* + * rg_get_eth_low_power_mode_status - Used to get port low power mode status, + * filled the value to buf, 0: high power mode, 1: low power mode + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_eth_low_power_mode_status(unsigned int eth_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_eth_low_power_mode_status); + + ret = g_drv->get_eth_low_power_mode_status(eth_index, buf, count); + return ret; +} + +/* + * rg_get_eth_interrupt_status - Used to get port interruption status, + * filled the value to buf, 0: no interruption, 1: interruption + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_eth_interrupt_status(unsigned int eth_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_eth_interrupt_status); + + ret = g_drv->get_eth_interrupt_status(eth_index, buf, count); + return ret; +} + +/* + * rg_get_eth_eeprom_size - Used to get port eeprom size + * + * This function returns the size of port eeprom, + * otherwise it returns a negative value on failed. + */ +static int rg_get_eth_eeprom_size(unsigned int eth_index) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_eth_eeprom_size); + + ret = g_drv->get_eth_eeprom_size(eth_index); + return ret; +} + +/* + * rg_read_eth_eeprom_data - Used to read port eeprom data, + * @buf: Data read buffer + * @offset: offset address to read port eeprom data + * @count: length of buf + * + * This function returns the length of the filled buffer, + * returns 0 means EOF, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_read_eth_eeprom_data(unsigned int eth_index, char *buf, loff_t offset, + size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->read_eth_eeprom_data); + + ret = g_drv->read_eth_eeprom_data(eth_index, buf, offset, count); + return ret; +} + +/* + * rg_write_eth_eeprom_data - Used to write port eeprom data + * @buf: Data write buffer + * @offset: offset address to write port eeprom data + * @count: length of buf + * + * This function returns the written length of port eeprom, + * returns 0 means EOF, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_write_eth_eeprom_data(unsigned int eth_index, char *buf, loff_t offset, + size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->write_eth_eeprom_data); + + ret = g_drv->write_eth_eeprom_data(eth_index, buf, offset, count); + return ret; +} +/************************************end of transceiver***************************************/ + +static struct s3ip_sysfs_transceiver_drivers_s drivers = { + /* + * set ODM transceiver drivers to /sys/s3ip/transceiver, + * if not support the function, set corresponding hook to NULL. + */ + .get_eth_number = rg_get_eth_number, + .get_transceiver_power_on_status = rg_get_transceiver_power_on_status, + .set_transceiver_power_on_status = rg_set_transceiver_power_on_status, + .get_eth_power_on_status = rg_get_eth_power_on_status, + .set_eth_power_on_status = rg_set_eth_power_on_status, + .get_eth_tx_fault_status = rg_get_eth_tx_fault_status, + .get_eth_tx_disable_status = rg_get_eth_tx_disable_status, + .set_eth_tx_disable_status = rg_set_eth_tx_disable_status, + .get_eth_present_status = rg_get_eth_present_status, + .get_eth_rx_los_status = rg_get_eth_rx_los_status, + .get_eth_reset_status = rg_get_eth_reset_status, + .set_eth_reset_status = rg_set_eth_reset_status, + .get_eth_low_power_mode_status = rg_get_eth_low_power_mode_status, + .get_eth_interrupt_status = rg_get_eth_interrupt_status, + .get_eth_eeprom_size = rg_get_eth_eeprom_size, + .read_eth_eeprom_data = rg_read_eth_eeprom_data, + .write_eth_eeprom_data = rg_write_eth_eeprom_data, +}; + +static int __init sff_dev_drv_init(void) +{ + int ret; + + SFF_INFO("sff_init...\n"); + g_drv = switch_driver_get(); + check_p(g_drv); + + ret = s3ip_sysfs_sff_drivers_register(&drivers); + if (ret < 0) { + SFF_ERR("transceiver drivers register err, ret %d.\n", ret); + return ret; + } + SFF_INFO("sff_init success.\n"); + return 0; +} + +static void __exit sff_dev_drv_exit(void) +{ + s3ip_sysfs_sff_drivers_unregister(); + SFF_INFO("sff_exit success.\n"); + return; +} + +module_init(sff_dev_drv_init); +module_exit(sff_dev_drv_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4, all=0xf).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_DESCRIPTION("transceiver device driver"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/vol_sensor_device_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/vol_sensor_device_driver.c new file mode 100644 index 000000000000..a58e122ac782 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/vol_sensor_device_driver.c @@ -0,0 +1,234 @@ +/* + * vol_sensor_device_driver.c + * + * This module realize /sys/s3ip/vol_sensor attributes read and write functions + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "device_driver_common.h" +#include "vol_sensor_sysfs.h" +#include "dfd_sysfs_common.h" + +#define VOL_SENSOR_INFO(fmt, args...) LOG_INFO("vol_sensor: ", fmt, ##args) +#define VOL_SENSOR_ERR(fmt, args...) LOG_ERR("vol_sensor: ", fmt, ##args) +#define VOL_SENSOR_DBG(fmt, args...) LOG_DBG("vol_sensor: ", fmt, ##args) + +static int g_loglevel = 0; +static struct switch_drivers_s *g_drv = NULL; + +/*************************************main board voltage***************************************/ +static int rg_get_main_board_vol_number(void) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_vol_number); + + ret = g_drv->get_main_board_vol_number(); + return ret; +} + +/* + * rg_get_main_board_vol_alias - Used to identify the location of the voltage sensor, + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_vol_alias(unsigned int vol_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_vol_alias); + + ret = g_drv->get_main_board_vol_alias(vol_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_vol_type - Used to get the model of voltage sensor, + * such as udc90160, tps53622 and so on + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_vol_type(unsigned int vol_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_vol_type); + + ret = g_drv->get_main_board_vol_type(vol_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_vol_max - Used to get the maximum threshold of voltage sensor + * filled the value to buf, the value is integer with mV + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_vol_max(unsigned int vol_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_vol_max); + + ret = g_drv->get_main_board_vol_max(vol_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_vol_min - Used to get the minimum threshold of voltage sensor + * filled the value to buf, the value is integer with mV + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_vol_min(unsigned int vol_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_vol_min); + + ret = g_drv->get_main_board_vol_min(vol_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_vol_range - Used to get the output error value of voltage sensor + * filled the value to buf + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_vol_range(unsigned int vol_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_vol_range); + + ret = g_drv->get_main_board_vol_range(vol_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_vol_nominal_value - Used to get the nominal value of voltage sensor + * filled the value to buf + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_vol_nominal_value(unsigned int vol_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_vol_nominal_value); + + ret = g_drv->get_main_board_vol_nominal_value(vol_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_vol_value - Used to get the input value of voltage sensor + * filled the value to buf, the value is integer with mV + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_vol_value(unsigned int vol_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_vol_value); + + ret = g_drv->get_main_board_vol_value(vol_index, buf, count); + return ret; +} +/*********************************end of main board voltage************************************/ + +static struct s3ip_sysfs_vol_sensor_drivers_s drivers = { + /* + * set ODM voltage sensor drivers to /sys/s3ip/vol_sensor, + * if not support the function, set corresponding hook to NULL. + */ + .get_main_board_vol_number = rg_get_main_board_vol_number, + .get_main_board_vol_alias = rg_get_main_board_vol_alias, + .get_main_board_vol_type = rg_get_main_board_vol_type, + .get_main_board_vol_max = rg_get_main_board_vol_max, + .get_main_board_vol_min = rg_get_main_board_vol_min, + .get_main_board_vol_range = rg_get_main_board_vol_range, + .get_main_board_vol_nominal_value = rg_get_main_board_vol_nominal_value, + .get_main_board_vol_value = rg_get_main_board_vol_value, +}; + +static int __init vol_sensor_dev_drv_init(void) +{ + int ret; + + VOL_SENSOR_INFO("vol_sensor_init...\n"); + g_drv = switch_driver_get(); + check_p(g_drv); + + ret = s3ip_sysfs_vol_sensor_drivers_register(&drivers); + if (ret < 0) { + VOL_SENSOR_ERR("vol sensor drivers register err, ret %d.\n", ret); + return ret; + } + VOL_SENSOR_INFO("vol_sensor_init success.\n"); + return 0; +} + +static void __exit vol_sensor_dev_drv_exit(void) +{ + s3ip_sysfs_vol_sensor_drivers_unregister(); + VOL_SENSOR_INFO("vol_sensor_exit success.\n"); + return; +} + +module_init(vol_sensor_dev_drv_init); +module_exit(vol_sensor_dev_drv_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4, all=0xf).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_DESCRIPTION("voltage sensors device driver"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/watchdog_device_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/watchdog_device_driver.c new file mode 100644 index 000000000000..6ac830cfb4ab --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/watchdog_device_driver.c @@ -0,0 +1,204 @@ +/* + * watchdog_device_driver.c + * + * This module realize /sys/s3ip/watchdog attributes read and write functions + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "device_driver_common.h" +#include "watchdog_sysfs.h" +#include "dfd_sysfs_common.h" + +#define WDT_INFO(fmt, args...) LOG_INFO("watchdog: ", fmt, ##args) +#define WDT_ERR(fmt, args...) LOG_ERR("watchdog: ", fmt, ##args) +#define WDT_DBG(fmt, args...) LOG_DBG("watchdog: ", fmt, ##args) + +static int g_loglevel = 0; +static struct switch_drivers_s *g_drv = NULL; + +/****************************************watchdog*********************************************/ +/* + * rg_get_watchdog_identify - Used to get watchdog identify, such as iTCO_wdt + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_watchdog_identify(char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_watchdog_identify); + + ret = g_drv->get_watchdog_identify(buf, count); + return ret; +} + +/* + * rg_get_watchdog_timeleft - Used to get watchdog timeleft, + * filled the value to buf + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_watchdog_timeleft(char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_watchdog_timeleft); + + ret = g_drv->get_watchdog_timeleft(buf, count); + return ret; +} + +/* + * rg_get_watchdog_timeout - Used to get watchdog timeout, + * filled the value to buf + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_watchdog_timeout(char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_watchdog_timeout); + + ret = g_drv->get_watchdog_timeout(buf, count); + return ret; +} + +/* + * rg_set_watchdog_timeout - Used to set watchdog timeout, + * @value: timeout value + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int rg_set_watchdog_timeout(int value) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->set_watchdog_timeout); + + ret = g_drv->set_watchdog_timeout(value); + return ret; +} + +/* + * rg_get_watchdog_enable_status - Used to get watchdog enable status, + * filled the value to buf, 0: disable, 1: enable + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_watchdog_enable_status(char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_watchdog_enable_status); + + ret = g_drv->get_watchdog_enable_status(buf, count); + return ret; +} + +/* + * rg_set_watchdog_enable_status - Used to set watchdog enable status, + * @value: enable status value, 0: disable, 1: enable + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int rg_set_watchdog_enable_status(int value) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->set_watchdog_enable_status); + + ret = g_drv->set_watchdog_enable_status(value); + return ret; +} + +/* + * rg_set_watchdog_reset - Used to feed watchdog, + * @value: any value to feed watchdog + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int rg_set_watchdog_reset(int value) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->set_watchdog_reset); + + ret = g_drv->set_watchdog_reset(value); + return ret; +} + +/*************************************end of watchdog*****************************************/ + +static struct s3ip_sysfs_watchdog_drivers_s drivers = { + /* + * set ODM watchdog sensor drivers to /sys/s3ip/watchdog, + * if not support the function, set corresponding hook to NULL. + */ + .get_watchdog_identify = rg_get_watchdog_identify, + .get_watchdog_timeleft = rg_get_watchdog_timeleft, + .get_watchdog_timeout = rg_get_watchdog_timeout, + .set_watchdog_timeout = rg_set_watchdog_timeout, + .get_watchdog_enable_status = rg_get_watchdog_enable_status, + .set_watchdog_enable_status = rg_set_watchdog_enable_status, + .set_watchdog_reset = rg_set_watchdog_reset, +}; + +static int __init watchdog_dev_drv_init(void) +{ + int ret; + + WDT_INFO("watchdog_init...\n"); + g_drv = switch_driver_get(); + check_p(g_drv); + + ret = s3ip_sysfs_watchdog_drivers_register(&drivers); + if (ret < 0) { + WDT_ERR("watchdog drivers register err, ret %d.\n", ret); + return ret; + } + WDT_INFO("watchdog create success.\n"); + return 0; +} + +static void __exit watchdog_dev_drv_exit(void) +{ + s3ip_sysfs_watchdog_drivers_unregister(); + WDT_INFO("watchdog_exit success.\n"); + return; +} + +module_init(watchdog_dev_drv_init); +module_exit(watchdog_dev_drv_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4, all=0xf).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_DESCRIPTION("watchdog device driver"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/Makefile b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/Makefile new file mode 100755 index 000000000000..af3af8c4f2a8 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/Makefile @@ -0,0 +1,36 @@ +PWD = $(shell pwd) + +EXTRA_CFLAGS:= -I$(M)/include +EXTRA_CFLAGS+= -Wall + +SUBDIR_CFG = cfg +rg_switch_driver-objs := switch_driver.o rg_module.o \ +rg_fan_driver.o \ +rg_eeprom_driver.o \ +rg_cpld_driver.o \ +rg_fpga_driver.o \ +rg_led_driver.o \ +rg_slot_driver.o \ +rg_sensors_driver.o \ +rg_psu_driver.o \ +rg_sff_driver.o \ +rg_watchdog_driver.o \ +$(SUBDIR_CFG)/dfd_cfg.o \ +$(SUBDIR_CFG)/dfd_cfg_adapter.o \ +$(SUBDIR_CFG)/dfd_cfg_file.o \ +$(SUBDIR_CFG)/dfd_cfg_info.o \ +$(SUBDIR_CFG)/dfd_cfg_listnode.o \ +$(SUBDIR_CFG)/dfd_frueeprom.o \ +$(SUBDIR_CFG)/dfd_tlveeprom.o \ + +obj-m := rg_switch_driver.o +all: + $(MAKE) -C $(KERNEL_SRC)/build M=$(PWD) modules + @if [ ! -d $(sysfs_out_put_dir) ]; then mkdir -p $(sysfs_out_put_dir) ;fi + cp -p $(PWD)/*.ko $(sysfs_out_put_dir) + @if [ ! -d $(sysfs_cfg_dir) ]; then mkdir -p $(sysfs_cfg_dir) ;fi + cp -r $(PWD)/dfd_cfg/* $(sysfs_cfg_dir) +clean: + rm -f $(PWD)/*.o $(PWD)/$(SUBDIR_CFG)/*.o $(PWD)/*.ko $(PWD)/*.mod.c $(PWD)/.*.cmd $(PWD)/$(SUBDIR_CFG)/.*.cmd $(PWD)/*.mod + rm -f $(PWD)/Module.markers $(PWD)/Module.symvers $(PWD)/modules.order + rm -rf $(PWD)/.tmp_versions \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_cfg.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_cfg.c new file mode 100644 index 000000000000..0522e7e5447b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_cfg.c @@ -0,0 +1,964 @@ +/* + * Copyright(C) 2001-2022 Ruijie Network. All rights reserved. + */ +/* + * dfd_cfg.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * History + * [Version] [Author] [Date] [Description] + * v1.0 sonic_rd@ruijie.com.cn 2020-02-17 Initial version + * + */ +#include +#include +#include +#include +#include +#include + +#include "rg_module.h" +#include "dfd_cfg_file.h" +#include "dfd_cfg_listnode.h" +#include "dfd_cfg_info.h" +#include "dfd_cfg_adapter.h" +#include "dfd_cfg.h" + +#ifdef DFD_CFG_ITEM +#undef DFD_CFG_ITEM +#endif +#define DFD_CFG_ITEM(_id, _name, _index_min, _index_max) _name, +static char *dfd_cfg_item_name[] = { + DFD_CFG_ITEM_ALL +}; + +#ifdef DFD_CFG_ITEM +#undef DFD_CFG_ITEM +#endif +#define DFD_CFG_ITEM(_id, _name, _index_min, _index_max) {_index_min, _index_max}, +static index_range_t dfd_cfg_item_index_range[] = { + DFD_CFG_ITEM_ALL +}; + +LIST_HEAD(dfd_lib_cfg_led_status_decode_conv_lst); + +LIST_HEAD(dfd_lib_cfg_fan_name_conv_dir_lst); + +LIST_HEAD(dfd_lib_cfg_power_name_conv_lst); + +static lnode_root_t dfd_ko_cfg_list_root; + +void dfd_ko_cfg_del_space_lf_cr(char *str) +{ + int i, j; + int len; + + if (str == NULL) { + DBG_DEBUG(DBG_ERROR, "param error, str is NULL\n"); + return; + } + len = strlen(str); + for (i = 0; i < len; i++) { + if (str[i] == '\r' || str[i] == '\n' || str[i] == ' ') { + for (j = i; j < len - 1; j++) { + str[j] = str[j + 1]; + } + str[j] = '\0'; + len--; + i--; + } + } +} + +void val_convert_node_lst_free(struct list_head *root) +{ + val_convert_node_t *node, *node_next; + + if (root == NULL){ + return ; + } + + list_for_each_entry_safe(node, node_next, root, lst) { + list_del(&node->lst); + kfree(node); + node = NULL; + } + + return ; + +} + +static void dfd_ko_cfg_regval_conv_lst_add(struct list_head *root, int val, char *str, + int index1, int index2) +{ + val_convert_node_t *val_convert; + + val_convert = (val_convert_node_t *)kmalloc(sizeof(val_convert_node_t), GFP_KERNEL); + if (val_convert == NULL) { + DBG_DEBUG(DBG_ERROR, "kmalloc val_convert_node_t fail\n"); + return; + } + memset(val_convert, 0, sizeof(val_convert_node_t)); + + val_convert->int_val = val; + val_convert->index1 = index1; + val_convert->index2 = index2; + if (str != NULL) { + strncpy(val_convert->str_val, str, sizeof(val_convert->str_val) - 1); + } + + list_add_tail(&(val_convert->lst), root); +} + +static int dfd_ko_cfg_get_index2_by_intval(struct list_head *root, int val, int index1, + int *index2) +{ + val_convert_node_t *val_convert; + + list_for_each_entry(val_convert, root, lst){ + if ((val_convert->int_val == val) && (index1 == val_convert->index1)) { + *index2 = val_convert->index2; + return 0; + } + } + + return -1; +} + +static int dfd_ko_cfg_get_index_by_strval(struct list_head *root, char *str, int *index1, int *index2) +{ + val_convert_node_t *val_convert; + + list_for_each_entry(val_convert, root, lst){ + if (strncmp(val_convert->str_val, str, strlen(val_convert->str_val)) == 0) { + *index1 = val_convert->index1; + *index2 = val_convert->index2; + return 0; + } + } + + return -1; +} + +static void dfd_ko_cfg_convert_list_build(dfd_cfg_item_id_t cfg_item_id, int val, char *str, + int index1, int index2) +{ + if (cfg_item_id == DFD_CFG_ITEM_LED_STATUS_DECODE) { + dfd_ko_cfg_regval_conv_lst_add(&dfd_lib_cfg_led_status_decode_conv_lst, val, str, index1, index2); + } else if (cfg_item_id == DFD_CFG_ITEM_FAN_DIRECTION) { + dfd_ko_cfg_regval_conv_lst_add(&dfd_lib_cfg_fan_name_conv_dir_lst, val, str, index1, index2); + } else if (cfg_item_id == DFD_CFG_ITEM_POWER_NAME) { + dfd_ko_cfg_regval_conv_lst_add(&dfd_lib_cfg_power_name_conv_lst, val, str, index1, index2); + } + return; +} + +int dfd_ko_cfg_get_led_status_decode2_by_regval(int regval, int index1, int *value) +{ + int rv; + + if (value == NULL) { + DBG_DEBUG(DBG_ERROR, "input arguments error\n"); + return -DFD_RV_INVALID_VALUE; + } + + rv = dfd_ko_cfg_get_index2_by_intval(&dfd_lib_cfg_led_status_decode_conv_lst, regval, + index1, value); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "get led status decode by regval[0x%x] index1[%d] fail\n", + regval, index1); + return -DFD_RV_INVALID_VALUE; + } + + return 0; +} + +int dfd_ko_cfg_get_fan_direction_by_name(char *fan_name, int *fan_direction) +{ + int rv; + int index1, index2; + + if ((fan_name == NULL) || (fan_direction == NULL)){ + DBG_DEBUG(DBG_ERROR, "input arguments error\n"); + return -DFD_RV_INVALID_VALUE; + } + + rv = dfd_ko_cfg_get_index_by_strval(&dfd_lib_cfg_fan_name_conv_dir_lst, fan_name, &index1, &index2); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "get fan direction by name[%s] fail\n", fan_name); + return -DFD_RV_NODE_FAIL; + } + + *fan_direction = index1; + + return 0; +} + +int dfd_ko_cfg_get_power_type_by_name(char *power_name, int *power_type) +{ + int rv; + int index1, index2; + + if ((power_name == NULL) || (power_type == NULL)){ + DBG_DEBUG(DBG_ERROR, "input arguments error\n"); + return -1; + } + + rv = dfd_ko_cfg_get_index_by_strval(&dfd_lib_cfg_power_name_conv_lst, power_name, &index1, &index2); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "get power type by name[%s] fail\n", power_name); + return -1; + } + + *power_type = index1; + + return 0; +} + +static int dfd_ko_cfg_get_value_from_char(char *value_str, int32_t *value, int line_num) +{ + int value_tmp = 0; + + if (strlen(value_str) == 0) { + DBG_DEBUG(DBG_WARN, "line%d: value str is empty\n", line_num); + *value = DFD_CFG_EMPTY_VALUE; + return 0; + } + + if ((strlen(value_str) > 2) && (value_str[0] == '0') + && (value_str[1] == 'x' || value_str[1] == 'X')) { + value_tmp = (int32_t)simple_strtol(value_str, NULL, 16); + } else { + value_tmp = (int32_t)simple_strtol(value_str, NULL, 10); + } + + *value = value_tmp; + return 0; +} + +static int dfd_ko_cfg_analyse_index(char *index_str, int *index1, int *index2, int line_num) +{ + int rv; + char *index1_begin_char, *index2_begin_char; + + if (index_str[0] != '_') { + DBG_DEBUG(DBG_ERROR, "line%d: no '-' between name and index1\n", line_num); + return -1; + } + + index1_begin_char = index_str; + rv = dfd_ko_cfg_get_value_from_char(++index1_begin_char, index1, line_num); + if (rv < 0) { + return -1; + } + + if (index2 == NULL) { + return 0; + } + + index2_begin_char = strchr(index1_begin_char, '_'); + if (index2_begin_char == NULL) { + DBG_DEBUG(DBG_ERROR, "line%d: no '-' between index1 and index2\n", line_num); + return -1; + } else { + rv = dfd_ko_cfg_get_value_from_char(++index2_begin_char, index2, line_num); + if (rv < 0) { + return -1; + } + } + + return 0; +} + +static int dfd_ko_cfg_check_array_index(index_range_t *index_range, int *index1, int *index2, + int line_num) +{ + if ((*index1 < 0) || (*index1 > index_range->index1_max)) { + DBG_DEBUG(DBG_ERROR, "line%d: index1[%d] invalid, max=%d\n", line_num, *index1, + index_range->index1_max); + return -1; + } + + if (index2 == NULL) { + return 0; + } + + if ((*index2 < 0) || (*index2 > index_range->index2_max)) { + DBG_DEBUG(DBG_ERROR, "line%d: index2[%d] invalid, max=%d\n", line_num, *index2, + index_range->index2_max); + return -1; + } + + return 0; +} + +static int dfd_ko_cfg_get_index(char *index_str, index_range_t *index_range, int *index1, + int *index2, int line_num) +{ + int rv; + + if (index_range->index2_max == INDEX_NOT_EXIST) { + index2 = NULL; + } + + rv = dfd_ko_cfg_analyse_index(index_str, index1, index2, line_num); + if (rv < 0) { + return -1; + } + + rv = dfd_ko_cfg_check_array_index(index_range, index1, index2, line_num); + if (rv < 0) { + return -1; + } + + return 0; +} + +static int dfd_ko_cfg_add_int_item(int key, int value, int line_num) +{ + int rv; + int *int_cfg; + + int_cfg = lnode_find_node(&dfd_ko_cfg_list_root, key); + if (int_cfg == NULL) { + int_cfg = (int *)kmalloc(sizeof(int), GFP_KERNEL); + if (int_cfg == NULL) { + DBG_DEBUG(DBG_ERROR, "line%d: kmalloc int fail\n", line_num); + return -1; + } + + *int_cfg = value; + rv = lnode_insert_node(&dfd_ko_cfg_list_root, key, int_cfg); + if (rv == 0) { + DBG_DEBUG(DBG_VERBOSE, "line%d: add int item[%d] success, key=0x%08x\n", + line_num, value, key); + } else { + kfree(int_cfg); + int_cfg = NULL; + DBG_DEBUG(DBG_ERROR, "line%d: add int item[%d] fail, key=0x%08x rv=%d \n", + line_num, value, key, rv); + return -1; + } + } else { + DBG_DEBUG(DBG_WARN, "line%d: replace int item[%d->%d], key=0x%08x\n", + line_num, *int_cfg, value, key); + *int_cfg = value; + } + + return 0; +} + +static int dfd_ko_cfg_analyse_int_item(dfd_cfg_item_id_t cfg_item_id, char *arg_name, + char *arg_value, char *cfg_pre, index_range_t *index_range, int line_num) +{ + int rv; + int index1 = 0, index2 = 0; + int value, key; + char *arg_name_tmp; + + if (index_range->index1_max != INDEX_NOT_EXIST) { + arg_name_tmp = arg_name + strlen(cfg_pre); + rv = dfd_ko_cfg_get_index(arg_name_tmp, index_range, &index1, &index2, line_num); + if (rv < 0) { + return -1; + } + } + + rv = dfd_ko_cfg_get_value_from_char(arg_value, &value, line_num); + if (rv < 0) { + return -1; + } + + key = DFD_CFG_KEY(cfg_item_id, index1, index2); + rv = dfd_ko_cfg_add_int_item(key, value, line_num); + if (rv < 0) { + return -1; + } + + dfd_ko_cfg_convert_list_build(cfg_item_id, value, NULL, index1, index2); + return 0; +} + +static int dfd_ko_cfg_add_str_item(int key, char *str, int line_num) +{ + int rv; + char *str_cfg; + + str_cfg = lnode_find_node(&dfd_ko_cfg_list_root, key); + if (str_cfg == NULL) { + str_cfg = (char *)kmalloc(DFD_CFG_STR_MAX_LEN, GFP_KERNEL); + if (str_cfg == NULL) { + DBG_DEBUG(DBG_ERROR, "line%d: kmalloc str[%lu] fail\n", line_num, strlen(str)); + return -1; + } + memset(str_cfg, 0, DFD_CFG_STR_MAX_LEN); + strncpy(str_cfg, str, DFD_CFG_STR_MAX_LEN - 1); + + rv = lnode_insert_node(&dfd_ko_cfg_list_root, key, str_cfg); + if (rv == 0) { + DBG_DEBUG(DBG_VERBOSE, "line%d: add string item[%s] success, key=0x%08x\n", + line_num, str_cfg, key); + } else { + kfree(str_cfg); + str_cfg = NULL; + DBG_DEBUG(DBG_ERROR, "line%d: add string item[%s] fail, key=0x%08x rv=%d \n", + line_num, str_cfg, key, rv); + return -1; + } + } else { + DBG_DEBUG(DBG_WARN, "line%d: replace string item[%s->%s], key=0x%08x\n", + line_num, str_cfg, str, key); + memset(str_cfg, 0, DFD_CFG_STR_MAX_LEN); + strncpy(str_cfg, str, DFD_CFG_STR_MAX_LEN - 1); + } + + return 0; +} + +static int dfd_ko_cfg_analyse_str_item(dfd_cfg_item_id_t cfg_item_id, char *arg_name, + char *arg_value, char *cfg_pre, index_range_t *index_range, int line_num) +{ + int rv; + int index1 = 0, index2 = 0; + int btree_key; + char *arg_name_tmp; + + if (index_range->index1_max != INDEX_NOT_EXIST) { + arg_name_tmp = arg_name + strlen(cfg_pre); + rv = dfd_ko_cfg_get_index(arg_name_tmp, index_range, &index1, &index2, line_num); + if (rv < 0) { + return -1; + } + } + + if (strlen(arg_value) >= DFD_CFG_STR_MAX_LEN) { + DBG_DEBUG(DBG_ERROR, "line%d: string item[%s] is too long \n", line_num, arg_value); + return -1; + } + + btree_key = DFD_CFG_KEY(cfg_item_id, index1, index2); + rv = dfd_ko_cfg_add_str_item(btree_key, arg_value, line_num); + if (rv < 0) { + return -1; + } + + dfd_ko_cfg_convert_list_build(cfg_item_id, 0, arg_value, index1, index2); + return 0; +} + +static int dfd_ko_cfg_get_i2c_dev_member(char *member_str, dfd_i2c_dev_mem_t *member, int line_num) +{ + dfd_i2c_dev_mem_t mem_index; + + for (mem_index = DFD_I2C_DEV_MEM_BUS; mem_index < DFD_I2C_DEV_MEM_END; mem_index++) { + if (memcmp(member_str, g_dfd_i2c_dev_mem_str[mem_index], + strlen(g_dfd_i2c_dev_mem_str[mem_index])) == 0) { + *member = mem_index; + return 0; + } + } + + DBG_DEBUG(DBG_ERROR, "line%d: i2c dev member[%s] invalid\n", line_num, member_str); + return -1; +} + +static void dfd_ko_cfg_set_i2c_dev_mem_value(dfd_i2c_dev_t *i2c_dev, dfd_i2c_dev_mem_t member, + int value) +{ + switch (member) { + case DFD_I2C_DEV_MEM_BUS: + i2c_dev->bus = value; + break; + case DFD_I2C_DEV_MEM_ADDR: + i2c_dev->addr = value; + break; + default: + break; + } +} + +static int dfd_ko_cfg_add_i2c_dev_item(int key, dfd_i2c_dev_mem_t member, int value, int line_num) +{ + int rv; + dfd_i2c_dev_t *i2c_dev_cfg; + + i2c_dev_cfg = lnode_find_node(&dfd_ko_cfg_list_root, key); + if (i2c_dev_cfg == NULL) { + i2c_dev_cfg = (dfd_i2c_dev_t *)kmalloc(sizeof(dfd_i2c_dev_t), GFP_KERNEL); + if (i2c_dev_cfg == NULL) { + DBG_DEBUG(DBG_ERROR, "line%d: kmalloc i2c_dev fail\n", line_num); + return -1; + } + memset(i2c_dev_cfg, 0, sizeof(dfd_i2c_dev_t)); + + dfd_ko_cfg_set_i2c_dev_mem_value(i2c_dev_cfg, member, value); + rv = lnode_insert_node(&dfd_ko_cfg_list_root, key, i2c_dev_cfg); + if (rv == 0) { + DBG_DEBUG(DBG_VERBOSE, "line%d: add i2c_dev item[%s=%d] success, key=0x%08x\n", + line_num, g_dfd_i2c_dev_mem_str[member], value, key); + } else { + kfree(i2c_dev_cfg); + i2c_dev_cfg = NULL; + DBG_DEBUG(DBG_ERROR, "line%d: add i2c_dev item[%s=%d] fail, key=0x%08x rv=%d\n", + line_num, g_dfd_i2c_dev_mem_str[member], value, key, rv); + return -1; + } + } else { + DBG_DEBUG(DBG_VERBOSE, "line%d: replace i2c_dev item[%s=%d], key=0x%08x\n", line_num, + g_dfd_i2c_dev_mem_str[member], value, key); + dfd_ko_cfg_set_i2c_dev_mem_value(i2c_dev_cfg, member, value); + } + + return 0; +} + +static int dfd_ko_cfg_analyse_i2c_dev_item(dfd_cfg_item_id_t cfg_item_id, char *arg_name, + char *arg_value, char *cfg_pre, index_range_t *index_range, int line_num) +{ + int rv; + int index1 = 0, index2 = 0; + int value, key; + char *arg_name_tmp; + dfd_i2c_dev_mem_t member; + + arg_name_tmp = arg_name + strlen(cfg_pre); + rv = dfd_ko_cfg_get_i2c_dev_member(arg_name_tmp, &member, line_num); + if (rv < 0) { + return -1; + } + + if (index_range->index1_max != INDEX_NOT_EXIST) { + arg_name_tmp += strlen(g_dfd_i2c_dev_mem_str[member]); + rv = dfd_ko_cfg_get_index(arg_name_tmp, index_range, &index1, &index2, line_num); + if (rv < 0) { + return -1; + } + } + + rv = dfd_ko_cfg_get_value_from_char(arg_value, &value, line_num); + if (rv < 0) { + return -1; + } + + key = DFD_CFG_KEY(cfg_item_id, index1, index2); + rv = dfd_ko_cfg_add_i2c_dev_item(key, member, value, line_num); + if (rv < 0) { + return -1; + } + + return 0; +} + +static int dfd_ko_cfg_get_enum_value_by_str(char *enum_val_str[], int enum_val_end, char *buf) +{ + int i; + int enum_val; + + enum_val = DFD_CFG_INVALID_VALUE; + for (i = 0; i < enum_val_end; i++) { + if (memcmp(buf, enum_val_str[i], strlen(enum_val_str[i])) == 0) { + enum_val = i; + break; + } + } + + return enum_val; +} + +static int dfd_ko_cfg_get_info_ctrl_member(char *member_str, info_ctrl_mem_t *member, int line_num) +{ + info_ctrl_mem_t mem_index; + + for (mem_index = INFO_CTRL_MEM_MODE; mem_index < INFO_CTRL_MEM_END; mem_index++) { + if (memcmp(member_str, g_info_ctrl_mem_str[mem_index], + strlen(g_info_ctrl_mem_str[mem_index])) == 0) { + *member = mem_index; + return 0; + } + } + + DBG_DEBUG(DBG_ERROR, "line%d: info ctrl member[%s] invalid\n", line_num, member_str); + return -1; +} + +static void dfd_ko_cfg_set_info_ctrl_mem_value(info_ctrl_t *info_ctrl, info_ctrl_mem_t member, + char *buf_val, int line_num) +{ + switch (member) { + case INFO_CTRL_MEM_MODE: + info_ctrl->mode = dfd_ko_cfg_get_enum_value_by_str(g_info_ctrl_mode_str, + INFO_CTRL_MODE_END, buf_val); + break; + case INFO_CTRL_MEM_INT_CONS: + dfd_ko_cfg_get_value_from_char(buf_val, &(info_ctrl->int_cons), line_num); + break; + case INFO_CTRL_MEM_SRC: + info_ctrl->src = dfd_ko_cfg_get_enum_value_by_str(g_info_src_str, INFO_SRC_END, buf_val); + break; + case INFO_CTRL_MEM_FRMT: + info_ctrl->frmt = dfd_ko_cfg_get_enum_value_by_str(g_info_frmt_str, INFO_FRMT_END, buf_val); + break; + case INFO_CTRL_MEM_POLA: + info_ctrl->pola = dfd_ko_cfg_get_enum_value_by_str(g_info_pola_str, INFO_POLA_END, buf_val); + break; + case INFO_CTRL_MEM_FPATH: + memset(info_ctrl->fpath, 0, sizeof(info_ctrl->fpath)); + strncpy(info_ctrl->fpath, buf_val, sizeof(info_ctrl->fpath) - 1); + break; + case INFO_CTRL_MEM_ADDR: + dfd_ko_cfg_get_value_from_char(buf_val, &(info_ctrl->addr), line_num); + break; + case INFO_CTRL_MEM_LEN: + dfd_ko_cfg_get_value_from_char(buf_val, &(info_ctrl->len), line_num); + break; + case INFO_CTRL_MEM_BIT_OFFSET: + dfd_ko_cfg_get_value_from_char(buf_val, &(info_ctrl->bit_offset), line_num); + break; + case INFO_CTRL_MEM_STR_CONS: + memset(info_ctrl->str_cons, 0, sizeof(info_ctrl->str_cons)); + strncpy(info_ctrl->str_cons, buf_val, sizeof(info_ctrl->str_cons) - 1); + break; + case INFO_CTRL_MEM_INT_EXTRA1: + dfd_ko_cfg_get_value_from_char(buf_val, &(info_ctrl->int_extra1), line_num); + break; + case INFO_CTRL_MEM_INT_EXTRA2: + dfd_ko_cfg_get_value_from_char(buf_val, &(info_ctrl->int_extra2), line_num); + break; + default: + break; + } +} + +static int dfd_ko_cfg_add_info_ctrl_item(int key, info_ctrl_mem_t member, char *buf_val, + int line_num) +{ + int rv; + info_ctrl_t *info_ctrl_cfg; + + info_ctrl_cfg = lnode_find_node(&dfd_ko_cfg_list_root, key); + if (info_ctrl_cfg == NULL) { + info_ctrl_cfg = (info_ctrl_t *)kmalloc(sizeof(info_ctrl_t), GFP_KERNEL); + if (info_ctrl_cfg == NULL) { + DBG_DEBUG(DBG_ERROR, "line%d: kmalloc info_ctrl fail\n", line_num); + return -1; + } + memset(info_ctrl_cfg, 0, sizeof(info_ctrl_t)); + + dfd_ko_cfg_set_info_ctrl_mem_value(info_ctrl_cfg, member, buf_val, line_num); + rv = lnode_insert_node(&dfd_ko_cfg_list_root, key, info_ctrl_cfg); + if (rv == 0) { + DBG_DEBUG(DBG_VERBOSE, "line%d: add info_ctrl item[%s=%s] success, key=0x%08x\n", + line_num, g_info_ctrl_mem_str[member], buf_val, key); + } else { + kfree(info_ctrl_cfg); + info_ctrl_cfg = NULL; + DBG_DEBUG(DBG_ERROR, "line%d: add info_ctrl item[%s=%s] fail, key=0x%08x rv=%d\n", + line_num, g_info_ctrl_mem_str[member], buf_val, key, rv); + return -1; + } + } else { + DBG_DEBUG(DBG_VERBOSE, "line%d: replace info_ctrl item[%s=%s], key=0x%08x\n", + line_num, g_info_ctrl_mem_str[member], buf_val, key); + dfd_ko_cfg_set_info_ctrl_mem_value(info_ctrl_cfg, member, buf_val, line_num); + } + + return 0; +} + +static int dfd_ko_cfg_analyse_info_ctrl_item(dfd_cfg_item_id_t cfg_item_id, char *arg_name, + char *arg_value, char *cfg_pre, index_range_t *index_range, int line_num) +{ + int rv; + int index1 = 0, index2 = 0; + int key; + char *arg_name_tmp; + info_ctrl_mem_t member; + + arg_name_tmp = arg_name + strlen(cfg_pre); + rv = dfd_ko_cfg_get_info_ctrl_member(arg_name_tmp, &member, line_num); + if (rv < 0) { + return -1; + } + + if (index_range->index1_max != INDEX_NOT_EXIST) { + arg_name_tmp += strlen(g_info_ctrl_mem_str[member]); + rv = dfd_ko_cfg_get_index(arg_name_tmp, index_range, &index1, &index2, line_num); + if (rv < 0) { + return -1; + } + } + + key = DFD_CFG_KEY(cfg_item_id, index1, index2); + rv = dfd_ko_cfg_add_info_ctrl_item(key, member, arg_value, line_num); + if (rv < 0) { + return -1; + } + + return 0; +} + +static int dfd_ko_cfg_analyse_config(char *arg_name, char*arg_value, int line_num) +{ + int i, rv = 0; + int cfg_item_num; + + cfg_item_num = sizeof(dfd_cfg_item_name) / sizeof(dfd_cfg_item_name[0]); + for (i = 0; i < cfg_item_num; i++) { + if (memcmp(arg_name, dfd_cfg_item_name[i], strlen(dfd_cfg_item_name[i])) == 0){ + if (DFD_CFG_ITEM_IS_INT(i)) { + rv = dfd_ko_cfg_analyse_int_item(i, arg_name, arg_value, dfd_cfg_item_name[i], + &(dfd_cfg_item_index_range[i]), line_num); + } else if (DFD_CFG_ITEM_IS_STRING(i)) { + rv = dfd_ko_cfg_analyse_str_item(i, arg_name, arg_value, dfd_cfg_item_name[i], + &(dfd_cfg_item_index_range[i]), line_num); + } else if (DFD_CFG_ITEM_IS_I2C_DEV(i)) { + rv = dfd_ko_cfg_analyse_i2c_dev_item(i, arg_name, arg_value, dfd_cfg_item_name[i], + &(dfd_cfg_item_index_range[i]), line_num); + } else if (DFD_CFG_ITEM_IS_INFO_CTRL(i)) { + rv = dfd_ko_cfg_analyse_info_ctrl_item(i, arg_name, arg_value, dfd_cfg_item_name[i], + &(dfd_cfg_item_index_range[i]), line_num); + } else { + rv = -1; + } + break; + } + } + + return rv; +} + +static int dfd_ko_cfg_cut_config_line(char *config_line, char *arg_name, char *arg_value) +{ + int i, j = 0, k = 0; + int len, name_value_flag = 0; + + len = strlen(config_line); + for (i = 0; i < len; i++) { + if (config_line[i] == '=') { + name_value_flag = 1; + continue; + } + + if (name_value_flag == 0) { + arg_name[j++] = config_line[i]; + } else { + arg_value[k++] = config_line[i]; + } + } + + if (name_value_flag == 0) { + return -1; + } else { + return 0; + } +} + +static int dfd_ko_cfg_analyse_config_line(char *config_line, int line_num) +{ + int rv; + char arg_name[DFD_CFG_NAME_MAX_LEN] = {0}; + char arg_value[DFD_CFG_VALUE_MAX_LEN] = {0}; + + dfd_ko_cfg_del_space_lf_cr(config_line); + + if (strlen(config_line) == 0) { + DBG_DEBUG(DBG_VERBOSE, "line%d: space line\n", line_num); + return 0; + } + + if (config_line[0] == '#') { + DBG_DEBUG(DBG_VERBOSE, "line%d: comment line[%s]\n", line_num, config_line); + return 0; + } + + rv = dfd_ko_cfg_cut_config_line(config_line, arg_name, arg_value); + if (rv < 0) { + DBG_DEBUG(DBG_VERBOSE, "line%d: [%s]no '=' between name and value\n", + line_num, config_line); + return -1; + } + + DBG_DEBUG(DBG_VERBOSE, "line%d: config_line[%s] name[%s] value[%s]\n", + line_num, config_line, arg_name, arg_value); + return dfd_ko_cfg_analyse_config(arg_name, arg_value, line_num); +} + +static int dfd_ko_cfg_analyse_config_file(char *fpath) +{ + int rv; + int line_num = 1; + kfile_ctrl_t kfile_ctrl; + char config_line[DFD_CFG_CMDLINE_MAX_LEN] = {0}; + + rv = kfile_open(fpath, &kfile_ctrl); + if (rv != KFILE_RV_OK) { + DBG_DEBUG(DBG_ERROR, "open config file[%s] fail, rv=%d\n", fpath, rv); + return -1; + } + + while(kfile_gets(config_line, sizeof(config_line), &kfile_ctrl) > 0){ + rv = dfd_ko_cfg_analyse_config_line(config_line, line_num++); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "!!!!file[%s] config line[%d %s] analyse fail\n", + fpath, line_num - 1, config_line); + break; + } + + (void)memset(config_line, 0, sizeof(config_line)); + + } + kfile_close(&kfile_ctrl); + + return rv; +} + +void *dfd_ko_cfg_get_item(int key) +{ + return lnode_find_node(&dfd_ko_cfg_list_root, key); +} + +static void dfd_ko_cfg_print_item(int key, const void *cfg) +{ + int item_id; + dfd_i2c_dev_t *i2c_dev; + info_ctrl_t *info_ctrl; + + if (cfg == NULL) { + DBG_DEBUG(DBG_ERROR, "input arguments error\n"); + return; + } + printk(KERN_INFO "**************************\n"); + printk(KERN_INFO "key=0x%08x\n", key); + + item_id = DFD_CFG_ITEM_ID(key); + if (DFD_CFG_ITEM_IS_INT(item_id)) { + printk(KERN_INFO "int=%d\n", *((int *)cfg)); + } else if (DFD_CFG_ITEM_IS_I2C_DEV(item_id)) { + i2c_dev = (dfd_i2c_dev_t *)cfg; + printk(KERN_INFO ".bus=0x%02x\n", i2c_dev->bus); + printk(KERN_INFO ".addr=0x%02x\n", i2c_dev->addr); + } else if (DFD_CFG_ITEM_IS_INFO_CTRL(item_id)) { + info_ctrl = (info_ctrl_t *)cfg; + printk(KERN_INFO ".mode=%s\n", g_info_ctrl_mode_str[info_ctrl->mode]); + printk(KERN_INFO ".int_cons=%d\n", info_ctrl->int_cons); + printk(KERN_INFO ".src=%s\n", g_info_src_str[info_ctrl->src]); + printk(KERN_INFO ".frmt=%s\n", g_info_frmt_str[info_ctrl->frmt]); + printk(KERN_INFO ".pola=%s\n", g_info_pola_str[info_ctrl->pola]); + printk(KERN_INFO ".fpath=%s\n", info_ctrl->fpath); + printk(KERN_INFO ".addr=0x%02x\n", info_ctrl->addr); + printk(KERN_INFO ".len=%d\n", info_ctrl->len); + printk(KERN_INFO ".bit_offset=%d\n", info_ctrl->bit_offset); + } else { + printk(KERN_INFO "item[%d] error!\n", item_id); + } +} + +void dfd_ko_cfg_show_item(int key) +{ + void *cfg; + + cfg = lnode_find_node(&dfd_ko_cfg_list_root, key); + if (cfg == 0) { + printk(KERN_INFO "item[0x%08x] not exist\n", key); + return; + } + + dfd_ko_cfg_print_item(key, cfg); +} + +static int dfd_get_my_dev_type_by_file(void) +{ + struct file *fp; + loff_t pos; + int card_type; + char buf[DFD_PID_BUF_LEN]; + int ret; + + fp= filp_open(DFD_PUB_CARDTYPE_FILE, O_RDONLY, 0); + if (IS_ERR(fp)) { + DBG_DEBUG(DBG_VERBOSE, "open file fail!\n"); + return -1; + } + + memset(buf, 0, DFD_PID_BUF_LEN); + pos = 0; + ret = kernel_read(fp, buf, DFD_PRODUCT_ID_LENGTH + 1, &pos); + if (ret < 0) { + DBG_DEBUG(DBG_VERBOSE, "kernel_read failed, path=%s, addr=0, size=%d, ret=%d\n", + DFD_PUB_CARDTYPE_FILE, DFD_PRODUCT_ID_LENGTH + 1, ret); + filp_close(fp, NULL); + return -1; + } + + card_type = simple_strtoul(buf, NULL, 10); + DBG_DEBUG(DBG_VERBOSE, "card_type 0x%x.\n", card_type); + + filp_close(fp, NULL); + return card_type; +} + +static int drv_get_my_dev_type(void) +{ + static int type = -1; + + if (type > 0) { + return type; + } + type = dfd_get_my_dev_type_by_file(); + DBG_DEBUG(DBG_VERBOSE, "ko board type %d\n", type); + return type; +} + +static int dfd_ko_cfg_init(void) +{ + int rv; + int card_type; + char file_name[32] = {0}; + char fpath[128] = {0}; + kfile_ctrl_t kfile_ctrl; + + rv = lnode_init_root(&dfd_ko_cfg_list_root); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "init list root fail, rv=%d\n", rv); + return -1; + } + + card_type = drv_get_my_dev_type(); + if (card_type < 0) { + DBG_DEBUG(DBG_ERROR, "get my dev type fail, rv=%d\n", card_type); + return -1; + } + + snprintf(fpath, sizeof(fpath), "%s0x%x", DFD_KO_FILE_NAME_DIR, card_type); + rv = kfile_open(fpath, &kfile_ctrl); + if (rv != KFILE_RV_OK) { + DBG_DEBUG(DBG_ERROR, "open config file[%s] fail, rv=%d\n", fpath, rv); + return -1; + } + + while (kfile_gets(file_name, sizeof(file_name), &kfile_ctrl) > 0) { + dfd_ko_cfg_del_space_lf_cr(file_name); + snprintf(fpath, sizeof(fpath), "%s%s.cfg", DFD_KO_CFG_FILE_DIR, file_name); + DBG_DEBUG(DBG_VERBOSE, ">>>>start parsing config file[%s]\n", fpath); + rv = dfd_ko_cfg_analyse_config_file(fpath); + if (rv < 0) { + break; + } + } + kfile_close(&kfile_ctrl); + return 0; +} + +int32_t dfd_dev_cfg_init(void) +{ + return dfd_ko_cfg_init(); +} + +void dfd_dev_cfg_exit(void) +{ + lnode_free_list(&dfd_ko_cfg_list_root); + val_convert_node_lst_free(&dfd_lib_cfg_led_status_decode_conv_lst); + val_convert_node_lst_free(&dfd_lib_cfg_fan_name_conv_dir_lst); + val_convert_node_lst_free(&dfd_lib_cfg_power_name_conv_lst); + return; +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_cfg_adapter.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_cfg_adapter.c new file mode 100644 index 000000000000..32a44ad7a1f6 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_cfg_adapter.c @@ -0,0 +1,415 @@ +/* + * Copyright(C) 2022 Ruijie Network. All rights reserved. + */ +/* + * dfd_cfg_adapter.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "rg_module.h" +#include "dfd_cfg_file.h" +#include "dfd_cfg.h" +#include "dfd_cfg_adapter.h" + +char *g_dfd_i2c_dev_mem_str[DFD_I2C_DEV_MEM_END] = { + ".bus", + ".addr", +}; + +static dfd_i2c_dev_t* dfd_ko_get_cpld_i2c_dev(int sub_slot, int cpld_id) +{ + int key; + dfd_i2c_dev_t *i2c_dev; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_CPLD_I2C_DEV, sub_slot, cpld_id); + i2c_dev = dfd_ko_cfg_get_item(key); + if (i2c_dev == NULL) { + DBG_DEBUG(DBG_ERROR, "get cpld[%d] i2c dev config fail, key=0x%08x\n", cpld_id, key); + return NULL; + } + + return i2c_dev; +} + +static int32_t dfd_ko_i2c_smbus_transfer(int read_write, int bus, int addr, int offset, uint8_t *buf, uint32_t size) +{ + int rv; + struct i2c_adapter *i2c_adap; + union i2c_smbus_data data; + + i2c_adap = i2c_get_adapter(bus); + if (i2c_adap == NULL) { + DBG_DEBUG(DBG_ERROR, "get i2c bus[%d] adapter fail\n", bus); + return -DFD_RV_DEV_FAIL; + } + + if (read_write == I2C_SMBUS_WRITE) { + data.byte = *buf; + } else { + data.byte = 0; + } + rv = i2c_smbus_xfer(i2c_adap, addr, 0, read_write, offset, I2C_SMBUS_BYTE_DATA, &data); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "i2c dev[bus=%d addr=0x%x offset=0x%x size=%d rw=%d] transfer fail, rv=%d\n", + bus, addr, offset, size, read_write, rv); + rv = -DFD_RV_DEV_FAIL; + } else { + DBG_DEBUG(DBG_VERBOSE, "i2c dev[bus=%d addr=0x%x offset=0x%x size=%d rw=%d] transfer success\n", + bus, addr, offset, size, read_write); + rv = DFD_RV_OK; + } + + if (read_write == I2C_SMBUS_READ) { + if (rv == DFD_RV_OK) { + *buf = data.byte; + } else { + *buf = 0; + } + } + + i2c_put_adapter(i2c_adap); + return rv; +} + +static int32_t dfd_ko_i2c_read_data(int bus, int addr, int offset, uint8_t *buf, uint32_t size) +{ + int i, rv; + for (i = 0; i < DFD_KO_CPLD_I2C_RETRY_TIMES; i++) { + rv = dfd_ko_i2c_smbus_transfer(I2C_SMBUS_READ, bus, addr, offset, buf, size); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "[%d]cpld read[offset=0x%x] fail, rv %d\n", i, addr, rv); + msleep(DFD_KO_CPLD_I2C_RETRY_SLEEP); + } else { + DBG_DEBUG(DBG_VERBOSE, "[%d]cpld read[offset=0x%x] success, value=0x%x\n", + i, addr, *buf); + break; + } + } + return rv; +} + +static int32_t dfd_ko_i2c_write_data(int bus, int addr, int offset, uint8_t data, uint32_t size) +{ + int i, rv; + for (i = 0; i < DFD_KO_CPLD_I2C_RETRY_TIMES; i++) { + rv = dfd_ko_i2c_smbus_transfer(I2C_SMBUS_WRITE, bus, addr, offset, &data, size); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "[%d]cpld write[offset=0x%x] fail, rv=%d\n", i, addr, rv); + msleep(DFD_KO_CPLD_I2C_RETRY_SLEEP); + } else { + DBG_DEBUG(DBG_VERBOSE, "[%d]cpld write[offset=0x%x, data=%d] success\n", i, addr, data); + break; + } + } + + return rv; +} + +static int32_t dfd_ko_cpld_i2c_read(int32_t addr, uint8_t *buf) +{ + int rv; + int sub_slot, cpld_id, cpld_addr; + dfd_i2c_dev_t *i2c_dev; + + if (buf == NULL) { + DBG_DEBUG(DBG_ERROR, "input arguments error\n"); + return -DFD_RV_INDEX_INVALID; + } + + sub_slot = DFD_KO_CPLD_GET_SLOT(addr); + cpld_id = DFD_KO_CPLD_GET_ID(addr); + cpld_addr = DFD_KO_CPLD_GET_INDEX(addr); + + i2c_dev = dfd_ko_get_cpld_i2c_dev(sub_slot, cpld_id); + if (i2c_dev == NULL) { + return -DFD_RV_DEV_NOTSUPPORT; + } + rv = dfd_ko_i2c_read_data(i2c_dev->bus, i2c_dev->addr, cpld_addr, buf, sizeof(uint8_t)); + + return rv; +} + +static int32_t dfd_ko_cpld_i2c_write(int32_t addr, uint8_t data) +{ + int rv; + int sub_slot, cpld_id, cpld_addr; + dfd_i2c_dev_t *i2c_dev; + + sub_slot = DFD_KO_CPLD_GET_SLOT(addr); + cpld_id = DFD_KO_CPLD_GET_ID(addr); + cpld_addr = DFD_KO_CPLD_GET_INDEX(addr); + + i2c_dev = dfd_ko_get_cpld_i2c_dev(sub_slot, cpld_id); + if (i2c_dev == NULL) { + return -DFD_RV_DEV_NOTSUPPORT; + } + + rv = dfd_ko_i2c_write_data(i2c_dev->bus, i2c_dev->addr, cpld_addr, data, sizeof(uint8_t)); + + return rv; +} + +static int32_t dfd_ko_cpld_io_read(int32_t addr, uint8_t *buf) +{ + int cpld_id, sub_slot, offset; + int key; + int *tmp; + uint16_t io_port; + + sub_slot = DFD_KO_CPLD_GET_SLOT(addr); + cpld_id = DFD_KO_CPLD_GET_ID(addr); + offset = DFD_KO_CPLD_GET_INDEX(addr); + + key = DFD_CFG_KEY(DFD_CFG_ITEM_CPLD_LPC_DEV, sub_slot, cpld_id); + tmp = dfd_ko_cfg_get_item(key); + if (tmp == NULL) { + DBG_DEBUG(DBG_ERROR,"get cpld io base config fail, key=0x%08x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + + io_port = (u16)(*tmp) + offset; + *buf = inb(io_port); + DBG_DEBUG(DBG_VERBOSE, "read cpld io port addr 0x%x, data 0x%x\n", io_port, *buf); + + return DFD_RV_OK; + +} + +static int32_t dfd_ko_cpld_io_write(int32_t addr, uint8_t data) +{ + int cpld_id, sub_slot, offset; + int key; + int *tmp; + uint16_t io_port; + + sub_slot = DFD_KO_CPLD_GET_SLOT(addr); + cpld_id = DFD_KO_CPLD_GET_ID(addr); + offset = DFD_KO_CPLD_GET_INDEX(addr); + + key = DFD_CFG_KEY(DFD_CFG_ITEM_CPLD_LPC_DEV, sub_slot, cpld_id); + tmp = dfd_ko_cfg_get_item(key); + if (tmp == NULL) { + DBG_DEBUG(DBG_ERROR, "get cpld io base config fail, key=0x%08x\n", key); + return -1; + } + + io_port = (u16)(*tmp) + offset; + DBG_DEBUG(DBG_VERBOSE, "write cpld io port addr 0x%x, data 0x%x\n", io_port, data); + outb(data, (u16)io_port); + + return DFD_RV_OK; +} + +static int dfd_cfg_get_cpld_mode(int sub_slot, int cpld_id, int *mode) +{ + int key; + char *name; + + if (mode == NULL) { + DBG_DEBUG(DBG_ERROR, "input arguments error\n"); + return -DFD_RV_TYPE_ERR; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_CPLD_MODE, sub_slot, cpld_id); + name = dfd_ko_cfg_get_item(key); + if (name == NULL) { + DBG_DEBUG(DBG_ERROR, "get cpld[%d] mode info ctrl fail, key=0x%08x\n", cpld_id, key); + return -DFD_RV_DEV_NOTSUPPORT; + } + + DBG_DEBUG(DBG_VERBOSE, "cpld_id %d mode_name %s.\n", cpld_id, name); + if (!strncmp(name, DFD_KO_CPLD_MODE_I2C_STRING, strlen(DFD_KO_CPLD_MODE_I2C_STRING))) { + *mode = DFD_CPLD_MODE_I2C; + } else if (!strncmp(name, DFD_KO_CPLD_MODE_LPC_STRING, strlen(DFD_KO_CPLD_MODE_LPC_STRING))) { + *mode = DFD_CPLD_MODE_LPC; + } else { + *mode = DFD_CPLD_MODE_I2C; + } + + DBG_DEBUG(DBG_VERBOSE, "cpld_id %d mode %d.\n", cpld_id, *mode); + return 0; +} + +int32_t dfd_ko_cpld_read(int32_t addr, uint8_t *buf) +{ + int ret; + int sub_slot, cpld_id; + int cpld_mode; + + sub_slot = DFD_KO_CPLD_GET_SLOT(addr); + cpld_id = DFD_KO_CPLD_GET_ID(addr); + ret = dfd_cfg_get_cpld_mode(sub_slot, cpld_id, &cpld_mode); + if (ret) { + DBG_DEBUG(DBG_WARN, "drv_get_cpld_mode sub_slot %d cpldid %d faile, set default i2c mode.\n", sub_slot, cpld_id); + cpld_mode = DFD_CPLD_MODE_I2C; + } + + if (cpld_mode == DFD_CPLD_MODE_I2C) { + ret = dfd_ko_cpld_i2c_read(addr, buf); + } else if (cpld_mode == DFD_CPLD_MODE_LPC) { + ret = dfd_ko_cpld_io_read(addr, buf); + } else { + DBG_DEBUG(DBG_ERROR, "cpld_mode %d invalid.\n", cpld_mode); + ret = -DFD_RV_DEV_NOTSUPPORT; + } + + DBG_DEBUG(DBG_VERBOSE, "addr 0x%x val 0x%x ret %d\n", addr, *buf, ret); + return ret; +} + +int32_t dfd_ko_cpld_write(int32_t addr, uint8_t val) +{ + int ret; + int sub_slot, cpld_id, cpld_mode; + + sub_slot = DFD_KO_CPLD_GET_SLOT(addr); + cpld_id = DFD_KO_CPLD_GET_ID(addr); + + ret = dfd_cfg_get_cpld_mode(sub_slot, cpld_id, &cpld_mode); + if (ret) { + DBG_DEBUG(DBG_ERROR, "drv_get_cpld_mode sub_slot %d cpldid %d faile, set default local_bus mode.\n", sub_slot, cpld_id); + cpld_mode = DFD_CPLD_MODE_I2C; + } + + if (cpld_mode == DFD_CPLD_MODE_I2C) { + ret = dfd_ko_cpld_i2c_write(addr, val); + } else if (cpld_mode == DFD_CPLD_MODE_LPC) { + ret = dfd_ko_cpld_io_write(addr, val); + } else { + DBG_DEBUG(DBG_ERROR, "cpld_mode %d invalid.\n", cpld_mode); + ret = -DFD_RV_MODE_INVALID; + } + + DBG_DEBUG(DBG_VERBOSE, "addr 0x%x val 0x%x ret %d\n", addr, val, ret); + return ret; +} + +static int32_t dfd_ko_i2c_read_tmp(int bus, int addr, int offset, uint8_t *buf, uint32_t size) +{ + int i, rv; + + for (i = 0; i < size; i++) { + rv = dfd_ko_i2c_read_data(bus, addr, offset, &buf[i], sizeof(uint8_t)); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "dfd_ko_i2c_read_data[bus=%d addr=0x%x offset=0x%x]fail, rv=%d\n", + bus, addr, offset, rv); + return rv; + } + offset++; + } + + return size; +} + +int32_t dfd_ko_i2c_write(int bus, int addr, int offset, uint8_t *buf, uint32_t size) +{ + int i, rv; + + for (i = 0; i < size; i++) { + rv = dfd_ko_i2c_write_data(bus, addr, offset, buf[i], sizeof(uint8_t)); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "dfd_ko_i2c_write[bus=%d addr=0x%x offset=0x%x]fail, rv=%d\n", + bus, addr, offset, rv); + return rv; + } + offset++; + } + + return size; + +} + +int32_t dfd_ko_read_file(char *fpath, int32_t addr, uint8_t *val, int32_t read_bytes) +{ + int32_t ret; + struct file *filp; + loff_t pos; + + if ((fpath == NULL) || (val == NULL) || (addr < 0) || (read_bytes < 0)) { + DBG_DEBUG(DBG_ERROR, "input arguments error, addr=%d read_bytes=%d\n", addr, read_bytes); + return -DFD_RV_INDEX_INVALID; + } + + filp = filp_open(fpath, O_RDONLY, 0); + if (IS_ERR(filp)){ + DBG_DEBUG(DBG_ERROR, "open file[%s] fail\n", fpath); + return -DFD_RV_DEV_FAIL; + } + pos = addr; + ret = kernel_read(filp, val, read_bytes, &pos); + if (ret < 0) { + DBG_DEBUG(DBG_ERROR, "kernel_read failed, path=%s, addr=%d, size=%d, ret=%d\n", fpath, addr, read_bytes, ret); + ret = -DFD_RV_DEV_FAIL; + } + filp_close(filp, NULL); + return ret; +} + +int32_t dfd_ko_i2c_read(int bus, int addr, int offset, uint8_t *buf, uint32_t size, const char *sysfs_name) +{ + int rv; + char sysfs_path[DFD_SYSFS_PATH_MAX_LEN]; + + if (buf == NULL) { + DBG_DEBUG(DBG_ERROR, "params error, buf is NULL.\n"); + return -DFD_RV_INVALID_VALUE; + } + + if (sysfs_name == NULL) { + DBG_DEBUG(DBG_VERBOSE, "using i2c_smbus_xfer, bus:%d, addr:0x%x, offset:0x%x, read size:%d.\n", + bus, addr, offset, size); + rv = dfd_ko_i2c_read_tmp(bus, addr, offset, buf, size); + } else { + memset(sysfs_path, 0, sizeof(sysfs_path)); + snprintf(sysfs_path, sizeof(sysfs_path), "/sys/bus/i2c/devices/%d-%04x/%s", + bus, addr, sysfs_name); + DBG_DEBUG(DBG_VERBOSE, "using sysfs, sysfs_path:%s, offset:0x%x, read size:%d.\n", + sysfs_path, offset, size); + rv = dfd_ko_read_file(sysfs_path, offset, buf, size); + } + + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "dfd_ko_i2c_read failed.\n"); + } else { + DBG_DEBUG(DBG_VERBOSE, "dfd_ko_i2c_read success.\n"); + } + + return rv; +} + +int32_t dfd_ko_write_file(char *fpath, int32_t addr, uint8_t *val, int32_t write_bytes) +{ + int32_t ret; + struct file *filp; + loff_t pos; + + if ((fpath == NULL) || (val == NULL) || (addr < 0) || (write_bytes <= 0)) { + DBG_DEBUG(DBG_ERROR, "input arguments error, addr=%d write_bytes=%d\n", addr, write_bytes); + return -DFD_RV_INDEX_INVALID; + } + + filp = filp_open(fpath, O_WRONLY, 0); + if (IS_ERR(filp)) { + DBG_DEBUG(DBG_ERROR, "open file[%s] fail\n", fpath); + return -DFD_RV_DEV_FAIL; + } + pos = addr; + ret = kernel_write(filp, val, write_bytes, &pos); + if (ret < 0) { + DBG_DEBUG(DBG_ERROR,"kernel_write failed, path=%s, addr=%d, size=%d, ret=%d\n", fpath, addr, write_bytes, ret); + ret = -DFD_RV_DEV_FAIL; + } + + filp_close(filp, NULL); + return ret; +} \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_cfg_file.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_cfg_file.c new file mode 100644 index 000000000000..4f1333dc06a9 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_cfg_file.c @@ -0,0 +1,203 @@ +/* + * Copyright(C) 2001-2015s Ruijie Network. All rights reserved. + */ +/* + * dfd_cfg_file.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * + * History + * [Version] [Author] [Date] [Description] + * v1.0 sonic_rd@ruijie.com.cn 2020-02-17 Initial version + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "dfd_cfg_file.h" +#include "rg_module.h" + +struct getdents_callback { + struct dir_context ctx; + const char *obj_name; + char *match_name; + int dir_len; + int found; +}; + +int kfile_open(char *fname, kfile_ctrl_t *kfile_ctrl) +{ + int ret; + struct file *filp; + loff_t pos; + + if ((fname == NULL) || (kfile_ctrl == NULL)) { + return KFILE_RV_INPUT_ERR; + } + + filp = filp_open(fname, O_RDONLY, 0); + if (IS_ERR(filp)){ + return KFILE_RV_OPEN_FAIL; + } + + kfile_ctrl->size = filp->f_inode->i_size; + + kfile_ctrl->buf = kmalloc(kfile_ctrl->size, GFP_KERNEL); + if (kfile_ctrl->buf == NULL) { + ret = KFILE_RV_MALLOC_FAIL; + goto close_fp; + } + memset(kfile_ctrl->buf, 0, kfile_ctrl->size); + pos = 0; + ret = kernel_read(filp, kfile_ctrl->buf, kfile_ctrl->size, &pos); + if (ret < 0) { + ret = KFILE_RV_RD_FAIL; + goto free_buf; + } + + kfile_ctrl->pos = 0; + + ret = KFILE_RV_OK; + goto close_fp; + +free_buf: + kfree(kfile_ctrl->buf); + kfile_ctrl->buf = NULL; + +close_fp: + filp_close(filp, NULL); + return ret; +} + +void kfile_close(kfile_ctrl_t *kfile_ctrl) +{ + if (kfile_ctrl == NULL) { + return; + } + + kfile_ctrl->size = 0; + kfile_ctrl->pos = 0; + if (kfile_ctrl->buf) { + kfree(kfile_ctrl->buf); + kfile_ctrl->buf = NULL; + } +} + +int kfile_gets(char *buf, int buf_size, kfile_ctrl_t *kfile_ctrl) +{ + int i; + int has_cr = 0; + + if ((buf == NULL) || (buf_size <= 0) || (kfile_ctrl == NULL) || (kfile_ctrl->buf == NULL) + || (kfile_ctrl->size <= 0)) { + return KFILE_RV_INPUT_ERR; + } + + memset(buf, 0, buf_size); + for (i = 0; i < buf_size; i++) { + if (kfile_ctrl->pos >= kfile_ctrl->size) { + break; + } + + if (has_cr) { + break; + } + + if (IS_CR(kfile_ctrl->buf[kfile_ctrl->pos])) { + has_cr = 1; + } + + buf[i] = kfile_ctrl->buf[kfile_ctrl->pos]; + kfile_ctrl->pos++; + } + + return i; +} + +int kfile_read(int32_t addr, char *buf, int buf_size, kfile_ctrl_t *kfile_ctrl) +{ + int i; + + if ((buf == NULL) || (buf_size <= 0) || (kfile_ctrl == NULL) || (kfile_ctrl->buf == NULL) + || (kfile_ctrl->size <= 0)) { + return KFILE_RV_INPUT_ERR; + } + + if ((addr < 0) || (addr >= kfile_ctrl->size)) { + return KFILE_RV_ADDR_ERR; + } + + memset(buf, 0, buf_size); + + kfile_ctrl->pos = addr; + for (i = 0; i < buf_size; i++) { + if (kfile_ctrl->pos >= kfile_ctrl->size) { + break; + } + buf[i] = kfile_ctrl->buf[kfile_ctrl->pos]; + kfile_ctrl->pos++; + } + + return i; +} + +static int kfile_filldir_one(struct dir_context *ctx, const char * name, int len, + loff_t pos, u64 ino, unsigned int d_type) +{ + struct getdents_callback *buf ; + int result; + buf = container_of(ctx, struct getdents_callback, ctx); + result = 0; + if (strncmp(buf->obj_name, name, strlen(buf->obj_name)) == 0) { + if (buf->dir_len < len) { + DBG_DEBUG(DBG_ERROR, "match ok. dir name:%s, but buf_len %d small than dir len %d.\n", + name, buf->dir_len, len); + buf->found = 0; + return -1; + } + memset(buf->match_name, 0 , buf->dir_len); + memcpy(buf->match_name, name, len); + buf->found = 1; + result = -1; + } + return result; +} + +int kfile_iterate_dir(const char *dir_path, const char *obj_name, char *match_name, int len) +{ + int ret; + struct file *dir; + struct getdents_callback buffer = { + .ctx.actor = kfile_filldir_one, + }; + + if(!dir_path || !obj_name || !match_name) { + DBG_DEBUG(DBG_ERROR, "params error. \n"); + return KFILE_RV_INPUT_ERR; + } + buffer.obj_name = obj_name; + buffer.match_name = match_name; + buffer.dir_len = len; + buffer.found = 0; + dir = filp_open(dir_path, O_RDONLY, 0); + if (IS_ERR(dir)) { + DBG_DEBUG(DBG_ERROR, "filp_open error, dir path:%s\n", dir_path); + return KFILE_RV_OPEN_FAIL; + } + ret = iterate_dir(dir, &buffer.ctx); + if (buffer.found) { + DBG_DEBUG(DBG_VERBOSE, "match ok, dir name:%s\n", match_name); + filp_close(dir, NULL); + return DFD_RV_OK; + } + filp_close(dir, NULL); + return -DFD_RV_NODE_FAIL; +} \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_cfg_info.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_cfg_info.c new file mode 100644 index 000000000000..5cde03c5242b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_cfg_info.c @@ -0,0 +1,583 @@ +/* + * Copyright(C) 2022 Ruijie Network. All rights reserved. + */ +/* + * dfd_cfg_info.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * + */ + +#include +#include +#include + +#include "rg_module.h" +#include "dfd_cfg_adapter.h" +#include "dfd_cfg.h" +#include "dfd_cfg_info.h" +#include "dfd_cfg_file.h" + +#define DFD_HWMON_NAME "hwmon" +#define DFD_GET_CPLD_VOLATGE_CODE_VALUE(value) ((value >> 4)& 0xfff) +#define DFD_GET_CPLD_VOLATGE_REAL_VALUE(code_val, k) ((code_val * 16 * 33 * k) / ((65536 - 5000) * 10)) + +char *g_info_ctrl_mem_str[INFO_CTRL_MEM_END] = { + ".mode", + ".int_cons", + ".src", + ".frmt", + ".pola", + ".fpath", + ".addr", + ".len", + ".bit_offset", + ".str_cons", + ".int_extra1", + ".int_extra2", +}; + +char *g_info_ctrl_mode_str[INFO_CTRL_MODE_END] = { + "none", + "config", + "constant", + "tlv", + "str_constant", +}; + +char *g_info_src_str[INFO_SRC_END] = { + "none", + "cpld", + "fpga", + "other_i2c", + "file", +}; + +char *g_info_frmt_str[INFO_FRMT_END] = { + "none", + "bit", + "byte", + "num_bytes", + "num_str", + "num_buf", + "buf", +}; + +char *g_info_pola_str[INFO_POLA_END] = { + "none", + "positive", + "negative", +}; + +static int dfd_read_info_from_cpld(int32_t addr, int read_bytes, uint8_t *val) +{ + int i, rv; + + for (i = 0; i < read_bytes; i++) { + rv = dfd_ko_cpld_read(addr, &(val[i])); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "read info[addr=0x%x read_bytes=%d] from cpld fail, reading_byte=%d rv=%d\n", + addr, read_bytes, i, rv); + return rv; + } + addr++; + } + + return read_bytes; +} + +static int dfd_write_info_to_cpld(int32_t addr, int write_bytes, uint8_t *val, uint8_t bit_mask) +{ + int rv; + uint8_t val_tmp; + + if (bit_mask != 0xff) { + rv = dfd_ko_cpld_read(addr, &val_tmp); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "read original info[addr=0x%x] from cpld fail, rv=%d\n", addr, rv); + return -1; + } + + val_tmp = (val_tmp & (~bit_mask)) | (val[0] & bit_mask); + } else { + val_tmp = val[0]; + } + + rv = dfd_ko_cpld_write(addr, val_tmp); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "write info[addr=0x%x val=0x%x] to cpld fail, rv=%d\n", addr, val_tmp, rv); + return -1; + } + + return 0; +} + +static int dfd_read_info(info_src_t src, char *fpath, int32_t addr, int read_bytes, uint8_t *val) +{ + int rv = 0; + + switch (src) { + case INFO_SRC_CPLD: + rv = dfd_read_info_from_cpld(addr, read_bytes, val); + break; + case INFO_SRC_FPGA: + rv = -1; + DBG_DEBUG(DBG_ERROR, "not support read info from fpga\n"); + break; + case INFO_SRC_OTHER_I2C: + rv = -1; + DBG_DEBUG(DBG_ERROR, "not support read info from other i2c\n"); + break; + case INFO_SRC_FILE: + rv = dfd_ko_read_file(fpath, addr, val, read_bytes); + break; + default: + rv = -1; + DBG_DEBUG(DBG_ERROR, "info src[%d] error\n", src); + break; + } + + return rv; +} + +static int dfd_write_info(info_src_t src, char *fpath, int32_t addr, int write_bytes, uint8_t *val, uint8_t bit_mask) +{ + int rv = 0; + + switch (src) { + case INFO_SRC_CPLD: + rv = dfd_write_info_to_cpld(addr, write_bytes, val, bit_mask); + break; + case INFO_SRC_FPGA: + rv = -1; + DBG_DEBUG(DBG_ERROR, "not support write info to fpga\n"); + break; + case INFO_SRC_OTHER_I2C: + rv = -1; + DBG_DEBUG(DBG_ERROR, "not support write info to other i2c\n"); + break; + case INFO_SRC_FILE: + rv = -1; + DBG_DEBUG(DBG_ERROR, "not support write info to file\n"); + break; + default: + rv = -1; + DBG_DEBUG(DBG_ERROR, "info src[%d] error\n", src); + break; + } + + return rv; +} + +int dfd_info_get_int(int key, int *ret, info_num_buf_to_value_f pfun) +{ + int i, rv; + int read_bytes, readed_bytes, int_tmp; + uint8_t byte_tmp, val[INFO_INT_MAX_LEN + 1] = {0}; + info_ctrl_t *info_ctrl; + + if (!DFD_CFG_ITEM_IS_INFO_CTRL(DFD_CFG_ITEM_ID(key)) || (ret == NULL)) { + DBG_DEBUG(DBG_ERROR, "input arguments error, key=0x%08x\n", key); + return -DFD_RV_INDEX_INVALID; + } + + info_ctrl = dfd_ko_cfg_get_item(key); + if (info_ctrl == NULL) { + DBG_DEBUG(DBG_WARN, "get info ctrl fail, key=0x%08x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + + if (info_ctrl->mode == INFO_CTRL_MODE_CONS) { + *ret = info_ctrl->int_cons; + return DFD_RV_OK; + } else if (info_ctrl->mode == INFO_CTRL_MODE_TLV) { + return INFO_CTRL_MODE_TLV; + } + + if (IS_INFO_FRMT_BIT(info_ctrl->frmt)) { + if (!INFO_BIT_OFFSET_VALID(info_ctrl->bit_offset)) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] bit_offsest[%d] invalid\n", + key, info_ctrl->bit_offset); + return -DFD_RV_TYPE_ERR; + } + + read_bytes = 1; + } else if (IS_INFO_FRMT_BYTE(info_ctrl->frmt) || IS_INFO_FRMT_NUM_STR(info_ctrl->frmt) + || IS_INFO_FRMT_NUM_BUF(info_ctrl->frmt)) { + if (!INFO_INT_LEN_VALAID(info_ctrl->len)) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] len[%d] invalid\n", key, info_ctrl->len); + return -DFD_RV_TYPE_ERR; + } + read_bytes = info_ctrl->len; + } else { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] info format[%d] error\n", key, info_ctrl->frmt); + return -DFD_RV_TYPE_ERR; + } + + readed_bytes = dfd_read_info(info_ctrl->src, info_ctrl->fpath, info_ctrl->addr, read_bytes, &(val[0])); + if (readed_bytes <= 0) { + DBG_DEBUG(DBG_ERROR, "read int info[key=0x%08x src=%s frmt=%s fpath=%s addr=0x%x read_bytes=%d] fail, rv=%d\n", + key, g_info_src_str[info_ctrl->src], g_info_frmt_str[info_ctrl->frmt], info_ctrl->fpath, + info_ctrl->addr, read_bytes, readed_bytes); + return -DFD_RV_DEV_FAIL; + } + + if (IS_INFO_FRMT_BIT(info_ctrl->frmt)) { + if (info_ctrl->pola == INFO_POLA_NEGA) { + val[0] = ~val[0]; + } + + byte_tmp = (val[0] >> info_ctrl->bit_offset) & (~(0xff << info_ctrl->len)); + + if (pfun) { + rv = pfun(&byte_tmp, sizeof(byte_tmp), &int_tmp); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] bit process fail, rv=%d\n", key, rv); + return rv; + } + } else { + int_tmp = (int)byte_tmp; + } + } else if (IS_INFO_FRMT_BYTE(info_ctrl->frmt)) { + int_tmp = 0; + for (i = 0; i < info_ctrl->len; i++) { + if (info_ctrl->pola == INFO_POLA_NEGA) { + int_tmp |= val[info_ctrl->len - i - 1]; + } else { + int_tmp |= val[i]; + } + if (i != (info_ctrl->len - 1)) { + int_tmp <<= 8; + } + } + } else if (IS_INFO_FRMT_NUM_STR(info_ctrl->frmt)) { + val[readed_bytes] = '\0'; + int_tmp = simple_strtol((char *)(&(val[0])), NULL, 10); + } else { + if (pfun == NULL) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] number buf process function is null\n", key); + return -DFD_RV_INDEX_INVALID; + } + rv = pfun(val, readed_bytes, &int_tmp); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] number buf process fail, rv=%d\n", key, rv); + return rv; + } + } + + *ret = int_tmp; + DBG_DEBUG(DBG_VERBOSE, "read int info[key=0x%08x src=%s frmt=%s pola=%s fpath=%s addr=0x%x len=%d bit_offset=%d] success, ret=%d\n", + key, g_info_src_str[info_ctrl->src], g_info_frmt_str[info_ctrl->frmt], g_info_pola_str[info_ctrl->pola], + info_ctrl->fpath, info_ctrl->addr, info_ctrl->len, info_ctrl->bit_offset, *ret); + return DFD_RV_OK; +} + +int dfd_info_get_buf(int key, uint8_t *buf, int buf_len, info_buf_to_buf_f pfun) +{ + int rv; + int read_bytes, buf_real_len; + uint8_t buf_tmp[INFO_BUF_MAX_LEN]; + info_ctrl_t *info_ctrl; + + if (!DFD_CFG_ITEM_IS_INFO_CTRL(DFD_CFG_ITEM_ID(key)) || (buf == NULL)) { + DBG_DEBUG(DBG_ERROR, "input arguments error, key=0x%08x\n", key); + return -DFD_RV_INDEX_INVALID; + } + + info_ctrl = dfd_ko_cfg_get_item(key); + if (info_ctrl == NULL) { + DBG_DEBUG(DBG_WARN, "get info ctrl fail, key=0x%08x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + + if (info_ctrl->mode != INFO_CTRL_MODE_CFG) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] mode[%d] invalid\n", key, info_ctrl->mode); + return -DFD_RV_TYPE_ERR; + } + + if (!IS_INFO_FRMT_BUF(info_ctrl->frmt) || !INFO_BUF_LEN_VALAID(info_ctrl->len) + || (buf_len <= info_ctrl->len)) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] format=%d or len=%d invlaid, buf_len=%d\n", + key, info_ctrl->frmt, info_ctrl->len, buf_len); + return -DFD_RV_TYPE_ERR; + } + + read_bytes = dfd_read_info(info_ctrl->src, info_ctrl->fpath, info_ctrl->addr, info_ctrl->len, buf_tmp); + if (read_bytes <= 0) { + DBG_DEBUG(DBG_ERROR, "read buf info[key=0x%08x src=%s frmt=%s fpath=%s addr=0x%x len=%d] fail, rv=%d\n", + key, g_info_src_str[info_ctrl->src], g_info_frmt_str[info_ctrl->frmt], info_ctrl->fpath, + info_ctrl->addr, info_ctrl->len, read_bytes); + return -DFD_RV_DEV_FAIL; + } + + if (pfun) { + buf_real_len = buf_len; + rv = pfun(buf_tmp, read_bytes, buf, &buf_real_len); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] buf process fail, rv=%d\n", key, rv); + return -DFD_RV_DEV_FAIL; + } + } else { + buf_real_len = read_bytes; + memcpy(buf, buf_tmp, read_bytes); + } + + return buf_real_len; +} + +static int dfd_2key_info_get_buf(info_ctrl_t *info_ctrl, uint8_t *buf, int buf_len, info_hwmon_buf_f pfun) +{ + int rv; + int read_bytes, buf_real_len; + uint8_t buf_tmp[INFO_BUF_MAX_LEN]; + char fpath[INFO_FPATH_MAX_LEN]; + int coefficient, addend; + + if (!IS_INFO_FRMT_BUF(info_ctrl->frmt) || !INFO_BUF_LEN_VALAID(info_ctrl->len) + || (buf_len <= info_ctrl->len)) { + DBG_DEBUG(DBG_ERROR, "key_path info ctrl format=%d or len=%d invlaid, buf_len=%d\n", + info_ctrl->frmt, info_ctrl->len, buf_len); + return -DFD_RV_TYPE_ERR; + } + + memset(buf_tmp, 0 , sizeof(buf_tmp)); + rv = kfile_iterate_dir(info_ctrl->fpath, DFD_HWMON_NAME, buf_tmp, INFO_BUF_MAX_LEN); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "dir patch:%s, can find name %s dir \n", + info_ctrl->fpath, DFD_HWMON_NAME); + return -DFD_RV_NO_NODE; + } + memset(fpath, 0 , sizeof(fpath)); + snprintf(fpath, sizeof(fpath), "%s%s/%s", + info_ctrl->fpath, buf_tmp, info_ctrl->str_cons); + DBG_DEBUG(DBG_VERBOSE, "match ok path: %s\n", fpath); + + memset(buf_tmp, 0, sizeof(buf_tmp)); + read_bytes = dfd_read_info(info_ctrl->src, fpath, info_ctrl->addr, info_ctrl->len, buf_tmp); + if (read_bytes <= 0) { + DBG_DEBUG(DBG_ERROR, "read buf info[src: %s frmt: %s fpath: %s addr: 0x%x len: %d] fail, rv=%d\n", + g_info_src_str[info_ctrl->src], g_info_src_str[info_ctrl->frmt], fpath, + info_ctrl->addr, info_ctrl->len, read_bytes); + return -DFD_RV_DEV_FAIL; + } + + if (pfun) { + buf_real_len = buf_len; + coefficient = info_ctrl->int_extra1; + addend = info_ctrl->int_extra2; + if (coefficient != 0) { + rv = pfun(buf_tmp, read_bytes, buf, &buf_real_len, info_ctrl, coefficient, addend); + } else { + rv = pfun(buf_tmp, read_bytes, buf, &buf_real_len, info_ctrl, 1, addend); + } + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "info ctrl buf process fail, rv=%d\n", rv); + return -DFD_RV_DEV_FAIL; + } + } else { + buf_real_len = read_bytes; + memcpy(buf, buf_tmp, buf_real_len); + } + return buf_real_len; +} + +int dfd_info_set_int(int key, int val) +{ + int rv; + int write_bytes; + uint8_t byte_tmp, bit_mask; + info_ctrl_t *info_ctrl; + + if (!DFD_CFG_ITEM_IS_INFO_CTRL(DFD_CFG_ITEM_ID(key))) { + DBG_DEBUG(DBG_ERROR, "input arguments error, key=0x%08x\n", key); + return -DFD_RV_INDEX_INVALID; + } + + info_ctrl = dfd_ko_cfg_get_item(key); + if (info_ctrl == NULL) { + DBG_DEBUG(DBG_WARN, "get info ctrl fail, key=0x%08x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + + if (info_ctrl->mode != INFO_CTRL_MODE_CFG) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] mode[%d] warnning\n", key, info_ctrl->mode); + return -DFD_RV_TYPE_ERR; + } + + if (IS_INFO_FRMT_BIT(info_ctrl->frmt)) { + if (!INFO_BIT_OFFSET_VALID(info_ctrl->bit_offset)) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] bit_offsest[%d] invalid\n", + key, info_ctrl->bit_offset); + return -DFD_RV_TYPE_ERR; + } + + write_bytes = 1; + + byte_tmp = (uint8_t)(val & 0xff); + byte_tmp <<= info_ctrl->bit_offset; + if (info_ctrl->pola == INFO_POLA_NEGA) { + byte_tmp = ~byte_tmp; + } + + bit_mask = (~(0xff << info_ctrl->len)) << info_ctrl->bit_offset; + } else if (IS_INFO_FRMT_BYTE(info_ctrl->frmt)) { + if (!INFO_INT_LEN_VALAID(info_ctrl->len)) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] len[%d] invalid\n", key, info_ctrl->len); + return -DFD_RV_TYPE_ERR; + } + + write_bytes = 1; + byte_tmp = (uint8_t)(val & 0xff); + bit_mask = 0xff; + } else if (IS_INFO_FRMT_NUM_STR(info_ctrl->frmt)) { + DBG_DEBUG(DBG_ERROR, "not support str int set\n"); + return -1; + } else if (IS_INFO_FRMT_NUM_BUF(info_ctrl->frmt)) { + if (!INFO_INT_LEN_VALAID(info_ctrl->len)) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] len[%d] invalid\n", key, info_ctrl->len); + return -DFD_RV_TYPE_ERR; + } + write_bytes = 1; + byte_tmp = (uint8_t)(val & 0xff); + bit_mask = 0xff; + } else { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] format[%d] error\n", key, info_ctrl->frmt); + return -DFD_RV_TYPE_ERR; + } + + rv = dfd_write_info(info_ctrl->src, info_ctrl->fpath, info_ctrl->addr, write_bytes, + &byte_tmp, bit_mask); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "write int info[src=%s frmt=%s fpath=%s addr=0x%x len=%d val=%d] fail, rv=%d\n", + g_info_src_str[info_ctrl->src], g_info_frmt_str[info_ctrl->frmt], info_ctrl->fpath, + info_ctrl->addr, info_ctrl->len, val, rv); + return -DFD_RV_DEV_FAIL; + } + DBG_DEBUG(DBG_VERBOSE, "write int info[src=%s frmt=%s pola=%s fpath=%s addr=0x%x len=%d bit_offset=%d val=%d] success\n", + g_info_src_str[info_ctrl->src], g_info_frmt_str[info_ctrl->frmt], g_info_pola_str[info_ctrl->pola], + info_ctrl->fpath, info_ctrl->addr, info_ctrl->len, info_ctrl->bit_offset, val); + return DFD_RV_OK; +} + +static int dfd_info_get_cpld_voltage(int key, int *value) +{ + int rv, addr_tmp; + int vol_ref_tmp, vol_ref; + int vol_curr_tmp, vol_curr; + info_ctrl_t *info_ctrl; + + info_ctrl = dfd_ko_cfg_get_item(key); + if (info_ctrl == NULL) { + DBG_DEBUG(DBG_WARN, "get info ctrl fail, key=0x%08x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + + rv = dfd_info_get_int(key, &vol_curr_tmp, NULL); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "get cpld current voltage error, addr:0x%x, rv =%d\n", info_ctrl->addr, rv); + return rv; + } + vol_curr_tmp = DFD_GET_CPLD_VOLATGE_CODE_VALUE(vol_curr_tmp); + if (info_ctrl->addr == info_ctrl->int_extra1) { + vol_curr = DFD_GET_CPLD_VOLATGE_REAL_VALUE(vol_curr_tmp, info_ctrl->int_extra2); + } else { + addr_tmp = info_ctrl->addr; + info_ctrl->addr = info_ctrl->int_extra1; + rv = dfd_info_get_int(key, &vol_ref_tmp, NULL); + info_ctrl->addr = addr_tmp; + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "get cpld reference voltage error, addr:0x%x rv:%d\n", info_ctrl->addr, rv); + return rv; + } + vol_ref = DFD_GET_CPLD_VOLATGE_CODE_VALUE(vol_ref_tmp); + vol_curr = (vol_curr_tmp * info_ctrl->int_extra2) / vol_ref; + } + *value = vol_curr; + return DFD_RV_OK; +} + +static int dfd_info_get_sensor_value(int key, uint8_t *buf, int buf_len, info_hwmon_buf_f pfun) +{ + int rv, buf_real_len; + int value; + uint8_t buf_tmp[INFO_BUF_MAX_LEN]; + info_ctrl_t *info_ctrl; + + info_ctrl = dfd_ko_cfg_get_item(key); + if (info_ctrl == NULL) { + DBG_DEBUG(DBG_VERBOSE, "can't find dfd config, key: 0x%08x\n", key); + return snprintf(buf, buf_len, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + if ((DFD_CFG_ITEM_ID(key) == DFD_CFG_ITEM_HWMON_IN) && (info_ctrl->src == INFO_SRC_CPLD)) { + rv = dfd_info_get_cpld_voltage(key, &value); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "get cpld voltage failed.key=0x%08x, rv:%d\n", key, rv); + return -DFD_RV_DEV_FAIL; + } + DBG_DEBUG(DBG_VERBOSE, "get cpld voltage ok, value:%d\n", value); + memset(buf_tmp, 0 ,sizeof(buf_tmp)); + snprintf(buf_tmp, sizeof(buf_tmp), "%d\n", value); + buf_real_len = strlen(buf_tmp); + if (buf_len <= buf_real_len) { + DBG_DEBUG(DBG_ERROR, "length not enough.buf_len:%d,need length:%d\n", buf_len, buf_real_len); + return -DFD_RV_DEV_FAIL; + } + if (pfun) { + buf_real_len = buf_len; + rv = pfun(buf_tmp, strlen(buf_tmp), buf, &buf_real_len, info_ctrl, 1, 0); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "deal date error.org value:%s, buf_len:%d, rv=%d\n", + buf_tmp, buf_len, rv); + return -DFD_RV_DEV_FAIL; + } + } else { + memcpy(buf, buf_tmp, buf_real_len); + } + return buf_real_len; + } + DBG_DEBUG(DBG_ERROR, "not support mode. key: 0x%08x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; +} + +int dfd_info_get_sensor(uint32_t key, char *buf, int buf_len, info_hwmon_buf_f pfun) +{ + info_ctrl_t *key_info_ctrl; + int rv; + + if (!DFD_CFG_ITEM_IS_INFO_CTRL(DFD_CFG_ITEM_ID(key)) || + (buf == NULL) || buf_len <= 0) { + DBG_DEBUG(DBG_ERROR, "input arguments error, key: 0x%08x, buf_len: %d\n", + key, buf_len); + return -DFD_RV_INVALID_VALUE; + } + memset(buf, 0, buf_len); + key_info_ctrl = dfd_ko_cfg_get_item(key); + if (key_info_ctrl == NULL) { + DBG_DEBUG(DBG_VERBOSE, "can't find dfd config, key: 0x%08x\n", key); + return snprintf(buf, buf_len, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + if (key_info_ctrl->mode == INFO_CTRL_MODE_SRT_CONS) { + snprintf(buf, buf_len, "%s\n", key_info_ctrl->str_cons); + DBG_DEBUG(DBG_VERBOSE, "get sensor value through string config, key: 0x%08x, value: %s\n", key, buf); + return strlen(buf); + } + if (key_info_ctrl->mode == INFO_CTRL_MODE_CONS) { + snprintf(buf, buf_len, "%d\n", key_info_ctrl->int_cons); + DBG_DEBUG(DBG_VERBOSE, "get sensor value through int config, key: 0x%08x, value: %d\n", key, key_info_ctrl->int_cons); + return strlen(buf); + } + + if (key_info_ctrl->mode == INFO_CTRL_MODE_CFG && key_info_ctrl->src == INFO_SRC_FILE) { + DBG_DEBUG(DBG_VERBOSE, "get sensor value through hwmon, key: 0x%08x\n", key); + rv = dfd_2key_info_get_buf(key_info_ctrl, buf, buf_len, pfun); + if (rv < 0) { + DBG_DEBUG(DBG_VERBOSE, "get sensor value through hwmon failed, key: 0x%08x, rv: %d\n", key, rv); + } + return rv; + } + rv = dfd_info_get_sensor_value(key, buf, buf_len, pfun); + if ( rv < 0) { + DBG_DEBUG(DBG_ERROR, "get sensor value failed, key: 0x%08x, rv: %d\n", key, rv); + } + return rv; +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_cfg_listnode.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_cfg_listnode.c new file mode 100644 index 000000000000..0983ed3ec70c --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_cfg_listnode.c @@ -0,0 +1,95 @@ +/* + * Copyright(C) 2001-2022 Ruijie Network. All rights reserved. + */ +/* + * dfd_cfg_listnode.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * + * History + * [Version] [Author] [Date] [Description] + * v1.0 sonic_rd@ruijie.com.cn 2020-02-17 Initial version + * + */ + +#include +#include + +#include "dfd_cfg_listnode.h" + +void *lnode_find_node(lnode_root_t *root, int key) +{ + lnode_node_t *lnode; + + if (root == NULL){ + return NULL; + } + + list_for_each_entry(lnode, &(root->root), lst) { + if (lnode->key == key) { + return lnode->data; + } + } + + return NULL; +} + +int lnode_insert_node(lnode_root_t *root, int key, void *data) +{ + lnode_node_t *lnode; + void *data_tmp; + + if ((root == NULL) || (data == NULL)) { + return LNODE_RV_INPUT_ERR; + } + + data_tmp = lnode_find_node(root, key); + if (data_tmp != NULL) { + return LNODE_RV_NODE_EXIST; + } + + lnode = kmalloc(sizeof(lnode_node_t), GFP_KERNEL); + if (lnode == NULL) { + return LNODE_RV_NOMEM; + } + + lnode->key = key; + lnode->data = data; + list_add_tail(&(lnode->lst), &(root->root)); + + return LNODE_RV_OK; +} + +int lnode_init_root(lnode_root_t *root) +{ + if (root == NULL) { + return LNODE_RV_INPUT_ERR; + } + + INIT_LIST_HEAD(&(root->root)); + + return LNODE_RV_OK; +} + +void lnode_free_list(lnode_root_t *root) +{ + lnode_node_t *lnode, *lnode_next; + + if (root == NULL){ + return ; + } + + list_for_each_entry_safe(lnode, lnode_next, &(root->root), lst) { + if ( lnode->data ) { + kfree(lnode->data); + lnode->data = NULL; + lnode->key = 0; + } + list_del(&lnode->lst); + kfree(lnode); + lnode = NULL; + } + + return ; + +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_frueeprom.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_frueeprom.c new file mode 100644 index 000000000000..8a25b5b6d94b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_frueeprom.c @@ -0,0 +1,498 @@ +/* + * Copyright(C) 2001-2022 Ruijie Network. All rights reserved. + */ +/* + * dfd_frueeprom.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * History + * [Version] [Author] [Date] [Description] + * * v1.0 sonic_rd@ruijie.com.cn 2020-02-17 Initial version + */ +#include +#include +#include +#include + +#include "dfd_frueeprom.h" +#include "dfd_cfg_adapter.h" +#include "rg_module.h" + +int g_dfd_fru_dbg_level = 0; +module_param(g_dfd_fru_dbg_level, int, S_IRUGO | S_IWUSR); + +/** + * Takes the pointer to stream of bytes and length + * and returns the 8 bit checksum + * This algo is per IPMI V2.0 spec + */ +static unsigned char ipmi_calculate_crc(const unsigned char *data, size_t len) +{ + char crc = 0; + size_t byte = 0; + + for (byte = 0; byte < len; byte++) + { + crc += *data++; + } + + return(-crc); +} + +/* Validates the data for crc and mandatory fields */ +static int ipmi_verify_fru_data(const uint8_t *data, const size_t len) +{ + uint8_t checksum = 0; + int rc = -DFD_RV_TYPE_ERR; + + /* Validate for first byte to always have a value of [1] */ + if (data[0] != IPMI_FRU_HDR_BYTE_ZERO) + { + DBG_FRU_DEBUG(DBG_ERROR, "Invalid entry:[%d] in byte-0\n",data[0]); + return rc; + } else { + DBG_FRU_DEBUG(DBG_VERBOSE, "SUCCESS: Validated [0x%X] in entry_1 of fru_data\n",data[0]); + } + + /* See if the calculated CRC matches with the embedded one. + * CRC to be calculated on all except the last one that is CRC itself.*/ + checksum = ipmi_calculate_crc(data, len - 1); + if (checksum != data[len-1]) + { + DBG_FRU_DEBUG(DBG_ERROR, "Checksum mismatch." + " Calculated:[0x%X], Embedded:[0x%X]\n", + checksum, data[len - 1]); + return rc; + } else { + DBG_FRU_DEBUG(DBG_VERBOSE, "SUCCESS: Checksum matches:[0x%X]\n",checksum); + } + + return 0; +} + +/* private method to parse type/length */ +static int ipmi_parse_type_length (const void *areabuf, + unsigned int areabuflen, + unsigned int current_area_offset, + uint8_t *number_of_data_bytes, + ipmi_fru_field_t *field) +{ + const uint8_t *areabufptr = (const uint8_t*) areabuf; + uint8_t type_length; + uint8_t type_code; + + type_length = areabufptr[current_area_offset]; + + /* ipmi workaround + * + * dell p weredge r610 + * + * my reading of the fru spec is that all non-custom fields are + * required to be listed by the vendor. however, on this + * motherboard, some areas list this, indicating that there is + * no more data to be parsed. so now, for "required" fields, i + * check to see if the type-length field is a sentinel before + * calling this function. + */ + + type_code = (type_length & IPMI_FRU_TYPE_LENGTH_TYPE_CODE_MASK) >> IPMI_FRU_TYPE_LENGTH_TYPE_CODE_SHIFT; + (*number_of_data_bytes) = type_length & IPMI_FRU_TYPE_LENGTH_NUMBER_OF_DATA_BYTES_MASK; + + /* special case: this shouldn't be a length of 0x01 (see type/length + * byte format in fru information storage definition). + */ + DBG_FRU_DEBUG(DBG_VERBOSE, "areabuflen:%d, current_area_offset:0x%x, type_code:0x%x, number_of_data_bytes:%d\n", + areabuflen, current_area_offset, type_code, *number_of_data_bytes ); + if ((current_area_offset + 1 + (*number_of_data_bytes)) > areabuflen) { + DBG_FRU_DEBUG(DBG_ERROR, "buf length error. current_area_offset:0x%x, need length:%d, total length:0x%x\n", + current_area_offset, *number_of_data_bytes, areabuflen ); + return (-1); + } + + if (field) { + memset (field->type_length_field, '\0', IPMI_FRU_AREA_TYPE_LENGTH_FIELD_MAX); + memcpy (field->type_length_field, &areabufptr[current_area_offset + 1], *number_of_data_bytes); + DBG_FRU_DEBUG(DBG_VERBOSE, "fru parse ok. value:%s\n", field->type_length_field); + field->type_length_field_length = *number_of_data_bytes; + } + + return (0); +} + +static int ipmi_fru_product_info_area(const void *areabuf, + unsigned int areabuflen, ipmi_product_info_t *ipmi_product_info) +{ + const uint8_t *areabufptr = (const uint8_t*) areabuf; + unsigned int area_offset = 2; + uint8_t number_of_data_bytes; + int rv; + ipmi_fru_field_t **ipmi_fru_field_point; + int ipmi_fru_field_len, i; + + if (!areabuf || !areabuflen || !ipmi_product_info) { + DBG_FRU_DEBUG(DBG_ERROR, "Invalid Parameter.\n"); + return -DFD_RV_INVALID_VALUE; + } + + /* Verify the crc and size */ + rv = ipmi_verify_fru_data(areabuf, areabuflen); + if (rv < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Failed to validate fru product info data\n"); + return rv; + } + + ipmi_fru_field_len = (sizeof(ipmi_product_info_t) - sizeof(uint8_t *)) /(sizeof(ipmi_fru_field_t *)); + + if (ipmi_product_info->language_code) { + (*ipmi_product_info->language_code) = areabufptr[area_offset]; + } + area_offset++; + ipmi_fru_field_point = (ipmi_fru_field_t **)((uint8_t *)ipmi_product_info + sizeof(uint8_t *)); + for (i = 0; i < ipmi_fru_field_len; i++) { + if (*ipmi_fru_field_point) { + memset(*ipmi_fru_field_point, '\0', sizeof(ipmi_fru_field_t)); + } + + if (((areabufptr[area_offset] == IPMI_FRU_SENTINEL_VALUE) && (i >= IPMI_FRU_PRODUCT_AREA_MIN_LEN)) + || (area_offset == areabuflen - 1)) { + rv = 0; + break; + } + + rv = ipmi_parse_type_length(areabufptr, areabuflen, area_offset, &number_of_data_bytes, *ipmi_fru_field_point); + if (rv < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "[%d] _parse_type_length area_offset[%d] rv=%d \n", i, area_offset, rv); + break; + } + + area_offset += 1; /* type/length byte */ + area_offset += number_of_data_bytes; + ipmi_fru_field_point++; + } + + return (rv); +} + +static int ipmi_fru_board_info_area(const void *areabuf, + unsigned int areabuflen, ipmi_board_info_t *ipmi_board_info) +{ + const uint8_t *areabufptr = (const uint8_t*) areabuf; + unsigned int area_offset = 2; + uint8_t number_of_data_bytes; + int rv; + ipmi_fru_field_t **ipmi_fru_field_point; + int ipmi_fru_field_len, i; + + if (!areabuf || !areabuflen || !ipmi_board_info) { + DBG_FRU_DEBUG(DBG_ERROR, "Invalid Parameter.\n"); + return -DFD_RV_INVALID_VALUE; + } + + /* Verify the crc and size */ + rv = ipmi_verify_fru_data(areabuf, areabuflen); + if (rv < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Failed to validate fru product info data\n"); + return rv; + } + + ipmi_fru_field_len = (sizeof(ipmi_board_info_t) - sizeof(uint8_t *) - sizeof(uint8_t *)) /(sizeof(ipmi_fru_field_t *)); + + if (ipmi_board_info->language_code) { + (*ipmi_board_info->language_code) = areabufptr[area_offset]; + } + area_offset++; + + if (ipmi_board_info->mfg_time) { + memcpy(ipmi_board_info->mfg_time, &areabufptr[area_offset], IPMI_FRU_BOARD_INFO_MFG_TIME_LENGTH); + } + area_offset += IPMI_FRU_BOARD_INFO_MFG_TIME_LENGTH; + ipmi_fru_field_point = (ipmi_fru_field_t **)((uint8_t *)ipmi_board_info + sizeof(uint8_t *) + sizeof(uint8_t *)); + for (i = 0; i < ipmi_fru_field_len; i++) { + if (*ipmi_fru_field_point) { + memset(*ipmi_fru_field_point, '\0', sizeof(ipmi_fru_field_t)); + } + + if (((areabufptr[area_offset] == IPMI_FRU_SENTINEL_VALUE) && (i >= IPMI_FRU_BOARD_AREA_MIN_LEN)) + || (area_offset == areabuflen - 1)) { + rv = 0; + break; + } + + rv = ipmi_parse_type_length(areabufptr, areabuflen, area_offset, &number_of_data_bytes, *ipmi_fru_field_point); + if (rv < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "[%d] _parse_type_length area_offset[%d] rv=%d \n", i, area_offset, rv); + break; + } + + area_offset += 1; /* type/length byte */ + area_offset += number_of_data_bytes; + ipmi_fru_field_point++; + } + + return (rv); +} + +/** + * Validates the fru data per ipmi common header constructs. + * Returns with updated common_hdr and also file_size + */ +static int ipmi_validate_common_hdr(const uint8_t *fru_data, const size_t data_len) +{ + int rc = -1; + + uint8_t common_hdr[sizeof(fru_common_header_t)] = {0}; + if (data_len >= sizeof(common_hdr)) + { + memcpy(common_hdr, fru_data, sizeof(common_hdr)); + } + else + { + DBG_FRU_DEBUG(DBG_ERROR, "Incomplete fru data file. Size:[%zd]\n", data_len); + return rc; + } + + /* Verify the crc and size */ + rc = ipmi_verify_fru_data(common_hdr, sizeof(common_hdr)); + if (rc < 0) + { + DBG_FRU_DEBUG(DBG_ERROR, "Failed to validate common header\n"); + return rc; + } + + return 0; +} + +static int dfd_get_frue2prom_info(int bus, int dev_addr, fru_common_header_t *info, const char *sysfs_name) +{ + int ret; + uint8_t fru_common_header_info[sizeof(fru_common_header_t)]; + + if (info == NULL) { + DBG_FRU_DEBUG(DBG_ERROR, "Invalid parameter!\n"); + return -DFD_RV_INVALID_VALUE; + } + + ret = dfd_ko_i2c_read(bus, dev_addr, 0, (uint8_t *)info, sizeof(fru_common_header_t), sysfs_name); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Read eeprom head info error(bus: %d, addr: 0x%02x).\n", bus, dev_addr); + return ret; + } + + memcpy(fru_common_header_info, (uint8_t *)info, sizeof(fru_common_header_t)); + + if (ipmi_validate_common_hdr(fru_common_header_info, sizeof(fru_common_header_t)) != 0) { + return -DFD_RV_TYPE_ERR; + } + + return DFD_RV_OK; +} + +static int dfd_set_fru_product_info(ipmi_product_info_t *ipmi_product_info, ipmi_fru_field_t *vpd_info, int type) +{ + int ret; + ret = DFD_RV_OK; + if (ipmi_product_info == NULL || vpd_info == NULL) { + DBG_FRU_DEBUG(DBG_ERROR, "Invalid parameter!\n"); + return -DFD_RV_INVALID_VALUE; + } + + memset((uint8_t *)ipmi_product_info, 0, sizeof(ipmi_product_info_t)); + switch(type) { + case DFD_DEV_INFO_TYPE_SN: + ipmi_product_info->product_serial_number = vpd_info; + break; + case DFD_DEV_INFO_TYPE_NAME: + ipmi_product_info->product_name = vpd_info; + break; + case DFD_DEV_INFO_TYPE_DEV_TYPE: + ipmi_product_info->product_type_fields = vpd_info; + break; + case DFD_DEV_INFO_TYPE_HW_INFO: + ipmi_product_info->product_version = vpd_info; + break; + case DFD_DEV_INFO_TYPE_PART_NAME: + ipmi_product_info->product_part_model_number = vpd_info; + break; + case DFD_DEV_INFO_TYPE_PART_NUMBER: + ipmi_product_info->product_part_model_number = vpd_info; + break; + default: + ret = -1; + break; + } + + return ret; +} + +static int dfd_set_fru_board_info(ipmi_board_info_t *ipmi_board_info, ipmi_fru_field_t *vpd_info, int type) +{ + int ret; + ret = DFD_RV_OK; + if (ipmi_board_info == NULL || vpd_info == NULL) { + DBG_FRU_DEBUG(DBG_ERROR, "Invalid parameter!\n"); + return -DFD_RV_INVALID_VALUE; + } + + memset((uint8_t *)ipmi_board_info, 0, sizeof(ipmi_board_info_t)); + switch(type) { + case DFD_DEV_INFO_TYPE_SN: + ipmi_board_info->board_serial_number = vpd_info; + break; + case DFD_DEV_INFO_TYPE_NAME: + ipmi_board_info->board_product_name = vpd_info; + break; + case DFD_DEV_INFO_TYPE_HW_INFO: + ipmi_board_info->board_custom_fields = vpd_info; + break; + case DFD_DEV_INFO_TYPE_PART_NUMBER: + ipmi_board_info->board_part_number = vpd_info; + break; + default: + ret = -1; + break; + } + + return ret; +} + +int dfd_get_fru_data(int bus, int dev_addr, int type, uint8_t *buf, uint32_t buf_len, const char *sysfs_name) +{ + fru_common_header_t info; + uint8_t *fru_data; + int ret; + uint8_t fru_len; + ipmi_product_info_t ipmi_product_info; + ipmi_fru_field_t vpd_info; + int product_offset; + int fru_len_tmp; + + if (buf == NULL || buf_len <= 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Invalid parameter!\n"); + return -DFD_RV_INVALID_VALUE; + } + + DBG_FRU_DEBUG(DBG_VERBOSE, "Read fru eeprom (bus: %d, addr: 0x%02x, type:%d, buf: %p, len: %d).\n", + bus, dev_addr, type, buf, buf_len); + + ret = dfd_get_frue2prom_info(bus, dev_addr, &info, sysfs_name); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Read eeprom info head error(bus: %d, addr: 0x%02x, buf: %p, len: %d).\n", + bus, dev_addr, buf, buf_len); + return ret; + } + + product_offset = info.product_offset * IPMI_EIGHT_BYTES; + ret = dfd_ko_i2c_read(bus, dev_addr, product_offset + 1, &fru_len, 1, sysfs_name); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "read eeprom info product_offset(bus: %d, addr: 0x%02x, product offset:%d).\n", + bus, dev_addr, info.product_offset); + return -DFD_RV_DEV_FAIL; + } + + fru_len_tmp = fru_len * IPMI_EIGHT_BYTES; + fru_data = (uint8_t *)kmalloc(sizeof(uint8_t) * fru_len_tmp, GFP_KERNEL); + if (fru_data == NULL) { + DBG_FRU_DEBUG(DBG_ERROR, "Allocate buffer(len:%d) error!\n", fru_len_tmp); + return -DFD_RV_NO_MEMORY; + } + + ret = dfd_ko_i2c_read(bus, dev_addr, product_offset, fru_data, fru_len_tmp, sysfs_name); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Get FRU data error.\n"); + kfree(fru_data); + return ret; + } + + memset((uint8_t *)&vpd_info, 0, sizeof(ipmi_fru_field_t)); + ret = dfd_set_fru_product_info(&ipmi_product_info, &vpd_info, type); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Not support to get info: %d.\n", type); + kfree(fru_data); + return ret; + } + + ret = ipmi_fru_product_info_area(fru_data, fru_len_tmp, &ipmi_product_info); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "analysis FRU product info error.\n"); + kfree(fru_data); + return ret; + } + + kfree(fru_data); + + buf_len = buf_len < vpd_info.type_length_field_length ? buf_len : vpd_info.type_length_field_length; + memcpy(buf, (uint8_t *)&vpd_info, buf_len); + + return DFD_RV_OK; +} + +int dfd_get_fru_board_data(int bus, int dev_addr, int type, uint8_t *buf, uint32_t buf_len, const char *sysfs_name) +{ + fru_common_header_t info; + uint8_t *fru_data; + int ret; + uint8_t fru_len; + ipmi_board_info_t ipmi_board_info; + ipmi_fru_field_t vpd_info; + int board_offset; + int fru_len_tmp; + + if (buf == NULL || buf_len <= 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Invalid parameter!\n"); + return -DFD_RV_INVALID_VALUE; + } + + DBG_FRU_DEBUG(DBG_VERBOSE, "Read fru eeprom (bus: %d, addr: 0x%02x, type:%d, buf: %p, len: %d).\n", + bus, dev_addr, type, buf, buf_len); + + ret = dfd_get_frue2prom_info(bus, dev_addr, &info, sysfs_name); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Read eeprom info head error(bus: %d, addr: 0x%02x, buf: %p, len: %d).\n", + bus, dev_addr, buf, buf_len); + return ret; + } + + board_offset = info.board_offset * IPMI_EIGHT_BYTES; + ret = dfd_ko_i2c_read(bus, dev_addr, board_offset + 1, &fru_len, 1, sysfs_name); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "read eeprom info product_offset(bus: %d, addr: 0x%02x, product offset:%d).\n", + bus, dev_addr, info.board_offset); + return -DFD_RV_DEV_FAIL; + } + + fru_len_tmp = fru_len * IPMI_EIGHT_BYTES; + fru_data = (uint8_t *)kmalloc(sizeof(uint8_t) * fru_len_tmp, GFP_KERNEL); + if (fru_data == NULL) { + DBG_FRU_DEBUG(DBG_ERROR, "Allocate buffer(len:%d) error!\n", fru_len_tmp); + return -DFD_RV_NO_MEMORY; + } + + ret = dfd_ko_i2c_read(bus, dev_addr, board_offset, fru_data, fru_len_tmp, sysfs_name); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Get FRU data error.\n"); + kfree(fru_data); + return ret; + } + + memset((uint8_t *)&vpd_info, 0, sizeof(ipmi_fru_field_t)); + ret = dfd_set_fru_board_info(&ipmi_board_info, &vpd_info, type); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Not support to get info: %d.\n", type); + kfree(fru_data); + return ret; + } + + ret = ipmi_fru_board_info_area(fru_data, fru_len_tmp, &ipmi_board_info); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "analysis FRU product info error.\n"); + kfree(fru_data); + return ret; + } + + kfree(fru_data); + + buf_len = buf_len < vpd_info.type_length_field_length ? buf_len : vpd_info.type_length_field_length; + memcpy(buf, (uint8_t *)&vpd_info, buf_len); + + return DFD_RV_OK; +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_tlveeprom.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_tlveeprom.c new file mode 100644 index 000000000000..712e2ef13d40 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_tlveeprom.c @@ -0,0 +1,443 @@ +/* + * Copyright (C) 2003-2014 FreeIPMI Core Team + * + * 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 . + * + */ +/*****************************************************************************\ + * Copyright (C) 2007-2014 Lawrence Livermore National Security, LLC. + * Copyright (C) 2007 The Regents of the University of California. + * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). + * Written by Albert Chu + * UCRL-CODE-232183 + * + * This file is part of Ipmi-fru, a tool used for retrieving + * motherboard field replaceable unit (FRU) information. For details, + * see http://www.llnl.gov/linux/. + * + * Ipmi-fru 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. + * + * Ipmi-fru 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 Ipmi-fru. If not, see . +\*****************************************************************************/ +#include + +#include "dfd_tlveeprom.h" +#include "rg_module.h" + +#define TLV_CODE_PRODUCT_NAME (0x21) +#define TLV_CODE_PART_NUMBER (0x22) +#define TLV_CODE_SERIAL_NUMBER (0x23) +#define TLV_CODE_MAC_BASE (0x24) +#define TLV_CODE_MANUF_DATE (0x25) +#define TLV_CODE_DEVICE_VERSION (0x26) +#define TLV_CODE_LABEL_REVISION (0x27) +#define TLV_CODE_PLATFORM_NAME (0x28) +#define TLV_CODE_ONIE_VERSION (0x29) +#define TLV_CODE_MAC_SIZE (0x2A) +#define TLV_CODE_MANUF_NAME (0x2B) +#define TLV_CODE_MANUF_COUNTRY (0x2C) +#define TLV_CODE_VENDOR_NAME (0x2D) +#define TLV_CODE_DIAG_VERSION (0x2E) +#define TLV_CODE_SERVICE_TAG (0x2F) +#define TLV_CODE_VENDOR_EXT (0xFD) +#define TLV_CODE_CRC_32 (0xFE) + +/* using in is_valid_tlvinfo_header */ +static uint32_t g_eeprom_size; + +/* + * List of TLV codes and names. + */ +static const struct tlv_code_desc tlv_code_list[] = { + { TLV_CODE_PRODUCT_NAME , "Product Name"}, + { TLV_CODE_PART_NUMBER , "Part Number"}, + { TLV_CODE_SERIAL_NUMBER , "Serial Number"}, + { TLV_CODE_MAC_BASE , "Base MAC Address"}, + { TLV_CODE_MANUF_DATE , "Manufacture Date"}, + { TLV_CODE_DEVICE_VERSION , "Device Version"}, + { TLV_CODE_LABEL_REVISION , "Label Revision"}, + { TLV_CODE_PLATFORM_NAME , "Platform Name"}, + { TLV_CODE_ONIE_VERSION , "ONIE Version"}, + { TLV_CODE_MAC_SIZE , "MAC Addresses"}, + { TLV_CODE_MANUF_NAME , "Manufacturer"}, + { TLV_CODE_MANUF_COUNTRY , "Country Code"}, + { TLV_CODE_VENDOR_NAME , "Vendor Name"}, + { TLV_CODE_DIAG_VERSION , "Diag Version"}, + { TLV_CODE_SERVICE_TAG , "Service Tag"}, + { TLV_CODE_VENDOR_EXT , "Vendor Extension"}, + { TLV_CODE_CRC_32 , "CRC-32"}, +}; + +#define TLV_CODE_NUM (sizeof(tlv_code_list) / sizeof(tlv_code_list[0])) + +const unsigned long g_crc_table[] = { + 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, + 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, + 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, + 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, + 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, + 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, + 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, + 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, + 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, + 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, + 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, + 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, + 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, + 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, + 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, + 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, + 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, + 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, + 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, + 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, + 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, + 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, + 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, + 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, + 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, + 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, + 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, + 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, + 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, + 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, + 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, + 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d, +}; + +static unsigned long crc32(unsigned long crc, const unsigned char *buf, unsigned len) +{ + unsigned i; + if (len < 1) + return 0xffffffff; + + for (i = 0; i != len; ++i) + { + crc = g_crc_table[(crc ^ buf[i]) & 0xff] ^ (crc >> 8); + } + + crc = crc ^ 0xffffffff; + + return crc; +} + +/* + * is_valid_tlv + * + * Perform basic sanity checks on a TLV field. The TLV is pointed to + * by the parameter provided. + * 1. The type code is not reserved (0x00 or 0xFF) + */ +static inline bool is_valid_tlv(tlvinfo_tlv_t *tlv) +{ + return ((tlv->type != 0x00) && (tlv->type != 0xFF)); +} + +/* + * is_valid_tlvinfo_header + * + * Perform sanity checks on the first 11 bytes of the TlvInfo EEPROM + * data pointed to by the parameter: + * 1. First 8 bytes contain null-terminated ASCII string "TlvInfo" + * 2. Version byte is 1 + * 3. Total length bytes contain value which is less than or equal + * to the allowed maximum (2048-11) + * + */ +static inline bool is_valid_tlvinfo_header(tlvinfo_header_t *hdr) +{ + int max_size = g_eeprom_size; + return((strcmp(hdr->signature, TLV_INFO_ID_STRING) == 0) && + (hdr->version == TLV_INFO_VERSION) && + (be16_to_cpu(hdr->totallen) <= max_size) ); +} + +/* + * decode_tlv_value + * + * Decode a single TLV value into a string. + + * The validity of EEPROM contents and the TLV field have been verified + * prior to calling this function. + */ +static void decode_tlv_value(tlvinfo_tlv_t *tlv, tlv_decode_value_t *decode_value) +{ + int i; + char *value; + uint32_t length; + + value = (char *)decode_value->value; + + switch (tlv->type) { + case TLV_CODE_PRODUCT_NAME: + case TLV_CODE_PART_NUMBER: + case TLV_CODE_SERIAL_NUMBER: + case TLV_CODE_MANUF_DATE: + case TLV_CODE_LABEL_REVISION: + case TLV_CODE_PLATFORM_NAME: + case TLV_CODE_ONIE_VERSION: + case TLV_CODE_MANUF_NAME: + case TLV_CODE_MANUF_COUNTRY: + case TLV_CODE_VENDOR_NAME: + case TLV_CODE_DIAG_VERSION: + case TLV_CODE_SERVICE_TAG: + memcpy(value, tlv->value, tlv->length); + value[tlv->length] = 0; + length = tlv->length; + break; + case TLV_CODE_MAC_BASE: + length = sprintf(value, "%02X:%02X:%02X:%02X:%02X:%02X", + tlv->value[0], tlv->value[1], tlv->value[2], + tlv->value[3], tlv->value[4], tlv->value[5]); + break; + case TLV_CODE_DEVICE_VERSION: + length = sprintf(value, "%u", tlv->value[0]); + break; + case TLV_CODE_MAC_SIZE: + length = sprintf(value, "%u", (tlv->value[0] << 8) | tlv->value[1]); + break; + case TLV_CODE_VENDOR_EXT: + value[0] = 0; + length = 0; + for (i = 0; (i < (TLV_DECODE_VALUE_MAX_LEN/5)) && (i < tlv->length); i++) { + length += sprintf(value, "%s %02X", value, tlv->value[i]); + } + break; + case TLV_CODE_CRC_32: + length = sprintf(value, "0x%02X%02X%02X%02X", tlv->value[0], + tlv->value[1], tlv->value[2], tlv->value[3]); + break; + default: + value[0] = 0; + length = 0; + for (i = 0; (i < (TLV_DECODE_VALUE_MAX_LEN/5)) && (i < tlv->length); i++) { + length += sprintf(value, "%s 0x%02X", value, tlv->value[i]); + } + break; + } + + decode_value->length = length; +} + +/* + * is_checksum_valid + * + * Validate the checksum in the provided TlvInfo EEPROM data. First, + * verify that the TlvInfo header is valid, then make sure the last + * TLV is a CRC-32 TLV. Then calculate the CRC over the EEPROM data + * and compare it to the value stored in the EEPROM CRC-32 TLV. + */ +static bool is_checksum_valid(uint8_t *eeprom) +{ + tlvinfo_header_t *eeprom_hdr; + tlvinfo_tlv_t *eeprom_crc; + unsigned int calc_crc; + unsigned int stored_crc; + + eeprom_hdr = (tlvinfo_header_t *) eeprom; + + /* Is the eeprom header valid? */ + if (!is_valid_tlvinfo_header(eeprom_hdr)) { + return false; + } + + /* Is the last TLV a CRC? */ + eeprom_crc = (tlvinfo_tlv_t *) &eeprom[sizeof(tlvinfo_header_t) + + be16_to_cpu(eeprom_hdr->totallen) - (sizeof(tlvinfo_tlv_t) + 4)]; + if ((eeprom_crc->type != TLV_CODE_CRC_32) || (eeprom_crc->length != 4)) { + return false; + } + + /* Calculate the checksum */ + calc_crc = crc32(0xffffffffL, (const unsigned char *)eeprom, sizeof(tlvinfo_header_t) + + be16_to_cpu(eeprom_hdr->totallen) - 4); + stored_crc = ((eeprom_crc->value[0] << 24) | (eeprom_crc->value[1] << 16) | + (eeprom_crc->value[2] << 8) | eeprom_crc->value[3]); + + return (calc_crc == stored_crc); +} + +/* + * tlvinfo_find_tlv + * + * This function finds the TLV with the supplied code in the EERPOM. + * An offset from the beginning of the EEPROM is returned in the + * eeprom_index parameter if the TLV is found. + */ +static bool tlvinfo_find_tlv(uint8_t *eeprom, uint8_t tcode, int *eeprom_index) +{ + tlvinfo_header_t *eeprom_hdr; + tlvinfo_tlv_t *eeprom_tlv; + int eeprom_end; + + eeprom_hdr = (tlvinfo_header_t *) eeprom; + + /* Search through the TLVs, looking for the first one which matches the + * supplied type code. */ + *eeprom_index = sizeof(tlvinfo_header_t); + eeprom_end = sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen); + while (*eeprom_index < eeprom_end) { + eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[*eeprom_index]; + if (!is_valid_tlv(eeprom_tlv)) { + return false; + } + + if (eeprom_tlv->type == tcode) { + return true; + } + + *eeprom_index += sizeof(tlvinfo_tlv_t) + eeprom_tlv->length; + } + + return false; +} + +/* + * tlvinfo_decode_tlv + * + * This function finds the TLV with the supplied code in the EERPOM + * and decodes the value into the buffer provided. + */ +static bool tlvinfo_decode_tlv(uint8_t *eeprom, uint8_t tcode, tlv_decode_value_t *decode_value) +{ + int eeprom_index; + tlvinfo_tlv_t *eeprom_tlv; + + /* Find the TLV and then decode it */ + if (tlvinfo_find_tlv(eeprom, tcode, &eeprom_index)) { + eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[eeprom_index]; + decode_tlv_value(eeprom_tlv, decode_value); + return true; + } + + return false; +} + +/* + * parse_tlv_eeprom + * + * parse the EEPROM into memory, if it hasn't already been read. + */ +int parse_tlv_eeprom(uint8_t *eeprom, uint32_t size) +{ + unsigned int i; + bool ret; + tlvinfo_header_t *eeprom_hdr; + tlv_decode_value_t decode_value; + int j; + + eeprom_hdr = (tlvinfo_header_t *) eeprom; + g_eeprom_size = size; /* eeprom real size */ + + if (!is_valid_tlvinfo_header(eeprom_hdr)) { + DBG_DEBUG(DBG_ERROR, "Failed to check tlv header.\n"); + return -1; + } + + if (!is_checksum_valid(eeprom)) { + DBG_DEBUG(DBG_ERROR, "Failed to check tlv crc.\n"); + return -1; + } + + for (i = 0; i < TLV_CODE_NUM; i++) { + memset((void *)&decode_value, 0, sizeof(tlv_decode_value_t)); + ret = tlvinfo_decode_tlv(eeprom, tlv_code_list[i].m_code, &decode_value); + if (!ret) { + DBG_DEBUG(DBG_ERROR, "No found type: %s\n", tlv_code_list[i].m_name); + continue; + } + + DBG_DEBUG(DBG_VERBOSE, "i: %d,Found type: %s tlv[%d]:%s\n", i, tlv_code_list[i].m_name, tlv_code_list[i].m_code, + decode_value.value); + for (j = 0; j < decode_value.length; j++) { + if ((j % 16) == 0) { + DBG_DEBUG(DBG_VERBOSE, "\n"); + } + DBG_DEBUG(DBG_VERBOSE, "%02x ", decode_value.value[j]); + } + DBG_DEBUG(DBG_VERBOSE, "\n\n"); + } + return 0; +} +static int dfd_parse_tlv_eeprom(uint8_t *eeprom, uint32_t size, uint8_t main_type, tlv_decode_value_t *decode_value) +{ + bool ret; + tlvinfo_header_t *eeprom_hdr; + int j; + + eeprom_hdr = (tlvinfo_header_t *) eeprom; + g_eeprom_size = size; /* eeprom real size */ + + if (!is_valid_tlvinfo_header(eeprom_hdr)) { + DBG_DEBUG(DBG_ERROR, "Failed to check tlv header.\n"); + return -1; + } + + if (!is_checksum_valid(eeprom)) { + DBG_DEBUG(DBG_ERROR, "Failed to check tlv crc.\n"); + return -1; + } + + ret = tlvinfo_decode_tlv(eeprom, main_type, decode_value); + if (!ret) { + DBG_DEBUG(DBG_ERROR, "No found type: %d\n", main_type); + return -1; + } + + DBG_DEBUG(DBG_VERBOSE, "Found type: %d, value: %s\n", main_type,decode_value->value); + for (j = 0; j < decode_value->length; j++) { + if ((j % 16) == 0) { + DBG_DEBUG(DBG_VERBOSE, "\n"); + } + DBG_DEBUG(DBG_VERBOSE, "%02x ", decode_value->value[j]); + } + DBG_DEBUG(DBG_VERBOSE, "\n\n"); + + return 0; +} + +int dfd_tlvinfo_get_e2prom_info(uint8_t *eeprom, uint32_t size, dfd_tlv_type_t *tlv_type, uint8_t* buf, uint32_t *buf_len) +{ + tlv_decode_value_t decode_value; + int ret; + + if (eeprom == NULL || tlv_type == NULL || buf == NULL) { + DBG_DEBUG(DBG_ERROR, "Input para invalid.\n"); + return -1; + } + + memset((void *)&decode_value, 0, sizeof(tlv_decode_value_t)); + ret = dfd_parse_tlv_eeprom(eeprom, size, tlv_type->main_type, &decode_value); + if (ret) { + DBG_DEBUG(DBG_ERROR, "dfd_parse_tlv_eeprom failed ret %d.\n", ret); + return ret; + } + + if (*buf_len >= decode_value.length) { + memcpy(buf, decode_value.value, decode_value.length); + *buf_len = decode_value.length; + return 0; + } + DBG_DEBUG(DBG_ERROR, "buf_len %d small than info_len %d.\n", *buf_len, decode_value.length); + return -1; +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-CPLD.cfg b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-CPLD.cfg new file mode 100755 index 000000000000..9c8f282d444e --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-CPLD.cfg @@ -0,0 +1,143 @@ +other_i2c_dev.bus_0_0=1 +other_i2c_dev.addr_0_0=0x56 + +eeprom_path_0_0=/sys/bus/i2c/devices/1-0056/eeprom + +eeprom_size_0_0=256 + +watchdog_id_0=0 + +watchdog_name_0_0=identity +watchdog_name_0_1=state +watchdog_name_0_2=timeleft +watchdog_name_0_3=timeout + +cpld_i2c_dev.bus_0_2=2 +cpld_i2c_dev.addr_0_2=0x1d +cpld_i2c_dev.bus_0_3=2 +cpld_i2c_dev.addr_0_3=0x2d +cpld_i2c_dev.bus_0_4=4 +cpld_i2c_dev.addr_0_4=0x3d + +cpld_lpc_dev_0_0=0x700 +cpld_lpc_dev_0_1=0x900 + +mode_cpld_0_0=lpc +mode_cpld_0_1=lpc +mode_cpld_0_2=i2c +mode_cpld_0_3=i2c +mode_cpld_0_4=i2c + +dev_num_0_8=5 + +cpld_name_0_0=CPU_CPLD +cpld_name_0_1=BASE_CPLD +cpld_name_0_2=MAC_CPLDA +cpld_name_0_3=MAC_CPLDB +cpld_name_0_4=FAN_CPLD + +cpld_type_0_0=LATTICE/LCMXO3LF-2100C-5BG256C +cpld_type_0_1=LATTICE/LCMXO3LF-2100C-5BG256C +cpld_type_0_2=LATTICE/LCMXO3LF-2100C-5BG256C +cpld_type_0_3=LATTICE/LCMXO3LF-2100C-5BG256C +cpld_type_0_4=LATTICE/LCMXO3LF-2100C-5BG256C + +cpld_version.mode_0_0=config +cpld_version.int_cons_0_0= +cpld_version.src_0_0=cpld +cpld_version.frmt_0_0=num_bytes +cpld_version.pola_0_0= +cpld_version.fpath_0_0= +cpld_version.addr_0_0=0x00000000 +cpld_version.len_0_0=4 +cpld_version.bit_offset_0_0= + +cpld_version.mode_0_1=config +cpld_version.int_cons_0_1= +cpld_version.src_0_1=cpld +cpld_version.frmt_0_1=num_bytes +cpld_version.pola_0_1= +cpld_version.fpath_0_1= +cpld_version.addr_0_1=0x00010000 +cpld_version.len_0_1=4 +cpld_version.bit_offset_0_1= + +cpld_version.mode_0_2=config +cpld_version.int_cons_0_2= +cpld_version.src_0_2=cpld +cpld_version.frmt_0_2=num_bytes +cpld_version.pola_0_2= +cpld_version.fpath_0_2= +cpld_version.addr_0_2=0x00020000 +cpld_version.len_0_2=4 +cpld_version.bit_offset_0_2= + +cpld_version.mode_0_3=config +cpld_version.int_cons_0_3= +cpld_version.src_0_3=cpld +cpld_version.frmt_0_3=num_bytes +cpld_version.pola_0_3= +cpld_version.fpath_0_3= +cpld_version.addr_0_3=0x00030000 +cpld_version.len_0_3=4 +cpld_version.bit_offset_0_3= + +cpld_version.mode_0_4=config +cpld_version.int_cons_0_4= +cpld_version.src_0_4=cpld +cpld_version.frmt_0_4=num_bytes +cpld_version.pola_0_4= +cpld_version.fpath_0_4= +cpld_version.addr_0_4=0x00040000 +cpld_version.len_0_4=4 +cpld_version.bit_offset_0_4= + +cpld_test_reg.mode_0_0=config +cpld_test_reg.int_cons_0_0= +cpld_test_reg.src_0_0=cpld +cpld_test_reg.frmt_0_0=byte +cpld_test_reg.pola_0_0= +cpld_test_reg.fpath_0_0= +cpld_test_reg.addr_0_0=0x00000005 +cpld_test_reg.len_0_0=1 +cpld_test_reg.bit_offset_0_0= + +cpld_test_reg.mode_0_1=config +cpld_test_reg.int_cons_0_1= +cpld_test_reg.src_0_1=cpld +cpld_test_reg.frmt_0_1=byte +cpld_test_reg.pola_0_1= +cpld_test_reg.fpath_0_1= +cpld_test_reg.addr_0_1=0x000100aa +cpld_test_reg.len_0_1=1 +cpld_test_reg.bit_offset_0_1= + +cpld_test_reg.mode_0_2=config +cpld_test_reg.int_cons_0_2= +cpld_test_reg.src_0_2=cpld +cpld_test_reg.frmt_0_2=byte +cpld_test_reg.pola_0_2= +cpld_test_reg.fpath_0_2= +cpld_test_reg.addr_0_2=0x000200aa +cpld_test_reg.len_0_2=1 +cpld_test_reg.bit_offset_0_2= + +cpld_test_reg.mode_0_3=config +cpld_test_reg.int_cons_0_3= +cpld_test_reg.src_0_3=cpld +cpld_test_reg.frmt_0_3=byte +cpld_test_reg.pola_0_3= +cpld_test_reg.fpath_0_3= +cpld_test_reg.addr_0_3=0x000300aa +cpld_test_reg.len_0_3=1 +cpld_test_reg.bit_offset_0_3= + +cpld_test_reg.mode_0_4=config +cpld_test_reg.int_cons_0_4= +cpld_test_reg.src_0_4=cpld +cpld_test_reg.frmt_0_4=byte +cpld_test_reg.pola_0_4= +cpld_test_reg.fpath_0_4= +cpld_test_reg.addr_0_4=0x000400aa +cpld_test_reg.len_0_4=1 +cpld_test_reg.bit_offset_0_4= diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-FAN.cfg b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-FAN.cfg new file mode 100755 index 000000000000..7017f26e52d0 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-FAN.cfg @@ -0,0 +1,386 @@ +other_i2c_dev.bus_1_1=35 +other_i2c_dev.addr_1_1=0x50 +other_i2c_dev.bus_1_2=34 +other_i2c_dev.addr_1_2=0x50 +other_i2c_dev.bus_1_3=33 +other_i2c_dev.addr_1_3=0x50 +other_i2c_dev.bus_1_4=32 +other_i2c_dev.addr_1_4=0x50 +other_i2c_dev.bus_1_5=31 +other_i2c_dev.addr_1_5=0x50 +other_i2c_dev.bus_1_6=30 +other_i2c_dev.addr_1_6=0x50 + +# fan number +dev_num_1_0=6 + +# fan motor number +dev_num_1_5=2 + +fan_e2_mode=fru + +fan_sysfs_name=eeprom + +fan_direction_0_1=FAN24K4056-F +fan_direction_1_1=FAN24K4056-R + +dev_present_status.mode_1_1=config +dev_present_status.src_1_1=cpld +dev_present_status.frmt_1_1=bit +dev_present_status.pola_1_1=negative +dev_present_status.addr_1_1=0x00040037 +dev_present_status.len_1_1=1 +dev_present_status.bit_offset_1_1=5 + +dev_present_status.mode_1_2=config +dev_present_status.src_1_2=cpld +dev_present_status.frmt_1_2=bit +dev_present_status.pola_1_2=negative +dev_present_status.addr_1_2=0x00040037 +dev_present_status.len_1_2=1 +dev_present_status.bit_offset_1_2=4 + +dev_present_status.mode_1_3=config +dev_present_status.src_1_3=cpld +dev_present_status.frmt_1_3=bit +dev_present_status.pola_1_3=negative +dev_present_status.addr_1_3=0x00040037 +dev_present_status.len_1_3=1 +dev_present_status.bit_offset_1_3=3 + +dev_present_status.mode_1_4=config +dev_present_status.src_1_4=cpld +dev_present_status.frmt_1_4=bit +dev_present_status.pola_1_4=negative +dev_present_status.addr_1_4=0x00040037 +dev_present_status.len_1_4=1 +dev_present_status.bit_offset_1_4=2 + +dev_present_status.mode_1_5=config +dev_present_status.src_1_5=cpld +dev_present_status.frmt_1_5=bit +dev_present_status.pola_1_5=negative +dev_present_status.addr_1_5=0x00040037 +dev_present_status.len_1_5=1 +dev_present_status.bit_offset_1_5=1 + +dev_present_status.mode_1_6=config +dev_present_status.src_1_6=cpld +dev_present_status.frmt_1_6=bit +dev_present_status.pola_1_6=negative +dev_present_status.addr_1_6=0x00040037 +dev_present_status.len_1_6=1 +dev_present_status.bit_offset_1_6=0 + +fan_roll_status.mode_1_1=config +fan_roll_status.int_cons_1_1= +fan_roll_status.src_1_1=cpld +fan_roll_status.frmt_1_1=bit +fan_roll_status.pola_1_1=positive +fan_roll_status.fpath_1_1= +fan_roll_status.addr_1_1=0x00040038 +fan_roll_status.len_1_1=1 +fan_roll_status.bit_offset_1_1=5 + +fan_roll_status.mode_1_2=config +fan_roll_status.int_cons_1_2= +fan_roll_status.src_1_2=cpld +fan_roll_status.frmt_1_2=bit +fan_roll_status.pola_1_2=positive +fan_roll_status.fpath_1_2= +fan_roll_status.addr_1_2=0x00040039 +fan_roll_status.len_1_2=1 +fan_roll_status.bit_offset_1_2=5 + +fan_roll_status.mode_2_1=config +fan_roll_status.int_cons_2_1= +fan_roll_status.src_2_1=cpld +fan_roll_status.frmt_2_1=bit +fan_roll_status.pola_2_1=positive +fan_roll_status.fpath_2_1= +fan_roll_status.addr_2_1=0x00040038 +fan_roll_status.len_2_1=1 +fan_roll_status.bit_offset_2_1=4 + +fan_roll_status.mode_2_2=config +fan_roll_status.int_cons_2_2= +fan_roll_status.src_2_2=cpld +fan_roll_status.frmt_2_2=bit +fan_roll_status.pola_2_2=positive +fan_roll_status.fpath_2_2= +fan_roll_status.addr_2_2=0x00040039 +fan_roll_status.len_2_2=1 +fan_roll_status.bit_offset_2_2=4 + +fan_roll_status.mode_3_1=config +fan_roll_status.int_cons_3_1= +fan_roll_status.src_3_1=cpld +fan_roll_status.frmt_3_1=bit +fan_roll_status.pola_3_1=positive +fan_roll_status.fpath_3_1= +fan_roll_status.addr_3_1=0x00040038 +fan_roll_status.len_3_1=1 +fan_roll_status.bit_offset_3_1=3 + +fan_roll_status.mode_3_2=config +fan_roll_status.int_cons_3_2= +fan_roll_status.src_3_2=cpld +fan_roll_status.frmt_3_2=bit +fan_roll_status.pola_3_2=positive +fan_roll_status.fpath_3_2= +fan_roll_status.addr_3_2=0x00040039 +fan_roll_status.len_3_2=1 +fan_roll_status.bit_offset_3_2=3 + +fan_roll_status.mode_4_1=config +fan_roll_status.int_cons_4_1= +fan_roll_status.src_4_1=cpld +fan_roll_status.frmt_4_1=bit +fan_roll_status.pola_4_1=positive +fan_roll_status.fpath_4_1= +fan_roll_status.addr_4_1=0x00040038 +fan_roll_status.len_4_1=1 +fan_roll_status.bit_offset_4_1=2 + +fan_roll_status.mode_4_2=config +fan_roll_status.int_cons_4_2= +fan_roll_status.src_4_2=cpld +fan_roll_status.frmt_4_2=bit +fan_roll_status.pola_4_2=positive +fan_roll_status.fpath_4_2= +fan_roll_status.addr_4_2=0x00040039 +fan_roll_status.len_4_2=1 +fan_roll_status.bit_offset_4_2=2 + +fan_roll_status.mode_5_1=config +fan_roll_status.int_cons_5_1= +fan_roll_status.src_5_1=cpld +fan_roll_status.frmt_5_1=bit +fan_roll_status.pola_5_1=positive +fan_roll_status.fpath_5_1= +fan_roll_status.addr_5_1=0x00040038 +fan_roll_status.len_5_1=1 +fan_roll_status.bit_offset_5_1=1 + +fan_roll_status.mode_5_2=config +fan_roll_status.int_cons_5_2= +fan_roll_status.src_5_2=cpld +fan_roll_status.frmt_5_2=bit +fan_roll_status.pola_5_2=positive +fan_roll_status.fpath_5_2= +fan_roll_status.addr_5_2=0x00040039 +fan_roll_status.len_5_2=1 +fan_roll_status.bit_offset_5_2=1 + +fan_roll_status.mode_6_1=config +fan_roll_status.int_cons_6_1= +fan_roll_status.src_6_1=cpld +fan_roll_status.frmt_6_1=bit +fan_roll_status.pola_6_1=positive +fan_roll_status.fpath_6_1= +fan_roll_status.addr_6_1=0x00040038 +fan_roll_status.len_6_1=1 +fan_roll_status.bit_offset_6_1=0 + +fan_roll_status.mode_6_2=config +fan_roll_status.int_cons_6_2= +fan_roll_status.src_6_2=cpld +fan_roll_status.frmt_6_2=bit +fan_roll_status.pola_6_2=positive +fan_roll_status.fpath_6_2= +fan_roll_status.addr_6_2=0x00040039 +fan_roll_status.len_6_2=1 +fan_roll_status.bit_offset_6_2=0 + +fan_speed.mode_1_1=config +fan_speed.int_cons_1_1= +fan_speed.src_1_1=cpld +fan_speed.frmt_1_1=num_bytes +fan_speed.pola_1_1=negative +fan_speed.fpath_1_1= +fan_speed.addr_1_1=0x00040070 +fan_speed.len_1_1=2 +fan_speed.bit_offset_1_1= + +fan_speed.mode_1_2=config +fan_speed.int_cons_1_2= +fan_speed.src_1_2=cpld +fan_speed.frmt_1_2=num_bytes +fan_speed.pola_1_2=negative +fan_speed.fpath_1_2= +fan_speed.addr_1_2=0x0004007c +fan_speed.len_1_2=2 +fan_speed.bit_offset_1_2= + +fan_speed.mode_2_1=config +fan_speed.int_cons_2_1= +fan_speed.src_2_1=cpld +fan_speed.frmt_2_1=num_bytes +fan_speed.pola_2_1=negative +fan_speed.fpath_2_1= +fan_speed.addr_2_1=0x0004006e +fan_speed.len_2_1=2 +fan_speed.bit_offset_2_1= + +fan_speed.mode_2_2=config +fan_speed.int_cons_2_2= +fan_speed.src_2_2=cpld +fan_speed.frmt_2_2=num_bytes +fan_speed.pola_2_2=negative +fan_speed.fpath_2_2= +fan_speed.addr_2_2=0x0004007a +fan_speed.len_2_2=2 +fan_speed.bit_offset_2_2= + +fan_speed.mode_3_1=config +fan_speed.int_cons_3_1= +fan_speed.src_3_1=cpld +fan_speed.frmt_3_1=num_bytes +fan_speed.pola_3_1=negative +fan_speed.fpath_3_1= +fan_speed.addr_3_1=0x0004006c +fan_speed.len_3_1=2 +fan_speed.bit_offset_3_1= + +fan_speed.mode_3_2=config +fan_speed.int_cons_3_2= +fan_speed.src_3_2=cpld +fan_speed.frmt_3_2=num_bytes +fan_speed.pola_3_2=negative +fan_speed.fpath_3_2= +fan_speed.addr_3_2=0x00040078 +fan_speed.len_3_2=2 +fan_speed.bit_offset_3_2= + +fan_speed.mode_4_1=config +fan_speed.int_cons_4_1= +fan_speed.src_4_1=cpld +fan_speed.frmt_4_1=num_bytes +fan_speed.pola_4_1=negative +fan_speed.fpath_4_1= +fan_speed.addr_4_1=0x0004006a +fan_speed.len_4_1=2 +fan_speed.bit_offset_4_1= + +fan_speed.mode_4_2=config +fan_speed.int_cons_4_2= +fan_speed.src_4_2=cpld +fan_speed.frmt_4_2=num_bytes +fan_speed.pola_4_2=negative +fan_speed.fpath_4_2= +fan_speed.addr_4_2=0x00040076 +fan_speed.len_4_2=2 +fan_speed.bit_offset_4_2= + +fan_speed.mode_5_1=config +fan_speed.int_cons_5_1= +fan_speed.src_5_1=cpld +fan_speed.frmt_5_1=num_bytes +fan_speed.pola_5_1=negative +fan_speed.fpath_5_1= +fan_speed.addr_5_1=0x00040068 +fan_speed.len_5_1=2 +fan_speed.bit_offset_5_1= + +fan_speed.mode_5_2=config +fan_speed.int_cons_5_2= +fan_speed.src_5_2=cpld +fan_speed.frmt_5_2=num_bytes +fan_speed.pola_5_2=negative +fan_speed.fpath_5_2= +fan_speed.addr_5_2=0x00040074 +fan_speed.len_5_2=2 +fan_speed.bit_offset_5_2= + +fan_speed.mode_6_1=config +fan_speed.int_cons_6_1= +fan_speed.src_6_1=cpld +fan_speed.frmt_6_1=num_bytes +fan_speed.pola_6_1=negative +fan_speed.fpath_6_1= +fan_speed.addr_6_1=0x00040066 +fan_speed.len_6_1=2 +fan_speed.bit_offset_6_1= + +fan_speed.mode_6_2=config +fan_speed.int_cons_6_2= +fan_speed.src_6_2=cpld +fan_speed.frmt_6_2=num_bytes +fan_speed.pola_6_2=negative +fan_speed.fpath_6_2= +fan_speed.addr_6_2=0x00040072 +fan_speed.len_6_2=2 +fan_speed.bit_offset_6_2= + +fan_ratio.mode_1=config +fan_ratio.int_cons_1= +fan_ratio.src_1=cpld +fan_ratio.frmt_1=byte +fan_ratio.pola_1= +fan_ratio.fpath_1= +fan_ratio.addr_1=0x00040065 +fan_ratio.len_1=1 +fan_ratio.bit_offset_1= + +fan_ratio.mode_2=config +fan_ratio.int_cons_2= +fan_ratio.src_2=cpld +fan_ratio.frmt_2=byte +fan_ratio.pola_2= +fan_ratio.fpath_2= +fan_ratio.addr_2=0x00040064 +fan_ratio.len_2=1 +fan_ratio.bit_offset_2= + +fan_ratio.mode_3=config +fan_ratio.int_cons_3= +fan_ratio.src_3=cpld +fan_ratio.frmt_3=byte +fan_ratio.pola_3= +fan_ratio.fpath_3= +fan_ratio.addr_3=0x00040063 +fan_ratio.len_3=1 +fan_ratio.bit_offset_3= + +fan_ratio.mode_4=config +fan_ratio.int_cons_4= +fan_ratio.src_4=cpld +fan_ratio.frmt_4=byte +fan_ratio.pola_4= +fan_ratio.fpath_4= +fan_ratio.addr_4=0x00040062 +fan_ratio.len_4=1 +fan_ratio.bit_offset_4= + +fan_ratio.mode_5=config +fan_ratio.int_cons_5= +fan_ratio.src_5=cpld +fan_ratio.frmt_5=byte +fan_ratio.pola_5= +fan_ratio.fpath_5= +fan_ratio.addr_5=0x00040061 +fan_ratio.len_5=1 +fan_ratio.bit_offset_5= + +fan_ratio.mode_6=config +fan_ratio.int_cons_6= +fan_ratio.src_6=cpld +fan_ratio.frmt_6=byte +fan_ratio.pola_6= +fan_ratio.fpath_6= +fan_ratio.addr_6=0x00040060 +fan_ratio.len_6=1 +fan_ratio.bit_offset_6= + +# display fan name number +dev_num_1_7=2 + +fan_type_num_1=2 +fan_type_num_2=1 + +fan_name_1_1=FAN24K4056-F +fan_name_1_2=FAN24K4056S-F +fan_name_2_1=FAN24K4056S-R + +decode_fan_name_1=FAN24K4056-F +decode_fan_name_2=FAN24K4056-R \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-FPGA.cfg b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-FPGA.cfg new file mode 100755 index 000000000000..b6d1887ef327 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-FPGA.cfg @@ -0,0 +1,41 @@ +# FPGA number +dev_num_0_9=1 + +fpga_name_0_0=MAC_FPGA + + +fpga_version.mode_0_0=config +fpga_version.int_cons_0_0= +fpga_version.src_0_0=file +fpga_version.frmt_0_0=num_bytes +fpga_version.pola_0_0=negative +fpga_version.fpath_0_0=/dev/fpga0 +fpga_version.addr_0_0=0x0 +fpga_version.len_0_0=4 +fpga_version.bit_offset_0_0= + + +fpga_test_reg.mode_0_0=config +fpga_test_reg.int_cons_0_0= +fpga_test_reg.src_0_0=file +fpga_test_reg.frmt_0_0=num_bytes +fpga_test_reg.pola_0_0=negative +fpga_test_reg.fpath_0_0=/dev/fpga0 +fpga_test_reg.addr_0_0=0x08 +fpga_test_reg.len_0_0=4 +fpga_test_reg.bit_offset_0_0= + + +fpga_model_reg.mode_0_0=config +fpga_model_reg.int_cons_0_0= +fpga_model_reg.src_0_0=file +fpga_model_reg.frmt_0_0=num_bytes +fpga_model_reg.pola_0_0=negative +fpga_model_reg.fpath_0_0=/dev/fpga0 +fpga_model_reg.addr_0_0=0xd8 +fpga_model_reg.len_0_0=4 +fpga_model_reg.bit_offset_0_0= + + +fpga_model_decode_0x0=XC7A100T-2FGG484C +fpga_model_decode_0x200=XC7A200T-2FBG484I diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-LED.cfg b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-LED.cfg new file mode 100755 index 000000000000..b365acd11ba5 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-LED.cfg @@ -0,0 +1,89 @@ +led_status.mode_0_0=config +led_status.src_0_0=cpld +led_status.frmt_0_0=bit +led_status.addr_0_0=0x00030040 +led_status.len_0_0=3 + +led_status_decode_0_0=0 +led_status_decode_0_1=7 +led_status_decode_0_2=3 +led_status_decode_0_3=5 +led_status_decode_0_4=1 +led_status_decode_0_5=6 +led_status_decode_0_6=2 +led_status_decode_0_7=0 + +led_status.mode_4_0=config +led_status.src_4_0=cpld +led_status.frmt_4_0=bit +led_status.addr_4_0=0x00030042 +led_status.len_4_0=3 + +led_status_decode_4_0=0 +led_status_decode_4_1=7 +led_status_decode_4_2=3 +led_status_decode_4_3=5 +led_status_decode_4_4=1 +led_status_decode_4_5=6 +led_status_decode_4_6=2 +led_status_decode_4_7=0 + +led_status.mode_6_0=config +led_status.src_6_0=cpld +led_status.frmt_6_0=bit +led_status.addr_6_0=0x00030043 +led_status.len_6_0=3 + +led_status_decode_6_0=0 +led_status_decode_6_1=7 +led_status_decode_6_2=3 +led_status_decode_6_3=5 +led_status_decode_6_4=1 +led_status_decode_6_5=6 +led_status_decode_6_6=2 +led_status_decode_6_7=0 + +led_status.mode_10_1=config +led_status.src_10_1=cpld +led_status.frmt_10_1=bit +led_status.addr_10_1=0x00040041 +led_status.len_10_1=3 + +led_status.mode_10_2=config +led_status.src_10_2=cpld +led_status.frmt_10_2=bit +led_status.addr_10_2=0x00040040 +led_status.len_10_2=3 + +led_status.mode_10_3=config +led_status.src_10_3=cpld +led_status.frmt_10_3=bit +led_status.addr_10_3=0x0004003f +led_status.len_10_3=3 + +led_status.mode_10_4=config +led_status.src_10_4=cpld +led_status.frmt_10_4=bit +led_status.addr_10_4=0x0004003e +led_status.len_10_4=3 + +led_status.mode_10_5=config +led_status.src_10_5=cpld +led_status.frmt_10_5=bit +led_status.addr_10_5=0x0004003d +led_status.len_10_5=3 + +led_status.mode_10_6=config +led_status.src_10_6=cpld +led_status.frmt_10_6=bit +led_status.addr_10_6=0x0004003c +led_status.len_10_6=3 + +led_status_decode_10_0=0 +led_status_decode_10_1=7 +led_status_decode_10_2=3 +led_status_decode_10_3=5 +led_status_decode_10_4=1 +led_status_decode_10_5=6 +led_status_decode_10_6=2 +led_status_decode_10_7=0 diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-PSU.cfg b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-PSU.cfg new file mode 100755 index 000000000000..be125d484f18 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-PSU.cfg @@ -0,0 +1,325 @@ +# psu number +dev_num_2_0=2 + +# psu temp number +dev_num_2_1=3 + +other_i2c_dev.bus_2_1=41 +other_i2c_dev.addr_2_1=0x50 +other_i2c_dev.bus_2_2=42 +other_i2c_dev.addr_2_2=0x50 + +psu_pmbus_id_1_11=0x29005880 +psu_pmbus_id_2_11=0x2a005880 + +psu_status.mode_1_0=config +psu_status.src_1_0=cpld +psu_status.frmt_1_0=bit +psu_status.pola_1_0=negative +psu_status.addr_1_0=0x00020034 +psu_status.len_1_0=1 +psu_status.bit_offset_1_0=0 + +psu_status.mode_1_1=config +psu_status.src_1_1=cpld +psu_status.frmt_1_1=bit +psu_status.pola_1_1=positive +psu_status.addr_1_1=0x00020034 +psu_status.len_1_1=1 +psu_status.bit_offset_1_1=1 + +psu_status.mode_1_2=config +psu_status.src_1_2=cpld +psu_status.frmt_1_2=bit +psu_status.pola_1_2=positive +psu_status.addr_1_2=0x00020034 +psu_status.len_1_2=1 +psu_status.bit_offset_1_2=2 + +psu_status.mode_2_0=config +psu_status.src_2_0=cpld +psu_status.frmt_2_0=bit +psu_status.pola_2_0=negative +psu_status.addr_2_0=0x00020034 +psu_status.len_2_0=1 +psu_status.bit_offset_2_0=4 + +psu_status.mode_2_1=config +psu_status.src_2_1=cpld +psu_status.frmt_2_1=bit +psu_status.pola_2_1=positive +psu_status.addr_2_1=0x00020034 +psu_status.len_2_1=1 +psu_status.bit_offset_2_1=5 + +psu_status.mode_2_2=config +psu_status.src_2_2=cpld +psu_status.frmt_2_2=bit +psu_status.pola_2_2=positive +psu_status.addr_2_2=0x00020034 +psu_status.len_2_2=1 +psu_status.bit_offset_2_2=6 + +# 0:None 1:in_vol 2:in_curr 3:in_power 4:out_vol 5:out_curr 6:out_power 7:fan +# psu1 in_vol +hwmon_psu.mode_1_1=config +hwmon_psu.int_cons_1_1=0 +hwmon_psu.src_1_1=file +hwmon_psu.frmt_1_1=buf +hwmon_psu.fpath_1_1=/sys/bus/i2c/devices/41-0058/hwmon/ +hwmon_psu.addr_1_1=0 +hwmon_psu.len_1_1=8 +hwmon_psu.bit_offset_1_1= +hwmon_psu.str_cons_1_1=in1_input + +# psu1 in_curr +hwmon_psu.mode_1_2=config +hwmon_psu.int_cons_1_2=0 +hwmon_psu.src_1_2=file +hwmon_psu.frmt_1_2=buf +hwmon_psu.fpath_1_2=/sys/bus/i2c/devices/41-0058/hwmon/ +hwmon_psu.addr_1_2=0 +hwmon_psu.len_1_2=8 +hwmon_psu.bit_offset_1_2= +hwmon_psu.str_cons_1_2=curr1_input + +# psu1 in_power +hwmon_psu.mode_1_3=config +hwmon_psu.int_cons_1_3=0 +hwmon_psu.src_1_3=file +hwmon_psu.frmt_1_3=buf +hwmon_psu.fpath_1_3=/sys/bus/i2c/devices/41-0058/hwmon/ +hwmon_psu.addr_1_3=0 +hwmon_psu.len_1_3=16 +hwmon_psu.bit_offset_1_3= +hwmon_psu.str_cons_1_3=power1_input + +# psu1 out_vol +hwmon_psu.mode_1_4=config +hwmon_psu.int_cons_1_4=0 +hwmon_psu.src_1_4=file +hwmon_psu.frmt_1_4=buf +hwmon_psu.fpath_1_4=/sys/bus/i2c/devices/41-0058/hwmon/ +hwmon_psu.addr_1_4=0 +hwmon_psu.len_1_4=8 +hwmon_psu.bit_offset_1_4= +hwmon_psu.str_cons_1_4=in2_input + +# psu1 out_curr +hwmon_psu.mode_1_5=config +hwmon_psu.int_cons_1_5=0 +hwmon_psu.src_1_5=file +hwmon_psu.frmt_1_5=buf +hwmon_psu.fpath_1_5=/sys/bus/i2c/devices/41-0058/hwmon/ +hwmon_psu.addr_1_5=0 +hwmon_psu.len_1_5=8 +hwmon_psu.bit_offset_1_5= +hwmon_psu.str_cons_1_5=curr2_input + +# psu1 out_power +hwmon_psu.mode_1_6=config +hwmon_psu.int_cons_1_6=0 +hwmon_psu.src_1_6=file +hwmon_psu.frmt_1_6=buf +hwmon_psu.fpath_1_6=/sys/bus/i2c/devices/41-0058/hwmon/ +hwmon_psu.addr_1_6=0 +hwmon_psu.len_1_6=16 +hwmon_psu.bit_offset_1_6= +hwmon_psu.str_cons_1_6=power2_input + +# psu1 fan +hwmon_psu.mode_1_7=config +hwmon_psu.int_cons_1_7= +hwmon_psu.src_1_7=file +hwmon_psu.frmt_1_7=buf +hwmon_psu.fpath_1_7=/sys/bus/i2c/devices/41-0058/hwmon/ +hwmon_psu.addr_1_7=0 +hwmon_psu.len_1_7=8 +hwmon_psu.bit_offset_1_7= +hwmon_psu.str_cons_1_7=fan1_input + +# psu2 in_vol +hwmon_psu.mode_2_1=config +hwmon_psu.int_cons_2_1=0 +hwmon_psu.src_2_1=file +hwmon_psu.frmt_2_1=buf +hwmon_psu.fpath_2_1=/sys/bus/i2c/devices/42-0058/hwmon/ +hwmon_psu.addr_2_1=0 +hwmon_psu.len_2_1=8 +hwmon_psu.bit_offset_2_1= +hwmon_psu.str_cons_2_1=in1_input + +# psu2 in_curr +hwmon_psu.mode_2_2=config +hwmon_psu.int_cons_2_2=0 +hwmon_psu.src_2_2=file +hwmon_psu.frmt_2_2=buf +hwmon_psu.fpath_2_2=/sys/bus/i2c/devices/42-0058/hwmon/ +hwmon_psu.addr_2_2=0 +hwmon_psu.len_2_2=8 +hwmon_psu.bit_offset_2_2= +hwmon_psu.str_cons_2_2=curr1_input + +# psu2 in_power +hwmon_psu.mode_2_3=config +hwmon_psu.int_cons_2_3=0 +hwmon_psu.src_2_3=file +hwmon_psu.frmt_2_3=buf +hwmon_psu.fpath_2_3=/sys/bus/i2c/devices/42-0058/hwmon/ +hwmon_psu.addr_2_3=0 +hwmon_psu.len_2_3=16 +hwmon_psu.bit_offset_2_3= +hwmon_psu.str_cons_2_3=power1_input + +# psu2 out_vol +hwmon_psu.mode_2_4=config +hwmon_psu.int_cons_2_4=0 +hwmon_psu.src_2_4=file +hwmon_psu.frmt_2_4=buf +hwmon_psu.fpath_2_4=/sys/bus/i2c/devices/42-0058/hwmon/ +hwmon_psu.addr_2_4=0 +hwmon_psu.len_2_4=8 +hwmon_psu.bit_offset_2_4= +hwmon_psu.str_cons_2_4=in2_input + +# psu2 out_curr +hwmon_psu.mode_2_5=config +hwmon_psu.int_cons_2_5=0 +hwmon_psu.src_2_5=file +hwmon_psu.frmt_2_5=buf +hwmon_psu.fpath_2_5=/sys/bus/i2c/devices/42-0058/hwmon/ +hwmon_psu.addr_2_5=0 +hwmon_psu.len_2_5=8 +hwmon_psu.bit_offset_2_5= +hwmon_psu.str_cons_2_5=curr2_input + +# psu2 out_power +hwmon_psu.mode_2_6=config +hwmon_psu.int_cons_2_6=0 +hwmon_psu.src_2_6=file +hwmon_psu.frmt_2_6=buf +hwmon_psu.fpath_2_6=/sys/bus/i2c/devices/42-0058/hwmon/ +hwmon_psu.addr_2_6=0 +hwmon_psu.len_2_6=16 +hwmon_psu.bit_offset_2_6= +hwmon_psu.str_cons_2_6=power2_input + +# psu2 fan +hwmon_psu.mode_2_7=config +hwmon_psu.int_cons_2_7= +hwmon_psu.src_2_7=file +hwmon_psu.frmt_2_7=buf +hwmon_psu.fpath_2_7=/sys/bus/i2c/devices/42-0058/hwmon/ +hwmon_psu.addr_2_7=0 +hwmon_psu.len_2_7=8 +hwmon_psu.bit_offset_2_7= +hwmon_psu.str_cons_2_7=fan1_input + +# 2:type 3:max 4:max_hyst 5:min 6:crit + +# psu1 temp1 input +hwmon_temp.mode_0x0101_0x20=config +hwmon_temp.int_cons_0x0101_0x20=0 +hwmon_temp.src_0x0101_0x20=file +hwmon_temp.frmt_0x0101_0x20=buf +hwmon_temp.fpath_0x0101_0x20=/sys/bus/i2c/devices/41-0058/hwmon/ +hwmon_temp.addr_0x0101_0x20=0 +hwmon_temp.len_0x0101_0x20=8 +hwmon_temp.bit_offset_0x0101_0x20= +hwmon_temp.str_cons_0x0101_0x20=temp1_input + +# psu1 temp1 alias +hwmon_temp.mode_0x0101_0x21=str_constant +hwmon_temp.str_cons_0x0101_0x21=temp1 + +# psu1 temp2 input +hwmon_temp.mode_0x0102_0x20=config +hwmon_temp.int_cons_0x0102_0x20=0 +hwmon_temp.src_0x0102_0x20=file +hwmon_temp.frmt_0x0102_0x20=buf +hwmon_temp.fpath_0x0102_0x20=/sys/bus/i2c/devices/41-0058/hwmon/ +hwmon_temp.addr_0x0102_0x20=0 +hwmon_temp.len_0x0102_0x20=8 +hwmon_temp.bit_offset_0x0102_0x20= +hwmon_temp.str_cons_0x0102_0x20=temp2_input + +# psu1 temp2 alias +hwmon_temp.mode_0x0102_0x21=str_constant +hwmon_temp.str_cons_0x0102_0x21=temp2 + +# psu1 temp3 input +hwmon_temp.mode_0x0103_0x20=config +hwmon_temp.int_cons_0x0103_0x20=0 +hwmon_temp.src_0x0103_0x20=file +hwmon_temp.frmt_0x0103_0x20=buf +hwmon_temp.fpath_0x0103_0x20=/sys/bus/i2c/devices/41-0058/hwmon/ +hwmon_temp.addr_0x0103_0x20=0 +hwmon_temp.len_0x0103_0x20=8 +hwmon_temp.bit_offset_0x0103_0x20= +hwmon_temp.str_cons_0x0103_0x20=temp3_input + +# psu1 temp3 alias +hwmon_temp.mode_0x0103_0x21=str_constant +hwmon_temp.str_cons_0x0103_0x21=temp3 + +# psu2 temp1 input +hwmon_temp.mode_0x0201_0x20=config +hwmon_temp.int_cons_0x0201_0x20=0 +hwmon_temp.src_0x0201_0x20=file +hwmon_temp.frmt_0x0201_0x20=buf +hwmon_temp.fpath_0x0201_0x20=/sys/bus/i2c/devices/42-0058/hwmon/ +hwmon_temp.addr_0x0201_0x20=0 +hwmon_temp.len_0x0201_0x20=8 +hwmon_temp.bit_offset_0x0201_0x20= +hwmon_temp.str_cons_0x0201_0x20=temp1_input + +# psu2 temp1 alias +hwmon_temp.mode_0x0201_0x21=str_constant +hwmon_temp.str_cons_0x0201_0x21=temp1 + +# psu2 temp2 input +hwmon_temp.mode_0x0202_0x20=config +hwmon_temp.int_cons_0x0202_0x20=0 +hwmon_temp.src_0x0202_0x20=file +hwmon_temp.frmt_0x0202_0x20=buf +hwmon_temp.fpath_0x0202_0x20=/sys/bus/i2c/devices/42-0058/hwmon/ +hwmon_temp.addr_0x0202_0x20=0 +hwmon_temp.len_0x0202_0x20=8 +hwmon_temp.bit_offset_0x0202_0x20= +hwmon_temp.str_cons_0x0202_0x20=temp2_input + +# psu2 temp2 alias +hwmon_temp.mode_0x0202_0x21=str_constant +hwmon_temp.str_cons_0x0202_0x21=temp2 + +# psu2 temp3 input +hwmon_temp.mode_0x0203_0x20=config +hwmon_temp.int_cons_0x0203_0x20=0 +hwmon_temp.src_0x0203_0x20=file +hwmon_temp.frmt_0x0203_0x20=buf +hwmon_temp.fpath_0x0203_0x20=/sys/bus/i2c/devices/42-0058/hwmon/ +hwmon_temp.addr_0x0203_0x20=0 +hwmon_temp.len_0x0203_0x20=8 +hwmon_temp.bit_offset_0x0203_0x20= +hwmon_temp.str_cons_0x0203_0x20=temp3_input + +# psu2 temp3 alias +hwmon_temp.mode_0x0203_0x21=str_constant +hwmon_temp.str_cons_0x0203_0x21=temp3 + +# display psu name number +dev_num_2_6=2 + +power_name_1_1=DPS-1300AB-6 +power_name_1_2=GW-CRPS1300D +power_name_2_1=DPS-1300AB-11 +power_name_2_2=CRPS1300D3R + +decode_power_name_1=PSA1300CRPS-F +decode_power_name_2=PSA1300CRPS-R + +power_rate_supply_1=1300000000 +power_rate_supply_2=1300000000 + +decode_power_fan_dir_1=0 +decode_power_fan_dir_2=1 \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-SENSOR.cfg b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-SENSOR.cfg new file mode 100755 index 000000000000..24028725ced6 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-SENSOR.cfg @@ -0,0 +1,1348 @@ +# temp sensor number +dev_num_0_1=21 + +# voltage sensor number +dev_num_0_2=30 + +# current sensor number +dev_num_0_3=7 + +# sensor temp1 input +hwmon_temp.mode_0x0001_0x00=config +hwmon_temp.int_cons_0x0001_0x00=0 +hwmon_temp.src_0x0001_0x00=file +hwmon_temp.frmt_0x0001_0x00=buf +hwmon_temp.fpath_0x0001_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0001_0x00=0 +hwmon_temp.len_0x0001_0x00=8 +hwmon_temp.bit_offset_0x0001_0x00= +hwmon_temp.str_cons_0x0001_0x00=temp1_input + +# sensor temp1 alias +hwmon_temp.mode_0x0001_0x01=config +hwmon_temp.int_cons_0x0001_0x01= +hwmon_temp.src_0x0001_0x01=file +hwmon_temp.frmt_0x0001_0x01=buf +hwmon_temp.fpath_0x0001_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0001_0x01=0 +hwmon_temp.len_0x0001_0x01=16 +hwmon_temp.bit_offset_0x0001_0x01= +hwmon_temp.str_cons_0x0001_0x01=temp1_label + +hwmon_temp.mode_0x0001_0x02=str_constant +hwmon_temp.str_cons_0x0001_0x02=cpu + +# sensor temp1 max +hwmon_temp.mode_0x0001_0x03=config +hwmon_temp.int_cons_0x0001_0x03=0 +hwmon_temp.src_0x0001_0x03=file +hwmon_temp.frmt_0x0001_0x03=buf +hwmon_temp.fpath_0x0001_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0001_0x03=0 +hwmon_temp.len_0x0001_0x03=8 +hwmon_temp.bit_offset_0x0001_0x03= +hwmon_temp.str_cons_0x0001_0x03=temp1_max + + +# sensor temp2 input +hwmon_temp.mode_0x0002_0x00=config +hwmon_temp.int_cons_0x0002_0x00=0 +hwmon_temp.src_0x0002_0x00=file +hwmon_temp.frmt_0x0002_0x00=buf +hwmon_temp.fpath_0x0002_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0002_0x00=0 +hwmon_temp.len_0x0002_0x00=8 +hwmon_temp.bit_offset_0x0002_0x00= +hwmon_temp.str_cons_0x0002_0x00=temp2_input + +# sensor temp2 alias +hwmon_temp.mode_0x0002_0x01=config +hwmon_temp.int_cons_0x0002_0x01= +hwmon_temp.src_0x0002_0x01=file +hwmon_temp.frmt_0x0002_0x01=buf +hwmon_temp.fpath_0x0002_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0002_0x01=0 +hwmon_temp.len_0x0002_0x01=16 +hwmon_temp.bit_offset_0x0002_0x01= +hwmon_temp.str_cons_0x0002_0x01=temp2_label + +hwmon_temp.mode_0x0002_0x02=str_constant +hwmon_temp.str_cons_0x0002_0x02=cpu + +# sensor temp2 max +hwmon_temp.mode_0x0002_0x03=config +hwmon_temp.int_cons_0x0002_0x03=0 +hwmon_temp.src_0x0002_0x03=file +hwmon_temp.frmt_0x0002_0x03=buf +hwmon_temp.fpath_0x0002_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0002_0x03=0 +hwmon_temp.len_0x0002_0x03=8 +hwmon_temp.bit_offset_0x0002_0x03= +hwmon_temp.str_cons_0x0002_0x03=temp2_max + + +# sensor temp3 input +hwmon_temp.mode_0x0003_0x00=config +hwmon_temp.int_cons_0x0003_0x00=0 +hwmon_temp.src_0x0003_0x00=file +hwmon_temp.frmt_0x0003_0x00=buf +hwmon_temp.fpath_0x0003_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0003_0x00=0 +hwmon_temp.len_0x0003_0x00=8 +hwmon_temp.bit_offset_0x0003_0x00= +hwmon_temp.str_cons_0x0003_0x00=temp3_input + +# sensor temp3 alias +hwmon_temp.mode_0x0003_0x01=config +hwmon_temp.int_cons_0x0003_0x01= +hwmon_temp.src_0x0003_0x01=file +hwmon_temp.frmt_0x0003_0x01=buf +hwmon_temp.fpath_0x0003_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0003_0x01=0 +hwmon_temp.len_0x0003_0x01=16 +hwmon_temp.bit_offset_0x0003_0x01= +hwmon_temp.str_cons_0x0003_0x01=temp3_label + +hwmon_temp.mode_0x0003_0x02=str_constant +hwmon_temp.str_cons_0x0003_0x02=cpu + +# sensor temp3 max +hwmon_temp.mode_0x0003_0x03=config +hwmon_temp.int_cons_0x0003_0x03=0 +hwmon_temp.src_0x0003_0x03=file +hwmon_temp.frmt_0x0003_0x03=buf +hwmon_temp.fpath_0x0003_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0003_0x03=0 +hwmon_temp.len_0x0003_0x03=8 +hwmon_temp.bit_offset_0x0003_0x03= +hwmon_temp.str_cons_0x0003_0x03=temp3_max + + +# sensor temp4 input +hwmon_temp.mode_0x0004_0x00=config +hwmon_temp.int_cons_0x0004_0x00=0 +hwmon_temp.src_0x0004_0x00=file +hwmon_temp.frmt_0x0004_0x00=buf +hwmon_temp.fpath_0x0004_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0004_0x00=0 +hwmon_temp.len_0x0004_0x00=8 +hwmon_temp.bit_offset_0x0004_0x00= +hwmon_temp.str_cons_0x0004_0x00=temp4_input + +# sensor temp4 alias +hwmon_temp.mode_0x0004_0x01=config +hwmon_temp.int_cons_0x0004_0x01= +hwmon_temp.src_0x0004_0x01=file +hwmon_temp.frmt_0x0004_0x01=buf +hwmon_temp.fpath_0x0004_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0004_0x01=0 +hwmon_temp.len_0x0004_0x01=16 +hwmon_temp.bit_offset_0x0004_0x01= +hwmon_temp.str_cons_0x0004_0x01=temp4_label + +hwmon_temp.mode_0x0004_0x02=str_constant +hwmon_temp.str_cons_0x0004_0x02=cpu + +# sensor temp4 max +hwmon_temp.mode_0x0004_0x03=config +hwmon_temp.int_cons_0x0004_0x03=0 +hwmon_temp.src_0x0004_0x03=file +hwmon_temp.frmt_0x0004_0x03=buf +hwmon_temp.fpath_0x0004_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0004_0x03=0 +hwmon_temp.len_0x0004_0x03=8 +hwmon_temp.bit_offset_0x0004_0x03= +hwmon_temp.str_cons_0x0004_0x03=temp4_max + + +# sensor temp5 input +hwmon_temp.mode_0x0005_0x00=config +hwmon_temp.int_cons_0x0005_0x00=0 +hwmon_temp.src_0x0005_0x00=file +hwmon_temp.frmt_0x0005_0x00=buf +hwmon_temp.fpath_0x0005_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0005_0x00=0 +hwmon_temp.len_0x0005_0x00=8 +hwmon_temp.bit_offset_0x0005_0x00= +hwmon_temp.str_cons_0x0005_0x00=temp5_input + +# sensor temp5 alias +hwmon_temp.mode_0x0005_0x01=config +hwmon_temp.int_cons_0x0005_0x01= +hwmon_temp.src_0x0005_0x01=file +hwmon_temp.frmt_0x0005_0x01=buf +hwmon_temp.fpath_0x0005_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0005_0x01=0 +hwmon_temp.len_0x0005_0x01=16 +hwmon_temp.bit_offset_0x0005_0x01= +hwmon_temp.str_cons_0x0005_0x01=temp5_label + +hwmon_temp.mode_0x0005_0x02=str_constant +hwmon_temp.str_cons_0x0005_0x02=cpu + +# sensor temp5 max +hwmon_temp.mode_0x0005_0x03=config +hwmon_temp.int_cons_0x0005_0x03=0 +hwmon_temp.src_0x0005_0x03=file +hwmon_temp.frmt_0x0005_0x03=buf +hwmon_temp.fpath_0x0005_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0005_0x03=0 +hwmon_temp.len_0x0005_0x03=8 +hwmon_temp.bit_offset_0x0005_0x03= +hwmon_temp.str_cons_0x0005_0x03=temp5_max + +# sensor temp6 input +hwmon_temp.mode_0x0006_0x00=config +hwmon_temp.int_cons_0x0006_0x00=3 +hwmon_temp.src_0x0006_0x00=file +hwmon_temp.frmt_0x0006_0x00=buf +hwmon_temp.fpath_0x0006_0x00=/sys/bus/i2c/devices/40-004f/hwmon/ +hwmon_temp.addr_0x0006_0x00=0 +hwmon_temp.len_0x0006_0x00=8 +hwmon_temp.bit_offset_0x0006_0x00=0 +hwmon_temp.str_cons_0x0006_0x00=temp1_input +hwmon_temp.int_extra1_0x0006_0x00=1000 +hwmon_temp.int_extra2_0x0006_0x00=-3000 + +# sensor temp6 alias +hwmon_temp.mode_0x0006_0x01=str_constant +hwmon_temp.str_cons_0x0006_0x01=air_inlet_TL + +# sensor temp6 type +hwmon_temp.mode_0x0006_0x02=str_constant +hwmon_temp.str_cons_0x0006_0x02=lm75 + +# sensor temp6 max +hwmon_temp.mode_0x0006_0x03=config +hwmon_temp.int_cons_0x0006_0x03=0 +hwmon_temp.src_0x0006_0x03=file +hwmon_temp.frmt_0x0006_0x03=buf +hwmon_temp.fpath_0x0006_0x03=/sys/bus/i2c/devices/40-004f/hwmon/ +hwmon_temp.addr_0x0006_0x03=0 +hwmon_temp.len_0x0006_0x03=8 +hwmon_temp.bit_offset_0x0006_0x03= +hwmon_temp.str_cons_0x0006_0x03=temp1_max + +# sensor temp6 max_hyst +hwmon_temp.mode_0x0006_0x04=config +hwmon_temp.int_cons_0x0006_0x04=0 +hwmon_temp.src_0x0006_0x04=file +hwmon_temp.frmt_0x0006_0x04=buf +hwmon_temp.fpath_0x0006_0x04=/sys/bus/i2c/devices/40-004f/hwmon/ +hwmon_temp.addr_0x0006_0x04=0 +hwmon_temp.len_0x0006_0x04=8 +hwmon_temp.bit_offset_0x0006_0x04= +hwmon_temp.str_cons_0x0006_0x04=temp1_max_hyst + + +# sensor temp7 input +hwmon_temp.mode_0x0007_0x00=config +hwmon_temp.int_cons_0x0007_0x00=0 +hwmon_temp.src_0x0007_0x00=file +hwmon_temp.frmt_0x0007_0x00=buf +hwmon_temp.fpath_0x0007_0x00=/sys/bus/i2c/devices/39-004b/hwmon/ +hwmon_temp.addr_0x0007_0x00=0 +hwmon_temp.len_0x0007_0x00=8 +hwmon_temp.bit_offset_0x0007_0x00= +hwmon_temp.str_cons_0x0007_0x00=temp1_input + +# sensor temp7 alias +hwmon_temp.mode_0x0007_0x01=str_constant +hwmon_temp.str_cons_0x0007_0x01=air_inlet_BL + +# sensor temp7 type +hwmon_temp.mode_0x0007_0x02=str_constant +hwmon_temp.str_cons_0x0007_0x02=lm75 + +# sensor temp7 max +hwmon_temp.mode_0x0007_0x03=config +hwmon_temp.int_cons_0x0007_0x03=0 +hwmon_temp.src_0x0007_0x03=file +hwmon_temp.frmt_0x0007_0x03=buf +hwmon_temp.fpath_0x0007_0x03=/sys/bus/i2c/devices/39-004b/hwmon/ +hwmon_temp.addr_0x0007_0x03=0 +hwmon_temp.len_0x0007_0x03=8 +hwmon_temp.bit_offset_0x0007_0x03= +hwmon_temp.str_cons_0x0007_0x03=temp1_max + +# sensor temp7 max_hyst +hwmon_temp.mode_0x0007_0x04=config +hwmon_temp.int_cons_0x0007_0x04=0 +hwmon_temp.src_0x0007_0x04=file +hwmon_temp.frmt_0x0007_0x04=buf +hwmon_temp.fpath_0x0007_0x04=/sys/bus/i2c/devices/39-004b/hwmon/ +hwmon_temp.addr_0x0007_0x04=0 +hwmon_temp.len_0x0007_0x04=8 +hwmon_temp.bit_offset_0x0007_0x04= +hwmon_temp.str_cons_0x0007_0x04=temp1_max_hyst + + +# sensor temp8 input +hwmon_temp.mode_0x0008_0x00=config +hwmon_temp.int_cons_0x0008_0x00=0 +hwmon_temp.src_0x0008_0x00=file +hwmon_temp.frmt_0x0008_0x00=buf +hwmon_temp.fpath_0x0008_0x00=/sys/bus/i2c/devices/36-0048/hwmon/ +hwmon_temp.addr_0x0008_0x00=0 +hwmon_temp.len_0x0008_0x00=8 +hwmon_temp.bit_offset_0x0008_0x00= +hwmon_temp.str_cons_0x0008_0x00=temp1_input + +# sensor temp8 alias +hwmon_temp.mode_0x0008_0x01=str_constant +hwmon_temp.str_cons_0x0008_0x01=air_outlet_L + +# sensor temp8 type +hwmon_temp.mode_0x0008_0x02=str_constant +hwmon_temp.str_cons_0x0008_0x02=lm75 + +# sensor temp8 max +hwmon_temp.mode_0x0008_0x03=config +hwmon_temp.int_cons_0x0008_0x03=0 +hwmon_temp.src_0x0008_0x03=file +hwmon_temp.frmt_0x0008_0x03=buf +hwmon_temp.fpath_0x0008_0x03=/sys/bus/i2c/devices/36-0048/hwmon/ +hwmon_temp.addr_0x0008_0x03=0 +hwmon_temp.len_0x0008_0x03=8 +hwmon_temp.bit_offset_0x0008_0x03= +hwmon_temp.str_cons_0x0008_0x03=temp1_max + +# sensor temp8 max_hyst +hwmon_temp.mode_0x0008_0x04=config +hwmon_temp.int_cons_0x0008_0x04=0 +hwmon_temp.src_0x0008_0x04=file +hwmon_temp.frmt_0x0008_0x04=buf +hwmon_temp.fpath_0x0008_0x04=/sys/bus/i2c/devices/36-0048/hwmon/ +hwmon_temp.addr_0x0008_0x04=0 +hwmon_temp.len_0x0008_0x04=8 +hwmon_temp.bit_offset_0x0008_0x04= +hwmon_temp.str_cons_0x0008_0x04=temp1_max_hyst + + +# sensor temp9 input +hwmon_temp.mode_0x0009_0x00=config +hwmon_temp.int_cons_0x0009_0x00=0 +hwmon_temp.src_0x0009_0x00=file +hwmon_temp.frmt_0x0009_0x00=buf +hwmon_temp.fpath_0x0009_0x00=/sys/bus/i2c/devices/36-0049/hwmon/ +hwmon_temp.addr_0x0009_0x00=0 +hwmon_temp.len_0x0009_0x00=8 +hwmon_temp.bit_offset_0x0009_0x00= +hwmon_temp.str_cons_0x0009_0x00=temp1_input + +# sensor temp9 alias +hwmon_temp.mode_0x0009_0x01=str_constant +hwmon_temp.str_cons_0x0009_0x01=air_outlet_R + +# sensor temp9 type +hwmon_temp.mode_0x0009_0x02=str_constant +hwmon_temp.str_cons_0x0009_0x02=lm75 + +# sensor temp9 max +hwmon_temp.mode_0x0009_0x03=config +hwmon_temp.int_cons_0x0009_0x03=0 +hwmon_temp.src_0x0009_0x03=file +hwmon_temp.frmt_0x0009_0x03=buf +hwmon_temp.fpath_0x0009_0x03=/sys/bus/i2c/devices/36-0049/hwmon/ +hwmon_temp.addr_0x0009_0x03=0 +hwmon_temp.len_0x0009_0x03=8 +hwmon_temp.bit_offset_0x0009_0x03= +hwmon_temp.str_cons_0x0009_0x03=temp1_max + +# sensor temp9 max_hyst +hwmon_temp.mode_0x0009_0x04=config +hwmon_temp.int_cons_0x0009_0x04=0 +hwmon_temp.src_0x0009_0x04=file +hwmon_temp.frmt_0x0009_0x04=buf +hwmon_temp.fpath_0x0009_0x04=/sys/bus/i2c/devices/36-0049/hwmon/ +hwmon_temp.addr_0x0009_0x04=0 +hwmon_temp.len_0x0009_0x04=8 +hwmon_temp.bit_offset_0x0009_0x04= +hwmon_temp.str_cons_0x0009_0x04=temp1_max_hyst + + +# sensor temp10 input +hwmon_temp.mode_0x000a_0x00=config +hwmon_temp.int_cons_0x000a_0x00=0 +hwmon_temp.src_0x000a_0x00=file +hwmon_temp.frmt_0x000a_0x00=buf +hwmon_temp.fpath_0x000a_0x00=/sys/bus/i2c/devices/40-004e/hwmon/ +hwmon_temp.addr_0x000a_0x00=0 +hwmon_temp.len_0x000a_0x00=8 +hwmon_temp.bit_offset_0x000a_0x00= +hwmon_temp.str_cons_0x000a_0x00=temp1_input + +# sensor temp10 alias +hwmon_temp.mode_0x000a_0x01=str_constant +hwmon_temp.str_cons_0x000a_0x01=air_hotlet + +# sensor temp10 type +hwmon_temp.mode_0x000a_0x02=str_constant +hwmon_temp.str_cons_0x000a_0x02=lm75 + +# sensor temp10 max +hwmon_temp.mode_0x000a_0x03=config +hwmon_temp.int_cons_0x000a_0x03=0 +hwmon_temp.src_0x000a_0x03=file +hwmon_temp.frmt_0x000a_0x03=buf +hwmon_temp.fpath_0x000a_0x03=/sys/bus/i2c/devices/40-004e/hwmon/ +hwmon_temp.addr_0x000a_0x03=0 +hwmon_temp.len_0x000a_0x03=8 +hwmon_temp.bit_offset_0x000a_0x03= +hwmon_temp.str_cons_0x000a_0x03=temp1_max + +# sensor temp10 max_hyst +hwmon_temp.mode_0x000a_0x04=config +hwmon_temp.int_cons_0x000a_0x04=0 +hwmon_temp.src_0x000a_0x04=file +hwmon_temp.frmt_0x000a_0x04=buf +hwmon_temp.fpath_0x000a_0x04=/sys/bus/i2c/devices/40-004e/hwmon/ +hwmon_temp.addr_0x000a_0x04=0 +hwmon_temp.len_0x000a_0x04=8 +hwmon_temp.bit_offset_0x000a_0x04= +hwmon_temp.str_cons_0x000a_0x04=temp1_max_hyst + + +# sensor temp11 input +hwmon_temp.mode_0x000b_0x00=config +hwmon_temp.int_cons_0x000b_0x00=0 +hwmon_temp.src_0x000b_0x00=file +hwmon_temp.frmt_0x000b_0x00=buf +hwmon_temp.fpath_0x000b_0x00=/sys/bus/i2c/devices/39-004c/hwmon/ +hwmon_temp.addr_0x000b_0x00=0 +hwmon_temp.len_0x000b_0x00=8 +hwmon_temp.bit_offset_0x000b_0x00= +hwmon_temp.str_cons_0x000b_0x00=temp2_input + +# sensor temp11 alias +hwmon_temp.mode_0x000b_0x01=str_constant +hwmon_temp.str_cons_0x000b_0x01=MAC_PACKAGE0 + +# sensor temp11 type +hwmon_temp.mode_0x000b_0x02=str_constant +hwmon_temp.str_cons_0x000b_0x02=tmp411 + +# sensor temp11 max +hwmon_temp.mode_0x000b_0x03=config +hwmon_temp.int_cons_0x000b_0x03=0 +hwmon_temp.src_0x000b_0x03=file +hwmon_temp.frmt_0x000b_0x03=buf +hwmon_temp.fpath_0x000b_0x03=/sys/bus/i2c/devices/39-004c/hwmon/ +hwmon_temp.addr_0x000b_0x03=0 +hwmon_temp.len_0x000b_0x03=8 +hwmon_temp.bit_offset_0x000b_0x03= +hwmon_temp.str_cons_0x000b_0x03=temp2_max + +# sensor temp12 input +hwmon_temp.mode_0x000c_0x00=config +hwmon_temp.int_cons_0x000c_0x00=0 +hwmon_temp.src_0x000c_0x00=file +hwmon_temp.frmt_0x000c_0x00=buf +hwmon_temp.fpath_0x000c_0x00=/sys/bus/i2c/devices/40-004c/hwmon/ +hwmon_temp.addr_0x000c_0x00=0 +hwmon_temp.len_0x000c_0x00=8 +hwmon_temp.bit_offset_0x000c_0x00= +hwmon_temp.str_cons_0x000c_0x00=temp2_input + +# sensor temp12 alias +hwmon_temp.mode_0x000c_0x01=str_constant +hwmon_temp.str_cons_0x000c_0x01=MAC_PACKAGE1 + +# sensor temp12 type +hwmon_temp.mode_0x000c_0x02=str_constant +hwmon_temp.str_cons_0x000c_0x02=tmp411 + +# sensor temp12 max +hwmon_temp.mode_0x000c_0x03=config +hwmon_temp.int_cons_0x000c_0x03=0 +hwmon_temp.src_0x000c_0x03=file +hwmon_temp.frmt_0x000c_0x03=buf +hwmon_temp.fpath_0x000c_0x03=/sys/bus/i2c/devices/40-004c/hwmon/ +hwmon_temp.addr_0x000c_0x03=0 +hwmon_temp.len_0x000c_0x03=8 +hwmon_temp.bit_offset_0x000c_0x03= +hwmon_temp.str_cons_0x000c_0x03=temp2_max + +# sensor temp13 input +hwmon_temp.mode_0x000d_0x00=config +hwmon_temp.int_cons_0x000d_0x00=0 +hwmon_temp.src_0x000d_0x00=file +hwmon_temp.frmt_0x000d_0x00=buf +hwmon_temp.fpath_0x000d_0x00=/sys/bus/i2c/devices/44-0044/hwmon/ +hwmon_temp.addr_0x000d_0x00=0 +hwmon_temp.len_0x000d_0x00=16 +hwmon_temp.bit_offset_0x000d_0x00= +hwmon_temp.str_cons_0x000d_0x00=temp1_input + +# sensor temp13 alias +hwmon_temp.mode_0x000d_0x01=str_constant +hwmon_temp.str_cons_0x000d_0x01=MAC_DIE_0 + +# sensor temp13 type +hwmon_temp.mode_0x000d_0x02=str_constant +hwmon_temp.str_cons_0x000d_0x02=mac_bsc + + +# sensor temp14 input +hwmon_temp.mode_0x000e_0x00=config +hwmon_temp.int_cons_0x000e_0x00=0 +hwmon_temp.src_0x000e_0x00=file +hwmon_temp.frmt_0x000e_0x00=buf +hwmon_temp.fpath_0x000e_0x00=/sys/bus/i2c/devices/44-0044/hwmon/ +hwmon_temp.addr_0x000e_0x00=0 +hwmon_temp.len_0x000e_0x00=16 +hwmon_temp.bit_offset_0x000e_0x00= +hwmon_temp.str_cons_0x000e_0x00=temp2_input + +# sensor temp14 alias +hwmon_temp.mode_0x000e_0x01=str_constant +hwmon_temp.str_cons_0x000e_0x01=MAC_DIE_1 + +# sensor temp14 type +hwmon_temp.mode_0x000e_0x02=str_constant +hwmon_temp.str_cons_0x000e_0x02=mac_bsc + + +# sensor temp15 input +hwmon_temp.mode_0x000f_0x00=config +hwmon_temp.int_cons_0x000f_0x00=0 +hwmon_temp.src_0x000f_0x00=file +hwmon_temp.frmt_0x000f_0x00=buf +hwmon_temp.fpath_0x000f_0x00=/sys/bus/i2c/devices/44-0044/hwmon/ +hwmon_temp.addr_0x000f_0x00=0 +hwmon_temp.len_0x000f_0x00=16 +hwmon_temp.bit_offset_0x000f_0x00= +hwmon_temp.str_cons_0x000f_0x00=temp3_input + +# sensor temp15 alias +hwmon_temp.mode_0x000f_0x01=str_constant +hwmon_temp.str_cons_0x000f_0x01=MAC_DIE_2 + +# sensor temp15 type +hwmon_temp.mode_0x000f_0x02=str_constant +hwmon_temp.str_cons_0x000f_0x02=mac_bsc + + +# sensor temp16 input +hwmon_temp.mode_0x0010_0x00=config +hwmon_temp.int_cons_0x0010_0x00=0 +hwmon_temp.src_0x0010_0x00=file +hwmon_temp.frmt_0x0010_0x00=buf +hwmon_temp.fpath_0x0010_0x00=/sys/bus/i2c/devices/44-0044/hwmon/ +hwmon_temp.addr_0x0010_0x00=0 +hwmon_temp.len_0x0010_0x00=16 +hwmon_temp.bit_offset_0x0010_0x00= +hwmon_temp.str_cons_0x0010_0x00=temp4_input + +# sensor temp16 alias +hwmon_temp.mode_0x0010_0x01=str_constant +hwmon_temp.str_cons_0x0010_0x01=MAC_DIE_3 + +# sensor temp16 type +hwmon_temp.mode_0x0010_0x02=str_constant +hwmon_temp.str_cons_0x0010_0x02=mac_bsc + + +# sensor temp17 input +hwmon_temp.mode_0x0011_0x00=config +hwmon_temp.int_cons_0x0011_0x00=0 +hwmon_temp.src_0x0011_0x00=file +hwmon_temp.frmt_0x0011_0x00=buf +hwmon_temp.fpath_0x0011_0x00=/sys/bus/i2c/devices/44-0044/hwmon/ +hwmon_temp.addr_0x0011_0x00=0 +hwmon_temp.len_0x0011_0x00=16 +hwmon_temp.bit_offset_0x0011_0x00= +hwmon_temp.str_cons_0x0011_0x00=temp5_input + +# sensor temp17 alias +hwmon_temp.mode_0x0011_0x01=str_constant +hwmon_temp.str_cons_0x0011_0x01=MAC_DIE_4 + +# sensor temp17 type +hwmon_temp.mode_0x0011_0x02=str_constant +hwmon_temp.str_cons_0x0011_0x02=mac_bsc + + +# sensor temp18 input +hwmon_temp.mode_0x0012_0x00=config +hwmon_temp.int_cons_0x0012_0x00=0 +hwmon_temp.src_0x0012_0x00=file +hwmon_temp.frmt_0x0012_0x00=buf +hwmon_temp.fpath_0x0012_0x00=/sys/bus/i2c/devices/44-0044/hwmon/ +hwmon_temp.addr_0x0012_0x00=0 +hwmon_temp.len_0x0012_0x00=16 +hwmon_temp.bit_offset_0x0012_0x00= +hwmon_temp.str_cons_0x0012_0x00=temp6_input + +# sensor temp18 alias +hwmon_temp.mode_0x0012_0x01=str_constant +hwmon_temp.str_cons_0x0012_0x01=MAC_DIE_5 + +# sensor temp18 type +hwmon_temp.mode_0x0012_0x02=str_constant +hwmon_temp.str_cons_0x0012_0x02=mac_bsc + + +# sensor temp19 input +hwmon_temp.mode_0x0013_0x00=config +hwmon_temp.int_cons_0x0013_0x00=0 +hwmon_temp.src_0x0013_0x00=file +hwmon_temp.frmt_0x0013_0x00=buf +hwmon_temp.fpath_0x0013_0x00=/sys/bus/i2c/devices/44-0044/hwmon/ +hwmon_temp.addr_0x0013_0x00=0 +hwmon_temp.len_0x0013_0x00=16 +hwmon_temp.bit_offset_0x0013_0x00= +hwmon_temp.str_cons_0x0013_0x00=temp7_input + +# sensor temp19 alias +hwmon_temp.mode_0x0013_0x01=str_constant +hwmon_temp.str_cons_0x0013_0x01=MAC_DIE_6 + +# sensor temp19 type +hwmon_temp.mode_0x0013_0x02=str_constant +hwmon_temp.str_cons_0x0013_0x02=mac_bsc + + +# sensor temp20 input +hwmon_temp.mode_0x0014_0x00=config +hwmon_temp.int_cons_0x0014_0x00=0 +hwmon_temp.src_0x0014_0x00=file +hwmon_temp.frmt_0x0014_0x00=buf +hwmon_temp.fpath_0x0014_0x00=/sys/bus/i2c/devices/44-0044/hwmon/ +hwmon_temp.addr_0x0014_0x00=0 +hwmon_temp.len_0x0014_0x00=16 +hwmon_temp.bit_offset_0x0014_0x00= +hwmon_temp.str_cons_0x0014_0x00=temp8_input + +# sensor temp20 alias +hwmon_temp.mode_0x0014_0x01=str_constant +hwmon_temp.str_cons_0x0014_0x01=MAC_DIE_7 + +# sensor temp20 type +hwmon_temp.mode_0x0014_0x02=str_constant +hwmon_temp.str_cons_0x0014_0x02=mac_bsc + + +# sensor temp21 input +hwmon_temp.mode_0x0015_0x00=config +hwmon_temp.int_cons_0x0015_0x00=0 +hwmon_temp.src_0x0015_0x00=file +hwmon_temp.frmt_0x0015_0x00=buf +hwmon_temp.fpath_0x0015_0x00=/sys/bus/i2c/devices/44-0044/hwmon/ +hwmon_temp.addr_0x0015_0x00=0 +hwmon_temp.len_0x0015_0x00=16 +hwmon_temp.bit_offset_0x0015_0x00= +hwmon_temp.str_cons_0x0015_0x00=temp9_input + +# sensor temp21 alias +hwmon_temp.mode_0x0015_0x01=str_constant +hwmon_temp.str_cons_0x0015_0x01=MAC_DIE_8 + +# sensor temp21 type +hwmon_temp.mode_0x0015_0x02=str_constant +hwmon_temp.str_cons_0x0015_0x02=mac_bsc + + +# 2:type 3:max 4:max_hyst 5:min 6:crit +# in1 +hwmon_in.mode_0x0001_0x00=config +hwmon_in.int_cons_0x0001_0x00=0 +hwmon_in.src_0x0001_0x00=file +hwmon_in.frmt_0x0001_0x00=buf +hwmon_in.fpath_0x0001_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0001_0x00=0 +hwmon_in.len_0x0001_0x00=8 +hwmon_in.bit_offset_0x0001_0x00= +hwmon_in.str_cons_0x0001_0x00=in1_input +hwmon_in.mode_0x0001_0x01=str_constant +hwmon_in.str_cons_0x0001_0x01=MAC_BOARD_VDD5V_CLK_MCU +hwmon_in.mode_0x0001_0x02=str_constant +hwmon_in.str_cons_0x0001_0x02=ucd90160 +hwmon_in.mode_0x0001_0x03=constant +hwmon_in.int_cons_0x0001_0x03=5345 +hwmon_in.mode_0x0001_0x05=constant +hwmon_in.int_cons_0x0001_0x05=4840 +# in2 +hwmon_in.mode_0x0002_0x00=config +hwmon_in.int_cons_0x0002_0x00=0 +hwmon_in.src_0x0002_0x00=file +hwmon_in.frmt_0x0002_0x00=buf +hwmon_in.fpath_0x0002_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0002_0x00=0 +hwmon_in.len_0x0002_0x00=8 +hwmon_in.bit_offset_0x0002_0x00= +hwmon_in.str_cons_0x0002_0x00=in2_input +hwmon_in.mode_0x0002_0x01=str_constant +hwmon_in.str_cons_0x0002_0x01=MAC_BOARD_VDD3.3_CLK +hwmon_in.mode_0x0002_0x02=str_constant +hwmon_in.str_cons_0x0002_0x02=ucd90160 +hwmon_in.mode_0x0002_0x03=constant +hwmon_in.int_cons_0x0002_0x03=3560 +hwmon_in.mode_0x0002_0x05=constant +hwmon_in.int_cons_0x0002_0x05=3220 +# in3 +hwmon_in.mode_0x0003_0x00=config +hwmon_in.int_cons_0x0003_0x00=0 +hwmon_in.src_0x0003_0x00=file +hwmon_in.frmt_0x0003_0x00=buf +hwmon_in.fpath_0x0003_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0003_0x00=0 +hwmon_in.len_0x0003_0x00=8 +hwmon_in.bit_offset_0x0003_0x00= +hwmon_in.str_cons_0x0003_0x00=in3_input +hwmon_in.mode_0x0003_0x01=str_constant +hwmon_in.str_cons_0x0003_0x01=MAC_BOARD_VDD1.0V +hwmon_in.mode_0x0003_0x02=str_constant +hwmon_in.str_cons_0x0003_0x02=ucd90160 +hwmon_in.mode_0x0003_0x03=constant +hwmon_in.int_cons_0x0003_0x03=1049 +hwmon_in.mode_0x0003_0x05=constant +hwmon_in.int_cons_0x0003_0x05=950 +# in4 +hwmon_in.mode_0x0004_0x00=config +hwmon_in.int_cons_0x0004_0x00=0 +hwmon_in.src_0x0004_0x00=file +hwmon_in.frmt_0x0004_0x00=buf +hwmon_in.fpath_0x0004_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0004_0x00=0 +hwmon_in.len_0x0004_0x00=8 +hwmon_in.bit_offset_0x0004_0x00= +hwmon_in.str_cons_0x0004_0x00=in4_input +hwmon_in.mode_0x0004_0x01=str_constant +hwmon_in.str_cons_0x0004_0x01=MAC_BOARD_VDD1.8V +hwmon_in.mode_0x0004_0x02=str_constant +hwmon_in.str_cons_0x0004_0x02=ucd90160 +hwmon_in.mode_0x0004_0x03=constant +hwmon_in.int_cons_0x0004_0x03=1903 +hwmon_in.mode_0x0004_0x05=constant +hwmon_in.int_cons_0x0004_0x05=1720 +# in5 +hwmon_in.mode_0x0005_0x00=config +hwmon_in.int_cons_0x0005_0x00=0 +hwmon_in.src_0x0005_0x00=file +hwmon_in.frmt_0x0005_0x00=buf +hwmon_in.fpath_0x0005_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0005_0x00=0 +hwmon_in.len_0x0005_0x00=8 +hwmon_in.bit_offset_0x0005_0x00= +hwmon_in.str_cons_0x0005_0x00=in5_input +hwmon_in.mode_0x0005_0x01=str_constant +hwmon_in.str_cons_0x0005_0x01=MAC_BOARD_VDD3.3V +hwmon_in.mode_0x0005_0x02=str_constant +hwmon_in.str_cons_0x0005_0x02=ucd90160 +hwmon_in.mode_0x0005_0x03=constant +hwmon_in.int_cons_0x0005_0x03=3499 +hwmon_in.mode_0x0005_0x05=constant +hwmon_in.int_cons_0x0005_0x05=3170 +# in6 +hwmon_in.mode_0x0006_0x00=config +hwmon_in.int_cons_0x0006_0x00=0 +hwmon_in.src_0x0006_0x00=file +hwmon_in.frmt_0x0006_0x00=buf +hwmon_in.fpath_0x0006_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0006_0x00=0 +hwmon_in.len_0x0006_0x00=8 +hwmon_in.bit_offset_0x0006_0x00= +hwmon_in.str_cons_0x0006_0x00=in6_input +hwmon_in.mode_0x0006_0x01=str_constant +hwmon_in.str_cons_0x0006_0x01=MAC_BOARD_VDD1.2V +hwmon_in.mode_0x0006_0x02=str_constant +hwmon_in.str_cons_0x0006_0x02=ucd90160 +hwmon_in.mode_0x0006_0x03=constant +hwmon_in.int_cons_0x0006_0x03=1272 +hwmon_in.mode_0x0006_0x05=constant +hwmon_in.int_cons_0x0006_0x05=1150 +# in7 +hwmon_in.mode_0x0007_0x00=config +hwmon_in.int_cons_0x0007_0x00=0 +hwmon_in.src_0x0007_0x00=file +hwmon_in.frmt_0x0007_0x00=buf +hwmon_in.fpath_0x0007_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0007_0x00=0 +hwmon_in.len_0x0007_0x00=8 +hwmon_in.bit_offset_0x0007_0x00= +hwmon_in.str_cons_0x0007_0x00=in7_input +hwmon_in.mode_0x0007_0x01=str_constant +hwmon_in.str_cons_0x0007_0x01=MAC_BOARD_VDD_CORE +hwmon_in.mode_0x0007_0x02=str_constant +hwmon_in.str_cons_0x0007_0x02=ucd90160 +hwmon_in.mode_0x0007_0x03=constant +hwmon_in.int_cons_0x0007_0x03=950 +hwmon_in.mode_0x0007_0x05=constant +hwmon_in.int_cons_0x0007_0x05=670 +# in8 +hwmon_in.mode_0x0008_0x00=config +hwmon_in.int_cons_0x0008_0x00=0 +hwmon_in.src_0x0008_0x00=file +hwmon_in.frmt_0x0008_0x00=buf +hwmon_in.fpath_0x0008_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0008_0x00=0 +hwmon_in.len_0x0008_0x00=8 +hwmon_in.bit_offset_0x0008_0x00= +hwmon_in.str_cons_0x0008_0x00=in8_input +hwmon_in.mode_0x0008_0x01=str_constant +hwmon_in.str_cons_0x0008_0x01=MAC_BOARD_ANALOG0.75V +hwmon_in.mode_0x0008_0x02=str_constant +hwmon_in.str_cons_0x0008_0x02=ucd90160 +hwmon_in.mode_0x0008_0x03=constant +hwmon_in.int_cons_0x0008_0x03=800 +hwmon_in.mode_0x0008_0x05=constant +hwmon_in.int_cons_0x0008_0x05=700 +# in9 +hwmon_in.mode_0x0009_0x00=config +hwmon_in.int_cons_0x0009_0x00=0 +hwmon_in.src_0x0009_0x00=file +hwmon_in.frmt_0x0009_0x00=buf +hwmon_in.fpath_0x0009_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0009_0x00=0 +hwmon_in.len_0x0009_0x00=8 +hwmon_in.bit_offset_0x0009_0x00= +hwmon_in.str_cons_0x0009_0x00=in9_input +hwmon_in.mode_0x0009_0x01=str_constant +hwmon_in.str_cons_0x0009_0x01=MAC_BOARD_MAC_VDD1.2V +hwmon_in.mode_0x0009_0x02=str_constant +hwmon_in.str_cons_0x0009_0x02=ucd90160 +hwmon_in.mode_0x0009_0x03=constant +hwmon_in.int_cons_0x0009_0x03=1259 +hwmon_in.mode_0x0009_0x05=constant +hwmon_in.int_cons_0x0009_0x05=1140 +# in10 +hwmon_in.mode_0x000a_0x00=config +hwmon_in.int_cons_0x000a_0x00=0 +hwmon_in.src_0x000a_0x00=file +hwmon_in.frmt_0x000a_0x00=buf +hwmon_in.fpath_0x000a_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x000a_0x00=0 +hwmon_in.len_0x000a_0x00=8 +hwmon_in.bit_offset_0x000a_0x00= +hwmon_in.str_cons_0x000a_0x00=in10_input +hwmon_in.mode_0x000a_0x01=str_constant +hwmon_in.str_cons_0x000a_0x01=MAC_BOARD_VDDO1.8V +hwmon_in.mode_0x000a_0x02=str_constant +hwmon_in.str_cons_0x000a_0x02=ucd90160 +hwmon_in.mode_0x000a_0x03=constant +hwmon_in.int_cons_0x000a_0x03=1937 +hwmon_in.mode_0x000a_0x05=constant +hwmon_in.int_cons_0x000a_0x05=1750 +# in11 +hwmon_in.mode_0x000b_0x00=config +hwmon_in.int_cons_0x000b_0x00=0 +hwmon_in.src_0x000b_0x00=file +hwmon_in.frmt_0x000b_0x00=buf +hwmon_in.fpath_0x000b_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x000b_0x00=0 +hwmon_in.len_0x000b_0x00=8 +hwmon_in.bit_offset_0x000b_0x00= +hwmon_in.str_cons_0x000b_0x00=in11_input +hwmon_in.mode_0x000b_0x01=str_constant +hwmon_in.str_cons_0x000b_0x01=MAC_BOARD_MAC_ANA1.2V +hwmon_in.mode_0x000b_0x02=str_constant +hwmon_in.str_cons_0x000b_0x02=ucd90160 +hwmon_in.mode_0x000b_0x03=constant +hwmon_in.int_cons_0x000b_0x03=1276 +hwmon_in.mode_0x000b_0x05=constant +hwmon_in.int_cons_0x000b_0x05=1150 +# in12 +hwmon_in.mode_0x000c_0x00=config +hwmon_in.int_cons_0x000c_0x00=0 +hwmon_in.src_0x000c_0x00=file +hwmon_in.frmt_0x000c_0x00=buf +hwmon_in.fpath_0x000c_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x000c_0x00=0 +hwmon_in.len_0x000c_0x00=8 +hwmon_in.bit_offset_0x000c_0x00= +hwmon_in.str_cons_0x000c_0x00=in12_input +hwmon_in.mode_0x000c_0x01=str_constant +hwmon_in.str_cons_0x000c_0x01=MAC_BOARD_MAC_ANA1.8V +hwmon_in.mode_0x000c_0x02=str_constant +hwmon_in.str_cons_0x000c_0x02=ucd90160 +hwmon_in.mode_0x000c_0x03=constant +hwmon_in.int_cons_0x000c_0x03=1910 +hwmon_in.mode_0x000c_0x05=constant +hwmon_in.int_cons_0x000c_0x05=1730 +# in13 +hwmon_in.mode_0x000d_0x00=config +hwmon_in.int_cons_0x000d_0x00=0 +hwmon_in.src_0x000d_0x00=file +hwmon_in.frmt_0x000d_0x00=buf +hwmon_in.fpath_0x000d_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x000d_0x00=0 +hwmon_in.len_0x000d_0x00=8 +hwmon_in.bit_offset_0x000d_0x00= +hwmon_in.str_cons_0x000d_0x00=in13_input +hwmon_in.mode_0x000d_0x01=str_constant +hwmon_in.str_cons_0x000d_0x01=MAC_BOARD_QSFP56_VDD3.3V_A +hwmon_in.mode_0x000d_0x02=str_constant +hwmon_in.str_cons_0x000d_0x02=ucd90160 +hwmon_in.mode_0x000d_0x03=constant +hwmon_in.int_cons_0x000d_0x03=3595 +hwmon_in.mode_0x000d_0x05=constant +hwmon_in.int_cons_0x000d_0x05=3250 +# in14 +hwmon_in.mode_0x000e_0x00=config +hwmon_in.int_cons_0x000e_0x00=0 +hwmon_in.src_0x000e_0x00=file +hwmon_in.frmt_0x000e_0x00=buf +hwmon_in.fpath_0x000e_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x000e_0x00=0 +hwmon_in.len_0x000e_0x00=8 +hwmon_in.bit_offset_0x000e_0x00= +hwmon_in.str_cons_0x000e_0x00=in14_input +hwmon_in.mode_0x000e_0x01=str_constant +hwmon_in.str_cons_0x000e_0x01=MAC_BOARD_QSFP56_VDD3.3V_B +hwmon_in.mode_0x000e_0x02=str_constant +hwmon_in.str_cons_0x000e_0x02=ucd90160 +hwmon_in.mode_0x000e_0x03=constant +hwmon_in.int_cons_0x000e_0x03=3601 +hwmon_in.mode_0x000e_0x05=constant +hwmon_in.int_cons_0x000e_0x05=3260 +# in15 +hwmon_in.mode_0x000f_0x00=config +hwmon_in.int_cons_0x000f_0x00=0 +hwmon_in.src_0x000f_0x00=file +hwmon_in.frmt_0x000f_0x00=buf +hwmon_in.fpath_0x000f_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x000f_0x00=0 +hwmon_in.len_0x000f_0x00=8 +hwmon_in.bit_offset_0x000f_0x00= +hwmon_in.str_cons_0x000f_0x00=in15_input +hwmon_in.mode_0x000f_0x01=str_constant +hwmon_in.str_cons_0x000f_0x01=MAC_BOARD_QSFPDD_VDD3.3V_A +hwmon_in.mode_0x000f_0x02=str_constant +hwmon_in.str_cons_0x000f_0x02=ucd90160 +hwmon_in.mode_0x000f_0x03=constant +hwmon_in.int_cons_0x000f_0x03=3565 +hwmon_in.mode_0x000f_0x05=constant +hwmon_in.int_cons_0x000f_0x05=3230 +# in16 +hwmon_in.mode_0x0010_0x00=config +hwmon_in.int_cons_0x0010_0x00=0 +hwmon_in.src_0x0010_0x00=file +hwmon_in.frmt_0x0010_0x00=buf +hwmon_in.fpath_0x0010_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0010_0x00=0 +hwmon_in.len_0x0010_0x00=8 +hwmon_in.bit_offset_0x0010_0x00= +hwmon_in.str_cons_0x0010_0x00=in16_input +hwmon_in.mode_0x0010_0x01=str_constant +hwmon_in.str_cons_0x0010_0x01=MAC_BOARD_QSFPDD_VDD3.3V_B +hwmon_in.mode_0x0010_0x02=str_constant +hwmon_in.str_cons_0x0010_0x02=ucd90160 +hwmon_in.mode_0x0010_0x03=constant +hwmon_in.int_cons_0x0010_0x03=3564 +hwmon_in.mode_0x0010_0x05=constant +hwmon_in.int_cons_0x0010_0x05=3220 +# in17 +hwmon_in.mode_0x0011_0x00=config +hwmon_in.int_cons_0x0011_0x00=0 +hwmon_in.src_0x0011_0x00=file +hwmon_in.frmt_0x0011_0x00=buf +hwmon_in.fpath_0x0011_0x00=/sys/bus/i2c/devices/24-005b/hwmon/ +hwmon_in.addr_0x0011_0x00=0 +hwmon_in.len_0x0011_0x00=8 +hwmon_in.bit_offset_0x0011_0x00= +hwmon_in.str_cons_0x0011_0x00=in1_input +hwmon_in.mode_0x0011_0x01=str_constant +hwmon_in.str_cons_0x0011_0x01=CPU_CONNECT_VDD5.0V +hwmon_in.mode_0x0011_0x02=str_constant +hwmon_in.str_cons_0x0011_0x02=ucd90160 +hwmon_in.mode_0x0011_0x03=constant +hwmon_in.int_cons_0x0011_0x03=5429 +hwmon_in.mode_0x0011_0x05=constant +hwmon_in.int_cons_0x0011_0x05=4910 +# in18 +hwmon_in.mode_0x0012_0x00=config +hwmon_in.int_cons_0x0012_0x00=0 +hwmon_in.src_0x0012_0x00=file +hwmon_in.frmt_0x0012_0x00=buf +hwmon_in.fpath_0x0012_0x00=/sys/bus/i2c/devices/24-005b/hwmon/ +hwmon_in.addr_0x0012_0x00=0 +hwmon_in.len_0x0012_0x00=8 +hwmon_in.bit_offset_0x0012_0x00= +hwmon_in.str_cons_0x0012_0x00=in2_input +hwmon_in.mode_0x0012_0x01=str_constant +hwmon_in.str_cons_0x0012_0x01=CPU_CONNECT_SW_VDD1.2V +hwmon_in.mode_0x0012_0x02=str_constant +hwmon_in.str_cons_0x0012_0x02=ucd90160 +hwmon_in.mode_0x0012_0x03=constant +hwmon_in.int_cons_0x0012_0x03=1284 +hwmon_in.mode_0x0012_0x05=constant +hwmon_in.int_cons_0x0012_0x05=1160 +# in19 +hwmon_in.mode_0x0013_0x00=config +hwmon_in.int_cons_0x0013_0x00=0 +hwmon_in.src_0x0013_0x00=file +hwmon_in.frmt_0x0013_0x00=buf +hwmon_in.fpath_0x0013_0x00=/sys/bus/i2c/devices/24-005b/hwmon/ +hwmon_in.addr_0x0013_0x00=0 +hwmon_in.len_0x0013_0x00=8 +hwmon_in.bit_offset_0x0013_0x00= +hwmon_in.str_cons_0x0013_0x00=in3_input +hwmon_in.mode_0x0013_0x01=str_constant +hwmon_in.str_cons_0x0013_0x01=CPU_CONNECT_VDD2.5V +hwmon_in.mode_0x0013_0x02=str_constant +hwmon_in.str_cons_0x0013_0x02=ucd90160 +hwmon_in.mode_0x0013_0x03=constant +hwmon_in.int_cons_0x0013_0x03=2620 +hwmon_in.mode_0x0013_0x05=constant +hwmon_in.int_cons_0x0013_0x05=2370 +# in20 +hwmon_in.mode_0x0014_0x00=config +hwmon_in.int_cons_0x0014_0x00=0 +hwmon_in.src_0x0014_0x00=file +hwmon_in.frmt_0x0014_0x00=buf +hwmon_in.fpath_0x0014_0x00=/sys/bus/i2c/devices/24-005b/hwmon/ +hwmon_in.addr_0x0014_0x00=0 +hwmon_in.len_0x0014_0x00=8 +hwmon_in.bit_offset_0x0014_0x00= +hwmon_in.str_cons_0x0014_0x00=in4_input +hwmon_in.mode_0x0014_0x01=str_constant +hwmon_in.str_cons_0x0014_0x01=CPU_CONNECT_VDD3.3V +hwmon_in.mode_0x0014_0x02=str_constant +hwmon_in.str_cons_0x0014_0x02=ucd90160 +hwmon_in.mode_0x0014_0x03=constant +hwmon_in.int_cons_0x0014_0x03=3437 +hwmon_in.mode_0x0014_0x05=constant +hwmon_in.int_cons_0x0014_0x05=3110 +# in22 +hwmon_in.mode_0x0016_0x00=config +hwmon_in.int_cons_0x0016_0x00=0 +hwmon_in.src_0x0016_0x00=file +hwmon_in.frmt_0x0016_0x00=buf +hwmon_in.fpath_0x0016_0x00=/sys/bus/i2c/devices/24-005b/hwmon/ +hwmon_in.addr_0x0016_0x00=0 +hwmon_in.len_0x0016_0x00=8 +hwmon_in.bit_offset_0x0016_0x00= +hwmon_in.str_cons_0x0016_0x00=in6_input +hwmon_in.mode_0x0016_0x01=str_constant +hwmon_in.str_cons_0x0016_0x01=CPU_CONNECT_VDD12V +hwmon_in.mode_0x0016_0x02=str_constant +hwmon_in.str_cons_0x0016_0x02=ucd90160 +hwmon_in.mode_0x0016_0x03=constant +hwmon_in.int_cons_0x0016_0x03=12700 +hwmon_in.mode_0x0016_0x05=constant +hwmon_in.int_cons_0x0016_0x05=11300 +# in23 +hwmon_in.mode_0x0017_0x00=config +hwmon_in.int_cons_0x0017_0x00=0 +hwmon_in.src_0x0017_0x00=file +hwmon_in.frmt_0x0017_0x00=buf +hwmon_in.fpath_0x0017_0x00=/sys/bus/i2c/devices/24-005b/hwmon/ +hwmon_in.addr_0x0017_0x00=0 +hwmon_in.len_0x0017_0x00=8 +hwmon_in.bit_offset_0x0017_0x00= +hwmon_in.str_cons_0x0017_0x00=in7_input +hwmon_in.mode_0x0017_0x01=str_constant +hwmon_in.str_cons_0x0017_0x01=CPU_CONNECT_VDD3.3_STBY +hwmon_in.mode_0x0017_0x02=str_constant +hwmon_in.str_cons_0x0017_0x02=ucd90160 +hwmon_in.mode_0x0017_0x03=constant +hwmon_in.int_cons_0x0017_0x03=3489 +hwmon_in.mode_0x0017_0x05=constant +hwmon_in.int_cons_0x0017_0x05=3160 +# in24 +hwmon_in.mode_0x0018_0x00=config +hwmon_in.int_cons_0x0018_0x00=0 +hwmon_in.src_0x0018_0x00=file +hwmon_in.frmt_0x0018_0x00=buf +hwmon_in.fpath_0x0018_0x00=/sys/bus/i2c/devices/24-005b/hwmon/ +hwmon_in.addr_0x0018_0x00=0 +hwmon_in.len_0x0018_0x00=8 +hwmon_in.bit_offset_0x0018_0x00= +hwmon_in.str_cons_0x0018_0x00=in8_input +hwmon_in.mode_0x0018_0x01=str_constant +hwmon_in.str_cons_0x0018_0x01=CPU_CONNECT_SSD_VDD3.3V +hwmon_in.mode_0x0018_0x02=str_constant +hwmon_in.str_cons_0x0018_0x02=ucd90160 +hwmon_in.mode_0x0018_0x03=constant +hwmon_in.int_cons_0x0018_0x03=3475 +hwmon_in.mode_0x0018_0x05=constant +hwmon_in.int_cons_0x0018_0x05=3140 +# in25 +hwmon_in.mode_0x0019_0x00=config +hwmon_in.int_cons_0x0019_0x00=0 +hwmon_in.src_0x0019_0x00=file +hwmon_in.frmt_0x0019_0x00=buf +hwmon_in.fpath_0x0019_0x00=/sys/bus/i2c/devices/25-0060/hwmon/ +hwmon_in.addr_0x0019_0x00=0 +hwmon_in.len_0x0019_0x00=8 +hwmon_in.bit_offset_0x0019_0x00= +hwmon_in.str_cons_0x0019_0x00=in3_input +hwmon_in.mode_0x0019_0x01=str_constant +hwmon_in.str_cons_0x0019_0x01=CPU_VCCIN +hwmon_in.mode_0x0019_0x02=str_constant +hwmon_in.str_cons_0x0019_0x02=tps53622 +hwmon_in.mode_0x0019_0x03=constant +hwmon_in.int_cons_0x0019_0x03=1879 +hwmon_in.mode_0x0019_0x05=constant +hwmon_in.int_cons_0x0019_0x05=1700 +# in26 +hwmon_in.mode_0x001a_0x00=config +hwmon_in.int_cons_0x001a_0x00=0 +hwmon_in.src_0x001a_0x00=file +hwmon_in.frmt_0x001a_0x00=buf +hwmon_in.fpath_0x001a_0x00=/sys/bus/i2c/devices/25-0060/hwmon/ +hwmon_in.addr_0x001a_0x00=0 +hwmon_in.len_0x001a_0x00=8 +hwmon_in.bit_offset_0x001a_0x00= +hwmon_in.str_cons_0x001a_0x00=in4_input +hwmon_in.mode_0x001a_0x01=str_constant +hwmon_in.str_cons_0x001a_0x01=CPU_P1V05 +hwmon_in.mode_0x001a_0x02=str_constant +hwmon_in.str_cons_0x001a_0x02=tps53622 +hwmon_in.mode_0x001a_0x03=constant +hwmon_in.int_cons_0x001a_0x03=1103 +hwmon_in.mode_0x001a_0x05=constant +hwmon_in.int_cons_0x001a_0x05=1000 +# in27 +hwmon_in.mode_0x001b_0x00=config +hwmon_in.int_cons_0x001b_0x00=0 +hwmon_in.src_0x001b_0x00=file +hwmon_in.frmt_0x001b_0x00=buf +hwmon_in.fpath_0x001b_0x00=/sys/bus/i2c/devices/25-006c/hwmon/ +hwmon_in.addr_0x001b_0x00=0 +hwmon_in.len_0x001b_0x00=8 +hwmon_in.bit_offset_0x001b_0x00= +hwmon_in.str_cons_0x001b_0x00=in3_input +hwmon_in.mode_0x001b_0x01=str_constant +hwmon_in.str_cons_0x001b_0x01=CPU_P1V2_VDDQ +hwmon_in.mode_0x001b_0x02=str_constant +hwmon_in.str_cons_0x001b_0x02=tps53622 +hwmon_in.mode_0x001b_0x03=constant +hwmon_in.int_cons_0x001b_0x03=1258 +hwmon_in.mode_0x001b_0x05=constant +hwmon_in.int_cons_0x001b_0x05=1140 +# in28 +hwmon_in.mode_0x001c_0x00=config +hwmon_in.int_cons_0x001c_0x00=3 +hwmon_in.src_0x001c_0x00=file +hwmon_in.frmt_0x001c_0x00=buf +hwmon_in.fpath_0x001c_0x00=/sys/bus/i2c/devices/25-006c/hwmon/ +hwmon_in.addr_0x001c_0x00=0 +hwmon_in.len_0x001c_0x00=8 +hwmon_in.bit_offset_0x001c_0x00=0 +hwmon_in.str_cons_0x001c_0x00=in4_input +hwmon_in.int_extra1_0x001c_0x00=1124 +hwmon_in.mode_0x001c_0x01=str_constant +hwmon_in.str_cons_0x001c_0x01=CPU_P2V5_VPP +hwmon_in.mode_0x001c_0x02=str_constant +hwmon_in.str_cons_0x001c_0x02=tps53622 +hwmon_in.mode_0x001c_0x03=constant +hwmon_in.int_cons_0x001c_0x03=2632 +hwmon_in.mode_0x001c_0x05=constant +hwmon_in.int_cons_0x001c_0x05=2380 +# in29 +hwmon_in.mode_0x001d_0x00=config +hwmon_in.int_cons_0x001d_0x00=0 +hwmon_in.src_0x001d_0x00=file +hwmon_in.frmt_0x001d_0x00=buf +hwmon_in.fpath_0x001d_0x00=/sys/bus/i2c/devices/25-0043/hwmon/ +hwmon_in.addr_0x001d_0x00=0 +hwmon_in.len_0x001d_0x00=8 +hwmon_in.bit_offset_0x001d_0x00= +hwmon_in.str_cons_0x001d_0x00=in1_input +hwmon_in.mode_0x001d_0x01=str_constant +hwmon_in.str_cons_0x001d_0x01=CPU_P3V3_STBY +hwmon_in.mode_0x001d_0x02=str_constant +hwmon_in.str_cons_0x001d_0x02=ina3221 +hwmon_in.mode_0x001d_0x03=constant +hwmon_in.int_cons_0x001d_0x03=3476 +hwmon_in.mode_0x001d_0x05=constant +hwmon_in.int_cons_0x001d_0x05=3140 +# in30 +hwmon_in.mode_0x001e_0x00=config +hwmon_in.int_cons_0x001e_0x00=0 +hwmon_in.src_0x001e_0x00=file +hwmon_in.frmt_0x001e_0x00=buf +hwmon_in.fpath_0x001e_0x00=/sys/bus/i2c/devices/25-0043/hwmon/ +hwmon_in.addr_0x001e_0x00=0 +hwmon_in.len_0x001e_0x00=8 +hwmon_in.bit_offset_0x001e_0x00= +hwmon_in.str_cons_0x001e_0x00=in2_input +hwmon_in.mode_0x001e_0x01=str_constant +hwmon_in.str_cons_0x001e_0x01=CPU_P5V_AUX_IN +hwmon_in.mode_0x001e_0x02=str_constant +hwmon_in.str_cons_0x001e_0x02=ina3221 +hwmon_in.mode_0x001e_0x03=constant +hwmon_in.int_cons_0x001e_0x03=5229 +hwmon_in.mode_0x001e_0x05=constant +hwmon_in.int_cons_0x001e_0x05=4730 +# in21: original place was 0x30,last one +hwmon_in.mode_0x0015_0x00=config +hwmon_in.int_cons_0x0015_0x00=0 +hwmon_in.src_0x0015_0x00=file +hwmon_in.frmt_0x0015_0x00=buf +hwmon_in.fpath_0x0015_0x00=/sys/bus/i2c/devices/25-0043/hwmon/ +hwmon_in.addr_0x0015_0x00=0 +hwmon_in.len_0x0015_0x00=8 +hwmon_in.bit_offset_0x0015_0x00= +hwmon_in.str_cons_0x0015_0x00=in3_input +hwmon_in.mode_0x0015_0x01=str_constant +hwmon_in.str_cons_0x0015_0x01=CPU_P1V7_VCCSCFUSESUS_IN +hwmon_in.mode_0x0015_0x02=str_constant +hwmon_in.str_cons_0x0015_0x02=ina3221 +hwmon_in.mode_0x0015_0x03=constant +hwmon_in.int_cons_0x0015_0x03=1789 +hwmon_in.mode_0x0015_0x05=constant +hwmon_in.int_cons_0x0015_0x05=1620 + +# curr1 +hwmon_curr.mode_0x0001_0x00=config +hwmon_curr.int_cons_0x0001_0x00=0 +hwmon_curr.src_0x0001_0x00=file +hwmon_curr.frmt_0x0001_0x00=buf +hwmon_curr.fpath_0x0001_0x00=/sys/bus/i2c/devices/25-0060/hwmon/ +hwmon_curr.addr_0x0001_0x00=0 +hwmon_curr.len_0x0001_0x00=8 +hwmon_curr.bit_offset_0x0001_0x00= +hwmon_curr.str_cons_0x0001_0x00=curr1_input + +hwmon_curr.mode_0x0001_0x01=str_constant +hwmon_curr.str_cons_0x0001_0x01=CPU_VCCIN_C + +hwmon_curr.mode_0x0001_0x02=str_constant +hwmon_curr.str_cons_0x0001_0x02=tps53622 + +hwmon_curr.mode_0x0001_0x03=constant +hwmon_curr.int_cons_0x0001_0x03=47300 + +hwmon_curr.mode_0x0001_0x05=constant +hwmon_curr.int_cons_0x0001_0x05=0 + +# curr2 +hwmon_curr.mode_0x0002_0x00=config +hwmon_curr.int_cons_0x0002_0x00=0 +hwmon_curr.src_0x0002_0x00=file +hwmon_curr.frmt_0x0002_0x00=buf +hwmon_curr.fpath_0x0002_0x00=/sys/bus/i2c/devices/25-0060/hwmon/ +hwmon_curr.addr_0x0002_0x00=0 +hwmon_curr.len_0x0002_0x00=8 +hwmon_curr.bit_offset_0x0002_0x00= +hwmon_curr.str_cons_0x0002_0x00=curr2_input + +hwmon_curr.mode_0x0002_0x01=str_constant +hwmon_curr.str_cons_0x0002_0x01=CPU_P1V05_C + +hwmon_curr.mode_0x0002_0x02=str_constant +hwmon_curr.str_cons_0x0002_0x02=tps53622 + +hwmon_curr.mode_0x0002_0x03=constant +hwmon_curr.int_cons_0x0002_0x03=15400 + +hwmon_curr.mode_0x0002_0x05=constant +hwmon_curr.int_cons_0x0002_0x05=0 + +# curr3 +hwmon_curr.mode_0x0003_0x00=config +hwmon_curr.int_cons_0x0003_0x00=0 +hwmon_curr.src_0x0003_0x00=file +hwmon_curr.frmt_0x0003_0x00=buf +hwmon_curr.fpath_0x0003_0x00=/sys/bus/i2c/devices/25-006c/hwmon/ +hwmon_curr.addr_0x0003_0x00=0 +hwmon_curr.len_0x0003_0x00=8 +hwmon_curr.bit_offset_0x0003_0x00= +hwmon_curr.str_cons_0x0003_0x00=curr1_input + +hwmon_curr.mode_0x0003_0x01=str_constant +hwmon_curr.str_cons_0x0003_0x01=CPU_P1V2_VDDQ_C + +hwmon_curr.mode_0x0003_0x02=str_constant +hwmon_curr.str_cons_0x0003_0x02=tps53622 + +hwmon_curr.mode_0x0003_0x03=constant +hwmon_curr.int_cons_0x0003_0x03=9900 + +hwmon_curr.mode_0x0003_0x05=constant +hwmon_curr.int_cons_0x0003_0x05=0 + +# curr4 +hwmon_curr.mode_0x0004_0x00=config +hwmon_curr.int_cons_0x0004_0x00=0 +hwmon_curr.src_0x0004_0x00=file +hwmon_curr.frmt_0x0004_0x00=buf +hwmon_curr.fpath_0x0004_0x00=/sys/bus/i2c/devices/25-006c/hwmon/ +hwmon_curr.addr_0x0004_0x00=0 +hwmon_curr.len_0x0004_0x00=8 +hwmon_curr.bit_offset_0x0004_0x00= +hwmon_curr.str_cons_0x0004_0x00=curr2_input + +hwmon_curr.mode_0x0004_0x01=str_constant +hwmon_curr.str_cons_0x0004_0x01=CPU_P2V5_VPP_C + +hwmon_curr.mode_0x0004_0x02=str_constant +hwmon_curr.str_cons_0x0004_0x02=tps53622 + +hwmon_curr.mode_0x0004_0x03=constant +hwmon_curr.int_cons_0x0004_0x03=2200 + +hwmon_curr.mode_0x0004_0x05=constant +hwmon_curr.int_cons_0x0004_0x05=0 + +# curr5 +hwmon_curr.mode_0x0005_0x00=config +hwmon_curr.int_cons_0x0005_0x00=0 +hwmon_curr.src_0x0005_0x00=file +hwmon_curr.frmt_0x0005_0x00=buf +hwmon_curr.fpath_0x0005_0x00=/sys/bus/i2c/devices/25-0043/hwmon/ +hwmon_curr.addr_0x0005_0x00=0 +hwmon_curr.len_0x0005_0x00=8 +hwmon_curr.bit_offset_0x0005_0x00= +hwmon_curr.str_cons_0x0005_0x00=curr1_input + +hwmon_curr.mode_0x0005_0x01=str_constant +hwmon_curr.str_cons_0x0005_0x01=CPU_P3V3_STBY_C + +hwmon_curr.mode_0x0005_0x02=str_constant +hwmon_curr.str_cons_0x0005_0x02=ina3221 + +hwmon_curr.mode_0x0005_0x03=constant +hwmon_curr.int_cons_0x0005_0x03=4686 + +hwmon_curr.mode_0x0005_0x05=constant +hwmon_curr.int_cons_0x0005_0x05=0 + +# curr6 +hwmon_curr.mode_0x0006_0x00=config +hwmon_curr.int_cons_0x0006_0x00=0 +hwmon_curr.src_0x0006_0x00=file +hwmon_curr.frmt_0x0006_0x00=buf +hwmon_curr.fpath_0x0006_0x00=/sys/bus/i2c/devices/25-0043/hwmon/ +hwmon_curr.addr_0x0006_0x00=0 +hwmon_curr.len_0x0006_0x00=8 +hwmon_curr.bit_offset_0x0006_0x00= +hwmon_curr.str_cons_0x0006_0x00=curr2_input + +hwmon_curr.mode_0x0006_0x01=str_constant +hwmon_curr.str_cons_0x0006_0x01=CPU_P5V_AUX_IN_C + +hwmon_curr.mode_0x0006_0x02=str_constant +hwmon_curr.str_cons_0x0006_0x02=ina3221 + +hwmon_curr.mode_0x0006_0x03=constant +hwmon_curr.int_cons_0x0006_0x03=2200 + +hwmon_curr.mode_0x0006_0x05=constant +hwmon_curr.int_cons_0x0006_0x05=0 + +# curr7 +hwmon_curr.mode_0x0007_0x00=config +hwmon_curr.int_cons_0x0007_0x00=0 +hwmon_curr.src_0x0007_0x00=file +hwmon_curr.frmt_0x0007_0x00=buf +hwmon_curr.fpath_0x0007_0x00=/sys/bus/i2c/devices/25-0043/hwmon/ +hwmon_curr.addr_0x0007_0x00=0 +hwmon_curr.len_0x0007_0x00=8 +hwmon_curr.bit_offset_0x0007_0x00= +hwmon_curr.str_cons_0x0007_0x00=curr3_input + +hwmon_curr.mode_0x0007_0x01=str_constant +hwmon_curr.str_cons_0x0007_0x01=CPU_P1V7_VCCSCFUSESUS_IN_C + +hwmon_curr.mode_0x0007_0x02=str_constant +hwmon_curr.str_cons_0x0007_0x02=ina3221 + +hwmon_curr.mode_0x0007_0x03=constant +hwmon_curr.int_cons_0x0007_0x03=2200 + +hwmon_curr.mode_0x0007_0x05=constant +hwmon_curr.int_cons_0x0007_0x05=0 \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-SFF.cfg b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-SFF.cfg new file mode 100755 index 000000000000..bdb9ce15cca5 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-SFF.cfg @@ -0,0 +1,1032 @@ +# sff number +dev_num_3_0=32 + +eeprom_size_3_1=0x8180 +eeprom_size_3_2=0x8180 +eeprom_size_3_3=0x8180 +eeprom_size_3_4=0x8180 +eeprom_size_3_5=0x8180 +eeprom_size_3_6=0x8180 +eeprom_size_3_7=0x8180 +eeprom_size_3_8=0x8180 +eeprom_size_3_9=0x8180 +eeprom_size_3_10=0x8180 +eeprom_size_3_11=0x8180 +eeprom_size_3_12=0x8180 +eeprom_size_3_13=0x8180 +eeprom_size_3_14=0x8180 +eeprom_size_3_15=0x8180 +eeprom_size_3_16=0x8180 +eeprom_size_3_17=0x8180 +eeprom_size_3_18=0x8180 +eeprom_size_3_19=0x8180 +eeprom_size_3_20=0x8180 +eeprom_size_3_21=0x8180 +eeprom_size_3_22=0x8180 +eeprom_size_3_23=0x8180 +eeprom_size_3_24=0x8180 +eeprom_size_3_25=0x8180 +eeprom_size_3_26=0x8180 +eeprom_size_3_27=0x8180 +eeprom_size_3_28=0x8180 +eeprom_size_3_29=0x8180 +eeprom_size_3_30=0x8180 +eeprom_size_3_31=0x8180 +eeprom_size_3_32=0x8180 + +eeprom_path_3_1=/sys/bus/i2c/devices/46-0050/eeprom +eeprom_path_3_2=/sys/bus/i2c/devices/47-0050/eeprom +eeprom_path_3_3=/sys/bus/i2c/devices/48-0050/eeprom +eeprom_path_3_4=/sys/bus/i2c/devices/49-0050/eeprom +eeprom_path_3_5=/sys/bus/i2c/devices/50-0050/eeprom +eeprom_path_3_6=/sys/bus/i2c/devices/51-0050/eeprom +eeprom_path_3_7=/sys/bus/i2c/devices/52-0050/eeprom +eeprom_path_3_8=/sys/bus/i2c/devices/53-0050/eeprom +eeprom_path_3_9=/sys/bus/i2c/devices/54-0050/eeprom +eeprom_path_3_10=/sys/bus/i2c/devices/55-0050/eeprom +eeprom_path_3_11=/sys/bus/i2c/devices/56-0050/eeprom +eeprom_path_3_12=/sys/bus/i2c/devices/57-0050/eeprom +eeprom_path_3_13=/sys/bus/i2c/devices/58-0050/eeprom +eeprom_path_3_14=/sys/bus/i2c/devices/59-0050/eeprom +eeprom_path_3_15=/sys/bus/i2c/devices/60-0050/eeprom +eeprom_path_3_16=/sys/bus/i2c/devices/61-0050/eeprom +eeprom_path_3_17=/sys/bus/i2c/devices/62-0050/eeprom +eeprom_path_3_18=/sys/bus/i2c/devices/63-0050/eeprom +eeprom_path_3_19=/sys/bus/i2c/devices/64-0050/eeprom +eeprom_path_3_20=/sys/bus/i2c/devices/65-0050/eeprom +eeprom_path_3_21=/sys/bus/i2c/devices/66-0050/eeprom +eeprom_path_3_22=/sys/bus/i2c/devices/67-0050/eeprom +eeprom_path_3_23=/sys/bus/i2c/devices/68-0050/eeprom +eeprom_path_3_24=/sys/bus/i2c/devices/69-0050/eeprom +eeprom_path_3_25=/sys/bus/i2c/devices/70-0050/eeprom +eeprom_path_3_26=/sys/bus/i2c/devices/71-0050/eeprom +eeprom_path_3_27=/sys/bus/i2c/devices/72-0050/eeprom +eeprom_path_3_28=/sys/bus/i2c/devices/73-0050/eeprom +eeprom_path_3_29=/sys/bus/i2c/devices/74-0050/eeprom +eeprom_path_3_30=/sys/bus/i2c/devices/75-0050/eeprom +eeprom_path_3_31=/sys/bus/i2c/devices/76-0050/eeprom +eeprom_path_3_32=/sys/bus/i2c/devices/77-0050/eeprom + + +sff_cpld_reg.mode_1_6=config +sff_cpld_reg.src_1_6=cpld +sff_cpld_reg.frmt_1_6=bit +sff_cpld_reg.pola_1_6=negative +sff_cpld_reg.addr_1_6=0x00030022 +sff_cpld_reg.len_1_6=1 +sff_cpld_reg.bit_offset_1_6=0 + +sff_cpld_reg.mode_2_6=config +sff_cpld_reg.src_2_6=cpld +sff_cpld_reg.frmt_2_6=bit +sff_cpld_reg.pola_2_6=negative +sff_cpld_reg.addr_2_6=0x00030022 +sff_cpld_reg.len_2_6=1 +sff_cpld_reg.bit_offset_2_6=1 + +sff_cpld_reg.mode_3_6=config +sff_cpld_reg.src_3_6=cpld +sff_cpld_reg.frmt_3_6=bit +sff_cpld_reg.pola_3_6=negative +sff_cpld_reg.addr_3_6=0x00030022 +sff_cpld_reg.len_3_6=1 +sff_cpld_reg.bit_offset_3_6=2 + +sff_cpld_reg.mode_4_6=config +sff_cpld_reg.src_4_6=cpld +sff_cpld_reg.frmt_4_6=bit +sff_cpld_reg.pola_4_6=negative +sff_cpld_reg.addr_4_6=0x00030022 +sff_cpld_reg.len_4_6=1 +sff_cpld_reg.bit_offset_4_6=3 + +sff_cpld_reg.mode_5_6=config +sff_cpld_reg.src_5_6=cpld +sff_cpld_reg.frmt_5_6=bit +sff_cpld_reg.pola_5_6=negative +sff_cpld_reg.addr_5_6=0x00030022 +sff_cpld_reg.len_5_6=1 +sff_cpld_reg.bit_offset_5_6=4 + +sff_cpld_reg.mode_6_6=config +sff_cpld_reg.src_6_6=cpld +sff_cpld_reg.frmt_6_6=bit +sff_cpld_reg.pola_6_6=negative +sff_cpld_reg.addr_6_6=0x00030022 +sff_cpld_reg.len_6_6=1 +sff_cpld_reg.bit_offset_6_6=5 + +sff_cpld_reg.mode_7_6=config +sff_cpld_reg.src_7_6=cpld +sff_cpld_reg.frmt_7_6=bit +sff_cpld_reg.pola_7_6=negative +sff_cpld_reg.addr_7_6=0x00030022 +sff_cpld_reg.len_7_6=1 +sff_cpld_reg.bit_offset_7_6=6 + +sff_cpld_reg.mode_8_6=config +sff_cpld_reg.src_8_6=cpld +sff_cpld_reg.frmt_8_6=bit +sff_cpld_reg.pola_8_6=negative +sff_cpld_reg.addr_8_6=0x00030022 +sff_cpld_reg.len_8_6=1 +sff_cpld_reg.bit_offset_8_6=7 + +sff_cpld_reg.mode_9_6=config +sff_cpld_reg.src_9_6=cpld +sff_cpld_reg.frmt_9_6=bit +sff_cpld_reg.pola_9_6=negative +sff_cpld_reg.addr_9_6=0x00030023 +sff_cpld_reg.len_9_6=1 +sff_cpld_reg.bit_offset_9_6=0 + +sff_cpld_reg.mode_10_6=config +sff_cpld_reg.src_10_6=cpld +sff_cpld_reg.frmt_10_6=bit +sff_cpld_reg.pola_10_6=negative +sff_cpld_reg.addr_10_6=0x00030023 +sff_cpld_reg.len_10_6=1 +sff_cpld_reg.bit_offset_10_6=1 + +sff_cpld_reg.mode_11_6=config +sff_cpld_reg.src_11_6=cpld +sff_cpld_reg.frmt_11_6=bit +sff_cpld_reg.pola_11_6=negative +sff_cpld_reg.addr_11_6=0x00030023 +sff_cpld_reg.len_11_6=1 +sff_cpld_reg.bit_offset_11_6=2 + +sff_cpld_reg.mode_12_6=config +sff_cpld_reg.src_12_6=cpld +sff_cpld_reg.frmt_12_6=bit +sff_cpld_reg.pola_12_6=negative +sff_cpld_reg.addr_12_6=0x00030023 +sff_cpld_reg.len_12_6=1 +sff_cpld_reg.bit_offset_12_6=3 + +sff_cpld_reg.mode_13_6=config +sff_cpld_reg.src_13_6=cpld +sff_cpld_reg.frmt_13_6=bit +sff_cpld_reg.pola_13_6=negative +sff_cpld_reg.addr_13_6=0x00030023 +sff_cpld_reg.len_13_6=1 +sff_cpld_reg.bit_offset_13_6=4 + +sff_cpld_reg.mode_14_6=config +sff_cpld_reg.src_14_6=cpld +sff_cpld_reg.frmt_14_6=bit +sff_cpld_reg.pola_14_6=negative +sff_cpld_reg.addr_14_6=0x00030023 +sff_cpld_reg.len_14_6=1 +sff_cpld_reg.bit_offset_14_6=5 + +sff_cpld_reg.mode_15_6=config +sff_cpld_reg.src_15_6=cpld +sff_cpld_reg.frmt_15_6=bit +sff_cpld_reg.pola_15_6=negative +sff_cpld_reg.addr_15_6=0x00030023 +sff_cpld_reg.len_15_6=1 +sff_cpld_reg.bit_offset_15_6=6 + +sff_cpld_reg.mode_16_6=config +sff_cpld_reg.src_16_6=cpld +sff_cpld_reg.frmt_16_6=bit +sff_cpld_reg.pola_16_6=negative +sff_cpld_reg.addr_16_6=0x00030023 +sff_cpld_reg.len_16_6=1 +sff_cpld_reg.bit_offset_16_6=7 + +sff_cpld_reg.mode_17_6=config +sff_cpld_reg.src_17_6=cpld +sff_cpld_reg.frmt_17_6=bit +sff_cpld_reg.pola_17_6=negative +sff_cpld_reg.addr_17_6=0x00020021 +sff_cpld_reg.len_17_6=1 +sff_cpld_reg.bit_offset_17_6=0 + +sff_cpld_reg.mode_18_6=config +sff_cpld_reg.src_18_6=cpld +sff_cpld_reg.frmt_18_6=bit +sff_cpld_reg.pola_18_6=negative +sff_cpld_reg.addr_18_6=0x00020021 +sff_cpld_reg.len_18_6=1 +sff_cpld_reg.bit_offset_18_6=1 + +sff_cpld_reg.mode_19_6=config +sff_cpld_reg.src_19_6=cpld +sff_cpld_reg.frmt_19_6=bit +sff_cpld_reg.pola_19_6=negative +sff_cpld_reg.addr_19_6=0x00020021 +sff_cpld_reg.len_19_6=1 +sff_cpld_reg.bit_offset_19_6=2 + +sff_cpld_reg.mode_20_6=config +sff_cpld_reg.src_20_6=cpld +sff_cpld_reg.frmt_20_6=bit +sff_cpld_reg.pola_20_6=negative +sff_cpld_reg.addr_20_6=0x00020021 +sff_cpld_reg.len_20_6=1 +sff_cpld_reg.bit_offset_20_6=3 + +sff_cpld_reg.mode_21_6=config +sff_cpld_reg.src_21_6=cpld +sff_cpld_reg.frmt_21_6=bit +sff_cpld_reg.pola_21_6=negative +sff_cpld_reg.addr_21_6=0x00020021 +sff_cpld_reg.len_21_6=1 +sff_cpld_reg.bit_offset_21_6=4 + +sff_cpld_reg.mode_22_6=config +sff_cpld_reg.src_22_6=cpld +sff_cpld_reg.frmt_22_6=bit +sff_cpld_reg.pola_22_6=negative +sff_cpld_reg.addr_22_6=0x00020021 +sff_cpld_reg.len_22_6=1 +sff_cpld_reg.bit_offset_22_6=5 + +sff_cpld_reg.mode_23_6=config +sff_cpld_reg.src_23_6=cpld +sff_cpld_reg.frmt_23_6=bit +sff_cpld_reg.pola_23_6=negative +sff_cpld_reg.addr_23_6=0x00020021 +sff_cpld_reg.len_23_6=1 +sff_cpld_reg.bit_offset_23_6=6 + +sff_cpld_reg.mode_24_6=config +sff_cpld_reg.src_24_6=cpld +sff_cpld_reg.frmt_24_6=bit +sff_cpld_reg.pola_24_6=negative +sff_cpld_reg.addr_24_6=0x00020021 +sff_cpld_reg.len_24_6=1 +sff_cpld_reg.bit_offset_24_6=7 + +sff_cpld_reg.mode_25_6=config +sff_cpld_reg.src_25_6=cpld +sff_cpld_reg.frmt_25_6=bit +sff_cpld_reg.pola_25_6=negative +sff_cpld_reg.addr_25_6=0x00020022 +sff_cpld_reg.len_25_6=1 +sff_cpld_reg.bit_offset_25_6=0 + +sff_cpld_reg.mode_26_6=config +sff_cpld_reg.src_26_6=cpld +sff_cpld_reg.frmt_26_6=bit +sff_cpld_reg.pola_26_6=negative +sff_cpld_reg.addr_26_6=0x00020022 +sff_cpld_reg.len_26_6=1 +sff_cpld_reg.bit_offset_26_6=1 + +sff_cpld_reg.mode_27_6=config +sff_cpld_reg.src_27_6=cpld +sff_cpld_reg.frmt_27_6=bit +sff_cpld_reg.pola_27_6=negative +sff_cpld_reg.addr_27_6=0x00020022 +sff_cpld_reg.len_27_6=1 +sff_cpld_reg.bit_offset_27_6=2 + +sff_cpld_reg.mode_28_6=config +sff_cpld_reg.src_28_6=cpld +sff_cpld_reg.frmt_28_6=bit +sff_cpld_reg.pola_28_6=negative +sff_cpld_reg.addr_28_6=0x00020022 +sff_cpld_reg.len_28_6=1 +sff_cpld_reg.bit_offset_28_6=3 + +sff_cpld_reg.mode_29_6=config +sff_cpld_reg.src_29_6=cpld +sff_cpld_reg.frmt_29_6=bit +sff_cpld_reg.pola_29_6=negative +sff_cpld_reg.addr_29_6=0x00020022 +sff_cpld_reg.len_29_6=1 +sff_cpld_reg.bit_offset_29_6=4 + +sff_cpld_reg.mode_30_6=config +sff_cpld_reg.src_30_6=cpld +sff_cpld_reg.frmt_30_6=bit +sff_cpld_reg.pola_30_6=negative +sff_cpld_reg.addr_30_6=0x00020022 +sff_cpld_reg.len_30_6=1 +sff_cpld_reg.bit_offset_30_6=5 + +sff_cpld_reg.mode_31_6=config +sff_cpld_reg.src_31_6=cpld +sff_cpld_reg.frmt_31_6=bit +sff_cpld_reg.pola_31_6=negative +sff_cpld_reg.addr_31_6=0x00020022 +sff_cpld_reg.len_31_6=1 +sff_cpld_reg.bit_offset_31_6=6 + +sff_cpld_reg.mode_32_6=config +sff_cpld_reg.src_32_6=cpld +sff_cpld_reg.frmt_32_6=bit +sff_cpld_reg.pola_32_6=negative +sff_cpld_reg.addr_32_6=0x00020022 +sff_cpld_reg.len_32_6=1 +sff_cpld_reg.bit_offset_32_6=7 + + +sff_cpld_reg.mode_1_8=config +sff_cpld_reg.src_1_8=cpld +sff_cpld_reg.frmt_1_8=bit +sff_cpld_reg.pola_1_8=negative +sff_cpld_reg.addr_1_8=0x00020030 +sff_cpld_reg.len_1_8=1 +sff_cpld_reg.bit_offset_1_8=0 + +sff_cpld_reg.mode_2_8=config +sff_cpld_reg.src_2_8=cpld +sff_cpld_reg.frmt_2_8=bit +sff_cpld_reg.pola_2_8=negative +sff_cpld_reg.addr_2_8=0x00020030 +sff_cpld_reg.len_2_8=1 +sff_cpld_reg.bit_offset_2_8=1 + +sff_cpld_reg.mode_3_8=config +sff_cpld_reg.src_3_8=cpld +sff_cpld_reg.frmt_3_8=bit +sff_cpld_reg.pola_3_8=negative +sff_cpld_reg.addr_3_8=0x00020030 +sff_cpld_reg.len_3_8=1 +sff_cpld_reg.bit_offset_3_8=2 + +sff_cpld_reg.mode_4_8=config +sff_cpld_reg.src_4_8=cpld +sff_cpld_reg.frmt_4_8=bit +sff_cpld_reg.pola_4_8=negative +sff_cpld_reg.addr_4_8=0x00020030 +sff_cpld_reg.len_4_8=1 +sff_cpld_reg.bit_offset_4_8=3 + +sff_cpld_reg.mode_5_8=config +sff_cpld_reg.src_5_8=cpld +sff_cpld_reg.frmt_5_8=bit +sff_cpld_reg.pola_5_8=negative +sff_cpld_reg.addr_5_8=0x00020030 +sff_cpld_reg.len_5_8=1 +sff_cpld_reg.bit_offset_5_8=4 + +sff_cpld_reg.mode_6_8=config +sff_cpld_reg.src_6_8=cpld +sff_cpld_reg.frmt_6_8=bit +sff_cpld_reg.pola_6_8=negative +sff_cpld_reg.addr_6_8=0x00020030 +sff_cpld_reg.len_6_8=1 +sff_cpld_reg.bit_offset_6_8=5 + +sff_cpld_reg.mode_7_8=config +sff_cpld_reg.src_7_8=cpld +sff_cpld_reg.frmt_7_8=bit +sff_cpld_reg.pola_7_8=negative +sff_cpld_reg.addr_7_8=0x00020030 +sff_cpld_reg.len_7_8=1 +sff_cpld_reg.bit_offset_7_8=6 + +sff_cpld_reg.mode_8_8=config +sff_cpld_reg.src_8_8=cpld +sff_cpld_reg.frmt_8_8=bit +sff_cpld_reg.pola_8_8=negative +sff_cpld_reg.addr_8_8=0x00020030 +sff_cpld_reg.len_8_8=1 +sff_cpld_reg.bit_offset_8_8=7 + +sff_cpld_reg.mode_9_8=config +sff_cpld_reg.src_9_8=cpld +sff_cpld_reg.frmt_9_8=bit +sff_cpld_reg.pola_9_8=negative +sff_cpld_reg.addr_9_8=0x00020031 +sff_cpld_reg.len_9_8=1 +sff_cpld_reg.bit_offset_9_8=0 + +sff_cpld_reg.mode_10_8=config +sff_cpld_reg.src_10_8=cpld +sff_cpld_reg.frmt_10_8=bit +sff_cpld_reg.pola_10_8=negative +sff_cpld_reg.addr_10_8=0x00020031 +sff_cpld_reg.len_10_8=1 +sff_cpld_reg.bit_offset_10_8=1 + +sff_cpld_reg.mode_11_8=config +sff_cpld_reg.src_11_8=cpld +sff_cpld_reg.frmt_11_8=bit +sff_cpld_reg.pola_11_8=negative +sff_cpld_reg.addr_11_8=0x00020031 +sff_cpld_reg.len_11_8=1 +sff_cpld_reg.bit_offset_11_8=2 + +sff_cpld_reg.mode_12_8=config +sff_cpld_reg.src_12_8=cpld +sff_cpld_reg.frmt_12_8=bit +sff_cpld_reg.pola_12_8=negative +sff_cpld_reg.addr_12_8=0x00020031 +sff_cpld_reg.len_12_8=1 +sff_cpld_reg.bit_offset_12_8=3 + +sff_cpld_reg.mode_13_8=config +sff_cpld_reg.src_13_8=cpld +sff_cpld_reg.frmt_13_8=bit +sff_cpld_reg.pola_13_8=negative +sff_cpld_reg.addr_13_8=0x00020031 +sff_cpld_reg.len_13_8=1 +sff_cpld_reg.bit_offset_13_8=4 + +sff_cpld_reg.mode_14_8=config +sff_cpld_reg.src_14_8=cpld +sff_cpld_reg.frmt_14_8=bit +sff_cpld_reg.pola_14_8=negative +sff_cpld_reg.addr_14_8=0x00020031 +sff_cpld_reg.len_14_8=1 +sff_cpld_reg.bit_offset_14_8=5 + +sff_cpld_reg.mode_15_8=config +sff_cpld_reg.src_15_8=cpld +sff_cpld_reg.frmt_15_8=bit +sff_cpld_reg.pola_15_8=negative +sff_cpld_reg.addr_15_8=0x00020031 +sff_cpld_reg.len_15_8=1 +sff_cpld_reg.bit_offset_15_8=6 + +sff_cpld_reg.mode_16_8=config +sff_cpld_reg.src_16_8=cpld +sff_cpld_reg.frmt_16_8=bit +sff_cpld_reg.pola_16_8=negative +sff_cpld_reg.addr_16_8=0x00020031 +sff_cpld_reg.len_16_8=1 +sff_cpld_reg.bit_offset_16_8=7 + +sff_cpld_reg.mode_17_8=config +sff_cpld_reg.src_17_8=cpld +sff_cpld_reg.frmt_17_8=bit +sff_cpld_reg.pola_17_8=negative +sff_cpld_reg.addr_17_8=0x00020032 +sff_cpld_reg.len_17_8=1 +sff_cpld_reg.bit_offset_17_8=0 + +sff_cpld_reg.mode_18_8=config +sff_cpld_reg.src_18_8=cpld +sff_cpld_reg.frmt_18_8=bit +sff_cpld_reg.pola_18_8=negative +sff_cpld_reg.addr_18_8=0x00020032 +sff_cpld_reg.len_18_8=1 +sff_cpld_reg.bit_offset_18_8=1 + +sff_cpld_reg.mode_19_8=config +sff_cpld_reg.src_19_8=cpld +sff_cpld_reg.frmt_19_8=bit +sff_cpld_reg.pola_19_8=negative +sff_cpld_reg.addr_19_8=0x00020032 +sff_cpld_reg.len_19_8=1 +sff_cpld_reg.bit_offset_19_8=2 + +sff_cpld_reg.mode_20_8=config +sff_cpld_reg.src_20_8=cpld +sff_cpld_reg.frmt_20_8=bit +sff_cpld_reg.pola_20_8=negative +sff_cpld_reg.addr_20_8=0x00020032 +sff_cpld_reg.len_20_8=1 +sff_cpld_reg.bit_offset_20_8=3 + +sff_cpld_reg.mode_21_8=config +sff_cpld_reg.src_21_8=cpld +sff_cpld_reg.frmt_21_8=bit +sff_cpld_reg.pola_21_8=negative +sff_cpld_reg.addr_21_8=0x00020032 +sff_cpld_reg.len_21_8=1 +sff_cpld_reg.bit_offset_21_8=4 + +sff_cpld_reg.mode_22_8=config +sff_cpld_reg.src_22_8=cpld +sff_cpld_reg.frmt_22_8=bit +sff_cpld_reg.pola_22_8=negative +sff_cpld_reg.addr_22_8=0x00020032 +sff_cpld_reg.len_22_8=1 +sff_cpld_reg.bit_offset_22_8=5 + +sff_cpld_reg.mode_23_8=config +sff_cpld_reg.src_23_8=cpld +sff_cpld_reg.frmt_23_8=bit +sff_cpld_reg.pola_23_8=negative +sff_cpld_reg.addr_23_8=0x00020032 +sff_cpld_reg.len_23_8=1 +sff_cpld_reg.bit_offset_23_8=6 + +sff_cpld_reg.mode_24_8=config +sff_cpld_reg.src_24_8=cpld +sff_cpld_reg.frmt_24_8=bit +sff_cpld_reg.pola_24_8=negative +sff_cpld_reg.addr_24_8=0x00020032 +sff_cpld_reg.len_24_8=1 +sff_cpld_reg.bit_offset_24_8=7 + +sff_cpld_reg.mode_25_8=config +sff_cpld_reg.src_25_8=cpld +sff_cpld_reg.frmt_25_8=bit +sff_cpld_reg.pola_25_8=negative +sff_cpld_reg.addr_25_8=0x00020033 +sff_cpld_reg.len_25_8=1 +sff_cpld_reg.bit_offset_25_8=0 + +sff_cpld_reg.mode_26_8=config +sff_cpld_reg.src_26_8=cpld +sff_cpld_reg.frmt_26_8=bit +sff_cpld_reg.pola_26_8=negative +sff_cpld_reg.addr_26_8=0x00020033 +sff_cpld_reg.len_26_8=1 +sff_cpld_reg.bit_offset_26_8=1 + +sff_cpld_reg.mode_27_8=config +sff_cpld_reg.src_27_8=cpld +sff_cpld_reg.frmt_27_8=bit +sff_cpld_reg.pola_27_8=negative +sff_cpld_reg.addr_27_8=0x00020033 +sff_cpld_reg.len_27_8=1 +sff_cpld_reg.bit_offset_27_8=2 + +sff_cpld_reg.mode_28_8=config +sff_cpld_reg.src_28_8=cpld +sff_cpld_reg.frmt_28_8=bit +sff_cpld_reg.pola_28_8=negative +sff_cpld_reg.addr_28_8=0x00020033 +sff_cpld_reg.len_28_8=1 +sff_cpld_reg.bit_offset_28_8=3 + +sff_cpld_reg.mode_29_8=config +sff_cpld_reg.src_29_8=cpld +sff_cpld_reg.frmt_29_8=bit +sff_cpld_reg.pola_29_8=negative +sff_cpld_reg.addr_29_8=0x00020033 +sff_cpld_reg.len_29_8=1 +sff_cpld_reg.bit_offset_29_8=4 + +sff_cpld_reg.mode_30_8=config +sff_cpld_reg.src_30_8=cpld +sff_cpld_reg.frmt_30_8=bit +sff_cpld_reg.pola_30_8=negative +sff_cpld_reg.addr_30_8=0x00020033 +sff_cpld_reg.len_30_8=1 +sff_cpld_reg.bit_offset_30_8=5 + +sff_cpld_reg.mode_31_8=config +sff_cpld_reg.src_31_8=cpld +sff_cpld_reg.frmt_31_8=bit +sff_cpld_reg.pola_31_8=negative +sff_cpld_reg.addr_31_8=0x00020033 +sff_cpld_reg.len_31_8=1 +sff_cpld_reg.bit_offset_31_8=6 + +sff_cpld_reg.mode_32_8=config +sff_cpld_reg.src_32_8=cpld +sff_cpld_reg.frmt_32_8=bit +sff_cpld_reg.pola_32_8=negative +sff_cpld_reg.addr_32_8=0x00020033 +sff_cpld_reg.len_32_8=1 +sff_cpld_reg.bit_offset_32_8=7 + + +sff_cpld_reg.mode_1_1=config +sff_cpld_reg.src_1_1=cpld +sff_cpld_reg.frmt_1_1=bit +sff_cpld_reg.addr_1_1=0x00030034 +sff_cpld_reg.len_1_1=1 +sff_cpld_reg.bit_offset_1_1=0 + +sff_cpld_reg.mode_2_1=config +sff_cpld_reg.src_2_1=cpld +sff_cpld_reg.frmt_2_1=bit +sff_cpld_reg.addr_2_1=0x00030034 +sff_cpld_reg.len_2_1=1 +sff_cpld_reg.bit_offset_2_1=1 + +sff_cpld_reg.mode_3_1=config +sff_cpld_reg.src_3_1=cpld +sff_cpld_reg.frmt_3_1=bit +sff_cpld_reg.addr_3_1=0x00030034 +sff_cpld_reg.len_3_1=1 +sff_cpld_reg.bit_offset_3_1=2 + +sff_cpld_reg.mode_4_1=config +sff_cpld_reg.src_4_1=cpld +sff_cpld_reg.frmt_4_1=bit +sff_cpld_reg.addr_4_1=0x00030034 +sff_cpld_reg.len_4_1=1 +sff_cpld_reg.bit_offset_4_1=3 + +sff_cpld_reg.mode_5_1=config +sff_cpld_reg.src_5_1=cpld +sff_cpld_reg.frmt_5_1=bit +sff_cpld_reg.addr_5_1=0x00030034 +sff_cpld_reg.len_5_1=1 +sff_cpld_reg.bit_offset_5_1=4 + +sff_cpld_reg.mode_6_1=config +sff_cpld_reg.src_6_1=cpld +sff_cpld_reg.frmt_6_1=bit +sff_cpld_reg.addr_6_1=0x00030034 +sff_cpld_reg.len_6_1=1 +sff_cpld_reg.bit_offset_6_1=5 + +sff_cpld_reg.mode_7_1=config +sff_cpld_reg.src_7_1=cpld +sff_cpld_reg.frmt_7_1=bit +sff_cpld_reg.addr_7_1=0x00030034 +sff_cpld_reg.len_7_1=1 +sff_cpld_reg.bit_offset_7_1=6 + +sff_cpld_reg.mode_8_1=config +sff_cpld_reg.src_8_1=cpld +sff_cpld_reg.frmt_8_1=bit +sff_cpld_reg.addr_8_1=0x00030034 +sff_cpld_reg.len_8_1=1 +sff_cpld_reg.bit_offset_8_1=7 + +sff_cpld_reg.mode_9_1=config +sff_cpld_reg.src_9_1=cpld +sff_cpld_reg.frmt_9_1=bit +sff_cpld_reg.addr_9_1=0x00030035 +sff_cpld_reg.len_9_1=1 +sff_cpld_reg.bit_offset_9_1=0 + +sff_cpld_reg.mode_10_1=config +sff_cpld_reg.src_10_1=cpld +sff_cpld_reg.frmt_10_1=bit +sff_cpld_reg.addr_10_1=0x00030035 +sff_cpld_reg.len_10_1=1 +sff_cpld_reg.bit_offset_10_1=1 + +sff_cpld_reg.mode_11_1=config +sff_cpld_reg.src_11_1=cpld +sff_cpld_reg.frmt_11_1=bit +sff_cpld_reg.addr_11_1=0x00030035 +sff_cpld_reg.len_11_1=1 +sff_cpld_reg.bit_offset_11_1=2 + +sff_cpld_reg.mode_12_1=config +sff_cpld_reg.src_12_1=cpld +sff_cpld_reg.frmt_12_1=bit +sff_cpld_reg.addr_12_1=0x00030035 +sff_cpld_reg.len_12_1=1 +sff_cpld_reg.bit_offset_12_1=3 + +sff_cpld_reg.mode_13_1=config +sff_cpld_reg.src_13_1=cpld +sff_cpld_reg.frmt_13_1=bit +sff_cpld_reg.addr_13_1=0x00030035 +sff_cpld_reg.len_13_1=1 +sff_cpld_reg.bit_offset_13_1=4 + +sff_cpld_reg.mode_14_1=config +sff_cpld_reg.src_14_1=cpld +sff_cpld_reg.frmt_14_1=bit +sff_cpld_reg.addr_14_1=0x00030035 +sff_cpld_reg.len_14_1=1 +sff_cpld_reg.bit_offset_14_1=5 + +sff_cpld_reg.mode_15_1=config +sff_cpld_reg.src_15_1=cpld +sff_cpld_reg.frmt_15_1=bit +sff_cpld_reg.addr_15_1=0x00030035 +sff_cpld_reg.len_15_1=1 +sff_cpld_reg.bit_offset_15_1=6 + +sff_cpld_reg.mode_16_1=config +sff_cpld_reg.src_16_1=cpld +sff_cpld_reg.frmt_16_1=bit +sff_cpld_reg.addr_16_1=0x00030035 +sff_cpld_reg.len_16_1=1 +sff_cpld_reg.bit_offset_16_1=7 + +sff_cpld_reg.mode_17_1=config +sff_cpld_reg.src_17_1=cpld +sff_cpld_reg.frmt_17_1=bit +sff_cpld_reg.addr_17_1=0x00020039 +sff_cpld_reg.len_17_1=1 +sff_cpld_reg.bit_offset_17_1=0 + +sff_cpld_reg.mode_18_1=config +sff_cpld_reg.src_18_1=cpld +sff_cpld_reg.frmt_18_1=bit +sff_cpld_reg.addr_18_1=0x00020039 +sff_cpld_reg.len_18_1=1 +sff_cpld_reg.bit_offset_18_1=1 + +sff_cpld_reg.mode_19_1=config +sff_cpld_reg.src_19_1=cpld +sff_cpld_reg.frmt_19_1=bit +sff_cpld_reg.addr_19_1=0x00020039 +sff_cpld_reg.len_19_1=1 +sff_cpld_reg.bit_offset_19_1=2 + +sff_cpld_reg.mode_20_1=config +sff_cpld_reg.src_20_1=cpld +sff_cpld_reg.frmt_20_1=bit +sff_cpld_reg.addr_20_1=0x00020039 +sff_cpld_reg.len_20_1=1 +sff_cpld_reg.bit_offset_20_1=3 + +sff_cpld_reg.mode_21_1=config +sff_cpld_reg.src_21_1=cpld +sff_cpld_reg.frmt_21_1=bit +sff_cpld_reg.addr_21_1=0x00020039 +sff_cpld_reg.len_21_1=1 +sff_cpld_reg.bit_offset_21_1=4 + +sff_cpld_reg.mode_22_1=config +sff_cpld_reg.src_22_1=cpld +sff_cpld_reg.frmt_22_1=bit +sff_cpld_reg.addr_22_1=0x00020039 +sff_cpld_reg.len_22_1=1 +sff_cpld_reg.bit_offset_22_1=5 + +sff_cpld_reg.mode_23_1=config +sff_cpld_reg.src_23_1=cpld +sff_cpld_reg.frmt_23_1=bit +sff_cpld_reg.addr_23_1=0x00020039 +sff_cpld_reg.len_23_1=1 +sff_cpld_reg.bit_offset_23_1=6 + +sff_cpld_reg.mode_24_1=config +sff_cpld_reg.src_24_1=cpld +sff_cpld_reg.frmt_24_1=bit +sff_cpld_reg.addr_24_1=0x00020039 +sff_cpld_reg.len_24_1=1 +sff_cpld_reg.bit_offset_24_1=7 + +sff_cpld_reg.mode_25_1=config +sff_cpld_reg.src_25_1=cpld +sff_cpld_reg.frmt_25_1=bit +sff_cpld_reg.addr_25_1=0x0002003a +sff_cpld_reg.len_25_1=1 +sff_cpld_reg.bit_offset_25_1=0 + +sff_cpld_reg.mode_26_1=config +sff_cpld_reg.src_26_1=cpld +sff_cpld_reg.frmt_26_1=bit +sff_cpld_reg.addr_26_1=0x0002003a +sff_cpld_reg.len_26_1=1 +sff_cpld_reg.bit_offset_26_1=1 + +sff_cpld_reg.mode_27_1=config +sff_cpld_reg.src_27_1=cpld +sff_cpld_reg.frmt_27_1=bit +sff_cpld_reg.addr_27_1=0x0002003a +sff_cpld_reg.len_27_1=1 +sff_cpld_reg.bit_offset_27_1=2 + +sff_cpld_reg.mode_28_1=config +sff_cpld_reg.src_28_1=cpld +sff_cpld_reg.frmt_28_1=bit +sff_cpld_reg.addr_28_1=0x0002003a +sff_cpld_reg.len_28_1=1 +sff_cpld_reg.bit_offset_28_1=3 + +sff_cpld_reg.mode_29_1=config +sff_cpld_reg.src_29_1=cpld +sff_cpld_reg.frmt_29_1=bit +sff_cpld_reg.addr_29_1=0x0002003a +sff_cpld_reg.len_29_1=1 +sff_cpld_reg.bit_offset_29_1=4 + +sff_cpld_reg.mode_30_1=config +sff_cpld_reg.src_30_1=cpld +sff_cpld_reg.frmt_30_1=bit +sff_cpld_reg.addr_30_1=0x0002003a +sff_cpld_reg.len_30_1=1 +sff_cpld_reg.bit_offset_30_1=5 + +sff_cpld_reg.mode_31_1=config +sff_cpld_reg.src_31_1=cpld +sff_cpld_reg.frmt_31_1=bit +sff_cpld_reg.addr_31_1=0x0002003a +sff_cpld_reg.len_31_1=1 +sff_cpld_reg.bit_offset_31_1=6 + +sff_cpld_reg.mode_32_1=config +sff_cpld_reg.src_32_1=cpld +sff_cpld_reg.frmt_32_1=bit +sff_cpld_reg.addr_32_1=0x0002003a +sff_cpld_reg.len_32_1=1 +sff_cpld_reg.bit_offset_32_1=7 + + +sff_cpld_reg.mode_1_7=config +sff_cpld_reg.src_1_7=cpld +sff_cpld_reg.frmt_1_7=bit +sff_cpld_reg.addr_1_7=0x00030032 +sff_cpld_reg.len_1_7=1 +sff_cpld_reg.bit_offset_1_7=0 + +sff_cpld_reg.mode_2_7=config +sff_cpld_reg.src_2_7=cpld +sff_cpld_reg.frmt_2_7=bit +sff_cpld_reg.addr_2_7=0x00030032 +sff_cpld_reg.len_2_7=1 +sff_cpld_reg.bit_offset_2_7=1 + +sff_cpld_reg.mode_3_7=config +sff_cpld_reg.src_3_7=cpld +sff_cpld_reg.frmt_3_7=bit +sff_cpld_reg.addr_3_7=0x00030032 +sff_cpld_reg.len_3_7=1 +sff_cpld_reg.bit_offset_3_7=2 + +sff_cpld_reg.mode_4_7=config +sff_cpld_reg.src_4_7=cpld +sff_cpld_reg.frmt_4_7=bit +sff_cpld_reg.addr_4_7=0x00030032 +sff_cpld_reg.len_4_7=1 +sff_cpld_reg.bit_offset_4_7=3 + +sff_cpld_reg.mode_5_7=config +sff_cpld_reg.src_5_7=cpld +sff_cpld_reg.frmt_5_7=bit +sff_cpld_reg.addr_5_7=0x00030032 +sff_cpld_reg.len_5_7=1 +sff_cpld_reg.bit_offset_5_7=4 + +sff_cpld_reg.mode_6_7=config +sff_cpld_reg.src_6_7=cpld +sff_cpld_reg.frmt_6_7=bit +sff_cpld_reg.addr_6_7=0x00030032 +sff_cpld_reg.len_6_7=1 +sff_cpld_reg.bit_offset_6_7=5 + +sff_cpld_reg.mode_7_7=config +sff_cpld_reg.src_7_7=cpld +sff_cpld_reg.frmt_7_7=bit +sff_cpld_reg.addr_7_7=0x00030032 +sff_cpld_reg.len_7_7=1 +sff_cpld_reg.bit_offset_7_7=6 + +sff_cpld_reg.mode_8_7=config +sff_cpld_reg.src_8_7=cpld +sff_cpld_reg.frmt_8_7=bit +sff_cpld_reg.addr_8_7=0x00030032 +sff_cpld_reg.len_8_7=1 +sff_cpld_reg.bit_offset_8_7=7 + +sff_cpld_reg.mode_9_7=config +sff_cpld_reg.src_9_7=cpld +sff_cpld_reg.frmt_9_7=bit +sff_cpld_reg.addr_9_7=0x00030033 +sff_cpld_reg.len_9_7=1 +sff_cpld_reg.bit_offset_9_7=0 + +sff_cpld_reg.mode_10_7=config +sff_cpld_reg.src_10_7=cpld +sff_cpld_reg.frmt_10_7=bit +sff_cpld_reg.addr_10_7=0x00030033 +sff_cpld_reg.len_10_7=1 +sff_cpld_reg.bit_offset_10_7=1 + +sff_cpld_reg.mode_11_7=config +sff_cpld_reg.src_11_7=cpld +sff_cpld_reg.frmt_11_7=bit +sff_cpld_reg.addr_11_7=0x00030033 +sff_cpld_reg.len_11_7=1 +sff_cpld_reg.bit_offset_11_7=2 + +sff_cpld_reg.mode_12_7=config +sff_cpld_reg.src_12_7=cpld +sff_cpld_reg.frmt_12_7=bit +sff_cpld_reg.addr_12_7=0x00030033 +sff_cpld_reg.len_12_7=1 +sff_cpld_reg.bit_offset_12_7=3 + +sff_cpld_reg.mode_13_7=config +sff_cpld_reg.src_13_7=cpld +sff_cpld_reg.frmt_13_7=bit +sff_cpld_reg.addr_13_7=0x00030033 +sff_cpld_reg.len_13_7=1 +sff_cpld_reg.bit_offset_13_7=4 + +sff_cpld_reg.mode_14_7=config +sff_cpld_reg.src_14_7=cpld +sff_cpld_reg.frmt_14_7=bit +sff_cpld_reg.addr_14_7=0x00030033 +sff_cpld_reg.len_14_7=1 +sff_cpld_reg.bit_offset_14_7=5 + +sff_cpld_reg.mode_15_7=config +sff_cpld_reg.src_15_7=cpld +sff_cpld_reg.frmt_15_7=bit +sff_cpld_reg.addr_15_7=0x00030033 +sff_cpld_reg.len_15_7=1 +sff_cpld_reg.bit_offset_15_7=6 + +sff_cpld_reg.mode_16_7=config +sff_cpld_reg.src_16_7=cpld +sff_cpld_reg.frmt_16_7=bit +sff_cpld_reg.addr_16_7=0x00030033 +sff_cpld_reg.len_16_7=1 +sff_cpld_reg.bit_offset_16_7=7 + +sff_cpld_reg.mode_17_7=config +sff_cpld_reg.src_17_7=cpld +sff_cpld_reg.frmt_17_7=bit +sff_cpld_reg.addr_17_7=0x00020037 +sff_cpld_reg.len_17_7=1 +sff_cpld_reg.bit_offset_17_7=0 + +sff_cpld_reg.mode_18_7=config +sff_cpld_reg.src_18_7=cpld +sff_cpld_reg.frmt_18_7=bit +sff_cpld_reg.addr_18_7=0x00020037 +sff_cpld_reg.len_18_7=1 +sff_cpld_reg.bit_offset_18_7=1 + +sff_cpld_reg.mode_19_7=config +sff_cpld_reg.src_19_7=cpld +sff_cpld_reg.frmt_19_7=bit +sff_cpld_reg.addr_19_7=0x00020037 +sff_cpld_reg.len_19_7=1 +sff_cpld_reg.bit_offset_19_7=2 + +sff_cpld_reg.mode_20_7=config +sff_cpld_reg.src_20_7=cpld +sff_cpld_reg.frmt_20_7=bit +sff_cpld_reg.addr_20_7=0x00020037 +sff_cpld_reg.len_20_7=1 +sff_cpld_reg.bit_offset_20_7=3 + +sff_cpld_reg.mode_21_7=config +sff_cpld_reg.src_21_7=cpld +sff_cpld_reg.frmt_21_7=bit +sff_cpld_reg.addr_21_7=0x00020037 +sff_cpld_reg.len_21_7=1 +sff_cpld_reg.bit_offset_21_7=4 + +sff_cpld_reg.mode_22_7=config +sff_cpld_reg.src_22_7=cpld +sff_cpld_reg.frmt_22_7=bit +sff_cpld_reg.addr_22_7=0x00020037 +sff_cpld_reg.len_22_7=1 +sff_cpld_reg.bit_offset_22_7=5 + +sff_cpld_reg.mode_23_7=config +sff_cpld_reg.src_23_7=cpld +sff_cpld_reg.frmt_23_7=bit +sff_cpld_reg.addr_23_7=0x00020037 +sff_cpld_reg.len_23_7=1 +sff_cpld_reg.bit_offset_23_7=6 + +sff_cpld_reg.mode_24_7=config +sff_cpld_reg.src_24_7=cpld +sff_cpld_reg.frmt_24_7=bit +sff_cpld_reg.addr_24_7=0x00020037 +sff_cpld_reg.len_24_7=1 +sff_cpld_reg.bit_offset_24_7=7 + +sff_cpld_reg.mode_25_7=config +sff_cpld_reg.src_25_7=cpld +sff_cpld_reg.frmt_25_7=bit +sff_cpld_reg.addr_25_7=0x00020038 +sff_cpld_reg.len_25_7=1 +sff_cpld_reg.bit_offset_25_7=0 + +sff_cpld_reg.mode_26_7=config +sff_cpld_reg.src_26_7=cpld +sff_cpld_reg.frmt_26_7=bit +sff_cpld_reg.addr_26_7=0x00020038 +sff_cpld_reg.len_26_7=1 +sff_cpld_reg.bit_offset_26_7=1 + +sff_cpld_reg.mode_27_7=config +sff_cpld_reg.src_27_7=cpld +sff_cpld_reg.frmt_27_7=bit +sff_cpld_reg.addr_27_7=0x00020038 +sff_cpld_reg.len_27_7=1 +sff_cpld_reg.bit_offset_27_7=2 + +sff_cpld_reg.mode_28_7=config +sff_cpld_reg.src_28_7=cpld +sff_cpld_reg.frmt_28_7=bit +sff_cpld_reg.addr_28_7=0x00020038 +sff_cpld_reg.len_28_7=1 +sff_cpld_reg.bit_offset_28_7=3 + +sff_cpld_reg.mode_29_7=config +sff_cpld_reg.src_29_7=cpld +sff_cpld_reg.frmt_29_7=bit +sff_cpld_reg.addr_29_7=0x00020038 +sff_cpld_reg.len_29_7=1 +sff_cpld_reg.bit_offset_29_7=4 + +sff_cpld_reg.mode_30_7=config +sff_cpld_reg.src_30_7=cpld +sff_cpld_reg.frmt_30_7=bit +sff_cpld_reg.addr_30_7=0x00020038 +sff_cpld_reg.len_30_7=1 +sff_cpld_reg.bit_offset_30_7=5 + +sff_cpld_reg.mode_31_7=config +sff_cpld_reg.src_31_7=cpld +sff_cpld_reg.frmt_31_7=bit +sff_cpld_reg.addr_31_7=0x00020038 +sff_cpld_reg.len_31_7=1 +sff_cpld_reg.bit_offset_31_7=6 + +sff_cpld_reg.mode_32_7=config +sff_cpld_reg.src_32_7=cpld +sff_cpld_reg.frmt_32_7=bit +sff_cpld_reg.addr_32_7=0x00020038 +sff_cpld_reg.len_32_7=1 +sff_cpld_reg.bit_offset_32_7=7 diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-V2-SENSOR.cfg b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-V2-SENSOR.cfg new file mode 100755 index 000000000000..bfffc5edab73 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-V2-SENSOR.cfg @@ -0,0 +1,1348 @@ +# temp sensor number +dev_num_0_1=21 + +# voltage sensor number +dev_num_0_2=30 + +# current sensor number +dev_num_0_3=7 + +# sensor temp1 input +hwmon_temp.mode_0x0001_0x00=config +hwmon_temp.int_cons_0x0001_0x00=0 +hwmon_temp.src_0x0001_0x00=file +hwmon_temp.frmt_0x0001_0x00=buf +hwmon_temp.fpath_0x0001_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0001_0x00=0 +hwmon_temp.len_0x0001_0x00=8 +hwmon_temp.bit_offset_0x0001_0x00= +hwmon_temp.str_cons_0x0001_0x00=temp1_input + +# sensor temp1 alias +hwmon_temp.mode_0x0001_0x01=config +hwmon_temp.int_cons_0x0001_0x01= +hwmon_temp.src_0x0001_0x01=file +hwmon_temp.frmt_0x0001_0x01=buf +hwmon_temp.fpath_0x0001_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0001_0x01=0 +hwmon_temp.len_0x0001_0x01=16 +hwmon_temp.bit_offset_0x0001_0x01= +hwmon_temp.str_cons_0x0001_0x01=temp1_label + +hwmon_temp.mode_0x0001_0x02=str_constant +hwmon_temp.str_cons_0x0001_0x02=cpu + +# sensor temp1 max +hwmon_temp.mode_0x0001_0x03=config +hwmon_temp.int_cons_0x0001_0x03=0 +hwmon_temp.src_0x0001_0x03=file +hwmon_temp.frmt_0x0001_0x03=buf +hwmon_temp.fpath_0x0001_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0001_0x03=0 +hwmon_temp.len_0x0001_0x03=8 +hwmon_temp.bit_offset_0x0001_0x03= +hwmon_temp.str_cons_0x0001_0x03=temp1_max + + +# sensor temp2 input +hwmon_temp.mode_0x0002_0x00=config +hwmon_temp.int_cons_0x0002_0x00=0 +hwmon_temp.src_0x0002_0x00=file +hwmon_temp.frmt_0x0002_0x00=buf +hwmon_temp.fpath_0x0002_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0002_0x00=0 +hwmon_temp.len_0x0002_0x00=8 +hwmon_temp.bit_offset_0x0002_0x00= +hwmon_temp.str_cons_0x0002_0x00=temp2_input + +# sensor temp2 alias +hwmon_temp.mode_0x0002_0x01=config +hwmon_temp.int_cons_0x0002_0x01= +hwmon_temp.src_0x0002_0x01=file +hwmon_temp.frmt_0x0002_0x01=buf +hwmon_temp.fpath_0x0002_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0002_0x01=0 +hwmon_temp.len_0x0002_0x01=16 +hwmon_temp.bit_offset_0x0002_0x01= +hwmon_temp.str_cons_0x0002_0x01=temp2_label + +hwmon_temp.mode_0x0002_0x02=str_constant +hwmon_temp.str_cons_0x0002_0x02=cpu + +# sensor temp2 max +hwmon_temp.mode_0x0002_0x03=config +hwmon_temp.int_cons_0x0002_0x03=0 +hwmon_temp.src_0x0002_0x03=file +hwmon_temp.frmt_0x0002_0x03=buf +hwmon_temp.fpath_0x0002_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0002_0x03=0 +hwmon_temp.len_0x0002_0x03=8 +hwmon_temp.bit_offset_0x0002_0x03= +hwmon_temp.str_cons_0x0002_0x03=temp2_max + + +# sensor temp3 input +hwmon_temp.mode_0x0003_0x00=config +hwmon_temp.int_cons_0x0003_0x00=0 +hwmon_temp.src_0x0003_0x00=file +hwmon_temp.frmt_0x0003_0x00=buf +hwmon_temp.fpath_0x0003_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0003_0x00=0 +hwmon_temp.len_0x0003_0x00=8 +hwmon_temp.bit_offset_0x0003_0x00= +hwmon_temp.str_cons_0x0003_0x00=temp3_input + +# sensor temp3 alias +hwmon_temp.mode_0x0003_0x01=config +hwmon_temp.int_cons_0x0003_0x01= +hwmon_temp.src_0x0003_0x01=file +hwmon_temp.frmt_0x0003_0x01=buf +hwmon_temp.fpath_0x0003_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0003_0x01=0 +hwmon_temp.len_0x0003_0x01=16 +hwmon_temp.bit_offset_0x0003_0x01= +hwmon_temp.str_cons_0x0003_0x01=temp3_label + +hwmon_temp.mode_0x0003_0x02=str_constant +hwmon_temp.str_cons_0x0003_0x02=cpu + +# sensor temp3 max +hwmon_temp.mode_0x0003_0x03=config +hwmon_temp.int_cons_0x0003_0x03=0 +hwmon_temp.src_0x0003_0x03=file +hwmon_temp.frmt_0x0003_0x03=buf +hwmon_temp.fpath_0x0003_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0003_0x03=0 +hwmon_temp.len_0x0003_0x03=8 +hwmon_temp.bit_offset_0x0003_0x03= +hwmon_temp.str_cons_0x0003_0x03=temp3_max + + +# sensor temp4 input +hwmon_temp.mode_0x0004_0x00=config +hwmon_temp.int_cons_0x0004_0x00=0 +hwmon_temp.src_0x0004_0x00=file +hwmon_temp.frmt_0x0004_0x00=buf +hwmon_temp.fpath_0x0004_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0004_0x00=0 +hwmon_temp.len_0x0004_0x00=8 +hwmon_temp.bit_offset_0x0004_0x00= +hwmon_temp.str_cons_0x0004_0x00=temp4_input + +# sensor temp4 alias +hwmon_temp.mode_0x0004_0x01=config +hwmon_temp.int_cons_0x0004_0x01= +hwmon_temp.src_0x0004_0x01=file +hwmon_temp.frmt_0x0004_0x01=buf +hwmon_temp.fpath_0x0004_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0004_0x01=0 +hwmon_temp.len_0x0004_0x01=16 +hwmon_temp.bit_offset_0x0004_0x01= +hwmon_temp.str_cons_0x0004_0x01=temp4_label + +hwmon_temp.mode_0x0004_0x02=str_constant +hwmon_temp.str_cons_0x0004_0x02=cpu + +# sensor temp4 max +hwmon_temp.mode_0x0004_0x03=config +hwmon_temp.int_cons_0x0004_0x03=0 +hwmon_temp.src_0x0004_0x03=file +hwmon_temp.frmt_0x0004_0x03=buf +hwmon_temp.fpath_0x0004_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0004_0x03=0 +hwmon_temp.len_0x0004_0x03=8 +hwmon_temp.bit_offset_0x0004_0x03= +hwmon_temp.str_cons_0x0004_0x03=temp4_max + + +# sensor temp5 input +hwmon_temp.mode_0x0005_0x00=config +hwmon_temp.int_cons_0x0005_0x00=0 +hwmon_temp.src_0x0005_0x00=file +hwmon_temp.frmt_0x0005_0x00=buf +hwmon_temp.fpath_0x0005_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0005_0x00=0 +hwmon_temp.len_0x0005_0x00=8 +hwmon_temp.bit_offset_0x0005_0x00= +hwmon_temp.str_cons_0x0005_0x00=temp5_input + +# sensor temp5 alias +hwmon_temp.mode_0x0005_0x01=config +hwmon_temp.int_cons_0x0005_0x01= +hwmon_temp.src_0x0005_0x01=file +hwmon_temp.frmt_0x0005_0x01=buf +hwmon_temp.fpath_0x0005_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0005_0x01=0 +hwmon_temp.len_0x0005_0x01=16 +hwmon_temp.bit_offset_0x0005_0x01= +hwmon_temp.str_cons_0x0005_0x01=temp5_label + +hwmon_temp.mode_0x0005_0x02=str_constant +hwmon_temp.str_cons_0x0005_0x02=cpu + +# sensor temp5 max +hwmon_temp.mode_0x0005_0x03=config +hwmon_temp.int_cons_0x0005_0x03=0 +hwmon_temp.src_0x0005_0x03=file +hwmon_temp.frmt_0x0005_0x03=buf +hwmon_temp.fpath_0x0005_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0005_0x03=0 +hwmon_temp.len_0x0005_0x03=8 +hwmon_temp.bit_offset_0x0005_0x03= +hwmon_temp.str_cons_0x0005_0x03=temp5_max + +# sensor temp6 input +hwmon_temp.mode_0x0006_0x00=config +hwmon_temp.int_cons_0x0006_0x00=3 +hwmon_temp.src_0x0006_0x00=file +hwmon_temp.frmt_0x0006_0x00=buf +hwmon_temp.fpath_0x0006_0x00=/sys/bus/i2c/devices/40-004f/hwmon/ +hwmon_temp.addr_0x0006_0x00=0 +hwmon_temp.len_0x0006_0x00=8 +hwmon_temp.bit_offset_0x0006_0x00=0 +hwmon_temp.str_cons_0x0006_0x00=temp1_input +hwmon_temp.int_extra1_0x0006_0x00=1000 +hwmon_temp.int_extra2_0x0006_0x00=-3000 + +# sensor temp6 alias +hwmon_temp.mode_0x0006_0x01=str_constant +hwmon_temp.str_cons_0x0006_0x01=air_inlet_TL + +# sensor temp6 type +hwmon_temp.mode_0x0006_0x02=str_constant +hwmon_temp.str_cons_0x0006_0x02=lm75 + +# sensor temp6 max +hwmon_temp.mode_0x0006_0x03=config +hwmon_temp.int_cons_0x0006_0x03=0 +hwmon_temp.src_0x0006_0x03=file +hwmon_temp.frmt_0x0006_0x03=buf +hwmon_temp.fpath_0x0006_0x03=/sys/bus/i2c/devices/40-004f/hwmon/ +hwmon_temp.addr_0x0006_0x03=0 +hwmon_temp.len_0x0006_0x03=8 +hwmon_temp.bit_offset_0x0006_0x03= +hwmon_temp.str_cons_0x0006_0x03=temp1_max + +# sensor temp6 max_hyst +hwmon_temp.mode_0x0006_0x04=config +hwmon_temp.int_cons_0x0006_0x04=0 +hwmon_temp.src_0x0006_0x04=file +hwmon_temp.frmt_0x0006_0x04=buf +hwmon_temp.fpath_0x0006_0x04=/sys/bus/i2c/devices/40-004f/hwmon/ +hwmon_temp.addr_0x0006_0x04=0 +hwmon_temp.len_0x0006_0x04=8 +hwmon_temp.bit_offset_0x0006_0x04= +hwmon_temp.str_cons_0x0006_0x04=temp1_max_hyst + + +# sensor temp7 input +hwmon_temp.mode_0x0007_0x00=config +hwmon_temp.int_cons_0x0007_0x00=0 +hwmon_temp.src_0x0007_0x00=file +hwmon_temp.frmt_0x0007_0x00=buf +hwmon_temp.fpath_0x0007_0x00=/sys/bus/i2c/devices/39-004b/hwmon/ +hwmon_temp.addr_0x0007_0x00=0 +hwmon_temp.len_0x0007_0x00=8 +hwmon_temp.bit_offset_0x0007_0x00= +hwmon_temp.str_cons_0x0007_0x00=temp1_input + +# sensor temp7 alias +hwmon_temp.mode_0x0007_0x01=str_constant +hwmon_temp.str_cons_0x0007_0x01=air_inlet_BL + +# sensor temp7 type +hwmon_temp.mode_0x0007_0x02=str_constant +hwmon_temp.str_cons_0x0007_0x02=lm75 + +# sensor temp7 max +hwmon_temp.mode_0x0007_0x03=config +hwmon_temp.int_cons_0x0007_0x03=0 +hwmon_temp.src_0x0007_0x03=file +hwmon_temp.frmt_0x0007_0x03=buf +hwmon_temp.fpath_0x0007_0x03=/sys/bus/i2c/devices/39-004b/hwmon/ +hwmon_temp.addr_0x0007_0x03=0 +hwmon_temp.len_0x0007_0x03=8 +hwmon_temp.bit_offset_0x0007_0x03= +hwmon_temp.str_cons_0x0007_0x03=temp1_max + +# sensor temp7 max_hyst +hwmon_temp.mode_0x0007_0x04=config +hwmon_temp.int_cons_0x0007_0x04=0 +hwmon_temp.src_0x0007_0x04=file +hwmon_temp.frmt_0x0007_0x04=buf +hwmon_temp.fpath_0x0007_0x04=/sys/bus/i2c/devices/39-004b/hwmon/ +hwmon_temp.addr_0x0007_0x04=0 +hwmon_temp.len_0x0007_0x04=8 +hwmon_temp.bit_offset_0x0007_0x04= +hwmon_temp.str_cons_0x0007_0x04=temp1_max_hyst + + +# sensor temp8 input +hwmon_temp.mode_0x0008_0x00=config +hwmon_temp.int_cons_0x0008_0x00=0 +hwmon_temp.src_0x0008_0x00=file +hwmon_temp.frmt_0x0008_0x00=buf +hwmon_temp.fpath_0x0008_0x00=/sys/bus/i2c/devices/36-0048/hwmon/ +hwmon_temp.addr_0x0008_0x00=0 +hwmon_temp.len_0x0008_0x00=8 +hwmon_temp.bit_offset_0x0008_0x00= +hwmon_temp.str_cons_0x0008_0x00=temp1_input + +# sensor temp8 alias +hwmon_temp.mode_0x0008_0x01=str_constant +hwmon_temp.str_cons_0x0008_0x01=air_outlet_L + +# sensor temp8 type +hwmon_temp.mode_0x0008_0x02=str_constant +hwmon_temp.str_cons_0x0008_0x02=lm75 + +# sensor temp8 max +hwmon_temp.mode_0x0008_0x03=config +hwmon_temp.int_cons_0x0008_0x03=0 +hwmon_temp.src_0x0008_0x03=file +hwmon_temp.frmt_0x0008_0x03=buf +hwmon_temp.fpath_0x0008_0x03=/sys/bus/i2c/devices/36-0048/hwmon/ +hwmon_temp.addr_0x0008_0x03=0 +hwmon_temp.len_0x0008_0x03=8 +hwmon_temp.bit_offset_0x0008_0x03= +hwmon_temp.str_cons_0x0008_0x03=temp1_max + +# sensor temp8 max_hyst +hwmon_temp.mode_0x0008_0x04=config +hwmon_temp.int_cons_0x0008_0x04=0 +hwmon_temp.src_0x0008_0x04=file +hwmon_temp.frmt_0x0008_0x04=buf +hwmon_temp.fpath_0x0008_0x04=/sys/bus/i2c/devices/36-0048/hwmon/ +hwmon_temp.addr_0x0008_0x04=0 +hwmon_temp.len_0x0008_0x04=8 +hwmon_temp.bit_offset_0x0008_0x04= +hwmon_temp.str_cons_0x0008_0x04=temp1_max_hyst + + +# sensor temp9 input +hwmon_temp.mode_0x0009_0x00=config +hwmon_temp.int_cons_0x0009_0x00=0 +hwmon_temp.src_0x0009_0x00=file +hwmon_temp.frmt_0x0009_0x00=buf +hwmon_temp.fpath_0x0009_0x00=/sys/bus/i2c/devices/36-0049/hwmon/ +hwmon_temp.addr_0x0009_0x00=0 +hwmon_temp.len_0x0009_0x00=8 +hwmon_temp.bit_offset_0x0009_0x00= +hwmon_temp.str_cons_0x0009_0x00=temp1_input + +# sensor temp9 alias +hwmon_temp.mode_0x0009_0x01=str_constant +hwmon_temp.str_cons_0x0009_0x01=air_outlet_R + +# sensor temp9 type +hwmon_temp.mode_0x0009_0x02=str_constant +hwmon_temp.str_cons_0x0009_0x02=lm75 + +# sensor temp9 max +hwmon_temp.mode_0x0009_0x03=config +hwmon_temp.int_cons_0x0009_0x03=0 +hwmon_temp.src_0x0009_0x03=file +hwmon_temp.frmt_0x0009_0x03=buf +hwmon_temp.fpath_0x0009_0x03=/sys/bus/i2c/devices/36-0049/hwmon/ +hwmon_temp.addr_0x0009_0x03=0 +hwmon_temp.len_0x0009_0x03=8 +hwmon_temp.bit_offset_0x0009_0x03= +hwmon_temp.str_cons_0x0009_0x03=temp1_max + +# sensor temp9 max_hyst +hwmon_temp.mode_0x0009_0x04=config +hwmon_temp.int_cons_0x0009_0x04=0 +hwmon_temp.src_0x0009_0x04=file +hwmon_temp.frmt_0x0009_0x04=buf +hwmon_temp.fpath_0x0009_0x04=/sys/bus/i2c/devices/36-0049/hwmon/ +hwmon_temp.addr_0x0009_0x04=0 +hwmon_temp.len_0x0009_0x04=8 +hwmon_temp.bit_offset_0x0009_0x04= +hwmon_temp.str_cons_0x0009_0x04=temp1_max_hyst + + +# sensor temp10 input +hwmon_temp.mode_0x000a_0x00=config +hwmon_temp.int_cons_0x000a_0x00=0 +hwmon_temp.src_0x000a_0x00=file +hwmon_temp.frmt_0x000a_0x00=buf +hwmon_temp.fpath_0x000a_0x00=/sys/bus/i2c/devices/40-004e/hwmon/ +hwmon_temp.addr_0x000a_0x00=0 +hwmon_temp.len_0x000a_0x00=8 +hwmon_temp.bit_offset_0x000a_0x00= +hwmon_temp.str_cons_0x000a_0x00=temp1_input + +# sensor temp10 alias +hwmon_temp.mode_0x000a_0x01=str_constant +hwmon_temp.str_cons_0x000a_0x01=air_hotlet + +# sensor temp10 type +hwmon_temp.mode_0x000a_0x02=str_constant +hwmon_temp.str_cons_0x000a_0x02=lm75 + +# sensor temp10 max +hwmon_temp.mode_0x000a_0x03=config +hwmon_temp.int_cons_0x000a_0x03=0 +hwmon_temp.src_0x000a_0x03=file +hwmon_temp.frmt_0x000a_0x03=buf +hwmon_temp.fpath_0x000a_0x03=/sys/bus/i2c/devices/40-004e/hwmon/ +hwmon_temp.addr_0x000a_0x03=0 +hwmon_temp.len_0x000a_0x03=8 +hwmon_temp.bit_offset_0x000a_0x03= +hwmon_temp.str_cons_0x000a_0x03=temp1_max + +# sensor temp10 max_hyst +hwmon_temp.mode_0x000a_0x04=config +hwmon_temp.int_cons_0x000a_0x04=0 +hwmon_temp.src_0x000a_0x04=file +hwmon_temp.frmt_0x000a_0x04=buf +hwmon_temp.fpath_0x000a_0x04=/sys/bus/i2c/devices/40-004e/hwmon/ +hwmon_temp.addr_0x000a_0x04=0 +hwmon_temp.len_0x000a_0x04=8 +hwmon_temp.bit_offset_0x000a_0x04= +hwmon_temp.str_cons_0x000a_0x04=temp1_max_hyst + + +# sensor temp11 input +hwmon_temp.mode_0x000b_0x00=config +hwmon_temp.int_cons_0x000b_0x00=0 +hwmon_temp.src_0x000b_0x00=file +hwmon_temp.frmt_0x000b_0x00=buf +hwmon_temp.fpath_0x000b_0x00=/sys/bus/i2c/devices/39-004c/hwmon/ +hwmon_temp.addr_0x000b_0x00=0 +hwmon_temp.len_0x000b_0x00=8 +hwmon_temp.bit_offset_0x000b_0x00= +hwmon_temp.str_cons_0x000b_0x00=temp2_input + +# sensor temp11 alias +hwmon_temp.mode_0x000b_0x01=str_constant +hwmon_temp.str_cons_0x000b_0x01=MAC_PACKAGE0 + +# sensor temp11 type +hwmon_temp.mode_0x000b_0x02=str_constant +hwmon_temp.str_cons_0x000b_0x02=tmp411 + +# sensor temp11 max +hwmon_temp.mode_0x000b_0x03=config +hwmon_temp.int_cons_0x000b_0x03=0 +hwmon_temp.src_0x000b_0x03=file +hwmon_temp.frmt_0x000b_0x03=buf +hwmon_temp.fpath_0x000b_0x03=/sys/bus/i2c/devices/39-004c/hwmon/ +hwmon_temp.addr_0x000b_0x03=0 +hwmon_temp.len_0x000b_0x03=8 +hwmon_temp.bit_offset_0x000b_0x03= +hwmon_temp.str_cons_0x000b_0x03=temp2_max + +# sensor temp12 input +hwmon_temp.mode_0x000c_0x00=config +hwmon_temp.int_cons_0x000c_0x00=0 +hwmon_temp.src_0x000c_0x00=file +hwmon_temp.frmt_0x000c_0x00=buf +hwmon_temp.fpath_0x000c_0x00=/sys/bus/i2c/devices/40-004c/hwmon/ +hwmon_temp.addr_0x000c_0x00=0 +hwmon_temp.len_0x000c_0x00=8 +hwmon_temp.bit_offset_0x000c_0x00= +hwmon_temp.str_cons_0x000c_0x00=temp2_input + +# sensor temp12 alias +hwmon_temp.mode_0x000c_0x01=str_constant +hwmon_temp.str_cons_0x000c_0x01=MAC_PACKAGE1 + +# sensor temp12 type +hwmon_temp.mode_0x000c_0x02=str_constant +hwmon_temp.str_cons_0x000c_0x02=tmp411 + +# sensor temp12 max +hwmon_temp.mode_0x000c_0x03=config +hwmon_temp.int_cons_0x000c_0x03=0 +hwmon_temp.src_0x000c_0x03=file +hwmon_temp.frmt_0x000c_0x03=buf +hwmon_temp.fpath_0x000c_0x03=/sys/bus/i2c/devices/40-004c/hwmon/ +hwmon_temp.addr_0x000c_0x03=0 +hwmon_temp.len_0x000c_0x03=8 +hwmon_temp.bit_offset_0x000c_0x03= +hwmon_temp.str_cons_0x000c_0x03=temp2_max + +# sensor temp13 input +hwmon_temp.mode_0x000d_0x00=config +hwmon_temp.int_cons_0x000d_0x00=0 +hwmon_temp.src_0x000d_0x00=file +hwmon_temp.frmt_0x000d_0x00=buf +hwmon_temp.fpath_0x000d_0x00=/sys/bus/i2c/devices/44-0044/hwmon/ +hwmon_temp.addr_0x000d_0x00=0 +hwmon_temp.len_0x000d_0x00=16 +hwmon_temp.bit_offset_0x000d_0x00= +hwmon_temp.str_cons_0x000d_0x00=temp1_input + +# sensor temp13 alias +hwmon_temp.mode_0x000d_0x01=str_constant +hwmon_temp.str_cons_0x000d_0x01=MAC_DIE_0 + +# sensor temp13 type +hwmon_temp.mode_0x000d_0x02=str_constant +hwmon_temp.str_cons_0x000d_0x02=mac_bsc + + +# sensor temp14 input +hwmon_temp.mode_0x000e_0x00=config +hwmon_temp.int_cons_0x000e_0x00=0 +hwmon_temp.src_0x000e_0x00=file +hwmon_temp.frmt_0x000e_0x00=buf +hwmon_temp.fpath_0x000e_0x00=/sys/bus/i2c/devices/44-0044/hwmon/ +hwmon_temp.addr_0x000e_0x00=0 +hwmon_temp.len_0x000e_0x00=16 +hwmon_temp.bit_offset_0x000e_0x00= +hwmon_temp.str_cons_0x000e_0x00=temp2_input + +# sensor temp14 alias +hwmon_temp.mode_0x000e_0x01=str_constant +hwmon_temp.str_cons_0x000e_0x01=MAC_DIE_1 + +# sensor temp14 type +hwmon_temp.mode_0x000e_0x02=str_constant +hwmon_temp.str_cons_0x000e_0x02=mac_bsc + + +# sensor temp15 input +hwmon_temp.mode_0x000f_0x00=config +hwmon_temp.int_cons_0x000f_0x00=0 +hwmon_temp.src_0x000f_0x00=file +hwmon_temp.frmt_0x000f_0x00=buf +hwmon_temp.fpath_0x000f_0x00=/sys/bus/i2c/devices/44-0044/hwmon/ +hwmon_temp.addr_0x000f_0x00=0 +hwmon_temp.len_0x000f_0x00=16 +hwmon_temp.bit_offset_0x000f_0x00= +hwmon_temp.str_cons_0x000f_0x00=temp3_input + +# sensor temp15 alias +hwmon_temp.mode_0x000f_0x01=str_constant +hwmon_temp.str_cons_0x000f_0x01=MAC_DIE_2 + +# sensor temp15 type +hwmon_temp.mode_0x000f_0x02=str_constant +hwmon_temp.str_cons_0x000f_0x02=mac_bsc + + +# sensor temp16 input +hwmon_temp.mode_0x0010_0x00=config +hwmon_temp.int_cons_0x0010_0x00=0 +hwmon_temp.src_0x0010_0x00=file +hwmon_temp.frmt_0x0010_0x00=buf +hwmon_temp.fpath_0x0010_0x00=/sys/bus/i2c/devices/44-0044/hwmon/ +hwmon_temp.addr_0x0010_0x00=0 +hwmon_temp.len_0x0010_0x00=16 +hwmon_temp.bit_offset_0x0010_0x00= +hwmon_temp.str_cons_0x0010_0x00=temp4_input + +# sensor temp16 alias +hwmon_temp.mode_0x0010_0x01=str_constant +hwmon_temp.str_cons_0x0010_0x01=MAC_DIE_3 + +# sensor temp16 type +hwmon_temp.mode_0x0010_0x02=str_constant +hwmon_temp.str_cons_0x0010_0x02=mac_bsc + + +# sensor temp17 input +hwmon_temp.mode_0x0011_0x00=config +hwmon_temp.int_cons_0x0011_0x00=0 +hwmon_temp.src_0x0011_0x00=file +hwmon_temp.frmt_0x0011_0x00=buf +hwmon_temp.fpath_0x0011_0x00=/sys/bus/i2c/devices/44-0044/hwmon/ +hwmon_temp.addr_0x0011_0x00=0 +hwmon_temp.len_0x0011_0x00=16 +hwmon_temp.bit_offset_0x0011_0x00= +hwmon_temp.str_cons_0x0011_0x00=temp5_input + +# sensor temp17 alias +hwmon_temp.mode_0x0011_0x01=str_constant +hwmon_temp.str_cons_0x0011_0x01=MAC_DIE_4 + +# sensor temp17 type +hwmon_temp.mode_0x0011_0x02=str_constant +hwmon_temp.str_cons_0x0011_0x02=mac_bsc + + +# sensor temp18 input +hwmon_temp.mode_0x0012_0x00=config +hwmon_temp.int_cons_0x0012_0x00=0 +hwmon_temp.src_0x0012_0x00=file +hwmon_temp.frmt_0x0012_0x00=buf +hwmon_temp.fpath_0x0012_0x00=/sys/bus/i2c/devices/44-0044/hwmon/ +hwmon_temp.addr_0x0012_0x00=0 +hwmon_temp.len_0x0012_0x00=16 +hwmon_temp.bit_offset_0x0012_0x00= +hwmon_temp.str_cons_0x0012_0x00=temp6_input + +# sensor temp18 alias +hwmon_temp.mode_0x0012_0x01=str_constant +hwmon_temp.str_cons_0x0012_0x01=MAC_DIE_5 + +# sensor temp18 type +hwmon_temp.mode_0x0012_0x02=str_constant +hwmon_temp.str_cons_0x0012_0x02=mac_bsc + + +# sensor temp19 input +hwmon_temp.mode_0x0013_0x00=config +hwmon_temp.int_cons_0x0013_0x00=0 +hwmon_temp.src_0x0013_0x00=file +hwmon_temp.frmt_0x0013_0x00=buf +hwmon_temp.fpath_0x0013_0x00=/sys/bus/i2c/devices/44-0044/hwmon/ +hwmon_temp.addr_0x0013_0x00=0 +hwmon_temp.len_0x0013_0x00=16 +hwmon_temp.bit_offset_0x0013_0x00= +hwmon_temp.str_cons_0x0013_0x00=temp7_input + +# sensor temp19 alias +hwmon_temp.mode_0x0013_0x01=str_constant +hwmon_temp.str_cons_0x0013_0x01=MAC_DIE_6 + +# sensor temp19 type +hwmon_temp.mode_0x0013_0x02=str_constant +hwmon_temp.str_cons_0x0013_0x02=mac_bsc + + +# sensor temp20 input +hwmon_temp.mode_0x0014_0x00=config +hwmon_temp.int_cons_0x0014_0x00=0 +hwmon_temp.src_0x0014_0x00=file +hwmon_temp.frmt_0x0014_0x00=buf +hwmon_temp.fpath_0x0014_0x00=/sys/bus/i2c/devices/44-0044/hwmon/ +hwmon_temp.addr_0x0014_0x00=0 +hwmon_temp.len_0x0014_0x00=16 +hwmon_temp.bit_offset_0x0014_0x00= +hwmon_temp.str_cons_0x0014_0x00=temp8_input + +# sensor temp20 alias +hwmon_temp.mode_0x0014_0x01=str_constant +hwmon_temp.str_cons_0x0014_0x01=MAC_DIE_7 + +# sensor temp20 type +hwmon_temp.mode_0x0014_0x02=str_constant +hwmon_temp.str_cons_0x0014_0x02=mac_bsc + + +# sensor temp21 input +hwmon_temp.mode_0x0015_0x00=config +hwmon_temp.int_cons_0x0015_0x00=0 +hwmon_temp.src_0x0015_0x00=file +hwmon_temp.frmt_0x0015_0x00=buf +hwmon_temp.fpath_0x0015_0x00=/sys/bus/i2c/devices/44-0044/hwmon/ +hwmon_temp.addr_0x0015_0x00=0 +hwmon_temp.len_0x0015_0x00=16 +hwmon_temp.bit_offset_0x0015_0x00= +hwmon_temp.str_cons_0x0015_0x00=temp9_input + +# sensor temp21 alias +hwmon_temp.mode_0x0015_0x01=str_constant +hwmon_temp.str_cons_0x0015_0x01=MAC_DIE_8 + +# sensor temp21 type +hwmon_temp.mode_0x0015_0x02=str_constant +hwmon_temp.str_cons_0x0015_0x02=mac_bsc + + +# 2:type 3:max 4:max_hyst 5:min 6:crit +# in1 +hwmon_in.mode_0x0001_0x00=config +hwmon_in.int_cons_0x0001_0x00=0 +hwmon_in.src_0x0001_0x00=file +hwmon_in.frmt_0x0001_0x00=buf +hwmon_in.fpath_0x0001_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0001_0x00=0 +hwmon_in.len_0x0001_0x00=8 +hwmon_in.bit_offset_0x0001_0x00= +hwmon_in.str_cons_0x0001_0x00=in1_input +hwmon_in.mode_0x0001_0x01=str_constant +hwmon_in.str_cons_0x0001_0x01=MAC_BOARD_VDD5V_CLK_MCU +hwmon_in.mode_0x0001_0x02=str_constant +hwmon_in.str_cons_0x0001_0x02=ucd90160 +hwmon_in.mode_0x0001_0x03=constant +hwmon_in.int_cons_0x0001_0x03=5345 +hwmon_in.mode_0x0001_0x05=constant +hwmon_in.int_cons_0x0001_0x05=4840 +# in2 +hwmon_in.mode_0x0002_0x00=config +hwmon_in.int_cons_0x0002_0x00=0 +hwmon_in.src_0x0002_0x00=file +hwmon_in.frmt_0x0002_0x00=buf +hwmon_in.fpath_0x0002_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0002_0x00=0 +hwmon_in.len_0x0002_0x00=8 +hwmon_in.bit_offset_0x0002_0x00= +hwmon_in.str_cons_0x0002_0x00=in2_input +hwmon_in.mode_0x0002_0x01=str_constant +hwmon_in.str_cons_0x0002_0x01=MAC_BOARD_VDD3.3_CLK +hwmon_in.mode_0x0002_0x02=str_constant +hwmon_in.str_cons_0x0002_0x02=ucd90160 +hwmon_in.mode_0x0002_0x03=constant +hwmon_in.int_cons_0x0002_0x03=3560 +hwmon_in.mode_0x0002_0x05=constant +hwmon_in.int_cons_0x0002_0x05=3220 +# in3 +hwmon_in.mode_0x0003_0x00=config +hwmon_in.int_cons_0x0003_0x00=0 +hwmon_in.src_0x0003_0x00=file +hwmon_in.frmt_0x0003_0x00=buf +hwmon_in.fpath_0x0003_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0003_0x00=0 +hwmon_in.len_0x0003_0x00=8 +hwmon_in.bit_offset_0x0003_0x00= +hwmon_in.str_cons_0x0003_0x00=in3_input +hwmon_in.mode_0x0003_0x01=str_constant +hwmon_in.str_cons_0x0003_0x01=MAC_BOARD_VDD1.0V +hwmon_in.mode_0x0003_0x02=str_constant +hwmon_in.str_cons_0x0003_0x02=ucd90160 +hwmon_in.mode_0x0003_0x03=constant +hwmon_in.int_cons_0x0003_0x03=1049 +hwmon_in.mode_0x0003_0x05=constant +hwmon_in.int_cons_0x0003_0x05=950 +# in4 +hwmon_in.mode_0x0004_0x00=config +hwmon_in.int_cons_0x0004_0x00=0 +hwmon_in.src_0x0004_0x00=file +hwmon_in.frmt_0x0004_0x00=buf +hwmon_in.fpath_0x0004_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0004_0x00=0 +hwmon_in.len_0x0004_0x00=8 +hwmon_in.bit_offset_0x0004_0x00= +hwmon_in.str_cons_0x0004_0x00=in4_input +hwmon_in.mode_0x0004_0x01=str_constant +hwmon_in.str_cons_0x0004_0x01=MAC_BOARD_VDD1.8V +hwmon_in.mode_0x0004_0x02=str_constant +hwmon_in.str_cons_0x0004_0x02=ucd90160 +hwmon_in.mode_0x0004_0x03=constant +hwmon_in.int_cons_0x0004_0x03=1903 +hwmon_in.mode_0x0004_0x05=constant +hwmon_in.int_cons_0x0004_0x05=1720 +# in5 +hwmon_in.mode_0x0005_0x00=config +hwmon_in.int_cons_0x0005_0x00=0 +hwmon_in.src_0x0005_0x00=file +hwmon_in.frmt_0x0005_0x00=buf +hwmon_in.fpath_0x0005_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0005_0x00=0 +hwmon_in.len_0x0005_0x00=8 +hwmon_in.bit_offset_0x0005_0x00= +hwmon_in.str_cons_0x0005_0x00=in5_input +hwmon_in.mode_0x0005_0x01=str_constant +hwmon_in.str_cons_0x0005_0x01=MAC_BOARD_VDD3.3V +hwmon_in.mode_0x0005_0x02=str_constant +hwmon_in.str_cons_0x0005_0x02=ucd90160 +hwmon_in.mode_0x0005_0x03=constant +hwmon_in.int_cons_0x0005_0x03=3499 +hwmon_in.mode_0x0005_0x05=constant +hwmon_in.int_cons_0x0005_0x05=3170 +# in6 +hwmon_in.mode_0x0006_0x00=config +hwmon_in.int_cons_0x0006_0x00=0 +hwmon_in.src_0x0006_0x00=file +hwmon_in.frmt_0x0006_0x00=buf +hwmon_in.fpath_0x0006_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0006_0x00=0 +hwmon_in.len_0x0006_0x00=8 +hwmon_in.bit_offset_0x0006_0x00= +hwmon_in.str_cons_0x0006_0x00=in6_input +hwmon_in.mode_0x0006_0x01=str_constant +hwmon_in.str_cons_0x0006_0x01=MAC_BOARD_VDD1.2V +hwmon_in.mode_0x0006_0x02=str_constant +hwmon_in.str_cons_0x0006_0x02=ucd90160 +hwmon_in.mode_0x0006_0x03=constant +hwmon_in.int_cons_0x0006_0x03=1272 +hwmon_in.mode_0x0006_0x05=constant +hwmon_in.int_cons_0x0006_0x05=1150 +# in7 +hwmon_in.mode_0x0007_0x00=config +hwmon_in.int_cons_0x0007_0x00=0 +hwmon_in.src_0x0007_0x00=file +hwmon_in.frmt_0x0007_0x00=buf +hwmon_in.fpath_0x0007_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0007_0x00=0 +hwmon_in.len_0x0007_0x00=8 +hwmon_in.bit_offset_0x0007_0x00= +hwmon_in.str_cons_0x0007_0x00=in7_input +hwmon_in.mode_0x0007_0x01=str_constant +hwmon_in.str_cons_0x0007_0x01=MAC_BOARD_VDD_CORE +hwmon_in.mode_0x0007_0x02=str_constant +hwmon_in.str_cons_0x0007_0x02=ucd90160 +hwmon_in.mode_0x0007_0x03=constant +hwmon_in.int_cons_0x0007_0x03=950 +hwmon_in.mode_0x0007_0x05=constant +hwmon_in.int_cons_0x0007_0x05=670 +# in8 +hwmon_in.mode_0x0008_0x00=config +hwmon_in.int_cons_0x0008_0x00=0 +hwmon_in.src_0x0008_0x00=file +hwmon_in.frmt_0x0008_0x00=buf +hwmon_in.fpath_0x0008_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0008_0x00=0 +hwmon_in.len_0x0008_0x00=8 +hwmon_in.bit_offset_0x0008_0x00= +hwmon_in.str_cons_0x0008_0x00=in8_input +hwmon_in.mode_0x0008_0x01=str_constant +hwmon_in.str_cons_0x0008_0x01=MAC_BOARD_ANALOG0.75V +hwmon_in.mode_0x0008_0x02=str_constant +hwmon_in.str_cons_0x0008_0x02=ucd90160 +hwmon_in.mode_0x0008_0x03=constant +hwmon_in.int_cons_0x0008_0x03=800 +hwmon_in.mode_0x0008_0x05=constant +hwmon_in.int_cons_0x0008_0x05=700 +# in9 +hwmon_in.mode_0x0009_0x00=config +hwmon_in.int_cons_0x0009_0x00=0 +hwmon_in.src_0x0009_0x00=file +hwmon_in.frmt_0x0009_0x00=buf +hwmon_in.fpath_0x0009_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0009_0x00=0 +hwmon_in.len_0x0009_0x00=8 +hwmon_in.bit_offset_0x0009_0x00= +hwmon_in.str_cons_0x0009_0x00=in9_input +hwmon_in.mode_0x0009_0x01=str_constant +hwmon_in.str_cons_0x0009_0x01=MAC_BOARD_MAC_VDD1.2V +hwmon_in.mode_0x0009_0x02=str_constant +hwmon_in.str_cons_0x0009_0x02=ucd90160 +hwmon_in.mode_0x0009_0x03=constant +hwmon_in.int_cons_0x0009_0x03=1259 +hwmon_in.mode_0x0009_0x05=constant +hwmon_in.int_cons_0x0009_0x05=1140 +# in10 +hwmon_in.mode_0x000a_0x00=config +hwmon_in.int_cons_0x000a_0x00=0 +hwmon_in.src_0x000a_0x00=file +hwmon_in.frmt_0x000a_0x00=buf +hwmon_in.fpath_0x000a_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x000a_0x00=0 +hwmon_in.len_0x000a_0x00=8 +hwmon_in.bit_offset_0x000a_0x00= +hwmon_in.str_cons_0x000a_0x00=in10_input +hwmon_in.mode_0x000a_0x01=str_constant +hwmon_in.str_cons_0x000a_0x01=MAC_BOARD_VDDO1.8V +hwmon_in.mode_0x000a_0x02=str_constant +hwmon_in.str_cons_0x000a_0x02=ucd90160 +hwmon_in.mode_0x000a_0x03=constant +hwmon_in.int_cons_0x000a_0x03=1937 +hwmon_in.mode_0x000a_0x05=constant +hwmon_in.int_cons_0x000a_0x05=1750 +# in11 +hwmon_in.mode_0x000b_0x00=config +hwmon_in.int_cons_0x000b_0x00=0 +hwmon_in.src_0x000b_0x00=file +hwmon_in.frmt_0x000b_0x00=buf +hwmon_in.fpath_0x000b_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x000b_0x00=0 +hwmon_in.len_0x000b_0x00=8 +hwmon_in.bit_offset_0x000b_0x00= +hwmon_in.str_cons_0x000b_0x00=in11_input +hwmon_in.mode_0x000b_0x01=str_constant +hwmon_in.str_cons_0x000b_0x01=MAC_BOARD_MAC_ANA1.2V +hwmon_in.mode_0x000b_0x02=str_constant +hwmon_in.str_cons_0x000b_0x02=ucd90160 +hwmon_in.mode_0x000b_0x03=constant +hwmon_in.int_cons_0x000b_0x03=1276 +hwmon_in.mode_0x000b_0x05=constant +hwmon_in.int_cons_0x000b_0x05=1150 +# in12 +hwmon_in.mode_0x000c_0x00=config +hwmon_in.int_cons_0x000c_0x00=0 +hwmon_in.src_0x000c_0x00=file +hwmon_in.frmt_0x000c_0x00=buf +hwmon_in.fpath_0x000c_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x000c_0x00=0 +hwmon_in.len_0x000c_0x00=8 +hwmon_in.bit_offset_0x000c_0x00= +hwmon_in.str_cons_0x000c_0x00=in12_input +hwmon_in.mode_0x000c_0x01=str_constant +hwmon_in.str_cons_0x000c_0x01=MAC_BOARD_MAC_ANA1.8V +hwmon_in.mode_0x000c_0x02=str_constant +hwmon_in.str_cons_0x000c_0x02=ucd90160 +hwmon_in.mode_0x000c_0x03=constant +hwmon_in.int_cons_0x000c_0x03=1910 +hwmon_in.mode_0x000c_0x05=constant +hwmon_in.int_cons_0x000c_0x05=1730 +# in13 +hwmon_in.mode_0x000d_0x00=config +hwmon_in.int_cons_0x000d_0x00=0 +hwmon_in.src_0x000d_0x00=file +hwmon_in.frmt_0x000d_0x00=buf +hwmon_in.fpath_0x000d_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x000d_0x00=0 +hwmon_in.len_0x000d_0x00=8 +hwmon_in.bit_offset_0x000d_0x00= +hwmon_in.str_cons_0x000d_0x00=in13_input +hwmon_in.mode_0x000d_0x01=str_constant +hwmon_in.str_cons_0x000d_0x01=MAC_BOARD_QSFP56_VDD3.3V_A +hwmon_in.mode_0x000d_0x02=str_constant +hwmon_in.str_cons_0x000d_0x02=ucd90160 +hwmon_in.mode_0x000d_0x03=constant +hwmon_in.int_cons_0x000d_0x03=3595 +hwmon_in.mode_0x000d_0x05=constant +hwmon_in.int_cons_0x000d_0x05=3250 +# in14 +hwmon_in.mode_0x000e_0x00=config +hwmon_in.int_cons_0x000e_0x00=0 +hwmon_in.src_0x000e_0x00=file +hwmon_in.frmt_0x000e_0x00=buf +hwmon_in.fpath_0x000e_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x000e_0x00=0 +hwmon_in.len_0x000e_0x00=8 +hwmon_in.bit_offset_0x000e_0x00= +hwmon_in.str_cons_0x000e_0x00=in14_input +hwmon_in.mode_0x000e_0x01=str_constant +hwmon_in.str_cons_0x000e_0x01=MAC_BOARD_QSFP56_VDD3.3V_B +hwmon_in.mode_0x000e_0x02=str_constant +hwmon_in.str_cons_0x000e_0x02=ucd90160 +hwmon_in.mode_0x000e_0x03=constant +hwmon_in.int_cons_0x000e_0x03=3601 +hwmon_in.mode_0x000e_0x05=constant +hwmon_in.int_cons_0x000e_0x05=3260 +# in15 +hwmon_in.mode_0x000f_0x00=config +hwmon_in.int_cons_0x000f_0x00=0 +hwmon_in.src_0x000f_0x00=file +hwmon_in.frmt_0x000f_0x00=buf +hwmon_in.fpath_0x000f_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x000f_0x00=0 +hwmon_in.len_0x000f_0x00=8 +hwmon_in.bit_offset_0x000f_0x00= +hwmon_in.str_cons_0x000f_0x00=in15_input +hwmon_in.mode_0x000f_0x01=str_constant +hwmon_in.str_cons_0x000f_0x01=MAC_BOARD_QSFPDD_VDD3.3V_A +hwmon_in.mode_0x000f_0x02=str_constant +hwmon_in.str_cons_0x000f_0x02=ucd90160 +hwmon_in.mode_0x000f_0x03=constant +hwmon_in.int_cons_0x000f_0x03=3565 +hwmon_in.mode_0x000f_0x05=constant +hwmon_in.int_cons_0x000f_0x05=3230 +# in16 +hwmon_in.mode_0x0010_0x00=config +hwmon_in.int_cons_0x0010_0x00=0 +hwmon_in.src_0x0010_0x00=file +hwmon_in.frmt_0x0010_0x00=buf +hwmon_in.fpath_0x0010_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0010_0x00=0 +hwmon_in.len_0x0010_0x00=8 +hwmon_in.bit_offset_0x0010_0x00= +hwmon_in.str_cons_0x0010_0x00=in16_input +hwmon_in.mode_0x0010_0x01=str_constant +hwmon_in.str_cons_0x0010_0x01=MAC_BOARD_QSFPDD_VDD3.3V_B +hwmon_in.mode_0x0010_0x02=str_constant +hwmon_in.str_cons_0x0010_0x02=ucd90160 +hwmon_in.mode_0x0010_0x03=constant +hwmon_in.int_cons_0x0010_0x03=3564 +hwmon_in.mode_0x0010_0x05=constant +hwmon_in.int_cons_0x0010_0x05=3220 +# in17 +hwmon_in.mode_0x0011_0x00=config +hwmon_in.int_cons_0x0011_0x00=0 +hwmon_in.src_0x0011_0x00=file +hwmon_in.frmt_0x0011_0x00=buf +hwmon_in.fpath_0x0011_0x00=/sys/bus/i2c/devices/24-005b/hwmon/ +hwmon_in.addr_0x0011_0x00=0 +hwmon_in.len_0x0011_0x00=8 +hwmon_in.bit_offset_0x0011_0x00= +hwmon_in.str_cons_0x0011_0x00=in1_input +hwmon_in.mode_0x0011_0x01=str_constant +hwmon_in.str_cons_0x0011_0x01=CPU_CONNECT_VDD5.0V +hwmon_in.mode_0x0011_0x02=str_constant +hwmon_in.str_cons_0x0011_0x02=ucd90160 +hwmon_in.mode_0x0011_0x03=constant +hwmon_in.int_cons_0x0011_0x03=5429 +hwmon_in.mode_0x0011_0x05=constant +hwmon_in.int_cons_0x0011_0x05=4910 +# in18 +hwmon_in.mode_0x0012_0x00=config +hwmon_in.int_cons_0x0012_0x00=0 +hwmon_in.src_0x0012_0x00=file +hwmon_in.frmt_0x0012_0x00=buf +hwmon_in.fpath_0x0012_0x00=/sys/bus/i2c/devices/24-005b/hwmon/ +hwmon_in.addr_0x0012_0x00=0 +hwmon_in.len_0x0012_0x00=8 +hwmon_in.bit_offset_0x0012_0x00= +hwmon_in.str_cons_0x0012_0x00=in4_input +hwmon_in.mode_0x0012_0x01=str_constant +hwmon_in.str_cons_0x0012_0x01=CPU_CONNECT_VDD3.3V +hwmon_in.mode_0x0012_0x02=str_constant +hwmon_in.str_cons_0x0012_0x02=ucd90160 +hwmon_in.mode_0x0012_0x03=constant +hwmon_in.int_cons_0x0012_0x03=3437 +hwmon_in.mode_0x0012_0x05=constant +hwmon_in.int_cons_0x0012_0x05=3110 +# in19 +hwmon_in.mode_0x0013_0x00=config +hwmon_in.int_cons_0x0013_0x00=0 +hwmon_in.src_0x0013_0x00=file +hwmon_in.frmt_0x0013_0x00=buf +hwmon_in.fpath_0x0013_0x00=/sys/bus/i2c/devices/24-005b/hwmon/ +hwmon_in.addr_0x0013_0x00=0 +hwmon_in.len_0x0013_0x00=8 +hwmon_in.bit_offset_0x0013_0x00= +hwmon_in.str_cons_0x0013_0x00=in6_input +hwmon_in.mode_0x0013_0x01=str_constant +hwmon_in.str_cons_0x0013_0x01=CPU_CONNECT_VDD12V +hwmon_in.mode_0x0013_0x02=str_constant +hwmon_in.str_cons_0x0013_0x02=ucd90160 +hwmon_in.mode_0x0013_0x03=constant +hwmon_in.int_cons_0x0013_0x03=12700 +hwmon_in.mode_0x0013_0x05=constant +hwmon_in.int_cons_0x0013_0x05=11300 +# in20 +hwmon_in.mode_0x0014_0x00=config +hwmon_in.int_cons_0x0014_0x00=0 +hwmon_in.src_0x0014_0x00=file +hwmon_in.frmt_0x0014_0x00=buf +hwmon_in.fpath_0x0014_0x00=/sys/bus/i2c/devices/24-005b/hwmon/ +hwmon_in.addr_0x0014_0x00=0 +hwmon_in.len_0x0014_0x00=8 +hwmon_in.bit_offset_0x0014_0x00= +hwmon_in.str_cons_0x0014_0x00=in7_input +hwmon_in.mode_0x0014_0x01=str_constant +hwmon_in.str_cons_0x0014_0x01=CPU_CONNECT_VDD3.3_STBY +hwmon_in.mode_0x0014_0x02=str_constant +hwmon_in.str_cons_0x0014_0x02=ucd90160 +hwmon_in.mode_0x0014_0x03=constant +hwmon_in.int_cons_0x0014_0x03=3489 +hwmon_in.mode_0x0014_0x05=constant +hwmon_in.int_cons_0x0014_0x05=3160 +# in21 +hwmon_in.mode_0x0015_0x00=config +hwmon_in.int_cons_0x0015_0x00=0 +hwmon_in.src_0x0015_0x00=file +hwmon_in.frmt_0x0015_0x00=buf +hwmon_in.fpath_0x0015_0x00=/sys/bus/i2c/devices/24-005b/hwmon/ +hwmon_in.addr_0x0015_0x00=0 +hwmon_in.len_0x0015_0x00=8 +hwmon_in.bit_offset_0x0015_0x00= +hwmon_in.str_cons_0x0015_0x00=in8_input +hwmon_in.mode_0x0015_0x01=str_constant +hwmon_in.str_cons_0x0015_0x01=CPU_CONNECT_SSD_VDD3.3V +hwmon_in.mode_0x0015_0x02=str_constant +hwmon_in.str_cons_0x0015_0x02=ucd90160 +hwmon_in.mode_0x0015_0x03=constant +hwmon_in.int_cons_0x0015_0x03=3475 +hwmon_in.mode_0x0015_0x05=constant +hwmon_in.int_cons_0x0015_0x05=3140 +# in22 +hwmon_in.mode_0x0016_0x00=config +hwmon_in.int_cons_0x0016_0x00=0 +hwmon_in.src_0x0016_0x00=file +hwmon_in.frmt_0x0016_0x00=buf +hwmon_in.fpath_0x0016_0x00=/sys/bus/i2c/devices/24-005b/hwmon/ +hwmon_in.addr_0x0016_0x00=0 +hwmon_in.len_0x0016_0x00=8 +hwmon_in.bit_offset_0x0016_0x00= +hwmon_in.str_cons_0x0016_0x00=in9_input +hwmon_in.mode_0x0016_0x01=str_constant +hwmon_in.str_cons_0x0016_0x01=CPU_CONNECT_PHY_VDD1V0 +hwmon_in.mode_0x0016_0x02=str_constant +hwmon_in.str_cons_0x0016_0x02=ucd90160 +hwmon_in.mode_0x0016_0x03=constant +hwmon_in.int_cons_0x0016_0x03=1050 +hwmon_in.mode_0x0016_0x05=constant +hwmon_in.int_cons_0x0016_0x05=950 +# in23 +hwmon_in.mode_0x0017_0x00=config +hwmon_in.int_cons_0x0017_0x00=0 +hwmon_in.src_0x0017_0x00=file +hwmon_in.frmt_0x0017_0x00=buf +hwmon_in.fpath_0x0017_0x00=/sys/bus/i2c/devices/24-005b/hwmon/ +hwmon_in.addr_0x0017_0x00=0 +hwmon_in.len_0x0017_0x00=8 +hwmon_in.bit_offset_0x0017_0x00= +hwmon_in.str_cons_0x0017_0x00=in11_input +hwmon_in.mode_0x0017_0x01=str_constant +hwmon_in.str_cons_0x0017_0x01=CPU_CONNECT_ODD_PHY_M +hwmon_in.mode_0x0017_0x02=str_constant +hwmon_in.str_cons_0x0017_0x02=ucd90160 +hwmon_in.mode_0x0017_0x03=constant +hwmon_in.int_cons_0x0017_0x03=3444 +hwmon_in.mode_0x0017_0x05=constant +hwmon_in.int_cons_0x0017_0x05=3116 +# in24 +hwmon_in.mode_0x0018_0x00=config +hwmon_in.int_cons_0x0018_0x00=0 +hwmon_in.src_0x0018_0x00=file +hwmon_in.frmt_0x0018_0x00=buf +hwmon_in.fpath_0x0018_0x00=/sys/bus/i2c/devices/25-0060/hwmon/ +hwmon_in.addr_0x0018_0x00=0 +hwmon_in.len_0x0018_0x00=8 +hwmon_in.bit_offset_0x0018_0x00= +hwmon_in.str_cons_0x0018_0x00=in3_input +hwmon_in.mode_0x0018_0x01=str_constant +hwmon_in.str_cons_0x0018_0x01=CPU_VCCIN +hwmon_in.mode_0x0018_0x02=str_constant +hwmon_in.str_cons_0x0018_0x02=tps53622 +hwmon_in.mode_0x0018_0x03=constant +hwmon_in.int_cons_0x0018_0x03=1879 +hwmon_in.mode_0x0018_0x05=constant +hwmon_in.int_cons_0x0018_0x05=1700 +# in25 +hwmon_in.mode_0x0019_0x00=config +hwmon_in.int_cons_0x0019_0x00=0 +hwmon_in.src_0x0019_0x00=file +hwmon_in.frmt_0x0019_0x00=buf +hwmon_in.fpath_0x0019_0x00=/sys/bus/i2c/devices/25-0060/hwmon/ +hwmon_in.addr_0x0019_0x00=0 +hwmon_in.len_0x0019_0x00=8 +hwmon_in.bit_offset_0x0019_0x00= +hwmon_in.str_cons_0x0019_0x00=in4_input +hwmon_in.mode_0x0019_0x01=str_constant +hwmon_in.str_cons_0x0019_0x01=CPU_P1V05 +hwmon_in.mode_0x0019_0x02=str_constant +hwmon_in.str_cons_0x0019_0x02=tps53622 +hwmon_in.mode_0x0019_0x03=constant +hwmon_in.int_cons_0x0019_0x03=1103 +hwmon_in.mode_0x0019_0x05=constant +hwmon_in.int_cons_0x0019_0x05=1000 +# in26 +hwmon_in.mode_0x001a_0x00=config +hwmon_in.int_cons_0x001a_0x00=0 +hwmon_in.src_0x001a_0x00=file +hwmon_in.frmt_0x001a_0x00=buf +hwmon_in.fpath_0x001a_0x00=/sys/bus/i2c/devices/25-006c/hwmon/ +hwmon_in.addr_0x001a_0x00=0 +hwmon_in.len_0x001a_0x00=8 +hwmon_in.bit_offset_0x001a_0x00= +hwmon_in.str_cons_0x001a_0x00=in3_input +hwmon_in.mode_0x001a_0x01=str_constant +hwmon_in.str_cons_0x001a_0x01=CPU_P1V2_VDDQ +hwmon_in.mode_0x001a_0x02=str_constant +hwmon_in.str_cons_0x001a_0x02=tps53622 +hwmon_in.mode_0x001a_0x03=constant +hwmon_in.int_cons_0x001a_0x03=1258 +hwmon_in.mode_0x001a_0x05=constant +hwmon_in.int_cons_0x001a_0x05=1140 +# in27 +hwmon_in.mode_0x001b_0x00=config +hwmon_in.int_cons_0x001b_0x00=3 +hwmon_in.src_0x001b_0x00=file +hwmon_in.frmt_0x001b_0x00=buf +hwmon_in.fpath_0x001b_0x00=/sys/bus/i2c/devices/25-006c/hwmon/ +hwmon_in.addr_0x001b_0x00=0 +hwmon_in.len_0x001b_0x00=8 +hwmon_in.bit_offset_0x001b_0x00=0 +hwmon_in.str_cons_0x001b_0x00=in4_input +hwmon_in.int_extra1_0x001b_0x00=1124 +hwmon_in.mode_0x001b_0x01=str_constant +hwmon_in.str_cons_0x001b_0x01=CPU_P2V5_VPP +hwmon_in.mode_0x001b_0x02=str_constant +hwmon_in.str_cons_0x001b_0x02=tps53622 +hwmon_in.mode_0x001b_0x03=constant +hwmon_in.int_cons_0x001b_0x03=2632 +hwmon_in.mode_0x001b_0x05=constant +hwmon_in.int_cons_0x001b_0x05=2380 +# in28 +hwmon_in.mode_0x001c_0x00=config +hwmon_in.int_cons_0x001c_0x00=0 +hwmon_in.src_0x001c_0x00=file +hwmon_in.frmt_0x001c_0x00=buf +hwmon_in.fpath_0x001c_0x00=/sys/bus/i2c/devices/25-0043/hwmon/ +hwmon_in.addr_0x001c_0x00=0 +hwmon_in.len_0x001c_0x00=8 +hwmon_in.bit_offset_0x001c_0x00= +hwmon_in.str_cons_0x001c_0x00=in1_input +hwmon_in.mode_0x001c_0x01=str_constant +hwmon_in.str_cons_0x001c_0x01=CPU_P3V3_STBY +hwmon_in.mode_0x001c_0x02=str_constant +hwmon_in.str_cons_0x001c_0x02=ina3221 +hwmon_in.mode_0x001c_0x03=constant +hwmon_in.int_cons_0x001c_0x03=3476 +hwmon_in.mode_0x001c_0x05=constant +hwmon_in.int_cons_0x001c_0x05=3140 +# in29 +hwmon_in.mode_0x001d_0x00=config +hwmon_in.int_cons_0x001d_0x00=0 +hwmon_in.src_0x001d_0x00=file +hwmon_in.frmt_0x001d_0x00=buf +hwmon_in.fpath_0x001d_0x00=/sys/bus/i2c/devices/25-0043/hwmon/ +hwmon_in.addr_0x001d_0x00=0 +hwmon_in.len_0x001d_0x00=8 +hwmon_in.bit_offset_0x001d_0x00= +hwmon_in.str_cons_0x001d_0x00=in2_input +hwmon_in.mode_0x001d_0x01=str_constant +hwmon_in.str_cons_0x001d_0x01=CPU_P5V_AUX_IN +hwmon_in.mode_0x001d_0x02=str_constant +hwmon_in.str_cons_0x001d_0x02=ina3221 +hwmon_in.mode_0x001d_0x03=constant +hwmon_in.int_cons_0x001d_0x03=5229 +hwmon_in.mode_0x001d_0x05=constant +hwmon_in.int_cons_0x001d_0x05=4730 +# in30 +hwmon_in.mode_0x001e_0x00=config +hwmon_in.int_cons_0x001e_0x00=0 +hwmon_in.src_0x001e_0x00=file +hwmon_in.frmt_0x001e_0x00=buf +hwmon_in.fpath_0x001e_0x00=/sys/bus/i2c/devices/25-0043/hwmon/ +hwmon_in.addr_0x001e_0x00=0 +hwmon_in.len_0x001e_0x00=8 +hwmon_in.bit_offset_0x001e_0x00= +hwmon_in.str_cons_0x001e_0x00=in3_input +hwmon_in.mode_0x001e_0x01=str_constant +hwmon_in.str_cons_0x001e_0x01=CPU_P1V7_VCCSCFUSESUS_IN +hwmon_in.mode_0x001e_0x02=str_constant +hwmon_in.str_cons_0x001e_0x02=ina3221 +hwmon_in.mode_0x001e_0x03=constant +hwmon_in.int_cons_0x001e_0x03=1789 +hwmon_in.mode_0x001e_0x05=constant +hwmon_in.int_cons_0x001e_0x05=1620 + +# curr1 +hwmon_curr.mode_0x0001_0x00=config +hwmon_curr.int_cons_0x0001_0x00=0 +hwmon_curr.src_0x0001_0x00=file +hwmon_curr.frmt_0x0001_0x00=buf +hwmon_curr.fpath_0x0001_0x00=/sys/bus/i2c/devices/25-0060/hwmon/ +hwmon_curr.addr_0x0001_0x00=0 +hwmon_curr.len_0x0001_0x00=8 +hwmon_curr.bit_offset_0x0001_0x00= +hwmon_curr.str_cons_0x0001_0x00=curr1_input + +hwmon_curr.mode_0x0001_0x01=str_constant +hwmon_curr.str_cons_0x0001_0x01=CPU_VCCIN_C + +hwmon_curr.mode_0x0001_0x02=str_constant +hwmon_curr.str_cons_0x0001_0x02=tps53622 + +hwmon_curr.mode_0x0001_0x03=constant +hwmon_curr.int_cons_0x0001_0x03=47300 + +hwmon_curr.mode_0x0001_0x05=constant +hwmon_curr.int_cons_0x0001_0x05=0 + +# curr2 +hwmon_curr.mode_0x0002_0x00=config +hwmon_curr.int_cons_0x0002_0x00=0 +hwmon_curr.src_0x0002_0x00=file +hwmon_curr.frmt_0x0002_0x00=buf +hwmon_curr.fpath_0x0002_0x00=/sys/bus/i2c/devices/25-0060/hwmon/ +hwmon_curr.addr_0x0002_0x00=0 +hwmon_curr.len_0x0002_0x00=8 +hwmon_curr.bit_offset_0x0002_0x00= +hwmon_curr.str_cons_0x0002_0x00=curr2_input + +hwmon_curr.mode_0x0002_0x01=str_constant +hwmon_curr.str_cons_0x0002_0x01=CPU_P1V05_C + +hwmon_curr.mode_0x0002_0x02=str_constant +hwmon_curr.str_cons_0x0002_0x02=tps53622 + +hwmon_curr.mode_0x0002_0x03=constant +hwmon_curr.int_cons_0x0002_0x03=15400 + +hwmon_curr.mode_0x0002_0x05=constant +hwmon_curr.int_cons_0x0002_0x05=0 + +# curr3 +hwmon_curr.mode_0x0003_0x00=config +hwmon_curr.int_cons_0x0003_0x00=0 +hwmon_curr.src_0x0003_0x00=file +hwmon_curr.frmt_0x0003_0x00=buf +hwmon_curr.fpath_0x0003_0x00=/sys/bus/i2c/devices/25-006c/hwmon/ +hwmon_curr.addr_0x0003_0x00=0 +hwmon_curr.len_0x0003_0x00=8 +hwmon_curr.bit_offset_0x0003_0x00= +hwmon_curr.str_cons_0x0003_0x00=curr1_input + +hwmon_curr.mode_0x0003_0x01=str_constant +hwmon_curr.str_cons_0x0003_0x01=CPU_P1V2_VDDQ_C + +hwmon_curr.mode_0x0003_0x02=str_constant +hwmon_curr.str_cons_0x0003_0x02=tps53622 + +hwmon_curr.mode_0x0003_0x03=constant +hwmon_curr.int_cons_0x0003_0x03=9900 + +hwmon_curr.mode_0x0003_0x05=constant +hwmon_curr.int_cons_0x0003_0x05=0 + +# curr4 +hwmon_curr.mode_0x0004_0x00=config +hwmon_curr.int_cons_0x0004_0x00=0 +hwmon_curr.src_0x0004_0x00=file +hwmon_curr.frmt_0x0004_0x00=buf +hwmon_curr.fpath_0x0004_0x00=/sys/bus/i2c/devices/25-006c/hwmon/ +hwmon_curr.addr_0x0004_0x00=0 +hwmon_curr.len_0x0004_0x00=8 +hwmon_curr.bit_offset_0x0004_0x00= +hwmon_curr.str_cons_0x0004_0x00=curr2_input + +hwmon_curr.mode_0x0004_0x01=str_constant +hwmon_curr.str_cons_0x0004_0x01=CPU_P2V5_VPP_C + +hwmon_curr.mode_0x0004_0x02=str_constant +hwmon_curr.str_cons_0x0004_0x02=tps53622 + +hwmon_curr.mode_0x0004_0x03=constant +hwmon_curr.int_cons_0x0004_0x03=2200 + +hwmon_curr.mode_0x0004_0x05=constant +hwmon_curr.int_cons_0x0004_0x05=0 + +# curr5 +hwmon_curr.mode_0x0005_0x00=config +hwmon_curr.int_cons_0x0005_0x00=0 +hwmon_curr.src_0x0005_0x00=file +hwmon_curr.frmt_0x0005_0x00=buf +hwmon_curr.fpath_0x0005_0x00=/sys/bus/i2c/devices/25-0043/hwmon/ +hwmon_curr.addr_0x0005_0x00=0 +hwmon_curr.len_0x0005_0x00=8 +hwmon_curr.bit_offset_0x0005_0x00= +hwmon_curr.str_cons_0x0005_0x00=curr1_input + +hwmon_curr.mode_0x0005_0x01=str_constant +hwmon_curr.str_cons_0x0005_0x01=CPU_P3V3_STBY_C + +hwmon_curr.mode_0x0005_0x02=str_constant +hwmon_curr.str_cons_0x0005_0x02=ina3221 + +hwmon_curr.mode_0x0005_0x03=constant +hwmon_curr.int_cons_0x0005_0x03=4686 + +hwmon_curr.mode_0x0005_0x05=constant +hwmon_curr.int_cons_0x0005_0x05=0 + +# curr6 +hwmon_curr.mode_0x0006_0x00=config +hwmon_curr.int_cons_0x0006_0x00=0 +hwmon_curr.src_0x0006_0x00=file +hwmon_curr.frmt_0x0006_0x00=buf +hwmon_curr.fpath_0x0006_0x00=/sys/bus/i2c/devices/25-0043/hwmon/ +hwmon_curr.addr_0x0006_0x00=0 +hwmon_curr.len_0x0006_0x00=8 +hwmon_curr.bit_offset_0x0006_0x00= +hwmon_curr.str_cons_0x0006_0x00=curr2_input + +hwmon_curr.mode_0x0006_0x01=str_constant +hwmon_curr.str_cons_0x0006_0x01=CPU_P5V_AUX_IN_C + +hwmon_curr.mode_0x0006_0x02=str_constant +hwmon_curr.str_cons_0x0006_0x02=ina3221 + +hwmon_curr.mode_0x0006_0x03=constant +hwmon_curr.int_cons_0x0006_0x03=2200 + +hwmon_curr.mode_0x0006_0x05=constant +hwmon_curr.int_cons_0x0006_0x05=0 + +# curr7 +hwmon_curr.mode_0x0007_0x00=config +hwmon_curr.int_cons_0x0007_0x00=0 +hwmon_curr.src_0x0007_0x00=file +hwmon_curr.frmt_0x0007_0x00=buf +hwmon_curr.fpath_0x0007_0x00=/sys/bus/i2c/devices/25-0043/hwmon/ +hwmon_curr.addr_0x0007_0x00=0 +hwmon_curr.len_0x0007_0x00=8 +hwmon_curr.bit_offset_0x0007_0x00= +hwmon_curr.str_cons_0x0007_0x00=curr3_input + +hwmon_curr.mode_0x0007_0x01=str_constant +hwmon_curr.str_cons_0x0007_0x01=CPU_P1V7_VCCSCFUSESUS_IN_C + +hwmon_curr.mode_0x0007_0x02=str_constant +hwmon_curr.str_cons_0x0007_0x02=ina3221 + +hwmon_curr.mode_0x0007_0x03=constant +hwmon_curr.int_cons_0x0007_0x03=2200 + +hwmon_curr.mode_0x0007_0x05=constant +hwmon_curr.int_cons_0x0007_0x05=0 \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-CPLD.cfg b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-CPLD.cfg new file mode 100755 index 000000000000..6c669c649626 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-CPLD.cfg @@ -0,0 +1,219 @@ +other_i2c_dev.bus_0_0=1 +other_i2c_dev.addr_0_0=0x56 + +eeprom_path_0_0=/sys/bus/i2c/devices/1-0056/eeprom + +eeprom_size_0_0=256 + +watchdog_id_0=0 + +watchdog_name_0_0=identity +watchdog_name_0_1=state +watchdog_name_0_2=timeleft +watchdog_name_0_3=timeout + +cpld_i2c_dev.bus_0_2=60 +cpld_i2c_dev.addr_0_2=0x3d +cpld_i2c_dev.bus_0_3=87 +cpld_i2c_dev.addr_0_3=0x0d +cpld_i2c_dev.bus_0_4=95 +cpld_i2c_dev.addr_0_4=0x0d +cpld_i2c_dev.bus_0_5=77 +cpld_i2c_dev.addr_0_5=0x1d +cpld_i2c_dev.bus_0_6=77 +cpld_i2c_dev.addr_0_6=0x2d +cpld_i2c_dev.bus_0_7=111 +cpld_i2c_dev.addr_0_7=0x3d + +cpld_lpc_dev_0_0=0x700 +cpld_lpc_dev_0_1=0x900 + +mode_cpld_0_0=lpc +mode_cpld_0_1=lpc +mode_cpld_0_2=i2c +mode_cpld_0_3=i2c +mode_cpld_0_4=i2c +mode_cpld_0_5=i2c +mode_cpld_0_6=i2c +mode_cpld_0_7=i2c + +dev_num_0_8=8 + +cpld_name_0_0=CPU_CPLD +cpld_name_0_1=BASE_CPLD +cpld_name_0_2=UPORT_CPLD +cpld_name_0_3=UFCB_CPLD +cpld_name_0_4=DFCB_CPLD +cpld_name_0_5=MAC_CPLDA +cpld_name_0_6=MAC_CPLDB +cpld_name_0_7=DPORT_CPLD + +cpld_type_0_0=LATTICE/LCMXO3LF-2100C-5BG256C +cpld_type_0_1=LATTICE/LCMXO3LF-4300C-6BG324I +cpld_type_0_2=LATTICE/LCMXO3LF-4300C-6BG324I +cpld_type_0_3=LATTICE/LCMXO3LF-2100C-5BG256C +cpld_type_0_4=LATTICE/LCMXO3LF-2100C-5BG256C +cpld_type_0_5=LATTICE/LCMXO3LF-4300C-6BG324I +cpld_type_0_6=LATTICE/LCMXO3LF-4300C-6BG324I +cpld_type_0_7=LATTICE/LCMXO3LF-4300C-6BG324I + +cpld_version.mode_0_0=config +cpld_version.int_cons_0_0= +cpld_version.src_0_0=cpld +cpld_version.frmt_0_0=num_bytes +cpld_version.pola_0_0= +cpld_version.fpath_0_0= +cpld_version.addr_0_0=0x00000000 +cpld_version.len_0_0=4 +cpld_version.bit_offset_0_0= + +cpld_version.mode_0_1=config +cpld_version.int_cons_0_1= +cpld_version.src_0_1=cpld +cpld_version.frmt_0_1=num_bytes +cpld_version.pola_0_1= +cpld_version.fpath_0_1= +cpld_version.addr_0_1=0x00010000 +cpld_version.len_0_1=4 +cpld_version.bit_offset_0_1= + +cpld_version.mode_0_2=config +cpld_version.int_cons_0_2= +cpld_version.src_0_2=cpld +cpld_version.frmt_0_2=num_bytes +cpld_version.pola_0_2= +cpld_version.fpath_0_2= +cpld_version.addr_0_2=0x00020000 +cpld_version.len_0_2=4 +cpld_version.bit_offset_0_2= + +cpld_version.mode_0_3=config +cpld_version.int_cons_0_3= +cpld_version.src_0_3=cpld +cpld_version.frmt_0_3=num_bytes +cpld_version.pola_0_3= +cpld_version.fpath_0_3= +cpld_version.addr_0_3=0x00030000 +cpld_version.len_0_3=4 +cpld_version.bit_offset_0_3= + +cpld_version.mode_0_4=config +cpld_version.int_cons_0_4= +cpld_version.src_0_4=cpld +cpld_version.frmt_0_4=num_bytes +cpld_version.pola_0_4= +cpld_version.fpath_0_4= +cpld_version.addr_0_4=0x00040000 +cpld_version.len_0_4=4 +cpld_version.bit_offset_0_4= + +cpld_version.mode_0_5=config +cpld_version.int_cons_0_5= +cpld_version.src_0_5=cpld +cpld_version.frmt_0_5=num_bytes +cpld_version.pola_0_5= +cpld_version.fpath_0_5= +cpld_version.addr_0_5=0x00050000 +cpld_version.len_0_5=4 +cpld_version.bit_offset_0_5= + +cpld_version.mode_0_6=config +cpld_version.int_cons_0_6= +cpld_version.src_0_6=cpld +cpld_version.frmt_0_6=num_bytes +cpld_version.pola_0_6= +cpld_version.fpath_0_6= +cpld_version.addr_0_6=0x00060000 +cpld_version.len_0_6=4 +cpld_version.bit_offset_0_6= + +cpld_version.mode_0_7=config +cpld_version.int_cons_0_7= +cpld_version.src_0_7=cpld +cpld_version.frmt_0_7=num_bytes +cpld_version.pola_0_7= +cpld_version.fpath_0_7= +cpld_version.addr_0_7=0x00070000 +cpld_version.len_0_7=4 +cpld_version.bit_offset_0_7= + +cpld_test_reg.mode_0_0=config +cpld_test_reg.int_cons_0_0= +cpld_test_reg.src_0_0=cpld +cpld_test_reg.frmt_0_0=byte +cpld_test_reg.pola_0_0= +cpld_test_reg.fpath_0_0= +cpld_test_reg.addr_0_0=0x00000005 +cpld_test_reg.len_0_0=1 +cpld_test_reg.bit_offset_0_0= + +cpld_test_reg.mode_0_1=config +cpld_test_reg.int_cons_0_1= +cpld_test_reg.src_0_1=cpld +cpld_test_reg.frmt_0_1=byte +cpld_test_reg.pola_0_1= +cpld_test_reg.fpath_0_1= +cpld_test_reg.addr_0_1=0x00010055 +cpld_test_reg.len_0_1=1 +cpld_test_reg.bit_offset_0_1= + +cpld_test_reg.mode_0_2=config +cpld_test_reg.int_cons_0_2= +cpld_test_reg.src_0_2=cpld +cpld_test_reg.frmt_0_2=byte +cpld_test_reg.pola_0_2= +cpld_test_reg.fpath_0_2= +cpld_test_reg.addr_0_2=0x000200aa +cpld_test_reg.len_0_2=1 +cpld_test_reg.bit_offset_0_2= + +cpld_test_reg.mode_0_3=config +cpld_test_reg.int_cons_0_3= +cpld_test_reg.src_0_3=cpld +cpld_test_reg.frmt_0_3=byte +cpld_test_reg.pola_0_3= +cpld_test_reg.fpath_0_3= +cpld_test_reg.addr_0_3=0x000300aa +cpld_test_reg.len_0_3=1 +cpld_test_reg.bit_offset_0_3= + +cpld_test_reg.mode_0_4=config +cpld_test_reg.int_cons_0_4= +cpld_test_reg.src_0_4=cpld +cpld_test_reg.frmt_0_4=byte +cpld_test_reg.pola_0_4= +cpld_test_reg.fpath_0_4= +cpld_test_reg.addr_0_4=0x000400aa +cpld_test_reg.len_0_4=1 +cpld_test_reg.bit_offset_0_4= + +cpld_test_reg.mode_0_5=config +cpld_test_reg.int_cons_0_5= +cpld_test_reg.src_0_5=cpld +cpld_test_reg.frmt_0_5=byte +cpld_test_reg.pola_0_5= +cpld_test_reg.fpath_0_5= +cpld_test_reg.addr_0_5=0x00050055 +cpld_test_reg.len_0_5=1 +cpld_test_reg.bit_offset_0_5= + +cpld_test_reg.mode_0_6=config +cpld_test_reg.int_cons_0_6= +cpld_test_reg.src_0_6=cpld +cpld_test_reg.frmt_0_6=byte +cpld_test_reg.pola_0_6= +cpld_test_reg.fpath_0_6= +cpld_test_reg.addr_0_6=0x000600aa +cpld_test_reg.len_0_6=1 +cpld_test_reg.bit_offset_0_6= + +cpld_test_reg.mode_0_7=config +cpld_test_reg.int_cons_0_7= +cpld_test_reg.src_0_7=cpld +cpld_test_reg.frmt_0_7=byte +cpld_test_reg.pola_0_7= +cpld_test_reg.fpath_0_7= +cpld_test_reg.addr_0_7=0x000700aa +cpld_test_reg.len_0_7=1 +cpld_test_reg.bit_offset_0_7= + diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-FAN.cfg b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-FAN.cfg new file mode 100755 index 000000000000..3bd43a58c525 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-FAN.cfg @@ -0,0 +1,501 @@ +other_i2c_dev.bus_1_1=90 +other_i2c_dev.addr_1_1=0x50 +other_i2c_dev.bus_1_2=98 +other_i2c_dev.addr_1_2=0x50 +other_i2c_dev.bus_1_3=91 +other_i2c_dev.addr_1_3=0x50 +other_i2c_dev.bus_1_4=99 +other_i2c_dev.addr_1_4=0x50 +other_i2c_dev.bus_1_5=92 +other_i2c_dev.addr_1_5=0x50 +other_i2c_dev.bus_1_6=100 +other_i2c_dev.addr_1_6=0x50 +other_i2c_dev.bus_1_7=93 +other_i2c_dev.addr_1_7=0x50 +other_i2c_dev.bus_1_8=101 +other_i2c_dev.addr_1_8=0x50 + +# fan number +dev_num_1_0=8 + +# fan motor number +dev_num_1_5=2 + +fan_e2_mode=fru + +fan_sysfs_name=eeprom + +fan_direction_0_1=FAN12K8080-F + +dev_present_status.mode_1_1=config +dev_present_status.src_1_1=cpld +dev_present_status.frmt_1_1=bit +dev_present_status.pola_1_1=negative +dev_present_status.addr_1_1=0x00030030 +dev_present_status.len_1_1=1 +dev_present_status.bit_offset_1_1=0 + +dev_present_status.mode_1_2=config +dev_present_status.src_1_2=cpld +dev_present_status.frmt_1_2=bit +dev_present_status.pola_1_2=negative +dev_present_status.addr_1_2=0x00040030 +dev_present_status.len_1_2=1 +dev_present_status.bit_offset_1_2=0 + +dev_present_status.mode_1_3=config +dev_present_status.src_1_3=cpld +dev_present_status.frmt_1_3=bit +dev_present_status.pola_1_3=negative +dev_present_status.addr_1_3=0x00030030 +dev_present_status.len_1_3=1 +dev_present_status.bit_offset_1_3=1 + +dev_present_status.mode_1_4=config +dev_present_status.src_1_4=cpld +dev_present_status.frmt_1_4=bit +dev_present_status.pola_1_4=negative +dev_present_status.addr_1_4=0x00040030 +dev_present_status.len_1_4=1 +dev_present_status.bit_offset_1_4=1 + +dev_present_status.mode_1_5=config +dev_present_status.src_1_5=cpld +dev_present_status.frmt_1_5=bit +dev_present_status.pola_1_5=negative +dev_present_status.addr_1_5=0x00030030 +dev_present_status.len_1_5=1 +dev_present_status.bit_offset_1_5=2 + +dev_present_status.mode_1_6=config +dev_present_status.src_1_6=cpld +dev_present_status.frmt_1_6=bit +dev_present_status.pola_1_6=negative +dev_present_status.addr_1_6=0x00040030 +dev_present_status.len_1_6=1 +dev_present_status.bit_offset_1_6=2 + +dev_present_status.mode_1_7=config +dev_present_status.src_1_7=cpld +dev_present_status.frmt_1_7=bit +dev_present_status.pola_1_7=negative +dev_present_status.addr_1_7=0x00030030 +dev_present_status.len_1_7=1 +dev_present_status.bit_offset_1_7=3 + +dev_present_status.mode_1_8=config +dev_present_status.src_1_8=cpld +dev_present_status.frmt_1_8=bit +dev_present_status.pola_1_8=negative +dev_present_status.addr_1_8=0x00040030 +dev_present_status.len_1_8=1 +dev_present_status.bit_offset_1_8=3 + +fan_roll_status.mode_1_1=config +fan_roll_status.int_cons_1_1= +fan_roll_status.src_1_1=cpld +fan_roll_status.frmt_1_1=bit +fan_roll_status.pola_1_1=positive +fan_roll_status.fpath_1_1= +fan_roll_status.addr_1_1=0x00030031 +fan_roll_status.len_1_1=1 +fan_roll_status.bit_offset_1_1=0 + +fan_roll_status.mode_1_2=config +fan_roll_status.int_cons_1_2= +fan_roll_status.src_1_2=cpld +fan_roll_status.frmt_1_2=bit +fan_roll_status.pola_1_2=positive +fan_roll_status.fpath_1_2= +fan_roll_status.addr_1_2=0x00030034 +fan_roll_status.len_1_2=1 +fan_roll_status.bit_offset_1_2=0 + +fan_roll_status.mode_2_1=config +fan_roll_status.int_cons_2_1= +fan_roll_status.src_2_1=cpld +fan_roll_status.frmt_2_1=bit +fan_roll_status.pola_2_1=positive +fan_roll_status.fpath_2_1= +fan_roll_status.addr_2_1=0x00040031 +fan_roll_status.len_2_1=1 +fan_roll_status.bit_offset_2_1=0 + +fan_roll_status.mode_2_2=config +fan_roll_status.int_cons_2_2= +fan_roll_status.src_2_2=cpld +fan_roll_status.frmt_2_2=bit +fan_roll_status.pola_2_2=positive +fan_roll_status.fpath_2_2= +fan_roll_status.addr_2_2=0x00040034 +fan_roll_status.len_2_2=1 +fan_roll_status.bit_offset_2_2=0 + +fan_roll_status.mode_3_1=config +fan_roll_status.int_cons_3_1= +fan_roll_status.src_3_1=cpld +fan_roll_status.frmt_3_1=bit +fan_roll_status.pola_3_1=positive +fan_roll_status.fpath_3_1= +fan_roll_status.addr_3_1=0x00030031 +fan_roll_status.len_3_1=1 +fan_roll_status.bit_offset_3_1=1 + +fan_roll_status.mode_3_2=config +fan_roll_status.int_cons_3_2= +fan_roll_status.src_3_2=cpld +fan_roll_status.frmt_3_2=bit +fan_roll_status.pola_3_2=positive +fan_roll_status.fpath_3_2= +fan_roll_status.addr_3_2=0x00030034 +fan_roll_status.len_3_2=1 +fan_roll_status.bit_offset_3_2=1 + +fan_roll_status.mode_4_1=config +fan_roll_status.int_cons_4_1= +fan_roll_status.src_4_1=cpld +fan_roll_status.frmt_4_1=bit +fan_roll_status.pola_4_1=positive +fan_roll_status.fpath_4_1= +fan_roll_status.addr_4_1=0x00040031 +fan_roll_status.len_4_1=1 +fan_roll_status.bit_offset_4_1=1 + +fan_roll_status.mode_4_2=config +fan_roll_status.int_cons_4_2= +fan_roll_status.src_4_2=cpld +fan_roll_status.frmt_4_2=bit +fan_roll_status.pola_4_2=positive +fan_roll_status.fpath_4_2= +fan_roll_status.addr_4_2=0x00040034 +fan_roll_status.len_4_2=1 +fan_roll_status.bit_offset_4_2=1 + +fan_roll_status.mode_5_1=config +fan_roll_status.int_cons_5_1= +fan_roll_status.src_5_1=cpld +fan_roll_status.frmt_5_1=bit +fan_roll_status.pola_5_1=positive +fan_roll_status.fpath_5_1= +fan_roll_status.addr_5_1=0x00030031 +fan_roll_status.len_5_1=1 +fan_roll_status.bit_offset_5_1=2 + +fan_roll_status.mode_5_2=config +fan_roll_status.int_cons_5_2= +fan_roll_status.src_5_2=cpld +fan_roll_status.frmt_5_2=bit +fan_roll_status.pola_5_2=positive +fan_roll_status.fpath_5_2= +fan_roll_status.addr_5_2=0x00030034 +fan_roll_status.len_5_2=1 +fan_roll_status.bit_offset_5_2=2 + +fan_roll_status.mode_6_1=config +fan_roll_status.int_cons_6_1= +fan_roll_status.src_6_1=cpld +fan_roll_status.frmt_6_1=bit +fan_roll_status.pola_6_1=positive +fan_roll_status.fpath_6_1= +fan_roll_status.addr_6_1=0x00040031 +fan_roll_status.len_6_1=1 +fan_roll_status.bit_offset_6_1=2 + +fan_roll_status.mode_6_2=config +fan_roll_status.int_cons_6_2= +fan_roll_status.src_6_2=cpld +fan_roll_status.frmt_6_2=bit +fan_roll_status.pola_6_2=positive +fan_roll_status.fpath_6_2= +fan_roll_status.addr_6_2=0x00040034 +fan_roll_status.len_6_2=1 +fan_roll_status.bit_offset_6_2=2 + +fan_roll_status.mode_7_1=config +fan_roll_status.int_cons_7_1= +fan_roll_status.src_7_1=cpld +fan_roll_status.frmt_7_1=bit +fan_roll_status.pola_7_1=positive +fan_roll_status.fpath_7_1= +fan_roll_status.addr_7_1=0x00030031 +fan_roll_status.len_7_1=1 +fan_roll_status.bit_offset_7_1=3 + +fan_roll_status.mode_7_2=config +fan_roll_status.int_cons_7_2= +fan_roll_status.src_7_2=cpld +fan_roll_status.frmt_7_2=bit +fan_roll_status.pola_7_2=positive +fan_roll_status.fpath_7_2= +fan_roll_status.addr_7_2=0x00030034 +fan_roll_status.len_7_2=1 +fan_roll_status.bit_offset_7_2=3 + +fan_roll_status.mode_8_1=config +fan_roll_status.int_cons_8_1= +fan_roll_status.src_8_1=cpld +fan_roll_status.frmt_8_1=bit +fan_roll_status.pola_8_1=positive +fan_roll_status.fpath_8_1= +fan_roll_status.addr_8_1=0x00040031 +fan_roll_status.len_8_1=1 +fan_roll_status.bit_offset_8_1=3 + +fan_roll_status.mode_8_2=config +fan_roll_status.int_cons_8_2= +fan_roll_status.src_8_2=cpld +fan_roll_status.frmt_8_2=bit +fan_roll_status.pola_8_2=positive +fan_roll_status.fpath_8_2= +fan_roll_status.addr_8_2=0x00040034 +fan_roll_status.len_8_2=1 +fan_roll_status.bit_offset_8_2=3 + +fan_speed.mode_1_1=config +fan_speed.int_cons_1_1= +fan_speed.src_1_1=cpld +fan_speed.frmt_1_1=num_bytes +fan_speed.pola_1_1=negative +fan_speed.fpath_1_1= +fan_speed.addr_1_1=0x0003001B +fan_speed.len_1_1=2 +fan_speed.bit_offset_1_1= + +fan_speed.mode_1_2=config +fan_speed.int_cons_1_2= +fan_speed.src_1_2=cpld +fan_speed.frmt_1_2=num_bytes +fan_speed.pola_1_2=negative +fan_speed.fpath_1_2= +fan_speed.addr_1_2=0x00030025 +fan_speed.len_1_2=2 +fan_speed.bit_offset_1_2= + +fan_speed.mode_2_1=config +fan_speed.int_cons_2_1= +fan_speed.src_2_1=cpld +fan_speed.frmt_2_1=num_bytes +fan_speed.pola_2_1=negative +fan_speed.fpath_2_1= +fan_speed.addr_2_1=0x0004001B +fan_speed.len_2_1=2 +fan_speed.bit_offset_2_1= + +fan_speed.mode_2_2=config +fan_speed.int_cons_2_2= +fan_speed.src_2_2=cpld +fan_speed.frmt_2_2=num_bytes +fan_speed.pola_2_2=negative +fan_speed.fpath_2_2= +fan_speed.addr_2_2=0x00040025 +fan_speed.len_2_2=2 +fan_speed.bit_offset_2_2= + +fan_speed.mode_3_1=config +fan_speed.int_cons_3_1= +fan_speed.src_3_1=cpld +fan_speed.frmt_3_1=num_bytes +fan_speed.pola_3_1=negative +fan_speed.fpath_3_1= +fan_speed.addr_3_1=0x0003001D +fan_speed.len_3_1=2 +fan_speed.bit_offset_3_1= + +fan_speed.mode_3_2=config +fan_speed.int_cons_3_2= +fan_speed.src_3_2=cpld +fan_speed.frmt_3_2=num_bytes +fan_speed.pola_3_2=negative +fan_speed.fpath_3_2= +fan_speed.addr_3_2=0x00030027 +fan_speed.len_3_2=2 +fan_speed.bit_offset_3_2= + +fan_speed.mode_4_1=config +fan_speed.int_cons_4_1= +fan_speed.src_4_1=cpld +fan_speed.frmt_4_1=num_bytes +fan_speed.pola_4_1=negative +fan_speed.fpath_4_1= +fan_speed.addr_4_1=0x0004001D +fan_speed.len_4_1=2 +fan_speed.bit_offset_4_1= + +fan_speed.mode_4_2=config +fan_speed.int_cons_4_2= +fan_speed.src_4_2=cpld +fan_speed.frmt_4_2=num_bytes +fan_speed.pola_4_2=negative +fan_speed.fpath_4_2= +fan_speed.addr_4_2=0x00040027 +fan_speed.len_4_2=2 +fan_speed.bit_offset_4_2= + +fan_speed.mode_5_1=config +fan_speed.int_cons_5_1= +fan_speed.src_5_1=cpld +fan_speed.frmt_5_1=num_bytes +fan_speed.pola_5_1=negative +fan_speed.fpath_5_1= +fan_speed.addr_5_1=0x0003001F +fan_speed.len_5_1=2 +fan_speed.bit_offset_5_1= + +fan_speed.mode_5_2=config +fan_speed.int_cons_5_2= +fan_speed.src_5_2=cpld +fan_speed.frmt_5_2=num_bytes +fan_speed.pola_5_2=negative +fan_speed.fpath_5_2= +fan_speed.addr_5_2=0x00030029 +fan_speed.len_5_2=2 +fan_speed.bit_offset_5_2= + +fan_speed.mode_6_1=config +fan_speed.int_cons_6_1= +fan_speed.src_6_1=cpld +fan_speed.frmt_6_1=num_bytes +fan_speed.pola_6_1=negative +fan_speed.fpath_6_1= +fan_speed.addr_6_1=0x0004001F +fan_speed.len_6_1=2 +fan_speed.bit_offset_6_1= + +fan_speed.mode_6_2=config +fan_speed.int_cons_6_2= +fan_speed.src_6_2=cpld +fan_speed.frmt_6_2=num_bytes +fan_speed.pola_6_2=negative +fan_speed.fpath_6_2= +fan_speed.addr_6_2=0x00040029 +fan_speed.len_6_2=2 +fan_speed.bit_offset_6_2= + +fan_speed.mode_7_1=config +fan_speed.int_cons_7_1= +fan_speed.src_7_1=cpld +fan_speed.frmt_7_1=num_bytes +fan_speed.pola_7_1=negative +fan_speed.fpath_7_1= +fan_speed.addr_7_1=0x00030021 +fan_speed.len_7_1=2 +fan_speed.bit_offset_7_1= + +fan_speed.mode_7_2=config +fan_speed.int_cons_7_2= +fan_speed.src_7_2=cpld +fan_speed.frmt_7_2=num_bytes +fan_speed.pola_7_2=negative +fan_speed.fpath_7_2= +fan_speed.addr_7_2=0x0003002b +fan_speed.len_7_2=2 +fan_speed.bit_offset_7_2= + +fan_speed.mode_8_1=config +fan_speed.int_cons_8_1= +fan_speed.src_8_1=cpld +fan_speed.frmt_8_1=num_bytes +fan_speed.pola_8_1=negative +fan_speed.fpath_8_1= +fan_speed.addr_8_1=0x00040021 +fan_speed.len_8_1=2 +fan_speed.bit_offset_8_1= + +fan_speed.mode_8_2=config +fan_speed.int_cons_8_2= +fan_speed.src_8_2=cpld +fan_speed.frmt_8_2=num_bytes +fan_speed.pola_8_2=negative +fan_speed.fpath_8_2= +fan_speed.addr_8_2=0x0004002b +fan_speed.len_8_2=2 +fan_speed.bit_offset_8_2= + +fan_ratio.mode_1=config +fan_ratio.int_cons_1= +fan_ratio.src_1=cpld +fan_ratio.frmt_1=byte +fan_ratio.pola_1= +fan_ratio.fpath_1= +fan_ratio.addr_1=0x00030014 +fan_ratio.len_1=1 +fan_ratio.bit_offset_1= + +fan_ratio.mode_2=config +fan_ratio.int_cons_2= +fan_ratio.src_2=cpld +fan_ratio.frmt_2=byte +fan_ratio.pola_2= +fan_ratio.fpath_2= +fan_ratio.addr_2=0x00040014 +fan_ratio.len_2=1 +fan_ratio.bit_offset_2= + +fan_ratio.mode_3=config +fan_ratio.int_cons_3= +fan_ratio.src_3=cpld +fan_ratio.frmt_3=byte +fan_ratio.pola_3= +fan_ratio.fpath_3= +fan_ratio.addr_3=0x00030015 +fan_ratio.len_3=1 +fan_ratio.bit_offset_3= + +fan_ratio.mode_4=config +fan_ratio.int_cons_4= +fan_ratio.src_4=cpld +fan_ratio.frmt_4=byte +fan_ratio.pola_4= +fan_ratio.fpath_4= +fan_ratio.addr_4=0x00040015 +fan_ratio.len_4=1 +fan_ratio.bit_offset_4= + +fan_ratio.mode_5=config +fan_ratio.int_cons_5= +fan_ratio.src_5=cpld +fan_ratio.frmt_5=byte +fan_ratio.pola_5= +fan_ratio.fpath_5= +fan_ratio.addr_5=0x00030016 +fan_ratio.len_5=1 +fan_ratio.bit_offset_5= + +fan_ratio.mode_6=config +fan_ratio.int_cons_6= +fan_ratio.src_6=cpld +fan_ratio.frmt_6=byte +fan_ratio.pola_6= +fan_ratio.fpath_6= +fan_ratio.addr_6=0x00040016 +fan_ratio.len_6=1 +fan_ratio.bit_offset_6= + +fan_ratio.mode_7=config +fan_ratio.int_cons_7= +fan_ratio.src_7=cpld +fan_ratio.frmt_7=byte +fan_ratio.pola_7= +fan_ratio.fpath_7= +fan_ratio.addr_7=0x00030017 +fan_ratio.len_7=1 +fan_ratio.bit_offset_7= + +fan_ratio.mode_8=config +fan_ratio.int_cons_8= +fan_ratio.src_8=cpld +fan_ratio.frmt_8=byte +fan_ratio.pola_8= +fan_ratio.fpath_8= +fan_ratio.addr_8=0x00040017 +fan_ratio.len_8=1 +fan_ratio.bit_offset_8= + +# display fan name number +dev_num_1_7=1 + +fan_type_num_1=1 + +fan_name_1_1=FAN12K8080-F + +decode_fan_name_1=FAN12K8080-F \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-FPGA.cfg b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-FPGA.cfg new file mode 100755 index 000000000000..b651cd1c1e4e --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-FPGA.cfg @@ -0,0 +1,103 @@ +# FPGA number +dev_num_0_9=3 + +fpga_name_0_0=UPORT_FPGA +fpga_name_0_1=MAC_FPGA +fpga_name_0_2=DPORT_FPGA + + +fpga_version.mode_0_0=config +fpga_version.int_cons_0_0= +fpga_version.src_0_0=file +fpga_version.frmt_0_0=num_bytes +fpga_version.pola_0_0=negative +fpga_version.fpath_0_0=/dev/fpga0 +fpga_version.addr_0_0=0x0 +fpga_version.len_0_0=4 +fpga_version.bit_offset_0_0= + +fpga_version.mode_0_1=config +fpga_version.int_cons_0_1= +fpga_version.src_0_1=file +fpga_version.frmt_0_1=num_bytes +fpga_version.pola_0_1=negative +fpga_version.fpath_0_1=/dev/fpga1 +fpga_version.addr_0_1=0x0 +fpga_version.len_0_1=4 +fpga_version.bit_offset_0_1= + +fpga_version.mode_0_2=config +fpga_version.int_cons_0_2= +fpga_version.src_0_2=file +fpga_version.frmt_0_2=num_bytes +fpga_version.pola_0_2=negative +fpga_version.fpath_0_2=/dev/fpga2 +fpga_version.addr_0_2=0x0 +fpga_version.len_0_2=4 +fpga_version.bit_offset_0_2= + + +fpga_test_reg.mode_0_0=config +fpga_test_reg.int_cons_0_0= +fpga_test_reg.src_0_0=file +fpga_test_reg.frmt_0_0=num_bytes +fpga_test_reg.pola_0_0=negative +fpga_test_reg.fpath_0_0=/dev/fpga0 +fpga_test_reg.addr_0_0=0x08 +fpga_test_reg.len_0_0=4 +fpga_test_reg.bit_offset_0_0= + +fpga_test_reg.mode_0_1=config +fpga_test_reg.int_cons_0_1= +fpga_test_reg.src_0_1=file +fpga_test_reg.frmt_0_1=num_bytes +fpga_test_reg.pola_0_1=negative +fpga_test_reg.fpath_0_1=/dev/fpga1 +fpga_test_reg.addr_0_1=0x08 +fpga_test_reg.len_0_1=4 +fpga_test_reg.bit_offset_0_1= + +fpga_test_reg.mode_0_2=config +fpga_test_reg.int_cons_0_2= +fpga_test_reg.src_0_2=file +fpga_test_reg.frmt_0_2=num_bytes +fpga_test_reg.pola_0_2=negative +fpga_test_reg.fpath_0_2=/dev/fpga2 +fpga_test_reg.addr_0_2=0x08 +fpga_test_reg.len_0_2=4 +fpga_test_reg.bit_offset_0_2= + + +fpga_model_reg.mode_0_0=config +fpga_model_reg.int_cons_0_0= +fpga_model_reg.src_0_0=file +fpga_model_reg.frmt_0_0=num_bytes +fpga_model_reg.pola_0_0=negative +fpga_model_reg.fpath_0_0=/dev/fpga0 +fpga_model_reg.addr_0_0=0x98 +fpga_model_reg.len_0_0=4 +fpga_model_reg.bit_offset_0_0= + +fpga_model_reg.mode_0_1=config +fpga_model_reg.int_cons_0_1= +fpga_model_reg.src_0_1=file +fpga_model_reg.frmt_0_1=num_bytes +fpga_model_reg.pola_0_1=negative +fpga_model_reg.fpath_0_1=/dev/fpga1 +fpga_model_reg.addr_0_1=0xb0 +fpga_model_reg.len_0_1=4 +fpga_model_reg.bit_offset_0_1= + +fpga_model_reg.mode_0_2=config +fpga_model_reg.int_cons_0_2= +fpga_model_reg.src_0_2=file +fpga_model_reg.frmt_0_2=num_bytes +fpga_model_reg.pola_0_2=negative +fpga_model_reg.fpath_0_2=/dev/fpga2 +fpga_model_reg.addr_0_2=0x98 +fpga_model_reg.len_0_2=4 +fpga_model_reg.bit_offset_0_2= + + +fpga_model_decode_0x0=XC7A100T-2FGG484C +fpga_model_decode_0x200=XC7A200T-2FBG484I \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-LED.cfg b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-LED.cfg new file mode 100755 index 000000000000..14b301e5cd09 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-LED.cfg @@ -0,0 +1,101 @@ +led_status.mode_0_0=config +led_status.src_0_0=cpld +led_status.frmt_0_0=bit +led_status.addr_0_0=0x00050008 +led_status.len_0_0=3 + +led_status_decode_0_0=0 +led_status_decode_0_1=7 +led_status_decode_0_2=3 +led_status_decode_0_3=5 +led_status_decode_0_4=1 +led_status_decode_0_5=6 +led_status_decode_0_6=2 +led_status_decode_0_7=0 + +led_status.mode_4_0=config +led_status.src_4_0=cpld +led_status.frmt_4_0=bit +led_status.addr_4_0=0x0005000a +led_status.len_4_0=3 + +led_status_decode_4_0=0 +led_status_decode_4_1=7 +led_status_decode_4_2=3 +led_status_decode_4_3=5 +led_status_decode_4_4=1 +led_status_decode_4_5=6 +led_status_decode_4_6=2 +led_status_decode_4_7=0 + +led_status.mode_6_0=config +led_status.src_6_0=cpld +led_status.frmt_6_0=bit +led_status.addr_6_0=0x00050009 +led_status.len_6_0=3 + +led_status_decode_6_0=0 +led_status_decode_6_1=7 +led_status_decode_6_2=3 +led_status_decode_6_3=5 +led_status_decode_6_4=1 +led_status_decode_6_5=6 +led_status_decode_6_6=2 +led_status_decode_6_7=0 + +led_status.mode_10_1=config +led_status.src_10_1=cpld +led_status.frmt_10_1=bit +led_status.addr_10_1=0x0003003b +led_status.len_10_1=3 + +led_status.mode_10_2=config +led_status.src_10_2=cpld +led_status.frmt_10_2=bit +led_status.addr_10_2=0x0004003b +led_status.len_10_2=3 + +led_status.mode_10_3=config +led_status.src_10_3=cpld +led_status.frmt_10_3=bit +led_status.addr_10_3=0x0003003c +led_status.len_10_3=3 + +led_status.mode_10_4=config +led_status.src_10_4=cpld +led_status.frmt_10_4=bit +led_status.addr_10_4=0x0004003c +led_status.len_10_4=3 + +led_status.mode_10_5=config +led_status.src_10_5=cpld +led_status.frmt_10_5=bit +led_status.addr_10_5=0x0003003d +led_status.len_10_5=3 + +led_status.mode_10_6=config +led_status.src_10_6=cpld +led_status.frmt_10_6=bit +led_status.addr_10_6=0x0004003d +led_status.len_10_6=3 + +led_status.mode_10_7=config +led_status.src_10_7=cpld +led_status.frmt_10_7=bit +led_status.addr_10_7=0x0003003e +led_status.len_10_7=3 + +led_status.mode_10_8=config +led_status.src_10_8=cpld +led_status.frmt_10_8=bit +led_status.addr_10_8=0x0004003e +led_status.len_10_8=3 + +led_status_decode_10_0=0 +led_status_decode_10_1=7 +led_status_decode_10_2=3 +led_status_decode_10_3=5 +led_status_decode_10_4=1 +led_status_decode_10_5=6 +led_status_decode_10_6=2 +led_status_decode_10_7=0 \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-PSU.cfg b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-PSU.cfg new file mode 100755 index 000000000000..288c7d4da87a --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-PSU.cfg @@ -0,0 +1,622 @@ +# psu number +dev_num_2_0=4 + +# psu temp number +dev_num_2_1=3 + +other_i2c_dev.bus_2_1=79 +other_i2c_dev.addr_2_1=0x50 +other_i2c_dev.bus_2_2=80 +other_i2c_dev.addr_2_2=0x50 +other_i2c_dev.bus_2_3=82 +other_i2c_dev.addr_2_3=0x50 +other_i2c_dev.bus_2_4=81 +other_i2c_dev.addr_2_4=0x50 + +psu_pmbus_id_1_11=0x4F005880 +psu_pmbus_id_2_11=0x50005880 +psu_pmbus_id_3_11=0x52005880 +psu_pmbus_id_4_11=0x51005880 + +psu_status.mode_1_0=config +psu_status.src_1_0=cpld +psu_status.frmt_1_0=bit +psu_status.pola_1_0=negative +psu_status.addr_1_0=0x00010064 +psu_status.len_1_0=1 +psu_status.bit_offset_1_0=0 + +psu_status.mode_1_1=config +psu_status.src_1_1=cpld +psu_status.frmt_1_1=bit +psu_status.pola_1_1=positive +psu_status.addr_1_1=0x00010064 +psu_status.len_1_1=1 +psu_status.bit_offset_1_1=1 + +psu_status.mode_1_2=config +psu_status.src_1_2=cpld +psu_status.frmt_1_2=bit +psu_status.pola_1_2=positive +psu_status.addr_1_2=0x00010064 +psu_status.len_1_2=1 +psu_status.bit_offset_1_2=2 + +psu_status.mode_2_0=config +psu_status.src_2_0=cpld +psu_status.frmt_2_0=bit +psu_status.pola_2_0=negative +psu_status.addr_2_0=0x00010064 +psu_status.len_2_0=1 +psu_status.bit_offset_2_0=4 + +psu_status.mode_2_1=config +psu_status.src_2_1=cpld +psu_status.frmt_2_1=bit +psu_status.pola_2_1=positive +psu_status.addr_2_1=0x00010064 +psu_status.len_2_1=1 +psu_status.bit_offset_2_1=5 + +psu_status.mode_2_2=config +psu_status.src_2_2=cpld +psu_status.frmt_2_2=bit +psu_status.pola_2_2=positive +psu_status.addr_2_2=0x00010064 +psu_status.len_2_2=1 +psu_status.bit_offset_2_2=6 + +psu_status.mode_3_0=config +psu_status.src_3_0=cpld +psu_status.frmt_3_0=bit +psu_status.pola_3_0=negative +psu_status.addr_3_0=0x00010065 +psu_status.len_3_0=1 +psu_status.bit_offset_3_0=4 + +psu_status.mode_3_1=config +psu_status.src_3_1=cpld +psu_status.frmt_3_1=bit +psu_status.pola_3_1=positive +psu_status.addr_3_1=0x00010065 +psu_status.len_3_1=1 +psu_status.bit_offset_3_1=5 + +psu_status.mode_3_2=config +psu_status.src_3_2=cpld +psu_status.frmt_3_2=bit +psu_status.pola_3_2=positive +psu_status.addr_3_2=0x00010065 +psu_status.len_3_2=1 +psu_status.bit_offset_3_2=6 + +psu_status.mode_4_0=config +psu_status.src_4_0=cpld +psu_status.frmt_4_0=bit +psu_status.pola_4_0=negative +psu_status.addr_4_0=0x00010065 +psu_status.len_4_0=1 +psu_status.bit_offset_4_0=0 + +psu_status.mode_4_1=config +psu_status.src_4_1=cpld +psu_status.frmt_4_1=bit +psu_status.pola_4_1=positive +psu_status.addr_4_1=0x00010065 +psu_status.len_4_1=1 +psu_status.bit_offset_4_1=1 + +psu_status.mode_4_2=config +psu_status.src_4_2=cpld +psu_status.frmt_4_2=bit +psu_status.pola_4_2=positive +psu_status.addr_4_2=0x00010065 +psu_status.len_4_2=1 +psu_status.bit_offset_4_2=2 + +# 0:None 1:in_vol 2:in_curr 3:in_power 4:out_vol 5:out_curr 6:out_power 7:fan +# psu1 in_vol +hwmon_psu.mode_1_1=config +hwmon_psu.int_cons_1_1=0 +hwmon_psu.src_1_1=file +hwmon_psu.frmt_1_1=buf +hwmon_psu.fpath_1_1=/sys/bus/i2c/devices/79-0058/hwmon/ +hwmon_psu.addr_1_1=0 +hwmon_psu.len_1_1=8 +hwmon_psu.bit_offset_1_1= +hwmon_psu.str_cons_1_1=in1_input + +# psu1 in_curr +hwmon_psu.mode_1_2=config +hwmon_psu.int_cons_1_2=0 +hwmon_psu.src_1_2=file +hwmon_psu.frmt_1_2=buf +hwmon_psu.fpath_1_2=/sys/bus/i2c/devices/79-0058/hwmon/ +hwmon_psu.addr_1_2=0 +hwmon_psu.len_1_2=8 +hwmon_psu.bit_offset_1_2= +hwmon_psu.str_cons_1_2=curr1_input + +# psu1 in_power +hwmon_psu.mode_1_3=config +hwmon_psu.int_cons_1_3=0 +hwmon_psu.src_1_3=file +hwmon_psu.frmt_1_3=buf +hwmon_psu.fpath_1_3=/sys/bus/i2c/devices/79-0058/hwmon/ +hwmon_psu.addr_1_3=0 +hwmon_psu.len_1_3=16 +hwmon_psu.bit_offset_1_3=0 +hwmon_psu.str_cons_1_3=power1_input + +# psu1 out_vol +hwmon_psu.mode_1_4=config +hwmon_psu.int_cons_1_4=0 +hwmon_psu.src_1_4=file +hwmon_psu.frmt_1_4=buf +hwmon_psu.fpath_1_4=/sys/bus/i2c/devices/79-0058/hwmon/ +hwmon_psu.addr_1_4=0 +hwmon_psu.len_1_4=8 +hwmon_psu.bit_offset_1_4= +hwmon_psu.str_cons_1_4=in2_input + +# psu1 out_curr +hwmon_psu.mode_1_5=config +hwmon_psu.int_cons_1_5=0 +hwmon_psu.src_1_5=file +hwmon_psu.frmt_1_5=buf +hwmon_psu.fpath_1_5=/sys/bus/i2c/devices/79-0058/hwmon/ +hwmon_psu.addr_1_5=0 +hwmon_psu.len_1_5=8 +hwmon_psu.bit_offset_1_5= +hwmon_psu.str_cons_1_5=curr2_input + +# psu1 out_power +hwmon_psu.mode_1_6=config +hwmon_psu.int_cons_1_6=0 +hwmon_psu.src_1_6=file +hwmon_psu.frmt_1_6=buf +hwmon_psu.fpath_1_6=/sys/bus/i2c/devices/79-0058/hwmon/ +hwmon_psu.addr_1_6=0 +hwmon_psu.len_1_6=16 +hwmon_psu.bit_offset_1_6=0 +hwmon_psu.str_cons_1_6=power2_input + +# psu1 fan +hwmon_psu.mode_1_7=config +hwmon_psu.int_cons_1_7= +hwmon_psu.src_1_7=file +hwmon_psu.frmt_1_7=buf +hwmon_psu.fpath_1_7=/sys/bus/i2c/devices/79-0058/hwmon/ +hwmon_psu.addr_1_7=0 +hwmon_psu.len_1_7=8 +hwmon_psu.bit_offset_1_7= +hwmon_psu.str_cons_1_7=fan1_input + +# psu2 in_vol +hwmon_psu.mode_2_1=config +hwmon_psu.int_cons_2_1=0 +hwmon_psu.src_2_1=file +hwmon_psu.frmt_2_1=buf +hwmon_psu.fpath_2_1=/sys/bus/i2c/devices/80-0058/hwmon/ +hwmon_psu.addr_2_1=0 +hwmon_psu.len_2_1=8 +hwmon_psu.bit_offset_2_1= +hwmon_psu.str_cons_2_1=in1_input + +# psu2 in_curr +hwmon_psu.mode_2_2=config +hwmon_psu.int_cons_2_2=0 +hwmon_psu.src_2_2=file +hwmon_psu.frmt_2_2=buf +hwmon_psu.fpath_2_2=/sys/bus/i2c/devices/80-0058/hwmon/ +hwmon_psu.addr_2_2=0 +hwmon_psu.len_2_2=8 +hwmon_psu.bit_offset_2_2= +hwmon_psu.str_cons_2_2=curr1_input + +# psu2 in_power +hwmon_psu.mode_2_3=config +hwmon_psu.int_cons_2_3=0 +hwmon_psu.src_2_3=file +hwmon_psu.frmt_2_3=buf +hwmon_psu.fpath_2_3=/sys/bus/i2c/devices/80-0058/hwmon/ +hwmon_psu.addr_2_3=0 +hwmon_psu.len_2_3=16 +hwmon_psu.bit_offset_2_3=0 +hwmon_psu.str_cons_2_3=power1_input + +# psu2 out_vol +hwmon_psu.mode_2_4=config +hwmon_psu.int_cons_2_4=0 +hwmon_psu.src_2_4=file +hwmon_psu.frmt_2_4=buf +hwmon_psu.fpath_2_4=/sys/bus/i2c/devices/80-0058/hwmon/ +hwmon_psu.addr_2_4=0 +hwmon_psu.len_2_4=8 +hwmon_psu.bit_offset_2_4= +hwmon_psu.str_cons_2_4=in2_input + +# psu2 out_curr +hwmon_psu.mode_2_5=config +hwmon_psu.int_cons_2_5=0 +hwmon_psu.src_2_5=file +hwmon_psu.frmt_2_5=buf +hwmon_psu.fpath_2_5=/sys/bus/i2c/devices/80-0058/hwmon/ +hwmon_psu.addr_2_5=0 +hwmon_psu.len_2_5=8 +hwmon_psu.bit_offset_2_5= +hwmon_psu.str_cons_2_5=curr2_input + +# psu2 out_power +hwmon_psu.mode_2_6=config +hwmon_psu.int_cons_2_6=0 +hwmon_psu.src_2_6=file +hwmon_psu.frmt_2_6=buf +hwmon_psu.fpath_2_6=/sys/bus/i2c/devices/80-0058/hwmon/ +hwmon_psu.addr_2_6=0 +hwmon_psu.len_2_6=16 +hwmon_psu.bit_offset_2_6=0 +hwmon_psu.str_cons_2_6=power2_input + +# psu2 fan +hwmon_psu.mode_2_7=config +hwmon_psu.int_cons_2_7= +hwmon_psu.src_2_7=file +hwmon_psu.frmt_2_7=buf +hwmon_psu.fpath_2_7=/sys/bus/i2c/devices/80-0058/hwmon/ +hwmon_psu.addr_2_7=0 +hwmon_psu.len_2_7=8 +hwmon_psu.bit_offset_2_7= +hwmon_psu.str_cons_2_7=fan1_input + +# psu3 in_vol +hwmon_psu.mode_3_1=config +hwmon_psu.int_cons_3_1=0 +hwmon_psu.src_3_1=file +hwmon_psu.frmt_3_1=buf +hwmon_psu.fpath_3_1=/sys/bus/i2c/devices/82-0058/hwmon/ +hwmon_psu.addr_3_1=0 +hwmon_psu.len_3_1=8 +hwmon_psu.bit_offset_3_1= +hwmon_psu.str_cons_3_1=in1_input + +# psu3 in_curr +hwmon_psu.mode_3_2=config +hwmon_psu.int_cons_3_2=0 +hwmon_psu.src_3_2=file +hwmon_psu.frmt_3_2=buf +hwmon_psu.fpath_3_2=/sys/bus/i2c/devices/82-0058/hwmon/ +hwmon_psu.addr_3_2=0 +hwmon_psu.len_3_2=8 +hwmon_psu.bit_offset_3_2= +hwmon_psu.str_cons_3_2=curr1_input + +# psu3 in_power +hwmon_psu.mode_3_3=config +hwmon_psu.int_cons_3_3=0 +hwmon_psu.src_3_3=file +hwmon_psu.frmt_3_3=buf +hwmon_psu.fpath_3_3=/sys/bus/i2c/devices/82-0058/hwmon/ +hwmon_psu.addr_3_3=0 +hwmon_psu.len_3_3=16 +hwmon_psu.bit_offset_3_3=0 +hwmon_psu.str_cons_3_3=power1_input + +# psu3 out_vol +hwmon_psu.mode_3_4=config +hwmon_psu.int_cons_3_4=0 +hwmon_psu.src_3_4=file +hwmon_psu.frmt_3_4=buf +hwmon_psu.fpath_3_4=/sys/bus/i2c/devices/82-0058/hwmon/ +hwmon_psu.addr_3_4=0 +hwmon_psu.len_3_4=8 +hwmon_psu.bit_offset_3_4= +hwmon_psu.str_cons_3_4=in2_input + +# psu3 out_curr +hwmon_psu.mode_3_5=config +hwmon_psu.int_cons_3_5=0 +hwmon_psu.src_3_5=file +hwmon_psu.frmt_3_5=buf +hwmon_psu.fpath_3_5=/sys/bus/i2c/devices/82-0058/hwmon/ +hwmon_psu.addr_3_5=0 +hwmon_psu.len_3_5=8 +hwmon_psu.bit_offset_3_5= +hwmon_psu.str_cons_3_5=curr2_input + +# psu3 out_power +hwmon_psu.mode_3_6=config +hwmon_psu.int_cons_3_6=0 +hwmon_psu.src_3_6=file +hwmon_psu.frmt_3_6=buf +hwmon_psu.fpath_3_6=/sys/bus/i2c/devices/82-0058/hwmon/ +hwmon_psu.addr_3_6=0 +hwmon_psu.len_3_6=16 +hwmon_psu.bit_offset_3_6=0 +hwmon_psu.str_cons_3_6=power2_input + +# psu3 fan +hwmon_psu.mode_3_7=config +hwmon_psu.int_cons_3_7= +hwmon_psu.src_3_7=file +hwmon_psu.frmt_3_7=buf +hwmon_psu.fpath_3_7=/sys/bus/i2c/devices/82-0058/hwmon/ +hwmon_psu.addr_3_7=0 +hwmon_psu.len_3_7=8 +hwmon_psu.bit_offset_3_7= +hwmon_psu.str_cons_3_7=fan1_input + +# psu4 in_vol +hwmon_psu.mode_4_1=config +hwmon_psu.int_cons_4_1=0 +hwmon_psu.src_4_1=file +hwmon_psu.frmt_4_1=buf +hwmon_psu.fpath_4_1=/sys/bus/i2c/devices/81-0058/hwmon/ +hwmon_psu.addr_4_1=0 +hwmon_psu.len_4_1=8 +hwmon_psu.bit_offset_4_1= +hwmon_psu.str_cons_4_1=in1_input + +# psu4 in_curr +hwmon_psu.mode_4_2=config +hwmon_psu.int_cons_4_2=0 +hwmon_psu.src_4_2=file +hwmon_psu.frmt_4_2=buf +hwmon_psu.fpath_4_2=/sys/bus/i2c/devices/81-0058/hwmon/ +hwmon_psu.addr_4_2=0 +hwmon_psu.len_4_2=8 +hwmon_psu.bit_offset_4_2= +hwmon_psu.str_cons_4_2=curr1_input + +# psu4 in_power +hwmon_psu.mode_4_3=config +hwmon_psu.int_cons_4_3=0 +hwmon_psu.src_4_3=file +hwmon_psu.frmt_4_3=buf +hwmon_psu.fpath_4_3=/sys/bus/i2c/devices/81-0058/hwmon/ +hwmon_psu.addr_4_3=0 +hwmon_psu.len_4_3=16 +hwmon_psu.bit_offset_4_3=0 +hwmon_psu.str_cons_4_3=power1_input + +# psu4 out_vol +hwmon_psu.mode_4_4=config +hwmon_psu.int_cons_4_4=0 +hwmon_psu.src_4_4=file +hwmon_psu.frmt_4_4=buf +hwmon_psu.fpath_4_4=/sys/bus/i2c/devices/81-0058/hwmon/ +hwmon_psu.addr_4_4=0 +hwmon_psu.len_4_4=8 +hwmon_psu.bit_offset_4_4= +hwmon_psu.str_cons_4_4=in2_input + +# psu4 out_curr +hwmon_psu.mode_4_5=config +hwmon_psu.int_cons_4_5=0 +hwmon_psu.src_4_5=file +hwmon_psu.frmt_4_5=buf +hwmon_psu.fpath_4_5=/sys/bus/i2c/devices/81-0058/hwmon/ +hwmon_psu.addr_4_5=0 +hwmon_psu.len_4_5=8 +hwmon_psu.bit_offset_4_5= +hwmon_psu.str_cons_4_5=curr2_input + +# psu4 out_power +hwmon_psu.mode_4_6=config +hwmon_psu.int_cons_4_6=0 +hwmon_psu.src_4_6=file +hwmon_psu.frmt_4_6=buf +hwmon_psu.fpath_4_6=/sys/bus/i2c/devices/81-0058/hwmon/ +hwmon_psu.addr_4_6=0 +hwmon_psu.len_4_6=16 +hwmon_psu.bit_offset_4_6=0 +hwmon_psu.str_cons_4_6=power2_input + +# psu4 fan +hwmon_psu.mode_4_7=config +hwmon_psu.int_cons_4_7= +hwmon_psu.src_4_7=file +hwmon_psu.frmt_4_7=buf +hwmon_psu.fpath_4_7=/sys/bus/i2c/devices/81-0058/hwmon/ +hwmon_psu.addr_4_7=0 +hwmon_psu.len_4_7=8 +hwmon_psu.bit_offset_4_7= +hwmon_psu.str_cons_4_7=fan1_input +# 2:type 3:max 4:max_hyst 5:min 6:crit + +# psu1 temp1 input +hwmon_temp.mode_0x0101_0x20=config +hwmon_temp.int_cons_0x0101_0x20=0 +hwmon_temp.src_0x0101_0x20=file +hwmon_temp.frmt_0x0101_0x20=buf +hwmon_temp.fpath_0x0101_0x20=/sys/bus/i2c/devices/79-0058/hwmon/ +hwmon_temp.addr_0x0101_0x20=0 +hwmon_temp.len_0x0101_0x20=8 +hwmon_temp.bit_offset_0x0101_0x20= +hwmon_temp.str_cons_0x0101_0x20=temp1_input + +# psu1 temp1 alias +hwmon_temp.mode_0x0101_0x21=str_constant +hwmon_temp.str_cons_0x0101_0x21=temp1 + +# psu1 temp2 input +hwmon_temp.mode_0x0102_0x20=config +hwmon_temp.int_cons_0x0102_0x20=0 +hwmon_temp.src_0x0102_0x20=file +hwmon_temp.frmt_0x0102_0x20=buf +hwmon_temp.fpath_0x0102_0x20=/sys/bus/i2c/devices/79-0058/hwmon/ +hwmon_temp.addr_0x0102_0x20=0 +hwmon_temp.len_0x0102_0x20=8 +hwmon_temp.bit_offset_0x0102_0x20= +hwmon_temp.str_cons_0x0102_0x20=temp2_input + +# psu1 temp2 alias +hwmon_temp.mode_0x0102_0x21=str_constant +hwmon_temp.str_cons_0x0102_0x21=temp2 + +# psu1 temp3 input +hwmon_temp.mode_0x0103_0x20=config +hwmon_temp.int_cons_0x0103_0x20=0 +hwmon_temp.src_0x0103_0x20=file +hwmon_temp.frmt_0x0103_0x20=buf +hwmon_temp.fpath_0x0103_0x20=/sys/bus/i2c/devices/79-0058/hwmon/ +hwmon_temp.addr_0x0103_0x20=0 +hwmon_temp.len_0x0103_0x20=8 +hwmon_temp.bit_offset_0x0103_0x20= +hwmon_temp.str_cons_0x0103_0x20=temp3_input + +# psu1 temp3 alias +hwmon_temp.mode_0x0103_0x21=str_constant +hwmon_temp.str_cons_0x0103_0x21=temp3 + +# psu2 temp1 input +hwmon_temp.mode_0x0201_0x20=config +hwmon_temp.int_cons_0x0201_0x20=0 +hwmon_temp.src_0x0201_0x20=file +hwmon_temp.frmt_0x0201_0x20=buf +hwmon_temp.fpath_0x0201_0x20=/sys/bus/i2c/devices/80-0058/hwmon/ +hwmon_temp.addr_0x0201_0x20=0 +hwmon_temp.len_0x0201_0x20=8 +hwmon_temp.bit_offset_0x0201_0x20= +hwmon_temp.str_cons_0x0201_0x20=temp1_input + +# psu2 temp1 alias +hwmon_temp.mode_0x0201_0x21=str_constant +hwmon_temp.str_cons_0x0201_0x21=temp1 + +# psu2 temp2 input +hwmon_temp.mode_0x0202_0x20=config +hwmon_temp.int_cons_0x0202_0x20=0 +hwmon_temp.src_0x0202_0x20=file +hwmon_temp.frmt_0x0202_0x20=buf +hwmon_temp.fpath_0x0202_0x20=/sys/bus/i2c/devices/80-0058/hwmon/ +hwmon_temp.addr_0x0202_0x20=0 +hwmon_temp.len_0x0202_0x20=8 +hwmon_temp.bit_offset_0x0202_0x20= +hwmon_temp.str_cons_0x0202_0x20=temp2_input + +# psu2 temp2 alias +hwmon_temp.mode_0x0202_0x21=str_constant +hwmon_temp.str_cons_0x0202_0x21=temp2 + +# psu2 temp3 input +hwmon_temp.mode_0x0203_0x20=config +hwmon_temp.int_cons_0x0203_0x20=0 +hwmon_temp.src_0x0203_0x20=file +hwmon_temp.frmt_0x0203_0x20=buf +hwmon_temp.fpath_0x0203_0x20=/sys/bus/i2c/devices/80-0058/hwmon/ +hwmon_temp.addr_0x0203_0x20=0 +hwmon_temp.len_0x0203_0x20=8 +hwmon_temp.bit_offset_0x0203_0x20= +hwmon_temp.str_cons_0x0203_0x20=temp3_input + +# psu2 temp3 alias +hwmon_temp.mode_0x0203_0x21=str_constant +hwmon_temp.str_cons_0x0203_0x21=temp3 + +# psu3 temp1 input +hwmon_temp.mode_0x0301_0x20=config +hwmon_temp.int_cons_0x0301_0x20=0 +hwmon_temp.src_0x0301_0x20=file +hwmon_temp.frmt_0x0301_0x20=buf +hwmon_temp.fpath_0x0301_0x20=/sys/bus/i2c/devices/82-0058/hwmon/ +hwmon_temp.addr_0x0301_0x20=0 +hwmon_temp.len_0x0301_0x20=8 +hwmon_temp.bit_offset_0x0301_0x20= +hwmon_temp.str_cons_0x0301_0x20=temp1_input + +# psu3 temp1 alias +hwmon_temp.mode_0x0301_0x21=str_constant +hwmon_temp.str_cons_0x0301_0x21=temp1 + +# psu3 temp2 input +hwmon_temp.mode_0x0302_0x20=config +hwmon_temp.int_cons_0x0302_0x20=0 +hwmon_temp.src_0x0302_0x20=file +hwmon_temp.frmt_0x0302_0x20=buf +hwmon_temp.fpath_0x0302_0x20=/sys/bus/i2c/devices/82-0058/hwmon/ +hwmon_temp.addr_0x0302_0x20=0 +hwmon_temp.len_0x0302_0x20=8 +hwmon_temp.bit_offset_0x0302_0x20= +hwmon_temp.str_cons_0x0302_0x20=temp2_input + +# psu3 temp2 alias +hwmon_temp.mode_0x0302_0x21=str_constant +hwmon_temp.str_cons_0x0302_0x21=temp2 + +# psu3 temp3 input +hwmon_temp.mode_0x0303_0x20=config +hwmon_temp.int_cons_0x0303_0x20=0 +hwmon_temp.src_0x0303_0x20=file +hwmon_temp.frmt_0x0303_0x20=buf +hwmon_temp.fpath_0x0303_0x20=/sys/bus/i2c/devices/82-0058/hwmon/ +hwmon_temp.addr_0x0303_0x20=0 +hwmon_temp.len_0x0303_0x20=8 +hwmon_temp.bit_offset_0x0303_0x20= +hwmon_temp.str_cons_0x0303_0x20=temp3_input + +# psu3 temp3 alias +hwmon_temp.mode_0x0303_0x21=str_constant +hwmon_temp.str_cons_0x0303_0x21=temp3 + +# psu4 temp1 input +hwmon_temp.mode_0x0401_0x20=config +hwmon_temp.int_cons_0x0401_0x20=0 +hwmon_temp.src_0x0401_0x20=file +hwmon_temp.frmt_0x0401_0x20=buf +hwmon_temp.fpath_0x0401_0x20=/sys/bus/i2c/devices/81-0058/hwmon/ +hwmon_temp.addr_0x0401_0x20=0 +hwmon_temp.len_0x0401_0x20=8 +hwmon_temp.bit_offset_0x0401_0x20= +hwmon_temp.str_cons_0x0401_0x20=temp1_input + +# psu4 temp1 alias +hwmon_temp.mode_0x0401_0x21=str_constant +hwmon_temp.str_cons_0x0401_0x21=temp1 + +# psu4 temp2 input +hwmon_temp.mode_0x0402_0x20=config +hwmon_temp.int_cons_0x0402_0x20=0 +hwmon_temp.src_0x0402_0x20=file +hwmon_temp.frmt_0x0402_0x20=buf +hwmon_temp.fpath_0x0402_0x20=/sys/bus/i2c/devices/81-0058/hwmon/ +hwmon_temp.addr_0x0402_0x20=0 +hwmon_temp.len_0x0402_0x20=8 +hwmon_temp.bit_offset_0x0402_0x20= +hwmon_temp.str_cons_0x0402_0x20=temp2_input + +# psu4 temp2 alias +hwmon_temp.mode_0x0402_0x21=str_constant +hwmon_temp.str_cons_0x0402_0x21=temp2 + +# psu4 temp3 input +hwmon_temp.mode_0x0403_0x20=config +hwmon_temp.int_cons_0x0403_0x20=0 +hwmon_temp.src_0x0403_0x20=file +hwmon_temp.frmt_0x0403_0x20=buf +hwmon_temp.fpath_0x0403_0x20=/sys/bus/i2c/devices/81-0058/hwmon/ +hwmon_temp.addr_0x0403_0x20=0 +hwmon_temp.len_0x0403_0x20=8 +hwmon_temp.bit_offset_0x0403_0x20= +hwmon_temp.str_cons_0x0403_0x20=temp3_input + +# psu4 temp3 alias +hwmon_temp.mode_0x0403_0x21=str_constant +hwmon_temp.str_cons_0x0403_0x21=temp3 + +# display psu name number +dev_num_2_6=2 + +power_name_1_1=DPS-1300AB-6 +power_name_1_2=GW-CRPS1300D +power_name_2_1=DPS-1300AB-11 +power_name_2_2=CRPS1300D3R + +decode_power_name_1=PSA1300CRPS-F +decode_power_name_2=PSA1300CRPS-R + +power_rate_supply_1=1300000000 +power_rate_supply_2=1300000000 + +decode_power_fan_dir_1=0 +decode_power_fan_dir_2=1 \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-SENSOR.cfg b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-SENSOR.cfg new file mode 100755 index 000000000000..ab6cbc7bac24 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-SENSOR.cfg @@ -0,0 +1,2402 @@ +# temp sensor number +dev_num_0_1=34 + +# voltage sensor number +dev_num_0_2=56 + +# current sensor number +dev_num_0_3=7 + +# sensor temp1 input +hwmon_temp.mode_0x0001_0x00=config +hwmon_temp.int_cons_0x0001_0x00=0 +hwmon_temp.src_0x0001_0x00=file +hwmon_temp.frmt_0x0001_0x00=buf +hwmon_temp.fpath_0x0001_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0001_0x00=0 +hwmon_temp.len_0x0001_0x00=8 +hwmon_temp.bit_offset_0x0001_0x00= +hwmon_temp.str_cons_0x0001_0x00=temp1_input + +# sensor temp1 alias +hwmon_temp.mode_0x0001_0x01=config +hwmon_temp.int_cons_0x0001_0x01= +hwmon_temp.src_0x0001_0x01=file +hwmon_temp.frmt_0x0001_0x01=buf +hwmon_temp.fpath_0x0001_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0001_0x01=0 +hwmon_temp.len_0x0001_0x01=16 +hwmon_temp.bit_offset_0x0001_0x01= +hwmon_temp.str_cons_0x0001_0x01=temp1_label + +hwmon_temp.mode_0x0001_0x02=str_constant +hwmon_temp.str_cons_0x0001_0x02=cpu + +# sensor temp1 max +hwmon_temp.mode_0x0001_0x03=config +hwmon_temp.int_cons_0x0001_0x03=0 +hwmon_temp.src_0x0001_0x03=file +hwmon_temp.frmt_0x0001_0x03=buf +hwmon_temp.fpath_0x0001_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0001_0x03=0 +hwmon_temp.len_0x0001_0x03=8 +hwmon_temp.bit_offset_0x0001_0x03= +hwmon_temp.str_cons_0x0001_0x03=temp1_max + + +# sensor temp2 input +hwmon_temp.mode_0x0002_0x00=config +hwmon_temp.int_cons_0x0002_0x00=0 +hwmon_temp.src_0x0002_0x00=file +hwmon_temp.frmt_0x0002_0x00=buf +hwmon_temp.fpath_0x0002_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0002_0x00=0 +hwmon_temp.len_0x0002_0x00=8 +hwmon_temp.bit_offset_0x0002_0x00= +hwmon_temp.str_cons_0x0002_0x00=temp2_input + +# sensor temp2 alias +hwmon_temp.mode_0x0002_0x01=config +hwmon_temp.int_cons_0x0002_0x01= +hwmon_temp.src_0x0002_0x01=file +hwmon_temp.frmt_0x0002_0x01=buf +hwmon_temp.fpath_0x0002_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0002_0x01=0 +hwmon_temp.len_0x0002_0x01=16 +hwmon_temp.bit_offset_0x0002_0x01= +hwmon_temp.str_cons_0x0002_0x01=temp2_label + +hwmon_temp.mode_0x0002_0x02=str_constant +hwmon_temp.str_cons_0x0002_0x02=cpu + +# sensor temp2 max +hwmon_temp.mode_0x0002_0x03=config +hwmon_temp.int_cons_0x0002_0x03=0 +hwmon_temp.src_0x0002_0x03=file +hwmon_temp.frmt_0x0002_0x03=buf +hwmon_temp.fpath_0x0002_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0002_0x03=0 +hwmon_temp.len_0x0002_0x03=8 +hwmon_temp.bit_offset_0x0002_0x03= +hwmon_temp.str_cons_0x0002_0x03=temp2_max + + +# sensor temp3 input +hwmon_temp.mode_0x0003_0x00=config +hwmon_temp.int_cons_0x0003_0x00=0 +hwmon_temp.src_0x0003_0x00=file +hwmon_temp.frmt_0x0003_0x00=buf +hwmon_temp.fpath_0x0003_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0003_0x00=0 +hwmon_temp.len_0x0003_0x00=8 +hwmon_temp.bit_offset_0x0003_0x00= +hwmon_temp.str_cons_0x0003_0x00=temp3_input + +# sensor temp3 alias +hwmon_temp.mode_0x0003_0x01=config +hwmon_temp.int_cons_0x0003_0x01= +hwmon_temp.src_0x0003_0x01=file +hwmon_temp.frmt_0x0003_0x01=buf +hwmon_temp.fpath_0x0003_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0003_0x01=0 +hwmon_temp.len_0x0003_0x01=16 +hwmon_temp.bit_offset_0x0003_0x01= +hwmon_temp.str_cons_0x0003_0x01=temp3_label + +hwmon_temp.mode_0x0003_0x02=str_constant +hwmon_temp.str_cons_0x0003_0x02=cpu + +# sensor temp3 max +hwmon_temp.mode_0x0003_0x03=config +hwmon_temp.int_cons_0x0003_0x03=0 +hwmon_temp.src_0x0003_0x03=file +hwmon_temp.frmt_0x0003_0x03=buf +hwmon_temp.fpath_0x0003_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0003_0x03=0 +hwmon_temp.len_0x0003_0x03=8 +hwmon_temp.bit_offset_0x0003_0x03= +hwmon_temp.str_cons_0x0003_0x03=temp3_max + + +# sensor temp4 input +hwmon_temp.mode_0x0004_0x00=config +hwmon_temp.int_cons_0x0004_0x00=0 +hwmon_temp.src_0x0004_0x00=file +hwmon_temp.frmt_0x0004_0x00=buf +hwmon_temp.fpath_0x0004_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0004_0x00=0 +hwmon_temp.len_0x0004_0x00=8 +hwmon_temp.bit_offset_0x0004_0x00= +hwmon_temp.str_cons_0x0004_0x00=temp4_input + +# sensor temp4 alias +hwmon_temp.mode_0x0004_0x01=config +hwmon_temp.int_cons_0x0004_0x01= +hwmon_temp.src_0x0004_0x01=file +hwmon_temp.frmt_0x0004_0x01=buf +hwmon_temp.fpath_0x0004_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0004_0x01=0 +hwmon_temp.len_0x0004_0x01=16 +hwmon_temp.bit_offset_0x0004_0x01= +hwmon_temp.str_cons_0x0004_0x01=temp4_label + +hwmon_temp.mode_0x0004_0x02=str_constant +hwmon_temp.str_cons_0x0004_0x02=cpu + +# sensor temp4 max +hwmon_temp.mode_0x0004_0x03=config +hwmon_temp.int_cons_0x0004_0x03=0 +hwmon_temp.src_0x0004_0x03=file +hwmon_temp.frmt_0x0004_0x03=buf +hwmon_temp.fpath_0x0004_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0004_0x03=0 +hwmon_temp.len_0x0004_0x03=8 +hwmon_temp.bit_offset_0x0004_0x03= +hwmon_temp.str_cons_0x0004_0x03=temp4_max + + +# sensor temp5 input +hwmon_temp.mode_0x0005_0x00=config +hwmon_temp.int_cons_0x0005_0x00=0 +hwmon_temp.src_0x0005_0x00=file +hwmon_temp.frmt_0x0005_0x00=buf +hwmon_temp.fpath_0x0005_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0005_0x00=0 +hwmon_temp.len_0x0005_0x00=8 +hwmon_temp.bit_offset_0x0005_0x00= +hwmon_temp.str_cons_0x0005_0x00=temp5_input + +# sensor temp5 alias +hwmon_temp.mode_0x0005_0x01=config +hwmon_temp.int_cons_0x0005_0x01= +hwmon_temp.src_0x0005_0x01=file +hwmon_temp.frmt_0x0005_0x01=buf +hwmon_temp.fpath_0x0005_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0005_0x01=0 +hwmon_temp.len_0x0005_0x01=16 +hwmon_temp.bit_offset_0x0005_0x01= +hwmon_temp.str_cons_0x0005_0x01=temp5_label + +hwmon_temp.mode_0x0005_0x02=str_constant +hwmon_temp.str_cons_0x0005_0x02=cpu + +# sensor temp5 max +hwmon_temp.mode_0x0005_0x03=config +hwmon_temp.int_cons_0x0005_0x03=0 +hwmon_temp.src_0x0005_0x03=file +hwmon_temp.frmt_0x0005_0x03=buf +hwmon_temp.fpath_0x0005_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0005_0x03=0 +hwmon_temp.len_0x0005_0x03=8 +hwmon_temp.bit_offset_0x0005_0x03= +hwmon_temp.str_cons_0x0005_0x03=temp5_max + +# sensor temp6 input +hwmon_temp.mode_0x0006_0x00=config +hwmon_temp.int_cons_0x0006_0x00=0 +hwmon_temp.src_0x0006_0x00=file +hwmon_temp.frmt_0x0006_0x00=buf +hwmon_temp.fpath_0x0006_0x00=/sys/bus/i2c/devices/107-004b/hwmon/ +hwmon_temp.addr_0x0006_0x00=0 +hwmon_temp.len_0x0006_0x00=8 +hwmon_temp.bit_offset_0x0006_0x00= +hwmon_temp.str_cons_0x0006_0x00=temp1_input + +hwmon_temp.mode_0x0006_0x01=str_constant +hwmon_temp.str_cons_0x0006_0x01=air_inlet + +hwmon_temp.mode_0x0006_0x02=str_constant +hwmon_temp.str_cons_0x0006_0x02=lm75 + +hwmon_temp.mode_0x0006_0x03=config +hwmon_temp.int_cons_0x0006_0x03=0 +hwmon_temp.src_0x0006_0x03=file +hwmon_temp.frmt_0x0006_0x03=buf +hwmon_temp.fpath_0x0006_0x03=/sys/bus/i2c/devices/107-004b/hwmon/ +hwmon_temp.addr_0x0006_0x03=0 +hwmon_temp.len_0x0006_0x03=8 +hwmon_temp.bit_offset_0x0006_0x03= +hwmon_temp.str_cons_0x0006_0x03=temp1_max + +hwmon_temp.mode_0x0006_0x04=config +hwmon_temp.int_cons_0x0006_0x04=0 +hwmon_temp.src_0x0006_0x04=file +hwmon_temp.frmt_0x0006_0x04=buf +hwmon_temp.fpath_0x0006_0x04=/sys/bus/i2c/devices/107-004b/hwmon/ +hwmon_temp.addr_0x0006_0x04=0 +hwmon_temp.len_0x0006_0x04=8 +hwmon_temp.bit_offset_0x0006_0x04= +hwmon_temp.str_cons_0x0006_0x04=temp1_max_hyst + +hwmon_temp.mode_0x0007_0x00=config +hwmon_temp.int_cons_0x0007_0x00=0 +hwmon_temp.src_0x0007_0x00=file +hwmon_temp.frmt_0x0007_0x00=buf +hwmon_temp.fpath_0x0007_0x00=/sys/bus/i2c/devices/64-004f/hwmon/ +hwmon_temp.addr_0x0007_0x00=0 +hwmon_temp.len_0x0007_0x00=8 +hwmon_temp.bit_offset_0x0007_0x00= +hwmon_temp.str_cons_0x0007_0x00=temp1_input + +hwmon_temp.mode_0x0007_0x01=str_constant +hwmon_temp.str_cons_0x0007_0x01=Uport_air_inlet_L + +hwmon_temp.mode_0x0007_0x02=str_constant +hwmon_temp.str_cons_0x0007_0x02=lm75 + +hwmon_temp.mode_0x0007_0x03=config +hwmon_temp.int_cons_0x0007_0x03=0 +hwmon_temp.src_0x0007_0x03=file +hwmon_temp.frmt_0x0007_0x03=buf +hwmon_temp.fpath_0x0007_0x03=/sys/bus/i2c/devices/64-004f/hwmon/ +hwmon_temp.addr_0x0007_0x03=0 +hwmon_temp.len_0x0007_0x03=8 +hwmon_temp.bit_offset_0x0007_0x03= +hwmon_temp.str_cons_0x0007_0x03=temp1_max + +hwmon_temp.mode_0x0007_0x04=config +hwmon_temp.int_cons_0x0007_0x04=0 +hwmon_temp.src_0x0007_0x04=file +hwmon_temp.frmt_0x0007_0x04=buf +hwmon_temp.fpath_0x0007_0x04=/sys/bus/i2c/devices/64-004f/hwmon/ +hwmon_temp.addr_0x0007_0x04=0 +hwmon_temp.len_0x0007_0x04=8 +hwmon_temp.bit_offset_0x0007_0x04= +hwmon_temp.str_cons_0x0007_0x04=temp1_max_hyst + +hwmon_temp.mode_0x0008_0x00=config +hwmon_temp.int_cons_0x0008_0x00=0 +hwmon_temp.src_0x0008_0x00=file +hwmon_temp.frmt_0x0008_0x00=buf +hwmon_temp.fpath_0x0008_0x00=/sys/bus/i2c/devices/63-004b/hwmon/ +hwmon_temp.addr_0x0008_0x00=0 +hwmon_temp.len_0x0008_0x00=8 +hwmon_temp.bit_offset_0x0008_0x00= +hwmon_temp.str_cons_0x0008_0x00=temp1_input + +hwmon_temp.mode_0x0008_0x01=str_constant +hwmon_temp.str_cons_0x0008_0x01=Uport_air_inlet_R + +hwmon_temp.mode_0x0008_0x02=str_constant +hwmon_temp.str_cons_0x0008_0x02=lm75 + +hwmon_temp.mode_0x0008_0x03=config +hwmon_temp.int_cons_0x0008_0x03=0 +hwmon_temp.src_0x0008_0x03=file +hwmon_temp.frmt_0x0008_0x03=buf +hwmon_temp.fpath_0x0008_0x03=/sys/bus/i2c/devices/63-004b/hwmon/ +hwmon_temp.addr_0x0008_0x03=0 +hwmon_temp.len_0x0008_0x03=8 +hwmon_temp.bit_offset_0x0008_0x03= +hwmon_temp.str_cons_0x0008_0x03=temp1_max + +hwmon_temp.mode_0x0008_0x04=config +hwmon_temp.int_cons_0x0008_0x04=0 +hwmon_temp.src_0x0008_0x04=file +hwmon_temp.frmt_0x0008_0x04=buf +hwmon_temp.fpath_0x0008_0x04=/sys/bus/i2c/devices/63-004b/hwmon/ +hwmon_temp.addr_0x0008_0x04=0 +hwmon_temp.len_0x0008_0x04=8 +hwmon_temp.bit_offset_0x0008_0x04= +hwmon_temp.str_cons_0x0008_0x04=temp1_max_hyst + +hwmon_temp.mode_0x0009_0x00=config +hwmon_temp.int_cons_0x0009_0x00=0 +hwmon_temp.src_0x0009_0x00=file +hwmon_temp.frmt_0x0009_0x00=buf +hwmon_temp.fpath_0x0009_0x00=/sys/bus/i2c/devices/114-004b/hwmon/ +hwmon_temp.addr_0x0009_0x00=0 +hwmon_temp.len_0x0009_0x00=8 +hwmon_temp.bit_offset_0x0009_0x00= +hwmon_temp.str_cons_0x0009_0x00=temp1_input + +hwmon_temp.mode_0x0009_0x01=str_constant +hwmon_temp.str_cons_0x0009_0x01=Dport_air_inlet_L + +hwmon_temp.mode_0x0009_0x02=str_constant +hwmon_temp.str_cons_0x0009_0x02=lm75 + +hwmon_temp.mode_0x0009_0x03=config +hwmon_temp.int_cons_0x0009_0x03=0 +hwmon_temp.src_0x0009_0x03=file +hwmon_temp.frmt_0x0009_0x03=buf +hwmon_temp.fpath_0x0009_0x03=/sys/bus/i2c/devices/114-004b/hwmon/ +hwmon_temp.addr_0x0009_0x03=0 +hwmon_temp.len_0x0009_0x03=8 +hwmon_temp.bit_offset_0x0009_0x03= +hwmon_temp.str_cons_0x0009_0x03=temp1_max + +hwmon_temp.mode_0x0009_0x04=config +hwmon_temp.int_cons_0x0009_0x04=0 +hwmon_temp.src_0x0009_0x04=file +hwmon_temp.frmt_0x0009_0x04=buf +hwmon_temp.fpath_0x0009_0x04=/sys/bus/i2c/devices/114-004b/hwmon/ +hwmon_temp.addr_0x0009_0x04=0 +hwmon_temp.len_0x0009_0x04=8 +hwmon_temp.bit_offset_0x0009_0x04= +hwmon_temp.str_cons_0x0009_0x04=temp1_max_hyst + +hwmon_temp.mode_0x000a_0x00=config +hwmon_temp.int_cons_0x000a_0x00=0 +hwmon_temp.src_0x000a_0x00=file +hwmon_temp.frmt_0x000a_0x00=buf +hwmon_temp.fpath_0x000a_0x00=/sys/bus/i2c/devices/115-004f/hwmon/ +hwmon_temp.addr_0x000a_0x00=0 +hwmon_temp.len_0x000a_0x00=8 +hwmon_temp.bit_offset_0x000a_0x00= +hwmon_temp.str_cons_0x000a_0x00=temp1_input + +hwmon_temp.mode_0x000a_0x01=str_constant +hwmon_temp.str_cons_0x000a_0x01=Dport_air_inlet_R + +hwmon_temp.mode_0x000a_0x02=str_constant +hwmon_temp.str_cons_0x000a_0x02=lm75 + +hwmon_temp.mode_0x000a_0x03=config +hwmon_temp.int_cons_0x000a_0x03=0 +hwmon_temp.src_0x000a_0x03=file +hwmon_temp.frmt_0x000a_0x03=buf +hwmon_temp.fpath_0x000a_0x03=/sys/bus/i2c/devices/115-004f/hwmon/ +hwmon_temp.addr_0x000a_0x03=0 +hwmon_temp.len_0x000a_0x03=8 +hwmon_temp.bit_offset_0x000a_0x03= +hwmon_temp.str_cons_0x000a_0x03=temp1_max + +hwmon_temp.mode_0x000a_0x04=config +hwmon_temp.int_cons_0x000a_0x04=0 +hwmon_temp.src_0x000a_0x04=file +hwmon_temp.frmt_0x000a_0x04=buf +hwmon_temp.fpath_0x000a_0x04=/sys/bus/i2c/devices/115-004f/hwmon/ +hwmon_temp.addr_0x000a_0x04=0 +hwmon_temp.len_0x000a_0x04=8 +hwmon_temp.bit_offset_0x000a_0x04= +hwmon_temp.str_cons_0x000a_0x04=temp1_max_hyst + +hwmon_temp.mode_0x000b_0x00=config +hwmon_temp.int_cons_0x000b_0x00=0 +hwmon_temp.src_0x000b_0x00=file +hwmon_temp.frmt_0x000b_0x00=buf +hwmon_temp.fpath_0x000b_0x00=/sys/bus/i2c/devices/69-004b/hwmon/ +hwmon_temp.addr_0x000b_0x00=0 +hwmon_temp.len_0x000b_0x00=8 +hwmon_temp.bit_offset_0x000b_0x00= +hwmon_temp.str_cons_0x000b_0x00=temp1_input + +hwmon_temp.mode_0x000b_0x01=str_constant +hwmon_temp.str_cons_0x000b_0x01=MAC_air_inlet + +hwmon_temp.mode_0x000b_0x02=str_constant +hwmon_temp.str_cons_0x000b_0x02=lm75 + +hwmon_temp.mode_0x000b_0x03=config +hwmon_temp.int_cons_0x000b_0x03=0 +hwmon_temp.src_0x000b_0x03=file +hwmon_temp.frmt_0x000b_0x03=buf +hwmon_temp.fpath_0x000b_0x03=/sys/bus/i2c/devices/69-004b/hwmon/ +hwmon_temp.addr_0x000b_0x03=0 +hwmon_temp.len_0x000b_0x03=8 +hwmon_temp.bit_offset_0x000b_0x03= +hwmon_temp.str_cons_0x000b_0x03=temp1_max + +hwmon_temp.mode_0x000b_0x04=config +hwmon_temp.int_cons_0x000b_0x04=0 +hwmon_temp.src_0x000b_0x04=file +hwmon_temp.frmt_0x000b_0x04=buf +hwmon_temp.fpath_0x000b_0x04=/sys/bus/i2c/devices/69-004b/hwmon/ +hwmon_temp.addr_0x000b_0x04=0 +hwmon_temp.len_0x000b_0x04=8 +hwmon_temp.bit_offset_0x000b_0x04= +hwmon_temp.str_cons_0x000b_0x04=temp1_max_hyst + +hwmon_temp.mode_0x000c_0x00=config +hwmon_temp.int_cons_0x000c_0x00=0 +hwmon_temp.src_0x000c_0x00=file +hwmon_temp.frmt_0x000c_0x00=buf +hwmon_temp.fpath_0x000c_0x00=/sys/bus/i2c/devices/109-004b/hwmon/ +hwmon_temp.addr_0x000c_0x00=0 +hwmon_temp.len_0x000c_0x00=8 +hwmon_temp.bit_offset_0x000c_0x00= +hwmon_temp.str_cons_0x000c_0x00=temp1_input + +hwmon_temp.mode_0x000c_0x01=str_constant +hwmon_temp.str_cons_0x000c_0x01=Base_air_inlet + +hwmon_temp.mode_0x000c_0x02=str_constant +hwmon_temp.str_cons_0x000c_0x02=lm75 + +hwmon_temp.mode_0x000c_0x03=config +hwmon_temp.int_cons_0x000c_0x03=0 +hwmon_temp.src_0x000c_0x03=file +hwmon_temp.frmt_0x000c_0x03=buf +hwmon_temp.fpath_0x000c_0x03=/sys/bus/i2c/devices/109-004b/hwmon/ +hwmon_temp.addr_0x000c_0x03=0 +hwmon_temp.len_0x000c_0x03=8 +hwmon_temp.bit_offset_0x000c_0x03= +hwmon_temp.str_cons_0x000c_0x03=temp1_max + +hwmon_temp.mode_0x000c_0x04=config +hwmon_temp.int_cons_0x000c_0x04=0 +hwmon_temp.src_0x000c_0x04=file +hwmon_temp.frmt_0x000c_0x04=buf +hwmon_temp.fpath_0x000c_0x04=/sys/bus/i2c/devices/109-004b/hwmon/ +hwmon_temp.addr_0x000c_0x04=0 +hwmon_temp.len_0x000c_0x04=8 +hwmon_temp.bit_offset_0x000c_0x04= +hwmon_temp.str_cons_0x000c_0x04=temp1_max_hyst + +hwmon_temp.mode_0x000d_0x00=config +hwmon_temp.int_cons_0x000d_0x00=0 +hwmon_temp.src_0x000d_0x00=file +hwmon_temp.frmt_0x000d_0x00=buf +hwmon_temp.fpath_0x000d_0x00=/sys/bus/i2c/devices/70-004f/hwmon/ +hwmon_temp.addr_0x000d_0x00=0 +hwmon_temp.len_0x000d_0x00=8 +hwmon_temp.bit_offset_0x000d_0x00= +hwmon_temp.str_cons_0x000d_0x00=temp1_input + +hwmon_temp.mode_0x000d_0x01=str_constant +hwmon_temp.str_cons_0x000d_0x01=MAC_air_outlet + +hwmon_temp.mode_0x000d_0x02=str_constant +hwmon_temp.str_cons_0x000d_0x02=lm75 + +hwmon_temp.mode_0x000d_0x03=config +hwmon_temp.int_cons_0x000d_0x03=0 +hwmon_temp.src_0x000d_0x03=file +hwmon_temp.frmt_0x000d_0x03=buf +hwmon_temp.fpath_0x000d_0x03=/sys/bus/i2c/devices/70-004f/hwmon/ +hwmon_temp.addr_0x000d_0x03=0 +hwmon_temp.len_0x000d_0x03=8 +hwmon_temp.bit_offset_0x000d_0x03= +hwmon_temp.str_cons_0x000d_0x03=temp1_max + +hwmon_temp.mode_0x000d_0x04=config +hwmon_temp.int_cons_0x000d_0x04=0 +hwmon_temp.src_0x000d_0x04=file +hwmon_temp.frmt_0x000d_0x04=buf +hwmon_temp.fpath_0x000d_0x04=/sys/bus/i2c/devices/70-004f/hwmon/ +hwmon_temp.addr_0x000d_0x04=0 +hwmon_temp.len_0x000d_0x04=8 +hwmon_temp.bit_offset_0x000d_0x04= +hwmon_temp.str_cons_0x000d_0x04=temp1_max_hyst + +hwmon_temp.mode_0x000e_0x00=config +hwmon_temp.int_cons_0x000e_0x00=0 +hwmon_temp.src_0x000e_0x00=file +hwmon_temp.frmt_0x000e_0x00=buf +hwmon_temp.fpath_0x000e_0x00=/sys/bus/i2c/devices/71-004c/hwmon/ +hwmon_temp.addr_0x000e_0x00=0 +hwmon_temp.len_0x000e_0x00=8 +hwmon_temp.bit_offset_0x000e_0x00= +hwmon_temp.str_cons_0x000e_0x00=temp2_input + +hwmon_temp.mode_0x000e_0x01=str_constant +hwmon_temp.str_cons_0x000e_0x01=MAC_TEMPDIODE0 + +hwmon_temp.mode_0x000e_0x02=str_constant +hwmon_temp.str_cons_0x000e_0x02=tmp411 + +hwmon_temp.mode_0x000e_0x03=config +hwmon_temp.int_cons_0x000e_0x03=0 +hwmon_temp.src_0x000e_0x03=file +hwmon_temp.frmt_0x000e_0x03=buf +hwmon_temp.fpath_0x000e_0x03=/sys/bus/i2c/devices/71-004c/hwmon/ +hwmon_temp.addr_0x000e_0x03=0 +hwmon_temp.len_0x000e_0x03=8 +hwmon_temp.bit_offset_0x000e_0x03= +hwmon_temp.str_cons_0x000e_0x03=temp2_max + +hwmon_temp.mode_0x000e_0x04=config +hwmon_temp.int_cons_0x000e_0x04=0 +hwmon_temp.src_0x000e_0x04=file +hwmon_temp.frmt_0x000e_0x04=buf +hwmon_temp.fpath_0x000e_0x04=/sys/bus/i2c/devices/71-004c/hwmon/ +hwmon_temp.addr_0x000e_0x04=0 +hwmon_temp.len_0x000e_0x04=8 +hwmon_temp.bit_offset_0x000e_0x04= +hwmon_temp.str_cons_0x000e_0x04=temp2_max_hyst + +hwmon_temp.mode_0x000f_0x00=config +hwmon_temp.int_cons_0x000f_0x00=0 +hwmon_temp.src_0x000f_0x00=file +hwmon_temp.frmt_0x000f_0x00=buf +hwmon_temp.fpath_0x000f_0x00=/sys/bus/i2c/devices/72-004c/hwmon/ +hwmon_temp.addr_0x000f_0x00=0 +hwmon_temp.len_0x000f_0x00=8 +hwmon_temp.bit_offset_0x000f_0x00= +hwmon_temp.str_cons_0x000f_0x00=temp2_input + +hwmon_temp.mode_0x000f_0x01=str_constant +hwmon_temp.str_cons_0x000f_0x01=MAC_TEMPDIODE1 + +hwmon_temp.mode_0x000f_0x02=str_constant +hwmon_temp.str_cons_0x000f_0x02=tmp411 + +hwmon_temp.mode_0x000f_0x03=config +hwmon_temp.int_cons_0x000f_0x03=0 +hwmon_temp.src_0x000f_0x03=file +hwmon_temp.frmt_0x000f_0x03=buf +hwmon_temp.fpath_0x000f_0x03=/sys/bus/i2c/devices/72-004c/hwmon/ +hwmon_temp.addr_0x000f_0x03=0 +hwmon_temp.len_0x000f_0x03=8 +hwmon_temp.bit_offset_0x000f_0x03= +hwmon_temp.str_cons_0x000f_0x03=temp2_max + +hwmon_temp.mode_0x000f_0x04=config +hwmon_temp.int_cons_0x000f_0x04=0 +hwmon_temp.src_0x000f_0x04=file +hwmon_temp.frmt_0x000f_0x04=buf +hwmon_temp.fpath_0x000f_0x04=/sys/bus/i2c/devices/72-004c/hwmon/ +hwmon_temp.addr_0x000f_0x04=0 +hwmon_temp.len_0x000f_0x04=8 +hwmon_temp.bit_offset_0x000f_0x04= +hwmon_temp.str_cons_0x000f_0x04=temp2_max_hyst + +hwmon_temp.mode_0x0010_0x00=config +hwmon_temp.int_cons_0x0010_0x00=0 +hwmon_temp.src_0x0010_0x00=file +hwmon_temp.frmt_0x0010_0x00=buf +hwmon_temp.fpath_0x0010_0x00=/sys/bus/i2c/devices/88-0048/hwmon/ +hwmon_temp.addr_0x0010_0x00=0 +hwmon_temp.len_0x0010_0x00=8 +hwmon_temp.bit_offset_0x0010_0x00= +hwmon_temp.str_cons_0x0010_0x00=temp1_input + +hwmon_temp.mode_0x0010_0x01=str_constant +hwmon_temp.str_cons_0x0010_0x01=FCB_air_outlet_UL + +hwmon_temp.mode_0x0010_0x02=str_constant +hwmon_temp.str_cons_0x0010_0x02=lm75 + +hwmon_temp.mode_0x0010_0x03=config +hwmon_temp.int_cons_0x0010_0x03=0 +hwmon_temp.src_0x0010_0x03=file +hwmon_temp.frmt_0x0010_0x03=buf +hwmon_temp.fpath_0x0010_0x03=/sys/bus/i2c/devices/88-0048/hwmon/ +hwmon_temp.addr_0x0010_0x03=0 +hwmon_temp.len_0x0010_0x03=8 +hwmon_temp.bit_offset_0x0010_0x03= +hwmon_temp.str_cons_0x0010_0x03=temp1_max + +hwmon_temp.mode_0x0010_0x04=config +hwmon_temp.int_cons_0x0010_0x04=0 +hwmon_temp.src_0x0010_0x04=file +hwmon_temp.frmt_0x0010_0x04=buf +hwmon_temp.fpath_0x0010_0x04=/sys/bus/i2c/devices/88-0048/hwmon/ +hwmon_temp.addr_0x0010_0x04=0 +hwmon_temp.len_0x0010_0x04=8 +hwmon_temp.bit_offset_0x0010_0x04= +hwmon_temp.str_cons_0x0010_0x04=temp1_max_hyst + +hwmon_temp.mode_0x0011_0x00=config +hwmon_temp.int_cons_0x0011_0x00=0 +hwmon_temp.src_0x0011_0x00=file +hwmon_temp.frmt_0x0011_0x00=buf +hwmon_temp.fpath_0x0011_0x00=/sys/bus/i2c/devices/89-0049/hwmon/ +hwmon_temp.addr_0x0011_0x00=0 +hwmon_temp.len_0x0011_0x00=8 +hwmon_temp.bit_offset_0x0011_0x00= +hwmon_temp.str_cons_0x0011_0x00=temp1_input + +hwmon_temp.mode_0x0011_0x01=str_constant +hwmon_temp.str_cons_0x0011_0x01=FCB_air_outlet_UR + +hwmon_temp.mode_0x0011_0x02=str_constant +hwmon_temp.str_cons_0x0011_0x02=lm75 + +hwmon_temp.mode_0x0011_0x03=config +hwmon_temp.int_cons_0x0011_0x03=0 +hwmon_temp.src_0x0011_0x03=file +hwmon_temp.frmt_0x0011_0x03=buf +hwmon_temp.fpath_0x0011_0x03=/sys/bus/i2c/devices/89-0049/hwmon/ +hwmon_temp.addr_0x0011_0x03=0 +hwmon_temp.len_0x0011_0x03=8 +hwmon_temp.bit_offset_0x0011_0x03= +hwmon_temp.str_cons_0x0011_0x03=temp1_max + +hwmon_temp.mode_0x0011_0x04=config +hwmon_temp.int_cons_0x0011_0x04=0 +hwmon_temp.src_0x0011_0x04=file +hwmon_temp.frmt_0x0011_0x04=buf +hwmon_temp.fpath_0x0011_0x04=/sys/bus/i2c/devices/89-0049/hwmon/ +hwmon_temp.addr_0x0011_0x04=0 +hwmon_temp.len_0x0011_0x04=8 +hwmon_temp.bit_offset_0x0011_0x04= +hwmon_temp.str_cons_0x0011_0x04=temp1_max_hyst + +hwmon_temp.mode_0x0012_0x00=config +hwmon_temp.int_cons_0x0012_0x00=0 +hwmon_temp.src_0x0012_0x00=file +hwmon_temp.frmt_0x0012_0x00=buf +hwmon_temp.fpath_0x0012_0x00=/sys/bus/i2c/devices/96-0048/hwmon/ +hwmon_temp.addr_0x0012_0x00=0 +hwmon_temp.len_0x0012_0x00=8 +hwmon_temp.bit_offset_0x0012_0x00= +hwmon_temp.str_cons_0x0012_0x00=temp1_input + +hwmon_temp.mode_0x0012_0x01=str_constant +hwmon_temp.str_cons_0x0012_0x01=FCB_air_outlet_DL + +hwmon_temp.mode_0x0012_0x02=str_constant +hwmon_temp.str_cons_0x0012_0x02=lm75 + +hwmon_temp.mode_0x0012_0x03=config +hwmon_temp.int_cons_0x0012_0x03=0 +hwmon_temp.src_0x0012_0x03=file +hwmon_temp.frmt_0x0012_0x03=buf +hwmon_temp.fpath_0x0012_0x03=/sys/bus/i2c/devices/96-0048/hwmon/ +hwmon_temp.addr_0x0012_0x03=0 +hwmon_temp.len_0x0012_0x03=8 +hwmon_temp.bit_offset_0x0012_0x03= +hwmon_temp.str_cons_0x0012_0x03=temp1_max + +hwmon_temp.mode_0x0012_0x04=config +hwmon_temp.int_cons_0x0012_0x04=0 +hwmon_temp.src_0x0012_0x04=file +hwmon_temp.frmt_0x0012_0x04=buf +hwmon_temp.fpath_0x0012_0x04=/sys/bus/i2c/devices/96-0048/hwmon/ +hwmon_temp.addr_0x0012_0x04=0 +hwmon_temp.len_0x0012_0x04=8 +hwmon_temp.bit_offset_0x0012_0x04= +hwmon_temp.str_cons_0x0012_0x04=temp1_max_hyst + +hwmon_temp.mode_0x0013_0x00=config +hwmon_temp.int_cons_0x0013_0x00=0 +hwmon_temp.src_0x0013_0x00=file +hwmon_temp.frmt_0x0013_0x00=buf +hwmon_temp.fpath_0x0013_0x00=/sys/bus/i2c/devices/97-0049/hwmon/ +hwmon_temp.addr_0x0013_0x00=0 +hwmon_temp.len_0x0013_0x00=8 +hwmon_temp.bit_offset_0x0013_0x00= +hwmon_temp.str_cons_0x0013_0x00=temp1_input + +hwmon_temp.mode_0x0013_0x01=str_constant +hwmon_temp.str_cons_0x0013_0x01=FCB_air_outlet_DR + +hwmon_temp.mode_0x0013_0x02=str_constant +hwmon_temp.str_cons_0x0013_0x02=lm75 + +hwmon_temp.mode_0x0013_0x03=config +hwmon_temp.int_cons_0x0013_0x03=0 +hwmon_temp.src_0x0013_0x03=file +hwmon_temp.frmt_0x0013_0x03=buf +hwmon_temp.fpath_0x0013_0x03=/sys/bus/i2c/devices/97-0049/hwmon/ +hwmon_temp.addr_0x0013_0x03=0 +hwmon_temp.len_0x0013_0x03=8 +hwmon_temp.bit_offset_0x0013_0x03= +hwmon_temp.str_cons_0x0013_0x03=temp1_max + +hwmon_temp.mode_0x0013_0x04=config +hwmon_temp.int_cons_0x0013_0x04=0 +hwmon_temp.src_0x0013_0x04=file +hwmon_temp.frmt_0x0013_0x04=buf +hwmon_temp.fpath_0x0013_0x04=/sys/bus/i2c/devices/97-0049/hwmon/ +hwmon_temp.addr_0x0013_0x04=0 +hwmon_temp.len_0x0013_0x04=8 +hwmon_temp.bit_offset_0x0013_0x04= +hwmon_temp.str_cons_0x0013_0x04=temp1_max_hyst + + +# sensor temp20 input +hwmon_temp.mode_0x0014_0x00=config +hwmon_temp.int_cons_0x0014_0x00=0 +hwmon_temp.src_0x0014_0x00=file +hwmon_temp.frmt_0x0014_0x00=buf +hwmon_temp.fpath_0x0014_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x0014_0x00=0 +hwmon_temp.len_0x0014_0x00=16 +hwmon_temp.bit_offset_0x0014_0x00= +hwmon_temp.str_cons_0x0014_0x00=temp1_input + +# sensor temp20 alias +hwmon_temp.mode_0x0014_0x01=str_constant +hwmon_temp.str_cons_0x0014_0x01=MAC_DIE_0 + +# sensor temp20 type +hwmon_temp.mode_0x0014_0x02=str_constant +hwmon_temp.str_cons_0x0014_0x02=mac_bsc + + +# sensor temp21 input +hwmon_temp.mode_0x0015_0x00=config +hwmon_temp.int_cons_0x0015_0x00=0 +hwmon_temp.src_0x0015_0x00=file +hwmon_temp.frmt_0x0015_0x00=buf +hwmon_temp.fpath_0x0015_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x0015_0x00=0 +hwmon_temp.len_0x0015_0x00=16 +hwmon_temp.bit_offset_0x0015_0x00= +hwmon_temp.str_cons_0x0015_0x00=temp2_input + +# sensor temp21 alias +hwmon_temp.mode_0x0015_0x01=str_constant +hwmon_temp.str_cons_0x0015_0x01=MAC_DIE_1 + +# sensor temp21 type +hwmon_temp.mode_0x0015_0x02=str_constant +hwmon_temp.str_cons_0x0015_0x02=mac_bsc + + +# sensor temp22 input +hwmon_temp.mode_0x0016_0x00=config +hwmon_temp.int_cons_0x0016_0x00=0 +hwmon_temp.src_0x0016_0x00=file +hwmon_temp.frmt_0x0016_0x00=buf +hwmon_temp.fpath_0x0016_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x0016_0x00=0 +hwmon_temp.len_0x0016_0x00=16 +hwmon_temp.bit_offset_0x0016_0x00= +hwmon_temp.str_cons_0x0016_0x00=temp3_input + +# sensor temp22 alias +hwmon_temp.mode_0x0016_0x01=str_constant +hwmon_temp.str_cons_0x0016_0x01=MAC_DIE_2 + +# sensor temp22 type +hwmon_temp.mode_0x0016_0x02=str_constant +hwmon_temp.str_cons_0x0016_0x02=mac_bsc + + +# sensor temp23 input +hwmon_temp.mode_0x0017_0x00=config +hwmon_temp.int_cons_0x0017_0x00=0 +hwmon_temp.src_0x0017_0x00=file +hwmon_temp.frmt_0x0017_0x00=buf +hwmon_temp.fpath_0x0017_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x0017_0x00=0 +hwmon_temp.len_0x0017_0x00=16 +hwmon_temp.bit_offset_0x0017_0x00= +hwmon_temp.str_cons_0x0017_0x00=temp4_input + +# sensor temp23 alias +hwmon_temp.mode_0x0017_0x01=str_constant +hwmon_temp.str_cons_0x0017_0x01=MAC_DIE_3 + +# sensor temp23 type +hwmon_temp.mode_0x0017_0x02=str_constant +hwmon_temp.str_cons_0x0017_0x02=mac_bsc + + +# sensor temp24 input +hwmon_temp.mode_0x0018_0x00=config +hwmon_temp.int_cons_0x0018_0x00=0 +hwmon_temp.src_0x0018_0x00=file +hwmon_temp.frmt_0x0018_0x00=buf +hwmon_temp.fpath_0x0018_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x0018_0x00=0 +hwmon_temp.len_0x0018_0x00=16 +hwmon_temp.bit_offset_0x0018_0x00= +hwmon_temp.str_cons_0x0018_0x00=temp5_input + +# sensor temp24 alias +hwmon_temp.mode_0x0018_0x01=str_constant +hwmon_temp.str_cons_0x0018_0x01=MAC_DIE_4 + +# sensor temp24 type +hwmon_temp.mode_0x0018_0x02=str_constant +hwmon_temp.str_cons_0x0018_0x02=mac_bsc + + +# sensor temp25 input +hwmon_temp.mode_0x0019_0x00=config +hwmon_temp.int_cons_0x0019_0x00=0 +hwmon_temp.src_0x0019_0x00=file +hwmon_temp.frmt_0x0019_0x00=buf +hwmon_temp.fpath_0x0019_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x0019_0x00=0 +hwmon_temp.len_0x0019_0x00=16 +hwmon_temp.bit_offset_0x0019_0x00= +hwmon_temp.str_cons_0x0019_0x00=temp6_input + +# sensor temp25 alias +hwmon_temp.mode_0x0019_0x01=str_constant +hwmon_temp.str_cons_0x0019_0x01=MAC_DIE_5 + +# sensor temp25 type +hwmon_temp.mode_0x0019_0x02=str_constant +hwmon_temp.str_cons_0x0019_0x02=mac_bsc + + +# sensor temp26 input +hwmon_temp.mode_0x001a_0x00=config +hwmon_temp.int_cons_0x001a_0x00=0 +hwmon_temp.src_0x001a_0x00=file +hwmon_temp.frmt_0x001a_0x00=buf +hwmon_temp.fpath_0x001a_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x001a_0x00=0 +hwmon_temp.len_0x001a_0x00=16 +hwmon_temp.bit_offset_0x001a_0x00= +hwmon_temp.str_cons_0x001a_0x00=temp7_input + +# sensor temp26 alias +hwmon_temp.mode_0x001a_0x01=str_constant +hwmon_temp.str_cons_0x001a_0x01=MAC_DIE_6 + +# sensor temp26 type +hwmon_temp.mode_0x001a_0x02=str_constant +hwmon_temp.str_cons_0x001a_0x02=mac_bsc + + +# sensor temp27 input +hwmon_temp.mode_0x001b_0x00=config +hwmon_temp.int_cons_0x001b_0x00=0 +hwmon_temp.src_0x001b_0x00=file +hwmon_temp.frmt_0x001b_0x00=buf +hwmon_temp.fpath_0x001b_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x001b_0x00=0 +hwmon_temp.len_0x001b_0x00=16 +hwmon_temp.bit_offset_0x001b_0x00= +hwmon_temp.str_cons_0x001b_0x00=temp8_input + +# sensor temp27 alias +hwmon_temp.mode_0x001b_0x01=str_constant +hwmon_temp.str_cons_0x001b_0x01=MAC_DIE_7 + +# sensor temp27 type +hwmon_temp.mode_0x001b_0x02=str_constant +hwmon_temp.str_cons_0x001b_0x02=mac_bsc + + +# sensor temp28 input +hwmon_temp.mode_0x001c_0x00=config +hwmon_temp.int_cons_0x001c_0x00=0 +hwmon_temp.src_0x001c_0x00=file +hwmon_temp.frmt_0x001c_0x00=buf +hwmon_temp.fpath_0x001c_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x001c_0x00=0 +hwmon_temp.len_0x001c_0x00=16 +hwmon_temp.bit_offset_0x001c_0x00= +hwmon_temp.str_cons_0x001c_0x00=temp9_input + +# sensor temp28 alias +hwmon_temp.mode_0x001c_0x01=str_constant +hwmon_temp.str_cons_0x001c_0x01=MAC_DIE_8 + +# sensor temp28 type +hwmon_temp.mode_0x001c_0x02=str_constant +hwmon_temp.str_cons_0x001c_0x02=mac_bsc + + +# sensor temp29 input +hwmon_temp.mode_0x001d_0x00=config +hwmon_temp.int_cons_0x001d_0x00=0 +hwmon_temp.src_0x001d_0x00=file +hwmon_temp.frmt_0x001d_0x00=buf +hwmon_temp.fpath_0x001d_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x001d_0x00=0 +hwmon_temp.len_0x001d_0x00=16 +hwmon_temp.bit_offset_0x001d_0x00= +hwmon_temp.str_cons_0x001d_0x00=temp10_input + +# sensor temp29 alias +hwmon_temp.mode_0x001d_0x01=str_constant +hwmon_temp.str_cons_0x001d_0x01=MAC_DIE_9 + +# sensor temp29 type +hwmon_temp.mode_0x001d_0x02=str_constant +hwmon_temp.str_cons_0x001d_0x02=mac_bsc + + +# sensor temp30 input +hwmon_temp.mode_0x001e_0x00=config +hwmon_temp.int_cons_0x001e_0x00=0 +hwmon_temp.src_0x001e_0x00=file +hwmon_temp.frmt_0x001e_0x00=buf +hwmon_temp.fpath_0x001e_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x001e_0x00=0 +hwmon_temp.len_0x001e_0x00=16 +hwmon_temp.bit_offset_0x001e_0x00= +hwmon_temp.str_cons_0x001e_0x00=temp11_input + +# sensor temp30 alias +hwmon_temp.mode_0x001e_0x01=str_constant +hwmon_temp.str_cons_0x001e_0x01=MAC_DIE_10 + +# sensor temp30 type +hwmon_temp.mode_0x001e_0x02=str_constant +hwmon_temp.str_cons_0x001e_0x02=mac_bsc + + +# sensor temp31 input +hwmon_temp.mode_0x001f_0x00=config +hwmon_temp.int_cons_0x001f_0x00=0 +hwmon_temp.src_0x001f_0x00=file +hwmon_temp.frmt_0x001f_0x00=buf +hwmon_temp.fpath_0x001f_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x001f_0x00=0 +hwmon_temp.len_0x001f_0x00=16 +hwmon_temp.bit_offset_0x001f_0x00= +hwmon_temp.str_cons_0x001f_0x00=temp12_input + +# sensor temp31 alias +hwmon_temp.mode_0x001f_0x01=str_constant +hwmon_temp.str_cons_0x001f_0x01=MAC_DIE_11 + +# sensor temp31 type +hwmon_temp.mode_0x001f_0x02=str_constant +hwmon_temp.str_cons_0x001f_0x02=mac_bsc + + +# sensor temp32 input +hwmon_temp.mode_0x0020_0x00=config +hwmon_temp.int_cons_0x0020_0x00=0 +hwmon_temp.src_0x0020_0x00=file +hwmon_temp.frmt_0x0020_0x00=buf +hwmon_temp.fpath_0x0020_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x0020_0x00=0 +hwmon_temp.len_0x0020_0x00=16 +hwmon_temp.bit_offset_0x0020_0x00= +hwmon_temp.str_cons_0x0020_0x00=temp13_input + +# sensor temp32 alias +hwmon_temp.mode_0x0020_0x01=str_constant +hwmon_temp.str_cons_0x0020_0x01=MAC_DIE_12 + +# sensor temp32 type +hwmon_temp.mode_0x0020_0x02=str_constant +hwmon_temp.str_cons_0x0020_0x02=mac_bsc + + +# sensor temp33 input +hwmon_temp.mode_0x0021_0x00=config +hwmon_temp.int_cons_0x0021_0x00=0 +hwmon_temp.src_0x0021_0x00=file +hwmon_temp.frmt_0x0021_0x00=buf +hwmon_temp.fpath_0x0021_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x0021_0x00=0 +hwmon_temp.len_0x0021_0x00=16 +hwmon_temp.bit_offset_0x0021_0x00= +hwmon_temp.str_cons_0x0021_0x00=temp14_input + +# sensor temp33 alias +hwmon_temp.mode_0x0021_0x01=str_constant +hwmon_temp.str_cons_0x0021_0x01=MAC_DIE_13 + +# sensor temp33 type +hwmon_temp.mode_0x0021_0x02=str_constant +hwmon_temp.str_cons_0x0021_0x02=mac_bsc + + +# sensor temp34 input +hwmon_temp.mode_0x0022_0x00=config +hwmon_temp.int_cons_0x0022_0x00=0 +hwmon_temp.src_0x0022_0x00=file +hwmon_temp.frmt_0x0022_0x00=buf +hwmon_temp.fpath_0x0022_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x0022_0x00=0 +hwmon_temp.len_0x0022_0x00=16 +hwmon_temp.bit_offset_0x0022_0x00= +hwmon_temp.str_cons_0x0022_0x00=temp15_input + +# sensor temp34 alias +hwmon_temp.mode_0x0022_0x01=str_constant +hwmon_temp.str_cons_0x0022_0x01=MAC_DIE_14 + +# sensor temp34 type +hwmon_temp.mode_0x0022_0x02=str_constant +hwmon_temp.str_cons_0x0022_0x02=mac_bsc + + +# sensor vol +hwmon_in.mode_0x0001_0x00=config +hwmon_in.int_cons_0x0001_0x00=0 +hwmon_in.src_0x0001_0x00=file +hwmon_in.frmt_0x0001_0x00=buf +hwmon_in.fpath_0x0001_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0001_0x00=0 +hwmon_in.len_0x0001_0x00=8 +hwmon_in.bit_offset_0x0001_0x00= +hwmon_in.str_cons_0x0001_0x00=in1_input + +hwmon_in.mode_0x0001_0x01=str_constant +hwmon_in.str_cons_0x0001_0x01=MAC_VDD_ANALOG1 + +hwmon_in.mode_0x0001_0x02=str_constant +hwmon_in.str_cons_0x0001_0x02=ucd90160 + +hwmon_in.mode_0x0001_0x03=constant +hwmon_in.int_cons_0x0001_0x03=809 + +hwmon_in.mode_0x0001_0x05=constant +hwmon_in.int_cons_0x0001_0x05=731 + +hwmon_in.mode_0x0002_0x00=config +hwmon_in.int_cons_0x0002_0x00=0 +hwmon_in.src_0x0002_0x00=file +hwmon_in.frmt_0x0002_0x00=buf +hwmon_in.fpath_0x0002_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0002_0x00=0 +hwmon_in.len_0x0002_0x00=8 +hwmon_in.bit_offset_0x0002_0x00= +hwmon_in.str_cons_0x0002_0x00=in2_input + +hwmon_in.mode_0x0002_0x01=str_constant +hwmon_in.str_cons_0x0002_0x01=MAC_VDD12V + +hwmon_in.mode_0x0002_0x02=str_constant +hwmon_in.str_cons_0x0002_0x02=ucd90160 + +hwmon_in.mode_0x0002_0x03=constant +hwmon_in.int_cons_0x0002_0x03=12600 + +hwmon_in.mode_0x0002_0x05=constant +hwmon_in.int_cons_0x0002_0x05=11400 + +hwmon_in.mode_0x0003_0x00=config +hwmon_in.int_cons_0x0003_0x00=0 +hwmon_in.src_0x0003_0x00=file +hwmon_in.frmt_0x0003_0x00=buf +hwmon_in.fpath_0x0003_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0003_0x00=0 +hwmon_in.len_0x0003_0x00=8 +hwmon_in.bit_offset_0x0003_0x00= +hwmon_in.str_cons_0x0003_0x00=in3_input + +hwmon_in.mode_0x0003_0x01=str_constant +hwmon_in.str_cons_0x0003_0x01=MAC_VDD1.0V_FPGA + +hwmon_in.mode_0x0003_0x02=str_constant +hwmon_in.str_cons_0x0003_0x02=ucd90160 + +hwmon_in.mode_0x0003_0x03=constant +hwmon_in.int_cons_0x0003_0x03=1071 + +hwmon_in.mode_0x0003_0x05=constant +hwmon_in.int_cons_0x0003_0x05=969 + +hwmon_in.mode_0x0004_0x00=config +hwmon_in.int_cons_0x0004_0x00=0 +hwmon_in.src_0x0004_0x00=file +hwmon_in.frmt_0x0004_0x00=buf +hwmon_in.fpath_0x0004_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0004_0x00=0 +hwmon_in.len_0x0004_0x00=8 +hwmon_in.bit_offset_0x0004_0x00= +hwmon_in.str_cons_0x0004_0x00=in4_input + +hwmon_in.mode_0x0004_0x01=str_constant +hwmon_in.str_cons_0x0004_0x01=MAC_VDD1.8V_FPGA + +hwmon_in.mode_0x0004_0x02=str_constant +hwmon_in.str_cons_0x0004_0x02=ucd90160 + +hwmon_in.mode_0x0004_0x03=constant +hwmon_in.int_cons_0x0004_0x03=1890 + +hwmon_in.mode_0x0004_0x05=constant +hwmon_in.int_cons_0x0004_0x05=1710 + +hwmon_in.mode_0x0005_0x00=config +hwmon_in.int_cons_0x0005_0x00=0 +hwmon_in.src_0x0005_0x00=file +hwmon_in.frmt_0x0005_0x00=buf +hwmon_in.fpath_0x0005_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0005_0x00=0 +hwmon_in.len_0x0005_0x00=8 +hwmon_in.bit_offset_0x0005_0x00= +hwmon_in.str_cons_0x0005_0x00=in5_input + +hwmon_in.mode_0x0005_0x01=str_constant +hwmon_in.str_cons_0x0005_0x01=MAC_VDD1.2V_FPGA + +hwmon_in.mode_0x0005_0x02=str_constant +hwmon_in.str_cons_0x0005_0x02=ucd90160 + +hwmon_in.mode_0x0005_0x03=constant +hwmon_in.int_cons_0x0005_0x03=1260 + +hwmon_in.mode_0x0005_0x05=constant +hwmon_in.int_cons_0x0005_0x05=1140 + +hwmon_in.mode_0x0006_0x00=config +hwmon_in.int_cons_0x0006_0x00=0 +hwmon_in.src_0x0006_0x00=file +hwmon_in.frmt_0x0006_0x00=buf +hwmon_in.fpath_0x0006_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0006_0x00=0 +hwmon_in.len_0x0006_0x00=8 +hwmon_in.bit_offset_0x0006_0x00= +hwmon_in.str_cons_0x0006_0x00=in6_input + +hwmon_in.mode_0x0006_0x01=str_constant +hwmon_in.str_cons_0x0006_0x01=MAC_VDD3.3V + +hwmon_in.mode_0x0006_0x02=str_constant +hwmon_in.str_cons_0x0006_0x02=ucd90160 + +hwmon_in.mode_0x0006_0x03=constant +hwmon_in.int_cons_0x0006_0x03=3465 + +hwmon_in.mode_0x0006_0x05=constant +hwmon_in.int_cons_0x0006_0x05=3135 + +hwmon_in.mode_0x0007_0x00=config +hwmon_in.int_cons_0x0007_0x00=0 +hwmon_in.src_0x0007_0x00=file +hwmon_in.frmt_0x0007_0x00=buf +hwmon_in.fpath_0x0007_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0007_0x00=0 +hwmon_in.len_0x0007_0x00=8 +hwmon_in.bit_offset_0x0007_0x00= +hwmon_in.str_cons_0x0007_0x00=in7_input + +hwmon_in.mode_0x0007_0x01=str_constant +hwmon_in.str_cons_0x0007_0x01=MAC_SW_VDD1.2V + +hwmon_in.mode_0x0007_0x02=str_constant +hwmon_in.str_cons_0x0007_0x02=ucd90160 + +hwmon_in.mode_0x0007_0x03=constant +hwmon_in.int_cons_0x0007_0x03=1260 + +hwmon_in.mode_0x0007_0x05=constant +hwmon_in.int_cons_0x0007_0x05=1140 + +hwmon_in.mode_0x0008_0x00=config +hwmon_in.int_cons_0x0008_0x00=0 +hwmon_in.src_0x0008_0x00=file +hwmon_in.frmt_0x0008_0x00=buf +hwmon_in.fpath_0x0008_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0008_0x00=0 +hwmon_in.len_0x0008_0x00=8 +hwmon_in.bit_offset_0x0008_0x00= +hwmon_in.str_cons_0x0008_0x00=in8_input + +hwmon_in.mode_0x0008_0x01=str_constant +hwmon_in.str_cons_0x0008_0x01=MAC_VDD5V_CLK_MCU + +hwmon_in.mode_0x0008_0x02=str_constant +hwmon_in.str_cons_0x0008_0x02=ucd90160 + +hwmon_in.mode_0x0008_0x03=constant +hwmon_in.int_cons_0x0008_0x03=5334 + +hwmon_in.mode_0x0008_0x05=constant +hwmon_in.int_cons_0x0008_0x05=4826 + +hwmon_in.mode_0x0009_0x00=config +hwmon_in.int_cons_0x0009_0x00=0 +hwmon_in.src_0x0009_0x00=file +hwmon_in.frmt_0x0009_0x00=buf +hwmon_in.fpath_0x0009_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0009_0x00=0 +hwmon_in.len_0x0009_0x00=8 +hwmon_in.bit_offset_0x0009_0x00= +hwmon_in.str_cons_0x0009_0x00=in9_input + +hwmon_in.mode_0x0009_0x01=str_constant +hwmon_in.str_cons_0x0009_0x01=MAC_VDD5V_VR + +hwmon_in.mode_0x0009_0x02=str_constant +hwmon_in.str_cons_0x0009_0x02=ucd90160 + +hwmon_in.mode_0x0009_0x03=constant +hwmon_in.int_cons_0x0009_0x03=5334 + +hwmon_in.mode_0x0009_0x05=constant +hwmon_in.int_cons_0x0009_0x05=4826 + +hwmon_in.mode_0x000a_0x00=config +hwmon_in.int_cons_0x000a_0x00=0 +hwmon_in.src_0x000a_0x00=file +hwmon_in.frmt_0x000a_0x00=buf +hwmon_in.fpath_0x000a_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x000a_0x00=0 +hwmon_in.len_0x000a_0x00=8 +hwmon_in.bit_offset_0x000a_0x00= +hwmon_in.str_cons_0x000a_0x00=in10_input + +hwmon_in.mode_0x000a_0x01=str_constant +hwmon_in.str_cons_0x000a_0x01=MAC_VDD3.3_CLK + +hwmon_in.mode_0x000a_0x02=str_constant +hwmon_in.str_cons_0x000a_0x02=ucd90160 + +hwmon_in.mode_0x000a_0x03=constant +hwmon_in.int_cons_0x000a_0x03=3486 + +hwmon_in.mode_0x000a_0x05=constant +hwmon_in.int_cons_0x000a_0x05=3154 + +hwmon_in.mode_0x000b_0x00=config +hwmon_in.int_cons_0x000b_0x00=0 +hwmon_in.src_0x000b_0x00=file +hwmon_in.frmt_0x000b_0x00=buf +hwmon_in.fpath_0x000b_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x000b_0x00=0 +hwmon_in.len_0x000b_0x00=8 +hwmon_in.bit_offset_0x000b_0x00= +hwmon_in.str_cons_0x000b_0x00=in11_input + +hwmon_in.mode_0x000b_0x01=str_constant +hwmon_in.str_cons_0x000b_0x01=MAC_VDDO1.8V + +hwmon_in.mode_0x000b_0x02=str_constant +hwmon_in.str_cons_0x000b_0x02=ucd90160 + +hwmon_in.mode_0x000b_0x03=constant +hwmon_in.int_cons_0x000b_0x03=1901 + +hwmon_in.mode_0x000b_0x05=constant +hwmon_in.int_cons_0x000b_0x05=1719 + +hwmon_in.mode_0x000c_0x00=config +hwmon_in.int_cons_0x000c_0x00=0 +hwmon_in.src_0x000c_0x00=file +hwmon_in.frmt_0x000c_0x00=buf +hwmon_in.fpath_0x000c_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x000c_0x00=0 +hwmon_in.len_0x000c_0x00=8 +hwmon_in.bit_offset_0x000c_0x00= +hwmon_in.str_cons_0x000c_0x00=in12_input + +hwmon_in.mode_0x000c_0x01=str_constant +hwmon_in.str_cons_0x000c_0x01=MAC_VDDO1.2V + +hwmon_in.mode_0x000c_0x02=str_constant +hwmon_in.str_cons_0x000c_0x02=ucd90160 + +hwmon_in.mode_0x000c_0x03=constant +hwmon_in.int_cons_0x000c_0x03=1260 + +hwmon_in.mode_0x000c_0x05=constant +hwmon_in.int_cons_0x000c_0x05=1140 + +hwmon_in.mode_0x000d_0x00=config +hwmon_in.int_cons_0x000d_0x00=0 +hwmon_in.src_0x000d_0x00=file +hwmon_in.frmt_0x000d_0x00=buf +hwmon_in.fpath_0x000d_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x000d_0x00=0 +hwmon_in.len_0x000d_0x00=8 +hwmon_in.bit_offset_0x000d_0x00= +hwmon_in.str_cons_0x000d_0x00=in13_input + +hwmon_in.mode_0x000d_0x01=str_constant +hwmon_in.str_cons_0x000d_0x01=MAC_VDD_CORE + +hwmon_in.mode_0x000d_0x02=str_constant +hwmon_in.str_cons_0x000d_0x02=ucd90160 + +hwmon_in.mode_0x000d_0x03=constant +hwmon_in.int_cons_0x000d_0x03=950 + +hwmon_in.mode_0x000d_0x05=constant +hwmon_in.int_cons_0x000d_0x05=700 + +hwmon_in.mode_0x000e_0x00=config +hwmon_in.int_cons_0x000e_0x00=0 +hwmon_in.src_0x000e_0x00=file +hwmon_in.frmt_0x000e_0x00=buf +hwmon_in.fpath_0x000e_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x000e_0x00=0 +hwmon_in.len_0x000e_0x00=8 +hwmon_in.bit_offset_0x000e_0x00= +hwmon_in.str_cons_0x000e_0x00=in14_input + +hwmon_in.mode_0x000e_0x01=str_constant +hwmon_in.str_cons_0x000e_0x01=MAC_VDD_ANALOG + +hwmon_in.mode_0x000e_0x02=str_constant +hwmon_in.str_cons_0x000e_0x02=ucd90160 + +hwmon_in.mode_0x000e_0x03=constant +hwmon_in.int_cons_0x000e_0x03=809 + +hwmon_in.mode_0x000e_0x05=constant +hwmon_in.int_cons_0x000e_0x05=731 + +hwmon_in.mode_0x000f_0x00=config +hwmon_in.int_cons_0x000f_0x00=0 +hwmon_in.src_0x000f_0x00=file +hwmon_in.frmt_0x000f_0x00=buf +hwmon_in.fpath_0x000f_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x000f_0x00=0 +hwmon_in.len_0x000f_0x00=8 +hwmon_in.bit_offset_0x000f_0x00= +hwmon_in.str_cons_0x000f_0x00=in15_input + +hwmon_in.mode_0x000f_0x01=str_constant +hwmon_in.str_cons_0x000f_0x01=MAC_VDD1.2V_MAC + +hwmon_in.mode_0x000f_0x02=str_constant +hwmon_in.str_cons_0x000f_0x02=ucd90160 + +hwmon_in.mode_0x000f_0x03=constant +hwmon_in.int_cons_0x000f_0x03=1260 + +hwmon_in.mode_0x000f_0x05=constant +hwmon_in.int_cons_0x000f_0x05=1140 + +hwmon_in.mode_0x0010_0x00=config +hwmon_in.int_cons_0x0010_0x00=0 +hwmon_in.src_0x0010_0x00=file +hwmon_in.frmt_0x0010_0x00=buf +hwmon_in.fpath_0x0010_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0010_0x00=0 +hwmon_in.len_0x0010_0x00=8 +hwmon_in.bit_offset_0x0010_0x00= +hwmon_in.str_cons_0x0010_0x00=in16_input + +hwmon_in.mode_0x0010_0x01=str_constant +hwmon_in.str_cons_0x0010_0x01=MAC_AVDD1.8V + +hwmon_in.mode_0x0010_0x02=str_constant +hwmon_in.str_cons_0x0010_0x02=ucd90160 + +hwmon_in.mode_0x0010_0x03=constant +hwmon_in.int_cons_0x0010_0x03=1890 + +hwmon_in.mode_0x0010_0x05=constant +hwmon_in.int_cons_0x0010_0x05=1710 + +hwmon_in.mode_0x0011_0x00=config +hwmon_in.int_cons_0x0011_0x00=0 +hwmon_in.src_0x0011_0x00=file +hwmon_in.frmt_0x0011_0x00=buf +hwmon_in.fpath_0x0011_0x00=/sys/bus/i2c/devices/105-005b/hwmon/ +hwmon_in.addr_0x0011_0x00=0 +hwmon_in.len_0x0011_0x00=8 +hwmon_in.bit_offset_0x0011_0x00= +hwmon_in.str_cons_0x0011_0x00=in1_input + +hwmon_in.mode_0x0011_0x01=str_constant +hwmon_in.str_cons_0x0011_0x01=BASE_VDD12V + +hwmon_in.mode_0x0011_0x02=str_constant +hwmon_in.str_cons_0x0011_0x02=ucd90160 + +hwmon_in.mode_0x0011_0x03=constant +hwmon_in.int_cons_0x0011_0x03=12600 + +hwmon_in.mode_0x0011_0x05=constant +hwmon_in.int_cons_0x0011_0x05=11400 + +hwmon_in.mode_0x0012_0x00=config +hwmon_in.int_cons_0x0012_0x00=0 +hwmon_in.src_0x0012_0x00=file +hwmon_in.frmt_0x0012_0x00=buf +hwmon_in.fpath_0x0012_0x00=/sys/bus/i2c/devices/105-005b/hwmon/ +hwmon_in.addr_0x0012_0x00=0 +hwmon_in.len_0x0012_0x00=8 +hwmon_in.bit_offset_0x0012_0x00= +hwmon_in.str_cons_0x0012_0x00=in2_input + +hwmon_in.mode_0x0012_0x01=str_constant +hwmon_in.str_cons_0x0012_0x01=BASE_SW_VDD1.2V + +hwmon_in.mode_0x0012_0x02=str_constant +hwmon_in.str_cons_0x0012_0x02=ucd90160 + +hwmon_in.mode_0x0012_0x03=constant +hwmon_in.int_cons_0x0012_0x03=1260 + +hwmon_in.mode_0x0012_0x05=constant +hwmon_in.int_cons_0x0012_0x05=1140 + +hwmon_in.mode_0x0013_0x00=config +hwmon_in.int_cons_0x0013_0x00=0 +hwmon_in.src_0x0013_0x00=file +hwmon_in.frmt_0x0013_0x00=buf +hwmon_in.fpath_0x0013_0x00=/sys/bus/i2c/devices/105-005b/hwmon/ +hwmon_in.addr_0x0013_0x00=0 +hwmon_in.len_0x0013_0x00=8 +hwmon_in.bit_offset_0x0013_0x00= +hwmon_in.str_cons_0x0013_0x00=in3_input + +hwmon_in.mode_0x0013_0x01=str_constant +hwmon_in.str_cons_0x0013_0x01=BASE_VDD2.5V + +hwmon_in.mode_0x0013_0x02=str_constant +hwmon_in.str_cons_0x0013_0x02=ucd90160 + +hwmon_in.mode_0x0013_0x03=constant +hwmon_in.int_cons_0x0013_0x03=2615 + +hwmon_in.mode_0x0013_0x05=constant +hwmon_in.int_cons_0x0013_0x05=2365 + +hwmon_in.mode_0x0014_0x00=config +hwmon_in.int_cons_0x0014_0x00=0 +hwmon_in.src_0x0014_0x00=file +hwmon_in.frmt_0x0014_0x00=buf +hwmon_in.fpath_0x0014_0x00=/sys/bus/i2c/devices/105-005b/hwmon/ +hwmon_in.addr_0x0014_0x00=0 +hwmon_in.len_0x0014_0x00=8 +hwmon_in.bit_offset_0x0014_0x00= +hwmon_in.str_cons_0x0014_0x00=in4_input + +hwmon_in.mode_0x0014_0x01=str_constant +hwmon_in.str_cons_0x0014_0x01=BASE_VDD3.3V + +hwmon_in.mode_0x0014_0x02=str_constant +hwmon_in.str_cons_0x0014_0x02=ucd90160 + +hwmon_in.mode_0x0014_0x03=constant +hwmon_in.int_cons_0x0014_0x03=3444 + +hwmon_in.mode_0x0014_0x05=constant +hwmon_in.int_cons_0x0014_0x05=3116 + +hwmon_in.mode_0x0015_0x00=config +hwmon_in.int_cons_0x0015_0x00=0 +hwmon_in.src_0x0015_0x00=file +hwmon_in.frmt_0x0015_0x00=buf +hwmon_in.fpath_0x0015_0x00=/sys/bus/i2c/devices/105-005b/hwmon/ +hwmon_in.addr_0x0015_0x00=0 +hwmon_in.len_0x0015_0x00=8 +hwmon_in.bit_offset_0x0015_0x00= +hwmon_in.str_cons_0x0015_0x00=in5_input + +hwmon_in.mode_0x0015_0x01=str_constant +hwmon_in.str_cons_0x0015_0x01=BASE_SSD_VDD3.3V + +hwmon_in.mode_0x0015_0x02=str_constant +hwmon_in.str_cons_0x0015_0x02=ucd90160 + +hwmon_in.mode_0x0015_0x03=constant +hwmon_in.int_cons_0x0015_0x03=3465 + +hwmon_in.mode_0x0015_0x05=constant +hwmon_in.int_cons_0x0015_0x05=3135 + +hwmon_in.mode_0x0016_0x00=config +hwmon_in.int_cons_0x0016_0x00=0 +hwmon_in.src_0x0016_0x00=file +hwmon_in.frmt_0x0016_0x00=buf +hwmon_in.fpath_0x0016_0x00=/sys/bus/i2c/devices/106-0060/hwmon/ +hwmon_in.addr_0x0016_0x00=0 +hwmon_in.len_0x0016_0x00=8 +hwmon_in.bit_offset_0x0016_0x00= +hwmon_in.str_cons_0x0016_0x00=in3_input + +hwmon_in.mode_0x0016_0x01=str_constant +hwmon_in.str_cons_0x0016_0x01=CPU_VCCIN + +hwmon_in.mode_0x0016_0x02=str_constant +hwmon_in.str_cons_0x0016_0x02=tps53622 + +hwmon_in.mode_0x0016_0x03=constant +hwmon_in.int_cons_0x0016_0x03=1950 + +hwmon_in.mode_0x0016_0x05=constant +hwmon_in.int_cons_0x0016_0x05=1600 + +hwmon_in.mode_0x0017_0x00=config +hwmon_in.int_cons_0x0017_0x00=0 +hwmon_in.src_0x0017_0x00=file +hwmon_in.frmt_0x0017_0x00=buf +hwmon_in.fpath_0x0017_0x00=/sys/bus/i2c/devices/106-0060/hwmon/ +hwmon_in.addr_0x0017_0x00=0 +hwmon_in.len_0x0017_0x00=8 +hwmon_in.bit_offset_0x0017_0x00= +hwmon_in.str_cons_0x0017_0x00=in4_input + +hwmon_in.mode_0x0017_0x01=str_constant +hwmon_in.str_cons_0x0017_0x01=CPU_P1V05 + +hwmon_in.mode_0x0017_0x02=str_constant +hwmon_in.str_cons_0x0017_0x02=tps53622 + +hwmon_in.mode_0x0017_0x03=constant +hwmon_in.int_cons_0x0017_0x03=1100 + +hwmon_in.mode_0x0017_0x05=constant +hwmon_in.int_cons_0x0017_0x05=1000 + +hwmon_in.mode_0x0018_0x00=config +hwmon_in.int_cons_0x0018_0x00=0 +hwmon_in.src_0x0018_0x00=file +hwmon_in.frmt_0x0018_0x00=buf +hwmon_in.fpath_0x0018_0x00=/sys/bus/i2c/devices/106-006c/hwmon/ +hwmon_in.addr_0x0018_0x00=0 +hwmon_in.len_0x0018_0x00=8 +hwmon_in.bit_offset_0x0018_0x00= +hwmon_in.str_cons_0x0018_0x00=in3_input + +hwmon_in.mode_0x0018_0x01=str_constant +hwmon_in.str_cons_0x0018_0x01=CPU_P1V2_VDDQ + +hwmon_in.mode_0x0018_0x02=str_constant +hwmon_in.str_cons_0x0018_0x02=tps53622 + +hwmon_in.mode_0x0018_0x03=constant +hwmon_in.int_cons_0x0018_0x03=1260 + +hwmon_in.mode_0x0018_0x05=constant +hwmon_in.int_cons_0x0018_0x05=1160 + +hwmon_in.mode_0x0019_0x00=config +hwmon_in.int_cons_0x0019_0x00=3 +hwmon_in.src_0x0019_0x00=file +hwmon_in.frmt_0x0019_0x00=buf +hwmon_in.fpath_0x0019_0x00=/sys/bus/i2c/devices/106-006c/hwmon/ +hwmon_in.addr_0x0019_0x00=0 +hwmon_in.len_0x0019_0x00=8 +hwmon_in.bit_offset_0x0019_0x00=0 +hwmon_in.str_cons_0x0019_0x00=in4_input +hwmon_in.int_extra1_0x0019_0x00=1124 + +hwmon_in.mode_0x0019_0x01=str_constant +hwmon_in.str_cons_0x0019_0x01=CPU_P2V5_VPP + +hwmon_in.mode_0x0019_0x02=str_constant +hwmon_in.str_cons_0x0019_0x02=tps53622 + +hwmon_in.mode_0x0019_0x03=constant +hwmon_in.int_cons_0x0019_0x03=2750 + +hwmon_in.mode_0x0019_0x05=constant +hwmon_in.int_cons_0x0019_0x05=2375 + +hwmon_in.mode_0x001a_0x00=config +hwmon_in.int_cons_0x001a_0x00=0 +hwmon_in.src_0x001a_0x00=file +hwmon_in.frmt_0x001a_0x00=buf +hwmon_in.fpath_0x001a_0x00=/sys/bus/i2c/devices/106-0043/hwmon/ +hwmon_in.addr_0x001a_0x00=0 +hwmon_in.len_0x001a_0x00=8 +hwmon_in.bit_offset_0x001a_0x00= +hwmon_in.str_cons_0x001a_0x00=in1_input + +hwmon_in.mode_0x001a_0x01=str_constant +hwmon_in.str_cons_0x001a_0x01=CPU_P3V3_STBY + +hwmon_in.mode_0x001a_0x02=str_constant +hwmon_in.str_cons_0x001a_0x02=ina3221 + +hwmon_in.mode_0x001a_0x03=constant +hwmon_in.int_cons_0x001a_0x03=3465 + +hwmon_in.mode_0x001a_0x05=constant +hwmon_in.int_cons_0x001a_0x05=3135 + +hwmon_in.mode_0x001b_0x00=config +hwmon_in.int_cons_0x001b_0x00=0 +hwmon_in.src_0x001b_0x00=file +hwmon_in.frmt_0x001b_0x00=buf +hwmon_in.fpath_0x001b_0x00=/sys/bus/i2c/devices/106-0043/hwmon/ +hwmon_in.addr_0x001b_0x00=0 +hwmon_in.len_0x001b_0x00=8 +hwmon_in.bit_offset_0x001b_0x00= +hwmon_in.str_cons_0x001b_0x00=in2_input + +hwmon_in.mode_0x001b_0x01=str_constant +hwmon_in.str_cons_0x001b_0x01=CPU_P5V_AUX_IN + +hwmon_in.mode_0x001b_0x02=str_constant +hwmon_in.str_cons_0x001b_0x02=ina3221 + +hwmon_in.mode_0x001b_0x03=constant +hwmon_in.int_cons_0x001b_0x03=5500 + +hwmon_in.mode_0x001b_0x05=constant +hwmon_in.int_cons_0x001b_0x05=4250 + +hwmon_in.mode_0x001c_0x00=config +hwmon_in.int_cons_0x001c_0x00=0 +hwmon_in.src_0x001c_0x00=file +hwmon_in.frmt_0x001c_0x00=buf +hwmon_in.fpath_0x001c_0x00=/sys/bus/i2c/devices/106-0043/hwmon/ +hwmon_in.addr_0x001c_0x00=0 +hwmon_in.len_0x001c_0x00=8 +hwmon_in.bit_offset_0x001c_0x00= +hwmon_in.str_cons_0x001c_0x00=in3_input + +hwmon_in.mode_0x001c_0x01=str_constant +hwmon_in.str_cons_0x001c_0x01=CPU_P1V7_VCCSCFUSESUS_IN + +hwmon_in.mode_0x001c_0x02=str_constant +hwmon_in.str_cons_0x001c_0x02=ina3221 + +hwmon_in.mode_0x001c_0x03=constant +hwmon_in.int_cons_0x001c_0x03=1785 + +hwmon_in.mode_0x001c_0x05=constant +hwmon_in.int_cons_0x001c_0x05=1615 + +hwmon_in.mode_0x001d_0x00=config +hwmon_in.int_cons_0x001d_0x00=0 +hwmon_in.src_0x001d_0x00=file +hwmon_in.frmt_0x001d_0x00=buf +hwmon_in.fpath_0x001d_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x001d_0x00=0 +hwmon_in.len_0x001d_0x00=8 +hwmon_in.bit_offset_0x001d_0x00= +hwmon_in.str_cons_0x001d_0x00=in1_input + +hwmon_in.mode_0x001d_0x01=str_constant +hwmon_in.str_cons_0x001d_0x01=UPORT_VDD1.0V_FPGA + +hwmon_in.mode_0x001d_0x02=str_constant +hwmon_in.str_cons_0x001d_0x02=ucd90160 + +hwmon_in.mode_0x001d_0x03=constant +hwmon_in.int_cons_0x001d_0x03=1061 + +hwmon_in.mode_0x001d_0x05=constant +hwmon_in.int_cons_0x001d_0x05=959 + +hwmon_in.mode_0x001e_0x00=config +hwmon_in.int_cons_0x001e_0x00=0 +hwmon_in.src_0x001e_0x00=file +hwmon_in.frmt_0x001e_0x00=buf +hwmon_in.fpath_0x001e_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x001e_0x00=0 +hwmon_in.len_0x001e_0x00=8 +hwmon_in.bit_offset_0x001e_0x00= +hwmon_in.str_cons_0x001e_0x00=in2_input + +hwmon_in.mode_0x001e_0x01=str_constant +hwmon_in.str_cons_0x001e_0x01=UPORT_VDD1.8V_FPGA + +hwmon_in.mode_0x001e_0x02=str_constant +hwmon_in.str_cons_0x001e_0x02=ucd90160 + +hwmon_in.mode_0x001e_0x03=constant +hwmon_in.int_cons_0x001e_0x03=1901 + +hwmon_in.mode_0x001e_0x05=constant +hwmon_in.int_cons_0x001e_0x05=1719 + +hwmon_in.mode_0x001f_0x00=config +hwmon_in.int_cons_0x001f_0x00=0 +hwmon_in.src_0x001f_0x00=file +hwmon_in.frmt_0x001f_0x00=buf +hwmon_in.fpath_0x001f_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x001f_0x00=0 +hwmon_in.len_0x001f_0x00=8 +hwmon_in.bit_offset_0x001f_0x00= +hwmon_in.str_cons_0x001f_0x00=in3_input + +hwmon_in.mode_0x001f_0x01=str_constant +hwmon_in.str_cons_0x001f_0x01=UPORT_VDD1.2V_FPGA + +hwmon_in.mode_0x001f_0x02=str_constant +hwmon_in.str_cons_0x001f_0x02=ucd90160 + +hwmon_in.mode_0x001f_0x03=constant +hwmon_in.int_cons_0x001f_0x03=1260 + +hwmon_in.mode_0x001f_0x05=constant +hwmon_in.int_cons_0x001f_0x05=1140 + +hwmon_in.mode_0x0020_0x00=config +hwmon_in.int_cons_0x0020_0x00=0 +hwmon_in.src_0x0020_0x00=file +hwmon_in.frmt_0x0020_0x00=buf +hwmon_in.fpath_0x0020_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x0020_0x00=0 +hwmon_in.len_0x0020_0x00=8 +hwmon_in.bit_offset_0x0020_0x00= +hwmon_in.str_cons_0x0020_0x00=in4_input + +hwmon_in.mode_0x0020_0x01=str_constant +hwmon_in.str_cons_0x0020_0x01=UPORT_VDD3.3V + +hwmon_in.mode_0x0020_0x02=str_constant +hwmon_in.str_cons_0x0020_0x02=ucd90160 + +hwmon_in.mode_0x0020_0x03=constant +hwmon_in.int_cons_0x0020_0x03=3600 + +hwmon_in.mode_0x0020_0x05=constant +hwmon_in.int_cons_0x0020_0x05=3200 + +hwmon_in.mode_0x0021_0x00=config +hwmon_in.int_cons_0x0021_0x00=0 +hwmon_in.src_0x0021_0x00=file +hwmon_in.frmt_0x0021_0x00=buf +hwmon_in.fpath_0x0021_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x0021_0x00=0 +hwmon_in.len_0x0021_0x00=8 +hwmon_in.bit_offset_0x0021_0x00= +hwmon_in.str_cons_0x0021_0x00=in5_input + +hwmon_in.mode_0x0021_0x01=str_constant +hwmon_in.str_cons_0x0021_0x01=UPORT_QSFP56_VDD3.3V_A + +hwmon_in.mode_0x0021_0x02=str_constant +hwmon_in.str_cons_0x0021_0x02=ucd90160 + +hwmon_in.mode_0x0021_0x03=constant +hwmon_in.int_cons_0x0021_0x03=3600 + +hwmon_in.mode_0x0021_0x05=constant +hwmon_in.int_cons_0x0021_0x05=3200 + +hwmon_in.mode_0x0022_0x00=config +hwmon_in.int_cons_0x0022_0x00=0 +hwmon_in.src_0x0022_0x00=file +hwmon_in.frmt_0x0022_0x00=buf +hwmon_in.fpath_0x0022_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x0022_0x00=0 +hwmon_in.len_0x0022_0x00=8 +hwmon_in.bit_offset_0x0022_0x00= +hwmon_in.str_cons_0x0022_0x00=in6_input + +hwmon_in.mode_0x0022_0x01=str_constant +hwmon_in.str_cons_0x0022_0x01=UPORT_QSFP56_VDD3.3V_B + +hwmon_in.mode_0x0022_0x02=str_constant +hwmon_in.str_cons_0x0022_0x02=ucd90160 + +hwmon_in.mode_0x0022_0x03=constant +hwmon_in.int_cons_0x0022_0x03=3600 + +hwmon_in.mode_0x0022_0x05=constant +hwmon_in.int_cons_0x0022_0x05=3200 + +hwmon_in.mode_0x0023_0x00=config +hwmon_in.int_cons_0x0023_0x00=0 +hwmon_in.src_0x0023_0x00=file +hwmon_in.frmt_0x0023_0x00=buf +hwmon_in.fpath_0x0023_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x0023_0x00=0 +hwmon_in.len_0x0023_0x00=8 +hwmon_in.bit_offset_0x0023_0x00= +hwmon_in.str_cons_0x0023_0x00=in7_input + +hwmon_in.mode_0x0023_0x01=str_constant +hwmon_in.str_cons_0x0023_0x01=UPORT_QSFP56_VDD3.3V_C + +hwmon_in.mode_0x0023_0x02=str_constant +hwmon_in.str_cons_0x0023_0x02=ucd90160 + +hwmon_in.mode_0x0023_0x03=constant +hwmon_in.int_cons_0x0023_0x03=3600 + +hwmon_in.mode_0x0023_0x05=constant +hwmon_in.int_cons_0x0023_0x05=3200 + +hwmon_in.mode_0x0024_0x00=config +hwmon_in.int_cons_0x0024_0x00=0 +hwmon_in.src_0x0024_0x00=file +hwmon_in.frmt_0x0024_0x00=buf +hwmon_in.fpath_0x0024_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x0024_0x00=0 +hwmon_in.len_0x0024_0x00=8 +hwmon_in.bit_offset_0x0024_0x00= +hwmon_in.str_cons_0x0024_0x00=in8_input + +hwmon_in.mode_0x0024_0x01=str_constant +hwmon_in.str_cons_0x0024_0x01=UPORT_QSFP56_VDD3.3V_D + +hwmon_in.mode_0x0024_0x02=str_constant +hwmon_in.str_cons_0x0024_0x02=ucd90160 + +hwmon_in.mode_0x0024_0x03=constant +hwmon_in.int_cons_0x0024_0x03=3600 + +hwmon_in.mode_0x0024_0x05=constant +hwmon_in.int_cons_0x0024_0x05=3200 + +hwmon_in.mode_0x0025_0x00=config +hwmon_in.int_cons_0x0025_0x00=0 +hwmon_in.src_0x0025_0x00=file +hwmon_in.frmt_0x0025_0x00=buf +hwmon_in.fpath_0x0025_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x0025_0x00=0 +hwmon_in.len_0x0025_0x00=8 +hwmon_in.bit_offset_0x0025_0x00= +hwmon_in.str_cons_0x0025_0x00=in9_input + +hwmon_in.mode_0x0025_0x01=str_constant +hwmon_in.str_cons_0x0025_0x01=UPORT_VDD3.3_MON + +hwmon_in.mode_0x0025_0x02=str_constant +hwmon_in.str_cons_0x0025_0x02=ucd90160 + +hwmon_in.mode_0x0025_0x03=constant +hwmon_in.int_cons_0x0025_0x03=3465 + +hwmon_in.mode_0x0025_0x05=constant +hwmon_in.int_cons_0x0025_0x05=3135 + +hwmon_in.mode_0x0026_0x00=config +hwmon_in.int_cons_0x0026_0x00=0 +hwmon_in.src_0x0026_0x00=file +hwmon_in.frmt_0x0026_0x00=buf +hwmon_in.fpath_0x0026_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x0026_0x00=0 +hwmon_in.len_0x0026_0x00=8 +hwmon_in.bit_offset_0x0026_0x00= +hwmon_in.str_cons_0x0026_0x00=in10_input + +hwmon_in.mode_0x0026_0x01=str_constant +hwmon_in.str_cons_0x0026_0x01=UPORT_VDD12V + +hwmon_in.mode_0x0026_0x02=str_constant +hwmon_in.str_cons_0x0026_0x02=ucd90160 + +hwmon_in.mode_0x0026_0x03=constant +hwmon_in.int_cons_0x0026_0x03=12600 + +hwmon_in.mode_0x0026_0x05=constant +hwmon_in.int_cons_0x0026_0x05=11400 + +hwmon_in.mode_0x0027_0x00=config +hwmon_in.int_cons_0x0027_0x00=0 +hwmon_in.src_0x0027_0x00=file +hwmon_in.frmt_0x0027_0x00=buf +hwmon_in.fpath_0x0027_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x0027_0x00=0 +hwmon_in.len_0x0027_0x00=8 +hwmon_in.bit_offset_0x0027_0x00= +hwmon_in.str_cons_0x0027_0x00=in1_input + +hwmon_in.mode_0x0027_0x01=str_constant +hwmon_in.str_cons_0x0027_0x01=DPORT_VDD1.0V_FPGA + +hwmon_in.mode_0x0027_0x02=str_constant +hwmon_in.str_cons_0x0027_0x02=ucd90160 + +hwmon_in.mode_0x0027_0x03=constant +hwmon_in.int_cons_0x0027_0x03=1061 + +hwmon_in.mode_0x0027_0x05=constant +hwmon_in.int_cons_0x0027_0x05=959 + +hwmon_in.mode_0x0028_0x00=config +hwmon_in.int_cons_0x0028_0x00=0 +hwmon_in.src_0x0028_0x00=file +hwmon_in.frmt_0x0028_0x00=buf +hwmon_in.fpath_0x0028_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x0028_0x00=0 +hwmon_in.len_0x0028_0x00=8 +hwmon_in.bit_offset_0x0028_0x00= +hwmon_in.str_cons_0x0028_0x00=in2_input + +hwmon_in.mode_0x0028_0x01=str_constant +hwmon_in.str_cons_0x0028_0x01=DPORT_VDD1.8V_FPGA + +hwmon_in.mode_0x0028_0x02=str_constant +hwmon_in.str_cons_0x0028_0x02=ucd90160 + +hwmon_in.mode_0x0028_0x03=constant +hwmon_in.int_cons_0x0028_0x03=1901 + +hwmon_in.mode_0x0028_0x05=constant +hwmon_in.int_cons_0x0028_0x05=1719 + +hwmon_in.mode_0x0029_0x00=config +hwmon_in.int_cons_0x0029_0x00=0 +hwmon_in.src_0x0029_0x00=file +hwmon_in.frmt_0x0029_0x00=buf +hwmon_in.fpath_0x0029_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x0029_0x00=0 +hwmon_in.len_0x0029_0x00=8 +hwmon_in.bit_offset_0x0029_0x00= +hwmon_in.str_cons_0x0029_0x00=in3_input + +hwmon_in.mode_0x0029_0x01=str_constant +hwmon_in.str_cons_0x0029_0x01=DPORT_VDD1.2V_FPGA + +hwmon_in.mode_0x0029_0x02=str_constant +hwmon_in.str_cons_0x0029_0x02=ucd90160 + +hwmon_in.mode_0x0029_0x03=constant +hwmon_in.int_cons_0x0029_0x03=1260 + +hwmon_in.mode_0x0029_0x05=constant +hwmon_in.int_cons_0x0029_0x05=1140 + +hwmon_in.mode_0x002a_0x00=config +hwmon_in.int_cons_0x002a_0x00=0 +hwmon_in.src_0x002a_0x00=file +hwmon_in.frmt_0x002a_0x00=buf +hwmon_in.fpath_0x002a_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x002a_0x00=0 +hwmon_in.len_0x002a_0x00=8 +hwmon_in.bit_offset_0x002a_0x00= +hwmon_in.str_cons_0x002a_0x00=in4_input + +hwmon_in.mode_0x002a_0x01=str_constant +hwmon_in.str_cons_0x002a_0x01=DPORT_VDD3.3V + +hwmon_in.mode_0x002a_0x02=str_constant +hwmon_in.str_cons_0x002a_0x02=ucd90160 + +hwmon_in.mode_0x002a_0x03=constant +hwmon_in.int_cons_0x002a_0x03=3600 + +hwmon_in.mode_0x002a_0x05=constant +hwmon_in.int_cons_0x002a_0x05=3200 + +hwmon_in.mode_0x002b_0x00=config +hwmon_in.int_cons_0x002b_0x00=0 +hwmon_in.src_0x002b_0x00=file +hwmon_in.frmt_0x002b_0x00=buf +hwmon_in.fpath_0x002b_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x002b_0x00=0 +hwmon_in.len_0x002b_0x00=8 +hwmon_in.bit_offset_0x002b_0x00= +hwmon_in.str_cons_0x002b_0x00=in5_input + +hwmon_in.mode_0x002b_0x01=str_constant +hwmon_in.str_cons_0x002b_0x01=DPORT_QSFP56_VDD3.3V_A + +hwmon_in.mode_0x002b_0x02=str_constant +hwmon_in.str_cons_0x002b_0x02=ucd90160 + +hwmon_in.mode_0x002b_0x03=constant +hwmon_in.int_cons_0x002b_0x03=3600 + +hwmon_in.mode_0x002b_0x05=constant +hwmon_in.int_cons_0x002b_0x05=3200 + +hwmon_in.mode_0x002c_0x00=config +hwmon_in.int_cons_0x002c_0x00=0 +hwmon_in.src_0x002c_0x00=file +hwmon_in.frmt_0x002c_0x00=buf +hwmon_in.fpath_0x002c_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x002c_0x00=0 +hwmon_in.len_0x002c_0x00=8 +hwmon_in.bit_offset_0x002c_0x00= +hwmon_in.str_cons_0x002c_0x00=in6_input + +hwmon_in.mode_0x002c_0x01=str_constant +hwmon_in.str_cons_0x002c_0x01=DPORT_QSFP56_VDD3.3V_B + +hwmon_in.mode_0x002c_0x02=str_constant +hwmon_in.str_cons_0x002c_0x02=ucd90160 + +hwmon_in.mode_0x002c_0x03=constant +hwmon_in.int_cons_0x002c_0x03=3600 + +hwmon_in.mode_0x002c_0x05=constant +hwmon_in.int_cons_0x002c_0x05=3200 + +hwmon_in.mode_0x002d_0x00=config +hwmon_in.int_cons_0x002d_0x00=0 +hwmon_in.src_0x002d_0x00=file +hwmon_in.frmt_0x002d_0x00=buf +hwmon_in.fpath_0x002d_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x002d_0x00=0 +hwmon_in.len_0x002d_0x00=8 +hwmon_in.bit_offset_0x002d_0x00= +hwmon_in.str_cons_0x002d_0x00=in7_input + +hwmon_in.mode_0x002d_0x01=str_constant +hwmon_in.str_cons_0x002d_0x01=DPORT_QSFP56_VDD3.3V_C + +hwmon_in.mode_0x002d_0x02=str_constant +hwmon_in.str_cons_0x002d_0x02=ucd90160 + +hwmon_in.mode_0x002d_0x03=constant +hwmon_in.int_cons_0x002d_0x03=3600 + +hwmon_in.mode_0x002d_0x05=constant +hwmon_in.int_cons_0x002d_0x05=3200 + +hwmon_in.mode_0x002e_0x00=config +hwmon_in.int_cons_0x002e_0x00=0 +hwmon_in.src_0x002e_0x00=file +hwmon_in.frmt_0x002e_0x00=buf +hwmon_in.fpath_0x002e_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x002e_0x00=0 +hwmon_in.len_0x002e_0x00=8 +hwmon_in.bit_offset_0x002e_0x00= +hwmon_in.str_cons_0x002e_0x00=in8_input + +hwmon_in.mode_0x002e_0x01=str_constant +hwmon_in.str_cons_0x002e_0x01=DPORT_QSFP56_VDD3.3V_D + +hwmon_in.mode_0x002e_0x02=str_constant +hwmon_in.str_cons_0x002e_0x02=ucd90160 + +hwmon_in.mode_0x002e_0x03=constant +hwmon_in.int_cons_0x002e_0x03=3600 + +hwmon_in.mode_0x002e_0x05=constant +hwmon_in.int_cons_0x002e_0x05=3200 + +hwmon_in.mode_0x002f_0x00=config +hwmon_in.int_cons_0x002f_0x00=0 +hwmon_in.src_0x002f_0x00=file +hwmon_in.frmt_0x002f_0x00=buf +hwmon_in.fpath_0x002f_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x002f_0x00=0 +hwmon_in.len_0x002f_0x00=8 +hwmon_in.bit_offset_0x002f_0x00= +hwmon_in.str_cons_0x002f_0x00=in9_input + +hwmon_in.mode_0x002f_0x01=str_constant +hwmon_in.str_cons_0x002f_0x01=DPORT_VDD3.3_MON + +hwmon_in.mode_0x002f_0x02=str_constant +hwmon_in.str_cons_0x002f_0x02=ucd90160 + +hwmon_in.mode_0x002f_0x03=constant +hwmon_in.int_cons_0x002f_0x03=3465 + +hwmon_in.mode_0x002f_0x05=constant +hwmon_in.int_cons_0x002f_0x05=3135 + +hwmon_in.mode_0x0030_0x00=config +hwmon_in.int_cons_0x0030_0x00=0 +hwmon_in.src_0x0030_0x00=file +hwmon_in.frmt_0x0030_0x00=buf +hwmon_in.fpath_0x0030_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x0030_0x00=0 +hwmon_in.len_0x0030_0x00=8 +hwmon_in.bit_offset_0x0030_0x00= +hwmon_in.str_cons_0x0030_0x00=in10_input + +hwmon_in.mode_0x0030_0x01=str_constant +hwmon_in.str_cons_0x0030_0x01=DPORT_VDD12V + +hwmon_in.mode_0x0030_0x02=str_constant +hwmon_in.str_cons_0x0030_0x02=ucd90160 + +hwmon_in.mode_0x0030_0x03=constant +hwmon_in.int_cons_0x0030_0x03=12600 + +hwmon_in.mode_0x0030_0x05=constant +hwmon_in.int_cons_0x0030_0x05=11400 + + +# MAC_QSFPDD_VDD3.3V_A +hwmon_in.mode_0x0031_0x00=config +hwmon_in.int_cons_0x0031_0x00=0 +hwmon_in.src_0x0031_0x00=cpld +hwmon_in.frmt_0x0031_0x00=num_bytes +hwmon_in.addr_0x0031_0x00=0x00050030 +hwmon_in.len_0x0031_0x00=2 +hwmon_in.int_extra1_0x0031_0x00=0x00050030 +hwmon_in.int_extra2_0x0031_0x00=2000 + +hwmon_in.mode_0x0031_0x01=str_constant +hwmon_in.str_cons_0x0031_0x01=MAC_QSFPDD_VDD3.3V_A + +hwmon_in.mode_0x0031_0x02=str_constant +hwmon_in.str_cons_0x0031_0x02=cpld + +hwmon_in.mode_0x0031_0x03=constant +hwmon_in.int_cons_0x0031_0x03=3600 + +hwmon_in.mode_0x0031_0x05=constant +hwmon_in.int_cons_0x0031_0x05=3200 + + +# MAC_QSFPDD_VDD3.3V_B +hwmon_in.mode_0x0032_0x00=config +hwmon_in.int_cons_0x0032_0x00=0 +hwmon_in.src_0x0032_0x00=cpld +hwmon_in.frmt_0x0032_0x00=num_bytes +hwmon_in.addr_0x0032_0x00=0x00050032 +hwmon_in.len_0x0032_0x00=2 +hwmon_in.int_extra1_0x0032_0x00=0x00050032 +hwmon_in.int_extra2_0x0032_0x00=2000 + +hwmon_in.mode_0x0032_0x01=str_constant +hwmon_in.str_cons_0x0032_0x01=MAC_QSFPDD_VDD3.3V_B + +hwmon_in.mode_0x0032_0x02=str_constant +hwmon_in.str_cons_0x0032_0x02=cpld + +hwmon_in.mode_0x0032_0x03=constant +hwmon_in.int_cons_0x0032_0x03=3600 + +hwmon_in.mode_0x0032_0x05=constant +hwmon_in.int_cons_0x0032_0x05=3200 + + +# MAC_QSFPDD_VDD3.3V_C +hwmon_in.mode_0x0033_0x00=config +hwmon_in.int_cons_0x0033_0x00=0 +hwmon_in.src_0x0033_0x00=cpld +hwmon_in.frmt_0x0033_0x00=num_bytes +hwmon_in.addr_0x0033_0x00=0x00050034 +hwmon_in.len_0x0033_0x00=2 +hwmon_in.int_extra1_0x0033_0x00=0x00050034 +hwmon_in.int_extra2_0x0033_0x00=2000 + +hwmon_in.mode_0x0033_0x01=str_constant +hwmon_in.str_cons_0x0033_0x01=MAC_QSFPDD_VDD3.3V_C + +hwmon_in.mode_0x0033_0x02=str_constant +hwmon_in.str_cons_0x0033_0x02=cpld + +hwmon_in.mode_0x0033_0x03=constant +hwmon_in.int_cons_0x0033_0x03=3600 + +hwmon_in.mode_0x0033_0x05=constant +hwmon_in.int_cons_0x0033_0x05=3200 + + +# MAC_QSFPDD_VDD3.3V_D +hwmon_in.mode_0x0034_0x00=config +hwmon_in.int_cons_0x0034_0x00=0 +hwmon_in.src_0x0034_0x00=cpld +hwmon_in.frmt_0x0034_0x00=num_bytes +hwmon_in.addr_0x0034_0x00=0x00050036 +hwmon_in.len_0x0034_0x00=2 +hwmon_in.int_extra1_0x0034_0x00=0x00050036 +hwmon_in.int_extra2_0x0034_0x00=2000 + +hwmon_in.mode_0x0034_0x01=str_constant +hwmon_in.str_cons_0x0034_0x01=MAC_QSFPDD_VDD3.3V_D + +hwmon_in.mode_0x0034_0x02=str_constant +hwmon_in.str_cons_0x0034_0x02=cpld + +hwmon_in.mode_0x0034_0x03=constant +hwmon_in.int_cons_0x0034_0x03=3600 + +hwmon_in.mode_0x0034_0x05=constant +hwmon_in.int_cons_0x0034_0x05=3200 + + +# MAC_QSFPDD_VDD3.3V_E +hwmon_in.mode_0x0035_0x00=config +hwmon_in.int_cons_0x0035_0x00=0 +hwmon_in.src_0x0035_0x00=cpld +hwmon_in.frmt_0x0035_0x00=num_bytes +hwmon_in.addr_0x0035_0x00=0x00050038 +hwmon_in.len_0x0035_0x00=2 +hwmon_in.int_extra1_0x0035_0x00=0x00050038 +hwmon_in.int_extra2_0x0035_0x00=2000 + +hwmon_in.mode_0x0035_0x01=str_constant +hwmon_in.str_cons_0x0035_0x01=MAC_QSFPDD_VDD3.3V_E + +hwmon_in.mode_0x0035_0x02=str_constant +hwmon_in.str_cons_0x0035_0x02=cpld + +hwmon_in.mode_0x0035_0x03=constant +hwmon_in.int_cons_0x0035_0x03=3600 + +hwmon_in.mode_0x0035_0x05=constant +hwmon_in.int_cons_0x0035_0x05=3200 + + +# MAC_QSFPDD_VDD3.3V_F +hwmon_in.mode_0x0036_0x00=config +hwmon_in.int_cons_0x0036_0x00=0 +hwmon_in.src_0x0036_0x00=cpld +hwmon_in.frmt_0x0036_0x00=num_bytes +hwmon_in.addr_0x0036_0x00=0x0005003a +hwmon_in.len_0x0036_0x00=2 +hwmon_in.int_extra1_0x0036_0x00=0x0005003a +hwmon_in.int_extra2_0x0036_0x00=2000 + +hwmon_in.mode_0x0036_0x01=str_constant +hwmon_in.str_cons_0x0036_0x01=MAC_QSFPDD_VDD3.3V_F + +hwmon_in.mode_0x0036_0x02=str_constant +hwmon_in.str_cons_0x0036_0x02=cpld + +hwmon_in.mode_0x0036_0x03=constant +hwmon_in.int_cons_0x0036_0x03=3600 + +hwmon_in.mode_0x0036_0x05=constant +hwmon_in.int_cons_0x0036_0x05=3200 + + +# MAC_QSFPDD_VDD3.3V_G +hwmon_in.mode_0x0037_0x00=config +hwmon_in.int_cons_0x0037_0x00=0 +hwmon_in.src_0x0037_0x00=cpld +hwmon_in.frmt_0x0037_0x00=num_bytes +hwmon_in.addr_0x0037_0x00=0x0005003c +hwmon_in.len_0x0037_0x00=2 +hwmon_in.int_extra1_0x0037_0x00=0x0005003c +hwmon_in.int_extra2_0x0037_0x00=2000 + +hwmon_in.mode_0x0037_0x01=str_constant +hwmon_in.str_cons_0x0037_0x01=MAC_QSFPDD_VDD3.3V_G + +hwmon_in.mode_0x0037_0x02=str_constant +hwmon_in.str_cons_0x0037_0x02=cpld + +hwmon_in.mode_0x0037_0x03=constant +hwmon_in.int_cons_0x0037_0x03=3600 + +hwmon_in.mode_0x0037_0x05=constant +hwmon_in.int_cons_0x0037_0x05=3200 + + +# MAC_QSFPDD_VDD3.3V_H +hwmon_in.mode_0x0038_0x00=config +hwmon_in.int_cons_0x0038_0x00=0 +hwmon_in.src_0x0038_0x00=cpld +hwmon_in.frmt_0x0038_0x00=num_bytes +hwmon_in.addr_0x0038_0x00=0x0005003e +hwmon_in.len_0x0038_0x00=2 +hwmon_in.int_extra1_0x0038_0x00=0x0005003e +hwmon_in.int_extra2_0x0038_0x00=2000 + +hwmon_in.mode_0x0038_0x01=str_constant +hwmon_in.str_cons_0x0038_0x01=MAC_QSFPDD_VDD3.3V_H + +hwmon_in.mode_0x0038_0x02=str_constant +hwmon_in.str_cons_0x0038_0x02=cpld + +hwmon_in.mode_0x0038_0x03=constant +hwmon_in.int_cons_0x0038_0x03=3600 + +hwmon_in.mode_0x0038_0x05=constant +hwmon_in.int_cons_0x0038_0x05=3200 + + +# curr1 +hwmon_curr.mode_0x0001_0x00=config +hwmon_curr.int_cons_0x0001_0x00=0 +hwmon_curr.src_0x0001_0x00=file +hwmon_curr.frmt_0x0001_0x00=buf +hwmon_curr.fpath_0x0001_0x00=/sys/bus/i2c/devices/106-0060/hwmon/ +hwmon_curr.addr_0x0001_0x00=0 +hwmon_curr.len_0x0001_0x00=8 +hwmon_curr.bit_offset_0x0001_0x00= +hwmon_curr.str_cons_0x0001_0x00=curr1_input + +hwmon_curr.mode_0x0001_0x01=str_constant +hwmon_curr.str_cons_0x0001_0x01=CPU_VCCIN_C + +hwmon_curr.mode_0x0001_0x02=str_constant +hwmon_curr.str_cons_0x0001_0x02=tps53622 + +hwmon_curr.mode_0x0001_0x03=constant +hwmon_curr.int_cons_0x0001_0x03=47300 + +hwmon_curr.mode_0x0001_0x05=constant +hwmon_curr.int_cons_0x0001_0x05=0 + +# curr2 +hwmon_curr.mode_0x0002_0x00=config +hwmon_curr.int_cons_0x0002_0x00=0 +hwmon_curr.src_0x0002_0x00=file +hwmon_curr.frmt_0x0002_0x00=buf +hwmon_curr.fpath_0x0002_0x00=/sys/bus/i2c/devices/106-0060/hwmon/ +hwmon_curr.addr_0x0002_0x00=0 +hwmon_curr.len_0x0002_0x00=8 +hwmon_curr.bit_offset_0x0002_0x00= +hwmon_curr.str_cons_0x0002_0x00=curr2_input + +hwmon_curr.mode_0x0002_0x01=str_constant +hwmon_curr.str_cons_0x0002_0x01=CPU_P1V05_C + +hwmon_curr.mode_0x0002_0x02=str_constant +hwmon_curr.str_cons_0x0002_0x02=tps53622 + +hwmon_curr.mode_0x0002_0x03=constant +hwmon_curr.int_cons_0x0002_0x03=15400 + +hwmon_curr.mode_0x0002_0x05=constant +hwmon_curr.int_cons_0x0002_0x05=0 + +# curr3 +hwmon_curr.mode_0x0003_0x00=config +hwmon_curr.int_cons_0x0003_0x00=0 +hwmon_curr.src_0x0003_0x00=file +hwmon_curr.frmt_0x0003_0x00=buf +hwmon_curr.fpath_0x0003_0x00=/sys/bus/i2c/devices/106-006c/hwmon/ +hwmon_curr.addr_0x0003_0x00=0 +hwmon_curr.len_0x0003_0x00=8 +hwmon_curr.bit_offset_0x0003_0x00= +hwmon_curr.str_cons_0x0003_0x00=curr1_input + +hwmon_curr.mode_0x0003_0x01=str_constant +hwmon_curr.str_cons_0x0003_0x01=CPU_P1V2_VDDQ_C + +hwmon_curr.mode_0x0003_0x02=str_constant +hwmon_curr.str_cons_0x0003_0x02=tps53622 + +hwmon_curr.mode_0x0003_0x03=constant +hwmon_curr.int_cons_0x0003_0x03=9900 + +hwmon_curr.mode_0x0003_0x05=constant +hwmon_curr.int_cons_0x0003_0x05=0 + +# curr4 +hwmon_curr.mode_0x0004_0x00=config +hwmon_curr.int_cons_0x0004_0x00=0 +hwmon_curr.src_0x0004_0x00=file +hwmon_curr.frmt_0x0004_0x00=buf +hwmon_curr.fpath_0x0004_0x00=/sys/bus/i2c/devices/106-006c/hwmon/ +hwmon_curr.addr_0x0004_0x00=0 +hwmon_curr.len_0x0004_0x00=8 +hwmon_curr.bit_offset_0x0004_0x00= +hwmon_curr.str_cons_0x0004_0x00=curr2_input + +hwmon_curr.mode_0x0004_0x01=str_constant +hwmon_curr.str_cons_0x0004_0x01=CPU_P2V5_VPP_C + +hwmon_curr.mode_0x0004_0x02=str_constant +hwmon_curr.str_cons_0x0004_0x02=tps53622 + +hwmon_curr.mode_0x0004_0x03=constant +hwmon_curr.int_cons_0x0004_0x03=2200 + +hwmon_curr.mode_0x0004_0x05=constant +hwmon_curr.int_cons_0x0004_0x05=0 + +# curr5 +hwmon_curr.mode_0x0005_0x00=config +hwmon_curr.int_cons_0x0005_0x00=0 +hwmon_curr.src_0x0005_0x00=file +hwmon_curr.frmt_0x0005_0x00=buf +hwmon_curr.fpath_0x0005_0x00=/sys/bus/i2c/devices/106-0043/hwmon/ +hwmon_curr.addr_0x0005_0x00=0 +hwmon_curr.len_0x0005_0x00=8 +hwmon_curr.bit_offset_0x0005_0x00= +hwmon_curr.str_cons_0x0005_0x00=curr1_input + +hwmon_curr.mode_0x0005_0x01=str_constant +hwmon_curr.str_cons_0x0005_0x01=CPU_P3V3_STBY_C + +hwmon_curr.mode_0x0005_0x02=str_constant +hwmon_curr.str_cons_0x0005_0x02=ina3221 + +hwmon_curr.mode_0x0005_0x03=constant +hwmon_curr.int_cons_0x0005_0x03=4686 + +hwmon_curr.mode_0x0005_0x05=constant +hwmon_curr.int_cons_0x0005_0x05=0 + +# curr6 +hwmon_curr.mode_0x0006_0x00=config +hwmon_curr.int_cons_0x0006_0x00=0 +hwmon_curr.src_0x0006_0x00=file +hwmon_curr.frmt_0x0006_0x00=buf +hwmon_curr.fpath_0x0006_0x00=/sys/bus/i2c/devices/106-0043/hwmon/ +hwmon_curr.addr_0x0006_0x00=0 +hwmon_curr.len_0x0006_0x00=8 +hwmon_curr.bit_offset_0x0006_0x00= +hwmon_curr.str_cons_0x0006_0x00=curr2_input + +hwmon_curr.mode_0x0006_0x01=str_constant +hwmon_curr.str_cons_0x0006_0x01=CPU_P5V_AUX_IN_C + +hwmon_curr.mode_0x0006_0x02=str_constant +hwmon_curr.str_cons_0x0006_0x02=ina3221 + +hwmon_curr.mode_0x0006_0x03=constant +hwmon_curr.int_cons_0x0006_0x03=2200 + +hwmon_curr.mode_0x0006_0x05=constant +hwmon_curr.int_cons_0x0006_0x05=0 + +# curr7 +hwmon_curr.mode_0x0007_0x00=config +hwmon_curr.int_cons_0x0007_0x00=0 +hwmon_curr.src_0x0007_0x00=file +hwmon_curr.frmt_0x0007_0x00=buf +hwmon_curr.fpath_0x0007_0x00=/sys/bus/i2c/devices/106-0043/hwmon/ +hwmon_curr.addr_0x0007_0x00=0 +hwmon_curr.len_0x0007_0x00=8 +hwmon_curr.bit_offset_0x0007_0x00= +hwmon_curr.str_cons_0x0007_0x00=curr3_input + +hwmon_curr.mode_0x0007_0x01=str_constant +hwmon_curr.str_cons_0x0007_0x01=CPU_P1V7_VCCSCFUSESUS_IN_C + +hwmon_curr.mode_0x0007_0x02=str_constant +hwmon_curr.str_cons_0x0007_0x02=ina3221 + +hwmon_curr.mode_0x0007_0x03=constant +hwmon_curr.int_cons_0x0007_0x03=2200 + +hwmon_curr.mode_0x0007_0x05=constant +hwmon_curr.int_cons_0x0007_0x05=0 \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-SFF.cfg b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-SFF.cfg new file mode 100755 index 000000000000..fa3f2e60364d --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-SFF.cfg @@ -0,0 +1,4233 @@ +# sff number +dev_num_3_0=128 + +eeprom_size_3_1=0x8180 +eeprom_size_3_2=0x8180 +eeprom_size_3_3=0x8180 +eeprom_size_3_4=0x8180 +eeprom_size_3_5=0x8180 +eeprom_size_3_6=0x8180 +eeprom_size_3_7=0x8180 +eeprom_size_3_8=0x8180 +eeprom_size_3_9=0x8180 +eeprom_size_3_10=0x8180 +eeprom_size_3_11=0x8180 +eeprom_size_3_12=0x8180 +eeprom_size_3_13=0x8180 +eeprom_size_3_14=0x8180 +eeprom_size_3_15=0x8180 +eeprom_size_3_16=0x8180 +eeprom_size_3_17=0x8180 +eeprom_size_3_18=0x8180 +eeprom_size_3_19=0x8180 +eeprom_size_3_20=0x8180 +eeprom_size_3_21=0x8180 +eeprom_size_3_22=0x8180 +eeprom_size_3_23=0x8180 +eeprom_size_3_24=0x8180 +eeprom_size_3_25=0x8180 +eeprom_size_3_26=0x8180 +eeprom_size_3_27=0x8180 +eeprom_size_3_28=0x8180 +eeprom_size_3_29=0x8180 +eeprom_size_3_30=0x8180 +eeprom_size_3_31=0x8180 +eeprom_size_3_32=0x8180 +eeprom_size_3_33=0x8180 +eeprom_size_3_34=0x8180 +eeprom_size_3_35=0x8180 +eeprom_size_3_36=0x8180 +eeprom_size_3_37=0x8180 +eeprom_size_3_38=0x8180 +eeprom_size_3_39=0x8180 +eeprom_size_3_40=0x8180 +eeprom_size_3_41=0x8180 +eeprom_size_3_42=0x8180 +eeprom_size_3_43=0x8180 +eeprom_size_3_44=0x8180 +eeprom_size_3_45=0x8180 +eeprom_size_3_46=0x8180 +eeprom_size_3_47=0x8180 +eeprom_size_3_48=0x8180 +eeprom_size_3_49=0x8180 +eeprom_size_3_50=0x8180 +eeprom_size_3_51=0x8180 +eeprom_size_3_52=0x8180 +eeprom_size_3_53=0x8180 +eeprom_size_3_54=0x8180 +eeprom_size_3_55=0x8180 +eeprom_size_3_56=0x8180 +eeprom_size_3_57=0x8180 +eeprom_size_3_58=0x8180 +eeprom_size_3_59=0x8180 +eeprom_size_3_60=0x8180 +eeprom_size_3_61=0x8180 +eeprom_size_3_62=0x8180 +eeprom_size_3_63=0x8180 +eeprom_size_3_64=0x8180 +eeprom_size_3_65=0x8180 +eeprom_size_3_66=0x8180 +eeprom_size_3_67=0x8180 +eeprom_size_3_68=0x8180 +eeprom_size_3_69=0x8180 +eeprom_size_3_70=0x8180 +eeprom_size_3_71=0x8180 +eeprom_size_3_72=0x8180 +eeprom_size_3_73=0x8180 +eeprom_size_3_74=0x8180 +eeprom_size_3_75=0x8180 +eeprom_size_3_76=0x8180 +eeprom_size_3_77=0x8180 +eeprom_size_3_78=0x8180 +eeprom_size_3_79=0x8180 +eeprom_size_3_80=0x8180 +eeprom_size_3_81=0x8180 +eeprom_size_3_82=0x8180 +eeprom_size_3_83=0x8180 +eeprom_size_3_84=0x8180 +eeprom_size_3_85=0x8180 +eeprom_size_3_86=0x8180 +eeprom_size_3_87=0x8180 +eeprom_size_3_88=0x8180 +eeprom_size_3_89=0x8180 +eeprom_size_3_90=0x8180 +eeprom_size_3_91=0x8180 +eeprom_size_3_92=0x8180 +eeprom_size_3_93=0x8180 +eeprom_size_3_94=0x8180 +eeprom_size_3_95=0x8180 +eeprom_size_3_96=0x8180 +eeprom_size_3_97=0x8180 +eeprom_size_3_98=0x8180 +eeprom_size_3_99=0x8180 +eeprom_size_3_100=0x8180 +eeprom_size_3_101=0x8180 +eeprom_size_3_102=0x8180 +eeprom_size_3_103=0x8180 +eeprom_size_3_104=0x8180 +eeprom_size_3_105=0x8180 +eeprom_size_3_106=0x8180 +eeprom_size_3_107=0x8180 +eeprom_size_3_108=0x8180 +eeprom_size_3_109=0x8180 +eeprom_size_3_110=0x8180 +eeprom_size_3_111=0x8180 +eeprom_size_3_112=0x8180 +eeprom_size_3_113=0x8180 +eeprom_size_3_114=0x8180 +eeprom_size_3_115=0x8180 +eeprom_size_3_116=0x8180 +eeprom_size_3_117=0x8180 +eeprom_size_3_118=0x8180 +eeprom_size_3_119=0x8180 +eeprom_size_3_120=0x8180 +eeprom_size_3_121=0x8180 +eeprom_size_3_122=0x8180 +eeprom_size_3_123=0x8180 +eeprom_size_3_124=0x8180 +eeprom_size_3_125=0x8180 +eeprom_size_3_126=0x8180 +eeprom_size_3_127=0x8180 +eeprom_size_3_128=0x8180 + + +eeprom_path_3_1=/sys/bus/i2c/devices/124-0050/eeprom +eeprom_path_3_2=/sys/bus/i2c/devices/125-0050/eeprom +eeprom_path_3_3=/sys/bus/i2c/devices/126-0050/eeprom +eeprom_path_3_4=/sys/bus/i2c/devices/127-0050/eeprom +eeprom_path_3_5=/sys/bus/i2c/devices/128-0050/eeprom +eeprom_path_3_6=/sys/bus/i2c/devices/129-0050/eeprom +eeprom_path_3_7=/sys/bus/i2c/devices/130-0050/eeprom +eeprom_path_3_8=/sys/bus/i2c/devices/131-0050/eeprom +eeprom_path_3_9=/sys/bus/i2c/devices/132-0050/eeprom +eeprom_path_3_10=/sys/bus/i2c/devices/133-0050/eeprom +eeprom_path_3_11=/sys/bus/i2c/devices/134-0050/eeprom +eeprom_path_3_12=/sys/bus/i2c/devices/135-0050/eeprom +eeprom_path_3_13=/sys/bus/i2c/devices/136-0050/eeprom +eeprom_path_3_14=/sys/bus/i2c/devices/137-0050/eeprom +eeprom_path_3_15=/sys/bus/i2c/devices/138-0050/eeprom +eeprom_path_3_16=/sys/bus/i2c/devices/139-0050/eeprom +eeprom_path_3_17=/sys/bus/i2c/devices/140-0050/eeprom +eeprom_path_3_18=/sys/bus/i2c/devices/141-0050/eeprom +eeprom_path_3_19=/sys/bus/i2c/devices/142-0050/eeprom +eeprom_path_3_20=/sys/bus/i2c/devices/143-0050/eeprom +eeprom_path_3_21=/sys/bus/i2c/devices/144-0050/eeprom +eeprom_path_3_22=/sys/bus/i2c/devices/145-0050/eeprom +eeprom_path_3_23=/sys/bus/i2c/devices/146-0050/eeprom +eeprom_path_3_24=/sys/bus/i2c/devices/147-0050/eeprom +eeprom_path_3_25=/sys/bus/i2c/devices/148-0050/eeprom +eeprom_path_3_26=/sys/bus/i2c/devices/149-0050/eeprom +eeprom_path_3_27=/sys/bus/i2c/devices/150-0050/eeprom +eeprom_path_3_28=/sys/bus/i2c/devices/151-0050/eeprom +eeprom_path_3_29=/sys/bus/i2c/devices/152-0050/eeprom +eeprom_path_3_30=/sys/bus/i2c/devices/153-0050/eeprom +eeprom_path_3_31=/sys/bus/i2c/devices/154-0050/eeprom +eeprom_path_3_32=/sys/bus/i2c/devices/155-0050/eeprom +eeprom_path_3_33=/sys/bus/i2c/devices/156-0050/eeprom +eeprom_path_3_34=/sys/bus/i2c/devices/157-0050/eeprom +eeprom_path_3_35=/sys/bus/i2c/devices/158-0050/eeprom +eeprom_path_3_36=/sys/bus/i2c/devices/159-0050/eeprom +eeprom_path_3_37=/sys/bus/i2c/devices/160-0050/eeprom +eeprom_path_3_38=/sys/bus/i2c/devices/161-0050/eeprom +eeprom_path_3_39=/sys/bus/i2c/devices/162-0050/eeprom +eeprom_path_3_40=/sys/bus/i2c/devices/163-0050/eeprom +eeprom_path_3_41=/sys/bus/i2c/devices/164-0050/eeprom +eeprom_path_3_42=/sys/bus/i2c/devices/165-0050/eeprom +eeprom_path_3_43=/sys/bus/i2c/devices/166-0050/eeprom +eeprom_path_3_44=/sys/bus/i2c/devices/167-0050/eeprom +eeprom_path_3_45=/sys/bus/i2c/devices/168-0050/eeprom +eeprom_path_3_46=/sys/bus/i2c/devices/169-0050/eeprom +eeprom_path_3_47=/sys/bus/i2c/devices/170-0050/eeprom +eeprom_path_3_48=/sys/bus/i2c/devices/171-0050/eeprom +eeprom_path_3_49=/sys/bus/i2c/devices/172-0050/eeprom +eeprom_path_3_50=/sys/bus/i2c/devices/173-0050/eeprom +eeprom_path_3_51=/sys/bus/i2c/devices/174-0050/eeprom +eeprom_path_3_52=/sys/bus/i2c/devices/175-0050/eeprom +eeprom_path_3_53=/sys/bus/i2c/devices/176-0050/eeprom +eeprom_path_3_54=/sys/bus/i2c/devices/177-0050/eeprom +eeprom_path_3_55=/sys/bus/i2c/devices/178-0050/eeprom +eeprom_path_3_56=/sys/bus/i2c/devices/179-0050/eeprom +eeprom_path_3_57=/sys/bus/i2c/devices/180-0050/eeprom +eeprom_path_3_58=/sys/bus/i2c/devices/181-0050/eeprom +eeprom_path_3_59=/sys/bus/i2c/devices/182-0050/eeprom +eeprom_path_3_60=/sys/bus/i2c/devices/183-0050/eeprom +eeprom_path_3_61=/sys/bus/i2c/devices/184-0050/eeprom +eeprom_path_3_62=/sys/bus/i2c/devices/185-0050/eeprom +eeprom_path_3_63=/sys/bus/i2c/devices/186-0050/eeprom +eeprom_path_3_64=/sys/bus/i2c/devices/187-0050/eeprom +eeprom_path_3_65=/sys/bus/i2c/devices/188-0050/eeprom +eeprom_path_3_66=/sys/bus/i2c/devices/189-0050/eeprom +eeprom_path_3_67=/sys/bus/i2c/devices/190-0050/eeprom +eeprom_path_3_68=/sys/bus/i2c/devices/191-0050/eeprom +eeprom_path_3_69=/sys/bus/i2c/devices/192-0050/eeprom +eeprom_path_3_70=/sys/bus/i2c/devices/193-0050/eeprom +eeprom_path_3_71=/sys/bus/i2c/devices/194-0050/eeprom +eeprom_path_3_72=/sys/bus/i2c/devices/195-0050/eeprom +eeprom_path_3_73=/sys/bus/i2c/devices/196-0050/eeprom +eeprom_path_3_74=/sys/bus/i2c/devices/197-0050/eeprom +eeprom_path_3_75=/sys/bus/i2c/devices/198-0050/eeprom +eeprom_path_3_76=/sys/bus/i2c/devices/199-0050/eeprom +eeprom_path_3_77=/sys/bus/i2c/devices/200-0050/eeprom +eeprom_path_3_78=/sys/bus/i2c/devices/201-0050/eeprom +eeprom_path_3_79=/sys/bus/i2c/devices/202-0050/eeprom +eeprom_path_3_80=/sys/bus/i2c/devices/203-0050/eeprom +eeprom_path_3_81=/sys/bus/i2c/devices/204-0050/eeprom +eeprom_path_3_82=/sys/bus/i2c/devices/205-0050/eeprom +eeprom_path_3_83=/sys/bus/i2c/devices/206-0050/eeprom +eeprom_path_3_84=/sys/bus/i2c/devices/207-0050/eeprom +eeprom_path_3_85=/sys/bus/i2c/devices/208-0050/eeprom +eeprom_path_3_86=/sys/bus/i2c/devices/209-0050/eeprom +eeprom_path_3_87=/sys/bus/i2c/devices/210-0050/eeprom +eeprom_path_3_88=/sys/bus/i2c/devices/211-0050/eeprom +eeprom_path_3_89=/sys/bus/i2c/devices/212-0050/eeprom +eeprom_path_3_90=/sys/bus/i2c/devices/213-0050/eeprom +eeprom_path_3_91=/sys/bus/i2c/devices/214-0050/eeprom +eeprom_path_3_92=/sys/bus/i2c/devices/215-0050/eeprom +eeprom_path_3_93=/sys/bus/i2c/devices/216-0050/eeprom +eeprom_path_3_94=/sys/bus/i2c/devices/217-0050/eeprom +eeprom_path_3_95=/sys/bus/i2c/devices/218-0050/eeprom +eeprom_path_3_96=/sys/bus/i2c/devices/219-0050/eeprom +eeprom_path_3_97=/sys/bus/i2c/devices/220-0050/eeprom +eeprom_path_3_98=/sys/bus/i2c/devices/221-0050/eeprom +eeprom_path_3_99=/sys/bus/i2c/devices/222-0050/eeprom +eeprom_path_3_100=/sys/bus/i2c/devices/223-0050/eeprom +eeprom_path_3_101=/sys/bus/i2c/devices/224-0050/eeprom +eeprom_path_3_102=/sys/bus/i2c/devices/225-0050/eeprom +eeprom_path_3_103=/sys/bus/i2c/devices/226-0050/eeprom +eeprom_path_3_104=/sys/bus/i2c/devices/227-0050/eeprom +eeprom_path_3_105=/sys/bus/i2c/devices/228-0050/eeprom +eeprom_path_3_106=/sys/bus/i2c/devices/229-0050/eeprom +eeprom_path_3_107=/sys/bus/i2c/devices/230-0050/eeprom +eeprom_path_3_108=/sys/bus/i2c/devices/231-0050/eeprom +eeprom_path_3_109=/sys/bus/i2c/devices/232-0050/eeprom +eeprom_path_3_110=/sys/bus/i2c/devices/233-0050/eeprom +eeprom_path_3_111=/sys/bus/i2c/devices/234-0050/eeprom +eeprom_path_3_112=/sys/bus/i2c/devices/235-0050/eeprom +eeprom_path_3_113=/sys/bus/i2c/devices/236-0050/eeprom +eeprom_path_3_114=/sys/bus/i2c/devices/237-0050/eeprom +eeprom_path_3_115=/sys/bus/i2c/devices/238-0050/eeprom +eeprom_path_3_116=/sys/bus/i2c/devices/239-0050/eeprom +eeprom_path_3_117=/sys/bus/i2c/devices/240-0050/eeprom +eeprom_path_3_118=/sys/bus/i2c/devices/241-0050/eeprom +eeprom_path_3_119=/sys/bus/i2c/devices/242-0050/eeprom +eeprom_path_3_120=/sys/bus/i2c/devices/243-0050/eeprom +eeprom_path_3_121=/sys/bus/i2c/devices/244-0050/eeprom +eeprom_path_3_122=/sys/bus/i2c/devices/245-0050/eeprom +eeprom_path_3_123=/sys/bus/i2c/devices/246-0050/eeprom +eeprom_path_3_124=/sys/bus/i2c/devices/247-0050/eeprom +eeprom_path_3_125=/sys/bus/i2c/devices/248-0050/eeprom +eeprom_path_3_126=/sys/bus/i2c/devices/249-0050/eeprom +eeprom_path_3_127=/sys/bus/i2c/devices/250-0050/eeprom +eeprom_path_3_128=/sys/bus/i2c/devices/251-0050/eeprom + + + +sff_cpld_reg.mode_1_6=config +sff_cpld_reg.src_1_6=cpld +sff_cpld_reg.frmt_1_6=bit +sff_cpld_reg.pola_1_6=negative +sff_cpld_reg.addr_1_6=0x00020073 +sff_cpld_reg.len_1_6=1 +sff_cpld_reg.bit_offset_1_6=0 + +sff_cpld_reg.mode_2_6=config +sff_cpld_reg.src_2_6=cpld +sff_cpld_reg.frmt_2_6=bit +sff_cpld_reg.pola_2_6=negative +sff_cpld_reg.addr_2_6=0x00020073 +sff_cpld_reg.len_2_6=1 +sff_cpld_reg.bit_offset_2_6=1 + +sff_cpld_reg.mode_3_6=config +sff_cpld_reg.src_3_6=cpld +sff_cpld_reg.frmt_3_6=bit +sff_cpld_reg.pola_3_6=negative +sff_cpld_reg.addr_3_6=0x00020073 +sff_cpld_reg.len_3_6=1 +sff_cpld_reg.bit_offset_3_6=2 + +sff_cpld_reg.mode_4_6=config +sff_cpld_reg.src_4_6=cpld +sff_cpld_reg.frmt_4_6=bit +sff_cpld_reg.pola_4_6=negative +sff_cpld_reg.addr_4_6=0x00020073 +sff_cpld_reg.len_4_6=1 +sff_cpld_reg.bit_offset_4_6=3 + +sff_cpld_reg.mode_5_6=config +sff_cpld_reg.src_5_6=cpld +sff_cpld_reg.frmt_5_6=bit +sff_cpld_reg.pola_5_6=negative +sff_cpld_reg.addr_5_6=0x00020073 +sff_cpld_reg.len_5_6=1 +sff_cpld_reg.bit_offset_5_6=4 + +sff_cpld_reg.mode_6_6=config +sff_cpld_reg.src_6_6=cpld +sff_cpld_reg.frmt_6_6=bit +sff_cpld_reg.pola_6_6=negative +sff_cpld_reg.addr_6_6=0x00020073 +sff_cpld_reg.len_6_6=1 +sff_cpld_reg.bit_offset_6_6=5 + +sff_cpld_reg.mode_7_6=config +sff_cpld_reg.src_7_6=cpld +sff_cpld_reg.frmt_7_6=bit +sff_cpld_reg.pola_7_6=negative +sff_cpld_reg.addr_7_6=0x00020073 +sff_cpld_reg.len_7_6=1 +sff_cpld_reg.bit_offset_7_6=6 + +sff_cpld_reg.mode_8_6=config +sff_cpld_reg.src_8_6=cpld +sff_cpld_reg.frmt_8_6=bit +sff_cpld_reg.pola_8_6=negative +sff_cpld_reg.addr_8_6=0x00020073 +sff_cpld_reg.len_8_6=1 +sff_cpld_reg.bit_offset_8_6=7 + +sff_cpld_reg.mode_9_6=config +sff_cpld_reg.src_9_6=cpld +sff_cpld_reg.frmt_9_6=bit +sff_cpld_reg.pola_9_6=negative +sff_cpld_reg.addr_9_6=0x00020072 +sff_cpld_reg.len_9_6=1 +sff_cpld_reg.bit_offset_9_6=0 + +sff_cpld_reg.mode_10_6=config +sff_cpld_reg.src_10_6=cpld +sff_cpld_reg.frmt_10_6=bit +sff_cpld_reg.pola_10_6=negative +sff_cpld_reg.addr_10_6=0x00020072 +sff_cpld_reg.len_10_6=1 +sff_cpld_reg.bit_offset_10_6=1 + +sff_cpld_reg.mode_11_6=config +sff_cpld_reg.src_11_6=cpld +sff_cpld_reg.frmt_11_6=bit +sff_cpld_reg.pola_11_6=negative +sff_cpld_reg.addr_11_6=0x00020072 +sff_cpld_reg.len_11_6=1 +sff_cpld_reg.bit_offset_11_6=2 + +sff_cpld_reg.mode_12_6=config +sff_cpld_reg.src_12_6=cpld +sff_cpld_reg.frmt_12_6=bit +sff_cpld_reg.pola_12_6=negative +sff_cpld_reg.addr_12_6=0x00020072 +sff_cpld_reg.len_12_6=1 +sff_cpld_reg.bit_offset_12_6=3 + +sff_cpld_reg.mode_13_6=config +sff_cpld_reg.src_13_6=cpld +sff_cpld_reg.frmt_13_6=bit +sff_cpld_reg.pola_13_6=negative +sff_cpld_reg.addr_13_6=0x00020072 +sff_cpld_reg.len_13_6=1 +sff_cpld_reg.bit_offset_13_6=4 + +sff_cpld_reg.mode_14_6=config +sff_cpld_reg.src_14_6=cpld +sff_cpld_reg.frmt_14_6=bit +sff_cpld_reg.pola_14_6=negative +sff_cpld_reg.addr_14_6=0x00020072 +sff_cpld_reg.len_14_6=1 +sff_cpld_reg.bit_offset_14_6=5 + +sff_cpld_reg.mode_15_6=config +sff_cpld_reg.src_15_6=cpld +sff_cpld_reg.frmt_15_6=bit +sff_cpld_reg.pola_15_6=negative +sff_cpld_reg.addr_15_6=0x00020072 +sff_cpld_reg.len_15_6=1 +sff_cpld_reg.bit_offset_15_6=6 + +sff_cpld_reg.mode_16_6=config +sff_cpld_reg.src_16_6=cpld +sff_cpld_reg.frmt_16_6=bit +sff_cpld_reg.pola_16_6=negative +sff_cpld_reg.addr_16_6=0x00020072 +sff_cpld_reg.len_16_6=1 +sff_cpld_reg.bit_offset_16_6=7 + +sff_cpld_reg.mode_17_6=config +sff_cpld_reg.src_17_6=cpld +sff_cpld_reg.frmt_17_6=bit +sff_cpld_reg.pola_17_6=negative +sff_cpld_reg.addr_17_6=0x00020071 +sff_cpld_reg.len_17_6=1 +sff_cpld_reg.bit_offset_17_6=0 + +sff_cpld_reg.mode_18_6=config +sff_cpld_reg.src_18_6=cpld +sff_cpld_reg.frmt_18_6=bit +sff_cpld_reg.pola_18_6=negative +sff_cpld_reg.addr_18_6=0x00020071 +sff_cpld_reg.len_18_6=1 +sff_cpld_reg.bit_offset_18_6=1 + +sff_cpld_reg.mode_19_6=config +sff_cpld_reg.src_19_6=cpld +sff_cpld_reg.frmt_19_6=bit +sff_cpld_reg.pola_19_6=negative +sff_cpld_reg.addr_19_6=0x00020071 +sff_cpld_reg.len_19_6=1 +sff_cpld_reg.bit_offset_19_6=2 + +sff_cpld_reg.mode_20_6=config +sff_cpld_reg.src_20_6=cpld +sff_cpld_reg.frmt_20_6=bit +sff_cpld_reg.pola_20_6=negative +sff_cpld_reg.addr_20_6=0x00020071 +sff_cpld_reg.len_20_6=1 +sff_cpld_reg.bit_offset_20_6=3 + +sff_cpld_reg.mode_21_6=config +sff_cpld_reg.src_21_6=cpld +sff_cpld_reg.frmt_21_6=bit +sff_cpld_reg.pola_21_6=negative +sff_cpld_reg.addr_21_6=0x00020071 +sff_cpld_reg.len_21_6=1 +sff_cpld_reg.bit_offset_21_6=4 + +sff_cpld_reg.mode_22_6=config +sff_cpld_reg.src_22_6=cpld +sff_cpld_reg.frmt_22_6=bit +sff_cpld_reg.pola_22_6=negative +sff_cpld_reg.addr_22_6=0x00020071 +sff_cpld_reg.len_22_6=1 +sff_cpld_reg.bit_offset_22_6=5 + +sff_cpld_reg.mode_23_6=config +sff_cpld_reg.src_23_6=cpld +sff_cpld_reg.frmt_23_6=bit +sff_cpld_reg.pola_23_6=negative +sff_cpld_reg.addr_23_6=0x00020071 +sff_cpld_reg.len_23_6=1 +sff_cpld_reg.bit_offset_23_6=6 + +sff_cpld_reg.mode_24_6=config +sff_cpld_reg.src_24_6=cpld +sff_cpld_reg.frmt_24_6=bit +sff_cpld_reg.pola_24_6=negative +sff_cpld_reg.addr_24_6=0x00020071 +sff_cpld_reg.len_24_6=1 +sff_cpld_reg.bit_offset_24_6=7 + +sff_cpld_reg.mode_25_6=config +sff_cpld_reg.src_25_6=cpld +sff_cpld_reg.frmt_25_6=bit +sff_cpld_reg.pola_25_6=negative +sff_cpld_reg.addr_25_6=0x00020070 +sff_cpld_reg.len_25_6=1 +sff_cpld_reg.bit_offset_25_6=0 + +sff_cpld_reg.mode_26_6=config +sff_cpld_reg.src_26_6=cpld +sff_cpld_reg.frmt_26_6=bit +sff_cpld_reg.pola_26_6=negative +sff_cpld_reg.addr_26_6=0x00020070 +sff_cpld_reg.len_26_6=1 +sff_cpld_reg.bit_offset_26_6=1 + +sff_cpld_reg.mode_27_6=config +sff_cpld_reg.src_27_6=cpld +sff_cpld_reg.frmt_27_6=bit +sff_cpld_reg.pola_27_6=negative +sff_cpld_reg.addr_27_6=0x00020070 +sff_cpld_reg.len_27_6=1 +sff_cpld_reg.bit_offset_27_6=2 + +sff_cpld_reg.mode_28_6=config +sff_cpld_reg.src_28_6=cpld +sff_cpld_reg.frmt_28_6=bit +sff_cpld_reg.pola_28_6=negative +sff_cpld_reg.addr_28_6=0x00020070 +sff_cpld_reg.len_28_6=1 +sff_cpld_reg.bit_offset_28_6=3 + +sff_cpld_reg.mode_29_6=config +sff_cpld_reg.src_29_6=cpld +sff_cpld_reg.frmt_29_6=bit +sff_cpld_reg.pola_29_6=negative +sff_cpld_reg.addr_29_6=0x00020070 +sff_cpld_reg.len_29_6=1 +sff_cpld_reg.bit_offset_29_6=4 + +sff_cpld_reg.mode_30_6=config +sff_cpld_reg.src_30_6=cpld +sff_cpld_reg.frmt_30_6=bit +sff_cpld_reg.pola_30_6=negative +sff_cpld_reg.addr_30_6=0x00020070 +sff_cpld_reg.len_30_6=1 +sff_cpld_reg.bit_offset_30_6=5 + +sff_cpld_reg.mode_31_6=config +sff_cpld_reg.src_31_6=cpld +sff_cpld_reg.frmt_31_6=bit +sff_cpld_reg.pola_31_6=negative +sff_cpld_reg.addr_31_6=0x00020070 +sff_cpld_reg.len_31_6=1 +sff_cpld_reg.bit_offset_31_6=6 + +sff_cpld_reg.mode_32_6=config +sff_cpld_reg.src_32_6=cpld +sff_cpld_reg.frmt_32_6=bit +sff_cpld_reg.pola_32_6=negative +sff_cpld_reg.addr_32_6=0x00020070 +sff_cpld_reg.len_32_6=1 +sff_cpld_reg.bit_offset_32_6=7 + +sff_cpld_reg.mode_33_6=config +sff_cpld_reg.src_33_6=cpld +sff_cpld_reg.frmt_33_6=bit +sff_cpld_reg.pola_33_6=negative +sff_cpld_reg.addr_33_6=0x00050072 +sff_cpld_reg.len_33_6=1 +sff_cpld_reg.bit_offset_33_6=0 + +sff_cpld_reg.mode_34_6=config +sff_cpld_reg.src_34_6=cpld +sff_cpld_reg.frmt_34_6=bit +sff_cpld_reg.pola_34_6=negative +sff_cpld_reg.addr_34_6=0x00050072 +sff_cpld_reg.len_34_6=1 +sff_cpld_reg.bit_offset_34_6=1 + +sff_cpld_reg.mode_35_6=config +sff_cpld_reg.src_35_6=cpld +sff_cpld_reg.frmt_35_6=bit +sff_cpld_reg.pola_35_6=negative +sff_cpld_reg.addr_35_6=0x00050072 +sff_cpld_reg.len_35_6=1 +sff_cpld_reg.bit_offset_35_6=2 + +sff_cpld_reg.mode_36_6=config +sff_cpld_reg.src_36_6=cpld +sff_cpld_reg.frmt_36_6=bit +sff_cpld_reg.pola_36_6=negative +sff_cpld_reg.addr_36_6=0x00050072 +sff_cpld_reg.len_36_6=1 +sff_cpld_reg.bit_offset_36_6=3 + +sff_cpld_reg.mode_37_6=config +sff_cpld_reg.src_37_6=cpld +sff_cpld_reg.frmt_37_6=bit +sff_cpld_reg.pola_37_6=negative +sff_cpld_reg.addr_37_6=0x00050071 +sff_cpld_reg.len_37_6=1 +sff_cpld_reg.bit_offset_37_6=0 + +sff_cpld_reg.mode_38_6=config +sff_cpld_reg.src_38_6=cpld +sff_cpld_reg.frmt_38_6=bit +sff_cpld_reg.pola_38_6=negative +sff_cpld_reg.addr_38_6=0x00050071 +sff_cpld_reg.len_38_6=1 +sff_cpld_reg.bit_offset_38_6=1 + +sff_cpld_reg.mode_39_6=config +sff_cpld_reg.src_39_6=cpld +sff_cpld_reg.frmt_39_6=bit +sff_cpld_reg.pola_39_6=negative +sff_cpld_reg.addr_39_6=0x00050071 +sff_cpld_reg.len_39_6=1 +sff_cpld_reg.bit_offset_39_6=2 + +sff_cpld_reg.mode_40_6=config +sff_cpld_reg.src_40_6=cpld +sff_cpld_reg.frmt_40_6=bit +sff_cpld_reg.pola_40_6=negative +sff_cpld_reg.addr_40_6=0x00050071 +sff_cpld_reg.len_40_6=1 +sff_cpld_reg.bit_offset_40_6=3 + +sff_cpld_reg.mode_41_6=config +sff_cpld_reg.src_41_6=cpld +sff_cpld_reg.frmt_41_6=bit +sff_cpld_reg.pola_41_6=negative +sff_cpld_reg.addr_41_6=0x00050071 +sff_cpld_reg.len_41_6=1 +sff_cpld_reg.bit_offset_41_6=4 + +sff_cpld_reg.mode_42_6=config +sff_cpld_reg.src_42_6=cpld +sff_cpld_reg.frmt_42_6=bit +sff_cpld_reg.pola_42_6=negative +sff_cpld_reg.addr_42_6=0x00050071 +sff_cpld_reg.len_42_6=1 +sff_cpld_reg.bit_offset_42_6=5 + +sff_cpld_reg.mode_43_6=config +sff_cpld_reg.src_43_6=cpld +sff_cpld_reg.frmt_43_6=bit +sff_cpld_reg.pola_43_6=negative +sff_cpld_reg.addr_43_6=0x00060075 +sff_cpld_reg.len_43_6=1 +sff_cpld_reg.bit_offset_43_6=0 + +sff_cpld_reg.mode_44_6=config +sff_cpld_reg.src_44_6=cpld +sff_cpld_reg.frmt_44_6=bit +sff_cpld_reg.pola_44_6=negative +sff_cpld_reg.addr_44_6=0x00060075 +sff_cpld_reg.len_44_6=1 +sff_cpld_reg.bit_offset_44_6=1 + +sff_cpld_reg.mode_45_6=config +sff_cpld_reg.src_45_6=cpld +sff_cpld_reg.frmt_45_6=bit +sff_cpld_reg.pola_45_6=negative +sff_cpld_reg.addr_45_6=0x00060075 +sff_cpld_reg.len_45_6=1 +sff_cpld_reg.bit_offset_45_6=2 + +sff_cpld_reg.mode_46_6=config +sff_cpld_reg.src_46_6=cpld +sff_cpld_reg.frmt_46_6=bit +sff_cpld_reg.pola_46_6=negative +sff_cpld_reg.addr_46_6=0x00060075 +sff_cpld_reg.len_46_6=1 +sff_cpld_reg.bit_offset_46_6=3 + +sff_cpld_reg.mode_47_6=config +sff_cpld_reg.src_47_6=cpld +sff_cpld_reg.frmt_47_6=bit +sff_cpld_reg.pola_47_6=negative +sff_cpld_reg.addr_47_6=0x00060075 +sff_cpld_reg.len_47_6=1 +sff_cpld_reg.bit_offset_47_6=4 + +sff_cpld_reg.mode_48_6=config +sff_cpld_reg.src_48_6=cpld +sff_cpld_reg.frmt_48_6=bit +sff_cpld_reg.pola_48_6=negative +sff_cpld_reg.addr_48_6=0x00060075 +sff_cpld_reg.len_48_6=1 +sff_cpld_reg.bit_offset_48_6=5 + +sff_cpld_reg.mode_49_6=config +sff_cpld_reg.src_49_6=cpld +sff_cpld_reg.frmt_49_6=bit +sff_cpld_reg.pola_49_6=negative +sff_cpld_reg.addr_49_6=0x00060074 +sff_cpld_reg.len_49_6=1 +sff_cpld_reg.bit_offset_49_6=0 + +sff_cpld_reg.mode_50_6=config +sff_cpld_reg.src_50_6=cpld +sff_cpld_reg.frmt_50_6=bit +sff_cpld_reg.pola_50_6=negative +sff_cpld_reg.addr_50_6=0x00060074 +sff_cpld_reg.len_50_6=1 +sff_cpld_reg.bit_offset_50_6=1 + +sff_cpld_reg.mode_51_6=config +sff_cpld_reg.src_51_6=cpld +sff_cpld_reg.frmt_51_6=bit +sff_cpld_reg.pola_51_6=negative +sff_cpld_reg.addr_51_6=0x00060074 +sff_cpld_reg.len_51_6=1 +sff_cpld_reg.bit_offset_51_6=2 + +sff_cpld_reg.mode_52_6=config +sff_cpld_reg.src_52_6=cpld +sff_cpld_reg.frmt_52_6=bit +sff_cpld_reg.pola_52_6=negative +sff_cpld_reg.addr_52_6=0x00060074 +sff_cpld_reg.len_52_6=1 +sff_cpld_reg.bit_offset_52_6=3 + +sff_cpld_reg.mode_53_6=config +sff_cpld_reg.src_53_6=cpld +sff_cpld_reg.frmt_53_6=bit +sff_cpld_reg.pola_53_6=negative +sff_cpld_reg.addr_53_6=0x00060074 +sff_cpld_reg.len_53_6=1 +sff_cpld_reg.bit_offset_53_6=4 + +sff_cpld_reg.mode_54_6=config +sff_cpld_reg.src_54_6=cpld +sff_cpld_reg.frmt_54_6=bit +sff_cpld_reg.pola_54_6=negative +sff_cpld_reg.addr_54_6=0x00060074 +sff_cpld_reg.len_54_6=1 +sff_cpld_reg.bit_offset_54_6=5 + +sff_cpld_reg.mode_55_6=config +sff_cpld_reg.src_55_6=cpld +sff_cpld_reg.frmt_55_6=bit +sff_cpld_reg.pola_55_6=negative +sff_cpld_reg.addr_55_6=0x00060074 +sff_cpld_reg.len_55_6=1 +sff_cpld_reg.bit_offset_55_6=6 + +sff_cpld_reg.mode_56_6=config +sff_cpld_reg.src_56_6=cpld +sff_cpld_reg.frmt_56_6=bit +sff_cpld_reg.pola_56_6=negative +sff_cpld_reg.addr_56_6=0x00060074 +sff_cpld_reg.len_56_6=1 +sff_cpld_reg.bit_offset_56_6=7 + +sff_cpld_reg.mode_57_6=config +sff_cpld_reg.src_57_6=cpld +sff_cpld_reg.frmt_57_6=bit +sff_cpld_reg.pola_57_6=negative +sff_cpld_reg.addr_57_6=0x00060073 +sff_cpld_reg.len_57_6=1 +sff_cpld_reg.bit_offset_57_6=0 + +sff_cpld_reg.mode_58_6=config +sff_cpld_reg.src_58_6=cpld +sff_cpld_reg.frmt_58_6=bit +sff_cpld_reg.pola_58_6=negative +sff_cpld_reg.addr_58_6=0x00060073 +sff_cpld_reg.len_58_6=1 +sff_cpld_reg.bit_offset_58_6=1 + +sff_cpld_reg.mode_59_6=config +sff_cpld_reg.src_59_6=cpld +sff_cpld_reg.frmt_59_6=bit +sff_cpld_reg.pola_59_6=negative +sff_cpld_reg.addr_59_6=0x00060073 +sff_cpld_reg.len_59_6=1 +sff_cpld_reg.bit_offset_59_6=2 + +sff_cpld_reg.mode_60_6=config +sff_cpld_reg.src_60_6=cpld +sff_cpld_reg.frmt_60_6=bit +sff_cpld_reg.pola_60_6=negative +sff_cpld_reg.addr_60_6=0x00060073 +sff_cpld_reg.len_60_6=1 +sff_cpld_reg.bit_offset_60_6=3 + +sff_cpld_reg.mode_61_6=config +sff_cpld_reg.src_61_6=cpld +sff_cpld_reg.frmt_61_6=bit +sff_cpld_reg.pola_61_6=negative +sff_cpld_reg.addr_61_6=0x00060073 +sff_cpld_reg.len_61_6=1 +sff_cpld_reg.bit_offset_61_6=4 + +sff_cpld_reg.mode_62_6=config +sff_cpld_reg.src_62_6=cpld +sff_cpld_reg.frmt_62_6=bit +sff_cpld_reg.pola_62_6=negative +sff_cpld_reg.addr_62_6=0x00060073 +sff_cpld_reg.len_62_6=1 +sff_cpld_reg.bit_offset_62_6=5 + +sff_cpld_reg.mode_63_6=config +sff_cpld_reg.src_63_6=cpld +sff_cpld_reg.frmt_63_6=bit +sff_cpld_reg.pola_63_6=negative +sff_cpld_reg.addr_63_6=0x00060073 +sff_cpld_reg.len_63_6=1 +sff_cpld_reg.bit_offset_63_6=6 + +sff_cpld_reg.mode_64_6=config +sff_cpld_reg.src_64_6=cpld +sff_cpld_reg.frmt_64_6=bit +sff_cpld_reg.pola_64_6=negative +sff_cpld_reg.addr_64_6=0x00060073 +sff_cpld_reg.len_64_6=1 +sff_cpld_reg.bit_offset_64_6=7 + +sff_cpld_reg.mode_65_6=config +sff_cpld_reg.src_65_6=cpld +sff_cpld_reg.frmt_65_6=bit +sff_cpld_reg.pola_65_6=negative +sff_cpld_reg.addr_65_6=0x00050071 +sff_cpld_reg.len_65_6=1 +sff_cpld_reg.bit_offset_65_6=6 + +sff_cpld_reg.mode_66_6=config +sff_cpld_reg.src_66_6=cpld +sff_cpld_reg.frmt_66_6=bit +sff_cpld_reg.pola_66_6=negative +sff_cpld_reg.addr_66_6=0x00050071 +sff_cpld_reg.len_66_6=1 +sff_cpld_reg.bit_offset_66_6=7 + +sff_cpld_reg.mode_67_6=config +sff_cpld_reg.src_67_6=cpld +sff_cpld_reg.frmt_67_6=bit +sff_cpld_reg.pola_67_6=negative +sff_cpld_reg.addr_67_6=0x00050070 +sff_cpld_reg.len_67_6=1 +sff_cpld_reg.bit_offset_67_6=0 + +sff_cpld_reg.mode_68_6=config +sff_cpld_reg.src_68_6=cpld +sff_cpld_reg.frmt_68_6=bit +sff_cpld_reg.pola_68_6=negative +sff_cpld_reg.addr_68_6=0x00050070 +sff_cpld_reg.len_68_6=1 +sff_cpld_reg.bit_offset_68_6=1 + +sff_cpld_reg.mode_69_6=config +sff_cpld_reg.src_69_6=cpld +sff_cpld_reg.frmt_69_6=bit +sff_cpld_reg.pola_69_6=negative +sff_cpld_reg.addr_69_6=0x00050070 +sff_cpld_reg.len_69_6=1 +sff_cpld_reg.bit_offset_69_6=2 + +sff_cpld_reg.mode_70_6=config +sff_cpld_reg.src_70_6=cpld +sff_cpld_reg.frmt_70_6=bit +sff_cpld_reg.pola_70_6=negative +sff_cpld_reg.addr_70_6=0x00050070 +sff_cpld_reg.len_70_6=1 +sff_cpld_reg.bit_offset_70_6=3 + +sff_cpld_reg.mode_71_6=config +sff_cpld_reg.src_71_6=cpld +sff_cpld_reg.frmt_71_6=bit +sff_cpld_reg.pola_71_6=negative +sff_cpld_reg.addr_71_6=0x00050070 +sff_cpld_reg.len_71_6=1 +sff_cpld_reg.bit_offset_71_6=4 + +sff_cpld_reg.mode_72_6=config +sff_cpld_reg.src_72_6=cpld +sff_cpld_reg.frmt_72_6=bit +sff_cpld_reg.pola_72_6=negative +sff_cpld_reg.addr_72_6=0x00050070 +sff_cpld_reg.len_72_6=1 +sff_cpld_reg.bit_offset_72_6=5 + +sff_cpld_reg.mode_73_6=config +sff_cpld_reg.src_73_6=cpld +sff_cpld_reg.frmt_73_6=bit +sff_cpld_reg.pola_73_6=negative +sff_cpld_reg.addr_73_6=0x00050070 +sff_cpld_reg.len_73_6=1 +sff_cpld_reg.bit_offset_73_6=6 + +sff_cpld_reg.mode_74_6=config +sff_cpld_reg.src_74_6=cpld +sff_cpld_reg.frmt_74_6=bit +sff_cpld_reg.pola_74_6=negative +sff_cpld_reg.addr_74_6=0x00050070 +sff_cpld_reg.len_74_6=1 +sff_cpld_reg.bit_offset_74_6=7 + +sff_cpld_reg.mode_75_6=config +sff_cpld_reg.src_75_6=cpld +sff_cpld_reg.frmt_75_6=bit +sff_cpld_reg.pola_75_6=negative +sff_cpld_reg.addr_75_6=0x00060072 +sff_cpld_reg.len_75_6=1 +sff_cpld_reg.bit_offset_75_6=0 + +sff_cpld_reg.mode_76_6=config +sff_cpld_reg.src_76_6=cpld +sff_cpld_reg.frmt_76_6=bit +sff_cpld_reg.pola_76_6=negative +sff_cpld_reg.addr_76_6=0x00060072 +sff_cpld_reg.len_76_6=1 +sff_cpld_reg.bit_offset_76_6=1 + +sff_cpld_reg.mode_77_6=config +sff_cpld_reg.src_77_6=cpld +sff_cpld_reg.frmt_77_6=bit +sff_cpld_reg.pola_77_6=negative +sff_cpld_reg.addr_77_6=0x00060072 +sff_cpld_reg.len_77_6=1 +sff_cpld_reg.bit_offset_77_6=2 + +sff_cpld_reg.mode_78_6=config +sff_cpld_reg.src_78_6=cpld +sff_cpld_reg.frmt_78_6=bit +sff_cpld_reg.pola_78_6=negative +sff_cpld_reg.addr_78_6=0x00060072 +sff_cpld_reg.len_78_6=1 +sff_cpld_reg.bit_offset_78_6=3 + +sff_cpld_reg.mode_79_6=config +sff_cpld_reg.src_79_6=cpld +sff_cpld_reg.frmt_79_6=bit +sff_cpld_reg.pola_79_6=negative +sff_cpld_reg.addr_79_6=0x00060072 +sff_cpld_reg.len_79_6=1 +sff_cpld_reg.bit_offset_79_6=4 + +sff_cpld_reg.mode_80_6=config +sff_cpld_reg.src_80_6=cpld +sff_cpld_reg.frmt_80_6=bit +sff_cpld_reg.pola_80_6=negative +sff_cpld_reg.addr_80_6=0x00060072 +sff_cpld_reg.len_80_6=1 +sff_cpld_reg.bit_offset_80_6=5 + +sff_cpld_reg.mode_81_6=config +sff_cpld_reg.src_81_6=cpld +sff_cpld_reg.frmt_81_6=bit +sff_cpld_reg.pola_81_6=negative +sff_cpld_reg.addr_81_6=0x00060071 +sff_cpld_reg.len_81_6=1 +sff_cpld_reg.bit_offset_81_6=0 + +sff_cpld_reg.mode_82_6=config +sff_cpld_reg.src_82_6=cpld +sff_cpld_reg.frmt_82_6=bit +sff_cpld_reg.pola_82_6=negative +sff_cpld_reg.addr_82_6=0x00060071 +sff_cpld_reg.len_82_6=1 +sff_cpld_reg.bit_offset_82_6=1 + +sff_cpld_reg.mode_83_6=config +sff_cpld_reg.src_83_6=cpld +sff_cpld_reg.frmt_83_6=bit +sff_cpld_reg.pola_83_6=negative +sff_cpld_reg.addr_83_6=0x00060071 +sff_cpld_reg.len_83_6=1 +sff_cpld_reg.bit_offset_83_6=2 + +sff_cpld_reg.mode_84_6=config +sff_cpld_reg.src_84_6=cpld +sff_cpld_reg.frmt_84_6=bit +sff_cpld_reg.pola_84_6=negative +sff_cpld_reg.addr_84_6=0x00060071 +sff_cpld_reg.len_84_6=1 +sff_cpld_reg.bit_offset_84_6=3 + +sff_cpld_reg.mode_85_6=config +sff_cpld_reg.src_85_6=cpld +sff_cpld_reg.frmt_85_6=bit +sff_cpld_reg.pola_85_6=negative +sff_cpld_reg.addr_85_6=0x00060071 +sff_cpld_reg.len_85_6=1 +sff_cpld_reg.bit_offset_85_6=4 + +sff_cpld_reg.mode_86_6=config +sff_cpld_reg.src_86_6=cpld +sff_cpld_reg.frmt_86_6=bit +sff_cpld_reg.pola_86_6=negative +sff_cpld_reg.addr_86_6=0x00060071 +sff_cpld_reg.len_86_6=1 +sff_cpld_reg.bit_offset_86_6=5 + +sff_cpld_reg.mode_87_6=config +sff_cpld_reg.src_87_6=cpld +sff_cpld_reg.frmt_87_6=bit +sff_cpld_reg.pola_87_6=negative +sff_cpld_reg.addr_87_6=0x00060071 +sff_cpld_reg.len_87_6=1 +sff_cpld_reg.bit_offset_87_6=6 + +sff_cpld_reg.mode_88_6=config +sff_cpld_reg.src_88_6=cpld +sff_cpld_reg.frmt_88_6=bit +sff_cpld_reg.pola_88_6=negative +sff_cpld_reg.addr_88_6=0x00060071 +sff_cpld_reg.len_88_6=1 +sff_cpld_reg.bit_offset_88_6=7 + +sff_cpld_reg.mode_89_6=config +sff_cpld_reg.src_89_6=cpld +sff_cpld_reg.frmt_89_6=bit +sff_cpld_reg.pola_89_6=negative +sff_cpld_reg.addr_89_6=0x00060070 +sff_cpld_reg.len_89_6=1 +sff_cpld_reg.bit_offset_89_6=0 + +sff_cpld_reg.mode_90_6=config +sff_cpld_reg.src_90_6=cpld +sff_cpld_reg.frmt_90_6=bit +sff_cpld_reg.pola_90_6=negative +sff_cpld_reg.addr_90_6=0x00060070 +sff_cpld_reg.len_90_6=1 +sff_cpld_reg.bit_offset_90_6=1 + +sff_cpld_reg.mode_91_6=config +sff_cpld_reg.src_91_6=cpld +sff_cpld_reg.frmt_91_6=bit +sff_cpld_reg.pola_91_6=negative +sff_cpld_reg.addr_91_6=0x00060070 +sff_cpld_reg.len_91_6=1 +sff_cpld_reg.bit_offset_91_6=2 + +sff_cpld_reg.mode_92_6=config +sff_cpld_reg.src_92_6=cpld +sff_cpld_reg.frmt_92_6=bit +sff_cpld_reg.pola_92_6=negative +sff_cpld_reg.addr_92_6=0x00060070 +sff_cpld_reg.len_92_6=1 +sff_cpld_reg.bit_offset_92_6=3 + +sff_cpld_reg.mode_93_6=config +sff_cpld_reg.src_93_6=cpld +sff_cpld_reg.frmt_93_6=bit +sff_cpld_reg.pola_93_6=negative +sff_cpld_reg.addr_93_6=0x00060070 +sff_cpld_reg.len_93_6=1 +sff_cpld_reg.bit_offset_93_6=4 + +sff_cpld_reg.mode_94_6=config +sff_cpld_reg.src_94_6=cpld +sff_cpld_reg.frmt_94_6=bit +sff_cpld_reg.pola_94_6=negative +sff_cpld_reg.addr_94_6=0x00060070 +sff_cpld_reg.len_94_6=1 +sff_cpld_reg.bit_offset_94_6=5 + +sff_cpld_reg.mode_95_6=config +sff_cpld_reg.src_95_6=cpld +sff_cpld_reg.frmt_95_6=bit +sff_cpld_reg.pola_95_6=negative +sff_cpld_reg.addr_95_6=0x00060070 +sff_cpld_reg.len_95_6=1 +sff_cpld_reg.bit_offset_95_6=6 + +sff_cpld_reg.mode_96_6=config +sff_cpld_reg.src_96_6=cpld +sff_cpld_reg.frmt_96_6=bit +sff_cpld_reg.pola_96_6=negative +sff_cpld_reg.addr_96_6=0x00060070 +sff_cpld_reg.len_96_6=1 +sff_cpld_reg.bit_offset_96_6=7 + +sff_cpld_reg.mode_97_6=config +sff_cpld_reg.src_97_6=cpld +sff_cpld_reg.frmt_97_6=bit +sff_cpld_reg.pola_97_6=negative +sff_cpld_reg.addr_97_6=0x00070073 +sff_cpld_reg.len_97_6=1 +sff_cpld_reg.bit_offset_97_6=0 + +sff_cpld_reg.mode_98_6=config +sff_cpld_reg.src_98_6=cpld +sff_cpld_reg.frmt_98_6=bit +sff_cpld_reg.pola_98_6=negative +sff_cpld_reg.addr_98_6=0x00070073 +sff_cpld_reg.len_98_6=1 +sff_cpld_reg.bit_offset_98_6=1 + +sff_cpld_reg.mode_99_6=config +sff_cpld_reg.src_99_6=cpld +sff_cpld_reg.frmt_99_6=bit +sff_cpld_reg.pola_99_6=negative +sff_cpld_reg.addr_99_6=0x00070073 +sff_cpld_reg.len_99_6=1 +sff_cpld_reg.bit_offset_99_6=2 + +sff_cpld_reg.mode_100_6=config +sff_cpld_reg.src_100_6=cpld +sff_cpld_reg.frmt_100_6=bit +sff_cpld_reg.pola_100_6=negative +sff_cpld_reg.addr_100_6=0x00070073 +sff_cpld_reg.len_100_6=1 +sff_cpld_reg.bit_offset_100_6=3 + +sff_cpld_reg.mode_101_6=config +sff_cpld_reg.src_101_6=cpld +sff_cpld_reg.frmt_101_6=bit +sff_cpld_reg.pola_101_6=negative +sff_cpld_reg.addr_101_6=0x00070073 +sff_cpld_reg.len_101_6=1 +sff_cpld_reg.bit_offset_101_6=4 + +sff_cpld_reg.mode_102_6=config +sff_cpld_reg.src_102_6=cpld +sff_cpld_reg.frmt_102_6=bit +sff_cpld_reg.pola_102_6=negative +sff_cpld_reg.addr_102_6=0x00070073 +sff_cpld_reg.len_102_6=1 +sff_cpld_reg.bit_offset_102_6=5 + +sff_cpld_reg.mode_103_6=config +sff_cpld_reg.src_103_6=cpld +sff_cpld_reg.frmt_103_6=bit +sff_cpld_reg.pola_103_6=negative +sff_cpld_reg.addr_103_6=0x00070073 +sff_cpld_reg.len_103_6=1 +sff_cpld_reg.bit_offset_103_6=6 + +sff_cpld_reg.mode_104_6=config +sff_cpld_reg.src_104_6=cpld +sff_cpld_reg.frmt_104_6=bit +sff_cpld_reg.pola_104_6=negative +sff_cpld_reg.addr_104_6=0x00070073 +sff_cpld_reg.len_104_6=1 +sff_cpld_reg.bit_offset_104_6=7 + +sff_cpld_reg.mode_105_6=config +sff_cpld_reg.src_105_6=cpld +sff_cpld_reg.frmt_105_6=bit +sff_cpld_reg.pola_105_6=negative +sff_cpld_reg.addr_105_6=0x00070072 +sff_cpld_reg.len_105_6=1 +sff_cpld_reg.bit_offset_105_6=0 + +sff_cpld_reg.mode_106_6=config +sff_cpld_reg.src_106_6=cpld +sff_cpld_reg.frmt_106_6=bit +sff_cpld_reg.pola_106_6=negative +sff_cpld_reg.addr_106_6=0x00070072 +sff_cpld_reg.len_106_6=1 +sff_cpld_reg.bit_offset_106_6=1 + +sff_cpld_reg.mode_107_6=config +sff_cpld_reg.src_107_6=cpld +sff_cpld_reg.frmt_107_6=bit +sff_cpld_reg.pola_107_6=negative +sff_cpld_reg.addr_107_6=0x00070072 +sff_cpld_reg.len_107_6=1 +sff_cpld_reg.bit_offset_107_6=2 + +sff_cpld_reg.mode_108_6=config +sff_cpld_reg.src_108_6=cpld +sff_cpld_reg.frmt_108_6=bit +sff_cpld_reg.pola_108_6=negative +sff_cpld_reg.addr_108_6=0x00070072 +sff_cpld_reg.len_108_6=1 +sff_cpld_reg.bit_offset_108_6=3 + +sff_cpld_reg.mode_109_6=config +sff_cpld_reg.src_109_6=cpld +sff_cpld_reg.frmt_109_6=bit +sff_cpld_reg.pola_109_6=negative +sff_cpld_reg.addr_109_6=0x00070072 +sff_cpld_reg.len_109_6=1 +sff_cpld_reg.bit_offset_109_6=4 + +sff_cpld_reg.mode_110_6=config +sff_cpld_reg.src_110_6=cpld +sff_cpld_reg.frmt_110_6=bit +sff_cpld_reg.pola_110_6=negative +sff_cpld_reg.addr_110_6=0x00070072 +sff_cpld_reg.len_110_6=1 +sff_cpld_reg.bit_offset_110_6=5 + +sff_cpld_reg.mode_111_6=config +sff_cpld_reg.src_111_6=cpld +sff_cpld_reg.frmt_111_6=bit +sff_cpld_reg.pola_111_6=negative +sff_cpld_reg.addr_111_6=0x00070072 +sff_cpld_reg.len_111_6=1 +sff_cpld_reg.bit_offset_111_6=6 + +sff_cpld_reg.mode_112_6=config +sff_cpld_reg.src_112_6=cpld +sff_cpld_reg.frmt_112_6=bit +sff_cpld_reg.pola_112_6=negative +sff_cpld_reg.addr_112_6=0x00070072 +sff_cpld_reg.len_112_6=1 +sff_cpld_reg.bit_offset_112_6=7 + +sff_cpld_reg.mode_113_6=config +sff_cpld_reg.src_113_6=cpld +sff_cpld_reg.frmt_113_6=bit +sff_cpld_reg.pola_113_6=negative +sff_cpld_reg.addr_113_6=0x00070071 +sff_cpld_reg.len_113_6=1 +sff_cpld_reg.bit_offset_113_6=0 + +sff_cpld_reg.mode_114_6=config +sff_cpld_reg.src_114_6=cpld +sff_cpld_reg.frmt_114_6=bit +sff_cpld_reg.pola_114_6=negative +sff_cpld_reg.addr_114_6=0x00070071 +sff_cpld_reg.len_114_6=1 +sff_cpld_reg.bit_offset_114_6=1 + +sff_cpld_reg.mode_115_6=config +sff_cpld_reg.src_115_6=cpld +sff_cpld_reg.frmt_115_6=bit +sff_cpld_reg.pola_115_6=negative +sff_cpld_reg.addr_115_6=0x00070071 +sff_cpld_reg.len_115_6=1 +sff_cpld_reg.bit_offset_115_6=2 + +sff_cpld_reg.mode_116_6=config +sff_cpld_reg.src_116_6=cpld +sff_cpld_reg.frmt_116_6=bit +sff_cpld_reg.pola_116_6=negative +sff_cpld_reg.addr_116_6=0x00070071 +sff_cpld_reg.len_116_6=1 +sff_cpld_reg.bit_offset_116_6=3 + +sff_cpld_reg.mode_117_6=config +sff_cpld_reg.src_117_6=cpld +sff_cpld_reg.frmt_117_6=bit +sff_cpld_reg.pola_117_6=negative +sff_cpld_reg.addr_117_6=0x00070071 +sff_cpld_reg.len_117_6=1 +sff_cpld_reg.bit_offset_117_6=4 + +sff_cpld_reg.mode_118_6=config +sff_cpld_reg.src_118_6=cpld +sff_cpld_reg.frmt_118_6=bit +sff_cpld_reg.pola_118_6=negative +sff_cpld_reg.addr_118_6=0x00070071 +sff_cpld_reg.len_118_6=1 +sff_cpld_reg.bit_offset_118_6=5 + +sff_cpld_reg.mode_119_6=config +sff_cpld_reg.src_119_6=cpld +sff_cpld_reg.frmt_119_6=bit +sff_cpld_reg.pola_119_6=negative +sff_cpld_reg.addr_119_6=0x00070071 +sff_cpld_reg.len_119_6=1 +sff_cpld_reg.bit_offset_119_6=6 + +sff_cpld_reg.mode_120_6=config +sff_cpld_reg.src_120_6=cpld +sff_cpld_reg.frmt_120_6=bit +sff_cpld_reg.pola_120_6=negative +sff_cpld_reg.addr_120_6=0x00070071 +sff_cpld_reg.len_120_6=1 +sff_cpld_reg.bit_offset_120_6=7 + +sff_cpld_reg.mode_121_6=config +sff_cpld_reg.src_121_6=cpld +sff_cpld_reg.frmt_121_6=bit +sff_cpld_reg.pola_121_6=negative +sff_cpld_reg.addr_121_6=0x00070070 +sff_cpld_reg.len_121_6=1 +sff_cpld_reg.bit_offset_121_6=0 + +sff_cpld_reg.mode_122_6=config +sff_cpld_reg.src_122_6=cpld +sff_cpld_reg.frmt_122_6=bit +sff_cpld_reg.pola_122_6=negative +sff_cpld_reg.addr_122_6=0x00070070 +sff_cpld_reg.len_122_6=1 +sff_cpld_reg.bit_offset_122_6=1 + +sff_cpld_reg.mode_123_6=config +sff_cpld_reg.src_123_6=cpld +sff_cpld_reg.frmt_123_6=bit +sff_cpld_reg.pola_123_6=negative +sff_cpld_reg.addr_123_6=0x00070070 +sff_cpld_reg.len_123_6=1 +sff_cpld_reg.bit_offset_123_6=2 + +sff_cpld_reg.mode_124_6=config +sff_cpld_reg.src_124_6=cpld +sff_cpld_reg.frmt_124_6=bit +sff_cpld_reg.pola_124_6=negative +sff_cpld_reg.addr_124_6=0x00070070 +sff_cpld_reg.len_124_6=1 +sff_cpld_reg.bit_offset_124_6=3 + +sff_cpld_reg.mode_125_6=config +sff_cpld_reg.src_125_6=cpld +sff_cpld_reg.frmt_125_6=bit +sff_cpld_reg.pola_125_6=negative +sff_cpld_reg.addr_125_6=0x00070070 +sff_cpld_reg.len_125_6=1 +sff_cpld_reg.bit_offset_125_6=4 + +sff_cpld_reg.mode_126_6=config +sff_cpld_reg.src_126_6=cpld +sff_cpld_reg.frmt_126_6=bit +sff_cpld_reg.pola_126_6=negative +sff_cpld_reg.addr_126_6=0x00070070 +sff_cpld_reg.len_126_6=1 +sff_cpld_reg.bit_offset_126_6=5 + +sff_cpld_reg.mode_127_6=config +sff_cpld_reg.src_127_6=cpld +sff_cpld_reg.frmt_127_6=bit +sff_cpld_reg.pola_127_6=negative +sff_cpld_reg.addr_127_6=0x00070070 +sff_cpld_reg.len_127_6=1 +sff_cpld_reg.bit_offset_127_6=6 + +sff_cpld_reg.mode_128_6=config +sff_cpld_reg.src_128_6=cpld +sff_cpld_reg.frmt_128_6=bit +sff_cpld_reg.pola_128_6=negative +sff_cpld_reg.addr_128_6=0x00070070 +sff_cpld_reg.len_128_6=1 +sff_cpld_reg.bit_offset_128_6=7 + +sff_cpld_reg.mode_1_7=config +sff_cpld_reg.src_1_7=cpld +sff_cpld_reg.frmt_1_7=bit +sff_cpld_reg.pola_1_7=positive +sff_cpld_reg.addr_1_7=0x0002007B +sff_cpld_reg.len_1_7=1 +sff_cpld_reg.bit_offset_1_7=0 + +sff_cpld_reg.mode_2_7=config +sff_cpld_reg.src_2_7=cpld +sff_cpld_reg.frmt_2_7=bit +sff_cpld_reg.pola_2_7=positive +sff_cpld_reg.addr_2_7=0x0002007B +sff_cpld_reg.len_2_7=1 +sff_cpld_reg.bit_offset_2_7=1 + +sff_cpld_reg.mode_3_7=config +sff_cpld_reg.src_3_7=cpld +sff_cpld_reg.frmt_3_7=bit +sff_cpld_reg.pola_3_7=positive +sff_cpld_reg.addr_3_7=0x0002007B +sff_cpld_reg.len_3_7=1 +sff_cpld_reg.bit_offset_3_7=2 + +sff_cpld_reg.mode_4_7=config +sff_cpld_reg.src_4_7=cpld +sff_cpld_reg.frmt_4_7=bit +sff_cpld_reg.pola_4_7=positive +sff_cpld_reg.addr_4_7=0x0002007B +sff_cpld_reg.len_4_7=1 +sff_cpld_reg.bit_offset_4_7=3 + +sff_cpld_reg.mode_5_7=config +sff_cpld_reg.src_5_7=cpld +sff_cpld_reg.frmt_5_7=bit +sff_cpld_reg.pola_5_7=positive +sff_cpld_reg.addr_5_7=0x0002007B +sff_cpld_reg.len_5_7=1 +sff_cpld_reg.bit_offset_5_7=4 + +sff_cpld_reg.mode_6_7=config +sff_cpld_reg.src_6_7=cpld +sff_cpld_reg.frmt_6_7=bit +sff_cpld_reg.pola_6_7=positive +sff_cpld_reg.addr_6_7=0x0002007B +sff_cpld_reg.len_6_7=1 +sff_cpld_reg.bit_offset_6_7=5 + +sff_cpld_reg.mode_7_7=config +sff_cpld_reg.src_7_7=cpld +sff_cpld_reg.frmt_7_7=bit +sff_cpld_reg.pola_7_7=positive +sff_cpld_reg.addr_7_7=0x0002007B +sff_cpld_reg.len_7_7=1 +sff_cpld_reg.bit_offset_7_7=6 + +sff_cpld_reg.mode_8_7=config +sff_cpld_reg.src_8_7=cpld +sff_cpld_reg.frmt_8_7=bit +sff_cpld_reg.pola_8_7=positive +sff_cpld_reg.addr_8_7=0x0002007B +sff_cpld_reg.len_8_7=1 +sff_cpld_reg.bit_offset_8_7=7 + +sff_cpld_reg.mode_9_7=config +sff_cpld_reg.src_9_7=cpld +sff_cpld_reg.frmt_9_7=bit +sff_cpld_reg.pola_9_7=positive +sff_cpld_reg.addr_9_7=0x0002007A +sff_cpld_reg.len_9_7=1 +sff_cpld_reg.bit_offset_9_7=0 + +sff_cpld_reg.mode_10_7=config +sff_cpld_reg.src_10_7=cpld +sff_cpld_reg.frmt_10_7=bit +sff_cpld_reg.pola_10_7=positive +sff_cpld_reg.addr_10_7=0x0002007A +sff_cpld_reg.len_10_7=1 +sff_cpld_reg.bit_offset_10_7=1 + +sff_cpld_reg.mode_11_7=config +sff_cpld_reg.src_11_7=cpld +sff_cpld_reg.frmt_11_7=bit +sff_cpld_reg.pola_11_7=positive +sff_cpld_reg.addr_11_7=0x0002007A +sff_cpld_reg.len_11_7=1 +sff_cpld_reg.bit_offset_11_7=2 + +sff_cpld_reg.mode_12_7=config +sff_cpld_reg.src_12_7=cpld +sff_cpld_reg.frmt_12_7=bit +sff_cpld_reg.pola_12_7=positive +sff_cpld_reg.addr_12_7=0x0002007A +sff_cpld_reg.len_12_7=1 +sff_cpld_reg.bit_offset_12_7=3 + +sff_cpld_reg.mode_13_7=config +sff_cpld_reg.src_13_7=cpld +sff_cpld_reg.frmt_13_7=bit +sff_cpld_reg.pola_13_7=positive +sff_cpld_reg.addr_13_7=0x0002007A +sff_cpld_reg.len_13_7=1 +sff_cpld_reg.bit_offset_13_7=4 + +sff_cpld_reg.mode_14_7=config +sff_cpld_reg.src_14_7=cpld +sff_cpld_reg.frmt_14_7=bit +sff_cpld_reg.pola_14_7=positive +sff_cpld_reg.addr_14_7=0x0002007A +sff_cpld_reg.len_14_7=1 +sff_cpld_reg.bit_offset_14_7=5 + +sff_cpld_reg.mode_15_7=config +sff_cpld_reg.src_15_7=cpld +sff_cpld_reg.frmt_15_7=bit +sff_cpld_reg.pola_15_7=positive +sff_cpld_reg.addr_15_7=0x0002007A +sff_cpld_reg.len_15_7=1 +sff_cpld_reg.bit_offset_15_7=6 + +sff_cpld_reg.mode_16_7=config +sff_cpld_reg.src_16_7=cpld +sff_cpld_reg.frmt_16_7=bit +sff_cpld_reg.pola_16_7=positive +sff_cpld_reg.addr_16_7=0x0002007A +sff_cpld_reg.len_16_7=1 +sff_cpld_reg.bit_offset_16_7=7 + +sff_cpld_reg.mode_17_7=config +sff_cpld_reg.src_17_7=cpld +sff_cpld_reg.frmt_17_7=bit +sff_cpld_reg.pola_17_7=positive +sff_cpld_reg.addr_17_7=0x00020079 +sff_cpld_reg.len_17_7=1 +sff_cpld_reg.bit_offset_17_7=0 + +sff_cpld_reg.mode_18_7=config +sff_cpld_reg.src_18_7=cpld +sff_cpld_reg.frmt_18_7=bit +sff_cpld_reg.pola_18_7=positive +sff_cpld_reg.addr_18_7=0x00020079 +sff_cpld_reg.len_18_7=1 +sff_cpld_reg.bit_offset_18_7=1 + +sff_cpld_reg.mode_19_7=config +sff_cpld_reg.src_19_7=cpld +sff_cpld_reg.frmt_19_7=bit +sff_cpld_reg.pola_19_7=positive +sff_cpld_reg.addr_19_7=0x00020079 +sff_cpld_reg.len_19_7=1 +sff_cpld_reg.bit_offset_19_7=2 + +sff_cpld_reg.mode_20_7=config +sff_cpld_reg.src_20_7=cpld +sff_cpld_reg.frmt_20_7=bit +sff_cpld_reg.pola_20_7=positive +sff_cpld_reg.addr_20_7=0x00020079 +sff_cpld_reg.len_20_7=1 +sff_cpld_reg.bit_offset_20_7=3 + +sff_cpld_reg.mode_21_7=config +sff_cpld_reg.src_21_7=cpld +sff_cpld_reg.frmt_21_7=bit +sff_cpld_reg.pola_21_7=positive +sff_cpld_reg.addr_21_7=0x00020079 +sff_cpld_reg.len_21_7=1 +sff_cpld_reg.bit_offset_21_7=4 + +sff_cpld_reg.mode_22_7=config +sff_cpld_reg.src_22_7=cpld +sff_cpld_reg.frmt_22_7=bit +sff_cpld_reg.pola_22_7=positive +sff_cpld_reg.addr_22_7=0x00020079 +sff_cpld_reg.len_22_7=1 +sff_cpld_reg.bit_offset_22_7=5 + +sff_cpld_reg.mode_23_7=config +sff_cpld_reg.src_23_7=cpld +sff_cpld_reg.frmt_23_7=bit +sff_cpld_reg.pola_23_7=positive +sff_cpld_reg.addr_23_7=0x00020079 +sff_cpld_reg.len_23_7=1 +sff_cpld_reg.bit_offset_23_7=6 + +sff_cpld_reg.mode_24_7=config +sff_cpld_reg.src_24_7=cpld +sff_cpld_reg.frmt_24_7=bit +sff_cpld_reg.pola_24_7=positive +sff_cpld_reg.addr_24_7=0x00020079 +sff_cpld_reg.len_24_7=1 +sff_cpld_reg.bit_offset_24_7=7 + +sff_cpld_reg.mode_25_7=config +sff_cpld_reg.src_25_7=cpld +sff_cpld_reg.frmt_25_7=bit +sff_cpld_reg.pola_25_7=positive +sff_cpld_reg.addr_25_7=0x00020078 +sff_cpld_reg.len_25_7=1 +sff_cpld_reg.bit_offset_25_7=0 + +sff_cpld_reg.mode_26_7=config +sff_cpld_reg.src_26_7=cpld +sff_cpld_reg.frmt_26_7=bit +sff_cpld_reg.pola_26_7=positive +sff_cpld_reg.addr_26_7=0x00020078 +sff_cpld_reg.len_26_7=1 +sff_cpld_reg.bit_offset_26_7=1 + +sff_cpld_reg.mode_27_7=config +sff_cpld_reg.src_27_7=cpld +sff_cpld_reg.frmt_27_7=bit +sff_cpld_reg.pola_27_7=positive +sff_cpld_reg.addr_27_7=0x00020078 +sff_cpld_reg.len_27_7=1 +sff_cpld_reg.bit_offset_27_7=2 + +sff_cpld_reg.mode_28_7=config +sff_cpld_reg.src_28_7=cpld +sff_cpld_reg.frmt_28_7=bit +sff_cpld_reg.pola_28_7=positive +sff_cpld_reg.addr_28_7=0x00020078 +sff_cpld_reg.len_28_7=1 +sff_cpld_reg.bit_offset_28_7=3 + +sff_cpld_reg.mode_29_7=config +sff_cpld_reg.src_29_7=cpld +sff_cpld_reg.frmt_29_7=bit +sff_cpld_reg.pola_29_7=positive +sff_cpld_reg.addr_29_7=0x00020078 +sff_cpld_reg.len_29_7=1 +sff_cpld_reg.bit_offset_29_7=4 + +sff_cpld_reg.mode_30_7=config +sff_cpld_reg.src_30_7=cpld +sff_cpld_reg.frmt_30_7=bit +sff_cpld_reg.pola_30_7=positive +sff_cpld_reg.addr_30_7=0x00020078 +sff_cpld_reg.len_30_7=1 +sff_cpld_reg.bit_offset_30_7=5 + +sff_cpld_reg.mode_31_7=config +sff_cpld_reg.src_31_7=cpld +sff_cpld_reg.frmt_31_7=bit +sff_cpld_reg.pola_31_7=positive +sff_cpld_reg.addr_31_7=0x00020078 +sff_cpld_reg.len_31_7=1 +sff_cpld_reg.bit_offset_31_7=6 + +sff_cpld_reg.mode_32_7=config +sff_cpld_reg.src_32_7=cpld +sff_cpld_reg.frmt_32_7=bit +sff_cpld_reg.pola_32_7=positive +sff_cpld_reg.addr_32_7=0x00020078 +sff_cpld_reg.len_32_7=1 +sff_cpld_reg.bit_offset_32_7=7 + +sff_cpld_reg.mode_33_7=config +sff_cpld_reg.src_33_7=cpld +sff_cpld_reg.frmt_33_7=bit +sff_cpld_reg.pola_33_7=positive +sff_cpld_reg.addr_33_7=0x00050078 +sff_cpld_reg.len_33_7=1 +sff_cpld_reg.bit_offset_33_7=0 + +sff_cpld_reg.mode_34_7=config +sff_cpld_reg.src_34_7=cpld +sff_cpld_reg.frmt_34_7=bit +sff_cpld_reg.pola_34_7=positive +sff_cpld_reg.addr_34_7=0x00050078 +sff_cpld_reg.len_34_7=1 +sff_cpld_reg.bit_offset_34_7=1 + +sff_cpld_reg.mode_35_7=config +sff_cpld_reg.src_35_7=cpld +sff_cpld_reg.frmt_35_7=bit +sff_cpld_reg.pola_35_7=positive +sff_cpld_reg.addr_35_7=0x00050078 +sff_cpld_reg.len_35_7=1 +sff_cpld_reg.bit_offset_35_7=2 + +sff_cpld_reg.mode_36_7=config +sff_cpld_reg.src_36_7=cpld +sff_cpld_reg.frmt_36_7=bit +sff_cpld_reg.pola_36_7=positive +sff_cpld_reg.addr_36_7=0x00050078 +sff_cpld_reg.len_36_7=1 +sff_cpld_reg.bit_offset_36_7=3 + +sff_cpld_reg.mode_37_7=config +sff_cpld_reg.src_37_7=cpld +sff_cpld_reg.frmt_37_7=bit +sff_cpld_reg.pola_37_7=positive +sff_cpld_reg.addr_37_7=0x00050077 +sff_cpld_reg.len_37_7=1 +sff_cpld_reg.bit_offset_37_7=0 + +sff_cpld_reg.mode_38_7=config +sff_cpld_reg.src_38_7=cpld +sff_cpld_reg.frmt_38_7=bit +sff_cpld_reg.pola_38_7=positive +sff_cpld_reg.addr_38_7=0x00050077 +sff_cpld_reg.len_38_7=1 +sff_cpld_reg.bit_offset_38_7=1 + +sff_cpld_reg.mode_39_7=config +sff_cpld_reg.src_39_7=cpld +sff_cpld_reg.frmt_39_7=bit +sff_cpld_reg.pola_39_7=positive +sff_cpld_reg.addr_39_7=0x00050077 +sff_cpld_reg.len_39_7=1 +sff_cpld_reg.bit_offset_39_7=2 + +sff_cpld_reg.mode_40_7=config +sff_cpld_reg.src_40_7=cpld +sff_cpld_reg.frmt_40_7=bit +sff_cpld_reg.pola_40_7=positive +sff_cpld_reg.addr_40_7=0x00050077 +sff_cpld_reg.len_40_7=1 +sff_cpld_reg.bit_offset_40_7=3 + +sff_cpld_reg.mode_41_7=config +sff_cpld_reg.src_41_7=cpld +sff_cpld_reg.frmt_41_7=bit +sff_cpld_reg.pola_41_7=positive +sff_cpld_reg.addr_41_7=0x00050077 +sff_cpld_reg.len_41_7=1 +sff_cpld_reg.bit_offset_41_7=4 + +sff_cpld_reg.mode_42_7=config +sff_cpld_reg.src_42_7=cpld +sff_cpld_reg.frmt_42_7=bit +sff_cpld_reg.pola_42_7=positive +sff_cpld_reg.addr_42_7=0x00050077 +sff_cpld_reg.len_42_7=1 +sff_cpld_reg.bit_offset_42_7=5 + +sff_cpld_reg.mode_43_7=config +sff_cpld_reg.src_43_7=cpld +sff_cpld_reg.frmt_43_7=bit +sff_cpld_reg.pola_43_7=positive +sff_cpld_reg.addr_43_7=0x00060085 +sff_cpld_reg.len_43_7=1 +sff_cpld_reg.bit_offset_43_7=0 + +sff_cpld_reg.mode_44_7=config +sff_cpld_reg.src_44_7=cpld +sff_cpld_reg.frmt_44_7=bit +sff_cpld_reg.pola_44_7=positive +sff_cpld_reg.addr_44_7=0x00060085 +sff_cpld_reg.len_44_7=1 +sff_cpld_reg.bit_offset_44_7=1 + +sff_cpld_reg.mode_45_7=config +sff_cpld_reg.src_45_7=cpld +sff_cpld_reg.frmt_45_7=bit +sff_cpld_reg.pola_45_7=positive +sff_cpld_reg.addr_45_7=0x00060085 +sff_cpld_reg.len_45_7=1 +sff_cpld_reg.bit_offset_45_7=2 + +sff_cpld_reg.mode_46_7=config +sff_cpld_reg.src_46_7=cpld +sff_cpld_reg.frmt_46_7=bit +sff_cpld_reg.pola_46_7=positive +sff_cpld_reg.addr_46_7=0x00060085 +sff_cpld_reg.len_46_7=1 +sff_cpld_reg.bit_offset_46_7=3 + +sff_cpld_reg.mode_47_7=config +sff_cpld_reg.src_47_7=cpld +sff_cpld_reg.frmt_47_7=bit +sff_cpld_reg.pola_47_7=positive +sff_cpld_reg.addr_47_7=0x00060085 +sff_cpld_reg.len_47_7=1 +sff_cpld_reg.bit_offset_47_7=4 + +sff_cpld_reg.mode_48_7=config +sff_cpld_reg.src_48_7=cpld +sff_cpld_reg.frmt_48_7=bit +sff_cpld_reg.pola_48_7=positive +sff_cpld_reg.addr_48_7=0x00060085 +sff_cpld_reg.len_48_7=1 +sff_cpld_reg.bit_offset_48_7=5 + +sff_cpld_reg.mode_49_7=config +sff_cpld_reg.src_49_7=cpld +sff_cpld_reg.frmt_49_7=bit +sff_cpld_reg.pola_49_7=positive +sff_cpld_reg.addr_49_7=0x00060084 +sff_cpld_reg.len_49_7=1 +sff_cpld_reg.bit_offset_49_7=0 + +sff_cpld_reg.mode_50_7=config +sff_cpld_reg.src_50_7=cpld +sff_cpld_reg.frmt_50_7=bit +sff_cpld_reg.pola_50_7=positive +sff_cpld_reg.addr_50_7=0x00060084 +sff_cpld_reg.len_50_7=1 +sff_cpld_reg.bit_offset_50_7=1 + +sff_cpld_reg.mode_51_7=config +sff_cpld_reg.src_51_7=cpld +sff_cpld_reg.frmt_51_7=bit +sff_cpld_reg.pola_51_7=positive +sff_cpld_reg.addr_51_7=0x00060084 +sff_cpld_reg.len_51_7=1 +sff_cpld_reg.bit_offset_51_7=2 + +sff_cpld_reg.mode_52_7=config +sff_cpld_reg.src_52_7=cpld +sff_cpld_reg.frmt_52_7=bit +sff_cpld_reg.pola_52_7=positive +sff_cpld_reg.addr_52_7=0x00060084 +sff_cpld_reg.len_52_7=1 +sff_cpld_reg.bit_offset_52_7=3 + +sff_cpld_reg.mode_53_7=config +sff_cpld_reg.src_53_7=cpld +sff_cpld_reg.frmt_53_7=bit +sff_cpld_reg.pola_53_7=positive +sff_cpld_reg.addr_53_7=0x00060084 +sff_cpld_reg.len_53_7=1 +sff_cpld_reg.bit_offset_53_7=4 + +sff_cpld_reg.mode_54_7=config +sff_cpld_reg.src_54_7=cpld +sff_cpld_reg.frmt_54_7=bit +sff_cpld_reg.pola_54_7=positive +sff_cpld_reg.addr_54_7=0x00060084 +sff_cpld_reg.len_54_7=1 +sff_cpld_reg.bit_offset_54_7=5 + +sff_cpld_reg.mode_55_7=config +sff_cpld_reg.src_55_7=cpld +sff_cpld_reg.frmt_55_7=bit +sff_cpld_reg.pola_55_7=positive +sff_cpld_reg.addr_55_7=0x00060084 +sff_cpld_reg.len_55_7=1 +sff_cpld_reg.bit_offset_55_7=6 + +sff_cpld_reg.mode_56_7=config +sff_cpld_reg.src_56_7=cpld +sff_cpld_reg.frmt_56_7=bit +sff_cpld_reg.pola_56_7=positive +sff_cpld_reg.addr_56_7=0x00060084 +sff_cpld_reg.len_56_7=1 +sff_cpld_reg.bit_offset_56_7=7 + +sff_cpld_reg.mode_57_7=config +sff_cpld_reg.src_57_7=cpld +sff_cpld_reg.frmt_57_7=bit +sff_cpld_reg.pola_57_7=positive +sff_cpld_reg.addr_57_7=0x00060083 +sff_cpld_reg.len_57_7=1 +sff_cpld_reg.bit_offset_57_7=0 + +sff_cpld_reg.mode_58_7=config +sff_cpld_reg.src_58_7=cpld +sff_cpld_reg.frmt_58_7=bit +sff_cpld_reg.pola_58_7=positive +sff_cpld_reg.addr_58_7=0x00060083 +sff_cpld_reg.len_58_7=1 +sff_cpld_reg.bit_offset_58_7=1 + +sff_cpld_reg.mode_59_7=config +sff_cpld_reg.src_59_7=cpld +sff_cpld_reg.frmt_59_7=bit +sff_cpld_reg.pola_59_7=positive +sff_cpld_reg.addr_59_7=0x00060083 +sff_cpld_reg.len_59_7=1 +sff_cpld_reg.bit_offset_59_7=2 + +sff_cpld_reg.mode_60_7=config +sff_cpld_reg.src_60_7=cpld +sff_cpld_reg.frmt_60_7=bit +sff_cpld_reg.pola_60_7=positive +sff_cpld_reg.addr_60_7=0x00060083 +sff_cpld_reg.len_60_7=1 +sff_cpld_reg.bit_offset_60_7=3 + +sff_cpld_reg.mode_61_7=config +sff_cpld_reg.src_61_7=cpld +sff_cpld_reg.frmt_61_7=bit +sff_cpld_reg.pola_61_7=positive +sff_cpld_reg.addr_61_7=0x00060083 +sff_cpld_reg.len_61_7=1 +sff_cpld_reg.bit_offset_61_7=4 + +sff_cpld_reg.mode_62_7=config +sff_cpld_reg.src_62_7=cpld +sff_cpld_reg.frmt_62_7=bit +sff_cpld_reg.pola_62_7=positive +sff_cpld_reg.addr_62_7=0x00060083 +sff_cpld_reg.len_62_7=1 +sff_cpld_reg.bit_offset_62_7=5 + +sff_cpld_reg.mode_63_7=config +sff_cpld_reg.src_63_7=cpld +sff_cpld_reg.frmt_63_7=bit +sff_cpld_reg.pola_63_7=positive +sff_cpld_reg.addr_63_7=0x00060083 +sff_cpld_reg.len_63_7=1 +sff_cpld_reg.bit_offset_63_7=6 + +sff_cpld_reg.mode_64_7=config +sff_cpld_reg.src_64_7=cpld +sff_cpld_reg.frmt_64_7=bit +sff_cpld_reg.pola_64_7=positive +sff_cpld_reg.addr_64_7=0x00060083 +sff_cpld_reg.len_64_7=1 +sff_cpld_reg.bit_offset_64_7=7 + +sff_cpld_reg.mode_65_7=config +sff_cpld_reg.src_65_7=cpld +sff_cpld_reg.frmt_65_7=bit +sff_cpld_reg.pola_65_7=positive +sff_cpld_reg.addr_65_7=0x00050077 +sff_cpld_reg.len_65_7=1 +sff_cpld_reg.bit_offset_65_7=6 + +sff_cpld_reg.mode_66_7=config +sff_cpld_reg.src_66_7=cpld +sff_cpld_reg.frmt_66_7=bit +sff_cpld_reg.pola_66_7=positive +sff_cpld_reg.addr_66_7=0x00050077 +sff_cpld_reg.len_66_7=1 +sff_cpld_reg.bit_offset_66_7=7 + +sff_cpld_reg.mode_67_7=config +sff_cpld_reg.src_67_7=cpld +sff_cpld_reg.frmt_67_7=bit +sff_cpld_reg.pola_67_7=positive +sff_cpld_reg.addr_67_7=0x00050076 +sff_cpld_reg.len_67_7=1 +sff_cpld_reg.bit_offset_67_7=0 + +sff_cpld_reg.mode_68_7=config +sff_cpld_reg.src_68_7=cpld +sff_cpld_reg.frmt_68_7=bit +sff_cpld_reg.pola_68_7=positive +sff_cpld_reg.addr_68_7=0x00050076 +sff_cpld_reg.len_68_7=1 +sff_cpld_reg.bit_offset_68_7=1 + +sff_cpld_reg.mode_69_7=config +sff_cpld_reg.src_69_7=cpld +sff_cpld_reg.frmt_69_7=bit +sff_cpld_reg.pola_69_7=positive +sff_cpld_reg.addr_69_7=0x00050076 +sff_cpld_reg.len_69_7=1 +sff_cpld_reg.bit_offset_69_7=2 + +sff_cpld_reg.mode_70_7=config +sff_cpld_reg.src_70_7=cpld +sff_cpld_reg.frmt_70_7=bit +sff_cpld_reg.pola_70_7=positive +sff_cpld_reg.addr_70_7=0x00050076 +sff_cpld_reg.len_70_7=1 +sff_cpld_reg.bit_offset_70_7=3 + +sff_cpld_reg.mode_71_7=config +sff_cpld_reg.src_71_7=cpld +sff_cpld_reg.frmt_71_7=bit +sff_cpld_reg.pola_71_7=positive +sff_cpld_reg.addr_71_7=0x00050076 +sff_cpld_reg.len_71_7=1 +sff_cpld_reg.bit_offset_71_7=4 + +sff_cpld_reg.mode_72_7=config +sff_cpld_reg.src_72_7=cpld +sff_cpld_reg.frmt_72_7=bit +sff_cpld_reg.pola_72_7=positive +sff_cpld_reg.addr_72_7=0x00050076 +sff_cpld_reg.len_72_7=1 +sff_cpld_reg.bit_offset_72_7=5 + +sff_cpld_reg.mode_73_7=config +sff_cpld_reg.src_73_7=cpld +sff_cpld_reg.frmt_73_7=bit +sff_cpld_reg.pola_73_7=positive +sff_cpld_reg.addr_73_7=0x00050076 +sff_cpld_reg.len_73_7=1 +sff_cpld_reg.bit_offset_73_7=6 + +sff_cpld_reg.mode_74_7=config +sff_cpld_reg.src_74_7=cpld +sff_cpld_reg.frmt_74_7=bit +sff_cpld_reg.pola_74_7=positive +sff_cpld_reg.addr_74_7=0x00050076 +sff_cpld_reg.len_74_7=1 +sff_cpld_reg.bit_offset_74_7=7 + +sff_cpld_reg.mode_75_7=config +sff_cpld_reg.src_75_7=cpld +sff_cpld_reg.frmt_75_7=bit +sff_cpld_reg.pola_75_7=positive +sff_cpld_reg.addr_75_7=0x00060082 +sff_cpld_reg.len_75_7=1 +sff_cpld_reg.bit_offset_75_7=0 + +sff_cpld_reg.mode_76_7=config +sff_cpld_reg.src_76_7=cpld +sff_cpld_reg.frmt_76_7=bit +sff_cpld_reg.pola_76_7=positive +sff_cpld_reg.addr_76_7=0x00060082 +sff_cpld_reg.len_76_7=1 +sff_cpld_reg.bit_offset_76_7=1 + +sff_cpld_reg.mode_77_7=config +sff_cpld_reg.src_77_7=cpld +sff_cpld_reg.frmt_77_7=bit +sff_cpld_reg.pola_77_7=positive +sff_cpld_reg.addr_77_7=0x00060082 +sff_cpld_reg.len_77_7=1 +sff_cpld_reg.bit_offset_77_7=2 + +sff_cpld_reg.mode_78_7=config +sff_cpld_reg.src_78_7=cpld +sff_cpld_reg.frmt_78_7=bit +sff_cpld_reg.pola_78_7=positive +sff_cpld_reg.addr_78_7=0x00060082 +sff_cpld_reg.len_78_7=1 +sff_cpld_reg.bit_offset_78_7=3 + +sff_cpld_reg.mode_79_7=config +sff_cpld_reg.src_79_7=cpld +sff_cpld_reg.frmt_79_7=bit +sff_cpld_reg.pola_79_7=positive +sff_cpld_reg.addr_79_7=0x00060082 +sff_cpld_reg.len_79_7=1 +sff_cpld_reg.bit_offset_79_7=4 + +sff_cpld_reg.mode_80_7=config +sff_cpld_reg.src_80_7=cpld +sff_cpld_reg.frmt_80_7=bit +sff_cpld_reg.pola_80_7=positive +sff_cpld_reg.addr_80_7=0x00060082 +sff_cpld_reg.len_80_7=1 +sff_cpld_reg.bit_offset_80_7=5 + +sff_cpld_reg.mode_81_7=config +sff_cpld_reg.src_81_7=cpld +sff_cpld_reg.frmt_81_7=bit +sff_cpld_reg.pola_81_7=positive +sff_cpld_reg.addr_81_7=0x00060081 +sff_cpld_reg.len_81_7=1 +sff_cpld_reg.bit_offset_81_7=0 + +sff_cpld_reg.mode_82_7=config +sff_cpld_reg.src_82_7=cpld +sff_cpld_reg.frmt_82_7=bit +sff_cpld_reg.pola_82_7=positive +sff_cpld_reg.addr_82_7=0x00060081 +sff_cpld_reg.len_82_7=1 +sff_cpld_reg.bit_offset_82_7=1 + +sff_cpld_reg.mode_83_7=config +sff_cpld_reg.src_83_7=cpld +sff_cpld_reg.frmt_83_7=bit +sff_cpld_reg.pola_83_7=positive +sff_cpld_reg.addr_83_7=0x00060081 +sff_cpld_reg.len_83_7=1 +sff_cpld_reg.bit_offset_83_7=2 + +sff_cpld_reg.mode_84_7=config +sff_cpld_reg.src_84_7=cpld +sff_cpld_reg.frmt_84_7=bit +sff_cpld_reg.pola_84_7=positive +sff_cpld_reg.addr_84_7=0x00060081 +sff_cpld_reg.len_84_7=1 +sff_cpld_reg.bit_offset_84_7=3 + +sff_cpld_reg.mode_85_7=config +sff_cpld_reg.src_85_7=cpld +sff_cpld_reg.frmt_85_7=bit +sff_cpld_reg.pola_85_7=positive +sff_cpld_reg.addr_85_7=0x00060081 +sff_cpld_reg.len_85_7=1 +sff_cpld_reg.bit_offset_85_7=4 + +sff_cpld_reg.mode_86_7=config +sff_cpld_reg.src_86_7=cpld +sff_cpld_reg.frmt_86_7=bit +sff_cpld_reg.pola_86_7=positive +sff_cpld_reg.addr_86_7=0x00060081 +sff_cpld_reg.len_86_7=1 +sff_cpld_reg.bit_offset_86_7=5 + +sff_cpld_reg.mode_87_7=config +sff_cpld_reg.src_87_7=cpld +sff_cpld_reg.frmt_87_7=bit +sff_cpld_reg.pola_87_7=positive +sff_cpld_reg.addr_87_7=0x00060081 +sff_cpld_reg.len_87_7=1 +sff_cpld_reg.bit_offset_87_7=6 + +sff_cpld_reg.mode_88_7=config +sff_cpld_reg.src_88_7=cpld +sff_cpld_reg.frmt_88_7=bit +sff_cpld_reg.pola_88_7=positive +sff_cpld_reg.addr_88_7=0x00060081 +sff_cpld_reg.len_88_7=1 +sff_cpld_reg.bit_offset_88_7=7 + +sff_cpld_reg.mode_89_7=config +sff_cpld_reg.src_89_7=cpld +sff_cpld_reg.frmt_89_7=bit +sff_cpld_reg.pola_89_7=positive +sff_cpld_reg.addr_89_7=0x00060080 +sff_cpld_reg.len_89_7=1 +sff_cpld_reg.bit_offset_89_7=0 + +sff_cpld_reg.mode_90_7=config +sff_cpld_reg.src_90_7=cpld +sff_cpld_reg.frmt_90_7=bit +sff_cpld_reg.pola_90_7=positive +sff_cpld_reg.addr_90_7=0x00060080 +sff_cpld_reg.len_90_7=1 +sff_cpld_reg.bit_offset_90_7=1 + +sff_cpld_reg.mode_91_7=config +sff_cpld_reg.src_91_7=cpld +sff_cpld_reg.frmt_91_7=bit +sff_cpld_reg.pola_91_7=positive +sff_cpld_reg.addr_91_7=0x00060080 +sff_cpld_reg.len_91_7=1 +sff_cpld_reg.bit_offset_91_7=2 + +sff_cpld_reg.mode_92_7=config +sff_cpld_reg.src_92_7=cpld +sff_cpld_reg.frmt_92_7=bit +sff_cpld_reg.pola_92_7=positive +sff_cpld_reg.addr_92_7=0x00060080 +sff_cpld_reg.len_92_7=1 +sff_cpld_reg.bit_offset_92_7=3 + +sff_cpld_reg.mode_93_7=config +sff_cpld_reg.src_93_7=cpld +sff_cpld_reg.frmt_93_7=bit +sff_cpld_reg.pola_93_7=positive +sff_cpld_reg.addr_93_7=0x00060080 +sff_cpld_reg.len_93_7=1 +sff_cpld_reg.bit_offset_93_7=4 + +sff_cpld_reg.mode_94_7=config +sff_cpld_reg.src_94_7=cpld +sff_cpld_reg.frmt_94_7=bit +sff_cpld_reg.pola_94_7=positive +sff_cpld_reg.addr_94_7=0x00060080 +sff_cpld_reg.len_94_7=1 +sff_cpld_reg.bit_offset_94_7=5 + +sff_cpld_reg.mode_95_7=config +sff_cpld_reg.src_95_7=cpld +sff_cpld_reg.frmt_95_7=bit +sff_cpld_reg.pola_95_7=positive +sff_cpld_reg.addr_95_7=0x00060080 +sff_cpld_reg.len_95_7=1 +sff_cpld_reg.bit_offset_95_7=6 + +sff_cpld_reg.mode_96_7=config +sff_cpld_reg.src_96_7=cpld +sff_cpld_reg.frmt_96_7=bit +sff_cpld_reg.pola_96_7=positive +sff_cpld_reg.addr_96_7=0x00060080 +sff_cpld_reg.len_96_7=1 +sff_cpld_reg.bit_offset_96_7=7 + +sff_cpld_reg.mode_97_7=config +sff_cpld_reg.src_97_7=cpld +sff_cpld_reg.frmt_97_7=bit +sff_cpld_reg.pola_97_7=positive +sff_cpld_reg.addr_97_7=0x0007007B +sff_cpld_reg.len_97_7=1 +sff_cpld_reg.bit_offset_97_7=0 + +sff_cpld_reg.mode_98_7=config +sff_cpld_reg.src_98_7=cpld +sff_cpld_reg.frmt_98_7=bit +sff_cpld_reg.pola_98_7=positive +sff_cpld_reg.addr_98_7=0x0007007B +sff_cpld_reg.len_98_7=1 +sff_cpld_reg.bit_offset_98_7=1 + +sff_cpld_reg.mode_99_7=config +sff_cpld_reg.src_99_7=cpld +sff_cpld_reg.frmt_99_7=bit +sff_cpld_reg.pola_99_7=positive +sff_cpld_reg.addr_99_7=0x0007007B +sff_cpld_reg.len_99_7=1 +sff_cpld_reg.bit_offset_99_7=2 + +sff_cpld_reg.mode_100_7=config +sff_cpld_reg.src_100_7=cpld +sff_cpld_reg.frmt_100_7=bit +sff_cpld_reg.pola_100_7=positive +sff_cpld_reg.addr_100_7=0x0007007B +sff_cpld_reg.len_100_7=1 +sff_cpld_reg.bit_offset_100_7=3 + +sff_cpld_reg.mode_101_7=config +sff_cpld_reg.src_101_7=cpld +sff_cpld_reg.frmt_101_7=bit +sff_cpld_reg.pola_101_7=positive +sff_cpld_reg.addr_101_7=0x0007007B +sff_cpld_reg.len_101_7=1 +sff_cpld_reg.bit_offset_101_7=4 + +sff_cpld_reg.mode_102_7=config +sff_cpld_reg.src_102_7=cpld +sff_cpld_reg.frmt_102_7=bit +sff_cpld_reg.pola_102_7=positive +sff_cpld_reg.addr_102_7=0x0007007B +sff_cpld_reg.len_102_7=1 +sff_cpld_reg.bit_offset_102_7=5 + +sff_cpld_reg.mode_103_7=config +sff_cpld_reg.src_103_7=cpld +sff_cpld_reg.frmt_103_7=bit +sff_cpld_reg.pola_103_7=positive +sff_cpld_reg.addr_103_7=0x0007007B +sff_cpld_reg.len_103_7=1 +sff_cpld_reg.bit_offset_103_7=6 + +sff_cpld_reg.mode_104_7=config +sff_cpld_reg.src_104_7=cpld +sff_cpld_reg.frmt_104_7=bit +sff_cpld_reg.pola_104_7=positive +sff_cpld_reg.addr_104_7=0x0007007B +sff_cpld_reg.len_104_7=1 +sff_cpld_reg.bit_offset_104_7=7 + +sff_cpld_reg.mode_105_7=config +sff_cpld_reg.src_105_7=cpld +sff_cpld_reg.frmt_105_7=bit +sff_cpld_reg.pola_105_7=positive +sff_cpld_reg.addr_105_7=0x0007007A +sff_cpld_reg.len_105_7=1 +sff_cpld_reg.bit_offset_105_7=0 + +sff_cpld_reg.mode_106_7=config +sff_cpld_reg.src_106_7=cpld +sff_cpld_reg.frmt_106_7=bit +sff_cpld_reg.pola_106_7=positive +sff_cpld_reg.addr_106_7=0x0007007A +sff_cpld_reg.len_106_7=1 +sff_cpld_reg.bit_offset_106_7=1 + +sff_cpld_reg.mode_107_7=config +sff_cpld_reg.src_107_7=cpld +sff_cpld_reg.frmt_107_7=bit +sff_cpld_reg.pola_107_7=positive +sff_cpld_reg.addr_107_7=0x0007007A +sff_cpld_reg.len_107_7=1 +sff_cpld_reg.bit_offset_107_7=2 + +sff_cpld_reg.mode_108_7=config +sff_cpld_reg.src_108_7=cpld +sff_cpld_reg.frmt_108_7=bit +sff_cpld_reg.pola_108_7=positive +sff_cpld_reg.addr_108_7=0x0007007A +sff_cpld_reg.len_108_7=1 +sff_cpld_reg.bit_offset_108_7=3 + +sff_cpld_reg.mode_109_7=config +sff_cpld_reg.src_109_7=cpld +sff_cpld_reg.frmt_109_7=bit +sff_cpld_reg.pola_109_7=positive +sff_cpld_reg.addr_109_7=0x0007007A +sff_cpld_reg.len_109_7=1 +sff_cpld_reg.bit_offset_109_7=4 + +sff_cpld_reg.mode_110_7=config +sff_cpld_reg.src_110_7=cpld +sff_cpld_reg.frmt_110_7=bit +sff_cpld_reg.pola_110_7=positive +sff_cpld_reg.addr_110_7=0x0007007A +sff_cpld_reg.len_110_7=1 +sff_cpld_reg.bit_offset_110_7=5 + +sff_cpld_reg.mode_111_7=config +sff_cpld_reg.src_111_7=cpld +sff_cpld_reg.frmt_111_7=bit +sff_cpld_reg.pola_111_7=positive +sff_cpld_reg.addr_111_7=0x0007007A +sff_cpld_reg.len_111_7=1 +sff_cpld_reg.bit_offset_111_7=6 + +sff_cpld_reg.mode_112_7=config +sff_cpld_reg.src_112_7=cpld +sff_cpld_reg.frmt_112_7=bit +sff_cpld_reg.pola_112_7=positive +sff_cpld_reg.addr_112_7=0x0007007A +sff_cpld_reg.len_112_7=1 +sff_cpld_reg.bit_offset_112_7=7 + +sff_cpld_reg.mode_113_7=config +sff_cpld_reg.src_113_7=cpld +sff_cpld_reg.frmt_113_7=bit +sff_cpld_reg.pola_113_7=positive +sff_cpld_reg.addr_113_7=0x00070079 +sff_cpld_reg.len_113_7=1 +sff_cpld_reg.bit_offset_113_7=0 + +sff_cpld_reg.mode_114_7=config +sff_cpld_reg.src_114_7=cpld +sff_cpld_reg.frmt_114_7=bit +sff_cpld_reg.pola_114_7=positive +sff_cpld_reg.addr_114_7=0x00070079 +sff_cpld_reg.len_114_7=1 +sff_cpld_reg.bit_offset_114_7=1 + +sff_cpld_reg.mode_115_7=config +sff_cpld_reg.src_115_7=cpld +sff_cpld_reg.frmt_115_7=bit +sff_cpld_reg.pola_115_7=positive +sff_cpld_reg.addr_115_7=0x00070079 +sff_cpld_reg.len_115_7=1 +sff_cpld_reg.bit_offset_115_7=2 + +sff_cpld_reg.mode_116_7=config +sff_cpld_reg.src_116_7=cpld +sff_cpld_reg.frmt_116_7=bit +sff_cpld_reg.pola_116_7=positive +sff_cpld_reg.addr_116_7=0x00070079 +sff_cpld_reg.len_116_7=1 +sff_cpld_reg.bit_offset_116_7=3 + +sff_cpld_reg.mode_117_7=config +sff_cpld_reg.src_117_7=cpld +sff_cpld_reg.frmt_117_7=bit +sff_cpld_reg.pola_117_7=positive +sff_cpld_reg.addr_117_7=0x00070079 +sff_cpld_reg.len_117_7=1 +sff_cpld_reg.bit_offset_117_7=4 + +sff_cpld_reg.mode_118_7=config +sff_cpld_reg.src_118_7=cpld +sff_cpld_reg.frmt_118_7=bit +sff_cpld_reg.pola_118_7=positive +sff_cpld_reg.addr_118_7=0x00070079 +sff_cpld_reg.len_118_7=1 +sff_cpld_reg.bit_offset_118_7=5 + +sff_cpld_reg.mode_119_7=config +sff_cpld_reg.src_119_7=cpld +sff_cpld_reg.frmt_119_7=bit +sff_cpld_reg.pola_119_7=positive +sff_cpld_reg.addr_119_7=0x00070079 +sff_cpld_reg.len_119_7=1 +sff_cpld_reg.bit_offset_119_7=6 + +sff_cpld_reg.mode_120_7=config +sff_cpld_reg.src_120_7=cpld +sff_cpld_reg.frmt_120_7=bit +sff_cpld_reg.pola_120_7=positive +sff_cpld_reg.addr_120_7=0x00070079 +sff_cpld_reg.len_120_7=1 +sff_cpld_reg.bit_offset_120_7=7 + +sff_cpld_reg.mode_121_7=config +sff_cpld_reg.src_121_7=cpld +sff_cpld_reg.frmt_121_7=bit +sff_cpld_reg.pola_121_7=positive +sff_cpld_reg.addr_121_7=0x00070078 +sff_cpld_reg.len_121_7=1 +sff_cpld_reg.bit_offset_121_7=0 + +sff_cpld_reg.mode_122_7=config +sff_cpld_reg.src_122_7=cpld +sff_cpld_reg.frmt_122_7=bit +sff_cpld_reg.pola_122_7=positive +sff_cpld_reg.addr_122_7=0x00070078 +sff_cpld_reg.len_122_7=1 +sff_cpld_reg.bit_offset_122_7=1 + +sff_cpld_reg.mode_123_7=config +sff_cpld_reg.src_123_7=cpld +sff_cpld_reg.frmt_123_7=bit +sff_cpld_reg.pola_123_7=positive +sff_cpld_reg.addr_123_7=0x00070078 +sff_cpld_reg.len_123_7=1 +sff_cpld_reg.bit_offset_123_7=2 + +sff_cpld_reg.mode_124_7=config +sff_cpld_reg.src_124_7=cpld +sff_cpld_reg.frmt_124_7=bit +sff_cpld_reg.pola_124_7=positive +sff_cpld_reg.addr_124_7=0x00070078 +sff_cpld_reg.len_124_7=1 +sff_cpld_reg.bit_offset_124_7=3 + +sff_cpld_reg.mode_125_7=config +sff_cpld_reg.src_125_7=cpld +sff_cpld_reg.frmt_125_7=bit +sff_cpld_reg.pola_125_7=positive +sff_cpld_reg.addr_125_7=0x00070078 +sff_cpld_reg.len_125_7=1 +sff_cpld_reg.bit_offset_125_7=4 + +sff_cpld_reg.mode_126_7=config +sff_cpld_reg.src_126_7=cpld +sff_cpld_reg.frmt_126_7=bit +sff_cpld_reg.pola_126_7=positive +sff_cpld_reg.addr_126_7=0x00070078 +sff_cpld_reg.len_126_7=1 +sff_cpld_reg.bit_offset_126_7=5 + +sff_cpld_reg.mode_127_7=config +sff_cpld_reg.src_127_7=cpld +sff_cpld_reg.frmt_127_7=bit +sff_cpld_reg.pola_127_7=positive +sff_cpld_reg.addr_127_7=0x00070078 +sff_cpld_reg.len_127_7=1 +sff_cpld_reg.bit_offset_127_7=6 + +sff_cpld_reg.mode_128_7=config +sff_cpld_reg.src_128_7=cpld +sff_cpld_reg.frmt_128_7=bit +sff_cpld_reg.pola_128_7=positive +sff_cpld_reg.addr_128_7=0x00070078 +sff_cpld_reg.len_128_7=1 +sff_cpld_reg.bit_offset_128_7=7 + +sff_cpld_reg.mode_1_8=config +sff_cpld_reg.src_1_8=cpld +sff_cpld_reg.frmt_1_8=bit +sff_cpld_reg.pola_1_8=negative +sff_cpld_reg.addr_1_8=0x00020077 +sff_cpld_reg.len_1_8=1 +sff_cpld_reg.bit_offset_1_8=0 + +sff_cpld_reg.mode_2_8=config +sff_cpld_reg.src_2_8=cpld +sff_cpld_reg.frmt_2_8=bit +sff_cpld_reg.pola_2_8=negative +sff_cpld_reg.addr_2_8=0x00020077 +sff_cpld_reg.len_2_8=1 +sff_cpld_reg.bit_offset_2_8=1 + +sff_cpld_reg.mode_3_8=config +sff_cpld_reg.src_3_8=cpld +sff_cpld_reg.frmt_3_8=bit +sff_cpld_reg.pola_3_8=negative +sff_cpld_reg.addr_3_8=0x00020077 +sff_cpld_reg.len_3_8=1 +sff_cpld_reg.bit_offset_3_8=2 + +sff_cpld_reg.mode_4_8=config +sff_cpld_reg.src_4_8=cpld +sff_cpld_reg.frmt_4_8=bit +sff_cpld_reg.pola_4_8=negative +sff_cpld_reg.addr_4_8=0x00020077 +sff_cpld_reg.len_4_8=1 +sff_cpld_reg.bit_offset_4_8=3 + +sff_cpld_reg.mode_5_8=config +sff_cpld_reg.src_5_8=cpld +sff_cpld_reg.frmt_5_8=bit +sff_cpld_reg.pola_5_8=negative +sff_cpld_reg.addr_5_8=0x00020077 +sff_cpld_reg.len_5_8=1 +sff_cpld_reg.bit_offset_5_8=4 + +sff_cpld_reg.mode_6_8=config +sff_cpld_reg.src_6_8=cpld +sff_cpld_reg.frmt_6_8=bit +sff_cpld_reg.pola_6_8=negative +sff_cpld_reg.addr_6_8=0x00020077 +sff_cpld_reg.len_6_8=1 +sff_cpld_reg.bit_offset_6_8=5 + +sff_cpld_reg.mode_7_8=config +sff_cpld_reg.src_7_8=cpld +sff_cpld_reg.frmt_7_8=bit +sff_cpld_reg.pola_7_8=negative +sff_cpld_reg.addr_7_8=0x00020077 +sff_cpld_reg.len_7_8=1 +sff_cpld_reg.bit_offset_7_8=6 + +sff_cpld_reg.mode_8_8=config +sff_cpld_reg.src_8_8=cpld +sff_cpld_reg.frmt_8_8=bit +sff_cpld_reg.pola_8_8=negative +sff_cpld_reg.addr_8_8=0x00020077 +sff_cpld_reg.len_8_8=1 +sff_cpld_reg.bit_offset_8_8=7 + +sff_cpld_reg.mode_9_8=config +sff_cpld_reg.src_9_8=cpld +sff_cpld_reg.frmt_9_8=bit +sff_cpld_reg.pola_9_8=negative +sff_cpld_reg.addr_9_8=0x00020076 +sff_cpld_reg.len_9_8=1 +sff_cpld_reg.bit_offset_9_8=0 + +sff_cpld_reg.mode_10_8=config +sff_cpld_reg.src_10_8=cpld +sff_cpld_reg.frmt_10_8=bit +sff_cpld_reg.pola_10_8=negative +sff_cpld_reg.addr_10_8=0x00020076 +sff_cpld_reg.len_10_8=1 +sff_cpld_reg.bit_offset_10_8=1 + +sff_cpld_reg.mode_11_8=config +sff_cpld_reg.src_11_8=cpld +sff_cpld_reg.frmt_11_8=bit +sff_cpld_reg.pola_11_8=negative +sff_cpld_reg.addr_11_8=0x00020076 +sff_cpld_reg.len_11_8=1 +sff_cpld_reg.bit_offset_11_8=2 + +sff_cpld_reg.mode_12_8=config +sff_cpld_reg.src_12_8=cpld +sff_cpld_reg.frmt_12_8=bit +sff_cpld_reg.pola_12_8=negative +sff_cpld_reg.addr_12_8=0x00020076 +sff_cpld_reg.len_12_8=1 +sff_cpld_reg.bit_offset_12_8=3 + +sff_cpld_reg.mode_13_8=config +sff_cpld_reg.src_13_8=cpld +sff_cpld_reg.frmt_13_8=bit +sff_cpld_reg.pola_13_8=negative +sff_cpld_reg.addr_13_8=0x00020076 +sff_cpld_reg.len_13_8=1 +sff_cpld_reg.bit_offset_13_8=4 + +sff_cpld_reg.mode_14_8=config +sff_cpld_reg.src_14_8=cpld +sff_cpld_reg.frmt_14_8=bit +sff_cpld_reg.pola_14_8=negative +sff_cpld_reg.addr_14_8=0x00020076 +sff_cpld_reg.len_14_8=1 +sff_cpld_reg.bit_offset_14_8=5 + +sff_cpld_reg.mode_15_8=config +sff_cpld_reg.src_15_8=cpld +sff_cpld_reg.frmt_15_8=bit +sff_cpld_reg.pola_15_8=negative +sff_cpld_reg.addr_15_8=0x00020076 +sff_cpld_reg.len_15_8=1 +sff_cpld_reg.bit_offset_15_8=6 + +sff_cpld_reg.mode_16_8=config +sff_cpld_reg.src_16_8=cpld +sff_cpld_reg.frmt_16_8=bit +sff_cpld_reg.pola_16_8=negative +sff_cpld_reg.addr_16_8=0x00020076 +sff_cpld_reg.len_16_8=1 +sff_cpld_reg.bit_offset_16_8=7 + +sff_cpld_reg.mode_17_8=config +sff_cpld_reg.src_17_8=cpld +sff_cpld_reg.frmt_17_8=bit +sff_cpld_reg.pola_17_8=negative +sff_cpld_reg.addr_17_8=0x00020075 +sff_cpld_reg.len_17_8=1 +sff_cpld_reg.bit_offset_17_8=0 + +sff_cpld_reg.mode_18_8=config +sff_cpld_reg.src_18_8=cpld +sff_cpld_reg.frmt_18_8=bit +sff_cpld_reg.pola_18_8=negative +sff_cpld_reg.addr_18_8=0x00020075 +sff_cpld_reg.len_18_8=1 +sff_cpld_reg.bit_offset_18_8=1 + +sff_cpld_reg.mode_19_8=config +sff_cpld_reg.src_19_8=cpld +sff_cpld_reg.frmt_19_8=bit +sff_cpld_reg.pola_19_8=negative +sff_cpld_reg.addr_19_8=0x00020075 +sff_cpld_reg.len_19_8=1 +sff_cpld_reg.bit_offset_19_8=2 + +sff_cpld_reg.mode_20_8=config +sff_cpld_reg.src_20_8=cpld +sff_cpld_reg.frmt_20_8=bit +sff_cpld_reg.pola_20_8=negative +sff_cpld_reg.addr_20_8=0x00020075 +sff_cpld_reg.len_20_8=1 +sff_cpld_reg.bit_offset_20_8=3 + +sff_cpld_reg.mode_21_8=config +sff_cpld_reg.src_21_8=cpld +sff_cpld_reg.frmt_21_8=bit +sff_cpld_reg.pola_21_8=negative +sff_cpld_reg.addr_21_8=0x00020075 +sff_cpld_reg.len_21_8=1 +sff_cpld_reg.bit_offset_21_8=4 + +sff_cpld_reg.mode_22_8=config +sff_cpld_reg.src_22_8=cpld +sff_cpld_reg.frmt_22_8=bit +sff_cpld_reg.pola_22_8=negative +sff_cpld_reg.addr_22_8=0x00020075 +sff_cpld_reg.len_22_8=1 +sff_cpld_reg.bit_offset_22_8=5 + +sff_cpld_reg.mode_23_8=config +sff_cpld_reg.src_23_8=cpld +sff_cpld_reg.frmt_23_8=bit +sff_cpld_reg.pola_23_8=negative +sff_cpld_reg.addr_23_8=0x00020075 +sff_cpld_reg.len_23_8=1 +sff_cpld_reg.bit_offset_23_8=6 + +sff_cpld_reg.mode_24_8=config +sff_cpld_reg.src_24_8=cpld +sff_cpld_reg.frmt_24_8=bit +sff_cpld_reg.pola_24_8=negative +sff_cpld_reg.addr_24_8=0x00020075 +sff_cpld_reg.len_24_8=1 +sff_cpld_reg.bit_offset_24_8=7 + +sff_cpld_reg.mode_25_8=config +sff_cpld_reg.src_25_8=cpld +sff_cpld_reg.frmt_25_8=bit +sff_cpld_reg.pola_25_8=negative +sff_cpld_reg.addr_25_8=0x00020074 +sff_cpld_reg.len_25_8=1 +sff_cpld_reg.bit_offset_25_8=0 + +sff_cpld_reg.mode_26_8=config +sff_cpld_reg.src_26_8=cpld +sff_cpld_reg.frmt_26_8=bit +sff_cpld_reg.pola_26_8=negative +sff_cpld_reg.addr_26_8=0x00020074 +sff_cpld_reg.len_26_8=1 +sff_cpld_reg.bit_offset_26_8=1 + +sff_cpld_reg.mode_27_8=config +sff_cpld_reg.src_27_8=cpld +sff_cpld_reg.frmt_27_8=bit +sff_cpld_reg.pola_27_8=negative +sff_cpld_reg.addr_27_8=0x00020074 +sff_cpld_reg.len_27_8=1 +sff_cpld_reg.bit_offset_27_8=2 + +sff_cpld_reg.mode_28_8=config +sff_cpld_reg.src_28_8=cpld +sff_cpld_reg.frmt_28_8=bit +sff_cpld_reg.pola_28_8=negative +sff_cpld_reg.addr_28_8=0x00020074 +sff_cpld_reg.len_28_8=1 +sff_cpld_reg.bit_offset_28_8=3 + +sff_cpld_reg.mode_29_8=config +sff_cpld_reg.src_29_8=cpld +sff_cpld_reg.frmt_29_8=bit +sff_cpld_reg.pola_29_8=negative +sff_cpld_reg.addr_29_8=0x00020074 +sff_cpld_reg.len_29_8=1 +sff_cpld_reg.bit_offset_29_8=4 + +sff_cpld_reg.mode_30_8=config +sff_cpld_reg.src_30_8=cpld +sff_cpld_reg.frmt_30_8=bit +sff_cpld_reg.pola_30_8=negative +sff_cpld_reg.addr_30_8=0x00020074 +sff_cpld_reg.len_30_8=1 +sff_cpld_reg.bit_offset_30_8=5 + +sff_cpld_reg.mode_31_8=config +sff_cpld_reg.src_31_8=cpld +sff_cpld_reg.frmt_31_8=bit +sff_cpld_reg.pola_31_8=negative +sff_cpld_reg.addr_31_8=0x00020074 +sff_cpld_reg.len_31_8=1 +sff_cpld_reg.bit_offset_31_8=6 + +sff_cpld_reg.mode_32_8=config +sff_cpld_reg.src_32_8=cpld +sff_cpld_reg.frmt_32_8=bit +sff_cpld_reg.pola_32_8=negative +sff_cpld_reg.addr_32_8=0x00020074 +sff_cpld_reg.len_32_8=1 +sff_cpld_reg.bit_offset_32_8=7 + +sff_cpld_reg.mode_33_8=config +sff_cpld_reg.src_33_8=cpld +sff_cpld_reg.frmt_33_8=bit +sff_cpld_reg.pola_33_8=negative +sff_cpld_reg.addr_33_8=0x00050075 +sff_cpld_reg.len_33_8=1 +sff_cpld_reg.bit_offset_33_8=0 + +sff_cpld_reg.mode_34_8=config +sff_cpld_reg.src_34_8=cpld +sff_cpld_reg.frmt_34_8=bit +sff_cpld_reg.pola_34_8=negative +sff_cpld_reg.addr_34_8=0x00050075 +sff_cpld_reg.len_34_8=1 +sff_cpld_reg.bit_offset_34_8=1 + +sff_cpld_reg.mode_35_8=config +sff_cpld_reg.src_35_8=cpld +sff_cpld_reg.frmt_35_8=bit +sff_cpld_reg.pola_35_8=negative +sff_cpld_reg.addr_35_8=0x00050075 +sff_cpld_reg.len_35_8=1 +sff_cpld_reg.bit_offset_35_8=2 + +sff_cpld_reg.mode_36_8=config +sff_cpld_reg.src_36_8=cpld +sff_cpld_reg.frmt_36_8=bit +sff_cpld_reg.pola_36_8=negative +sff_cpld_reg.addr_36_8=0x00050075 +sff_cpld_reg.len_36_8=1 +sff_cpld_reg.bit_offset_36_8=3 + +sff_cpld_reg.mode_37_8=config +sff_cpld_reg.src_37_8=cpld +sff_cpld_reg.frmt_37_8=bit +sff_cpld_reg.pola_37_8=negative +sff_cpld_reg.addr_37_8=0x00050074 +sff_cpld_reg.len_37_8=1 +sff_cpld_reg.bit_offset_37_8=0 + +sff_cpld_reg.mode_38_8=config +sff_cpld_reg.src_38_8=cpld +sff_cpld_reg.frmt_38_8=bit +sff_cpld_reg.pola_38_8=negative +sff_cpld_reg.addr_38_8=0x00050074 +sff_cpld_reg.len_38_8=1 +sff_cpld_reg.bit_offset_38_8=1 + +sff_cpld_reg.mode_39_8=config +sff_cpld_reg.src_39_8=cpld +sff_cpld_reg.frmt_39_8=bit +sff_cpld_reg.pola_39_8=negative +sff_cpld_reg.addr_39_8=0x00050074 +sff_cpld_reg.len_39_8=1 +sff_cpld_reg.bit_offset_39_8=2 + +sff_cpld_reg.mode_40_8=config +sff_cpld_reg.src_40_8=cpld +sff_cpld_reg.frmt_40_8=bit +sff_cpld_reg.pola_40_8=negative +sff_cpld_reg.addr_40_8=0x00050074 +sff_cpld_reg.len_40_8=1 +sff_cpld_reg.bit_offset_40_8=3 + +sff_cpld_reg.mode_41_8=config +sff_cpld_reg.src_41_8=cpld +sff_cpld_reg.frmt_41_8=bit +sff_cpld_reg.pola_41_8=negative +sff_cpld_reg.addr_41_8=0x00050074 +sff_cpld_reg.len_41_8=1 +sff_cpld_reg.bit_offset_41_8=4 + +sff_cpld_reg.mode_42_8=config +sff_cpld_reg.src_42_8=cpld +sff_cpld_reg.frmt_42_8=bit +sff_cpld_reg.pola_42_8=negative +sff_cpld_reg.addr_42_8=0x00050074 +sff_cpld_reg.len_42_8=1 +sff_cpld_reg.bit_offset_42_8=5 + +sff_cpld_reg.mode_43_8=config +sff_cpld_reg.src_43_8=cpld +sff_cpld_reg.frmt_43_8=bit +sff_cpld_reg.pola_43_8=negative +sff_cpld_reg.addr_43_8=0x0006007B +sff_cpld_reg.len_43_8=1 +sff_cpld_reg.bit_offset_43_8=0 + +sff_cpld_reg.mode_44_8=config +sff_cpld_reg.src_44_8=cpld +sff_cpld_reg.frmt_44_8=bit +sff_cpld_reg.pola_44_8=negative +sff_cpld_reg.addr_44_8=0x0006007B +sff_cpld_reg.len_44_8=1 +sff_cpld_reg.bit_offset_44_8=1 + +sff_cpld_reg.mode_45_8=config +sff_cpld_reg.src_45_8=cpld +sff_cpld_reg.frmt_45_8=bit +sff_cpld_reg.pola_45_8=negative +sff_cpld_reg.addr_45_8=0x0006007B +sff_cpld_reg.len_45_8=1 +sff_cpld_reg.bit_offset_45_8=2 + +sff_cpld_reg.mode_46_8=config +sff_cpld_reg.src_46_8=cpld +sff_cpld_reg.frmt_46_8=bit +sff_cpld_reg.pola_46_8=negative +sff_cpld_reg.addr_46_8=0x0006007B +sff_cpld_reg.len_46_8=1 +sff_cpld_reg.bit_offset_46_8=3 + +sff_cpld_reg.mode_47_8=config +sff_cpld_reg.src_47_8=cpld +sff_cpld_reg.frmt_47_8=bit +sff_cpld_reg.pola_47_8=negative +sff_cpld_reg.addr_47_8=0x0006007B +sff_cpld_reg.len_47_8=1 +sff_cpld_reg.bit_offset_47_8=4 + +sff_cpld_reg.mode_48_8=config +sff_cpld_reg.src_48_8=cpld +sff_cpld_reg.frmt_48_8=bit +sff_cpld_reg.pola_48_8=negative +sff_cpld_reg.addr_48_8=0x0006007B +sff_cpld_reg.len_48_8=1 +sff_cpld_reg.bit_offset_48_8=5 + +sff_cpld_reg.mode_49_8=config +sff_cpld_reg.src_49_8=cpld +sff_cpld_reg.frmt_49_8=bit +sff_cpld_reg.pola_49_8=negative +sff_cpld_reg.addr_49_8=0x0006007A +sff_cpld_reg.len_49_8=1 +sff_cpld_reg.bit_offset_49_8=0 + +sff_cpld_reg.mode_50_8=config +sff_cpld_reg.src_50_8=cpld +sff_cpld_reg.frmt_50_8=bit +sff_cpld_reg.pola_50_8=negative +sff_cpld_reg.addr_50_8=0x0006007A +sff_cpld_reg.len_50_8=1 +sff_cpld_reg.bit_offset_50_8=1 + +sff_cpld_reg.mode_51_8=config +sff_cpld_reg.src_51_8=cpld +sff_cpld_reg.frmt_51_8=bit +sff_cpld_reg.pola_51_8=negative +sff_cpld_reg.addr_51_8=0x0006007A +sff_cpld_reg.len_51_8=1 +sff_cpld_reg.bit_offset_51_8=2 + +sff_cpld_reg.mode_52_8=config +sff_cpld_reg.src_52_8=cpld +sff_cpld_reg.frmt_52_8=bit +sff_cpld_reg.pola_52_8=negative +sff_cpld_reg.addr_52_8=0x0006007A +sff_cpld_reg.len_52_8=1 +sff_cpld_reg.bit_offset_52_8=3 + +sff_cpld_reg.mode_53_8=config +sff_cpld_reg.src_53_8=cpld +sff_cpld_reg.frmt_53_8=bit +sff_cpld_reg.pola_53_8=negative +sff_cpld_reg.addr_53_8=0x0006007A +sff_cpld_reg.len_53_8=1 +sff_cpld_reg.bit_offset_53_8=4 + +sff_cpld_reg.mode_54_8=config +sff_cpld_reg.src_54_8=cpld +sff_cpld_reg.frmt_54_8=bit +sff_cpld_reg.pola_54_8=negative +sff_cpld_reg.addr_54_8=0x0006007A +sff_cpld_reg.len_54_8=1 +sff_cpld_reg.bit_offset_54_8=5 + +sff_cpld_reg.mode_55_8=config +sff_cpld_reg.src_55_8=cpld +sff_cpld_reg.frmt_55_8=bit +sff_cpld_reg.pola_55_8=negative +sff_cpld_reg.addr_55_8=0x0006007A +sff_cpld_reg.len_55_8=1 +sff_cpld_reg.bit_offset_55_8=6 + +sff_cpld_reg.mode_56_8=config +sff_cpld_reg.src_56_8=cpld +sff_cpld_reg.frmt_56_8=bit +sff_cpld_reg.pola_56_8=negative +sff_cpld_reg.addr_56_8=0x0006007A +sff_cpld_reg.len_56_8=1 +sff_cpld_reg.bit_offset_56_8=7 + +sff_cpld_reg.mode_57_8=config +sff_cpld_reg.src_57_8=cpld +sff_cpld_reg.frmt_57_8=bit +sff_cpld_reg.pola_57_8=negative +sff_cpld_reg.addr_57_8=0x00060079 +sff_cpld_reg.len_57_8=1 +sff_cpld_reg.bit_offset_57_8=0 + +sff_cpld_reg.mode_58_8=config +sff_cpld_reg.src_58_8=cpld +sff_cpld_reg.frmt_58_8=bit +sff_cpld_reg.pola_58_8=negative +sff_cpld_reg.addr_58_8=0x00060079 +sff_cpld_reg.len_58_8=1 +sff_cpld_reg.bit_offset_58_8=1 + +sff_cpld_reg.mode_59_8=config +sff_cpld_reg.src_59_8=cpld +sff_cpld_reg.frmt_59_8=bit +sff_cpld_reg.pola_59_8=negative +sff_cpld_reg.addr_59_8=0x00060079 +sff_cpld_reg.len_59_8=1 +sff_cpld_reg.bit_offset_59_8=2 + +sff_cpld_reg.mode_60_8=config +sff_cpld_reg.src_60_8=cpld +sff_cpld_reg.frmt_60_8=bit +sff_cpld_reg.pola_60_8=negative +sff_cpld_reg.addr_60_8=0x00060079 +sff_cpld_reg.len_60_8=1 +sff_cpld_reg.bit_offset_60_8=3 + +sff_cpld_reg.mode_61_8=config +sff_cpld_reg.src_61_8=cpld +sff_cpld_reg.frmt_61_8=bit +sff_cpld_reg.pola_61_8=negative +sff_cpld_reg.addr_61_8=0x00060079 +sff_cpld_reg.len_61_8=1 +sff_cpld_reg.bit_offset_61_8=4 + +sff_cpld_reg.mode_62_8=config +sff_cpld_reg.src_62_8=cpld +sff_cpld_reg.frmt_62_8=bit +sff_cpld_reg.pola_62_8=negative +sff_cpld_reg.addr_62_8=0x00060079 +sff_cpld_reg.len_62_8=1 +sff_cpld_reg.bit_offset_62_8=5 + +sff_cpld_reg.mode_63_8=config +sff_cpld_reg.src_63_8=cpld +sff_cpld_reg.frmt_63_8=bit +sff_cpld_reg.pola_63_8=negative +sff_cpld_reg.addr_63_8=0x00060079 +sff_cpld_reg.len_63_8=1 +sff_cpld_reg.bit_offset_63_8=6 + +sff_cpld_reg.mode_64_8=config +sff_cpld_reg.src_64_8=cpld +sff_cpld_reg.frmt_64_8=bit +sff_cpld_reg.pola_64_8=negative +sff_cpld_reg.addr_64_8=0x00060079 +sff_cpld_reg.len_64_8=1 +sff_cpld_reg.bit_offset_64_8=7 + +sff_cpld_reg.mode_65_8=config +sff_cpld_reg.src_65_8=cpld +sff_cpld_reg.frmt_65_8=bit +sff_cpld_reg.pola_65_8=negative +sff_cpld_reg.addr_65_8=0x00050074 +sff_cpld_reg.len_65_8=1 +sff_cpld_reg.bit_offset_65_8=6 + +sff_cpld_reg.mode_66_8=config +sff_cpld_reg.src_66_8=cpld +sff_cpld_reg.frmt_66_8=bit +sff_cpld_reg.pola_66_8=negative +sff_cpld_reg.addr_66_8=0x00050074 +sff_cpld_reg.len_66_8=1 +sff_cpld_reg.bit_offset_66_8=7 + +sff_cpld_reg.mode_67_8=config +sff_cpld_reg.src_67_8=cpld +sff_cpld_reg.frmt_67_8=bit +sff_cpld_reg.pola_67_8=negative +sff_cpld_reg.addr_67_8=0x00050073 +sff_cpld_reg.len_67_8=1 +sff_cpld_reg.bit_offset_67_8=0 + +sff_cpld_reg.mode_68_8=config +sff_cpld_reg.src_68_8=cpld +sff_cpld_reg.frmt_68_8=bit +sff_cpld_reg.pola_68_8=negative +sff_cpld_reg.addr_68_8=0x00050073 +sff_cpld_reg.len_68_8=1 +sff_cpld_reg.bit_offset_68_8=1 + +sff_cpld_reg.mode_69_8=config +sff_cpld_reg.src_69_8=cpld +sff_cpld_reg.frmt_69_8=bit +sff_cpld_reg.pola_69_8=negative +sff_cpld_reg.addr_69_8=0x00050073 +sff_cpld_reg.len_69_8=1 +sff_cpld_reg.bit_offset_69_8=2 + +sff_cpld_reg.mode_70_8=config +sff_cpld_reg.src_70_8=cpld +sff_cpld_reg.frmt_70_8=bit +sff_cpld_reg.pola_70_8=negative +sff_cpld_reg.addr_70_8=0x00050073 +sff_cpld_reg.len_70_8=1 +sff_cpld_reg.bit_offset_70_8=3 + +sff_cpld_reg.mode_71_8=config +sff_cpld_reg.src_71_8=cpld +sff_cpld_reg.frmt_71_8=bit +sff_cpld_reg.pola_71_8=negative +sff_cpld_reg.addr_71_8=0x00050073 +sff_cpld_reg.len_71_8=1 +sff_cpld_reg.bit_offset_71_8=4 + +sff_cpld_reg.mode_72_8=config +sff_cpld_reg.src_72_8=cpld +sff_cpld_reg.frmt_72_8=bit +sff_cpld_reg.pola_72_8=negative +sff_cpld_reg.addr_72_8=0x00050073 +sff_cpld_reg.len_72_8=1 +sff_cpld_reg.bit_offset_72_8=5 + +sff_cpld_reg.mode_73_8=config +sff_cpld_reg.src_73_8=cpld +sff_cpld_reg.frmt_73_8=bit +sff_cpld_reg.pola_73_8=negative +sff_cpld_reg.addr_73_8=0x00050073 +sff_cpld_reg.len_73_8=1 +sff_cpld_reg.bit_offset_73_8=6 + +sff_cpld_reg.mode_74_8=config +sff_cpld_reg.src_74_8=cpld +sff_cpld_reg.frmt_74_8=bit +sff_cpld_reg.pola_74_8=negative +sff_cpld_reg.addr_74_8=0x00050073 +sff_cpld_reg.len_74_8=1 +sff_cpld_reg.bit_offset_74_8=7 + +sff_cpld_reg.mode_75_8=config +sff_cpld_reg.src_75_8=cpld +sff_cpld_reg.frmt_75_8=bit +sff_cpld_reg.pola_75_8=negative +sff_cpld_reg.addr_75_8=0x00060078 +sff_cpld_reg.len_75_8=1 +sff_cpld_reg.bit_offset_75_8=0 + +sff_cpld_reg.mode_76_8=config +sff_cpld_reg.src_76_8=cpld +sff_cpld_reg.frmt_76_8=bit +sff_cpld_reg.pola_76_8=negative +sff_cpld_reg.addr_76_8=0x00060078 +sff_cpld_reg.len_76_8=1 +sff_cpld_reg.bit_offset_76_8=1 + +sff_cpld_reg.mode_77_8=config +sff_cpld_reg.src_77_8=cpld +sff_cpld_reg.frmt_77_8=bit +sff_cpld_reg.pola_77_8=negative +sff_cpld_reg.addr_77_8=0x00060078 +sff_cpld_reg.len_77_8=1 +sff_cpld_reg.bit_offset_77_8=2 + +sff_cpld_reg.mode_78_8=config +sff_cpld_reg.src_78_8=cpld +sff_cpld_reg.frmt_78_8=bit +sff_cpld_reg.pola_78_8=negative +sff_cpld_reg.addr_78_8=0x00060078 +sff_cpld_reg.len_78_8=1 +sff_cpld_reg.bit_offset_78_8=3 + +sff_cpld_reg.mode_79_8=config +sff_cpld_reg.src_79_8=cpld +sff_cpld_reg.frmt_79_8=bit +sff_cpld_reg.pola_79_8=negative +sff_cpld_reg.addr_79_8=0x00060078 +sff_cpld_reg.len_79_8=1 +sff_cpld_reg.bit_offset_79_8=4 + +sff_cpld_reg.mode_80_8=config +sff_cpld_reg.src_80_8=cpld +sff_cpld_reg.frmt_80_8=bit +sff_cpld_reg.pola_80_8=negative +sff_cpld_reg.addr_80_8=0x00060078 +sff_cpld_reg.len_80_8=1 +sff_cpld_reg.bit_offset_80_8=5 + +sff_cpld_reg.mode_81_8=config +sff_cpld_reg.src_81_8=cpld +sff_cpld_reg.frmt_81_8=bit +sff_cpld_reg.pola_81_8=negative +sff_cpld_reg.addr_81_8=0x00060077 +sff_cpld_reg.len_81_8=1 +sff_cpld_reg.bit_offset_81_8=0 + +sff_cpld_reg.mode_82_8=config +sff_cpld_reg.src_82_8=cpld +sff_cpld_reg.frmt_82_8=bit +sff_cpld_reg.pola_82_8=negative +sff_cpld_reg.addr_82_8=0x00060077 +sff_cpld_reg.len_82_8=1 +sff_cpld_reg.bit_offset_82_8=1 + +sff_cpld_reg.mode_83_8=config +sff_cpld_reg.src_83_8=cpld +sff_cpld_reg.frmt_83_8=bit +sff_cpld_reg.pola_83_8=negative +sff_cpld_reg.addr_83_8=0x00060077 +sff_cpld_reg.len_83_8=1 +sff_cpld_reg.bit_offset_83_8=2 + +sff_cpld_reg.mode_84_8=config +sff_cpld_reg.src_84_8=cpld +sff_cpld_reg.frmt_84_8=bit +sff_cpld_reg.pola_84_8=negative +sff_cpld_reg.addr_84_8=0x00060077 +sff_cpld_reg.len_84_8=1 +sff_cpld_reg.bit_offset_84_8=3 + +sff_cpld_reg.mode_85_8=config +sff_cpld_reg.src_85_8=cpld +sff_cpld_reg.frmt_85_8=bit +sff_cpld_reg.pola_85_8=negative +sff_cpld_reg.addr_85_8=0x00060077 +sff_cpld_reg.len_85_8=1 +sff_cpld_reg.bit_offset_85_8=4 + +sff_cpld_reg.mode_86_8=config +sff_cpld_reg.src_86_8=cpld +sff_cpld_reg.frmt_86_8=bit +sff_cpld_reg.pola_86_8=negative +sff_cpld_reg.addr_86_8=0x00060077 +sff_cpld_reg.len_86_8=1 +sff_cpld_reg.bit_offset_86_8=5 + +sff_cpld_reg.mode_87_8=config +sff_cpld_reg.src_87_8=cpld +sff_cpld_reg.frmt_87_8=bit +sff_cpld_reg.pola_87_8=negative +sff_cpld_reg.addr_87_8=0x00060077 +sff_cpld_reg.len_87_8=1 +sff_cpld_reg.bit_offset_87_8=6 + +sff_cpld_reg.mode_88_8=config +sff_cpld_reg.src_88_8=cpld +sff_cpld_reg.frmt_88_8=bit +sff_cpld_reg.pola_88_8=negative +sff_cpld_reg.addr_88_8=0x00060077 +sff_cpld_reg.len_88_8=1 +sff_cpld_reg.bit_offset_88_8=7 + +sff_cpld_reg.mode_89_8=config +sff_cpld_reg.src_89_8=cpld +sff_cpld_reg.frmt_89_8=bit +sff_cpld_reg.pola_89_8=negative +sff_cpld_reg.addr_89_8=0x00060076 +sff_cpld_reg.len_89_8=1 +sff_cpld_reg.bit_offset_89_8=0 + +sff_cpld_reg.mode_90_8=config +sff_cpld_reg.src_90_8=cpld +sff_cpld_reg.frmt_90_8=bit +sff_cpld_reg.pola_90_8=negative +sff_cpld_reg.addr_90_8=0x00060076 +sff_cpld_reg.len_90_8=1 +sff_cpld_reg.bit_offset_90_8=1 + +sff_cpld_reg.mode_91_8=config +sff_cpld_reg.src_91_8=cpld +sff_cpld_reg.frmt_91_8=bit +sff_cpld_reg.pola_91_8=negative +sff_cpld_reg.addr_91_8=0x00060076 +sff_cpld_reg.len_91_8=1 +sff_cpld_reg.bit_offset_91_8=2 + +sff_cpld_reg.mode_92_8=config +sff_cpld_reg.src_92_8=cpld +sff_cpld_reg.frmt_92_8=bit +sff_cpld_reg.pola_92_8=negative +sff_cpld_reg.addr_92_8=0x00060076 +sff_cpld_reg.len_92_8=1 +sff_cpld_reg.bit_offset_92_8=3 + +sff_cpld_reg.mode_93_8=config +sff_cpld_reg.src_93_8=cpld +sff_cpld_reg.frmt_93_8=bit +sff_cpld_reg.pola_93_8=negative +sff_cpld_reg.addr_93_8=0x00060076 +sff_cpld_reg.len_93_8=1 +sff_cpld_reg.bit_offset_93_8=4 + +sff_cpld_reg.mode_94_8=config +sff_cpld_reg.src_94_8=cpld +sff_cpld_reg.frmt_94_8=bit +sff_cpld_reg.pola_94_8=negative +sff_cpld_reg.addr_94_8=0x00060076 +sff_cpld_reg.len_94_8=1 +sff_cpld_reg.bit_offset_94_8=5 + +sff_cpld_reg.mode_95_8=config +sff_cpld_reg.src_95_8=cpld +sff_cpld_reg.frmt_95_8=bit +sff_cpld_reg.pola_95_8=negative +sff_cpld_reg.addr_95_8=0x00060076 +sff_cpld_reg.len_95_8=1 +sff_cpld_reg.bit_offset_95_8=6 + +sff_cpld_reg.mode_96_8=config +sff_cpld_reg.src_96_8=cpld +sff_cpld_reg.frmt_96_8=bit +sff_cpld_reg.pola_96_8=negative +sff_cpld_reg.addr_96_8=0x00060076 +sff_cpld_reg.len_96_8=1 +sff_cpld_reg.bit_offset_96_8=7 + +sff_cpld_reg.mode_97_8=config +sff_cpld_reg.src_97_8=cpld +sff_cpld_reg.frmt_97_8=bit +sff_cpld_reg.pola_97_8=negative +sff_cpld_reg.addr_97_8=0x00070077 +sff_cpld_reg.len_97_8=1 +sff_cpld_reg.bit_offset_97_8=0 + +sff_cpld_reg.mode_98_8=config +sff_cpld_reg.src_98_8=cpld +sff_cpld_reg.frmt_98_8=bit +sff_cpld_reg.pola_98_8=negative +sff_cpld_reg.addr_98_8=0x00070077 +sff_cpld_reg.len_98_8=1 +sff_cpld_reg.bit_offset_98_8=1 + +sff_cpld_reg.mode_99_8=config +sff_cpld_reg.src_99_8=cpld +sff_cpld_reg.frmt_99_8=bit +sff_cpld_reg.pola_99_8=negative +sff_cpld_reg.addr_99_8=0x00070077 +sff_cpld_reg.len_99_8=1 +sff_cpld_reg.bit_offset_99_8=2 + +sff_cpld_reg.mode_100_8=config +sff_cpld_reg.src_100_8=cpld +sff_cpld_reg.frmt_100_8=bit +sff_cpld_reg.pola_100_8=negative +sff_cpld_reg.addr_100_8=0x00070077 +sff_cpld_reg.len_100_8=1 +sff_cpld_reg.bit_offset_100_8=3 + +sff_cpld_reg.mode_101_8=config +sff_cpld_reg.src_101_8=cpld +sff_cpld_reg.frmt_101_8=bit +sff_cpld_reg.pola_101_8=negative +sff_cpld_reg.addr_101_8=0x00070077 +sff_cpld_reg.len_101_8=1 +sff_cpld_reg.bit_offset_101_8=4 + +sff_cpld_reg.mode_102_8=config +sff_cpld_reg.src_102_8=cpld +sff_cpld_reg.frmt_102_8=bit +sff_cpld_reg.pola_102_8=negative +sff_cpld_reg.addr_102_8=0x00070077 +sff_cpld_reg.len_102_8=1 +sff_cpld_reg.bit_offset_102_8=5 + +sff_cpld_reg.mode_103_8=config +sff_cpld_reg.src_103_8=cpld +sff_cpld_reg.frmt_103_8=bit +sff_cpld_reg.pola_103_8=negative +sff_cpld_reg.addr_103_8=0x00070077 +sff_cpld_reg.len_103_8=1 +sff_cpld_reg.bit_offset_103_8=6 + +sff_cpld_reg.mode_104_8=config +sff_cpld_reg.src_104_8=cpld +sff_cpld_reg.frmt_104_8=bit +sff_cpld_reg.pola_104_8=negative +sff_cpld_reg.addr_104_8=0x00070077 +sff_cpld_reg.len_104_8=1 +sff_cpld_reg.bit_offset_104_8=7 + +sff_cpld_reg.mode_105_8=config +sff_cpld_reg.src_105_8=cpld +sff_cpld_reg.frmt_105_8=bit +sff_cpld_reg.pola_105_8=negative +sff_cpld_reg.addr_105_8=0x00070076 +sff_cpld_reg.len_105_8=1 +sff_cpld_reg.bit_offset_105_8=0 + +sff_cpld_reg.mode_106_8=config +sff_cpld_reg.src_106_8=cpld +sff_cpld_reg.frmt_106_8=bit +sff_cpld_reg.pola_106_8=negative +sff_cpld_reg.addr_106_8=0x00070076 +sff_cpld_reg.len_106_8=1 +sff_cpld_reg.bit_offset_106_8=1 + +sff_cpld_reg.mode_107_8=config +sff_cpld_reg.src_107_8=cpld +sff_cpld_reg.frmt_107_8=bit +sff_cpld_reg.pola_107_8=negative +sff_cpld_reg.addr_107_8=0x00070076 +sff_cpld_reg.len_107_8=1 +sff_cpld_reg.bit_offset_107_8=2 + +sff_cpld_reg.mode_108_8=config +sff_cpld_reg.src_108_8=cpld +sff_cpld_reg.frmt_108_8=bit +sff_cpld_reg.pola_108_8=negative +sff_cpld_reg.addr_108_8=0x00070076 +sff_cpld_reg.len_108_8=1 +sff_cpld_reg.bit_offset_108_8=3 + +sff_cpld_reg.mode_109_8=config +sff_cpld_reg.src_109_8=cpld +sff_cpld_reg.frmt_109_8=bit +sff_cpld_reg.pola_109_8=negative +sff_cpld_reg.addr_109_8=0x00070076 +sff_cpld_reg.len_109_8=1 +sff_cpld_reg.bit_offset_109_8=4 + +sff_cpld_reg.mode_110_8=config +sff_cpld_reg.src_110_8=cpld +sff_cpld_reg.frmt_110_8=bit +sff_cpld_reg.pola_110_8=negative +sff_cpld_reg.addr_110_8=0x00070076 +sff_cpld_reg.len_110_8=1 +sff_cpld_reg.bit_offset_110_8=5 + +sff_cpld_reg.mode_111_8=config +sff_cpld_reg.src_111_8=cpld +sff_cpld_reg.frmt_111_8=bit +sff_cpld_reg.pola_111_8=negative +sff_cpld_reg.addr_111_8=0x00070076 +sff_cpld_reg.len_111_8=1 +sff_cpld_reg.bit_offset_111_8=6 + +sff_cpld_reg.mode_112_8=config +sff_cpld_reg.src_112_8=cpld +sff_cpld_reg.frmt_112_8=bit +sff_cpld_reg.pola_112_8=negative +sff_cpld_reg.addr_112_8=0x00070076 +sff_cpld_reg.len_112_8=1 +sff_cpld_reg.bit_offset_112_8=7 + +sff_cpld_reg.mode_113_8=config +sff_cpld_reg.src_113_8=cpld +sff_cpld_reg.frmt_113_8=bit +sff_cpld_reg.pola_113_8=negative +sff_cpld_reg.addr_113_8=0x00070075 +sff_cpld_reg.len_113_8=1 +sff_cpld_reg.bit_offset_113_8=0 + +sff_cpld_reg.mode_114_8=config +sff_cpld_reg.src_114_8=cpld +sff_cpld_reg.frmt_114_8=bit +sff_cpld_reg.pola_114_8=negative +sff_cpld_reg.addr_114_8=0x00070075 +sff_cpld_reg.len_114_8=1 +sff_cpld_reg.bit_offset_114_8=1 + +sff_cpld_reg.mode_115_8=config +sff_cpld_reg.src_115_8=cpld +sff_cpld_reg.frmt_115_8=bit +sff_cpld_reg.pola_115_8=negative +sff_cpld_reg.addr_115_8=0x00070075 +sff_cpld_reg.len_115_8=1 +sff_cpld_reg.bit_offset_115_8=2 + +sff_cpld_reg.mode_116_8=config +sff_cpld_reg.src_116_8=cpld +sff_cpld_reg.frmt_116_8=bit +sff_cpld_reg.pola_116_8=negative +sff_cpld_reg.addr_116_8=0x00070075 +sff_cpld_reg.len_116_8=1 +sff_cpld_reg.bit_offset_116_8=3 + +sff_cpld_reg.mode_117_8=config +sff_cpld_reg.src_117_8=cpld +sff_cpld_reg.frmt_117_8=bit +sff_cpld_reg.pola_117_8=negative +sff_cpld_reg.addr_117_8=0x00070075 +sff_cpld_reg.len_117_8=1 +sff_cpld_reg.bit_offset_117_8=4 + +sff_cpld_reg.mode_118_8=config +sff_cpld_reg.src_118_8=cpld +sff_cpld_reg.frmt_118_8=bit +sff_cpld_reg.pola_118_8=negative +sff_cpld_reg.addr_118_8=0x00070075 +sff_cpld_reg.len_118_8=1 +sff_cpld_reg.bit_offset_118_8=5 + +sff_cpld_reg.mode_119_8=config +sff_cpld_reg.src_119_8=cpld +sff_cpld_reg.frmt_119_8=bit +sff_cpld_reg.pola_119_8=negative +sff_cpld_reg.addr_119_8=0x00070075 +sff_cpld_reg.len_119_8=1 +sff_cpld_reg.bit_offset_119_8=6 + +sff_cpld_reg.mode_120_8=config +sff_cpld_reg.src_120_8=cpld +sff_cpld_reg.frmt_120_8=bit +sff_cpld_reg.pola_120_8=negative +sff_cpld_reg.addr_120_8=0x00070075 +sff_cpld_reg.len_120_8=1 +sff_cpld_reg.bit_offset_120_8=7 + +sff_cpld_reg.mode_121_8=config +sff_cpld_reg.src_121_8=cpld +sff_cpld_reg.frmt_121_8=bit +sff_cpld_reg.pola_121_8=negative +sff_cpld_reg.addr_121_8=0x00070074 +sff_cpld_reg.len_121_8=1 +sff_cpld_reg.bit_offset_121_8=0 + +sff_cpld_reg.mode_122_8=config +sff_cpld_reg.src_122_8=cpld +sff_cpld_reg.frmt_122_8=bit +sff_cpld_reg.pola_122_8=negative +sff_cpld_reg.addr_122_8=0x00070074 +sff_cpld_reg.len_122_8=1 +sff_cpld_reg.bit_offset_122_8=1 + +sff_cpld_reg.mode_123_8=config +sff_cpld_reg.src_123_8=cpld +sff_cpld_reg.frmt_123_8=bit +sff_cpld_reg.pola_123_8=negative +sff_cpld_reg.addr_123_8=0x00070074 +sff_cpld_reg.len_123_8=1 +sff_cpld_reg.bit_offset_123_8=2 + +sff_cpld_reg.mode_124_8=config +sff_cpld_reg.src_124_8=cpld +sff_cpld_reg.frmt_124_8=bit +sff_cpld_reg.pola_124_8=negative +sff_cpld_reg.addr_124_8=0x00070074 +sff_cpld_reg.len_124_8=1 +sff_cpld_reg.bit_offset_124_8=3 + +sff_cpld_reg.mode_125_8=config +sff_cpld_reg.src_125_8=cpld +sff_cpld_reg.frmt_125_8=bit +sff_cpld_reg.pola_125_8=negative +sff_cpld_reg.addr_125_8=0x00070074 +sff_cpld_reg.len_125_8=1 +sff_cpld_reg.bit_offset_125_8=4 + +sff_cpld_reg.mode_126_8=config +sff_cpld_reg.src_126_8=cpld +sff_cpld_reg.frmt_126_8=bit +sff_cpld_reg.pola_126_8=negative +sff_cpld_reg.addr_126_8=0x00070074 +sff_cpld_reg.len_126_8=1 +sff_cpld_reg.bit_offset_126_8=5 + +sff_cpld_reg.mode_127_8=config +sff_cpld_reg.src_127_8=cpld +sff_cpld_reg.frmt_127_8=bit +sff_cpld_reg.pola_127_8=negative +sff_cpld_reg.addr_127_8=0x00070074 +sff_cpld_reg.len_127_8=1 +sff_cpld_reg.bit_offset_127_8=6 + +sff_cpld_reg.mode_128_8=config +sff_cpld_reg.src_128_8=cpld +sff_cpld_reg.frmt_128_8=bit +sff_cpld_reg.pola_128_8=negative +sff_cpld_reg.addr_128_8=0x00070074 +sff_cpld_reg.len_128_8=1 +sff_cpld_reg.bit_offset_128_8=7 + + +sff_cpld_reg.mode_1_1=config +sff_cpld_reg.src_1_1=cpld +sff_cpld_reg.frmt_1_1=bit +sff_cpld_reg.addr_1_1=0x00020080 +sff_cpld_reg.len_1_1=1 +sff_cpld_reg.bit_offset_1_1=0 + +sff_cpld_reg.mode_2_1=config +sff_cpld_reg.src_2_1=cpld +sff_cpld_reg.frmt_2_1=bit +sff_cpld_reg.addr_2_1=0x00020080 +sff_cpld_reg.len_2_1=1 +sff_cpld_reg.bit_offset_2_1=0 + +sff_cpld_reg.mode_3_1=config +sff_cpld_reg.src_3_1=cpld +sff_cpld_reg.frmt_3_1=bit +sff_cpld_reg.addr_3_1=0x00020080 +sff_cpld_reg.len_3_1=1 +sff_cpld_reg.bit_offset_3_1=0 + +sff_cpld_reg.mode_4_1=config +sff_cpld_reg.src_4_1=cpld +sff_cpld_reg.frmt_4_1=bit +sff_cpld_reg.addr_4_1=0x00020080 +sff_cpld_reg.len_4_1=1 +sff_cpld_reg.bit_offset_4_1=0 + +sff_cpld_reg.mode_5_1=config +sff_cpld_reg.src_5_1=cpld +sff_cpld_reg.frmt_5_1=bit +sff_cpld_reg.addr_5_1=0x00020080 +sff_cpld_reg.len_5_1=1 +sff_cpld_reg.bit_offset_5_1=0 + +sff_cpld_reg.mode_6_1=config +sff_cpld_reg.src_6_1=cpld +sff_cpld_reg.frmt_6_1=bit +sff_cpld_reg.addr_6_1=0x00020080 +sff_cpld_reg.len_6_1=1 +sff_cpld_reg.bit_offset_6_1=0 + +sff_cpld_reg.mode_7_1=config +sff_cpld_reg.src_7_1=cpld +sff_cpld_reg.frmt_7_1=bit +sff_cpld_reg.addr_7_1=0x00020080 +sff_cpld_reg.len_7_1=1 +sff_cpld_reg.bit_offset_7_1=0 + +sff_cpld_reg.mode_8_1=config +sff_cpld_reg.src_8_1=cpld +sff_cpld_reg.frmt_8_1=bit +sff_cpld_reg.addr_8_1=0x00020080 +sff_cpld_reg.len_8_1=1 +sff_cpld_reg.bit_offset_8_1=0 + +sff_cpld_reg.mode_9_1=config +sff_cpld_reg.src_9_1=cpld +sff_cpld_reg.frmt_9_1=bit +sff_cpld_reg.addr_9_1=0x00020080 +sff_cpld_reg.len_9_1=1 +sff_cpld_reg.bit_offset_9_1=1 + +sff_cpld_reg.mode_10_1=config +sff_cpld_reg.src_10_1=cpld +sff_cpld_reg.frmt_10_1=bit +sff_cpld_reg.addr_10_1=0x00020080 +sff_cpld_reg.len_10_1=1 +sff_cpld_reg.bit_offset_10_1=1 + +sff_cpld_reg.mode_11_1=config +sff_cpld_reg.src_11_1=cpld +sff_cpld_reg.frmt_11_1=bit +sff_cpld_reg.addr_11_1=0x00020080 +sff_cpld_reg.len_11_1=1 +sff_cpld_reg.bit_offset_11_1=1 + +sff_cpld_reg.mode_12_1=config +sff_cpld_reg.src_12_1=cpld +sff_cpld_reg.frmt_12_1=bit +sff_cpld_reg.addr_12_1=0x00020080 +sff_cpld_reg.len_12_1=1 +sff_cpld_reg.bit_offset_12_1=1 + +sff_cpld_reg.mode_13_1=config +sff_cpld_reg.src_13_1=cpld +sff_cpld_reg.frmt_13_1=bit +sff_cpld_reg.addr_13_1=0x00020080 +sff_cpld_reg.len_13_1=1 +sff_cpld_reg.bit_offset_13_1=1 + +sff_cpld_reg.mode_14_1=config +sff_cpld_reg.src_14_1=cpld +sff_cpld_reg.frmt_14_1=bit +sff_cpld_reg.addr_14_1=0x00020080 +sff_cpld_reg.len_14_1=1 +sff_cpld_reg.bit_offset_14_1=1 + +sff_cpld_reg.mode_15_1=config +sff_cpld_reg.src_15_1=cpld +sff_cpld_reg.frmt_15_1=bit +sff_cpld_reg.addr_15_1=0x00020080 +sff_cpld_reg.len_15_1=1 +sff_cpld_reg.bit_offset_15_1=1 + +sff_cpld_reg.mode_16_1=config +sff_cpld_reg.src_16_1=cpld +sff_cpld_reg.frmt_16_1=bit +sff_cpld_reg.addr_16_1=0x00020080 +sff_cpld_reg.len_16_1=1 +sff_cpld_reg.bit_offset_16_1=1 + +sff_cpld_reg.mode_17_1=config +sff_cpld_reg.src_17_1=cpld +sff_cpld_reg.frmt_17_1=bit +sff_cpld_reg.addr_17_1=0x00020080 +sff_cpld_reg.len_17_1=1 +sff_cpld_reg.bit_offset_17_1=2 + +sff_cpld_reg.mode_18_1=config +sff_cpld_reg.src_18_1=cpld +sff_cpld_reg.frmt_18_1=bit +sff_cpld_reg.addr_18_1=0x00020080 +sff_cpld_reg.len_18_1=1 +sff_cpld_reg.bit_offset_18_1=2 + +sff_cpld_reg.mode_19_1=config +sff_cpld_reg.src_19_1=cpld +sff_cpld_reg.frmt_19_1=bit +sff_cpld_reg.addr_19_1=0x00020080 +sff_cpld_reg.len_19_1=1 +sff_cpld_reg.bit_offset_19_1=2 + +sff_cpld_reg.mode_20_1=config +sff_cpld_reg.src_20_1=cpld +sff_cpld_reg.frmt_20_1=bit +sff_cpld_reg.addr_20_1=0x00020080 +sff_cpld_reg.len_20_1=1 +sff_cpld_reg.bit_offset_20_1=2 + +sff_cpld_reg.mode_21_1=config +sff_cpld_reg.src_21_1=cpld +sff_cpld_reg.frmt_21_1=bit +sff_cpld_reg.addr_21_1=0x00020080 +sff_cpld_reg.len_21_1=1 +sff_cpld_reg.bit_offset_21_1=2 + +sff_cpld_reg.mode_22_1=config +sff_cpld_reg.src_22_1=cpld +sff_cpld_reg.frmt_22_1=bit +sff_cpld_reg.addr_22_1=0x00020080 +sff_cpld_reg.len_22_1=1 +sff_cpld_reg.bit_offset_22_1=2 + +sff_cpld_reg.mode_23_1=config +sff_cpld_reg.src_23_1=cpld +sff_cpld_reg.frmt_23_1=bit +sff_cpld_reg.addr_23_1=0x00020080 +sff_cpld_reg.len_23_1=1 +sff_cpld_reg.bit_offset_23_1=2 + +sff_cpld_reg.mode_24_1=config +sff_cpld_reg.src_24_1=cpld +sff_cpld_reg.frmt_24_1=bit +sff_cpld_reg.addr_24_1=0x00020080 +sff_cpld_reg.len_24_1=1 +sff_cpld_reg.bit_offset_24_1=2 + +sff_cpld_reg.mode_25_1=config +sff_cpld_reg.src_25_1=cpld +sff_cpld_reg.frmt_25_1=bit +sff_cpld_reg.addr_25_1=0x00020080 +sff_cpld_reg.len_25_1=1 +sff_cpld_reg.bit_offset_25_1=3 + +sff_cpld_reg.mode_26_1=config +sff_cpld_reg.src_26_1=cpld +sff_cpld_reg.frmt_26_1=bit +sff_cpld_reg.addr_26_1=0x00020080 +sff_cpld_reg.len_26_1=1 +sff_cpld_reg.bit_offset_26_1=3 + +sff_cpld_reg.mode_27_1=config +sff_cpld_reg.src_27_1=cpld +sff_cpld_reg.frmt_27_1=bit +sff_cpld_reg.addr_27_1=0x00020080 +sff_cpld_reg.len_27_1=1 +sff_cpld_reg.bit_offset_27_1=3 + +sff_cpld_reg.mode_28_1=config +sff_cpld_reg.src_28_1=cpld +sff_cpld_reg.frmt_28_1=bit +sff_cpld_reg.addr_28_1=0x00020080 +sff_cpld_reg.len_28_1=1 +sff_cpld_reg.bit_offset_28_1=3 + +sff_cpld_reg.mode_29_1=config +sff_cpld_reg.src_29_1=cpld +sff_cpld_reg.frmt_29_1=bit +sff_cpld_reg.addr_29_1=0x00020080 +sff_cpld_reg.len_29_1=1 +sff_cpld_reg.bit_offset_29_1=3 + +sff_cpld_reg.mode_30_1=config +sff_cpld_reg.src_30_1=cpld +sff_cpld_reg.frmt_30_1=bit +sff_cpld_reg.addr_30_1=0x00020080 +sff_cpld_reg.len_30_1=1 +sff_cpld_reg.bit_offset_30_1=3 + +sff_cpld_reg.mode_31_1=config +sff_cpld_reg.src_31_1=cpld +sff_cpld_reg.frmt_31_1=bit +sff_cpld_reg.addr_31_1=0x00020080 +sff_cpld_reg.len_31_1=1 +sff_cpld_reg.bit_offset_31_1=3 + +sff_cpld_reg.mode_32_1=config +sff_cpld_reg.src_32_1=cpld +sff_cpld_reg.frmt_32_1=bit +sff_cpld_reg.addr_32_1=0x00020080 +sff_cpld_reg.len_32_1=1 +sff_cpld_reg.bit_offset_32_1=3 + +sff_cpld_reg.mode_33_1=config +sff_cpld_reg.src_33_1=cpld +sff_cpld_reg.frmt_33_1=bit +sff_cpld_reg.addr_33_1=0x0005007C +sff_cpld_reg.len_33_1=1 +sff_cpld_reg.bit_offset_33_1=0 + +sff_cpld_reg.mode_34_1=config +sff_cpld_reg.src_34_1=cpld +sff_cpld_reg.frmt_34_1=bit +sff_cpld_reg.addr_34_1=0x0005007C +sff_cpld_reg.len_34_1=1 +sff_cpld_reg.bit_offset_34_1=0 + +sff_cpld_reg.mode_35_1=config +sff_cpld_reg.src_35_1=cpld +sff_cpld_reg.frmt_35_1=bit +sff_cpld_reg.addr_35_1=0x0005007C +sff_cpld_reg.len_35_1=1 +sff_cpld_reg.bit_offset_35_1=0 + +sff_cpld_reg.mode_36_1=config +sff_cpld_reg.src_36_1=cpld +sff_cpld_reg.frmt_36_1=bit +sff_cpld_reg.addr_36_1=0x0005007C +sff_cpld_reg.len_36_1=1 +sff_cpld_reg.bit_offset_36_1=0 + +sff_cpld_reg.mode_37_1=config +sff_cpld_reg.src_37_1=cpld +sff_cpld_reg.frmt_37_1=bit +sff_cpld_reg.addr_37_1=0x0005007C +sff_cpld_reg.len_37_1=1 +sff_cpld_reg.bit_offset_37_1=0 + +sff_cpld_reg.mode_38_1=config +sff_cpld_reg.src_38_1=cpld +sff_cpld_reg.frmt_38_1=bit +sff_cpld_reg.addr_38_1=0x0005007C +sff_cpld_reg.len_38_1=1 +sff_cpld_reg.bit_offset_38_1=0 + +sff_cpld_reg.mode_39_1=config +sff_cpld_reg.src_39_1=cpld +sff_cpld_reg.frmt_39_1=bit +sff_cpld_reg.addr_39_1=0x0005007C +sff_cpld_reg.len_39_1=1 +sff_cpld_reg.bit_offset_39_1=0 + +sff_cpld_reg.mode_40_1=config +sff_cpld_reg.src_40_1=cpld +sff_cpld_reg.frmt_40_1=bit +sff_cpld_reg.addr_40_1=0x0005007C +sff_cpld_reg.len_40_1=1 +sff_cpld_reg.bit_offset_40_1=0 + +sff_cpld_reg.mode_41_1=config +sff_cpld_reg.src_41_1=cpld +sff_cpld_reg.frmt_41_1=bit +sff_cpld_reg.addr_41_1=0x0005007C +sff_cpld_reg.len_41_1=1 +sff_cpld_reg.bit_offset_41_1=1 + +sff_cpld_reg.mode_42_1=config +sff_cpld_reg.src_42_1=cpld +sff_cpld_reg.frmt_42_1=bit +sff_cpld_reg.addr_42_1=0x0005007C +sff_cpld_reg.len_42_1=1 +sff_cpld_reg.bit_offset_42_1=1 + +sff_cpld_reg.mode_43_1=config +sff_cpld_reg.src_43_1=cpld +sff_cpld_reg.frmt_43_1=bit +sff_cpld_reg.addr_43_1=0x0005007C +sff_cpld_reg.len_43_1=1 +sff_cpld_reg.bit_offset_43_1=1 + +sff_cpld_reg.mode_44_1=config +sff_cpld_reg.src_44_1=cpld +sff_cpld_reg.frmt_44_1=bit +sff_cpld_reg.addr_44_1=0x0005007C +sff_cpld_reg.len_44_1=1 +sff_cpld_reg.bit_offset_44_1=1 + +sff_cpld_reg.mode_45_1=config +sff_cpld_reg.src_45_1=cpld +sff_cpld_reg.frmt_45_1=bit +sff_cpld_reg.addr_45_1=0x0005007C +sff_cpld_reg.len_45_1=1 +sff_cpld_reg.bit_offset_45_1=1 + +sff_cpld_reg.mode_46_1=config +sff_cpld_reg.src_46_1=cpld +sff_cpld_reg.frmt_46_1=bit +sff_cpld_reg.addr_46_1=0x0005007C +sff_cpld_reg.len_46_1=1 +sff_cpld_reg.bit_offset_46_1=1 + +sff_cpld_reg.mode_47_1=config +sff_cpld_reg.src_47_1=cpld +sff_cpld_reg.frmt_47_1=bit +sff_cpld_reg.addr_47_1=0x0005007C +sff_cpld_reg.len_47_1=1 +sff_cpld_reg.bit_offset_47_1=1 + +sff_cpld_reg.mode_48_1=config +sff_cpld_reg.src_48_1=cpld +sff_cpld_reg.frmt_48_1=bit +sff_cpld_reg.addr_48_1=0x0005007C +sff_cpld_reg.len_48_1=1 +sff_cpld_reg.bit_offset_48_1=1 + +sff_cpld_reg.mode_49_1=config +sff_cpld_reg.src_49_1=cpld +sff_cpld_reg.frmt_49_1=bit +sff_cpld_reg.addr_49_1=0x0005007C +sff_cpld_reg.len_49_1=1 +sff_cpld_reg.bit_offset_49_1=2 + +sff_cpld_reg.mode_50_1=config +sff_cpld_reg.src_50_1=cpld +sff_cpld_reg.frmt_50_1=bit +sff_cpld_reg.addr_50_1=0x0005007C +sff_cpld_reg.len_50_1=1 +sff_cpld_reg.bit_offset_50_1=2 + +sff_cpld_reg.mode_51_1=config +sff_cpld_reg.src_51_1=cpld +sff_cpld_reg.frmt_51_1=bit +sff_cpld_reg.addr_51_1=0x0005007C +sff_cpld_reg.len_51_1=1 +sff_cpld_reg.bit_offset_51_1=2 + +sff_cpld_reg.mode_52_1=config +sff_cpld_reg.src_52_1=cpld +sff_cpld_reg.frmt_52_1=bit +sff_cpld_reg.addr_52_1=0x0005007C +sff_cpld_reg.len_52_1=1 +sff_cpld_reg.bit_offset_52_1=2 + +sff_cpld_reg.mode_53_1=config +sff_cpld_reg.src_53_1=cpld +sff_cpld_reg.frmt_53_1=bit +sff_cpld_reg.addr_53_1=0x0005007C +sff_cpld_reg.len_53_1=1 +sff_cpld_reg.bit_offset_53_1=2 + +sff_cpld_reg.mode_54_1=config +sff_cpld_reg.src_54_1=cpld +sff_cpld_reg.frmt_54_1=bit +sff_cpld_reg.addr_54_1=0x0005007C +sff_cpld_reg.len_54_1=1 +sff_cpld_reg.bit_offset_54_1=2 + +sff_cpld_reg.mode_55_1=config +sff_cpld_reg.src_55_1=cpld +sff_cpld_reg.frmt_55_1=bit +sff_cpld_reg.addr_55_1=0x0005007C +sff_cpld_reg.len_55_1=1 +sff_cpld_reg.bit_offset_55_1=2 + +sff_cpld_reg.mode_56_1=config +sff_cpld_reg.src_56_1=cpld +sff_cpld_reg.frmt_56_1=bit +sff_cpld_reg.addr_56_1=0x0005007C +sff_cpld_reg.len_56_1=1 +sff_cpld_reg.bit_offset_56_1=2 + +sff_cpld_reg.mode_57_1=config +sff_cpld_reg.src_57_1=cpld +sff_cpld_reg.frmt_57_1=bit +sff_cpld_reg.addr_57_1=0x0005007C +sff_cpld_reg.len_57_1=1 +sff_cpld_reg.bit_offset_57_1=3 + +sff_cpld_reg.mode_58_1=config +sff_cpld_reg.src_58_1=cpld +sff_cpld_reg.frmt_58_1=bit +sff_cpld_reg.addr_58_1=0x0005007C +sff_cpld_reg.len_58_1=1 +sff_cpld_reg.bit_offset_58_1=3 + +sff_cpld_reg.mode_59_1=config +sff_cpld_reg.src_59_1=cpld +sff_cpld_reg.frmt_59_1=bit +sff_cpld_reg.addr_59_1=0x0005007C +sff_cpld_reg.len_59_1=1 +sff_cpld_reg.bit_offset_59_1=3 + +sff_cpld_reg.mode_60_1=config +sff_cpld_reg.src_60_1=cpld +sff_cpld_reg.frmt_60_1=bit +sff_cpld_reg.addr_60_1=0x0005007C +sff_cpld_reg.len_60_1=1 +sff_cpld_reg.bit_offset_60_1=3 + +sff_cpld_reg.mode_61_1=config +sff_cpld_reg.src_61_1=cpld +sff_cpld_reg.frmt_61_1=bit +sff_cpld_reg.addr_61_1=0x0005007C +sff_cpld_reg.len_61_1=1 +sff_cpld_reg.bit_offset_61_1=3 + +sff_cpld_reg.mode_62_1=config +sff_cpld_reg.src_62_1=cpld +sff_cpld_reg.frmt_62_1=bit +sff_cpld_reg.addr_62_1=0x0005007C +sff_cpld_reg.len_62_1=1 +sff_cpld_reg.bit_offset_62_1=3 + +sff_cpld_reg.mode_63_1=config +sff_cpld_reg.src_63_1=cpld +sff_cpld_reg.frmt_63_1=bit +sff_cpld_reg.addr_63_1=0x0005007C +sff_cpld_reg.len_63_1=1 +sff_cpld_reg.bit_offset_63_1=3 + +sff_cpld_reg.mode_64_1=config +sff_cpld_reg.src_64_1=cpld +sff_cpld_reg.frmt_64_1=bit +sff_cpld_reg.addr_64_1=0x0005007C +sff_cpld_reg.len_64_1=1 +sff_cpld_reg.bit_offset_64_1=3 + +sff_cpld_reg.mode_65_1=config +sff_cpld_reg.src_65_1=cpld +sff_cpld_reg.frmt_65_1=bit +sff_cpld_reg.addr_65_1=0x0005007C +sff_cpld_reg.len_65_1=1 +sff_cpld_reg.bit_offset_65_1=4 + +sff_cpld_reg.mode_66_1=config +sff_cpld_reg.src_66_1=cpld +sff_cpld_reg.frmt_66_1=bit +sff_cpld_reg.addr_66_1=0x0005007C +sff_cpld_reg.len_66_1=1 +sff_cpld_reg.bit_offset_66_1=4 + +sff_cpld_reg.mode_67_1=config +sff_cpld_reg.src_67_1=cpld +sff_cpld_reg.frmt_67_1=bit +sff_cpld_reg.addr_67_1=0x0005007C +sff_cpld_reg.len_67_1=1 +sff_cpld_reg.bit_offset_67_1=4 + +sff_cpld_reg.mode_68_1=config +sff_cpld_reg.src_68_1=cpld +sff_cpld_reg.frmt_68_1=bit +sff_cpld_reg.addr_68_1=0x0005007C +sff_cpld_reg.len_68_1=1 +sff_cpld_reg.bit_offset_68_1=4 + +sff_cpld_reg.mode_69_1=config +sff_cpld_reg.src_69_1=cpld +sff_cpld_reg.frmt_69_1=bit +sff_cpld_reg.addr_69_1=0x0005007C +sff_cpld_reg.len_69_1=1 +sff_cpld_reg.bit_offset_69_1=4 + +sff_cpld_reg.mode_70_1=config +sff_cpld_reg.src_70_1=cpld +sff_cpld_reg.frmt_70_1=bit +sff_cpld_reg.addr_70_1=0x0005007C +sff_cpld_reg.len_70_1=1 +sff_cpld_reg.bit_offset_70_1=4 + +sff_cpld_reg.mode_71_1=config +sff_cpld_reg.src_71_1=cpld +sff_cpld_reg.frmt_71_1=bit +sff_cpld_reg.addr_71_1=0x0005007C +sff_cpld_reg.len_71_1=1 +sff_cpld_reg.bit_offset_71_1=4 + +sff_cpld_reg.mode_72_1=config +sff_cpld_reg.src_72_1=cpld +sff_cpld_reg.frmt_72_1=bit +sff_cpld_reg.addr_72_1=0x0005007C +sff_cpld_reg.len_72_1=1 +sff_cpld_reg.bit_offset_72_1=4 + +sff_cpld_reg.mode_73_1=config +sff_cpld_reg.src_73_1=cpld +sff_cpld_reg.frmt_73_1=bit +sff_cpld_reg.addr_73_1=0x0005007C +sff_cpld_reg.len_73_1=1 +sff_cpld_reg.bit_offset_73_1=5 + +sff_cpld_reg.mode_74_1=config +sff_cpld_reg.src_74_1=cpld +sff_cpld_reg.frmt_74_1=bit +sff_cpld_reg.addr_74_1=0x0005007C +sff_cpld_reg.len_74_1=1 +sff_cpld_reg.bit_offset_74_1=5 + +sff_cpld_reg.mode_75_1=config +sff_cpld_reg.src_75_1=cpld +sff_cpld_reg.frmt_75_1=bit +sff_cpld_reg.addr_75_1=0x0005007C +sff_cpld_reg.len_75_1=1 +sff_cpld_reg.bit_offset_75_1=5 + +sff_cpld_reg.mode_76_1=config +sff_cpld_reg.src_76_1=cpld +sff_cpld_reg.frmt_76_1=bit +sff_cpld_reg.addr_76_1=0x0005007C +sff_cpld_reg.len_76_1=1 +sff_cpld_reg.bit_offset_76_1=5 + +sff_cpld_reg.mode_77_1=config +sff_cpld_reg.src_77_1=cpld +sff_cpld_reg.frmt_77_1=bit +sff_cpld_reg.addr_77_1=0x0005007C +sff_cpld_reg.len_77_1=1 +sff_cpld_reg.bit_offset_77_1=5 + +sff_cpld_reg.mode_78_1=config +sff_cpld_reg.src_78_1=cpld +sff_cpld_reg.frmt_78_1=bit +sff_cpld_reg.addr_78_1=0x0005007C +sff_cpld_reg.len_78_1=1 +sff_cpld_reg.bit_offset_78_1=5 + +sff_cpld_reg.mode_79_1=config +sff_cpld_reg.src_79_1=cpld +sff_cpld_reg.frmt_79_1=bit +sff_cpld_reg.addr_79_1=0x0005007C +sff_cpld_reg.len_79_1=1 +sff_cpld_reg.bit_offset_79_1=5 + +sff_cpld_reg.mode_80_1=config +sff_cpld_reg.src_80_1=cpld +sff_cpld_reg.frmt_80_1=bit +sff_cpld_reg.addr_80_1=0x0005007C +sff_cpld_reg.len_80_1=1 +sff_cpld_reg.bit_offset_80_1=5 + +sff_cpld_reg.mode_81_1=config +sff_cpld_reg.src_81_1=cpld +sff_cpld_reg.frmt_81_1=bit +sff_cpld_reg.addr_81_1=0x0005007C +sff_cpld_reg.len_81_1=1 +sff_cpld_reg.bit_offset_81_1=6 + +sff_cpld_reg.mode_82_1=config +sff_cpld_reg.src_82_1=cpld +sff_cpld_reg.frmt_82_1=bit +sff_cpld_reg.addr_82_1=0x0005007C +sff_cpld_reg.len_82_1=1 +sff_cpld_reg.bit_offset_82_1=6 + +sff_cpld_reg.mode_83_1=config +sff_cpld_reg.src_83_1=cpld +sff_cpld_reg.frmt_83_1=bit +sff_cpld_reg.addr_83_1=0x0005007C +sff_cpld_reg.len_83_1=1 +sff_cpld_reg.bit_offset_83_1=6 + +sff_cpld_reg.mode_84_1=config +sff_cpld_reg.src_84_1=cpld +sff_cpld_reg.frmt_84_1=bit +sff_cpld_reg.addr_84_1=0x0005007C +sff_cpld_reg.len_84_1=1 +sff_cpld_reg.bit_offset_84_1=6 + +sff_cpld_reg.mode_85_1=config +sff_cpld_reg.src_85_1=cpld +sff_cpld_reg.frmt_85_1=bit +sff_cpld_reg.addr_85_1=0x0005007C +sff_cpld_reg.len_85_1=1 +sff_cpld_reg.bit_offset_85_1=6 + +sff_cpld_reg.mode_86_1=config +sff_cpld_reg.src_86_1=cpld +sff_cpld_reg.frmt_86_1=bit +sff_cpld_reg.addr_86_1=0x0005007C +sff_cpld_reg.len_86_1=1 +sff_cpld_reg.bit_offset_86_1=6 + +sff_cpld_reg.mode_87_1=config +sff_cpld_reg.src_87_1=cpld +sff_cpld_reg.frmt_87_1=bit +sff_cpld_reg.addr_87_1=0x0005007C +sff_cpld_reg.len_87_1=1 +sff_cpld_reg.bit_offset_87_1=6 + +sff_cpld_reg.mode_88_1=config +sff_cpld_reg.src_88_1=cpld +sff_cpld_reg.frmt_88_1=bit +sff_cpld_reg.addr_88_1=0x0005007C +sff_cpld_reg.len_88_1=1 +sff_cpld_reg.bit_offset_88_1=6 + +sff_cpld_reg.mode_89_1=config +sff_cpld_reg.src_89_1=cpld +sff_cpld_reg.frmt_89_1=bit +sff_cpld_reg.addr_89_1=0x0005007C +sff_cpld_reg.len_89_1=1 +sff_cpld_reg.bit_offset_89_1=7 + +sff_cpld_reg.mode_90_1=config +sff_cpld_reg.src_90_1=cpld +sff_cpld_reg.frmt_90_1=bit +sff_cpld_reg.addr_90_1=0x0005007C +sff_cpld_reg.len_90_1=1 +sff_cpld_reg.bit_offset_90_1=7 + +sff_cpld_reg.mode_91_1=config +sff_cpld_reg.src_91_1=cpld +sff_cpld_reg.frmt_91_1=bit +sff_cpld_reg.addr_91_1=0x0005007C +sff_cpld_reg.len_91_1=1 +sff_cpld_reg.bit_offset_91_1=7 + +sff_cpld_reg.mode_92_1=config +sff_cpld_reg.src_92_1=cpld +sff_cpld_reg.frmt_92_1=bit +sff_cpld_reg.addr_92_1=0x0005007C +sff_cpld_reg.len_92_1=1 +sff_cpld_reg.bit_offset_92_1=7 + +sff_cpld_reg.mode_93_1=config +sff_cpld_reg.src_93_1=cpld +sff_cpld_reg.frmt_93_1=bit +sff_cpld_reg.addr_93_1=0x0005007C +sff_cpld_reg.len_93_1=1 +sff_cpld_reg.bit_offset_93_1=7 + +sff_cpld_reg.mode_94_1=config +sff_cpld_reg.src_94_1=cpld +sff_cpld_reg.frmt_94_1=bit +sff_cpld_reg.addr_94_1=0x0005007C +sff_cpld_reg.len_94_1=1 +sff_cpld_reg.bit_offset_94_1=7 + +sff_cpld_reg.mode_95_1=config +sff_cpld_reg.src_95_1=cpld +sff_cpld_reg.frmt_95_1=bit +sff_cpld_reg.addr_95_1=0x0005007C +sff_cpld_reg.len_95_1=1 +sff_cpld_reg.bit_offset_95_1=7 + +sff_cpld_reg.mode_96_1=config +sff_cpld_reg.src_96_1=cpld +sff_cpld_reg.frmt_96_1=bit +sff_cpld_reg.addr_96_1=0x0005007C +sff_cpld_reg.len_96_1=1 +sff_cpld_reg.bit_offset_96_1=7 + +sff_cpld_reg.mode_97_1=config +sff_cpld_reg.src_97_1=cpld +sff_cpld_reg.frmt_97_1=bit +sff_cpld_reg.addr_97_1=0x00070080 +sff_cpld_reg.len_97_1=1 +sff_cpld_reg.bit_offset_97_1=0 + +sff_cpld_reg.mode_98_1=config +sff_cpld_reg.src_98_1=cpld +sff_cpld_reg.frmt_98_1=bit +sff_cpld_reg.addr_98_1=0x00070080 +sff_cpld_reg.len_98_1=1 +sff_cpld_reg.bit_offset_98_1=0 + +sff_cpld_reg.mode_99_1=config +sff_cpld_reg.src_99_1=cpld +sff_cpld_reg.frmt_99_1=bit +sff_cpld_reg.addr_99_1=0x00070080 +sff_cpld_reg.len_99_1=1 +sff_cpld_reg.bit_offset_99_1=0 + +sff_cpld_reg.mode_100_1=config +sff_cpld_reg.src_100_1=cpld +sff_cpld_reg.frmt_100_1=bit +sff_cpld_reg.addr_100_1=0x00070080 +sff_cpld_reg.len_100_1=1 +sff_cpld_reg.bit_offset_100_1=0 + +sff_cpld_reg.mode_101_1=config +sff_cpld_reg.src_101_1=cpld +sff_cpld_reg.frmt_101_1=bit +sff_cpld_reg.addr_101_1=0x00070080 +sff_cpld_reg.len_101_1=1 +sff_cpld_reg.bit_offset_101_1=0 + +sff_cpld_reg.mode_102_1=config +sff_cpld_reg.src_102_1=cpld +sff_cpld_reg.frmt_102_1=bit +sff_cpld_reg.addr_102_1=0x00070080 +sff_cpld_reg.len_102_1=1 +sff_cpld_reg.bit_offset_102_1=0 + +sff_cpld_reg.mode_103_1=config +sff_cpld_reg.src_103_1=cpld +sff_cpld_reg.frmt_103_1=bit +sff_cpld_reg.addr_103_1=0x00070080 +sff_cpld_reg.len_103_1=1 +sff_cpld_reg.bit_offset_103_1=0 + +sff_cpld_reg.mode_104_1=config +sff_cpld_reg.src_104_1=cpld +sff_cpld_reg.frmt_104_1=bit +sff_cpld_reg.addr_104_1=0x00070080 +sff_cpld_reg.len_104_1=1 +sff_cpld_reg.bit_offset_104_1=0 + +sff_cpld_reg.mode_105_1=config +sff_cpld_reg.src_105_1=cpld +sff_cpld_reg.frmt_105_1=bit +sff_cpld_reg.addr_105_1=0x00070080 +sff_cpld_reg.len_105_1=1 +sff_cpld_reg.bit_offset_105_1=1 + +sff_cpld_reg.mode_106_1=config +sff_cpld_reg.src_106_1=cpld +sff_cpld_reg.frmt_106_1=bit +sff_cpld_reg.addr_106_1=0x00070080 +sff_cpld_reg.len_106_1=1 +sff_cpld_reg.bit_offset_106_1=1 + +sff_cpld_reg.mode_107_1=config +sff_cpld_reg.src_107_1=cpld +sff_cpld_reg.frmt_107_1=bit +sff_cpld_reg.addr_107_1=0x00070080 +sff_cpld_reg.len_107_1=1 +sff_cpld_reg.bit_offset_107_1=1 + +sff_cpld_reg.mode_108_1=config +sff_cpld_reg.src_108_1=cpld +sff_cpld_reg.frmt_108_1=bit +sff_cpld_reg.addr_108_1=0x00070080 +sff_cpld_reg.len_108_1=1 +sff_cpld_reg.bit_offset_108_1=1 + +sff_cpld_reg.mode_109_1=config +sff_cpld_reg.src_109_1=cpld +sff_cpld_reg.frmt_109_1=bit +sff_cpld_reg.addr_109_1=0x00070080 +sff_cpld_reg.len_109_1=1 +sff_cpld_reg.bit_offset_109_1=1 + +sff_cpld_reg.mode_110_1=config +sff_cpld_reg.src_110_1=cpld +sff_cpld_reg.frmt_110_1=bit +sff_cpld_reg.addr_110_1=0x00070080 +sff_cpld_reg.len_110_1=1 +sff_cpld_reg.bit_offset_110_1=1 + +sff_cpld_reg.mode_111_1=config +sff_cpld_reg.src_111_1=cpld +sff_cpld_reg.frmt_111_1=bit +sff_cpld_reg.addr_111_1=0x00070080 +sff_cpld_reg.len_111_1=1 +sff_cpld_reg.bit_offset_111_1=1 + +sff_cpld_reg.mode_112_1=config +sff_cpld_reg.src_112_1=cpld +sff_cpld_reg.frmt_112_1=bit +sff_cpld_reg.addr_112_1=0x00070080 +sff_cpld_reg.len_112_1=1 +sff_cpld_reg.bit_offset_112_1=1 + +sff_cpld_reg.mode_113_1=config +sff_cpld_reg.src_113_1=cpld +sff_cpld_reg.frmt_113_1=bit +sff_cpld_reg.addr_113_1=0x00070080 +sff_cpld_reg.len_113_1=1 +sff_cpld_reg.bit_offset_113_1=2 + +sff_cpld_reg.mode_114_1=config +sff_cpld_reg.src_114_1=cpld +sff_cpld_reg.frmt_114_1=bit +sff_cpld_reg.addr_114_1=0x00070080 +sff_cpld_reg.len_114_1=1 +sff_cpld_reg.bit_offset_114_1=2 + +sff_cpld_reg.mode_115_1=config +sff_cpld_reg.src_115_1=cpld +sff_cpld_reg.frmt_115_1=bit +sff_cpld_reg.addr_115_1=0x00070080 +sff_cpld_reg.len_115_1=1 +sff_cpld_reg.bit_offset_115_1=2 + +sff_cpld_reg.mode_116_1=config +sff_cpld_reg.src_116_1=cpld +sff_cpld_reg.frmt_116_1=bit +sff_cpld_reg.addr_116_1=0x00070080 +sff_cpld_reg.len_116_1=1 +sff_cpld_reg.bit_offset_116_1=2 + +sff_cpld_reg.mode_117_1=config +sff_cpld_reg.src_117_1=cpld +sff_cpld_reg.frmt_117_1=bit +sff_cpld_reg.addr_117_1=0x00070080 +sff_cpld_reg.len_117_1=1 +sff_cpld_reg.bit_offset_117_1=2 + +sff_cpld_reg.mode_118_1=config +sff_cpld_reg.src_118_1=cpld +sff_cpld_reg.frmt_118_1=bit +sff_cpld_reg.addr_118_1=0x00070080 +sff_cpld_reg.len_118_1=1 +sff_cpld_reg.bit_offset_118_1=2 + +sff_cpld_reg.mode_119_1=config +sff_cpld_reg.src_119_1=cpld +sff_cpld_reg.frmt_119_1=bit +sff_cpld_reg.addr_119_1=0x00070080 +sff_cpld_reg.len_119_1=1 +sff_cpld_reg.bit_offset_119_1=2 + +sff_cpld_reg.mode_120_1=config +sff_cpld_reg.src_120_1=cpld +sff_cpld_reg.frmt_120_1=bit +sff_cpld_reg.addr_120_1=0x00070080 +sff_cpld_reg.len_120_1=1 +sff_cpld_reg.bit_offset_120_1=2 + +sff_cpld_reg.mode_121_1=config +sff_cpld_reg.src_121_1=cpld +sff_cpld_reg.frmt_121_1=bit +sff_cpld_reg.addr_121_1=0x00070080 +sff_cpld_reg.len_121_1=1 +sff_cpld_reg.bit_offset_121_1=3 + +sff_cpld_reg.mode_122_1=config +sff_cpld_reg.src_122_1=cpld +sff_cpld_reg.frmt_122_1=bit +sff_cpld_reg.addr_122_1=0x00070080 +sff_cpld_reg.len_122_1=1 +sff_cpld_reg.bit_offset_122_1=3 + +sff_cpld_reg.mode_123_1=config +sff_cpld_reg.src_123_1=cpld +sff_cpld_reg.frmt_123_1=bit +sff_cpld_reg.addr_123_1=0x00070080 +sff_cpld_reg.len_123_1=1 +sff_cpld_reg.bit_offset_123_1=3 + +sff_cpld_reg.mode_124_1=config +sff_cpld_reg.src_124_1=cpld +sff_cpld_reg.frmt_124_1=bit +sff_cpld_reg.addr_124_1=0x00070080 +sff_cpld_reg.len_124_1=1 +sff_cpld_reg.bit_offset_124_1=3 + +sff_cpld_reg.mode_125_1=config +sff_cpld_reg.src_125_1=cpld +sff_cpld_reg.frmt_125_1=bit +sff_cpld_reg.addr_125_1=0x00070080 +sff_cpld_reg.len_125_1=1 +sff_cpld_reg.bit_offset_125_1=3 + +sff_cpld_reg.mode_126_1=config +sff_cpld_reg.src_126_1=cpld +sff_cpld_reg.frmt_126_1=bit +sff_cpld_reg.addr_126_1=0x00070080 +sff_cpld_reg.len_126_1=1 +sff_cpld_reg.bit_offset_126_1=3 + +sff_cpld_reg.mode_127_1=config +sff_cpld_reg.src_127_1=cpld +sff_cpld_reg.frmt_127_1=bit +sff_cpld_reg.addr_127_1=0x00070080 +sff_cpld_reg.len_127_1=1 +sff_cpld_reg.bit_offset_127_1=3 + +sff_cpld_reg.mode_128_1=config +sff_cpld_reg.src_128_1=cpld +sff_cpld_reg.frmt_128_1=bit +sff_cpld_reg.addr_128_1=0x00070080 +sff_cpld_reg.len_128_1=1 +sff_cpld_reg.bit_offset_128_1=3 + diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-V2-SENSOR.cfg b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-V2-SENSOR.cfg new file mode 100755 index 000000000000..6cf1bc3adfc8 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-V2-SENSOR.cfg @@ -0,0 +1,2405 @@ +# temp sensor number +dev_num_0_1=34 + +# voltage sensor number +dev_num_0_2=56 + +# current sensor number +dev_num_0_3=7 + +# sensor temp1 input +hwmon_temp.mode_0x0001_0x00=config +hwmon_temp.int_cons_0x0001_0x00=0 +hwmon_temp.src_0x0001_0x00=file +hwmon_temp.frmt_0x0001_0x00=buf +hwmon_temp.fpath_0x0001_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0001_0x00=0 +hwmon_temp.len_0x0001_0x00=8 +hwmon_temp.bit_offset_0x0001_0x00= +hwmon_temp.str_cons_0x0001_0x00=temp1_input + +# sensor temp1 alias +hwmon_temp.mode_0x0001_0x01=config +hwmon_temp.int_cons_0x0001_0x01= +hwmon_temp.src_0x0001_0x01=file +hwmon_temp.frmt_0x0001_0x01=buf +hwmon_temp.fpath_0x0001_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0001_0x01=0 +hwmon_temp.len_0x0001_0x01=16 +hwmon_temp.bit_offset_0x0001_0x01= +hwmon_temp.str_cons_0x0001_0x01=temp1_label + +hwmon_temp.mode_0x0001_0x02=str_constant +hwmon_temp.str_cons_0x0001_0x02=cpu + +# sensor temp1 max +hwmon_temp.mode_0x0001_0x03=config +hwmon_temp.int_cons_0x0001_0x03=0 +hwmon_temp.src_0x0001_0x03=file +hwmon_temp.frmt_0x0001_0x03=buf +hwmon_temp.fpath_0x0001_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0001_0x03=0 +hwmon_temp.len_0x0001_0x03=8 +hwmon_temp.bit_offset_0x0001_0x03= +hwmon_temp.str_cons_0x0001_0x03=temp1_max + + +# sensor temp2 input +hwmon_temp.mode_0x0002_0x00=config +hwmon_temp.int_cons_0x0002_0x00=0 +hwmon_temp.src_0x0002_0x00=file +hwmon_temp.frmt_0x0002_0x00=buf +hwmon_temp.fpath_0x0002_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0002_0x00=0 +hwmon_temp.len_0x0002_0x00=8 +hwmon_temp.bit_offset_0x0002_0x00= +hwmon_temp.str_cons_0x0002_0x00=temp2_input + +# sensor temp2 alias +hwmon_temp.mode_0x0002_0x01=config +hwmon_temp.int_cons_0x0002_0x01= +hwmon_temp.src_0x0002_0x01=file +hwmon_temp.frmt_0x0002_0x01=buf +hwmon_temp.fpath_0x0002_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0002_0x01=0 +hwmon_temp.len_0x0002_0x01=16 +hwmon_temp.bit_offset_0x0002_0x01= +hwmon_temp.str_cons_0x0002_0x01=temp2_label + +hwmon_temp.mode_0x0002_0x02=str_constant +hwmon_temp.str_cons_0x0002_0x02=cpu + +# sensor temp2 max +hwmon_temp.mode_0x0002_0x03=config +hwmon_temp.int_cons_0x0002_0x03=0 +hwmon_temp.src_0x0002_0x03=file +hwmon_temp.frmt_0x0002_0x03=buf +hwmon_temp.fpath_0x0002_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0002_0x03=0 +hwmon_temp.len_0x0002_0x03=8 +hwmon_temp.bit_offset_0x0002_0x03= +hwmon_temp.str_cons_0x0002_0x03=temp2_max + + +# sensor temp3 input +hwmon_temp.mode_0x0003_0x00=config +hwmon_temp.int_cons_0x0003_0x00=0 +hwmon_temp.src_0x0003_0x00=file +hwmon_temp.frmt_0x0003_0x00=buf +hwmon_temp.fpath_0x0003_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0003_0x00=0 +hwmon_temp.len_0x0003_0x00=8 +hwmon_temp.bit_offset_0x0003_0x00= +hwmon_temp.str_cons_0x0003_0x00=temp3_input + +# sensor temp3 alias +hwmon_temp.mode_0x0003_0x01=config +hwmon_temp.int_cons_0x0003_0x01= +hwmon_temp.src_0x0003_0x01=file +hwmon_temp.frmt_0x0003_0x01=buf +hwmon_temp.fpath_0x0003_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0003_0x01=0 +hwmon_temp.len_0x0003_0x01=16 +hwmon_temp.bit_offset_0x0003_0x01= +hwmon_temp.str_cons_0x0003_0x01=temp3_label + +hwmon_temp.mode_0x0003_0x02=str_constant +hwmon_temp.str_cons_0x0003_0x02=cpu + +# sensor temp3 max +hwmon_temp.mode_0x0003_0x03=config +hwmon_temp.int_cons_0x0003_0x03=0 +hwmon_temp.src_0x0003_0x03=file +hwmon_temp.frmt_0x0003_0x03=buf +hwmon_temp.fpath_0x0003_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0003_0x03=0 +hwmon_temp.len_0x0003_0x03=8 +hwmon_temp.bit_offset_0x0003_0x03= +hwmon_temp.str_cons_0x0003_0x03=temp3_max + + +# sensor temp4 input +hwmon_temp.mode_0x0004_0x00=config +hwmon_temp.int_cons_0x0004_0x00=0 +hwmon_temp.src_0x0004_0x00=file +hwmon_temp.frmt_0x0004_0x00=buf +hwmon_temp.fpath_0x0004_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0004_0x00=0 +hwmon_temp.len_0x0004_0x00=8 +hwmon_temp.bit_offset_0x0004_0x00= +hwmon_temp.str_cons_0x0004_0x00=temp4_input + +# sensor temp4 alias +hwmon_temp.mode_0x0004_0x01=config +hwmon_temp.int_cons_0x0004_0x01= +hwmon_temp.src_0x0004_0x01=file +hwmon_temp.frmt_0x0004_0x01=buf +hwmon_temp.fpath_0x0004_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0004_0x01=0 +hwmon_temp.len_0x0004_0x01=16 +hwmon_temp.bit_offset_0x0004_0x01= +hwmon_temp.str_cons_0x0004_0x01=temp4_label + +hwmon_temp.mode_0x0004_0x02=str_constant +hwmon_temp.str_cons_0x0004_0x02=cpu + +# sensor temp4 max +hwmon_temp.mode_0x0004_0x03=config +hwmon_temp.int_cons_0x0004_0x03=0 +hwmon_temp.src_0x0004_0x03=file +hwmon_temp.frmt_0x0004_0x03=buf +hwmon_temp.fpath_0x0004_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0004_0x03=0 +hwmon_temp.len_0x0004_0x03=8 +hwmon_temp.bit_offset_0x0004_0x03= +hwmon_temp.str_cons_0x0004_0x03=temp4_max + + +# sensor temp5 input +hwmon_temp.mode_0x0005_0x00=config +hwmon_temp.int_cons_0x0005_0x00=0 +hwmon_temp.src_0x0005_0x00=file +hwmon_temp.frmt_0x0005_0x00=buf +hwmon_temp.fpath_0x0005_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0005_0x00=0 +hwmon_temp.len_0x0005_0x00=8 +hwmon_temp.bit_offset_0x0005_0x00= +hwmon_temp.str_cons_0x0005_0x00=temp5_input + +# sensor temp5 alias +hwmon_temp.mode_0x0005_0x01=config +hwmon_temp.int_cons_0x0005_0x01= +hwmon_temp.src_0x0005_0x01=file +hwmon_temp.frmt_0x0005_0x01=buf +hwmon_temp.fpath_0x0005_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0005_0x01=0 +hwmon_temp.len_0x0005_0x01=16 +hwmon_temp.bit_offset_0x0005_0x01= +hwmon_temp.str_cons_0x0005_0x01=temp5_label + +hwmon_temp.mode_0x0005_0x02=str_constant +hwmon_temp.str_cons_0x0005_0x02=cpu + +# sensor temp5 max +hwmon_temp.mode_0x0005_0x03=config +hwmon_temp.int_cons_0x0005_0x03=0 +hwmon_temp.src_0x0005_0x03=file +hwmon_temp.frmt_0x0005_0x03=buf +hwmon_temp.fpath_0x0005_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0005_0x03=0 +hwmon_temp.len_0x0005_0x03=8 +hwmon_temp.bit_offset_0x0005_0x03= +hwmon_temp.str_cons_0x0005_0x03=temp5_max + +# sensor temp6 input +hwmon_temp.mode_0x0006_0x00=config +hwmon_temp.int_cons_0x0006_0x00=0 +hwmon_temp.src_0x0006_0x00=file +hwmon_temp.frmt_0x0006_0x00=buf +hwmon_temp.fpath_0x0006_0x00=/sys/bus/i2c/devices/107-004b/hwmon/ +hwmon_temp.addr_0x0006_0x00=0 +hwmon_temp.len_0x0006_0x00=8 +hwmon_temp.bit_offset_0x0006_0x00= +hwmon_temp.str_cons_0x0006_0x00=temp1_input + +hwmon_temp.mode_0x0006_0x01=str_constant +hwmon_temp.str_cons_0x0006_0x01=air_inlet + +hwmon_temp.mode_0x0006_0x02=str_constant +hwmon_temp.str_cons_0x0006_0x02=lm75 + +hwmon_temp.mode_0x0006_0x03=config +hwmon_temp.int_cons_0x0006_0x03=0 +hwmon_temp.src_0x0006_0x03=file +hwmon_temp.frmt_0x0006_0x03=buf +hwmon_temp.fpath_0x0006_0x03=/sys/bus/i2c/devices/107-004b/hwmon/ +hwmon_temp.addr_0x0006_0x03=0 +hwmon_temp.len_0x0006_0x03=8 +hwmon_temp.bit_offset_0x0006_0x03= +hwmon_temp.str_cons_0x0006_0x03=temp1_max + +hwmon_temp.mode_0x0006_0x04=config +hwmon_temp.int_cons_0x0006_0x04=0 +hwmon_temp.src_0x0006_0x04=file +hwmon_temp.frmt_0x0006_0x04=buf +hwmon_temp.fpath_0x0006_0x04=/sys/bus/i2c/devices/107-004b/hwmon/ +hwmon_temp.addr_0x0006_0x04=0 +hwmon_temp.len_0x0006_0x04=8 +hwmon_temp.bit_offset_0x0006_0x04= +hwmon_temp.str_cons_0x0006_0x04=temp1_max_hyst + +hwmon_temp.mode_0x0007_0x00=config +hwmon_temp.int_cons_0x0007_0x00=0 +hwmon_temp.src_0x0007_0x00=file +hwmon_temp.frmt_0x0007_0x00=buf +hwmon_temp.fpath_0x0007_0x00=/sys/bus/i2c/devices/64-004f/hwmon/ +hwmon_temp.addr_0x0007_0x00=0 +hwmon_temp.len_0x0007_0x00=8 +hwmon_temp.bit_offset_0x0007_0x00= +hwmon_temp.str_cons_0x0007_0x00=temp1_input + +hwmon_temp.mode_0x0007_0x01=str_constant +hwmon_temp.str_cons_0x0007_0x01=Uport_air_inlet_L + +hwmon_temp.mode_0x0007_0x02=str_constant +hwmon_temp.str_cons_0x0007_0x02=lm75 + +hwmon_temp.mode_0x0007_0x03=config +hwmon_temp.int_cons_0x0007_0x03=0 +hwmon_temp.src_0x0007_0x03=file +hwmon_temp.frmt_0x0007_0x03=buf +hwmon_temp.fpath_0x0007_0x03=/sys/bus/i2c/devices/64-004f/hwmon/ +hwmon_temp.addr_0x0007_0x03=0 +hwmon_temp.len_0x0007_0x03=8 +hwmon_temp.bit_offset_0x0007_0x03= +hwmon_temp.str_cons_0x0007_0x03=temp1_max + +hwmon_temp.mode_0x0007_0x04=config +hwmon_temp.int_cons_0x0007_0x04=0 +hwmon_temp.src_0x0007_0x04=file +hwmon_temp.frmt_0x0007_0x04=buf +hwmon_temp.fpath_0x0007_0x04=/sys/bus/i2c/devices/64-004f/hwmon/ +hwmon_temp.addr_0x0007_0x04=0 +hwmon_temp.len_0x0007_0x04=8 +hwmon_temp.bit_offset_0x0007_0x04= +hwmon_temp.str_cons_0x0007_0x04=temp1_max_hyst + +hwmon_temp.mode_0x0008_0x00=config +hwmon_temp.int_cons_0x0008_0x00=0 +hwmon_temp.src_0x0008_0x00=file +hwmon_temp.frmt_0x0008_0x00=buf +hwmon_temp.fpath_0x0008_0x00=/sys/bus/i2c/devices/63-004b/hwmon/ +hwmon_temp.addr_0x0008_0x00=0 +hwmon_temp.len_0x0008_0x00=8 +hwmon_temp.bit_offset_0x0008_0x00= +hwmon_temp.str_cons_0x0008_0x00=temp1_input + +hwmon_temp.mode_0x0008_0x01=str_constant +hwmon_temp.str_cons_0x0008_0x01=Uport_air_inlet_R + +hwmon_temp.mode_0x0008_0x02=str_constant +hwmon_temp.str_cons_0x0008_0x02=lm75 + +hwmon_temp.mode_0x0008_0x03=config +hwmon_temp.int_cons_0x0008_0x03=0 +hwmon_temp.src_0x0008_0x03=file +hwmon_temp.frmt_0x0008_0x03=buf +hwmon_temp.fpath_0x0008_0x03=/sys/bus/i2c/devices/63-004b/hwmon/ +hwmon_temp.addr_0x0008_0x03=0 +hwmon_temp.len_0x0008_0x03=8 +hwmon_temp.bit_offset_0x0008_0x03= +hwmon_temp.str_cons_0x0008_0x03=temp1_max + +hwmon_temp.mode_0x0008_0x04=config +hwmon_temp.int_cons_0x0008_0x04=0 +hwmon_temp.src_0x0008_0x04=file +hwmon_temp.frmt_0x0008_0x04=buf +hwmon_temp.fpath_0x0008_0x04=/sys/bus/i2c/devices/63-004b/hwmon/ +hwmon_temp.addr_0x0008_0x04=0 +hwmon_temp.len_0x0008_0x04=8 +hwmon_temp.bit_offset_0x0008_0x04= +hwmon_temp.str_cons_0x0008_0x04=temp1_max_hyst + +hwmon_temp.mode_0x0009_0x00=config +hwmon_temp.int_cons_0x0009_0x00=0 +hwmon_temp.src_0x0009_0x00=file +hwmon_temp.frmt_0x0009_0x00=buf +hwmon_temp.fpath_0x0009_0x00=/sys/bus/i2c/devices/114-004b/hwmon/ +hwmon_temp.addr_0x0009_0x00=0 +hwmon_temp.len_0x0009_0x00=8 +hwmon_temp.bit_offset_0x0009_0x00= +hwmon_temp.str_cons_0x0009_0x00=temp1_input + +hwmon_temp.mode_0x0009_0x01=str_constant +hwmon_temp.str_cons_0x0009_0x01=Dport_air_inlet_L + +hwmon_temp.mode_0x0009_0x02=str_constant +hwmon_temp.str_cons_0x0009_0x02=lm75 + +hwmon_temp.mode_0x0009_0x03=config +hwmon_temp.int_cons_0x0009_0x03=0 +hwmon_temp.src_0x0009_0x03=file +hwmon_temp.frmt_0x0009_0x03=buf +hwmon_temp.fpath_0x0009_0x03=/sys/bus/i2c/devices/114-004b/hwmon/ +hwmon_temp.addr_0x0009_0x03=0 +hwmon_temp.len_0x0009_0x03=8 +hwmon_temp.bit_offset_0x0009_0x03= +hwmon_temp.str_cons_0x0009_0x03=temp1_max + +hwmon_temp.mode_0x0009_0x04=config +hwmon_temp.int_cons_0x0009_0x04=0 +hwmon_temp.src_0x0009_0x04=file +hwmon_temp.frmt_0x0009_0x04=buf +hwmon_temp.fpath_0x0009_0x04=/sys/bus/i2c/devices/114-004b/hwmon/ +hwmon_temp.addr_0x0009_0x04=0 +hwmon_temp.len_0x0009_0x04=8 +hwmon_temp.bit_offset_0x0009_0x04= +hwmon_temp.str_cons_0x0009_0x04=temp1_max_hyst + +hwmon_temp.mode_0x000a_0x00=config +hwmon_temp.int_cons_0x000a_0x00=0 +hwmon_temp.src_0x000a_0x00=file +hwmon_temp.frmt_0x000a_0x00=buf +hwmon_temp.fpath_0x000a_0x00=/sys/bus/i2c/devices/115-004f/hwmon/ +hwmon_temp.addr_0x000a_0x00=0 +hwmon_temp.len_0x000a_0x00=8 +hwmon_temp.bit_offset_0x000a_0x00= +hwmon_temp.str_cons_0x000a_0x00=temp1_input + +hwmon_temp.mode_0x000a_0x01=str_constant +hwmon_temp.str_cons_0x000a_0x01=Dport_air_inlet_R + +hwmon_temp.mode_0x000a_0x02=str_constant +hwmon_temp.str_cons_0x000a_0x02=lm75 + +hwmon_temp.mode_0x000a_0x03=config +hwmon_temp.int_cons_0x000a_0x03=0 +hwmon_temp.src_0x000a_0x03=file +hwmon_temp.frmt_0x000a_0x03=buf +hwmon_temp.fpath_0x000a_0x03=/sys/bus/i2c/devices/115-004f/hwmon/ +hwmon_temp.addr_0x000a_0x03=0 +hwmon_temp.len_0x000a_0x03=8 +hwmon_temp.bit_offset_0x000a_0x03= +hwmon_temp.str_cons_0x000a_0x03=temp1_max + +hwmon_temp.mode_0x000a_0x04=config +hwmon_temp.int_cons_0x000a_0x04=0 +hwmon_temp.src_0x000a_0x04=file +hwmon_temp.frmt_0x000a_0x04=buf +hwmon_temp.fpath_0x000a_0x04=/sys/bus/i2c/devices/115-004f/hwmon/ +hwmon_temp.addr_0x000a_0x04=0 +hwmon_temp.len_0x000a_0x04=8 +hwmon_temp.bit_offset_0x000a_0x04= +hwmon_temp.str_cons_0x000a_0x04=temp1_max_hyst + +hwmon_temp.mode_0x000b_0x00=config +hwmon_temp.int_cons_0x000b_0x00=0 +hwmon_temp.src_0x000b_0x00=file +hwmon_temp.frmt_0x000b_0x00=buf +hwmon_temp.fpath_0x000b_0x00=/sys/bus/i2c/devices/69-004b/hwmon/ +hwmon_temp.addr_0x000b_0x00=0 +hwmon_temp.len_0x000b_0x00=8 +hwmon_temp.bit_offset_0x000b_0x00= +hwmon_temp.str_cons_0x000b_0x00=temp1_input + +hwmon_temp.mode_0x000b_0x01=str_constant +hwmon_temp.str_cons_0x000b_0x01=MAC_air_inlet + +hwmon_temp.mode_0x000b_0x02=str_constant +hwmon_temp.str_cons_0x000b_0x02=lm75 + +hwmon_temp.mode_0x000b_0x03=config +hwmon_temp.int_cons_0x000b_0x03=0 +hwmon_temp.src_0x000b_0x03=file +hwmon_temp.frmt_0x000b_0x03=buf +hwmon_temp.fpath_0x000b_0x03=/sys/bus/i2c/devices/69-004b/hwmon/ +hwmon_temp.addr_0x000b_0x03=0 +hwmon_temp.len_0x000b_0x03=8 +hwmon_temp.bit_offset_0x000b_0x03= +hwmon_temp.str_cons_0x000b_0x03=temp1_max + +hwmon_temp.mode_0x000b_0x04=config +hwmon_temp.int_cons_0x000b_0x04=0 +hwmon_temp.src_0x000b_0x04=file +hwmon_temp.frmt_0x000b_0x04=buf +hwmon_temp.fpath_0x000b_0x04=/sys/bus/i2c/devices/69-004b/hwmon/ +hwmon_temp.addr_0x000b_0x04=0 +hwmon_temp.len_0x000b_0x04=8 +hwmon_temp.bit_offset_0x000b_0x04= +hwmon_temp.str_cons_0x000b_0x04=temp1_max_hyst + +hwmon_temp.mode_0x000c_0x00=config +hwmon_temp.int_cons_0x000c_0x00=0 +hwmon_temp.src_0x000c_0x00=file +hwmon_temp.frmt_0x000c_0x00=buf +hwmon_temp.fpath_0x000c_0x00=/sys/bus/i2c/devices/109-004b/hwmon/ +hwmon_temp.addr_0x000c_0x00=0 +hwmon_temp.len_0x000c_0x00=8 +hwmon_temp.bit_offset_0x000c_0x00= +hwmon_temp.str_cons_0x000c_0x00=temp1_input + +hwmon_temp.mode_0x000c_0x01=str_constant +hwmon_temp.str_cons_0x000c_0x01=Base_air_inlet + +hwmon_temp.mode_0x000c_0x02=str_constant +hwmon_temp.str_cons_0x000c_0x02=lm75 + +hwmon_temp.mode_0x000c_0x03=config +hwmon_temp.int_cons_0x000c_0x03=0 +hwmon_temp.src_0x000c_0x03=file +hwmon_temp.frmt_0x000c_0x03=buf +hwmon_temp.fpath_0x000c_0x03=/sys/bus/i2c/devices/109-004b/hwmon/ +hwmon_temp.addr_0x000c_0x03=0 +hwmon_temp.len_0x000c_0x03=8 +hwmon_temp.bit_offset_0x000c_0x03= +hwmon_temp.str_cons_0x000c_0x03=temp1_max + +hwmon_temp.mode_0x000c_0x04=config +hwmon_temp.int_cons_0x000c_0x04=0 +hwmon_temp.src_0x000c_0x04=file +hwmon_temp.frmt_0x000c_0x04=buf +hwmon_temp.fpath_0x000c_0x04=/sys/bus/i2c/devices/109-004b/hwmon/ +hwmon_temp.addr_0x000c_0x04=0 +hwmon_temp.len_0x000c_0x04=8 +hwmon_temp.bit_offset_0x000c_0x04= +hwmon_temp.str_cons_0x000c_0x04=temp1_max_hyst + +hwmon_temp.mode_0x000d_0x00=config +hwmon_temp.int_cons_0x000d_0x00=0 +hwmon_temp.src_0x000d_0x00=file +hwmon_temp.frmt_0x000d_0x00=buf +hwmon_temp.fpath_0x000d_0x00=/sys/bus/i2c/devices/70-004f/hwmon/ +hwmon_temp.addr_0x000d_0x00=0 +hwmon_temp.len_0x000d_0x00=8 +hwmon_temp.bit_offset_0x000d_0x00= +hwmon_temp.str_cons_0x000d_0x00=temp1_input + +hwmon_temp.mode_0x000d_0x01=str_constant +hwmon_temp.str_cons_0x000d_0x01=MAC_air_outlet + +hwmon_temp.mode_0x000d_0x02=str_constant +hwmon_temp.str_cons_0x000d_0x02=lm75 + +hwmon_temp.mode_0x000d_0x03=config +hwmon_temp.int_cons_0x000d_0x03=0 +hwmon_temp.src_0x000d_0x03=file +hwmon_temp.frmt_0x000d_0x03=buf +hwmon_temp.fpath_0x000d_0x03=/sys/bus/i2c/devices/70-004f/hwmon/ +hwmon_temp.addr_0x000d_0x03=0 +hwmon_temp.len_0x000d_0x03=8 +hwmon_temp.bit_offset_0x000d_0x03= +hwmon_temp.str_cons_0x000d_0x03=temp1_max + +hwmon_temp.mode_0x000d_0x04=config +hwmon_temp.int_cons_0x000d_0x04=0 +hwmon_temp.src_0x000d_0x04=file +hwmon_temp.frmt_0x000d_0x04=buf +hwmon_temp.fpath_0x000d_0x04=/sys/bus/i2c/devices/70-004f/hwmon/ +hwmon_temp.addr_0x000d_0x04=0 +hwmon_temp.len_0x000d_0x04=8 +hwmon_temp.bit_offset_0x000d_0x04= +hwmon_temp.str_cons_0x000d_0x04=temp1_max_hyst + +hwmon_temp.mode_0x000e_0x00=config +hwmon_temp.int_cons_0x000e_0x00=0 +hwmon_temp.src_0x000e_0x00=file +hwmon_temp.frmt_0x000e_0x00=buf +hwmon_temp.fpath_0x000e_0x00=/sys/bus/i2c/devices/71-004c/hwmon/ +hwmon_temp.addr_0x000e_0x00=0 +hwmon_temp.len_0x000e_0x00=8 +hwmon_temp.bit_offset_0x000e_0x00= +hwmon_temp.str_cons_0x000e_0x00=temp2_input + +hwmon_temp.mode_0x000e_0x01=str_constant +hwmon_temp.str_cons_0x000e_0x01=MAC_TEMPDIODE0 + +hwmon_temp.mode_0x000e_0x02=str_constant +hwmon_temp.str_cons_0x000e_0x02=tmp411 + +hwmon_temp.mode_0x000e_0x03=config +hwmon_temp.int_cons_0x000e_0x03=0 +hwmon_temp.src_0x000e_0x03=file +hwmon_temp.frmt_0x000e_0x03=buf +hwmon_temp.fpath_0x000e_0x03=/sys/bus/i2c/devices/71-004c/hwmon/ +hwmon_temp.addr_0x000e_0x03=0 +hwmon_temp.len_0x000e_0x03=8 +hwmon_temp.bit_offset_0x000e_0x03= +hwmon_temp.str_cons_0x000e_0x03=temp2_max + +hwmon_temp.mode_0x000e_0x04=config +hwmon_temp.int_cons_0x000e_0x04=0 +hwmon_temp.src_0x000e_0x04=file +hwmon_temp.frmt_0x000e_0x04=buf +hwmon_temp.fpath_0x000e_0x04=/sys/bus/i2c/devices/71-004c/hwmon/ +hwmon_temp.addr_0x000e_0x04=0 +hwmon_temp.len_0x000e_0x04=8 +hwmon_temp.bit_offset_0x000e_0x04= +hwmon_temp.str_cons_0x000e_0x04=temp2_max_hyst + +hwmon_temp.mode_0x000f_0x00=config +hwmon_temp.int_cons_0x000f_0x00=0 +hwmon_temp.src_0x000f_0x00=file +hwmon_temp.frmt_0x000f_0x00=buf +hwmon_temp.fpath_0x000f_0x00=/sys/bus/i2c/devices/72-004c/hwmon/ +hwmon_temp.addr_0x000f_0x00=0 +hwmon_temp.len_0x000f_0x00=8 +hwmon_temp.bit_offset_0x000f_0x00= +hwmon_temp.str_cons_0x000f_0x00=temp2_input + +hwmon_temp.mode_0x000f_0x01=str_constant +hwmon_temp.str_cons_0x000f_0x01=MAC_TEMPDIODE1 + +hwmon_temp.mode_0x000f_0x02=str_constant +hwmon_temp.str_cons_0x000f_0x02=tmp411 + +hwmon_temp.mode_0x000f_0x03=config +hwmon_temp.int_cons_0x000f_0x03=0 +hwmon_temp.src_0x000f_0x03=file +hwmon_temp.frmt_0x000f_0x03=buf +hwmon_temp.fpath_0x000f_0x03=/sys/bus/i2c/devices/72-004c/hwmon/ +hwmon_temp.addr_0x000f_0x03=0 +hwmon_temp.len_0x000f_0x03=8 +hwmon_temp.bit_offset_0x000f_0x03= +hwmon_temp.str_cons_0x000f_0x03=temp2_max + +hwmon_temp.mode_0x000f_0x04=config +hwmon_temp.int_cons_0x000f_0x04=0 +hwmon_temp.src_0x000f_0x04=file +hwmon_temp.frmt_0x000f_0x04=buf +hwmon_temp.fpath_0x000f_0x04=/sys/bus/i2c/devices/72-004c/hwmon/ +hwmon_temp.addr_0x000f_0x04=0 +hwmon_temp.len_0x000f_0x04=8 +hwmon_temp.bit_offset_0x000f_0x04= +hwmon_temp.str_cons_0x000f_0x04=temp2_max_hyst + +hwmon_temp.mode_0x0010_0x00=config +hwmon_temp.int_cons_0x0010_0x00=0 +hwmon_temp.src_0x0010_0x00=file +hwmon_temp.frmt_0x0010_0x00=buf +hwmon_temp.fpath_0x0010_0x00=/sys/bus/i2c/devices/88-0048/hwmon/ +hwmon_temp.addr_0x0010_0x00=0 +hwmon_temp.len_0x0010_0x00=8 +hwmon_temp.bit_offset_0x0010_0x00= +hwmon_temp.str_cons_0x0010_0x00=temp1_input + +hwmon_temp.mode_0x0010_0x01=str_constant +hwmon_temp.str_cons_0x0010_0x01=FCB_air_outlet_UL + +hwmon_temp.mode_0x0010_0x02=str_constant +hwmon_temp.str_cons_0x0010_0x02=lm75 + +hwmon_temp.mode_0x0010_0x03=config +hwmon_temp.int_cons_0x0010_0x03=0 +hwmon_temp.src_0x0010_0x03=file +hwmon_temp.frmt_0x0010_0x03=buf +hwmon_temp.fpath_0x0010_0x03=/sys/bus/i2c/devices/88-0048/hwmon/ +hwmon_temp.addr_0x0010_0x03=0 +hwmon_temp.len_0x0010_0x03=8 +hwmon_temp.bit_offset_0x0010_0x03= +hwmon_temp.str_cons_0x0010_0x03=temp1_max + +hwmon_temp.mode_0x0010_0x04=config +hwmon_temp.int_cons_0x0010_0x04=0 +hwmon_temp.src_0x0010_0x04=file +hwmon_temp.frmt_0x0010_0x04=buf +hwmon_temp.fpath_0x0010_0x04=/sys/bus/i2c/devices/88-0048/hwmon/ +hwmon_temp.addr_0x0010_0x04=0 +hwmon_temp.len_0x0010_0x04=8 +hwmon_temp.bit_offset_0x0010_0x04= +hwmon_temp.str_cons_0x0010_0x04=temp1_max_hyst + +hwmon_temp.mode_0x0011_0x00=config +hwmon_temp.int_cons_0x0011_0x00=0 +hwmon_temp.src_0x0011_0x00=file +hwmon_temp.frmt_0x0011_0x00=buf +hwmon_temp.fpath_0x0011_0x00=/sys/bus/i2c/devices/89-0049/hwmon/ +hwmon_temp.addr_0x0011_0x00=0 +hwmon_temp.len_0x0011_0x00=8 +hwmon_temp.bit_offset_0x0011_0x00= +hwmon_temp.str_cons_0x0011_0x00=temp1_input + +hwmon_temp.mode_0x0011_0x01=str_constant +hwmon_temp.str_cons_0x0011_0x01=FCB_air_outlet_UR + +hwmon_temp.mode_0x0011_0x02=str_constant +hwmon_temp.str_cons_0x0011_0x02=lm75 + +hwmon_temp.mode_0x0011_0x03=config +hwmon_temp.int_cons_0x0011_0x03=0 +hwmon_temp.src_0x0011_0x03=file +hwmon_temp.frmt_0x0011_0x03=buf +hwmon_temp.fpath_0x0011_0x03=/sys/bus/i2c/devices/89-0049/hwmon/ +hwmon_temp.addr_0x0011_0x03=0 +hwmon_temp.len_0x0011_0x03=8 +hwmon_temp.bit_offset_0x0011_0x03= +hwmon_temp.str_cons_0x0011_0x03=temp1_max + +hwmon_temp.mode_0x0011_0x04=config +hwmon_temp.int_cons_0x0011_0x04=0 +hwmon_temp.src_0x0011_0x04=file +hwmon_temp.frmt_0x0011_0x04=buf +hwmon_temp.fpath_0x0011_0x04=/sys/bus/i2c/devices/89-0049/hwmon/ +hwmon_temp.addr_0x0011_0x04=0 +hwmon_temp.len_0x0011_0x04=8 +hwmon_temp.bit_offset_0x0011_0x04= +hwmon_temp.str_cons_0x0011_0x04=temp1_max_hyst + +hwmon_temp.mode_0x0012_0x00=config +hwmon_temp.int_cons_0x0012_0x00=0 +hwmon_temp.src_0x0012_0x00=file +hwmon_temp.frmt_0x0012_0x00=buf +hwmon_temp.fpath_0x0012_0x00=/sys/bus/i2c/devices/96-0048/hwmon/ +hwmon_temp.addr_0x0012_0x00=0 +hwmon_temp.len_0x0012_0x00=8 +hwmon_temp.bit_offset_0x0012_0x00= +hwmon_temp.str_cons_0x0012_0x00=temp1_input + +hwmon_temp.mode_0x0012_0x01=str_constant +hwmon_temp.str_cons_0x0012_0x01=FCB_air_outlet_DL + +hwmon_temp.mode_0x0012_0x02=str_constant +hwmon_temp.str_cons_0x0012_0x02=lm75 + +hwmon_temp.mode_0x0012_0x03=config +hwmon_temp.int_cons_0x0012_0x03=0 +hwmon_temp.src_0x0012_0x03=file +hwmon_temp.frmt_0x0012_0x03=buf +hwmon_temp.fpath_0x0012_0x03=/sys/bus/i2c/devices/96-0048/hwmon/ +hwmon_temp.addr_0x0012_0x03=0 +hwmon_temp.len_0x0012_0x03=8 +hwmon_temp.bit_offset_0x0012_0x03= +hwmon_temp.str_cons_0x0012_0x03=temp1_max + +hwmon_temp.mode_0x0012_0x04=config +hwmon_temp.int_cons_0x0012_0x04=0 +hwmon_temp.src_0x0012_0x04=file +hwmon_temp.frmt_0x0012_0x04=buf +hwmon_temp.fpath_0x0012_0x04=/sys/bus/i2c/devices/96-0048/hwmon/ +hwmon_temp.addr_0x0012_0x04=0 +hwmon_temp.len_0x0012_0x04=8 +hwmon_temp.bit_offset_0x0012_0x04= +hwmon_temp.str_cons_0x0012_0x04=temp1_max_hyst + +hwmon_temp.mode_0x0013_0x00=config +hwmon_temp.int_cons_0x0013_0x00=0 +hwmon_temp.src_0x0013_0x00=file +hwmon_temp.frmt_0x0013_0x00=buf +hwmon_temp.fpath_0x0013_0x00=/sys/bus/i2c/devices/97-0049/hwmon/ +hwmon_temp.addr_0x0013_0x00=0 +hwmon_temp.len_0x0013_0x00=8 +hwmon_temp.bit_offset_0x0013_0x00= +hwmon_temp.str_cons_0x0013_0x00=temp1_input + +hwmon_temp.mode_0x0013_0x01=str_constant +hwmon_temp.str_cons_0x0013_0x01=FCB_air_outlet_DR + +hwmon_temp.mode_0x0013_0x02=str_constant +hwmon_temp.str_cons_0x0013_0x02=lm75 + +hwmon_temp.mode_0x0013_0x03=config +hwmon_temp.int_cons_0x0013_0x03=0 +hwmon_temp.src_0x0013_0x03=file +hwmon_temp.frmt_0x0013_0x03=buf +hwmon_temp.fpath_0x0013_0x03=/sys/bus/i2c/devices/97-0049/hwmon/ +hwmon_temp.addr_0x0013_0x03=0 +hwmon_temp.len_0x0013_0x03=8 +hwmon_temp.bit_offset_0x0013_0x03= +hwmon_temp.str_cons_0x0013_0x03=temp1_max + +hwmon_temp.mode_0x0013_0x04=config +hwmon_temp.int_cons_0x0013_0x04=0 +hwmon_temp.src_0x0013_0x04=file +hwmon_temp.frmt_0x0013_0x04=buf +hwmon_temp.fpath_0x0013_0x04=/sys/bus/i2c/devices/97-0049/hwmon/ +hwmon_temp.addr_0x0013_0x04=0 +hwmon_temp.len_0x0013_0x04=8 +hwmon_temp.bit_offset_0x0013_0x04= +hwmon_temp.str_cons_0x0013_0x04=temp1_max_hyst + + +# sensor temp20 input +hwmon_temp.mode_0x0014_0x00=config +hwmon_temp.int_cons_0x0014_0x00=0 +hwmon_temp.src_0x0014_0x00=file +hwmon_temp.frmt_0x0014_0x00=buf +hwmon_temp.fpath_0x0014_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x0014_0x00=0 +hwmon_temp.len_0x0014_0x00=16 +hwmon_temp.bit_offset_0x0014_0x00= +hwmon_temp.str_cons_0x0014_0x00=temp1_input + +# sensor temp20 alias +hwmon_temp.mode_0x0014_0x01=str_constant +hwmon_temp.str_cons_0x0014_0x01=MAC_DIE_0 + +# sensor temp20 type +hwmon_temp.mode_0x0014_0x02=str_constant +hwmon_temp.str_cons_0x0014_0x02=mac_bsc + + +# sensor temp21 input +hwmon_temp.mode_0x0015_0x00=config +hwmon_temp.int_cons_0x0015_0x00=0 +hwmon_temp.src_0x0015_0x00=file +hwmon_temp.frmt_0x0015_0x00=buf +hwmon_temp.fpath_0x0015_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x0015_0x00=0 +hwmon_temp.len_0x0015_0x00=16 +hwmon_temp.bit_offset_0x0015_0x00= +hwmon_temp.str_cons_0x0015_0x00=temp2_input + +# sensor temp21 alias +hwmon_temp.mode_0x0015_0x01=str_constant +hwmon_temp.str_cons_0x0015_0x01=MAC_DIE_1 + +# sensor temp21 type +hwmon_temp.mode_0x0015_0x02=str_constant +hwmon_temp.str_cons_0x0015_0x02=mac_bsc + + +# sensor temp22 input +hwmon_temp.mode_0x0016_0x00=config +hwmon_temp.int_cons_0x0016_0x00=0 +hwmon_temp.src_0x0016_0x00=file +hwmon_temp.frmt_0x0016_0x00=buf +hwmon_temp.fpath_0x0016_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x0016_0x00=0 +hwmon_temp.len_0x0016_0x00=16 +hwmon_temp.bit_offset_0x0016_0x00= +hwmon_temp.str_cons_0x0016_0x00=temp3_input + +# sensor temp22 alias +hwmon_temp.mode_0x0016_0x01=str_constant +hwmon_temp.str_cons_0x0016_0x01=MAC_DIE_2 + +# sensor temp22 type +hwmon_temp.mode_0x0016_0x02=str_constant +hwmon_temp.str_cons_0x0016_0x02=mac_bsc + + +# sensor temp23 input +hwmon_temp.mode_0x0017_0x00=config +hwmon_temp.int_cons_0x0017_0x00=0 +hwmon_temp.src_0x0017_0x00=file +hwmon_temp.frmt_0x0017_0x00=buf +hwmon_temp.fpath_0x0017_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x0017_0x00=0 +hwmon_temp.len_0x0017_0x00=16 +hwmon_temp.bit_offset_0x0017_0x00= +hwmon_temp.str_cons_0x0017_0x00=temp4_input + +# sensor temp23 alias +hwmon_temp.mode_0x0017_0x01=str_constant +hwmon_temp.str_cons_0x0017_0x01=MAC_DIE_3 + +# sensor temp23 type +hwmon_temp.mode_0x0017_0x02=str_constant +hwmon_temp.str_cons_0x0017_0x02=mac_bsc + + +# sensor temp24 input +hwmon_temp.mode_0x0018_0x00=config +hwmon_temp.int_cons_0x0018_0x00=0 +hwmon_temp.src_0x0018_0x00=file +hwmon_temp.frmt_0x0018_0x00=buf +hwmon_temp.fpath_0x0018_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x0018_0x00=0 +hwmon_temp.len_0x0018_0x00=16 +hwmon_temp.bit_offset_0x0018_0x00= +hwmon_temp.str_cons_0x0018_0x00=temp5_input + +# sensor temp24 alias +hwmon_temp.mode_0x0018_0x01=str_constant +hwmon_temp.str_cons_0x0018_0x01=MAC_DIE_4 + +# sensor temp24 type +hwmon_temp.mode_0x0018_0x02=str_constant +hwmon_temp.str_cons_0x0018_0x02=mac_bsc + + +# sensor temp25 input +hwmon_temp.mode_0x0019_0x00=config +hwmon_temp.int_cons_0x0019_0x00=0 +hwmon_temp.src_0x0019_0x00=file +hwmon_temp.frmt_0x0019_0x00=buf +hwmon_temp.fpath_0x0019_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x0019_0x00=0 +hwmon_temp.len_0x0019_0x00=16 +hwmon_temp.bit_offset_0x0019_0x00= +hwmon_temp.str_cons_0x0019_0x00=temp6_input + +# sensor temp25 alias +hwmon_temp.mode_0x0019_0x01=str_constant +hwmon_temp.str_cons_0x0019_0x01=MAC_DIE_5 + +# sensor temp25 type +hwmon_temp.mode_0x0019_0x02=str_constant +hwmon_temp.str_cons_0x0019_0x02=mac_bsc + + +# sensor temp26 input +hwmon_temp.mode_0x001a_0x00=config +hwmon_temp.int_cons_0x001a_0x00=0 +hwmon_temp.src_0x001a_0x00=file +hwmon_temp.frmt_0x001a_0x00=buf +hwmon_temp.fpath_0x001a_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x001a_0x00=0 +hwmon_temp.len_0x001a_0x00=16 +hwmon_temp.bit_offset_0x001a_0x00= +hwmon_temp.str_cons_0x001a_0x00=temp7_input + +# sensor temp26 alias +hwmon_temp.mode_0x001a_0x01=str_constant +hwmon_temp.str_cons_0x001a_0x01=MAC_DIE_6 + +# sensor temp26 type +hwmon_temp.mode_0x001a_0x02=str_constant +hwmon_temp.str_cons_0x001a_0x02=mac_bsc + + +# sensor temp27 input +hwmon_temp.mode_0x001b_0x00=config +hwmon_temp.int_cons_0x001b_0x00=0 +hwmon_temp.src_0x001b_0x00=file +hwmon_temp.frmt_0x001b_0x00=buf +hwmon_temp.fpath_0x001b_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x001b_0x00=0 +hwmon_temp.len_0x001b_0x00=16 +hwmon_temp.bit_offset_0x001b_0x00= +hwmon_temp.str_cons_0x001b_0x00=temp8_input + +# sensor temp27 alias +hwmon_temp.mode_0x001b_0x01=str_constant +hwmon_temp.str_cons_0x001b_0x01=MAC_DIE_7 + +# sensor temp27 type +hwmon_temp.mode_0x001b_0x02=str_constant +hwmon_temp.str_cons_0x001b_0x02=mac_bsc + + +# sensor temp28 input +hwmon_temp.mode_0x001c_0x00=config +hwmon_temp.int_cons_0x001c_0x00=0 +hwmon_temp.src_0x001c_0x00=file +hwmon_temp.frmt_0x001c_0x00=buf +hwmon_temp.fpath_0x001c_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x001c_0x00=0 +hwmon_temp.len_0x001c_0x00=16 +hwmon_temp.bit_offset_0x001c_0x00= +hwmon_temp.str_cons_0x001c_0x00=temp9_input + +# sensor temp28 alias +hwmon_temp.mode_0x001c_0x01=str_constant +hwmon_temp.str_cons_0x001c_0x01=MAC_DIE_8 + +# sensor temp28 type +hwmon_temp.mode_0x001c_0x02=str_constant +hwmon_temp.str_cons_0x001c_0x02=mac_bsc + + +# sensor temp29 input +hwmon_temp.mode_0x001d_0x00=config +hwmon_temp.int_cons_0x001d_0x00=0 +hwmon_temp.src_0x001d_0x00=file +hwmon_temp.frmt_0x001d_0x00=buf +hwmon_temp.fpath_0x001d_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x001d_0x00=0 +hwmon_temp.len_0x001d_0x00=16 +hwmon_temp.bit_offset_0x001d_0x00= +hwmon_temp.str_cons_0x001d_0x00=temp10_input + +# sensor temp29 alias +hwmon_temp.mode_0x001d_0x01=str_constant +hwmon_temp.str_cons_0x001d_0x01=MAC_DIE_9 + +# sensor temp29 type +hwmon_temp.mode_0x001d_0x02=str_constant +hwmon_temp.str_cons_0x001d_0x02=mac_bsc + + +# sensor temp30 input +hwmon_temp.mode_0x001e_0x00=config +hwmon_temp.int_cons_0x001e_0x00=0 +hwmon_temp.src_0x001e_0x00=file +hwmon_temp.frmt_0x001e_0x00=buf +hwmon_temp.fpath_0x001e_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x001e_0x00=0 +hwmon_temp.len_0x001e_0x00=16 +hwmon_temp.bit_offset_0x001e_0x00= +hwmon_temp.str_cons_0x001e_0x00=temp11_input + +# sensor temp30 alias +hwmon_temp.mode_0x001e_0x01=str_constant +hwmon_temp.str_cons_0x001e_0x01=MAC_DIE_10 + +# sensor temp30 type +hwmon_temp.mode_0x001e_0x02=str_constant +hwmon_temp.str_cons_0x001e_0x02=mac_bsc + + +# sensor temp31 input +hwmon_temp.mode_0x001f_0x00=config +hwmon_temp.int_cons_0x001f_0x00=0 +hwmon_temp.src_0x001f_0x00=file +hwmon_temp.frmt_0x001f_0x00=buf +hwmon_temp.fpath_0x001f_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x001f_0x00=0 +hwmon_temp.len_0x001f_0x00=16 +hwmon_temp.bit_offset_0x001f_0x00= +hwmon_temp.str_cons_0x001f_0x00=temp12_input + +# sensor temp31 alias +hwmon_temp.mode_0x001f_0x01=str_constant +hwmon_temp.str_cons_0x001f_0x01=MAC_DIE_11 + +# sensor temp31 type +hwmon_temp.mode_0x001f_0x02=str_constant +hwmon_temp.str_cons_0x001f_0x02=mac_bsc + + +# sensor temp32 input +hwmon_temp.mode_0x0020_0x00=config +hwmon_temp.int_cons_0x0020_0x00=0 +hwmon_temp.src_0x0020_0x00=file +hwmon_temp.frmt_0x0020_0x00=buf +hwmon_temp.fpath_0x0020_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x0020_0x00=0 +hwmon_temp.len_0x0020_0x00=16 +hwmon_temp.bit_offset_0x0020_0x00= +hwmon_temp.str_cons_0x0020_0x00=temp13_input + +# sensor temp32 alias +hwmon_temp.mode_0x0020_0x01=str_constant +hwmon_temp.str_cons_0x0020_0x01=MAC_DIE_12 + +# sensor temp32 type +hwmon_temp.mode_0x0020_0x02=str_constant +hwmon_temp.str_cons_0x0020_0x02=mac_bsc + + +# sensor temp33 input +hwmon_temp.mode_0x0021_0x00=config +hwmon_temp.int_cons_0x0021_0x00=0 +hwmon_temp.src_0x0021_0x00=file +hwmon_temp.frmt_0x0021_0x00=buf +hwmon_temp.fpath_0x0021_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x0021_0x00=0 +hwmon_temp.len_0x0021_0x00=16 +hwmon_temp.bit_offset_0x0021_0x00= +hwmon_temp.str_cons_0x0021_0x00=temp14_input + +# sensor temp33 alias +hwmon_temp.mode_0x0021_0x01=str_constant +hwmon_temp.str_cons_0x0021_0x01=MAC_DIE_13 + +# sensor temp33 type +hwmon_temp.mode_0x0021_0x02=str_constant +hwmon_temp.str_cons_0x0021_0x02=mac_bsc + + +# sensor temp34 input +hwmon_temp.mode_0x0022_0x00=config +hwmon_temp.int_cons_0x0022_0x00=0 +hwmon_temp.src_0x0022_0x00=file +hwmon_temp.frmt_0x0022_0x00=buf +hwmon_temp.fpath_0x0022_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x0022_0x00=0 +hwmon_temp.len_0x0022_0x00=16 +hwmon_temp.bit_offset_0x0022_0x00= +hwmon_temp.str_cons_0x0022_0x00=temp15_input + +# sensor temp34 alias +hwmon_temp.mode_0x0022_0x01=str_constant +hwmon_temp.str_cons_0x0022_0x01=MAC_DIE_14 + +# sensor temp34 type +hwmon_temp.mode_0x0022_0x02=str_constant +hwmon_temp.str_cons_0x0022_0x02=mac_bsc + + +# sensor vol +hwmon_in.mode_0x0001_0x00=config +hwmon_in.int_cons_0x0001_0x00=0 +hwmon_in.src_0x0001_0x00=file +hwmon_in.frmt_0x0001_0x00=buf +hwmon_in.fpath_0x0001_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0001_0x00=0 +hwmon_in.len_0x0001_0x00=8 +hwmon_in.bit_offset_0x0001_0x00= +hwmon_in.str_cons_0x0001_0x00=in1_input + +hwmon_in.mode_0x0001_0x01=str_constant +hwmon_in.str_cons_0x0001_0x01=MAC_VDD_ANALOG1 + +hwmon_in.mode_0x0001_0x02=str_constant +hwmon_in.str_cons_0x0001_0x02=ucd90160 + +hwmon_in.mode_0x0001_0x03=constant +hwmon_in.int_cons_0x0001_0x03=809 + +hwmon_in.mode_0x0001_0x05=constant +hwmon_in.int_cons_0x0001_0x05=731 + +hwmon_in.mode_0x0002_0x00=config +hwmon_in.int_cons_0x0002_0x00=0 +hwmon_in.src_0x0002_0x00=file +hwmon_in.frmt_0x0002_0x00=buf +hwmon_in.fpath_0x0002_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0002_0x00=0 +hwmon_in.len_0x0002_0x00=8 +hwmon_in.bit_offset_0x0002_0x00= +hwmon_in.str_cons_0x0002_0x00=in2_input + +hwmon_in.mode_0x0002_0x01=str_constant +hwmon_in.str_cons_0x0002_0x01=MAC_VDD12V + +hwmon_in.mode_0x0002_0x02=str_constant +hwmon_in.str_cons_0x0002_0x02=ucd90160 + +hwmon_in.mode_0x0002_0x03=constant +hwmon_in.int_cons_0x0002_0x03=12600 + +hwmon_in.mode_0x0002_0x05=constant +hwmon_in.int_cons_0x0002_0x05=11400 + +hwmon_in.mode_0x0003_0x00=config +hwmon_in.int_cons_0x0003_0x00=0 +hwmon_in.src_0x0003_0x00=file +hwmon_in.frmt_0x0003_0x00=buf +hwmon_in.fpath_0x0003_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0003_0x00=0 +hwmon_in.len_0x0003_0x00=8 +hwmon_in.bit_offset_0x0003_0x00= +hwmon_in.str_cons_0x0003_0x00=in3_input + +hwmon_in.mode_0x0003_0x01=str_constant +hwmon_in.str_cons_0x0003_0x01=MAC_VDD1.0V_FPGA + +hwmon_in.mode_0x0003_0x02=str_constant +hwmon_in.str_cons_0x0003_0x02=ucd90160 + +hwmon_in.mode_0x0003_0x03=constant +hwmon_in.int_cons_0x0003_0x03=1071 + +hwmon_in.mode_0x0003_0x05=constant +hwmon_in.int_cons_0x0003_0x05=969 + +hwmon_in.mode_0x0004_0x00=config +hwmon_in.int_cons_0x0004_0x00=0 +hwmon_in.src_0x0004_0x00=file +hwmon_in.frmt_0x0004_0x00=buf +hwmon_in.fpath_0x0004_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0004_0x00=0 +hwmon_in.len_0x0004_0x00=8 +hwmon_in.bit_offset_0x0004_0x00= +hwmon_in.str_cons_0x0004_0x00=in4_input + +hwmon_in.mode_0x0004_0x01=str_constant +hwmon_in.str_cons_0x0004_0x01=MAC_VDD1.8V_FPGA + +hwmon_in.mode_0x0004_0x02=str_constant +hwmon_in.str_cons_0x0004_0x02=ucd90160 + +hwmon_in.mode_0x0004_0x03=constant +hwmon_in.int_cons_0x0004_0x03=1890 + +hwmon_in.mode_0x0004_0x05=constant +hwmon_in.int_cons_0x0004_0x05=1710 + +hwmon_in.mode_0x0005_0x00=config +hwmon_in.int_cons_0x0005_0x00=0 +hwmon_in.src_0x0005_0x00=file +hwmon_in.frmt_0x0005_0x00=buf +hwmon_in.fpath_0x0005_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0005_0x00=0 +hwmon_in.len_0x0005_0x00=8 +hwmon_in.bit_offset_0x0005_0x00= +hwmon_in.str_cons_0x0005_0x00=in5_input + +hwmon_in.mode_0x0005_0x01=str_constant +hwmon_in.str_cons_0x0005_0x01=MAC_VDD1.2V_FPGA + +hwmon_in.mode_0x0005_0x02=str_constant +hwmon_in.str_cons_0x0005_0x02=ucd90160 + +hwmon_in.mode_0x0005_0x03=constant +hwmon_in.int_cons_0x0005_0x03=1260 + +hwmon_in.mode_0x0005_0x05=constant +hwmon_in.int_cons_0x0005_0x05=1140 + +hwmon_in.mode_0x0006_0x00=config +hwmon_in.int_cons_0x0006_0x00=0 +hwmon_in.src_0x0006_0x00=file +hwmon_in.frmt_0x0006_0x00=buf +hwmon_in.fpath_0x0006_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0006_0x00=0 +hwmon_in.len_0x0006_0x00=8 +hwmon_in.bit_offset_0x0006_0x00= +hwmon_in.str_cons_0x0006_0x00=in6_input + +hwmon_in.mode_0x0006_0x01=str_constant +hwmon_in.str_cons_0x0006_0x01=MAC_VDD3.3V + +hwmon_in.mode_0x0006_0x02=str_constant +hwmon_in.str_cons_0x0006_0x02=ucd90160 + +hwmon_in.mode_0x0006_0x03=constant +hwmon_in.int_cons_0x0006_0x03=3465 + +hwmon_in.mode_0x0006_0x05=constant +hwmon_in.int_cons_0x0006_0x05=3135 + +hwmon_in.mode_0x0007_0x00=config +hwmon_in.int_cons_0x0007_0x00=0 +hwmon_in.src_0x0007_0x00=file +hwmon_in.frmt_0x0007_0x00=buf +hwmon_in.fpath_0x0007_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0007_0x00=0 +hwmon_in.len_0x0007_0x00=8 +hwmon_in.bit_offset_0x0007_0x00= +hwmon_in.str_cons_0x0007_0x00=in7_input + +hwmon_in.mode_0x0007_0x01=str_constant +hwmon_in.str_cons_0x0007_0x01=MAC_SW_VDD1.2V + +hwmon_in.mode_0x0007_0x02=str_constant +hwmon_in.str_cons_0x0007_0x02=ucd90160 + +hwmon_in.mode_0x0007_0x03=constant +hwmon_in.int_cons_0x0007_0x03=1260 + +hwmon_in.mode_0x0007_0x05=constant +hwmon_in.int_cons_0x0007_0x05=1140 + +hwmon_in.mode_0x0008_0x00=config +hwmon_in.int_cons_0x0008_0x00=0 +hwmon_in.src_0x0008_0x00=file +hwmon_in.frmt_0x0008_0x00=buf +hwmon_in.fpath_0x0008_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0008_0x00=0 +hwmon_in.len_0x0008_0x00=8 +hwmon_in.bit_offset_0x0008_0x00= +hwmon_in.str_cons_0x0008_0x00=in8_input + +hwmon_in.mode_0x0008_0x01=str_constant +hwmon_in.str_cons_0x0008_0x01=MAC_VDD5V_CLK_MCU + +hwmon_in.mode_0x0008_0x02=str_constant +hwmon_in.str_cons_0x0008_0x02=ucd90160 + +hwmon_in.mode_0x0008_0x03=constant +hwmon_in.int_cons_0x0008_0x03=5334 + +hwmon_in.mode_0x0008_0x05=constant +hwmon_in.int_cons_0x0008_0x05=4826 + +hwmon_in.mode_0x0009_0x00=config +hwmon_in.int_cons_0x0009_0x00=0 +hwmon_in.src_0x0009_0x00=file +hwmon_in.frmt_0x0009_0x00=buf +hwmon_in.fpath_0x0009_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0009_0x00=0 +hwmon_in.len_0x0009_0x00=8 +hwmon_in.bit_offset_0x0009_0x00= +hwmon_in.str_cons_0x0009_0x00=in9_input + +hwmon_in.mode_0x0009_0x01=str_constant +hwmon_in.str_cons_0x0009_0x01=MAC_VDD5V_VR + +hwmon_in.mode_0x0009_0x02=str_constant +hwmon_in.str_cons_0x0009_0x02=ucd90160 + +hwmon_in.mode_0x0009_0x03=constant +hwmon_in.int_cons_0x0009_0x03=5334 + +hwmon_in.mode_0x0009_0x05=constant +hwmon_in.int_cons_0x0009_0x05=4826 + +hwmon_in.mode_0x000a_0x00=config +hwmon_in.int_cons_0x000a_0x00=0 +hwmon_in.src_0x000a_0x00=file +hwmon_in.frmt_0x000a_0x00=buf +hwmon_in.fpath_0x000a_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x000a_0x00=0 +hwmon_in.len_0x000a_0x00=8 +hwmon_in.bit_offset_0x000a_0x00= +hwmon_in.str_cons_0x000a_0x00=in10_input + +hwmon_in.mode_0x000a_0x01=str_constant +hwmon_in.str_cons_0x000a_0x01=MAC_VDD3.3_CLK + +hwmon_in.mode_0x000a_0x02=str_constant +hwmon_in.str_cons_0x000a_0x02=ucd90160 + +hwmon_in.mode_0x000a_0x03=constant +hwmon_in.int_cons_0x000a_0x03=3486 + +hwmon_in.mode_0x000a_0x05=constant +hwmon_in.int_cons_0x000a_0x05=3154 + +hwmon_in.mode_0x000b_0x00=config +hwmon_in.int_cons_0x000b_0x00=0 +hwmon_in.src_0x000b_0x00=file +hwmon_in.frmt_0x000b_0x00=buf +hwmon_in.fpath_0x000b_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x000b_0x00=0 +hwmon_in.len_0x000b_0x00=8 +hwmon_in.bit_offset_0x000b_0x00= +hwmon_in.str_cons_0x000b_0x00=in11_input + +hwmon_in.mode_0x000b_0x01=str_constant +hwmon_in.str_cons_0x000b_0x01=MAC_VDDO1.8V + +hwmon_in.mode_0x000b_0x02=str_constant +hwmon_in.str_cons_0x000b_0x02=ucd90160 + +hwmon_in.mode_0x000b_0x03=constant +hwmon_in.int_cons_0x000b_0x03=1901 + +hwmon_in.mode_0x000b_0x05=constant +hwmon_in.int_cons_0x000b_0x05=1719 + +hwmon_in.mode_0x000c_0x00=config +hwmon_in.int_cons_0x000c_0x00=0 +hwmon_in.src_0x000c_0x00=file +hwmon_in.frmt_0x000c_0x00=buf +hwmon_in.fpath_0x000c_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x000c_0x00=0 +hwmon_in.len_0x000c_0x00=8 +hwmon_in.bit_offset_0x000c_0x00= +hwmon_in.str_cons_0x000c_0x00=in12_input + +hwmon_in.mode_0x000c_0x01=str_constant +hwmon_in.str_cons_0x000c_0x01=MAC_VDDO1.2V + +hwmon_in.mode_0x000c_0x02=str_constant +hwmon_in.str_cons_0x000c_0x02=ucd90160 + +hwmon_in.mode_0x000c_0x03=constant +hwmon_in.int_cons_0x000c_0x03=1260 + +hwmon_in.mode_0x000c_0x05=constant +hwmon_in.int_cons_0x000c_0x05=1140 + +hwmon_in.mode_0x000d_0x00=config +hwmon_in.int_cons_0x000d_0x00=0 +hwmon_in.src_0x000d_0x00=file +hwmon_in.frmt_0x000d_0x00=buf +hwmon_in.fpath_0x000d_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x000d_0x00=0 +hwmon_in.len_0x000d_0x00=8 +hwmon_in.bit_offset_0x000d_0x00= +hwmon_in.str_cons_0x000d_0x00=in13_input + +hwmon_in.mode_0x000d_0x01=str_constant +hwmon_in.str_cons_0x000d_0x01=MAC_VDD_CORE + +hwmon_in.mode_0x000d_0x02=str_constant +hwmon_in.str_cons_0x000d_0x02=ucd90160 + +hwmon_in.mode_0x000d_0x03=constant +hwmon_in.int_cons_0x000d_0x03=950 + +hwmon_in.mode_0x000d_0x05=constant +hwmon_in.int_cons_0x000d_0x05=700 + +hwmon_in.mode_0x000e_0x00=config +hwmon_in.int_cons_0x000e_0x00=0 +hwmon_in.src_0x000e_0x00=file +hwmon_in.frmt_0x000e_0x00=buf +hwmon_in.fpath_0x000e_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x000e_0x00=0 +hwmon_in.len_0x000e_0x00=8 +hwmon_in.bit_offset_0x000e_0x00= +hwmon_in.str_cons_0x000e_0x00=in14_input + +hwmon_in.mode_0x000e_0x01=str_constant +hwmon_in.str_cons_0x000e_0x01=MAC_VDD_ANALOG + +hwmon_in.mode_0x000e_0x02=str_constant +hwmon_in.str_cons_0x000e_0x02=ucd90160 + +hwmon_in.mode_0x000e_0x03=constant +hwmon_in.int_cons_0x000e_0x03=809 + +hwmon_in.mode_0x000e_0x05=constant +hwmon_in.int_cons_0x000e_0x05=731 + +hwmon_in.mode_0x000f_0x00=config +hwmon_in.int_cons_0x000f_0x00=0 +hwmon_in.src_0x000f_0x00=file +hwmon_in.frmt_0x000f_0x00=buf +hwmon_in.fpath_0x000f_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x000f_0x00=0 +hwmon_in.len_0x000f_0x00=8 +hwmon_in.bit_offset_0x000f_0x00= +hwmon_in.str_cons_0x000f_0x00=in15_input + +hwmon_in.mode_0x000f_0x01=str_constant +hwmon_in.str_cons_0x000f_0x01=MAC_VDD1.2V_MAC + +hwmon_in.mode_0x000f_0x02=str_constant +hwmon_in.str_cons_0x000f_0x02=ucd90160 + +hwmon_in.mode_0x000f_0x03=constant +hwmon_in.int_cons_0x000f_0x03=1260 + +hwmon_in.mode_0x000f_0x05=constant +hwmon_in.int_cons_0x000f_0x05=1140 + +hwmon_in.mode_0x0010_0x00=config +hwmon_in.int_cons_0x0010_0x00=0 +hwmon_in.src_0x0010_0x00=file +hwmon_in.frmt_0x0010_0x00=buf +hwmon_in.fpath_0x0010_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0010_0x00=0 +hwmon_in.len_0x0010_0x00=8 +hwmon_in.bit_offset_0x0010_0x00= +hwmon_in.str_cons_0x0010_0x00=in16_input + +hwmon_in.mode_0x0010_0x01=str_constant +hwmon_in.str_cons_0x0010_0x01=MAC_AVDD1.8V + +hwmon_in.mode_0x0010_0x02=str_constant +hwmon_in.str_cons_0x0010_0x02=ucd90160 + +hwmon_in.mode_0x0010_0x03=constant +hwmon_in.int_cons_0x0010_0x03=1890 + +hwmon_in.mode_0x0010_0x05=constant +hwmon_in.int_cons_0x0010_0x05=1710 + +hwmon_in.mode_0x0011_0x00=config +hwmon_in.int_cons_0x0011_0x00=0 +hwmon_in.src_0x0011_0x00=file +hwmon_in.frmt_0x0011_0x00=buf +hwmon_in.fpath_0x0011_0x00=/sys/bus/i2c/devices/105-005b/hwmon/ +hwmon_in.addr_0x0011_0x00=0 +hwmon_in.len_0x0011_0x00=8 +hwmon_in.bit_offset_0x0011_0x00= +hwmon_in.str_cons_0x0011_0x00=in1_input + +hwmon_in.mode_0x0011_0x01=str_constant +hwmon_in.str_cons_0x0011_0x01=BASE_VDD12V + +hwmon_in.mode_0x0011_0x02=str_constant +hwmon_in.str_cons_0x0011_0x02=ucd90160 + +hwmon_in.mode_0x0011_0x03=constant +hwmon_in.int_cons_0x0011_0x03=12600 + +hwmon_in.mode_0x0011_0x05=constant +hwmon_in.int_cons_0x0011_0x05=11400 + +hwmon_in.mode_0x0012_0x00=config +hwmon_in.int_cons_0x0012_0x00=0 +hwmon_in.src_0x0012_0x00=file +hwmon_in.frmt_0x0012_0x00=buf +hwmon_in.fpath_0x0012_0x00=/sys/bus/i2c/devices/105-005b/hwmon/ +hwmon_in.addr_0x0012_0x00=0 +hwmon_in.len_0x0012_0x00=8 +hwmon_in.bit_offset_0x0012_0x00= +hwmon_in.str_cons_0x0012_0x00=in2_input + +hwmon_in.mode_0x0012_0x01=str_constant +hwmon_in.str_cons_0x0012_0x01=BASE_SW_VDD1.0V + +hwmon_in.mode_0x0012_0x02=str_constant +hwmon_in.str_cons_0x0012_0x02=ucd90160 + +hwmon_in.mode_0x0012_0x03=constant +hwmon_in.int_cons_0x0012_0x03=1050 + +hwmon_in.mode_0x0012_0x05=constant +hwmon_in.int_cons_0x0012_0x05=950 + + +hwmon_in.mode_0x0013_0x00=config +hwmon_in.int_cons_0x0013_0x00=0 +hwmon_in.src_0x0013_0x00=file +hwmon_in.frmt_0x0013_0x00=buf +hwmon_in.fpath_0x0013_0x00=/sys/bus/i2c/devices/105-005b/hwmon/ +hwmon_in.addr_0x0013_0x00=0 +hwmon_in.len_0x0013_0x00=8 +hwmon_in.bit_offset_0x0013_0x00= +hwmon_in.str_cons_0x0013_0x00=in4_input + +hwmon_in.mode_0x0013_0x01=str_constant +hwmon_in.str_cons_0x0013_0x01=BASE_VDD3.3V + +hwmon_in.mode_0x0013_0x02=str_constant +hwmon_in.str_cons_0x0013_0x02=ucd90160 + +hwmon_in.mode_0x0013_0x03=constant +hwmon_in.int_cons_0x0013_0x03=3444 + +hwmon_in.mode_0x0013_0x05=constant +hwmon_in.int_cons_0x0013_0x05=3116 + + +hwmon_in.mode_0x0014_0x00=config +hwmon_in.int_cons_0x0014_0x00=0 +hwmon_in.src_0x0014_0x00=file +hwmon_in.frmt_0x0014_0x00=buf +hwmon_in.fpath_0x0014_0x00=/sys/bus/i2c/devices/105-005b/hwmon/ +hwmon_in.addr_0x0014_0x00=0 +hwmon_in.len_0x0014_0x00=8 +hwmon_in.bit_offset_0x0014_0x00= +hwmon_in.str_cons_0x0014_0x00=in5_input + +hwmon_in.mode_0x0014_0x01=str_constant +hwmon_in.str_cons_0x0014_0x01=BASE_SW_OVDD + +hwmon_in.mode_0x0014_0x02=str_constant +hwmon_in.str_cons_0x0014_0x02=ucd90160 + +hwmon_in.mode_0x0014_0x03=constant +hwmon_in.int_cons_0x0014_0x03=3444 + +hwmon_in.mode_0x0014_0x05=constant +hwmon_in.int_cons_0x0014_0x05=3116 + + +hwmon_in.mode_0x0015_0x00=config +hwmon_in.int_cons_0x0015_0x00=0 +hwmon_in.src_0x0015_0x00=file +hwmon_in.frmt_0x0015_0x00=buf +hwmon_in.fpath_0x0015_0x00=/sys/bus/i2c/devices/105-005b/hwmon/ +hwmon_in.addr_0x0015_0x00=0 +hwmon_in.len_0x0015_0x00=8 +hwmon_in.bit_offset_0x0015_0x00= +hwmon_in.str_cons_0x0015_0x00=in6_input + +hwmon_in.mode_0x0015_0x01=str_constant +hwmon_in.str_cons_0x0015_0x01=BASE_SSD_VDD3.3V + +hwmon_in.mode_0x0015_0x02=str_constant +hwmon_in.str_cons_0x0015_0x02=ucd90160 + +hwmon_in.mode_0x0015_0x03=constant +hwmon_in.int_cons_0x0015_0x03=3465 + +hwmon_in.mode_0x0015_0x05=constant +hwmon_in.int_cons_0x0015_0x05=3135 + +hwmon_in.mode_0x0016_0x00=config +hwmon_in.int_cons_0x0016_0x00=0 +hwmon_in.src_0x0016_0x00=file +hwmon_in.frmt_0x0016_0x00=buf +hwmon_in.fpath_0x0016_0x00=/sys/bus/i2c/devices/106-0060/hwmon/ +hwmon_in.addr_0x0016_0x00=0 +hwmon_in.len_0x0016_0x00=8 +hwmon_in.bit_offset_0x0016_0x00= +hwmon_in.str_cons_0x0016_0x00=in3_input + +hwmon_in.mode_0x0016_0x01=str_constant +hwmon_in.str_cons_0x0016_0x01=CPU_VCCIN + +hwmon_in.mode_0x0016_0x02=str_constant +hwmon_in.str_cons_0x0016_0x02=tps53622 + +hwmon_in.mode_0x0016_0x03=constant +hwmon_in.int_cons_0x0016_0x03=1950 + +hwmon_in.mode_0x0016_0x05=constant +hwmon_in.int_cons_0x0016_0x05=1600 + +hwmon_in.mode_0x0017_0x00=config +hwmon_in.int_cons_0x0017_0x00=0 +hwmon_in.src_0x0017_0x00=file +hwmon_in.frmt_0x0017_0x00=buf +hwmon_in.fpath_0x0017_0x00=/sys/bus/i2c/devices/106-0060/hwmon/ +hwmon_in.addr_0x0017_0x00=0 +hwmon_in.len_0x0017_0x00=8 +hwmon_in.bit_offset_0x0017_0x00= +hwmon_in.str_cons_0x0017_0x00=in4_input + +hwmon_in.mode_0x0017_0x01=str_constant +hwmon_in.str_cons_0x0017_0x01=CPU_P1V05 + +hwmon_in.mode_0x0017_0x02=str_constant +hwmon_in.str_cons_0x0017_0x02=tps53622 + +hwmon_in.mode_0x0017_0x03=constant +hwmon_in.int_cons_0x0017_0x03=1100 + +hwmon_in.mode_0x0017_0x05=constant +hwmon_in.int_cons_0x0017_0x05=1000 + +hwmon_in.mode_0x0018_0x00=config +hwmon_in.int_cons_0x0018_0x00=0 +hwmon_in.src_0x0018_0x00=file +hwmon_in.frmt_0x0018_0x00=buf +hwmon_in.fpath_0x0018_0x00=/sys/bus/i2c/devices/106-006c/hwmon/ +hwmon_in.addr_0x0018_0x00=0 +hwmon_in.len_0x0018_0x00=8 +hwmon_in.bit_offset_0x0018_0x00= +hwmon_in.str_cons_0x0018_0x00=in3_input + +hwmon_in.mode_0x0018_0x01=str_constant +hwmon_in.str_cons_0x0018_0x01=CPU_P1V2_VDDQ + +hwmon_in.mode_0x0018_0x02=str_constant +hwmon_in.str_cons_0x0018_0x02=tps53622 + +hwmon_in.mode_0x0018_0x03=constant +hwmon_in.int_cons_0x0018_0x03=1260 + +hwmon_in.mode_0x0018_0x05=constant +hwmon_in.int_cons_0x0018_0x05=1160 + +hwmon_in.mode_0x0019_0x00=config +hwmon_in.int_cons_0x0019_0x00=3 +hwmon_in.src_0x0019_0x00=file +hwmon_in.frmt_0x0019_0x00=buf +hwmon_in.fpath_0x0019_0x00=/sys/bus/i2c/devices/106-006c/hwmon/ +hwmon_in.addr_0x0019_0x00=0 +hwmon_in.len_0x0019_0x00=8 +hwmon_in.bit_offset_0x0019_0x00=0 +hwmon_in.str_cons_0x0019_0x00=in4_input +hwmon_in.int_extra1_0x0019_0x00=1124 + +hwmon_in.mode_0x0019_0x01=str_constant +hwmon_in.str_cons_0x0019_0x01=CPU_P2V5_VPP + +hwmon_in.mode_0x0019_0x02=str_constant +hwmon_in.str_cons_0x0019_0x02=tps53622 + +hwmon_in.mode_0x0019_0x03=constant +hwmon_in.int_cons_0x0019_0x03=2750 + +hwmon_in.mode_0x0019_0x05=constant +hwmon_in.int_cons_0x0019_0x05=2375 + +hwmon_in.mode_0x001a_0x00=config +hwmon_in.int_cons_0x001a_0x00=0 +hwmon_in.src_0x001a_0x00=file +hwmon_in.frmt_0x001a_0x00=buf +hwmon_in.fpath_0x001a_0x00=/sys/bus/i2c/devices/106-0043/hwmon/ +hwmon_in.addr_0x001a_0x00=0 +hwmon_in.len_0x001a_0x00=8 +hwmon_in.bit_offset_0x001a_0x00= +hwmon_in.str_cons_0x001a_0x00=in1_input + +hwmon_in.mode_0x001a_0x01=str_constant +hwmon_in.str_cons_0x001a_0x01=CPU_P3V3_STBY + +hwmon_in.mode_0x001a_0x02=str_constant +hwmon_in.str_cons_0x001a_0x02=ina3221 + +hwmon_in.mode_0x001a_0x03=constant +hwmon_in.int_cons_0x001a_0x03=3465 + +hwmon_in.mode_0x001a_0x05=constant +hwmon_in.int_cons_0x001a_0x05=3135 + +hwmon_in.mode_0x001b_0x00=config +hwmon_in.int_cons_0x001b_0x00=0 +hwmon_in.src_0x001b_0x00=file +hwmon_in.frmt_0x001b_0x00=buf +hwmon_in.fpath_0x001b_0x00=/sys/bus/i2c/devices/106-0043/hwmon/ +hwmon_in.addr_0x001b_0x00=0 +hwmon_in.len_0x001b_0x00=8 +hwmon_in.bit_offset_0x001b_0x00= +hwmon_in.str_cons_0x001b_0x00=in2_input + +hwmon_in.mode_0x001b_0x01=str_constant +hwmon_in.str_cons_0x001b_0x01=CPU_P5V_AUX_IN + +hwmon_in.mode_0x001b_0x02=str_constant +hwmon_in.str_cons_0x001b_0x02=ina3221 + +hwmon_in.mode_0x001b_0x03=constant +hwmon_in.int_cons_0x001b_0x03=5500 + +hwmon_in.mode_0x001b_0x05=constant +hwmon_in.int_cons_0x001b_0x05=4250 + +hwmon_in.mode_0x001c_0x00=config +hwmon_in.int_cons_0x001c_0x00=0 +hwmon_in.src_0x001c_0x00=file +hwmon_in.frmt_0x001c_0x00=buf +hwmon_in.fpath_0x001c_0x00=/sys/bus/i2c/devices/106-0043/hwmon/ +hwmon_in.addr_0x001c_0x00=0 +hwmon_in.len_0x001c_0x00=8 +hwmon_in.bit_offset_0x001c_0x00= +hwmon_in.str_cons_0x001c_0x00=in3_input + +hwmon_in.mode_0x001c_0x01=str_constant +hwmon_in.str_cons_0x001c_0x01=CPU_P1V7_VCCSCFUSESUS_IN + +hwmon_in.mode_0x001c_0x02=str_constant +hwmon_in.str_cons_0x001c_0x02=ina3221 + +hwmon_in.mode_0x001c_0x03=constant +hwmon_in.int_cons_0x001c_0x03=1785 + +hwmon_in.mode_0x001c_0x05=constant +hwmon_in.int_cons_0x001c_0x05=1615 + +hwmon_in.mode_0x001d_0x00=config +hwmon_in.int_cons_0x001d_0x00=0 +hwmon_in.src_0x001d_0x00=file +hwmon_in.frmt_0x001d_0x00=buf +hwmon_in.fpath_0x001d_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x001d_0x00=0 +hwmon_in.len_0x001d_0x00=8 +hwmon_in.bit_offset_0x001d_0x00= +hwmon_in.str_cons_0x001d_0x00=in1_input + +hwmon_in.mode_0x001d_0x01=str_constant +hwmon_in.str_cons_0x001d_0x01=UPORT_VDD1.0V_FPGA + +hwmon_in.mode_0x001d_0x02=str_constant +hwmon_in.str_cons_0x001d_0x02=ucd90160 + +hwmon_in.mode_0x001d_0x03=constant +hwmon_in.int_cons_0x001d_0x03=1061 + +hwmon_in.mode_0x001d_0x05=constant +hwmon_in.int_cons_0x001d_0x05=959 + +hwmon_in.mode_0x001e_0x00=config +hwmon_in.int_cons_0x001e_0x00=0 +hwmon_in.src_0x001e_0x00=file +hwmon_in.frmt_0x001e_0x00=buf +hwmon_in.fpath_0x001e_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x001e_0x00=0 +hwmon_in.len_0x001e_0x00=8 +hwmon_in.bit_offset_0x001e_0x00= +hwmon_in.str_cons_0x001e_0x00=in2_input + +hwmon_in.mode_0x001e_0x01=str_constant +hwmon_in.str_cons_0x001e_0x01=UPORT_VDD1.8V_FPGA + +hwmon_in.mode_0x001e_0x02=str_constant +hwmon_in.str_cons_0x001e_0x02=ucd90160 + +hwmon_in.mode_0x001e_0x03=constant +hwmon_in.int_cons_0x001e_0x03=1901 + +hwmon_in.mode_0x001e_0x05=constant +hwmon_in.int_cons_0x001e_0x05=1719 + +hwmon_in.mode_0x001f_0x00=config +hwmon_in.int_cons_0x001f_0x00=0 +hwmon_in.src_0x001f_0x00=file +hwmon_in.frmt_0x001f_0x00=buf +hwmon_in.fpath_0x001f_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x001f_0x00=0 +hwmon_in.len_0x001f_0x00=8 +hwmon_in.bit_offset_0x001f_0x00= +hwmon_in.str_cons_0x001f_0x00=in3_input + +hwmon_in.mode_0x001f_0x01=str_constant +hwmon_in.str_cons_0x001f_0x01=UPORT_VDD1.2V_FPGA + +hwmon_in.mode_0x001f_0x02=str_constant +hwmon_in.str_cons_0x001f_0x02=ucd90160 + +hwmon_in.mode_0x001f_0x03=constant +hwmon_in.int_cons_0x001f_0x03=1260 + +hwmon_in.mode_0x001f_0x05=constant +hwmon_in.int_cons_0x001f_0x05=1140 + +hwmon_in.mode_0x0020_0x00=config +hwmon_in.int_cons_0x0020_0x00=0 +hwmon_in.src_0x0020_0x00=file +hwmon_in.frmt_0x0020_0x00=buf +hwmon_in.fpath_0x0020_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x0020_0x00=0 +hwmon_in.len_0x0020_0x00=8 +hwmon_in.bit_offset_0x0020_0x00= +hwmon_in.str_cons_0x0020_0x00=in4_input + +hwmon_in.mode_0x0020_0x01=str_constant +hwmon_in.str_cons_0x0020_0x01=UPORT_VDD3.3V + +hwmon_in.mode_0x0020_0x02=str_constant +hwmon_in.str_cons_0x0020_0x02=ucd90160 + +hwmon_in.mode_0x0020_0x03=constant +hwmon_in.int_cons_0x0020_0x03=3600 + +hwmon_in.mode_0x0020_0x05=constant +hwmon_in.int_cons_0x0020_0x05=3200 + +hwmon_in.mode_0x0021_0x00=config +hwmon_in.int_cons_0x0021_0x00=0 +hwmon_in.src_0x0021_0x00=file +hwmon_in.frmt_0x0021_0x00=buf +hwmon_in.fpath_0x0021_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x0021_0x00=0 +hwmon_in.len_0x0021_0x00=8 +hwmon_in.bit_offset_0x0021_0x00= +hwmon_in.str_cons_0x0021_0x00=in5_input + +hwmon_in.mode_0x0021_0x01=str_constant +hwmon_in.str_cons_0x0021_0x01=UPORT_QSFP56_VDD3.3V_A + +hwmon_in.mode_0x0021_0x02=str_constant +hwmon_in.str_cons_0x0021_0x02=ucd90160 + +hwmon_in.mode_0x0021_0x03=constant +hwmon_in.int_cons_0x0021_0x03=3600 + +hwmon_in.mode_0x0021_0x05=constant +hwmon_in.int_cons_0x0021_0x05=3200 + +hwmon_in.mode_0x0022_0x00=config +hwmon_in.int_cons_0x0022_0x00=0 +hwmon_in.src_0x0022_0x00=file +hwmon_in.frmt_0x0022_0x00=buf +hwmon_in.fpath_0x0022_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x0022_0x00=0 +hwmon_in.len_0x0022_0x00=8 +hwmon_in.bit_offset_0x0022_0x00= +hwmon_in.str_cons_0x0022_0x00=in6_input + +hwmon_in.mode_0x0022_0x01=str_constant +hwmon_in.str_cons_0x0022_0x01=UPORT_QSFP56_VDD3.3V_B + +hwmon_in.mode_0x0022_0x02=str_constant +hwmon_in.str_cons_0x0022_0x02=ucd90160 + +hwmon_in.mode_0x0022_0x03=constant +hwmon_in.int_cons_0x0022_0x03=3600 + +hwmon_in.mode_0x0022_0x05=constant +hwmon_in.int_cons_0x0022_0x05=3200 + +hwmon_in.mode_0x0023_0x00=config +hwmon_in.int_cons_0x0023_0x00=0 +hwmon_in.src_0x0023_0x00=file +hwmon_in.frmt_0x0023_0x00=buf +hwmon_in.fpath_0x0023_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x0023_0x00=0 +hwmon_in.len_0x0023_0x00=8 +hwmon_in.bit_offset_0x0023_0x00= +hwmon_in.str_cons_0x0023_0x00=in7_input + +hwmon_in.mode_0x0023_0x01=str_constant +hwmon_in.str_cons_0x0023_0x01=UPORT_QSFP56_VDD3.3V_C + +hwmon_in.mode_0x0023_0x02=str_constant +hwmon_in.str_cons_0x0023_0x02=ucd90160 + +hwmon_in.mode_0x0023_0x03=constant +hwmon_in.int_cons_0x0023_0x03=3600 + +hwmon_in.mode_0x0023_0x05=constant +hwmon_in.int_cons_0x0023_0x05=3200 + +hwmon_in.mode_0x0024_0x00=config +hwmon_in.int_cons_0x0024_0x00=0 +hwmon_in.src_0x0024_0x00=file +hwmon_in.frmt_0x0024_0x00=buf +hwmon_in.fpath_0x0024_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x0024_0x00=0 +hwmon_in.len_0x0024_0x00=8 +hwmon_in.bit_offset_0x0024_0x00= +hwmon_in.str_cons_0x0024_0x00=in8_input + +hwmon_in.mode_0x0024_0x01=str_constant +hwmon_in.str_cons_0x0024_0x01=UPORT_QSFP56_VDD3.3V_D + +hwmon_in.mode_0x0024_0x02=str_constant +hwmon_in.str_cons_0x0024_0x02=ucd90160 + +hwmon_in.mode_0x0024_0x03=constant +hwmon_in.int_cons_0x0024_0x03=3600 + +hwmon_in.mode_0x0024_0x05=constant +hwmon_in.int_cons_0x0024_0x05=3200 + +hwmon_in.mode_0x0025_0x00=config +hwmon_in.int_cons_0x0025_0x00=0 +hwmon_in.src_0x0025_0x00=file +hwmon_in.frmt_0x0025_0x00=buf +hwmon_in.fpath_0x0025_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x0025_0x00=0 +hwmon_in.len_0x0025_0x00=8 +hwmon_in.bit_offset_0x0025_0x00= +hwmon_in.str_cons_0x0025_0x00=in9_input + +hwmon_in.mode_0x0025_0x01=str_constant +hwmon_in.str_cons_0x0025_0x01=UPORT_VDD3.3_MON + +hwmon_in.mode_0x0025_0x02=str_constant +hwmon_in.str_cons_0x0025_0x02=ucd90160 + +hwmon_in.mode_0x0025_0x03=constant +hwmon_in.int_cons_0x0025_0x03=3465 + +hwmon_in.mode_0x0025_0x05=constant +hwmon_in.int_cons_0x0025_0x05=3135 + +hwmon_in.mode_0x0026_0x00=config +hwmon_in.int_cons_0x0026_0x00=0 +hwmon_in.src_0x0026_0x00=file +hwmon_in.frmt_0x0026_0x00=buf +hwmon_in.fpath_0x0026_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x0026_0x00=0 +hwmon_in.len_0x0026_0x00=8 +hwmon_in.bit_offset_0x0026_0x00= +hwmon_in.str_cons_0x0026_0x00=in10_input + +hwmon_in.mode_0x0026_0x01=str_constant +hwmon_in.str_cons_0x0026_0x01=UPORT_VDD12V + +hwmon_in.mode_0x0026_0x02=str_constant +hwmon_in.str_cons_0x0026_0x02=ucd90160 + +hwmon_in.mode_0x0026_0x03=constant +hwmon_in.int_cons_0x0026_0x03=12600 + +hwmon_in.mode_0x0026_0x05=constant +hwmon_in.int_cons_0x0026_0x05=11400 + +hwmon_in.mode_0x0027_0x00=config +hwmon_in.int_cons_0x0027_0x00=0 +hwmon_in.src_0x0027_0x00=file +hwmon_in.frmt_0x0027_0x00=buf +hwmon_in.fpath_0x0027_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x0027_0x00=0 +hwmon_in.len_0x0027_0x00=8 +hwmon_in.bit_offset_0x0027_0x00= +hwmon_in.str_cons_0x0027_0x00=in1_input + +hwmon_in.mode_0x0027_0x01=str_constant +hwmon_in.str_cons_0x0027_0x01=DPORT_VDD1.0V_FPGA + +hwmon_in.mode_0x0027_0x02=str_constant +hwmon_in.str_cons_0x0027_0x02=ucd90160 + +hwmon_in.mode_0x0027_0x03=constant +hwmon_in.int_cons_0x0027_0x03=1061 + +hwmon_in.mode_0x0027_0x05=constant +hwmon_in.int_cons_0x0027_0x05=959 + +hwmon_in.mode_0x0028_0x00=config +hwmon_in.int_cons_0x0028_0x00=0 +hwmon_in.src_0x0028_0x00=file +hwmon_in.frmt_0x0028_0x00=buf +hwmon_in.fpath_0x0028_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x0028_0x00=0 +hwmon_in.len_0x0028_0x00=8 +hwmon_in.bit_offset_0x0028_0x00= +hwmon_in.str_cons_0x0028_0x00=in2_input + +hwmon_in.mode_0x0028_0x01=str_constant +hwmon_in.str_cons_0x0028_0x01=DPORT_VDD1.8V_FPGA + +hwmon_in.mode_0x0028_0x02=str_constant +hwmon_in.str_cons_0x0028_0x02=ucd90160 + +hwmon_in.mode_0x0028_0x03=constant +hwmon_in.int_cons_0x0028_0x03=1901 + +hwmon_in.mode_0x0028_0x05=constant +hwmon_in.int_cons_0x0028_0x05=1719 + +hwmon_in.mode_0x0029_0x00=config +hwmon_in.int_cons_0x0029_0x00=0 +hwmon_in.src_0x0029_0x00=file +hwmon_in.frmt_0x0029_0x00=buf +hwmon_in.fpath_0x0029_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x0029_0x00=0 +hwmon_in.len_0x0029_0x00=8 +hwmon_in.bit_offset_0x0029_0x00= +hwmon_in.str_cons_0x0029_0x00=in3_input + +hwmon_in.mode_0x0029_0x01=str_constant +hwmon_in.str_cons_0x0029_0x01=DPORT_VDD1.2V_FPGA + +hwmon_in.mode_0x0029_0x02=str_constant +hwmon_in.str_cons_0x0029_0x02=ucd90160 + +hwmon_in.mode_0x0029_0x03=constant +hwmon_in.int_cons_0x0029_0x03=1260 + +hwmon_in.mode_0x0029_0x05=constant +hwmon_in.int_cons_0x0029_0x05=1140 + +hwmon_in.mode_0x002a_0x00=config +hwmon_in.int_cons_0x002a_0x00=0 +hwmon_in.src_0x002a_0x00=file +hwmon_in.frmt_0x002a_0x00=buf +hwmon_in.fpath_0x002a_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x002a_0x00=0 +hwmon_in.len_0x002a_0x00=8 +hwmon_in.bit_offset_0x002a_0x00= +hwmon_in.str_cons_0x002a_0x00=in4_input + +hwmon_in.mode_0x002a_0x01=str_constant +hwmon_in.str_cons_0x002a_0x01=DPORT_VDD3.3V + +hwmon_in.mode_0x002a_0x02=str_constant +hwmon_in.str_cons_0x002a_0x02=ucd90160 + +hwmon_in.mode_0x002a_0x03=constant +hwmon_in.int_cons_0x002a_0x03=3600 + +hwmon_in.mode_0x002a_0x05=constant +hwmon_in.int_cons_0x002a_0x05=3200 + +hwmon_in.mode_0x002b_0x00=config +hwmon_in.int_cons_0x002b_0x00=0 +hwmon_in.src_0x002b_0x00=file +hwmon_in.frmt_0x002b_0x00=buf +hwmon_in.fpath_0x002b_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x002b_0x00=0 +hwmon_in.len_0x002b_0x00=8 +hwmon_in.bit_offset_0x002b_0x00= +hwmon_in.str_cons_0x002b_0x00=in5_input + +hwmon_in.mode_0x002b_0x01=str_constant +hwmon_in.str_cons_0x002b_0x01=DPORT_QSFP56_VDD3.3V_A + +hwmon_in.mode_0x002b_0x02=str_constant +hwmon_in.str_cons_0x002b_0x02=ucd90160 + +hwmon_in.mode_0x002b_0x03=constant +hwmon_in.int_cons_0x002b_0x03=3600 + +hwmon_in.mode_0x002b_0x05=constant +hwmon_in.int_cons_0x002b_0x05=3200 + +hwmon_in.mode_0x002c_0x00=config +hwmon_in.int_cons_0x002c_0x00=0 +hwmon_in.src_0x002c_0x00=file +hwmon_in.frmt_0x002c_0x00=buf +hwmon_in.fpath_0x002c_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x002c_0x00=0 +hwmon_in.len_0x002c_0x00=8 +hwmon_in.bit_offset_0x002c_0x00= +hwmon_in.str_cons_0x002c_0x00=in6_input + +hwmon_in.mode_0x002c_0x01=str_constant +hwmon_in.str_cons_0x002c_0x01=DPORT_QSFP56_VDD3.3V_B + +hwmon_in.mode_0x002c_0x02=str_constant +hwmon_in.str_cons_0x002c_0x02=ucd90160 + +hwmon_in.mode_0x002c_0x03=constant +hwmon_in.int_cons_0x002c_0x03=3600 + +hwmon_in.mode_0x002c_0x05=constant +hwmon_in.int_cons_0x002c_0x05=3200 + +hwmon_in.mode_0x002d_0x00=config +hwmon_in.int_cons_0x002d_0x00=0 +hwmon_in.src_0x002d_0x00=file +hwmon_in.frmt_0x002d_0x00=buf +hwmon_in.fpath_0x002d_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x002d_0x00=0 +hwmon_in.len_0x002d_0x00=8 +hwmon_in.bit_offset_0x002d_0x00= +hwmon_in.str_cons_0x002d_0x00=in7_input + +hwmon_in.mode_0x002d_0x01=str_constant +hwmon_in.str_cons_0x002d_0x01=DPORT_QSFP56_VDD3.3V_C + +hwmon_in.mode_0x002d_0x02=str_constant +hwmon_in.str_cons_0x002d_0x02=ucd90160 + +hwmon_in.mode_0x002d_0x03=constant +hwmon_in.int_cons_0x002d_0x03=3600 + +hwmon_in.mode_0x002d_0x05=constant +hwmon_in.int_cons_0x002d_0x05=3200 + +hwmon_in.mode_0x002e_0x00=config +hwmon_in.int_cons_0x002e_0x00=0 +hwmon_in.src_0x002e_0x00=file +hwmon_in.frmt_0x002e_0x00=buf +hwmon_in.fpath_0x002e_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x002e_0x00=0 +hwmon_in.len_0x002e_0x00=8 +hwmon_in.bit_offset_0x002e_0x00= +hwmon_in.str_cons_0x002e_0x00=in8_input + +hwmon_in.mode_0x002e_0x01=str_constant +hwmon_in.str_cons_0x002e_0x01=DPORT_QSFP56_VDD3.3V_D + +hwmon_in.mode_0x002e_0x02=str_constant +hwmon_in.str_cons_0x002e_0x02=ucd90160 + +hwmon_in.mode_0x002e_0x03=constant +hwmon_in.int_cons_0x002e_0x03=3600 + +hwmon_in.mode_0x002e_0x05=constant +hwmon_in.int_cons_0x002e_0x05=3200 + +hwmon_in.mode_0x002f_0x00=config +hwmon_in.int_cons_0x002f_0x00=0 +hwmon_in.src_0x002f_0x00=file +hwmon_in.frmt_0x002f_0x00=buf +hwmon_in.fpath_0x002f_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x002f_0x00=0 +hwmon_in.len_0x002f_0x00=8 +hwmon_in.bit_offset_0x002f_0x00= +hwmon_in.str_cons_0x002f_0x00=in9_input + +hwmon_in.mode_0x002f_0x01=str_constant +hwmon_in.str_cons_0x002f_0x01=DPORT_VDD3.3_MON + +hwmon_in.mode_0x002f_0x02=str_constant +hwmon_in.str_cons_0x002f_0x02=ucd90160 + +hwmon_in.mode_0x002f_0x03=constant +hwmon_in.int_cons_0x002f_0x03=3465 + +hwmon_in.mode_0x002f_0x05=constant +hwmon_in.int_cons_0x002f_0x05=3135 + +hwmon_in.mode_0x0030_0x00=config +hwmon_in.int_cons_0x0030_0x00=0 +hwmon_in.src_0x0030_0x00=file +hwmon_in.frmt_0x0030_0x00=buf +hwmon_in.fpath_0x0030_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x0030_0x00=0 +hwmon_in.len_0x0030_0x00=8 +hwmon_in.bit_offset_0x0030_0x00= +hwmon_in.str_cons_0x0030_0x00=in10_input + +hwmon_in.mode_0x0030_0x01=str_constant +hwmon_in.str_cons_0x0030_0x01=DPORT_VDD12V + +hwmon_in.mode_0x0030_0x02=str_constant +hwmon_in.str_cons_0x0030_0x02=ucd90160 + +hwmon_in.mode_0x0030_0x03=constant +hwmon_in.int_cons_0x0030_0x03=12600 + +hwmon_in.mode_0x0030_0x05=constant +hwmon_in.int_cons_0x0030_0x05=11400 + + +# MAC_QSFPDD_VDD3.3V_A +hwmon_in.mode_0x0031_0x00=config +hwmon_in.int_cons_0x0031_0x00=0 +hwmon_in.src_0x0031_0x00=cpld +hwmon_in.frmt_0x0031_0x00=num_bytes +hwmon_in.addr_0x0031_0x00=0x00050030 +hwmon_in.len_0x0031_0x00=2 +hwmon_in.int_extra1_0x0031_0x00=0x00050030 +hwmon_in.int_extra2_0x0031_0x00=2000 + +hwmon_in.mode_0x0031_0x01=str_constant +hwmon_in.str_cons_0x0031_0x01=MAC_QSFPDD_VDD3.3V_A + +hwmon_in.mode_0x0031_0x02=str_constant +hwmon_in.str_cons_0x0031_0x02=cpld + +hwmon_in.mode_0x0031_0x03=constant +hwmon_in.int_cons_0x0031_0x03=3600 + +hwmon_in.mode_0x0031_0x05=constant +hwmon_in.int_cons_0x0031_0x05=3200 + + +# MAC_QSFPDD_VDD3.3V_B +hwmon_in.mode_0x0032_0x00=config +hwmon_in.int_cons_0x0032_0x00=0 +hwmon_in.src_0x0032_0x00=cpld +hwmon_in.frmt_0x0032_0x00=num_bytes +hwmon_in.addr_0x0032_0x00=0x00050032 +hwmon_in.len_0x0032_0x00=2 +hwmon_in.int_extra1_0x0032_0x00=0x00050032 +hwmon_in.int_extra2_0x0032_0x00=2000 + +hwmon_in.mode_0x0032_0x01=str_constant +hwmon_in.str_cons_0x0032_0x01=MAC_QSFPDD_VDD3.3V_B + +hwmon_in.mode_0x0032_0x02=str_constant +hwmon_in.str_cons_0x0032_0x02=cpld + +hwmon_in.mode_0x0032_0x03=constant +hwmon_in.int_cons_0x0032_0x03=3600 + +hwmon_in.mode_0x0032_0x05=constant +hwmon_in.int_cons_0x0032_0x05=3200 + + +# MAC_QSFPDD_VDD3.3V_C +hwmon_in.mode_0x0033_0x00=config +hwmon_in.int_cons_0x0033_0x00=0 +hwmon_in.src_0x0033_0x00=cpld +hwmon_in.frmt_0x0033_0x00=num_bytes +hwmon_in.addr_0x0033_0x00=0x00050034 +hwmon_in.len_0x0033_0x00=2 +hwmon_in.int_extra1_0x0033_0x00=0x00050034 +hwmon_in.int_extra2_0x0033_0x00=2000 + +hwmon_in.mode_0x0033_0x01=str_constant +hwmon_in.str_cons_0x0033_0x01=MAC_QSFPDD_VDD3.3V_C + +hwmon_in.mode_0x0033_0x02=str_constant +hwmon_in.str_cons_0x0033_0x02=cpld + +hwmon_in.mode_0x0033_0x03=constant +hwmon_in.int_cons_0x0033_0x03=3600 + +hwmon_in.mode_0x0033_0x05=constant +hwmon_in.int_cons_0x0033_0x05=3200 + + +# MAC_QSFPDD_VDD3.3V_D +hwmon_in.mode_0x0034_0x00=config +hwmon_in.int_cons_0x0034_0x00=0 +hwmon_in.src_0x0034_0x00=cpld +hwmon_in.frmt_0x0034_0x00=num_bytes +hwmon_in.addr_0x0034_0x00=0x00050036 +hwmon_in.len_0x0034_0x00=2 +hwmon_in.int_extra1_0x0034_0x00=0x00050036 +hwmon_in.int_extra2_0x0034_0x00=2000 + +hwmon_in.mode_0x0034_0x01=str_constant +hwmon_in.str_cons_0x0034_0x01=MAC_QSFPDD_VDD3.3V_D + +hwmon_in.mode_0x0034_0x02=str_constant +hwmon_in.str_cons_0x0034_0x02=cpld + +hwmon_in.mode_0x0034_0x03=constant +hwmon_in.int_cons_0x0034_0x03=3600 + +hwmon_in.mode_0x0034_0x05=constant +hwmon_in.int_cons_0x0034_0x05=3200 + + +# MAC_QSFPDD_VDD3.3V_E +hwmon_in.mode_0x0035_0x00=config +hwmon_in.int_cons_0x0035_0x00=0 +hwmon_in.src_0x0035_0x00=cpld +hwmon_in.frmt_0x0035_0x00=num_bytes +hwmon_in.addr_0x0035_0x00=0x00050038 +hwmon_in.len_0x0035_0x00=2 +hwmon_in.int_extra1_0x0035_0x00=0x00050038 +hwmon_in.int_extra2_0x0035_0x00=2000 + +hwmon_in.mode_0x0035_0x01=str_constant +hwmon_in.str_cons_0x0035_0x01=MAC_QSFPDD_VDD3.3V_E + +hwmon_in.mode_0x0035_0x02=str_constant +hwmon_in.str_cons_0x0035_0x02=cpld + +hwmon_in.mode_0x0035_0x03=constant +hwmon_in.int_cons_0x0035_0x03=3600 + +hwmon_in.mode_0x0035_0x05=constant +hwmon_in.int_cons_0x0035_0x05=3200 + + +# MAC_QSFPDD_VDD3.3V_F +hwmon_in.mode_0x0036_0x00=config +hwmon_in.int_cons_0x0036_0x00=0 +hwmon_in.src_0x0036_0x00=cpld +hwmon_in.frmt_0x0036_0x00=num_bytes +hwmon_in.addr_0x0036_0x00=0x0005003a +hwmon_in.len_0x0036_0x00=2 +hwmon_in.int_extra1_0x0036_0x00=0x0005003a +hwmon_in.int_extra2_0x0036_0x00=2000 + +hwmon_in.mode_0x0036_0x01=str_constant +hwmon_in.str_cons_0x0036_0x01=MAC_QSFPDD_VDD3.3V_F + +hwmon_in.mode_0x0036_0x02=str_constant +hwmon_in.str_cons_0x0036_0x02=cpld + +hwmon_in.mode_0x0036_0x03=constant +hwmon_in.int_cons_0x0036_0x03=3600 + +hwmon_in.mode_0x0036_0x05=constant +hwmon_in.int_cons_0x0036_0x05=3200 + + +# MAC_QSFPDD_VDD3.3V_G +hwmon_in.mode_0x0037_0x00=config +hwmon_in.int_cons_0x0037_0x00=0 +hwmon_in.src_0x0037_0x00=cpld +hwmon_in.frmt_0x0037_0x00=num_bytes +hwmon_in.addr_0x0037_0x00=0x0005003c +hwmon_in.len_0x0037_0x00=2 +hwmon_in.int_extra1_0x0037_0x00=0x0005003c +hwmon_in.int_extra2_0x0037_0x00=2000 + +hwmon_in.mode_0x0037_0x01=str_constant +hwmon_in.str_cons_0x0037_0x01=MAC_QSFPDD_VDD3.3V_G + +hwmon_in.mode_0x0037_0x02=str_constant +hwmon_in.str_cons_0x0037_0x02=cpld + +hwmon_in.mode_0x0037_0x03=constant +hwmon_in.int_cons_0x0037_0x03=3600 + +hwmon_in.mode_0x0037_0x05=constant +hwmon_in.int_cons_0x0037_0x05=3200 + + +# MAC_QSFPDD_VDD3.3V_H +hwmon_in.mode_0x0038_0x00=config +hwmon_in.int_cons_0x0038_0x00=0 +hwmon_in.src_0x0038_0x00=cpld +hwmon_in.frmt_0x0038_0x00=num_bytes +hwmon_in.addr_0x0038_0x00=0x0005003e +hwmon_in.len_0x0038_0x00=2 +hwmon_in.int_extra1_0x0038_0x00=0x0005003e +hwmon_in.int_extra2_0x0038_0x00=2000 + +hwmon_in.mode_0x0038_0x01=str_constant +hwmon_in.str_cons_0x0038_0x01=MAC_QSFPDD_VDD3.3V_H + +hwmon_in.mode_0x0038_0x02=str_constant +hwmon_in.str_cons_0x0038_0x02=cpld + +hwmon_in.mode_0x0038_0x03=constant +hwmon_in.int_cons_0x0038_0x03=3600 + +hwmon_in.mode_0x0038_0x05=constant +hwmon_in.int_cons_0x0038_0x05=3200 + + +# curr1 +hwmon_curr.mode_0x0001_0x00=config +hwmon_curr.int_cons_0x0001_0x00=0 +hwmon_curr.src_0x0001_0x00=file +hwmon_curr.frmt_0x0001_0x00=buf +hwmon_curr.fpath_0x0001_0x00=/sys/bus/i2c/devices/106-0060/hwmon/ +hwmon_curr.addr_0x0001_0x00=0 +hwmon_curr.len_0x0001_0x00=8 +hwmon_curr.bit_offset_0x0001_0x00= +hwmon_curr.str_cons_0x0001_0x00=curr1_input + +hwmon_curr.mode_0x0001_0x01=str_constant +hwmon_curr.str_cons_0x0001_0x01=CPU_VCCIN_C + +hwmon_curr.mode_0x0001_0x02=str_constant +hwmon_curr.str_cons_0x0001_0x02=tps53622 + +hwmon_curr.mode_0x0001_0x03=constant +hwmon_curr.int_cons_0x0001_0x03=47300 + +hwmon_curr.mode_0x0001_0x05=constant +hwmon_curr.int_cons_0x0001_0x05=0 + +# curr2 +hwmon_curr.mode_0x0002_0x00=config +hwmon_curr.int_cons_0x0002_0x00=0 +hwmon_curr.src_0x0002_0x00=file +hwmon_curr.frmt_0x0002_0x00=buf +hwmon_curr.fpath_0x0002_0x00=/sys/bus/i2c/devices/106-0060/hwmon/ +hwmon_curr.addr_0x0002_0x00=0 +hwmon_curr.len_0x0002_0x00=8 +hwmon_curr.bit_offset_0x0002_0x00= +hwmon_curr.str_cons_0x0002_0x00=curr2_input + +hwmon_curr.mode_0x0002_0x01=str_constant +hwmon_curr.str_cons_0x0002_0x01=CPU_P1V05_C + +hwmon_curr.mode_0x0002_0x02=str_constant +hwmon_curr.str_cons_0x0002_0x02=tps53622 + +hwmon_curr.mode_0x0002_0x03=constant +hwmon_curr.int_cons_0x0002_0x03=15400 + +hwmon_curr.mode_0x0002_0x05=constant +hwmon_curr.int_cons_0x0002_0x05=0 + +# curr3 +hwmon_curr.mode_0x0003_0x00=config +hwmon_curr.int_cons_0x0003_0x00=0 +hwmon_curr.src_0x0003_0x00=file +hwmon_curr.frmt_0x0003_0x00=buf +hwmon_curr.fpath_0x0003_0x00=/sys/bus/i2c/devices/106-006c/hwmon/ +hwmon_curr.addr_0x0003_0x00=0 +hwmon_curr.len_0x0003_0x00=8 +hwmon_curr.bit_offset_0x0003_0x00= +hwmon_curr.str_cons_0x0003_0x00=curr1_input + +hwmon_curr.mode_0x0003_0x01=str_constant +hwmon_curr.str_cons_0x0003_0x01=CPU_P1V2_VDDQ_C + +hwmon_curr.mode_0x0003_0x02=str_constant +hwmon_curr.str_cons_0x0003_0x02=tps53622 + +hwmon_curr.mode_0x0003_0x03=constant +hwmon_curr.int_cons_0x0003_0x03=9900 + +hwmon_curr.mode_0x0003_0x05=constant +hwmon_curr.int_cons_0x0003_0x05=0 + +# curr4 +hwmon_curr.mode_0x0004_0x00=config +hwmon_curr.int_cons_0x0004_0x00=0 +hwmon_curr.src_0x0004_0x00=file +hwmon_curr.frmt_0x0004_0x00=buf +hwmon_curr.fpath_0x0004_0x00=/sys/bus/i2c/devices/106-006c/hwmon/ +hwmon_curr.addr_0x0004_0x00=0 +hwmon_curr.len_0x0004_0x00=8 +hwmon_curr.bit_offset_0x0004_0x00= +hwmon_curr.str_cons_0x0004_0x00=curr2_input + +hwmon_curr.mode_0x0004_0x01=str_constant +hwmon_curr.str_cons_0x0004_0x01=CPU_P2V5_VPP_C + +hwmon_curr.mode_0x0004_0x02=str_constant +hwmon_curr.str_cons_0x0004_0x02=tps53622 + +hwmon_curr.mode_0x0004_0x03=constant +hwmon_curr.int_cons_0x0004_0x03=2200 + +hwmon_curr.mode_0x0004_0x05=constant +hwmon_curr.int_cons_0x0004_0x05=0 + +# curr5 +hwmon_curr.mode_0x0005_0x00=config +hwmon_curr.int_cons_0x0005_0x00=0 +hwmon_curr.src_0x0005_0x00=file +hwmon_curr.frmt_0x0005_0x00=buf +hwmon_curr.fpath_0x0005_0x00=/sys/bus/i2c/devices/106-0043/hwmon/ +hwmon_curr.addr_0x0005_0x00=0 +hwmon_curr.len_0x0005_0x00=8 +hwmon_curr.bit_offset_0x0005_0x00= +hwmon_curr.str_cons_0x0005_0x00=curr1_input + +hwmon_curr.mode_0x0005_0x01=str_constant +hwmon_curr.str_cons_0x0005_0x01=CPU_P3V3_STBY_C + +hwmon_curr.mode_0x0005_0x02=str_constant +hwmon_curr.str_cons_0x0005_0x02=ina3221 + +hwmon_curr.mode_0x0005_0x03=constant +hwmon_curr.int_cons_0x0005_0x03=4686 + +hwmon_curr.mode_0x0005_0x05=constant +hwmon_curr.int_cons_0x0005_0x05=0 + +# curr6 +hwmon_curr.mode_0x0006_0x00=config +hwmon_curr.int_cons_0x0006_0x00=0 +hwmon_curr.src_0x0006_0x00=file +hwmon_curr.frmt_0x0006_0x00=buf +hwmon_curr.fpath_0x0006_0x00=/sys/bus/i2c/devices/106-0043/hwmon/ +hwmon_curr.addr_0x0006_0x00=0 +hwmon_curr.len_0x0006_0x00=8 +hwmon_curr.bit_offset_0x0006_0x00= +hwmon_curr.str_cons_0x0006_0x00=curr2_input + +hwmon_curr.mode_0x0006_0x01=str_constant +hwmon_curr.str_cons_0x0006_0x01=CPU_P5V_AUX_IN_C + +hwmon_curr.mode_0x0006_0x02=str_constant +hwmon_curr.str_cons_0x0006_0x02=ina3221 + +hwmon_curr.mode_0x0006_0x03=constant +hwmon_curr.int_cons_0x0006_0x03=2200 + +hwmon_curr.mode_0x0006_0x05=constant +hwmon_curr.int_cons_0x0006_0x05=0 + +# curr7 +hwmon_curr.mode_0x0007_0x00=config +hwmon_curr.int_cons_0x0007_0x00=0 +hwmon_curr.src_0x0007_0x00=file +hwmon_curr.frmt_0x0007_0x00=buf +hwmon_curr.fpath_0x0007_0x00=/sys/bus/i2c/devices/106-0043/hwmon/ +hwmon_curr.addr_0x0007_0x00=0 +hwmon_curr.len_0x0007_0x00=8 +hwmon_curr.bit_offset_0x0007_0x00= +hwmon_curr.str_cons_0x0007_0x00=curr3_input + +hwmon_curr.mode_0x0007_0x01=str_constant +hwmon_curr.str_cons_0x0007_0x01=CPU_P1V7_VCCSCFUSESUS_IN_C + +hwmon_curr.mode_0x0007_0x02=str_constant +hwmon_curr.str_cons_0x0007_0x02=ina3221 + +hwmon_curr.mode_0x0007_0x03=constant +hwmon_curr.int_cons_0x0007_0x03=2200 + +hwmon_curr.mode_0x0007_0x05=constant +hwmon_curr.int_cons_0x0007_0x05=0 \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/file_name/0x4074 b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/file_name/0x4074 new file mode 100755 index 000000000000..255b82321caf --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/file_name/0x4074 @@ -0,0 +1,7 @@ +TCS8400-CPLD +TCS8400-FPGA +TCS8400-FAN +TCS8400-LED +TCS8400-PSU +TCS8400-SENSOR +TCS8400-SFF \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/file_name/0x4078 b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/file_name/0x4078 new file mode 100755 index 000000000000..99df76574a75 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/file_name/0x4078 @@ -0,0 +1,7 @@ +TCS9400-CPLD +TCS9400-FPGA +TCS9400-FAN +TCS9400-LED +TCS9400-PSU +TCS9400-SENSOR +TCS9400-SFF \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/file_name/0x407b b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/file_name/0x407b new file mode 100755 index 000000000000..90747316d593 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/file_name/0x407b @@ -0,0 +1,7 @@ +TCS8400-CPLD +TCS8400-FPGA +TCS8400-FAN +TCS8400-LED +TCS8400-PSU +TCS8400-V2-SENSOR +TCS8400-SFF \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/file_name/0x407c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/file_name/0x407c new file mode 100755 index 000000000000..f09852e08737 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/file_name/0x407c @@ -0,0 +1,7 @@ +TCS9400-CPLD +TCS9400-FPGA +TCS9400-FAN +TCS9400-LED +TCS9400-PSU +TCS9400-V2-SENSOR +TCS9400-SFF \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_cfg.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_cfg.h new file mode 100644 index 000000000000..4ed3e57a7a2c --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_cfg.h @@ -0,0 +1,139 @@ +#ifndef __DFD_CFG_H__ +#define __DFD_CFG_H__ + +#include + +#define DFD_KO_FILE_NAME_DIR "/etc/dfd_cfg/ko/file_name/" +#define DFD_KO_CFG_FILE_DIR "/etc/dfd_cfg/ko/cfg_file/" +#define DFD_PUB_CARDTYPE_FILE "/sys/module/ruijie_common/parameters/dfd_my_type" + +#define DFD_CFG_CMDLINE_MAX_LEN (256) +#define DFD_CFG_NAME_MAX_LEN (256) +#define DFD_CFG_VALUE_MAX_LEN (256) +#define DFD_CFG_STR_MAX_LEN (64) +#define DFD_CFG_CPLD_NUM_MAX (16) +#define DFD_PRODUCT_ID_LENGTH (8) +#define DFD_PID_BUF_LEN (32) +#define DFD_TEMP_NAME_BUF_LEN (32) + +#define DFD_CFG_EMPTY_VALUE (-1) +#define DFD_CFG_INVALID_VALUE (0) + +#define DFD_CFG_KEY(item, index1, index2) \ + ((((item) & 0xff) << 24) | (((index1) & 0xffff) << 8) | ((index2) & 0xff)) +#define DFD_CFG_ITEM_ID(key) (((key) >> 24) & 0xff) +#define DFD_CFG_INDEX1(key) (((key) >> 8) & 0xffff) +#define DFD_CFG_INDEX2(key) ((key)& 0xff) + +#define INDEX_NOT_EXIST (-1) +#define INDEX1_MAX (0xffff) +#define INDEX2_MAX (0xff) + +#define DFD_CFG_ITEM_ALL \ + DFD_CFG_ITEM(DFD_CFG_ITEM_NONE, "none", INDEX_NOT_EXIST, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_DEV_NUM, "dev_num", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FAN_SPEED_TOLERANCE, "fan_speed_tolerance", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FAN_SPEED_TARGET, "fan_speed_target", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FAN_SPEED_MAX, "fan_speed_max", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FAN_SPEED_MIN, "fan_speed_min", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_LED_STATUS_DECODE, "led_status_decode", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_CPLD_LPC_DEV, "cpld_lpc_dev", INDEX1_MAX, DFD_CFG_CPLD_NUM_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FAN_TYPE_NUM, "fan_type_num", INDEX1_MAX, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_EEPROM_SIZE, "eeprom_size", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_DECODE_POWER_FAN_DIR, "decode_power_fan_dir", INDEX1_MAX, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_WATCHDOG_ID, "watchdog_id", INDEX1_MAX, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_POWER_RSUPPLY, "power_rate_supply", INDEX1_MAX, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_PSU_PMBUS_ID, "psu_pmbus_id", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_INT_END, "end_int", INDEX_NOT_EXIST, INDEX_NOT_EXIST) \ + \ + DFD_CFG_ITEM(DFD_CFG_ITEM_CPLD_MODE, "mode_cpld", INDEX1_MAX, DFD_CFG_CPLD_NUM_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_CPLD_NAME, "cpld_name", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_CPLD_TYPE, "cpld_type", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FPGA_NAME, "fpga_name", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FPGA_TYPE, "fpga_type", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FPGA_MODEL_DECODE, "fpga_model_decode", INDEX1_MAX, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FAN_E2_MODE, "fan_e2_mode", INDEX_NOT_EXIST, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FAN_SYSFS_NAME, "fan_sysfs_name", INDEX_NOT_EXIST, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_POWER_NAME, "power_name", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FAN_NAME, "fan_name", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_DECODE_POWER_NAME, "decode_power_name", INDEX1_MAX, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_DECODE_FAN_NAME, "decode_fan_name", INDEX1_MAX, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_EEPROM_PATH, "eeprom_path", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FAN_DIRECTION, "fan_direction", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_WATCHDOG_NAME, "watchdog_name", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_PSU_SYSFS_NAME, "psu_sysfs_name", INDEX_NOT_EXIST, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_SLOT_SYSFS_NAME, "slot_sysfs_name", INDEX_NOT_EXIST, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_STRING_END, "end_string", INDEX_NOT_EXIST, INDEX_NOT_EXIST) \ + \ + DFD_CFG_ITEM(DFD_CFG_ITEM_CPLD_I2C_DEV, "cpld_i2c_dev", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_OTHER_I2C_DEV, "other_i2c_dev", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_I2C_DEV_END, "end_i2c_dev", INDEX_NOT_EXIST, INDEX_NOT_EXIST) \ + \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FAN_ROLL_STATUS, "fan_roll_status", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FAN_SPEED, "fan_speed", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FAN_RATIO, "fan_ratio", INDEX1_MAX, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_LED_STATUS, "led_status", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_CPLD_VERSION, "cpld_version", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_CPLD_TEST_REG, "cpld_test_reg", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_DEV_PRESENT_STATUS, "dev_present_status", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_PSU_STATUS, "psu_status", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_HWMON_TEMP, "hwmon_temp", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_HWMON_IN, "hwmon_in", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_HWMON_CURR, "hwmon_curr", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_HWMON_PSU, "hwmon_psu", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_SFF_CPLD_REG, "sff_cpld_reg", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FPGA_VERSION, "fpga_version", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FPGA_TEST_REG, "fpga_test_reg", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FPGA_MODEL_REG, "fpga_model_reg", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_INFO_CTRL_END, "end_info_ctrl", INDEX_NOT_EXIST, INDEX_NOT_EXIST) \ + +#ifdef DFD_CFG_ITEM +#undef DFD_CFG_ITEM +#endif +#define DFD_CFG_ITEM(_id, _name, _index_min, _index_max) _id, +typedef enum dfd_cfg_item_id_s { + DFD_CFG_ITEM_ALL +} dfd_cfg_item_id_t; + +#define DFD_CFG_ITEM_IS_INT(item_id) \ + (((item_id) > DFD_CFG_ITEM_NONE) && ((item_id) < DFD_CFG_ITEM_INT_END)) + +#define DFD_CFG_ITEM_IS_STRING(item_id) \ + (((item_id) > DFD_CFG_ITEM_INT_END) && ((item_id) < DFD_CFG_ITEM_STRING_END)) + +#define DFD_CFG_ITEM_IS_I2C_DEV(item_id) \ + (((item_id) > DFD_CFG_ITEM_STRING_END) && ((item_id) < DFD_CFG_ITEM_I2C_DEV_END)) + +#define DFD_CFG_ITEM_IS_INFO_CTRL(item_id) \ + (((item_id) > DFD_CFG_ITEM_I2C_DEV_END) && ((item_id) < DFD_CFG_ITEM_INFO_CTRL_END)) + +typedef struct index_range_s { + int index1_max; + int index2_max; +} index_range_t; + +typedef struct val_convert_node_s { + struct list_head lst; + int int_val; + char str_val[DFD_CFG_STR_MAX_LEN]; + int index1; + int index2; +} val_convert_node_t; + +void *dfd_ko_cfg_get_item(int key); + +void dfd_ko_cfg_show_item(int key); + +int32_t dfd_dev_cfg_init(void); + +void dfd_dev_cfg_exit(void); + +void dfd_ko_cfg_del_space_lf_cr(char *str); + +int dfd_ko_cfg_get_fan_direction_by_name(char *fan_name, int *fan_direction); + +int dfd_ko_cfg_get_power_type_by_name(char *power_name, int *power_type); + +int dfd_ko_cfg_get_led_status_decode2_by_regval(int regval, int index1, int *value); + +#endif /* __DFD_CFG_H__ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_cfg_adapter.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_cfg_adapter.h new file mode 100644 index 000000000000..7b6c2682ca80 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_cfg_adapter.h @@ -0,0 +1,49 @@ +#ifndef __DFD_CFG_ADAPTER_H__ +#define __DFD_CFG_ADAPTER_H__ + +#define DFD_KO_CPLD_I2C_RETRY_SLEEP (10) /* ms */ +#define DFD_KO_CPLD_I2C_RETRY_TIMES (50 / DFD_KO_CPLD_I2C_RETRY_SLEEP) + +#define DFD_KO_CPLD_GET_SLOT(addr) ((addr >> 24) & 0xff) +#define DFD_KO_CPLD_GET_ID(addr) ((addr >> 16) & 0xff) +#define DFD_KO_CPLD_GET_INDEX(addr) (addr & 0xffff) +#define DFD_KO_CPLD_MODE_I2C_STRING "i2c" +#define DFD_KO_CPLD_MODE_LPC_STRING "lpc" +#define DFD_SYSFS_PATH_MAX_LEN (64) + +typedef struct dfd_i2c_dev_s { + int bus; + int addr; +} dfd_i2c_dev_t; + +typedef enum dfd_i2c_dev_mem_s { + DFD_I2C_DEV_MEM_BUS, + DFD_I2C_DEV_MEM_ADDR, + DFD_I2C_DEV_MEM_END +} dfd_i2c_dev_mem_t; + +typedef enum cpld_mode_e { + DFD_CPLD_MODE_I2C, + DFD_CPLD_MODE_LPC, +} cpld_mode_t; + +typedef enum i2c_mode_e { + DFD_I2C_MODE_NORMAL_I2C, + DFD_I2C_MODE_SMBUS, +} i2c_mode_t; + +extern char *g_dfd_i2c_dev_mem_str[DFD_I2C_DEV_MEM_END]; + +int32_t dfd_ko_cpld_read(int32_t addr, uint8_t *buf); + +int32_t dfd_ko_cpld_write(int32_t addr, uint8_t val); + +int32_t dfd_ko_i2c_read(int bus, int addr, int offset, uint8_t *buf, uint32_t size, const char *sysfs_name); + +int32_t dfd_ko_i2c_write(int bus, int addr, int offset, uint8_t *buf, uint32_t size); + +int32_t dfd_ko_read_file(char *fpath, int32_t addr, uint8_t *val, int32_t read_bytes); + +int32_t dfd_ko_write_file(char *fpath, int32_t addr, uint8_t *val, int32_t write_bytes); + +#endif /* __DFD_CFG_ADAPTER_H__ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_cfg_file.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_cfg_file.h new file mode 100644 index 000000000000..50d7a42d5564 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_cfg_file.h @@ -0,0 +1,37 @@ +#ifndef __DFD_CFG_FILE_H__ +#define __DFD_CFG_FILE_H__ + +#include + +#define KFILE_RV_OK (0) +#define KFILE_RV_INPUT_ERR (-1) +#define KFILE_RV_STAT_FAIL (-2) +#define KFILE_RV_OPEN_FAIL (-3) +#define KFILE_RV_MALLOC_FAIL (-4) +#define KFILE_RV_RD_FAIL (-5) +#define KFILE_RV_ADDR_ERR (-6) +#define KFILE_RV_WR_FAIL (-7) + +#define IS_CR(c) ((c) == '\n') + +typedef struct kfile_ctrl_s { + int32_t size; + int32_t pos; + char *buf; +} kfile_ctrl_t; + +int kfile_open(char *fname, kfile_ctrl_t *kfile_ctrl); + +void kfile_close(kfile_ctrl_t *kfile_ctrl); + +int kfile_gets(char *buf, int buf_size, kfile_ctrl_t *kfile_ctrl); + +int kfile_read(int32_t addr, char *buf, int buf_size, kfile_ctrl_t *kfile_ctrl); + +int kfile_iterate_dir(const char *dir_path, const char *obj_name, char *match_name, int len); + +#if 0 + +int kfile_write(char *fpath, int32_t addr, char *buf, int buf_size); +#endif +#endif /* __DFD_CFG_FILE_H__ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_cfg_info.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_cfg_info.h new file mode 100644 index 000000000000..a80734989964 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_cfg_info.h @@ -0,0 +1,110 @@ +#ifndef __DFD_CFG_INFO_H__ +#define __DFD_CFG_INFO_H__ + +#include + +typedef int (*info_num_buf_to_value_f)(uint8_t *num_buf, int buf_len, int *num_val); + +typedef int (*info_buf_to_buf_f)(uint8_t *buf, int buf_len, uint8_t *buf_new, int *buf_len_new); + +#define IS_INFO_FRMT_BIT(frmt) ((frmt) == INFO_FRMT_BIT) +#define IS_INFO_FRMT_BYTE(frmt) (((frmt) == INFO_FRMT_BYTE) || ((frmt) == INFO_FRMT_NUM_BYTES)) +#define IS_INFO_FRMT_NUM_STR(frmt) ((frmt) == INFO_FRMT_NUM_STR) +#define IS_INFO_FRMT_NUM_BUF(frmt) ((frmt) == INFO_FRMT_NUM_BUF) +#define IS_INFO_FRMT_BUF(frmt) ((frmt) == INFO_FRMT_BUF) + +#define INFO_INT_MAX_LEN (32) +#define INFO_INT_LEN_VALAID(len) (((len) > 0) && ((len) < INFO_INT_MAX_LEN)) + +#define INFO_BUF_MAX_LEN (128) +#define INFO_BUF_LEN_VALAID(len) (((len) > 0) && ((len) < INFO_BUF_MAX_LEN)) + +#define INFO_BIT_OFFSET_VALID(bit_offset) (((bit_offset) >= 0) && ((bit_offset) < 8)) + +typedef enum info_ctrl_mode_e { + INFO_CTRL_MODE_NONE, + INFO_CTRL_MODE_CFG, + INFO_CTRL_MODE_CONS, + INFO_CTRL_MODE_TLV, + INFO_CTRL_MODE_SRT_CONS, + INFO_CTRL_MODE_END +} info_ctrl_mode_t; + +typedef enum info_frmt_e { + INFO_FRMT_NONE, + INFO_FRMT_BIT, + INFO_FRMT_BYTE, + INFO_FRMT_NUM_BYTES, + INFO_FRMT_NUM_STR, + INFO_FRMT_NUM_BUF, + INFO_FRMT_BUF, + INFO_FRMT_END +} info_frmt_t; + +typedef enum info_src_e { + INFO_SRC_NONE, + INFO_SRC_CPLD, + INFO_SRC_FPGA, + INFO_SRC_OTHER_I2C, + INFO_SRC_FILE, + INFO_SRC_END +} info_src_t; + +typedef enum info_pola_e { + INFO_POLA_NONE, + INFO_POLA_POSI, + INFO_POLA_NEGA, + INFO_POLA_END +} info_pola_t; + +#define INFO_FPATH_MAX_LEN (128) +#define INFO_STR_CONS_MAX_LEN (64) +typedef struct info_ctrl_s { + info_ctrl_mode_t mode; + int32_t int_cons; + info_src_t src; + info_frmt_t frmt; + info_pola_t pola; + char fpath[INFO_FPATH_MAX_LEN]; + int32_t addr; + int32_t len; + int32_t bit_offset; + char str_cons[INFO_STR_CONS_MAX_LEN]; + int32_t int_extra1; + int32_t int_extra2; +} info_ctrl_t; + +typedef enum info_ctrl_mem_s { + INFO_CTRL_MEM_MODE, + INFO_CTRL_MEM_INT_CONS, + INFO_CTRL_MEM_SRC, + INFO_CTRL_MEM_FRMT, + INFO_CTRL_MEM_POLA, + INFO_CTRL_MEM_FPATH, + INFO_CTRL_MEM_ADDR, + INFO_CTRL_MEM_LEN, + INFO_CTRL_MEM_BIT_OFFSET, + INFO_CTRL_MEM_STR_CONS, + INFO_CTRL_MEM_INT_EXTRA1, + INFO_CTRL_MEM_INT_EXTRA2, + INFO_CTRL_MEM_END +} info_ctrl_mem_t; + +typedef int (*info_hwmon_buf_f)(uint8_t *buf, int buf_len, uint8_t *buf_new, int *buf_len_new, + info_ctrl_t *info_ctrl, int coefficient, int addend); + +extern char *g_info_ctrl_mem_str[INFO_CTRL_MEM_END]; +extern char *g_info_src_str[INFO_SRC_END]; +extern char *g_info_frmt_str[INFO_FRMT_END]; +extern char *g_info_pola_str[INFO_POLA_END]; +extern char *g_info_ctrl_mode_str[INFO_CTRL_MODE_END]; + +int dfd_info_get_int(int key, int *ret, info_num_buf_to_value_f pfun); + +int dfd_info_get_buf(int key, uint8_t *buf, int buf_len, info_buf_to_buf_f pfun); + +int dfd_info_set_int(int key, int val); + +int dfd_info_get_sensor(uint32_t key, char *buf, int buf_len, info_hwmon_buf_f pfun); + +#endif /* __DFD_CFG_INFO_H__ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_cfg_listnode.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_cfg_listnode.h new file mode 100644 index 000000000000..955dfa96e42e --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_cfg_listnode.h @@ -0,0 +1,30 @@ +#ifndef __DFD_CFG_LISTNODE_H__ +#define __DFD_CFG_LISTNODE_H__ + +#include + +#define LNODE_RV_OK (0) +#define LNODE_RV_INPUT_ERR (-1) +#define LNODE_RV_NODE_EXIST (-2) +#define LNODE_RV_NOMEM (-3) + +typedef struct lnode_root_s { + struct list_head root; +} lnode_root_t; + +typedef struct lnode_node_s { + struct list_head lst; + + int key; + void *data; +} lnode_node_t; + +void *lnode_find_node(lnode_root_t *root, int key); + +int lnode_insert_node(lnode_root_t *root, int key, void *data); + +int lnode_init_root(lnode_root_t *root); + +void lnode_free_list(lnode_root_t *root); + +#endif /* __DFD_CFG_LISTNODE_H__ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_frueeprom.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_frueeprom.h new file mode 100644 index 000000000000..64aa88d4c8c7 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_frueeprom.h @@ -0,0 +1,69 @@ +#ifndef _DFD_FRUEEPROM_H_ +#define _DFD_FRUEEPROM_H_ + +/* Per IPMI v2.0 FRU specification */ +typedef struct fru_common_header_s +{ + uint8_t fixed; + uint8_t internal_offset; + uint8_t chassis_offset; + uint8_t board_offset; + uint8_t product_offset; + uint8_t multi_offset; + uint8_t pad; + uint8_t crc; +}__attribute__((packed)) fru_common_header_t; + +/* first byte in header is 1h per IPMI V2 spec. */ + +#define IPMI_FRU_HDR_BYTE_ZERO 1 +#define IPMI_EIGHT_BYTES 8 +#define IPMI_FRU_PRODUCT_AREA_MIN_LEN (7) +#define IPMI_FRU_BOARD_AREA_MIN_LEN (5) + +#define IPMI_FRU_AREA_TYPE_LENGTH_FIELD_MAX 512 +#define IPMI_FRU_BOARD_INFO_MFG_TIME_LENGTH 3 +#define IPMI_FRU_SENTINEL_VALUE 0xC1 +#define IPMI_FRU_TYPE_LENGTH_TYPE_CODE_MASK 0xC0 +#define IPMI_FRU_TYPE_LENGTH_TYPE_CODE_SHIFT 0x06 +#define IPMI_FRU_TYPE_LENGTH_NUMBER_OF_DATA_BYTES_MASK 0x3F +#define IPMI_FRU_TYPE_LENGTH_TYPE_CODE_LANGUAGE_CODE 0x03 + +struct ipmi_fru_field +{ + uint8_t type_length_field[IPMI_FRU_AREA_TYPE_LENGTH_FIELD_MAX]; + /* store length of data stored in buffer */ + unsigned int type_length_field_length; +}; + +typedef struct ipmi_fru_field ipmi_fru_field_t; + +typedef struct ipmi_product_info_s { + uint8_t *language_code; + ipmi_fru_field_t *product_manufacturer_name; + ipmi_fru_field_t *product_name; + ipmi_fru_field_t *product_part_model_number; + ipmi_fru_field_t *product_version; + ipmi_fru_field_t *product_serial_number; + ipmi_fru_field_t *product_asset_tag; + ipmi_fru_field_t *product_fru_file_id; + ipmi_fru_field_t *product_custom_fields; + ipmi_fru_field_t *product_type_fields; +}ipmi_product_info_t; + +typedef struct ipmi_board_info_s { + uint8_t *language_code; + uint8_t *mfg_time; + ipmi_fru_field_t *board_manufacturer; + ipmi_fru_field_t *board_product_name; + ipmi_fru_field_t *board_serial_number; + ipmi_fru_field_t *board_part_number; + ipmi_fru_field_t *board_fru_file_id; + ipmi_fru_field_t *board_custom_fields; /*hw version */ +}ipmi_board_info_t; + +int dfd_get_fru_data(int bus, int dev_addr, int type, uint8_t *buf, uint32_t buf_len, const char *sysfs_name); + +int dfd_get_fru_board_data(int bus, int dev_addr, int type, uint8_t *buf, uint32_t buf_len, const char *sysfs_name); + +#endif /* endif _DFD_FRUEEPROM_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_sysfs_common.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_sysfs_common.h new file mode 100644 index 000000000000..ee2802209d8b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_sysfs_common.h @@ -0,0 +1,192 @@ +#ifndef _DFD_SYSFS_COMMON_H_ +#define _DFD_SYSFS_COMMON_H_ + +struct switch_drivers_s { + /* temperature sensors */ + int (*get_main_board_temp_number)(void); + ssize_t (*get_main_board_temp_alias)(unsigned int temp_index, char *buf, size_t count); + ssize_t (*get_main_board_temp_type)(unsigned int temp_index, char *buf, size_t count); + ssize_t (*get_main_board_temp_max)(unsigned int temp_index, char *buf, size_t count); + int (*set_main_board_temp_max)(unsigned int temp_index, const char *buf, size_t count); + ssize_t (*get_main_board_temp_min)(unsigned int temp_index, char *buf, size_t count); + int (*set_main_board_temp_min)(unsigned int temp_index, const char *buf, size_t count); + ssize_t (*get_main_board_temp_value)(unsigned int temp_index, char *buf, size_t count); + /* voltage sensors */ + int (*get_main_board_vol_number)(void); + ssize_t (*get_main_board_vol_alias)(unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_main_board_vol_type)(unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_main_board_vol_max)(unsigned int vol_index, char *buf, size_t count); + int (*set_main_board_vol_max)(unsigned int vol_index, const char *buf, size_t count); + ssize_t (*get_main_board_vol_min)(unsigned int vol_index, char *buf, size_t count); + int (*set_main_board_vol_min)(unsigned int vol_index, const char *buf, size_t count); + ssize_t (*get_main_board_vol_range)(unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_main_board_vol_nominal_value)(unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_main_board_vol_value)(unsigned int vol_index, char *buf, size_t count); + /* current sensors */ + int (*get_main_board_curr_number)(void); + ssize_t (*get_main_board_curr_alias)(unsigned int curr_index, char *buf, size_t count); + ssize_t (*get_main_board_curr_type)(unsigned int curr_index, char *buf, size_t count); + ssize_t (*get_main_board_curr_max)(unsigned int curr_index, char *buf, size_t count); + int (*set_main_board_curr_max)(unsigned int curr_index, const char *buf, size_t count); + ssize_t (*get_main_board_curr_min)(unsigned int curr_index, char *buf, size_t count); + int (*set_main_board_curr_min)(unsigned int curr_index, const char *buf, size_t count); + ssize_t (*get_main_board_curr_value)(unsigned int curr_index, char *buf, size_t count); + /* syseeprom */ + int (*get_syseeprom_size)(void); + ssize_t (*read_syseeprom_data)(char *buf, loff_t offset, size_t count); + ssize_t (*write_syseeprom_data)(char *buf, loff_t offset, size_t count); + /* fan */ + int (*get_fan_number)(void); + int (*get_fan_motor_number)(unsigned int fan_index); + ssize_t (*get_fan_model_name)(unsigned int fan_index, char *buf, size_t count); + ssize_t (*get_fan_serial_number)(unsigned int fan_index, char *buf, size_t count); + ssize_t (*get_fan_part_number)(unsigned int fan_index, char *buf, size_t count); + ssize_t (*get_fan_hardware_version)(unsigned int fan_index, char *buf, size_t count); + ssize_t (*get_fan_status)(unsigned int fan_index, char *buf, size_t count); + ssize_t (*get_fan_led_status)(unsigned int fan_index, char *buf, size_t count); + int (*set_fan_led_status)(unsigned int fan_index, int status); + ssize_t (*get_fan_direction)(unsigned int fan_index, char *buf, size_t count); + ssize_t (*get_fan_motor_speed)(unsigned int fan_index, unsigned int motor_index, char *buf, size_t count); + ssize_t (*get_fan_motor_speed_tolerance)(unsigned int fan_index, unsigned int motor_index, char *buf, size_t count); + ssize_t (*get_fan_motor_speed_target)(unsigned int fan_index, unsigned int motor_index, char *buf, size_t count); + ssize_t (*get_fan_motor_speed_max)(unsigned int fan_index, unsigned int motor_index, char *buf, size_t count); + ssize_t (*get_fan_motor_speed_min)(unsigned int fan_index, unsigned int motor_index, char *buf, size_t count); + ssize_t (*get_fan_ratio)(unsigned int fan_index, char *buf, size_t count); + int (*set_fan_ratio)(unsigned int fan_index, int ratio); + /* PSU */ + int (*get_psu_number)(void); + int (*get_psu_temp_number)(unsigned int psu_index); + ssize_t (*get_psu_model_name)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_serial_number)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_part_number)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_hardware_version)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_type)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_in_curr)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_in_vol)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_in_power)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_out_curr)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_out_vol)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_out_power)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_out_max_power)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_present_status)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_in_status)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_out_status)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_fan_speed)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_fan_ratio)(unsigned int psu_index, char *buf, size_t count); + int (*set_psu_fan_ratio)(unsigned int psu_index, int ratio); + ssize_t (*get_psu_fan_direction)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_led_status)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_temp_alias)(unsigned int psu_index, unsigned int temp_index, char *buf, size_t count); + ssize_t (*get_psu_temp_type)(unsigned int psu_index, unsigned int temp_index, char *buf, size_t count); + ssize_t (*get_psu_temp_max)(unsigned int psu_index, unsigned int temp_index, char *buf, size_t count); + int (*set_psu_temp_max)(unsigned int psu_index, unsigned int temp_index, const char *buf, size_t count); + ssize_t (*get_psu_temp_min)(unsigned int psu_index, unsigned int temp_index, char *buf, size_t count); + int (*set_psu_temp_min)(unsigned int psu_index, unsigned int temp_index, const char *buf, size_t count); + ssize_t (*get_psu_temp_value)(unsigned int psu_index, unsigned int temp_index, char *buf, size_t count); + /* transceiver */ + int (*get_eth_number)(void); + ssize_t (*get_transceiver_power_on_status)(char *buf, size_t count); + int (*set_transceiver_power_on_status)(int status); + ssize_t (*get_eth_power_on_status)(unsigned int eth_index, char *buf, size_t count); + int (*set_eth_power_on_status)(unsigned int eth_index, int status); + ssize_t (*get_eth_tx_fault_status)(unsigned int eth_index, char *buf, size_t count); + ssize_t (*get_eth_tx_disable_status)(unsigned int eth_index, char *buf, size_t count); + int (*set_eth_tx_disable_status)(unsigned int eth_index, int status); + ssize_t (*get_eth_present_status)(unsigned int eth_index, char *buf, size_t count); + ssize_t (*get_eth_rx_los_status)(unsigned int eth_index, char *buf, size_t count); + ssize_t (*get_eth_reset_status)(unsigned int eth_index, char *buf, size_t count); + int (*set_eth_reset_status)(unsigned int eth_index, int status); + ssize_t (*get_eth_low_power_mode_status)(unsigned int eth_index, char *buf, size_t count); + ssize_t (*get_eth_interrupt_status)(unsigned int eth_index, char *buf, size_t count); + int (*get_eth_eeprom_size)(unsigned int eth_index); + ssize_t (*read_eth_eeprom_data)(unsigned int eth_index, char *buf, loff_t offset, size_t count); + ssize_t (*write_eth_eeprom_data)(unsigned int eth_index, char *buf, loff_t offset, size_t count); + /* sysled */ + ssize_t (*get_sys_led_status)(char *buf, size_t count); + int (*set_sys_led_status)(int status); + ssize_t (*get_bmc_led_status)(char *buf, size_t count); + int (*set_bmc_led_status)(int status); + ssize_t (*get_sys_fan_led_status)(char *buf, size_t count); + int (*set_sys_fan_led_status)(int status); + ssize_t (*get_sys_psu_led_status)(char *buf, size_t count); + int (*set_sys_psu_led_status)(int status); + ssize_t (*get_id_led_status)(char *buf, size_t count); + int (*set_id_led_status)(int status); + /* FPGA */ + int (*get_main_board_fpga_number)(void); + ssize_t (*get_main_board_fpga_alias)(unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_main_board_fpga_type)(unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_main_board_fpga_firmware_version)(unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_main_board_fpga_board_version)(unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_main_board_fpga_test_reg)(unsigned int fpga_index, char *buf, size_t count); + int (*set_main_board_fpga_test_reg)(unsigned int fpga_index, unsigned int value); + /* CPLD */ + int (*get_main_board_cpld_number)(void); + ssize_t (*get_main_board_cpld_alias)(unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_main_board_cpld_type)(unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_main_board_cpld_firmware_version)(unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_main_board_cpld_board_version)(unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_main_board_cpld_test_reg)(unsigned int cpld_index, char *buf, size_t count); + int (*set_main_board_cpld_test_reg)(unsigned int cpld_index, unsigned int value); + /* watchdog */ + ssize_t (*get_watchdog_identify)(char *buf, size_t count); + ssize_t (*get_watchdog_timeleft)(char *buf, size_t count); + ssize_t (*get_watchdog_timeout)(char *buf, size_t count); + int (*set_watchdog_timeout)(int value); + ssize_t (*get_watchdog_enable_status)(char *buf, size_t count); + int (*set_watchdog_enable_status)(int value); + int (*set_watchdog_reset)(int value); + /* slot */ + int (*get_slot_number)(void); + int (*get_slot_temp_number)(unsigned int slot_index); + int (*get_slot_vol_number)(unsigned int slot_index); + int (*get_slot_curr_number)(unsigned int slot_index); + int (*get_slot_cpld_number)(unsigned int slot_index); + int (*get_slot_fpga_number)(unsigned int slot_index); + ssize_t (*get_slot_model_name)(unsigned int slot_index, char *buf, size_t count); + ssize_t (*get_slot_serial_number)(unsigned int slot_index, char *buf, size_t count); + ssize_t (*get_slot_part_number)(unsigned int slot_index, char *buf, size_t count); + ssize_t (*get_slot_hardware_version)(unsigned int slot_index, char *buf, size_t count); + ssize_t (*get_slot_status)(unsigned int slot_index, char *buf, size_t count); + ssize_t (*get_slot_led_status)(unsigned int slot_index, char *buf, size_t count); + int (*set_slot_led_status)(unsigned int slot_index, int status); + ssize_t (*get_slot_temp_alias)(unsigned int slot_index, unsigned int temp_index, char *buf, size_t count); + ssize_t (*get_slot_temp_type)(unsigned int slot_index, unsigned int temp_index, char *buf, size_t count); + ssize_t (*get_slot_temp_max)(unsigned int slot_index, unsigned int temp_index, char *buf, size_t count); + int (*set_slot_temp_max)(unsigned int slot_index, unsigned int temp_index, const char *buf, size_t count); + ssize_t (*get_slot_temp_min)(unsigned int slot_index, unsigned int temp_index, char *buf, size_t count); + int (*set_slot_temp_min)(unsigned int slot_index, unsigned int temp_index, const char *buf, size_t count); + ssize_t (*get_slot_temp_value)(unsigned int slot_index, unsigned int temp_index, char *buf, size_t count); + ssize_t (*get_slot_vol_alias)(unsigned int slot_index, unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_slot_vol_type)(unsigned int slot_index, unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_slot_vol_max)(unsigned int slot_index, unsigned int vol_index, char *buf, size_t count); + int (*set_slot_vol_max)(unsigned int slot_index, unsigned int vol_index, const char *buf, size_t count); + ssize_t (*get_slot_vol_min)(unsigned int slot_index, unsigned int vol_index, char *buf, size_t count); + int (*set_slot_vol_min)(unsigned int slot_index, unsigned int vol_index, const char *buf, size_t count); + ssize_t (*get_slot_vol_range)(unsigned int slot_index, unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_slot_vol_nominal_value)(unsigned int slot_index, unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_slot_vol_value)(unsigned int slot_index, unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_slot_curr_alias)(unsigned int slot_index, unsigned int curr_index, char *buf, size_t count); + ssize_t (*get_slot_curr_type)(unsigned int slot_index, unsigned int curr_index, char *buf, size_t count); + ssize_t (*get_slot_curr_max)(unsigned int slot_index, unsigned int curr_index, char *buf, size_t count); + int (*set_slot_curr_max)(unsigned int slot_index, unsigned int curr_index, const char *buf, size_t count); + ssize_t (*get_slot_curr_min)(unsigned int slot_index, unsigned int curr_index, char *buf, size_t count); + int (*set_slot_curr_min)(unsigned int slot_index, unsigned int curr_index, const char *buf, size_t count); + ssize_t (*get_slot_curr_value)(unsigned int slot_index, unsigned int curr_index, char *buf, size_t count); + ssize_t (*get_slot_fpga_alias)(unsigned int slot_index, unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_slot_fpga_type)(unsigned int slot_index, unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_slot_fpga_firmware_version)(unsigned int slot_index, unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_slot_fpga_board_version)(unsigned int slot_index, unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_slot_fpga_test_reg)(unsigned int slot_index, unsigned int fpga_index, char *buf, size_t count); + int (*set_slot_fpga_test_reg)(unsigned int slot_index, unsigned int fpga_index, unsigned int value); + ssize_t (*get_slot_cpld_alias)(unsigned int slot_index, unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_slot_cpld_type)(unsigned int slot_index, unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_slot_cpld_firmware_version)(unsigned int slot_index, unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_slot_cpld_board_version)(unsigned int slot_index, unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_slot_cpld_test_reg)(unsigned int slot_index, unsigned int cpld_index, char *buf, size_t count); + int (*set_slot_cpld_test_reg)(unsigned int slot_index, unsigned int cpld_index, unsigned int value); +}; + +extern struct switch_drivers_s * switch_driver_get(void); + +#endif /*_DFD_SYSFS_COMMON_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_tlveeprom.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_tlveeprom.h new file mode 100644 index 000000000000..4f894ec352d3 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_tlveeprom.h @@ -0,0 +1,70 @@ +#ifndef _DFD_TLVEEPROM_H_ +#define _DFD_TLVEEPROM_H_ + +#ifndef be16_to_cpu +#define be16_to_cpu(x) ntohs(x) +#endif + +#ifndef cpu_to_be16 +#define cpu_to_be16(x) htons(x) +#endif + +#define TLV_CODE_NAME_LEN 64 + +/* + * Struct for displaying the TLV codes and names. + */ +struct tlv_code_desc { + uint8_t m_code; + char m_name[TLV_CODE_NAME_LEN]; +}; + +typedef struct dfd_tlv_type_s { + uint8_t main_type; + uint8_t ext_type; +} dfd_tlv_type_t; + +/* Header Field Constants */ +#define TLV_INFO_ID_STRING "TlvInfo" +#define TLV_INFO_VERSION 0x01 + +struct __attribute__ ((__packed__)) tlvinfo_header_s { + char signature[8]; /* 0x00 - 0x07 EEPROM Tag "TlvInfo" */ + uint8_t version; /* 0x08 Structure version */ + uint16_t totallen; /* 0x09 - 0x0A Length of all data which follows */ +}; +typedef struct tlvinfo_header_s tlvinfo_header_t; + +/* + * TlvInfo TLV: Layout of a TLV field + */ +struct __attribute__ ((__packed__)) tlvinfo_tlv_s { + uint8_t type; + uint8_t length; + uint8_t value[0]; +}; +typedef struct tlvinfo_tlv_s tlvinfo_tlv_t; + +#define TLV_VALUE_MAX_LEN 255 +/* + * The max decode value is currently for the 'raw' type or the 'vendor + * extension' type, both of which have the same decode format. The + * max decode string size is computed as follows: + * + * strlen(" 0xFF") * TLV_VALUE_MAX_LEN + 1 + * + */ +#define TLV_DECODE_VALUE_MAX_LEN ((5 * TLV_VALUE_MAX_LEN) + 1) + +typedef struct tlv_decode_value_s { + uint8_t value[TLV_DECODE_VALUE_MAX_LEN]; + uint32_t length; +} tlv_decode_value_t; + +typedef enum dfd_tlvinfo_ext_tlv_type_e { + DFD_TLVINFO_EXT_TLV_TYPE_DEV_TYPE = 1, +} dfd_tlvinfo_ext_tlv_type_t; + +int dfd_tlvinfo_get_e2prom_info(uint8_t *eeprom, uint32_t size, dfd_tlv_type_t *tlv_type, uint8_t* buf, uint32_t *buf_len); + +#endif /* endif _DFD_TLVEEPROM_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_cpld_driver.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_cpld_driver.h new file mode 100644 index 000000000000..fbf5b077ce82 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_cpld_driver.h @@ -0,0 +1,19 @@ +#ifndef _RG_CPLD_DRIVER_H_ +#define _RG_CPLD_DRIVER_H_ + +ssize_t dfd_get_cpld_name(uint8_t main_dev_id, unsigned int cpld_index, char *buf, size_t count); + +ssize_t dfd_get_cpld_type(uint8_t main_dev_id, unsigned int cpld_index, char *buf, size_t count); + +ssize_t dfd_get_cpld_fw_version(uint8_t main_dev_id, unsigned int cpld_index, char *buf, size_t count); + +ssize_t dfd_get_cpld_hw_version(uint8_t main_dev_id, unsigned int cpld_index, char *buf, size_t count); + +int dfd_set_cpld_testreg(uint8_t main_dev_id, unsigned int cpld_index, int value); + +int dfd_get_cpld_testreg(uint8_t main_dev_id, unsigned int cpld_index, int *value); + +ssize_t dfd_get_cpld_testreg_str(uint8_t main_dev_id, unsigned int cpld_index, + char *buf, size_t count); + +#endif /* _RG_CPLD_DRIVER_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_eeprom_driver.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_eeprom_driver.h new file mode 100644 index 000000000000..8fc74e1e1ef7 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_eeprom_driver.h @@ -0,0 +1,9 @@ +#ifndef _RG_EEPROM_DRIVER_H_ +#define _RG_EEPROM_DRIVER_H_ + +int dfd_get_eeprom_size(int e2_type, int index); + +ssize_t dfd_read_eeprom_data(int e2_type, int index, char *buf, loff_t offset, size_t count); + +ssize_t dfd_write_eeprom_data(int e2_type, int index, char *buf, loff_t offset, size_t count); +#endif /* _RG_EEPROM_DRIVER_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_fan_driver.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_fan_driver.h new file mode 100644 index 000000000000..96d57e309232 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_fan_driver.h @@ -0,0 +1,35 @@ +#ifndef _RG_FAN_DRIVER_H_ +#define _RG_FAN_DRIVER_H_ + +ssize_t dfd_get_fan_status_str(unsigned int fan_index, char *buf, size_t count); + +ssize_t dfd_get_fan_info(unsigned int fan_index, uint8_t cmd, char *buf, size_t count); + +int dfd_get_fan_speed(unsigned int fan_index, unsigned int motor_index,unsigned int *speed); + +ssize_t dfd_get_fan_speed_str(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count); + +int dfd_set_fan_pwm(unsigned int fan_index, int pwm); + +int dfd_get_fan_pwm(unsigned int fan_index, int *pwm); + +ssize_t dfd_get_fan_pwm_str(unsigned int fan_index, char *buf, size_t count); + +ssize_t dfd_get_fan_motor_speed_tolerance_str(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count); + +int dfd_get_fan_speed_target(unsigned int fan_index, unsigned int motor_index, int *value); + +ssize_t dfd_get_fan_motor_speed_target_str(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count); + +ssize_t dfd_get_fan_direction_str(unsigned int fan_index, char *buf, size_t count); + +ssize_t dfd_get_fan_motor_speed_max_str(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count); + +ssize_t dfd_get_fan_motor_speed_min_str(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count); + +#endif /* _RG_FAN_DRIVER_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_fpga_driver.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_fpga_driver.h new file mode 100644 index 000000000000..a850d9343ef7 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_fpga_driver.h @@ -0,0 +1,19 @@ +#ifndef _RG_FPGA_DRIVER_H_ +#define _RG_FPGA_DRIVER_H_ + +ssize_t dfd_get_fpga_name(uint8_t main_dev_id, unsigned int fpga_index, char *buf, size_t count); + +ssize_t dfd_get_fpga_type(uint8_t main_dev_id, unsigned int fpga_index, char *buf, size_t count); + +ssize_t dfd_get_fpga_fw_version(uint8_t main_dev_id, unsigned int fpga_index, char *buf, size_t count); + +ssize_t dfd_get_fpga_hw_version(uint8_t main_dev_id, unsigned int fpga_index, char *buf, size_t count); + +int dfd_set_fpga_testreg(uint8_t main_dev_id, unsigned int fpga_index, int value); + +int dfd_get_fpga_testreg(uint8_t main_dev_id, unsigned int fpga_index, int *value); + +ssize_t dfd_get_fpga_testreg_str(uint8_t main_dev_id, unsigned int fpga_index, + char *buf, size_t count); + +#endif /* _RG_FPGA_DRIVER_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_led_driver.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_led_driver.h new file mode 100644 index 000000000000..8798ed2eacdb --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_led_driver.h @@ -0,0 +1,8 @@ +#ifndef _RG_LED_DRIVER_H_ +#define _RG_LED_DRIVER_H_ + +ssize_t dfd_get_led_status(uint16_t led_id, uint8_t led_index, char *buf, size_t count); + +ssize_t dfd_set_led_status(uint16_t led_id, uint8_t led_index, int value); + +#endif /* _RG_LED_DRIVER_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_module.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_module.h new file mode 100644 index 000000000000..22107a470afe --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_module.h @@ -0,0 +1,267 @@ +#ifndef _RG_MODULE_H_ +#define _RG_MODULE_H_ + +#include "switch_driver.h" + +typedef enum dfd_rv_s { + DFD_RV_OK = 0, + DFD_RV_INIT_ERR = 1, + DFD_RV_SLOT_INVALID = 2, + DFD_RV_MODE_INVALID = 3, + DFD_RV_MODE_NOTSUPPORT = 4, + DFD_RV_TYPE_ERR = 5, + DFD_RV_DEV_NOTSUPPORT = 6, + DFD_RV_DEV_FAIL = 7, + DFD_RV_INDEX_INVALID = 8, + DFD_RV_NO_INTF = 9, + DFD_RV_NO_NODE = 10, + DFD_RV_NODE_FAIL = 11, + DFD_RV_INVALID_VALUE = 12, + DFD_RV_NO_MEMORY = 13, +} dfd_rv_t; + +typedef enum status_mem_e { + STATUS_ABSENT = 0, + STATUS_OK = 1, + STATUS_NOT_OK = 2, + STATUS_MEM_END = 3, +} status_mem_t; + +/* psu PMBUS */ +typedef enum psu_sensors_type_e { + PSU_SENSOR_NONE = 0, + PSU_IN_VOL = 1, + PSU_IN_CURR = 2, + PSU_IN_POWER = 3, + PSU_OUT_VOL = 4, + PSU_OUT_CURR = 5, + PSU_OUT_POWER = 6, + PSU_FAN_SPEED = 7, + PSU_OUT_MAX_POWERE = 8, + PSU_OUT_STATUS = 9, + PSU_IN_STATUS = 10, + PSU_IN_TYPE = 11, +} psu_sensors_type_t; + +typedef enum rg_wdt_type_e { + RG_WDT_TYPE_NAME = 0, /* watchdog identify */ + RG_WDT_TYPE_STATE = 1, /* watchdog state */ + RG_WDT_TYPE_TIMELEFT = 2, /* watchdog timeleft */ + RG_WDT_TYPE_TIMEOUT = 3, /* watchdog timeout */ + RG_WDT_TYPE_ENABLE = 4, /* watchdog enable */ +} rg_wdt_type_t; + +typedef enum dfd_dev_info_type_e { + DFD_DEV_INFO_TYPE_MAC = 1, + DFD_DEV_INFO_TYPE_NAME = 2, + DFD_DEV_INFO_TYPE_SN = 3, + DFD_DEV_INFO_TYPE_PWR_CONS = 4, + DFD_DEV_INFO_TYPE_HW_INFO = 5, + DFD_DEV_INFO_TYPE_DEV_TYPE = 6, + DFD_DEV_INFO_TYPE_PART_NAME = 7, + DFD_DEV_INFO_TYPE_PART_NUMBER = 8, /* part number */ + DFD_DEV_INFO_TYPE_FAN_DIRECTION = 9, + DFD_DEV_INFO_TYPE_MAX_OUTPUT_POWRER = 10, /* max_output_power */ +} dfd_dev_tlv_type_t; + +typedef enum rg_main_dev_type_e { + RG_MAIN_DEV_MAINBOARD = 0, + RG_MAIN_DEV_FAN = 1, + RG_MAIN_DEV_PSU = 2, + RG_MAIN_DEV_SFF = 3, + RG_MAIN_DEV_CPLD = 4, /* CPLD */ + RG_MAIN_DEV_SLOT = 5, +} rg_main_dev_type_t; + +typedef enum rg_minor_dev_type_e { + RG_MINOR_DEV_NONE = 0, /* None */ + RG_MINOR_DEV_TEMP = 1, + RG_MINOR_DEV_IN = 2, + RG_MINOR_DEV_CURR = 3, + RG_MINOR_DEV_POWER = 4, + RG_MINOR_DEV_MOTOR = 5, + RG_MINOR_DEV_PSU = 6, + RG_MINOR_DEV_FAN = 7, + RG_MINOR_DEV_CPLD = 8, /* CPLD */ + RG_MINOR_DEV_FPGA = 9, /* FPGA */ +} rg_minor_dev_type_t; + +typedef enum rg_sensor_type_e { + RG_SENSOR_INPUT = 0, + RG_SENSOR_ALIAS = 1, + RG_SENSOR_TYPE = 2, + RG_SENSOR_MAX = 3, + RG_SENSOR_MAX_HYST = 4, + RG_SENSOR_MIN = 5, + RG_SENSOR_CRIT = 6, + RG_SENSOR_RANGE = 7, + RG_SENSOR_NOMINAL_VAL = 8, +} rg_sensor_type_t; + +typedef enum rg_sff_cpld_attr_e { + RG_SFF_POWER_ON = 0x01, + RG_SFF_TX_FAULT, + RG_SFF_TX_DIS, + RG_SFF_PRESENT_RESERVED, + RG_SFF_RX_LOS, + RG_SFF_RESET, + RG_SFF_LPMODE, + RG_SFF_MODULE_PRESENT, + RG_SFF_INTERRUPT, +} rg_sff_cpld_attr_t; + +typedef enum rg_led_e { + RG_SYS_LED_FRONT = 0, + RG_SYS_LED_REAR = 1, + RG_BMC_LED_FRONT = 2, + RG_BMC_LED_REAR = 3, + RG_FAN_LED_FRONT = 4, + RG_FAN_LED_REAR = 5, + RG_PSU_LED_FRONT = 6, + RG_PSU_LED_REAR = 7, + RG_ID_LED_FRONT = 8, + RG_ID_LED_REAR = 9, + RG_FAN_LED_MODULE = 10, + RG_PSU_LED_MODULE = 11, + RG_SLOT_LED_MODULE = 12, +} rg_led_t; + +extern int g_dfd_dbg_level; +extern int g_dfd_fan_dbg_level; +extern int g_dfd_fru_dbg_level; +extern int g_dfd_eeprom_dbg_level; +extern int g_dfd_cpld_dbg_level; +extern int g_dfd_fpga_dbg_level; +extern int g_dfd_sysled_dbg_level; +extern int g_dfd_slot_dbg_level; +extern int g_dfd_sensor_dbg_level; +extern int g_dfd_psu_dbg_level; +extern int g_dfd_sff_dbg_level; +extern int g_dfd_watchdog_dbg_level; + +#define DBG_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DFD_FAN_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_fan_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DBG_FRU_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_fru_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DBG_EEPROM_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_eeprom_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DBG_CPLD_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_cpld_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DBG_FPGA_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_fpga_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DBG_SYSLED_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_sysled_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DFD_SLOT_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_slot_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DFD_SENSOR_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_sensor_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DFD_PSU_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_psu_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DFD_SFF_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_sff_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DFD_WDT_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_watchdog_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +int32_t rg_dev_cfg_init(void); + +void rg_dev_cfg_exit(void); + +int dfd_get_dev_number(unsigned int main_dev_id, unsigned int minor_dev_id); +#endif /* _RG_MODULE_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_psu_driver.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_psu_driver.h new file mode 100644 index 000000000000..13934e9c0221 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_psu_driver.h @@ -0,0 +1,14 @@ +#ifndef _RG_PSU_DRIVER_H_ +#define _RG_PSU_DRIVER_H_ + +ssize_t dfd_get_psu_info(unsigned int psu_index, uint8_t cmd, char *buf, size_t count); + +ssize_t dfd_get_psu_present_status_str(unsigned int psu_index, char *buf, size_t count); + +ssize_t dfd_get_psu_out_status_str(unsigned int psu_index, char *buf, size_t count); + +ssize_t dfd_get_psu_in_status_str(unsigned int psu_index, char *buf, size_t count); + +ssize_t dfd_get_psu_input_type(unsigned int psu_index, char *buf, size_t count); + +#endif /* _RG_PSU_DRIVER_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_sensors_driver.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_sensors_driver.h new file mode 100644 index 000000000000..464e3bca0ed7 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_sensors_driver.h @@ -0,0 +1,15 @@ +#ifndef _RG_SENSORS_DRIVER_H_ +#define _RG_SENSORS_DRIVER_H_ + +ssize_t dfd_get_temp_info(uint8_t main_dev_id, uint8_t dev_index, uint8_t temp_index, + uint8_t temp_attr, char *buf, size_t count); + +ssize_t dfd_get_voltage_info(uint8_t main_dev_id, uint8_t dev_index, uint8_t in_index, + uint8_t in_attr, char *buf, size_t count); + +ssize_t dfd_get_current_info(uint8_t main_dev_id, uint8_t dev_index, uint8_t curr_index, + uint8_t curr_attr, char *buf, size_t count); + +ssize_t dfd_get_psu_sensor_info(uint8_t psu_index, uint8_t sensor_type, char *buf, size_t count); + +#endif /* _RG_SENSORS_DRIVER_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_sff_driver.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_sff_driver.h new file mode 100644 index 000000000000..d1c8e4e68f62 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_sff_driver.h @@ -0,0 +1,8 @@ +#ifndef _RG_SFF_DRIVER_H_ +#define _RG_SFF_DRIVER_H_ + +int dfd_set_sff_cpld_info(unsigned int sff_index, int cpld_reg_type, int value); + +ssize_t dfd_get_sff_cpld_info(unsigned int sff_index, int cpld_reg_type, char *buf, size_t count); + +#endif /* _RG_SFF_DRIVER_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_slot_driver.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_slot_driver.h new file mode 100644 index 000000000000..8ce45618beea --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_slot_driver.h @@ -0,0 +1,8 @@ +#ifndef _RG_SLOT_DRIVER_H_ +#define _RG_SLOT_DRIVER_H_ + +ssize_t dfd_get_slot_status_str(unsigned int slot_index, char *buf, size_t count); + +ssize_t dfd_get_slot_info(unsigned int slot_index, uint8_t cmd, char *buf, size_t count); + +#endif /* _RG_SLOT_DRIVER_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_watchdog_driver.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_watchdog_driver.h new file mode 100644 index 000000000000..3da88d2662f0 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_watchdog_driver.h @@ -0,0 +1,8 @@ +#ifndef _RG_WATCHDOG_DRIVER_H_ +#define _RG_WATCHDOG_DRIVER_H_ + +ssize_t dfd_get_watchdog_info(uint8_t type, char *buf, size_t count); + +ssize_t dfd_watchdog_get_status_str(char *buf, size_t count); + +#endif /* _RG_WATCHDOG_DRIVER_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/switch_driver.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/switch_driver.h new file mode 100644 index 000000000000..d7d9788ace75 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/switch_driver.h @@ -0,0 +1,61 @@ +#ifndef _SWITCH_DRIVER_H_ +#define _SWITCH_DRIVER_H_ + +#define SWITCH_DEV_NO_SUPPORT "NA" + +typedef enum dbg_level_e { + DBG_VERBOSE = 0x01, + DBG_WARN = 0x02, + DBG_ERROR = 0x04, +} dbg_level_t; + +typedef enum fan_status_e { + FAN_STATUS_ABSENT = 0, + FAN_STATUS_OK = 1, + FAN_STATUS_NOT_OK = 2, +} fan_status_t; + +typedef enum led_status_e { + LED_STATUS_DARK = 0, + LED_STATUS_GREEN = 1, + LED_STATUS_YELLOW = 2, + LED_STATUS_RED = 3, + LED_STATUS_BLUE = 4, + LED_STATUS_GREEN_FLASH = 5, + LED_STATUS_YELLOW_FLASH = 6, + LED_STATUS_RED_FLASH = 7, +} led_status_t; + +typedef enum air_flow_direction_e { + F2B = 0, /* air enters from the front of the cabinet, and exhausts from the back */ + B2F = 1, /* air enters from the back of the cabinet, and exhausts from the front */ +} air_flow_direction_t; + +typedef enum psu_input_type_e { + POWER_DC = 0, + POWER_AC = 1, +} psu_input_type_t; + +typedef enum psu_status_e { + PSU_STATUS_ABSENT = 0, + PSU_STATUS_PRESENT = 1, +} psu_status_t; + +typedef enum psu_io_status_e { + PSU_IO_STATUS_ABNORMAL = 0, + PSU_IO_STATUS_NORMAL = 1, +} psu_io_status_t; + +extern int g_switch_dbg_level; + +#define SWITCH_DEBUG(level, fmt, arg...) do { \ + if (g_switch_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#endif /* _SWITCH_DRIVER_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_cpld_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_cpld_driver.c new file mode 100644 index 000000000000..7a9cc184082a --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_cpld_driver.c @@ -0,0 +1,196 @@ +/* + * Copyright(C) 2001-2022 Ruijie Network. All rights reserved. + */ +/* + * rg_cpld_driver.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * History + * [Version] [Author] [Date] [Description] + * * v1.0 sonic_rd@ruijie.com.cn 2020-02-17 Initial version + */ + +#include + +#include "rg_module.h" +#include "dfd_cfg.h" +#include "dfd_cfg_adapter.h" +#include "dfd_cfg_info.h" + +int g_dfd_cpld_dbg_level = 0; +module_param(g_dfd_cpld_dbg_level, int, S_IRUGO | S_IWUSR); + +ssize_t dfd_get_cpld_name(uint8_t main_dev_id, unsigned int cpld_index, char *buf, size_t count) +{ + int key; + char *cpld_name; + + if (buf == NULL) { + DBG_CPLD_DEBUG(DBG_ERROR, "param error, buf is NULL. main_dev_id: %u, cpld index: %u\n", + main_dev_id, cpld_index); + return -DFD_RV_INVALID_VALUE; + } + + if (count <= 0) { + DBG_CPLD_DEBUG(DBG_ERROR, "buf size error, count: %lu, main_dev_id: %u, cpld index: %u\n", + count, main_dev_id, cpld_index); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, count); + key = DFD_CFG_KEY(DFD_CFG_ITEM_CPLD_NAME, main_dev_id, cpld_index); + cpld_name = dfd_ko_cfg_get_item(key); + if (cpld_name == NULL) { + DBG_CPLD_DEBUG(DBG_ERROR, "main_dev_id: %u, cpld%u name config error, key: 0x%08x\n", + main_dev_id, cpld_index, key); + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + + DBG_CPLD_DEBUG(DBG_VERBOSE, "%s\n", cpld_name); + snprintf(buf, count, "%s\n", cpld_name); + return strlen(buf); +} + +ssize_t dfd_get_cpld_type(uint8_t main_dev_id, unsigned int cpld_index, char *buf, size_t count) +{ + int key; + char *cpld_type; + + if (buf == NULL) { + DBG_CPLD_DEBUG(DBG_ERROR, "param error, buf is NULL, main_dev_id: %u, cpld index: %u\n", + main_dev_id, cpld_index); + return -DFD_RV_INVALID_VALUE; + } + + if (count <= 0) { + DBG_CPLD_DEBUG(DBG_ERROR, "buf size error, count: %lu, main_dev_id: %u, cpld index: %u\n", + count, main_dev_id, cpld_index); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, count); + key = DFD_CFG_KEY(DFD_CFG_ITEM_CPLD_TYPE, main_dev_id, cpld_index); + cpld_type = dfd_ko_cfg_get_item(key); + if (cpld_type == NULL) { + DBG_CPLD_DEBUG(DBG_ERROR, "main_dev_id: %u, cpld%u type config error, key: 0x%08x\n", + main_dev_id, cpld_index, key); + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + + DBG_CPLD_DEBUG(DBG_VERBOSE, "%s\n", cpld_type); + snprintf(buf, count, "%s\n", cpld_type); + return strlen(buf); +} + +ssize_t dfd_get_cpld_fw_version(uint8_t main_dev_id, unsigned int cpld_index, char *buf, size_t count) +{ + int key, rv; + uint32_t value; + + if (buf == NULL) { + DBG_CPLD_DEBUG(DBG_ERROR, "param error, buf is NULL, main_dev_id: %u, cpld index: %u\n", + main_dev_id, cpld_index); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DBG_CPLD_DEBUG(DBG_ERROR, "buf size error, count: %lu, main_dev_id: %u, cpld index: %u\n", + count, main_dev_id, cpld_index); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, count); + key = DFD_CFG_KEY(DFD_CFG_ITEM_CPLD_VERSION, main_dev_id, cpld_index); + rv = dfd_info_get_int(key, &value, NULL); + if (rv < 0) { + DBG_CPLD_DEBUG(DBG_ERROR, "main_dev_id: %u, cpld%u fw config error, key: 0x%08x, ret: %d\n", + main_dev_id, cpld_index, key, rv); + if (rv == -DFD_RV_DEV_NOTSUPPORT) { + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + return rv; + } + + DBG_CPLD_DEBUG(DBG_VERBOSE, "main_dev_id: %u, cpld%u firmware version: %x\n", + main_dev_id, cpld_index, value); + snprintf(buf, count, "%08x\n", value); + return strlen(buf); +} + +ssize_t dfd_get_cpld_hw_version(uint8_t main_dev_id, unsigned int cpld_index, char *buf, size_t count) +{ + + if (buf == NULL) { + DBG_CPLD_DEBUG(DBG_ERROR, "param error, buf is NULL, main_dev_id: %u, cpld index: %u\n", + main_dev_id, cpld_index); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DBG_CPLD_DEBUG(DBG_ERROR, "buf size error, count: %lu, main_dev_id: %u, cpld index: %u\n", + count, main_dev_id, cpld_index); + return -DFD_RV_INVALID_VALUE; + } + DBG_CPLD_DEBUG(DBG_VERBOSE, "main_dev_id: %u, cpld%u hardware version not support\n", + main_dev_id, cpld_index); + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); +} + +int dfd_set_cpld_testreg(uint8_t main_dev_id, unsigned int cpld_index, int value) +{ + int key, ret; + + if (value < 0 || value > 0xff) { + DBG_CPLD_DEBUG(DBG_ERROR, "main_dev_id: %u, can't set cpld%u test reg value = 0x%02x\n", + main_dev_id, cpld_index, value); + return -DFD_RV_INVALID_VALUE; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_CPLD_TEST_REG, main_dev_id, cpld_index); + ret = dfd_info_set_int(key, value); + if (ret < 0) { + DBG_CPLD_DEBUG(DBG_ERROR, "main_dev_id: %u, set cpld%u test reg error, key: 0x%x, ret:%d\n", + main_dev_id, cpld_index, key, ret); + return ret; + } + return DFD_RV_OK; +} + +int dfd_get_cpld_testreg(uint8_t main_dev_id, unsigned int cpld_index, int *value) +{ + int key, ret; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_CPLD_TEST_REG, main_dev_id, cpld_index); + ret = dfd_info_get_int(key, value, NULL); + if (ret < 0) { + DBG_CPLD_DEBUG(DBG_ERROR, "main_dev_id: %u, get cpld%u test reg error, key: 0x%x, ret: %d\n", + main_dev_id, cpld_index, key, ret); + return ret; + } + return DFD_RV_OK; +} + +ssize_t dfd_get_cpld_testreg_str(uint8_t main_dev_id, unsigned int cpld_index, + char *buf, size_t count) +{ + int ret, value; + + if (buf == NULL) { + DBG_CPLD_DEBUG(DBG_ERROR, "param error, buf is NULL, main_dev_id: %u, cpld index: %u\n", + main_dev_id, cpld_index); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DBG_CPLD_DEBUG(DBG_ERROR, "buf size error, count: %lu, main_dev_id: %u, cpld index: %u\n", + count, main_dev_id, cpld_index); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, count); + ret = dfd_get_cpld_testreg(main_dev_id, cpld_index, &value); + if (ret < 0) { + if (ret == -DFD_RV_DEV_NOTSUPPORT) { + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + return ret; + } + return (ssize_t)snprintf(buf, count, "0x%02x\n", value); +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_eeprom_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_eeprom_driver.c new file mode 100644 index 000000000000..745ed88b482e --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_eeprom_driver.c @@ -0,0 +1,107 @@ +/* + * Copyright(C) 2001-2022 Ruijie Network. All rights reserved. + */ +/* + * rg_eeprom_driver.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * History + * [Version] [Author] [Date] [Description] + * * v1.0 sonic_rd@ruijie.com.cn 2020-02-17 Initial version + */ + +#include + +#include "rg_module.h" +#include "dfd_cfg.h" +#include "dfd_cfg_adapter.h" +#include "dfd_tlveeprom.h" + +int g_dfd_eeprom_dbg_level = 0; +module_param(g_dfd_eeprom_dbg_level, int, S_IRUGO | S_IWUSR); + +int dfd_get_eeprom_size(int e2_type, int index) +{ + int key; + int *p_eeprom_size; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_EEPROM_SIZE, e2_type, index); + + p_eeprom_size = dfd_ko_cfg_get_item(key); + if (p_eeprom_size == NULL) { + DBG_EEPROM_DEBUG(DBG_ERROR, "get eeprom size error. key:0x%x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + + return *p_eeprom_size; +} + +ssize_t dfd_read_eeprom_data(int e2_type, int index, char *buf, loff_t offset, size_t count) +{ + int key; + ssize_t rd_len; + char *eeprom_path; + + if (buf == NULL || offset < 0 || count <= 0) { + DBG_EEPROM_DEBUG(DBG_ERROR, "params error, offset: 0x%llx, rd_count: %lu.\n", + offset, count); + return -DFD_RV_INVALID_VALUE; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_EEPROM_PATH, e2_type, index); + eeprom_path = dfd_ko_cfg_get_item(key); + if (eeprom_path == NULL) { + DBG_EEPROM_DEBUG(DBG_ERROR, "get eeprom path error, e2_type: %d, index: %d, key: 0x%08x\n", + e2_type, index, key); + return -DFD_RV_DEV_NOTSUPPORT; + } + + DBG_EEPROM_DEBUG(DBG_VERBOSE, "e2_type: %d, index: %d, path: %s, offset: 0x%llx, \ + rd_count: %lu\n", e2_type, index, eeprom_path, offset, count); + + memset(buf, 0, count); + rd_len = dfd_ko_read_file(eeprom_path, offset, buf, count); + if (rd_len < 0) { + DBG_EEPROM_DEBUG(DBG_ERROR, "read eeprom data failed, loc: %s, offset: 0x%llx, \ + rd_count: %lu, ret: %ld,\n", eeprom_path, offset, count, rd_len); + } else { + DBG_EEPROM_DEBUG(DBG_VERBOSE, "read eeprom data success, loc: %s, offset: 0x%llx, \ + rd_count: %lu, rd_len: %ld,\n", eeprom_path, offset, count, rd_len); + } + + return rd_len; +} + +ssize_t dfd_write_eeprom_data(int e2_type, int index, char *buf, loff_t offset, size_t count) +{ + int key; + ssize_t wr_len; + char *eeprom_path; + + if (buf == NULL || offset < 0 || count <= 0) { + DBG_EEPROM_DEBUG(DBG_ERROR, "params error, offset: 0x%llx, count: %lu.\n", offset, count); + return -DFD_RV_INVALID_VALUE; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_EEPROM_PATH, e2_type, index); + eeprom_path = dfd_ko_cfg_get_item(key); + if (eeprom_path == NULL) { + DBG_EEPROM_DEBUG(DBG_ERROR, "get eeprom path error, e2_type: %d, index: %d, key: 0x%08x\n", + e2_type, index, key); + return -DFD_RV_DEV_NOTSUPPORT; + } + + DBG_EEPROM_DEBUG(DBG_VERBOSE, "e2_type: %d, index: %d, path: %s, offset: 0x%llx, \ + wr_count: %lu.\n", e2_type, index, eeprom_path, offset, count); + + wr_len = dfd_ko_write_file(eeprom_path, offset, buf, count); + if (wr_len < 0) { + DBG_EEPROM_DEBUG(DBG_ERROR, "write eeprom data failed, loc:%s, offset: 0x%llx, \ + wr_count: %lu, ret: %ld.\n", eeprom_path, offset, count, wr_len); + } else { + DBG_EEPROM_DEBUG(DBG_VERBOSE, "write eeprom data success, loc:%s, offset: 0x%llx, \ + wr_count: %lu, wr_len: %ld.\n", eeprom_path, offset, count, wr_len); + } + + return wr_len; +} \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_fan_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_fan_driver.c new file mode 100644 index 000000000000..1174a2489014 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_fan_driver.c @@ -0,0 +1,724 @@ +/* + * Copyright(C) 2001-2022 Ruijie Network. All rights reserved. + */ +/* + * rg_fan_driver.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * History + * [Version] [Author] [Date] [Description] + * * v1.0 sonic_rd@ruijie.com.cn 2020-02-17 Initial version + */ + +#include +#include + +#include "rg_module.h" +#include "dfd_cfg.h" +#include "dfd_cfg_adapter.h" +#include "dfd_cfg_info.h" +#include "dfd_frueeprom.h" + +#define DFD_FAN_EEPROM_MODE_TLV_STRING "tlv" +#define DFD_FAN_EEPROM_MODE_FRU_STRING "fru" +#define FAN_SIZE (256) + +typedef enum fan_present_status_e { + ABSENT = 0, + PRESENT = 1, +} fan_present_status_t; + +typedef enum fan_motor_status_e { + MOTOR_STALL = 0, + MOTOR_ROLL = 1, +} fan_motor_status_t; + +typedef enum fan_eeprom_mode_e { + FAN_EEPROM_MODE_TLV, /* TLV */ + FAN_EEPROM_MODE_FRU, /*FRU*/ +} fan_eeprom_mode_t; + +typedef struct dfd_dev_head_info_s { + uint8_t ver; + uint8_t flag; + uint8_t hw_ver; + uint8_t type; + int16_t tlv_len; +} dfd_dev_head_info_t; + +typedef struct dfd_dev_tlv_info_s { + uint8_t type; + uint8_t len; + uint8_t data[0]; +} dfd_dev_tlv_info_t; + +int g_dfd_fan_dbg_level = 0; +module_param(g_dfd_fan_dbg_level, int, S_IRUGO | S_IWUSR); + +static char *dfd_get_fan_sysfs_name(void) +{ + int key; + char *sysfs_name; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_SYSFS_NAME, 0, 0); + sysfs_name = dfd_ko_cfg_get_item(key); + if (sysfs_name == NULL) { + DFD_FAN_DEBUG(DBG_VERBOSE, "key=0x%08x, sysfs_name is NULL, use default way.\n", key); + } else { + DFD_FAN_DEBUG(DBG_VERBOSE, "sysfs_name: %s.\n", sysfs_name); + } + return sysfs_name; +} + +static int dfd_get_fan_eeprom_mode(void) +{ + int key, mode; + char *name; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_E2_MODE, 0, 0); + name = dfd_ko_cfg_get_item(key); + if (name == NULL) { + DFD_FAN_DEBUG(DBG_WARN, "get fan eeprom mode fail, key=0x%08x\n", key); + return FAN_EEPROM_MODE_TLV; + } + + DFD_FAN_DEBUG(DBG_VERBOSE, "fan eeprom mode_name %s.\n", name); + if (!strncmp(name, DFD_FAN_EEPROM_MODE_TLV_STRING, strlen(DFD_FAN_EEPROM_MODE_TLV_STRING))) { + mode = FAN_EEPROM_MODE_TLV; + } else if (!strncmp(name, DFD_FAN_EEPROM_MODE_FRU_STRING, strlen(DFD_FAN_EEPROM_MODE_FRU_STRING))) { + mode = FAN_EEPROM_MODE_FRU; + } else { + mode = FAN_EEPROM_MODE_TLV; + } + + DFD_FAN_DEBUG(DBG_VERBOSE, "fan eeprom mode %d.\n", mode); + return mode; +} + +static int dfd_fan_tlv_eeprom_read(int bus, int addr, uint8_t cmd, char *buf, int len, + const char *sysfs_name) +{ + dfd_dev_head_info_t info; + char tmp_tlv_len[sizeof(uint16_t)]; + char *tlv_data; + dfd_dev_tlv_info_t *tlv; + int buf_len; + int rv, match_flag; + + rv = dfd_ko_i2c_read(bus, addr, 0, (uint8_t *)&info, sizeof(dfd_dev_head_info_t), sysfs_name); + if (rv < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "read fan i2c failed, bus: %d, addr: 0x%x, rv: %d\n", + bus, addr, rv); + return -DFD_RV_DEV_FAIL; + } + + memcpy(tmp_tlv_len, (uint8_t *)&info.tlv_len, sizeof(uint16_t)); + info.tlv_len = (tmp_tlv_len[0] << 8) + tmp_tlv_len[1]; + + if ((info.tlv_len <= 0 ) || (info.tlv_len > 0xFF)) { + DFD_FAN_DEBUG(DBG_ERROR, "fan maybe not set mac.\n"); + return -DFD_RV_TYPE_ERR; + } + DFD_FAN_DEBUG(DBG_VERBOSE, "info.tlv_len: %d\n", info.tlv_len); + + tlv_data = (uint8_t *)kmalloc(info.tlv_len, GFP_KERNEL); + if (tlv_data == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "tlv_data kmalloc failed \n"); + return -DFD_RV_NO_MEMORY; + } + memset(tlv_data, 0, info.tlv_len); + + rv = dfd_ko_i2c_read(bus, addr, sizeof(dfd_dev_head_info_t), tlv_data, info.tlv_len, sysfs_name); + if (rv < 0) { + DFD_FAN_DEBUG(DBG_ERROR,"fan eeprom read failed\n"); + kfree(tlv_data); + return -DFD_RV_DEV_FAIL; + } + + buf_len = len - 1; + match_flag = 0; + for (tlv = (dfd_dev_tlv_info_t *)tlv_data; (ulong)tlv < (ulong)tlv_data + info.tlv_len;) { + DFD_FAN_DEBUG(DBG_VERBOSE, "tlv: %p, tlv->type: 0x%x, tlv->len: 0x%x info->tlv_len: 0x%x\n", + tlv, tlv->type, tlv->len, info.tlv_len); + if (tlv->type == cmd && tlv->len <= buf_len ) { + DFD_FAN_DEBUG(DBG_VERBOSE, "find tlv data, copy...\n"); + memcpy(buf, (uint8_t *)tlv->data, tlv->len); + buf_len = (uint32_t)tlv->len; + match_flag = 1; + break; + } + tlv = (dfd_dev_tlv_info_t *)((uint8_t* )tlv + sizeof(dfd_dev_tlv_info_t) + tlv->len); + } + kfree(tlv_data); + if (match_flag == 0) { + DFD_FAN_DEBUG(DBG_ERROR,"can't find fan tlv date. bus: %d, addr: 0x%02x, tlv type: %d.\n", + bus, addr, cmd); + return -DFD_RV_TYPE_ERR; + } + return buf_len; +} + +static int dfd_get_fan_roll_status(unsigned int fan_index, unsigned int motor_index) +{ + int key, ret; + int status; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_ROLL_STATUS, fan_index, motor_index); + ret = dfd_info_get_int(key, &status, NULL); + if (ret < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan roll status error, fan: %u, motor: %u\n", + fan_index, motor_index); + return ret; + } + return status; +} + +static int dfd_get_fan_present_status(unsigned int fan_index) +{ + int key, ret; + int status; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_DEV_PRESENT_STATUS, RG_MAIN_DEV_FAN, fan_index); + ret = dfd_info_get_int(key, &status, NULL); + if (ret < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan present status error, key: 0x%x\n", key); + return ret; + } + return status; +} + +static int dfd_get_fan_status(unsigned int fan_index) +{ + int motor_num, motor_index, status, errcnt; + + status = dfd_get_fan_present_status(fan_index); + if (status != PRESENT) { + DFD_FAN_DEBUG(DBG_ERROR, "fan index: %u, status: %d\n", fan_index, status); + return status; + } + + motor_num = dfd_get_dev_number(RG_MAIN_DEV_FAN, RG_MINOR_DEV_MOTOR); + if (motor_num <= 0) { + DFD_FAN_DEBUG(DBG_ERROR, "get motor number error: %d\n", motor_num); + return -DFD_RV_DEV_FAIL; + } + errcnt = 0; + for (motor_index = 1; motor_index <= motor_num; motor_index++) { + status = dfd_get_fan_roll_status(fan_index, motor_index); + if (status < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan roll status error, fan index: %u, motor index: %d, status: %d\n", + fan_index, motor_index, status); + return status; + } + if (status != MOTOR_ROLL) { + DFD_FAN_DEBUG(DBG_ERROR, + "stall:fan index: %u, motor index: %d, status: %d\n",fan_index, motor_index, status); + errcnt++; + } + } + if (errcnt > 0) { + return FAN_STATUS_NOT_OK; + } + return FAN_STATUS_OK; +} + +ssize_t dfd_get_fan_status_str(unsigned int fan_index, char *buf, size_t count) +{ + int ret; + + if (buf == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "params error, fan_index: %u count: %lu", + fan_index, count); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DFD_FAN_DEBUG(DBG_ERROR, "buf size error, count: %lu, fan index: %u\n", + count, fan_index); + return -DFD_RV_INVALID_VALUE; + } + ret = dfd_get_fan_status(fan_index); + if (ret < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan status error, ret: %d, fan_index: %u\n", + ret, fan_index); + return ret; + } + memset(buf, 0, count); + return (ssize_t)snprintf(buf, count, "%d\n", ret); +} + +static int dfd_fan_product_name_decode(char *fan_buf, int buf_len) +{ + int key, i, j; + char *p_fan_name, *p_decode_name; + int *fan_type_num; + int *fan_display_num; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_DEV_NUM, RG_MAIN_DEV_FAN, RG_MINOR_DEV_FAN); + fan_display_num = dfd_ko_cfg_get_item(key); + if (fan_display_num == NULL) { + DFD_FAN_DEBUG(DBG_VERBOSE, "get fan display name number error, key:0x%x, \ + skip fan name decode\n", key); + return DFD_RV_OK; + } + + for (i = 1; i <= *fan_display_num; i++) { + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_TYPE_NUM, i, 0); + fan_type_num = dfd_ko_cfg_get_item(key); + if (fan_type_num == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "config error, get fan type number error, key: 0x%x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + for (j = 1; j <= *fan_type_num; j++) { + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_NAME, i, j); + p_fan_name = dfd_ko_cfg_get_item(key); + if (p_fan_name == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "config error, get fan origin name error, key: 0x%x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + if (!strncmp(fan_buf, p_fan_name, strlen(p_fan_name))) { + key = DFD_CFG_KEY(DFD_CFG_ITEM_DECODE_FAN_NAME, i, 0); + p_decode_name = dfd_ko_cfg_get_item(key); + if (p_decode_name == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "config error, get fan decode name error, key: 0x%x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + memset(fan_buf, 0, buf_len); + strncpy(fan_buf, p_decode_name, buf_len -1); + DFD_FAN_DEBUG(DBG_VERBOSE, "fan name match ok, display fan name: %s.\n", fan_buf); + return DFD_RV_OK; + } + } + } + + DFD_FAN_DEBUG(DBG_ERROR, "fan name: %s error, can't match.\n", fan_buf); + return -DFD_RV_DEV_NOTSUPPORT; +} + +ssize_t dfd_get_fan_info(unsigned int fan_index, uint8_t cmd, char *buf, size_t count) +{ + int key, rv, eeprom_mode; + char fan_buf[FAN_SIZE]; + dfd_i2c_dev_t *i2c_dev; + const char *sysfs_name; + + if (buf == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "buf is NULL, fan index: %u, cmd: 0x%x.\n", fan_index, cmd); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DFD_FAN_DEBUG(DBG_ERROR, "buf size error, count: %lu, fan index: %u, cmd: 0x%x.\n", + count, fan_index, cmd); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, count); + key = DFD_CFG_KEY(DFD_CFG_ITEM_OTHER_I2C_DEV, RG_MAIN_DEV_FAN, fan_index); + i2c_dev = dfd_ko_cfg_get_item(key); + if (i2c_dev == NULL) { + DFD_FAN_DEBUG(DBG_VERBOSE, "can't find fan%u I2C dfd config, key: 0x%08x\n", fan_index, key); + return snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + + sysfs_name = dfd_get_fan_sysfs_name(); + eeprom_mode = dfd_get_fan_eeprom_mode(); + memset(fan_buf, 0, FAN_SIZE); + if (eeprom_mode == FAN_EEPROM_MODE_TLV) { + if (cmd == DFD_DEV_INFO_TYPE_PART_NUMBER) { + DFD_FAN_DEBUG(DBG_VERBOSE, "fan tlv not have part_number attributes\n"); + return snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + rv = dfd_fan_tlv_eeprom_read(i2c_dev->bus, i2c_dev->addr, cmd, fan_buf, FAN_SIZE, sysfs_name); + } else { + rv = dfd_get_fru_data(i2c_dev->bus, i2c_dev->addr, cmd, fan_buf, FAN_SIZE, sysfs_name); + } + + if (rv < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "fan eeprom read failed"); + return -DFD_RV_DEV_FAIL; + } + + DFD_FAN_DEBUG(DBG_VERBOSE, "%s\n", fan_buf); + if (cmd == DFD_DEV_INFO_TYPE_NAME) { + rv = dfd_fan_product_name_decode(fan_buf, FAN_SIZE); + if (rv < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "fan name decode error. rv: %d\n", rv); + return rv; + } + } + + snprintf(buf, count, "%s\n", fan_buf); + return strlen(buf); +} + +int dfd_get_fan_speed(unsigned int fan_index, unsigned int motor_index, unsigned int *speed) +{ + int key, ret, speed_tmp; + + if (speed == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "param error. fan index: %u, motor index: %u\n", + fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_SPEED, fan_index, motor_index); + ret = dfd_info_get_int(key, &speed_tmp, NULL); + if (ret < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan%u motor%u speed error, key: 0x%x, ret: %d\n", + fan_index, motor_index, key, ret); + return ret; + } + + if (speed_tmp == 0 || speed_tmp == 0xffff) { + *speed = 0; + } else { + *speed = 15000000 / speed_tmp; + } + return DFD_RV_OK; +} + +ssize_t dfd_get_fan_speed_str(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count) +{ + int ret; + unsigned int speed; + + if (buf == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "buf is NULL, fan index: %u, motor index: %u\n", + fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DFD_FAN_DEBUG(DBG_ERROR, "buf size error, count: %lu, fan index: %u, motor index: %u\n", + count, fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + ret = dfd_get_fan_speed(fan_index, motor_index, &speed); + if (ret < 0) { + return ret; + } + memset(buf, 0, count); + return (ssize_t)snprintf(buf, count, "%d\n", speed); +} + +int dfd_set_fan_pwm(unsigned int fan_index, int pwm) +{ + int key, ret, data; + + if (pwm < 0 || pwm > 100) { + DFD_FAN_DEBUG(DBG_ERROR, "can not set pwm = %d.\n", pwm); + return -DFD_RV_INVALID_VALUE; + } + + data = pwm * 255 / 100; + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_RATIO, fan_index, 0); + ret = dfd_info_set_int(key, data); + if (ret < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "set fan%u ratio error, key: 0x%x,ret: %d\n", + fan_index, key, ret); + return ret; + } + return DFD_RV_OK; +} + +int dfd_get_fan_pwm(unsigned int fan_index, int *pwm) +{ + int key, ret, ratio; + + if (pwm == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "param error. fan index: %u\n", fan_index); + return -DFD_RV_INVALID_VALUE; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_RATIO, fan_index, 0); + ret = dfd_info_get_int(key, &ratio, NULL); + if (ret < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan%u ratio error, key: 0x%x,ret: %d\n", + fan_index, key, ret); + return ret; + } + if ((ratio * 100) % 255 > 0) { + *pwm = ratio * 100 / 255 + 1; + } else { + *pwm = ratio * 100 / 255; + } + return DFD_RV_OK; +} + +ssize_t dfd_get_fan_pwm_str(unsigned int fan_index, char *buf, size_t count) +{ + int ret, value; + + if (buf == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "buf is NULL, fan index: %u\n", fan_index); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DFD_FAN_DEBUG(DBG_ERROR, "buf size error, count: %lu, fan index: %u\n", count, + fan_index); + return -DFD_RV_INVALID_VALUE; + } + + ret = dfd_get_fan_pwm(fan_index, &value); + if (ret < 0) { + return ret; + } + memset(buf, 0, count); + return (ssize_t)snprintf(buf, count, "%d\n", value); +} + +static int dfd_get_fan_motor_speed_tolerance(unsigned int fan_index, unsigned int motor_index, int *value) +{ + int key; + int *p_fan_speed_tolerance; + + if (value == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "param error. fan index: %u, motor index: %u.\n", + fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_SPEED_TOLERANCE, fan_index, motor_index); + p_fan_speed_tolerance = dfd_ko_cfg_get_item(key); + if (p_fan_speed_tolerance == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan%u motor%u speed tolerance failed, key: 0x%x\n", + fan_index, motor_index, key); + return -DFD_RV_DEV_NOTSUPPORT; + } + *value = *p_fan_speed_tolerance; + DFD_FAN_DEBUG(DBG_VERBOSE, "get fan%u motor%u speed tolerance ok, key: 0x%x, value: %d\n", + fan_index, motor_index, key, *value); + return DFD_RV_OK; +} + +ssize_t dfd_get_fan_motor_speed_tolerance_str(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count) +{ + int ret, value; + + if (buf == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "buf is NULL, fan index: %u, motor index: %u\n", + fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DFD_FAN_DEBUG(DBG_ERROR, "buf size error, count: %lu, fan index: %u, motor index: %u\n", + count, fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, count); + ret = dfd_get_fan_motor_speed_tolerance(fan_index, motor_index, &value); + if (ret < 0) { + if (ret == -DFD_RV_DEV_NOTSUPPORT) { + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + return ret; + } + return (ssize_t)snprintf(buf, count, "%d\n", value); +} + +int dfd_get_fan_speed_target(unsigned int fan_index, unsigned int motor_index, int *value) +{ + int key; + int *p_fan_speed_target; + + if (value == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "param error. fan index: %u, motor index: %u\n", + fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_SPEED_TARGET, fan_index, motor_index); + p_fan_speed_target = dfd_ko_cfg_get_item(key); + if (p_fan_speed_target == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan%u motor%u speed target failed, key: 0x%x\n", + fan_index, motor_index, key); + return -DFD_RV_DEV_NOTSUPPORT; + } + *value = *p_fan_speed_target; + DFD_FAN_DEBUG(DBG_VERBOSE, "get fan%u motor%u speed target ok, key: 0x%x, value: %d\n", + fan_index, motor_index, key, *value); + return DFD_RV_OK; +} + +ssize_t dfd_get_fan_motor_speed_target_str(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count) +{ + int ret, value; + + if (buf == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "buf is NULL, fan index: %u, motor index: %u\n", + fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DFD_FAN_DEBUG(DBG_ERROR, "buf size error, count: %lu, fan index: %u, motor index: %u\n", + count, fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, count); + ret = dfd_get_fan_speed_target(fan_index, motor_index, &value); + if (ret < 0) { + if (ret == -DFD_RV_DEV_NOTSUPPORT) { + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + return ret; + } + return (ssize_t)snprintf(buf, count, "%d\n", value); +} + +static int dfd_get_fan_direction(unsigned int fan_index, int *value) +{ + int fan_direction, ret; + char fan_name[FAN_SIZE]; + + if (value == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "param error, fan index: %u\n", fan_index); + return -DFD_RV_INVALID_VALUE; + } + + ret = dfd_get_fan_info(fan_index, DFD_DEV_INFO_TYPE_NAME, fan_name, FAN_SIZE); + if (ret < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan%u name error, ret: %d\n", fan_index, ret); + return ret; + } + dfd_ko_cfg_del_space_lf_cr(fan_name); + DFD_FAN_DEBUG(DBG_VERBOSE, "fan%u name: %s\n", fan_index, fan_name); + + ret = dfd_ko_cfg_get_fan_direction_by_name(fan_name, &fan_direction); + if (ret < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan%u direction failde, fan name: %s, ret: %d\n", + fan_index, fan_name, ret); + return ret; + } + DFD_FAN_DEBUG(DBG_VERBOSE, "get fan%u direction ok, fan name: %s, direction: %d\n", + fan_index, fan_name, fan_direction); + *value = fan_direction; + return DFD_RV_OK; +} + +ssize_t dfd_get_fan_direction_str(unsigned int fan_index, char *buf, size_t count) +{ + int ret, value; + + if (buf == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "param error, buf is NULL, fan index: %u.\n", fan_index); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DFD_FAN_DEBUG(DBG_ERROR, "param error, buf is NULL, fan index: %u.\n", fan_index); + return -DFD_RV_INVALID_VALUE; + } + + ret = dfd_get_fan_direction(fan_index, &value); + if (ret < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan direction string failed, ret: %d, fan_index: %u\n", + ret, fan_index); + return ret; + } + memset(buf, 0, count); + return (ssize_t)snprintf(buf, count, "%d\n", value); +} + +static int dfd_get_fan_motor_speed_max(unsigned int fan_index, unsigned int motor_index, int *value) +{ + int key; + int *p_fan_speed_max; + + if (value == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "param error, fan index: %u, motor index: %u\n", + fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_SPEED_MAX, fan_index, motor_index); + p_fan_speed_max = dfd_ko_cfg_get_item(key); + if (p_fan_speed_max == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan%u motor%u speed max failed, key: 0x%x\n", + fan_index, motor_index, key); + return -DFD_RV_DEV_NOTSUPPORT; + } + *value = *p_fan_speed_max; + DFD_FAN_DEBUG(DBG_VERBOSE, "get fan%u motor%u speed max success, key: 0x%x, value: %d\n", + fan_index, motor_index, key, *value); + return DFD_RV_OK; +} + +ssize_t dfd_get_fan_motor_speed_max_str(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count) +{ + int ret, value; + + if (buf == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "buf is NULL, fan index: %u, motor index: %u\n", + fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DFD_FAN_DEBUG(DBG_ERROR, "buf size error, count: %lu, fan index: %u, motor index: %u\n", + count, fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, count); + ret = dfd_get_fan_motor_speed_max(fan_index, motor_index, &value); + if (ret < 0) { + if (ret == -DFD_RV_DEV_NOTSUPPORT) { + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + return ret; + } + return (ssize_t)snprintf(buf, count, "%d\n", value); +} + +static int dfd_get_fan_motor_speed_min(unsigned int fan_index, unsigned int motor_index, int *value) +{ + int key; + int *p_fan_speed_min; + + if (value == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "param error. fan index: %u, motor index: %u\n", + fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_SPEED_MIN, fan_index, motor_index); + p_fan_speed_min = dfd_ko_cfg_get_item(key); + if (p_fan_speed_min == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan%u motor%u speed min failed, key: 0x%x\n", + fan_index, motor_index, key); + return -DFD_RV_DEV_NOTSUPPORT; + } + *value = *p_fan_speed_min; + DFD_FAN_DEBUG(DBG_VERBOSE, "get fan%u motor%u speed min success, key: 0x%x, value: %d\n", + fan_index, motor_index, key, *value); + return DFD_RV_OK; +} + +ssize_t dfd_get_fan_motor_speed_min_str(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count) +{ + int ret, value; + + if (buf == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "buf is NULL, fan index: %u, motor index: %u\n", + fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DFD_FAN_DEBUG(DBG_ERROR, "buf size error, count: %lu, fan index: %u, motor index: %u\n", + count, fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, count); + ret = dfd_get_fan_motor_speed_min(fan_index, motor_index, &value); + if (ret < 0) { + if (ret == -DFD_RV_DEV_NOTSUPPORT) { + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + return ret; + } + return (ssize_t)snprintf(buf, count, "%d\n", value); +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_fpga_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_fpga_driver.c new file mode 100644 index 000000000000..20883e20e2eb --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_fpga_driver.c @@ -0,0 +1,275 @@ +/* + * Copyright(C) 2001-2022 Ruijie Network. All rights reserved. + */ +/* + * rg_fpga_driver.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * History + * [Version] [Author] [Date] [Description] + * * v1.0 sonic_rd@ruijie.com.cn 2020-02-17 Initial version + */ + +#include + +#include "rg_module.h" +#include "dfd_cfg.h" +#include "dfd_cfg_adapter.h" +#include "dfd_cfg_info.h" + +#define FPGA_REG_WIDTH_MAX (4) + +int g_dfd_fpga_dbg_level = 0; +module_param(g_dfd_fpga_dbg_level, int, S_IRUGO | S_IWUSR); + +ssize_t dfd_get_fpga_name(uint8_t main_dev_id, unsigned int fpga_index, char *buf, size_t count) +{ + int key; + char *fpga_name; + + if (buf == NULL) { + DBG_FPGA_DEBUG(DBG_ERROR, "param error, buf is NULL. main_dev_id: %u, fpga index: %u\n", + main_dev_id, fpga_index); + return -DFD_RV_INVALID_VALUE; + } + + if (count <= 0) { + DBG_FPGA_DEBUG(DBG_ERROR, "buf size error, count: %lu, main_dev_id: %u, fpga index: %u\n", + count, main_dev_id, fpga_index); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, count); + key = DFD_CFG_KEY(DFD_CFG_ITEM_FPGA_NAME, main_dev_id, fpga_index); + fpga_name = dfd_ko_cfg_get_item(key); + if (fpga_name == NULL) { + DBG_FPGA_DEBUG(DBG_ERROR, "main_dev_id: %u, fpga%u name config error, key: 0x%08x\n", + main_dev_id, fpga_index, key); + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + + DBG_FPGA_DEBUG(DBG_VERBOSE, "%s\n", fpga_name); + snprintf(buf, count, "%s\n", fpga_name); + return strlen(buf); +} + +static ssize_t dfd_get_fpga_model(uint8_t main_dev_id, unsigned int fpga_index, char *buf, size_t count) +{ + int key, ret, fpga_model_val; + char *fpga_type; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FPGA_MODEL_REG, main_dev_id, fpga_index); + ret = dfd_info_get_int(key, &fpga_model_val, NULL); + if (ret < 0) { + DBG_FPGA_DEBUG(DBG_ERROR, "get main_dev_id: %u, fpga%u model failed, key: 0x%08x, ret: %d\n", + main_dev_id, fpga_index, key, ret); + if (ret == -DFD_RV_DEV_NOTSUPPORT) { + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + return ret; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FPGA_MODEL_DECODE, fpga_model_val, 0); + fpga_type = dfd_ko_cfg_get_item(key); + if (fpga_type == NULL) { + DBG_FPGA_DEBUG(DBG_ERROR, "main_dev_id: %u, fpga%u decode fpga model val 0x%08x failed\n", + main_dev_id, fpga_index, fpga_model_val); + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + + DBG_FPGA_DEBUG(DBG_VERBOSE, + "main_dev_id: %u, fpga%u decode fpga model success, origin value: 0x%08x decode value: %s\n", + main_dev_id, fpga_index, fpga_model_val, fpga_type); + snprintf(buf, count, "%s\n", fpga_type); + return strlen(buf); +} + +ssize_t dfd_get_fpga_type(uint8_t main_dev_id, unsigned int fpga_index, char *buf, size_t count) +{ + int key; + char *fpga_type; + ssize_t ret; + + if (buf == NULL) { + DBG_FPGA_DEBUG(DBG_ERROR, "param error, buf is NULL, main_dev_id: %u, fpga index: %u\n", + main_dev_id, fpga_index); + return -DFD_RV_INVALID_VALUE; + } + + if (count <= 0) { + DBG_FPGA_DEBUG(DBG_ERROR, "buf size error, count: %lu, main_dev_id: %u, fpga index: %u\n", + count, main_dev_id, fpga_index); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, count); + key = DFD_CFG_KEY(DFD_CFG_ITEM_FPGA_TYPE, main_dev_id, fpga_index); + fpga_type = dfd_ko_cfg_get_item(key); + if (fpga_type == NULL) { + DBG_FPGA_DEBUG(DBG_VERBOSE, + "main_dev_id: %u, fpga%u type config is NULL, try to get fpga type from fpga model\n", + main_dev_id, fpga_index); + ret = dfd_get_fpga_model(main_dev_id, fpga_index, buf, count); + return ret; + } + + DBG_FPGA_DEBUG(DBG_VERBOSE, "%s\n", fpga_type); + snprintf(buf, count, "%s\n", fpga_type); + return strlen(buf); +} + +ssize_t dfd_get_fpga_fw_version(uint8_t main_dev_id, unsigned int fpga_index, char *buf, size_t count) +{ + int key, rv; + uint32_t value; + + if (buf == NULL) { + DBG_FPGA_DEBUG(DBG_ERROR, "param error, buf is NULL, main_dev_id: %u, fpga index: %u\n", + main_dev_id, fpga_index); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DBG_FPGA_DEBUG(DBG_ERROR, "buf size error, count: %lu, main_dev_id: %u, fpga index: %u\n", + count, main_dev_id, fpga_index); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, count); + key = DFD_CFG_KEY(DFD_CFG_ITEM_FPGA_VERSION, main_dev_id, fpga_index); + rv = dfd_info_get_int(key, &value, NULL); + if (rv < 0) { + DBG_FPGA_DEBUG(DBG_ERROR, "main_dev_id: %u, fpga%u fw config error, key: 0x%08x, ret: %d\n", + main_dev_id, fpga_index, key, rv); + if (rv == -DFD_RV_DEV_NOTSUPPORT) { + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + return rv; + } + + DBG_FPGA_DEBUG(DBG_VERBOSE, "main_dev_id: %u, fpga%u firmware version: %x\n", + main_dev_id, fpga_index, value); + snprintf(buf, count, "0x%08x\n", value); + return strlen(buf); +} + +ssize_t dfd_get_fpga_hw_version(uint8_t main_dev_id, unsigned int fpga_index, char *buf, size_t count) +{ + + if (buf == NULL) { + DBG_FPGA_DEBUG(DBG_ERROR, "param error, buf is NULL, main_dev_id: %u, fpga index: %u\n", + main_dev_id, fpga_index); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DBG_FPGA_DEBUG(DBG_ERROR, "buf size error, count: %lu, main_dev_id: %u, fpga index: %u\n", + count, main_dev_id, fpga_index); + return -DFD_RV_INVALID_VALUE; + } + DBG_FPGA_DEBUG(DBG_VERBOSE, "main_dev_id: %u, fpga%u hardware version not support\n", + main_dev_id, fpga_index); + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); +} + +static int value_convert_to_buf(unsigned int value, uint8_t *buf, int len, int pola) +{ + int i; + + if ((pola != INFO_POLA_POSI) && (pola != INFO_POLA_NEGA)) { + DBG_FPGA_DEBUG(DBG_ERROR, "unsupport pola mode: %d\n", pola); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, len); + if (pola == INFO_POLA_POSI) { + for (i = 0; i < len; i++) { + buf[i] = (value >> ((len - i - 1) * 8)) & 0xff; + } + } else { + for (i = 0; i < len; i++) { + buf[i] = (value >> (i * 8)) & 0xff; + } + } + return DFD_RV_OK; +} + +int dfd_set_fpga_testreg(uint8_t main_dev_id, unsigned int fpga_index, unsigned int value) +{ + int key, ret; + uint8_t wr_buf[FPGA_REG_WIDTH_MAX]; + info_ctrl_t *info_ctrl; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FPGA_TEST_REG, main_dev_id, fpga_index); + info_ctrl = dfd_ko_cfg_get_item(key); + if (info_ctrl == NULL) { + DBG_FPGA_DEBUG(DBG_VERBOSE, "main_dev_id: %u, fpga%u get info ctrl failed, key: 0x%08x\n", + main_dev_id, fpga_index, key); + return -DFD_RV_DEV_NOTSUPPORT; + } + if (info_ctrl->fpath == NULL) { + DBG_FPGA_DEBUG(DBG_VERBOSE, "main_dev_id: %u, fpga%u get fpath failed\n", main_dev_id, + fpga_index); + return -DFD_RV_INVALID_VALUE; + } + if (info_ctrl->len > FPGA_REG_WIDTH_MAX) { + DBG_FPGA_DEBUG(DBG_ERROR, "main_dev_id: %u, fpga%u info_ctrl len: %d, unsupport\n", + main_dev_id, fpga_index, info_ctrl->len); + return -DFD_RV_INVALID_VALUE; + } + + ret = value_convert_to_buf(value, wr_buf, FPGA_REG_WIDTH_MAX, info_ctrl->pola); + if (ret < 0) { + DBG_FPGA_DEBUG(DBG_ERROR, "value: 0x%x convert to buf failed, pola:%d, ret: %d\n", + value, info_ctrl->pola, ret); + return ret; + } + + DBG_FPGA_DEBUG(DBG_VERBOSE, "main_dev_id: %u, fpga%u fpath: %s, addr: 0x%x, len: %d value: 0x%x\n", + main_dev_id, fpga_index, info_ctrl->fpath, info_ctrl->addr, info_ctrl->len, value); + ret = dfd_ko_write_file(info_ctrl->fpath, info_ctrl->addr, wr_buf, info_ctrl->len); + if (ret < 0) { + DBG_FPGA_DEBUG(DBG_ERROR, "set fpga test reg failed, ret: %d", ret); + return ret; + } + return DFD_RV_OK; +} + +int dfd_get_fpga_testreg(uint8_t main_dev_id, unsigned int fpga_index, int *value) +{ + int key, ret; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FPGA_TEST_REG, main_dev_id, fpga_index); + ret = dfd_info_get_int(key, value, NULL); + if (ret < 0) { + DBG_FPGA_DEBUG(DBG_ERROR, "main_dev_id: %u, get fpga%u test reg error, key: 0x%x, ret: %d\n", + main_dev_id, fpga_index, key, ret); + return ret; + } + return DFD_RV_OK; +} + +ssize_t dfd_get_fpga_testreg_str(uint8_t main_dev_id, unsigned int fpga_index, + char *buf, size_t count) +{ + int ret, value; + + if (buf == NULL) { + DBG_FPGA_DEBUG(DBG_ERROR, "param error, buf is NULL, main_dev_id: %u, fpga index: %u\n", + main_dev_id, fpga_index); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DBG_FPGA_DEBUG(DBG_ERROR, "buf size error, count: %lu, main_dev_id: %u, fpga index: %u\n", + count, main_dev_id, fpga_index); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, count); + ret = dfd_get_fpga_testreg(main_dev_id, fpga_index, &value); + if (ret < 0) { + if (ret == -DFD_RV_DEV_NOTSUPPORT) { + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + return ret; + } + return (ssize_t)snprintf(buf, count, "0x%08x\n", value); +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_led_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_led_driver.c new file mode 100644 index 000000000000..88e05876dc40 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_led_driver.c @@ -0,0 +1,103 @@ +/* + * Copyright(C) 2001-2022 Ruijie Network. All rights reserved. + */ +/* + * rg_led_driver.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * History + * [Version] [Author] [Date] [Description] + * * v1.0 sonic_rd@ruijie.com.cn 2020-02-17 Initial version + */ + +#include + +#include "rg_module.h" +#include "dfd_cfg.h" +#include "dfd_cfg_info.h" +#include "dfd_cfg_adapter.h" + +int g_dfd_sysled_dbg_level = 0; +module_param(g_dfd_sysled_dbg_level, int, S_IRUGO | S_IWUSR); + +static int dfd_get_led_status_value(uint16_t led_id, uint8_t led_index, int *value) +{ + int key, ori_value, ret; + int *p_decode_value; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_LED_STATUS, led_id, led_index); + ret = dfd_info_get_int(key, &ori_value, NULL); + if (ret < 0) { + DBG_SYSLED_DEBUG(DBG_ERROR, "get led status error, key: 0x%x, ret: %d\n", key, ret); + return ret; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_LED_STATUS_DECODE, led_id, ori_value); + p_decode_value = dfd_ko_cfg_get_item(key); + if (p_decode_value != NULL) { + DBG_SYSLED_DEBUG(DBG_VERBOSE, "led id: %u index: %u, ori_value: 0x%x, decode value :0x%x\n", + led_id, led_index, ori_value, *p_decode_value); + *value = *p_decode_value; + return DFD_RV_OK; + } + return -DFD_RV_INVALID_VALUE; +} + +ssize_t dfd_get_led_status(uint16_t led_id, uint8_t led_index, char *buf, size_t count) +{ + int ret, led_value; + + if (buf == NULL) { + DBG_SYSLED_DEBUG(DBG_ERROR, "param error, buf is NULL. led_id: %u, led_index: %u\n", + led_id, led_index); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DBG_SYSLED_DEBUG(DBG_ERROR, "buf size error, count: %lu, led_id: %u, led_index: %u\n", + count, led_id, led_index); + return -DFD_RV_INVALID_VALUE; + } + memset(buf, 0 , count); + ret = dfd_get_led_status_value(led_id, led_index, &led_value); + if (ret < 0) { + if (ret == -DFD_RV_DEV_NOTSUPPORT) { + DBG_SYSLED_DEBUG(DBG_VERBOSE, "led_id: %u, led_index: %u, can't find config.\n", + led_id, led_index); + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + DBG_SYSLED_DEBUG(DBG_ERROR, "get led status error, ret: %d, led_id: %u, led_index: %u\n", + ret, led_id, led_index); + return ret; + } + return (ssize_t)snprintf(buf, count, "%d\n", led_value); +} + +ssize_t dfd_set_led_status(uint16_t led_id, uint8_t led_index, int value) +{ + int ret, led_value, key; + + if (value < 0 || value > 0xff) { + DBG_SYSLED_DEBUG(DBG_ERROR, "can not set led status value = %d.\n", value); + return -DFD_RV_INVALID_VALUE; + } + + DBG_SYSLED_DEBUG(DBG_VERBOSE, "set led id: %u index: %u, status[%d].\n", + led_id, led_index, value); + ret = dfd_ko_cfg_get_led_status_decode2_by_regval(value, led_id, &led_value); + if(ret < 0) { + DBG_SYSLED_DEBUG(DBG_ERROR, "get led status register error, ret: %d, led_id: %u, value: %d\n", + ret, led_id, value); + return ret; + } + + DBG_SYSLED_DEBUG(DBG_VERBOSE, "get led[%u] index[%u] status[%d] decode value[%d]\n", + led_id, led_index, value, led_value); + key = DFD_CFG_KEY(DFD_CFG_ITEM_LED_STATUS, led_id, led_index); + ret = dfd_info_set_int(key, led_value); + if (ret < 0) { + DBG_SYSLED_DEBUG(DBG_ERROR, "set led status error, key: 0x%x, ret: %d\n", key, ret); + return ret; + } + + return DFD_RV_OK; +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_module.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_module.c new file mode 100644 index 000000000000..03f03e8791fa --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_module.c @@ -0,0 +1,47 @@ +/* + * Copyright(C) 2001-2022 Ruijie Network. All rights reserved. + */ +/* + * rg_module.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * + * History + * [Version] [Author] [Date] [Description] + * * v1.0 sonic_rd@ruijie.com.cn 2020-02-17 Initial version + * * v1.1 sonic_rd@ruijie.com.cn 2021-08-26 S3IP sysfs + */ +#include + +#include "rg_module.h" +#include "dfd_cfg.h" + +int g_dfd_dbg_level = 0; +module_param(g_dfd_dbg_level, int, S_IRUGO | S_IWUSR); + +int32_t rg_dev_cfg_init(void) +{ + return dfd_dev_cfg_init(); +} + +void rg_dev_cfg_exit(void) +{ + dfd_dev_cfg_exit(); + return; +} + +int dfd_get_dev_number(unsigned int main_dev_id, unsigned int minor_dev_id) +{ + int key,dev_num; + int *p_dev_num; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_DEV_NUM, main_dev_id, minor_dev_id); + p_dev_num = dfd_ko_cfg_get_item(key); + if (p_dev_num == NULL) { + DBG_DEBUG(DBG_ERROR, "get device number failed, key:0x%x\n",key); + return -DFD_RV_DEV_NOTSUPPORT; + } + dev_num = *p_dev_num; + DBG_DEBUG(DBG_VERBOSE, "get device number ok, number:%d\n",dev_num); + return dev_num; +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_psu_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_psu_driver.c new file mode 100644 index 000000000000..3df87ac58b30 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_psu_driver.c @@ -0,0 +1,390 @@ +/* + * Copyright(C) 2001-2022 Ruijie Network. All rights reserved. + */ +/* + * rg_psu_driver.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * History + * [Version] [Author] [Date] [Description] + * * v1.0 sonic_rd@ruijie.com.cn 2020-02-17 Initial version + */ + +#include +#include + +#include "rg_module.h" +#include "dfd_cfg.h" +#include "dfd_cfg_adapter.h" +#include "dfd_cfg_info.h" +#include "dfd_frueeprom.h" + +#define PSU_SIZE (256) +#define RG_GET_PSU_PMBUS_BUS(addr) (((addr) >> 24) & 0xff) +#define RG_GET_PSU_PMBUS_ADDR(addr) (((addr) >> 8) & 0xffff) +#define RG_GET_PSU_PMBUS_OFFSET(addr) ((addr) & 0xff) + +typedef enum dfd_psu_pmbus_type_e { + DFD_PSU_PMBUS_TYPE_AC = 1, + DFD_PSU_PMBUS_TYPE_DC = 2, +} dfd_psu_pmbus_type_t; + +typedef enum dfd_psu_sysfs_type_e { + DFD_PSU_SYSFS_TYPE_DC = 0, + DFD_PSU_SYSFS_TYPE_AC = 1, +} dfd_psu_sysfs_type_t; + +typedef enum dfd_psu_status_e { + DFD_PSU_PRESENT_STATUS = 0, + DFD_PSU_OUTPUT_STATUS = 1, + DFD_PSU_ALERT_STATUS = 2, +} dfd_psu_status_t; + +int g_dfd_psu_dbg_level = 0; +module_param(g_dfd_psu_dbg_level, int, S_IRUGO | S_IWUSR); + +static char *dfd_get_psu_sysfs_name(void) +{ + int key; + char *sysfs_name; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_PSU_SYSFS_NAME, 0, 0); + sysfs_name = dfd_ko_cfg_get_item(key); + if (sysfs_name == NULL) { + DFD_PSU_DEBUG(DBG_VERBOSE, "key=0x%08x, sysfs_name is NULL, use default way.\n", key); + } else { + DFD_PSU_DEBUG(DBG_VERBOSE, "sysfs_name: %s.\n", sysfs_name); + } + return sysfs_name; +} + +static void dfd_psu_del_no_print_string(char *buf) +{ + int i, len; + + len = strlen(buf); + for (i = 0; i < len; i++) { + if ((buf[i] < 0x21) || (buf[i] > 0x7E)) { + buf[i] = '\0'; + break; + } + } + return ; +} + +static int dfd_get_psu_present_status(unsigned int psu_index) +{ + int present_key, present_status; + int ret; + + present_key = DFD_CFG_KEY(DFD_CFG_ITEM_PSU_STATUS, psu_index, DFD_PSU_PRESENT_STATUS); + ret = dfd_info_get_int(present_key, &present_status, NULL); + if (ret < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "dfd_get_psu_status error. psu_index: %u, ret: %d\n", + psu_index, ret); + return ret; + } + + return present_status; +} + +ssize_t dfd_get_psu_present_status_str(unsigned int psu_index, char *buf, size_t count) +{ + int ret; + if (buf == NULL) { + DFD_PSU_DEBUG(DBG_ERROR, "params error.psu_index: %u.",psu_index); + return -EINVAL; + } + if (count <= 0) { + DFD_PSU_DEBUG(DBG_ERROR, "buf size error, count: %lu, psu index: %u\n", + count, psu_index); + return -EINVAL; + } + + ret = dfd_get_psu_present_status(psu_index); + if (ret < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "get psu status error, ret: %d, psu_index: %u\n", ret, psu_index); + return -EIO; + } + memset(buf, 0, count); + return (ssize_t)snprintf(buf, count, "%d\n", ret); +} + +ssize_t dfd_get_psu_out_status_str(unsigned int psu_index, char *buf, size_t count) +{ + int ret; + int output_key, output_status; + + if (buf == NULL) { + DFD_PSU_DEBUG(DBG_ERROR, "params error, psu_index: %u", psu_index); + return -EINVAL; + } + if (count <= 0) { + DFD_PSU_DEBUG(DBG_ERROR, "buf size error, count: %lu, psu index: %u\n", + count, psu_index); + return -EINVAL; + } + + output_key = DFD_CFG_KEY(DFD_CFG_ITEM_PSU_STATUS, psu_index, DFD_PSU_OUTPUT_STATUS); + ret = dfd_info_get_int(output_key, &output_status, NULL); + if (ret < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "get psu out status error, ret: %d, psu_index: %u\n", + ret, psu_index); + return -EIO; + } + memset(buf, 0, count); + return (ssize_t)snprintf(buf, count, "%d\n", output_status); +} + +ssize_t dfd_get_psu_in_status_str(unsigned int psu_index, char *buf, size_t count) +{ + if (buf == NULL) { + DFD_PSU_DEBUG(DBG_ERROR, "params error, psu_index: %u", psu_index); + return -EINVAL; + } + if (count <= 0) { + DFD_PSU_DEBUG(DBG_ERROR, "buf size error, count: %lu, psu index: %u\n", + count, psu_index); + return -EINVAL; + } + + memset(buf, 0 , count); + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); +} + +static int dfd_psu_product_name_decode(int power_type, char *psu_buf, int buf_len) +{ + int key; + char *p_decode_name; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_DECODE_POWER_NAME, power_type, 0); + p_decode_name = dfd_ko_cfg_get_item(key); + if (p_decode_name == NULL) { + DFD_PSU_DEBUG(DBG_ERROR, "config error, get psu decode name error, key: 0x%x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + memset(psu_buf, 0, buf_len); + strncpy(psu_buf, p_decode_name, buf_len - 1); + DFD_PSU_DEBUG(DBG_VERBOSE, "psu name match ok, display psu name: %s\n", psu_buf); + return DFD_RV_OK; +} + +static int dfd_psu_fan_direction_decode(int power_type, char *psu_buf, int buf_len) +{ + int key; + char *p_decode_direction; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_DECODE_POWER_FAN_DIR, power_type, 0); + p_decode_direction = dfd_ko_cfg_get_item(key); + if (p_decode_direction == NULL) { + DFD_PSU_DEBUG(DBG_ERROR, "config error, get psu decode direction error, key: 0x%x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + memset(psu_buf, 0, buf_len); + snprintf(psu_buf, buf_len, "%d", *p_decode_direction); + DFD_PSU_DEBUG(DBG_VERBOSE, "psu%u fan direction match ok, display psu direction: %s\n", + power_type, psu_buf); + return DFD_RV_OK; +} + +static int dfd_psu_max_output_power(int power_type, char *psu_buf, int buf_len) +{ + int key, value; + int *p_power_max_output_power; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_POWER_RSUPPLY, power_type, 0); + p_power_max_output_power = dfd_ko_cfg_get_item(key); + if (p_power_max_output_power == NULL) { + DFD_PSU_DEBUG(DBG_ERROR, "config error, get psu input type error, key: 0x%x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + value = *p_power_max_output_power; + memset(psu_buf, 0, buf_len); + snprintf(psu_buf, buf_len, "%d", value); + DFD_PSU_DEBUG(DBG_VERBOSE, "psu name %s match max output power %d\n", psu_buf, value); + return DFD_RV_OK; +} + +static int dfd_get_psu_type(unsigned int psu_index, dfd_i2c_dev_t *i2c_dev, int *power_type, + const char *sysfs_name) +{ + int rv; + char psu_buf[PSU_SIZE]; + + rv = dfd_get_fru_data(i2c_dev->bus, i2c_dev->addr, DFD_DEV_INFO_TYPE_PART_NUMBER, psu_buf, + PSU_SIZE, sysfs_name); + if (rv < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "get psu type from eeprom read failed, rv: %d\n", rv); + return -DFD_RV_DEV_FAIL; + } + + DFD_PSU_DEBUG(DBG_VERBOSE, "%s\n", psu_buf); + dfd_psu_del_no_print_string(psu_buf); + + DFD_PSU_DEBUG(DBG_VERBOSE, "dfd_psu_product_name_decode get psu name %s\n", psu_buf); + rv = dfd_ko_cfg_get_power_type_by_name((char *)psu_buf, power_type); + if (rv < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "get power type by name[%s] fail, rv: %d\n", psu_buf, rv); + return -DFD_RV_NO_NODE; + } + + DFD_PSU_DEBUG(DBG_VERBOSE, "get psu[%u] bus[%d] addr[0x%x] return power_type[0x%x]\n", + psu_index, i2c_dev->bus, i2c_dev->addr, *power_type); + return DFD_RV_OK; +} + +ssize_t dfd_get_psu_info(unsigned int psu_index, uint8_t cmd, char *buf, size_t count) +{ + int key, rv; + char psu_buf[PSU_SIZE]; + dfd_i2c_dev_t *i2c_dev; + int power_type; + const char *sysfs_name; + + if (buf == NULL) { + DFD_PSU_DEBUG(DBG_ERROR, "buf is NULL, psu index: %u, cmd: 0x%x\n", psu_index, cmd); + return -EINVAL; + } + if (count <= 0) { + DFD_PSU_DEBUG(DBG_ERROR, "buf size error, count: %lu, psu index: %u, cmd: 0x%x\n", + count, psu_index, cmd); + return -EINVAL; + } + + memset(buf, 0, count); + memset(psu_buf, 0, PSU_SIZE); + key = DFD_CFG_KEY(DFD_CFG_ITEM_OTHER_I2C_DEV, RG_MAIN_DEV_PSU, psu_index); + i2c_dev = dfd_ko_cfg_get_item(key); + if (i2c_dev == NULL) { + DFD_PSU_DEBUG(DBG_ERROR, "psu i2c dev config error, key: 0x%08x\n", key); + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + sysfs_name = dfd_get_psu_sysfs_name(); + if (cmd == DFD_DEV_INFO_TYPE_PART_NAME) { + rv = dfd_get_psu_type(psu_index, i2c_dev, &power_type, sysfs_name); + if (rv < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "psu get type error, rv: %d\n", rv); + return -EIO; + } + rv = dfd_psu_product_name_decode(power_type, psu_buf, PSU_SIZE); + if (rv < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "psu name decode error, power_type[0x%x] rv: %d\n", + power_type, rv); + return -EIO; + } + } else if (cmd == DFD_DEV_INFO_TYPE_FAN_DIRECTION) { + rv = dfd_get_psu_type(psu_index, i2c_dev, &power_type, sysfs_name); + if (rv < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "psu get type error, rv: %d\n", rv); + return -EIO; + } + rv = dfd_psu_fan_direction_decode(power_type, psu_buf, PSU_SIZE); + if (rv < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "psu input type decode error, power_type[0x%x] rv: %d\n", + power_type, rv); + return -EIO; + } + } else if (cmd == DFD_DEV_INFO_TYPE_MAX_OUTPUT_POWRER) { + rv = dfd_get_psu_type(psu_index, i2c_dev, &power_type, sysfs_name); + if (rv < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "psu get type error, rv:%d\n", rv); + return -EIO; + } + rv = dfd_psu_max_output_power(power_type, psu_buf, PSU_SIZE); + if (rv < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "psu max ouput power error, power_type[0x%x] rv: %d\n", + power_type, rv); + return -EIO; + } + } else { + rv = dfd_get_fru_data(i2c_dev->bus, i2c_dev->addr, cmd, psu_buf, PSU_SIZE, sysfs_name); + if (rv < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "psu eeprom read failed, rv: %d\n", rv); + return -EIO; + } + } + snprintf(buf, count, "%s\n", psu_buf); + return strlen(buf); +} + +static int dfd_get_psu_pmbus_id(unsigned int psu_index, uint8_t type, uint32_t *p_psu_pmbus_id) +{ + int key; + int *p_psu_pmbus_id_buf; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_PSU_PMBUS_ID, psu_index, type); + p_psu_pmbus_id_buf = dfd_ko_cfg_get_item(key); + if (p_psu_pmbus_id_buf == NULL) { + DFD_PSU_DEBUG(DBG_ERROR, "get psu pmbus id error, key: 0x%x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + + *p_psu_pmbus_id = *p_psu_pmbus_id_buf; + DFD_PSU_DEBUG(DBG_VERBOSE, "get psu pmbus id ok, psu index: %u, id: 0x%x\n", + psu_index, *p_psu_pmbus_id); + return DFD_RV_OK; +} + +static int dfd_get_psu_pmbus_byte(unsigned int psu_index, uint8_t cmd, uint8_t *buf) +{ + int rv; + uint8_t bus, offset; + uint16_t addr; + uint32_t p_psu_pmbus_id; + + if (buf == NULL) { + DFD_PSU_DEBUG(DBG_ERROR, "buf is NULL, psu index: %u, cmd: 0x%x\n", psu_index, cmd); + return -DFD_RV_INVALID_VALUE; + } + + rv = dfd_get_psu_pmbus_id(psu_index, cmd, &p_psu_pmbus_id); + if (rv < 0) { + DFD_PSU_DEBUG(DBG_WARN, "get psu%u pmbus %u info failed, rv: %d\n", psu_index, cmd, rv); + return -DFD_RV_DEV_NOTSUPPORT; + } + + bus = RG_GET_PSU_PMBUS_BUS(p_psu_pmbus_id); + addr = RG_GET_PSU_PMBUS_ADDR(p_psu_pmbus_id); + offset = RG_GET_PSU_PMBUS_OFFSET(p_psu_pmbus_id); + rv = dfd_ko_i2c_read(bus, addr, offset, buf, 1, NULL); + if (rv < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "read psu%u pmbus %u info(bus: %d, addr: 0x%02x, offset:%d) failed, rv: %d\n", + psu_index, cmd, bus, addr, offset, rv); + return -DFD_RV_DEV_FAIL; + } + return DFD_RV_OK; +} + +ssize_t dfd_get_psu_input_type(unsigned int psu_index, char *buf, size_t count) +{ + int ret; + uint8_t data; + + if (buf == NULL) { + DFD_PSU_DEBUG(DBG_ERROR, "buf is NULL, psu index: %u\n", psu_index); + return -EINVAL; + } + if (count <= 0) { + DFD_PSU_DEBUG(DBG_ERROR, "buf size error, count: %lu, psu index: %u\n", count, psu_index); + return -EINVAL; + } + + ret = dfd_get_psu_pmbus_byte(psu_index, PSU_IN_TYPE, &data); + if (ret == -DFD_RV_DEV_NOTSUPPORT) { + DFD_PSU_DEBUG(DBG_WARN, "get psu%u pmbus type info don't support\n", psu_index); + return snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } else if (ret < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "get psu%u pmbus type info failed, ret: %d\n", psu_index, ret); + return -EIO; + } + + if (data == DFD_PSU_PMBUS_TYPE_AC) { + return snprintf(buf, count, "%d\n", DFD_PSU_SYSFS_TYPE_AC); + } else if (data == DFD_PSU_PMBUS_TYPE_DC) { + return snprintf(buf, count, "%d\n", DFD_PSU_SYSFS_TYPE_DC); + } + + DFD_PSU_DEBUG(DBG_ERROR, "get psu%u pmbus type data[%u] unknow, ret: %d\n", + psu_index, data, ret); + return -EIO; +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_sensors_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_sensors_driver.c new file mode 100644 index 000000000000..0a4b92497bea --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_sensors_driver.c @@ -0,0 +1,230 @@ +/* + * Copyright(C) 2001-2022 Ruijie Network. All rights reserved. + */ +/* + * rg_sensor_driver.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * History + * [Version] [Author] [Date] [Description] + * * v1.0 sonic_rd@ruijie.com.cn 2020-02-17 Initial version + */ + +#include +#include + +#include "rg_module.h" +#include "dfd_cfg.h" +#include "dfd_cfg_adapter.h" +#include "dfd_cfg_info.h" +#include "dfd_frueeprom.h" +#include "dfd_cfg_file.h" + +#define DFD_GET_TEMP_SENSOR_KEY1(dev_index, temp_index) \ + (((dev_index & 0xff) << 8) | (temp_index & 0xff)) +#define DFD_GET_TEMP_SENSOR_KEY2(main_dev_id, temp_type) \ + (((main_dev_id & 0x0f) << 4) | (temp_type & 0x0f)) +#define DFD_FORMAT_STR_MAX_LEN (32) + +int g_dfd_sensor_dbg_level = 0; +module_param(g_dfd_sensor_dbg_level, int, S_IRUGO | S_IWUSR); + +static int dfd_deal_hwmon_buf(uint8_t *buf, int buf_len, uint8_t *buf_new, int *buf_len_new, + info_ctrl_t *info_ctrl, int coefficient, int addend) +{ + int i, tmp_len; + int exp, decimal, divisor; + int org_value, tmp_value; + int div_result, div_mod; + char fmt_str[DFD_FORMAT_STR_MAX_LEN]; + + exp = info_ctrl->int_cons; + decimal = info_ctrl->bit_offset; + + if (exp <= 0) { + DBG_DEBUG(DBG_VERBOSE, "exponent %d, don't need transform, buf_len: %d, buf_len_new: %d\n", + exp, buf_len, *buf_len_new); + snprintf(buf_new, *buf_len_new, "%s", buf); + *buf_len_new = strlen(buf_new); + return DFD_RV_OK; + } + divisor = 1; + for (i = 0; i < exp; i++) { + divisor *= 10; + } + org_value = simple_strtol(buf, NULL, 10); + org_value = (org_value + addend) * coefficient; + if (org_value < 0) { + tmp_value = 0 - org_value; + } else { + tmp_value = org_value; + } + div_result = tmp_value / divisor; + div_mod = tmp_value % divisor; + DBG_DEBUG(DBG_VERBOSE, "exp: %d, decimal: %d, original value: %d, coefficient: %d, \ + divisor: %d, result: %d, mod: %d\n", exp, decimal, org_value, coefficient, divisor, + div_result, div_mod); + + if (decimal == 0) { + snprintf(buf_new, *buf_len_new, "%d\n", div_result); + *buf_len_new = strlen(buf_new); + return DFD_RV_OK; + } + memset(fmt_str, 0, sizeof(fmt_str)); + if (org_value < 0) { + snprintf(fmt_str, sizeof(fmt_str), "-%%d.%%0%dd\n",exp); + } else { + snprintf(fmt_str, sizeof(fmt_str), "%%d.%%0%dd\n",exp); + } + DBG_DEBUG(DBG_VERBOSE, "format string: %s",fmt_str); + snprintf(buf_new, *buf_len_new, fmt_str, div_result, div_mod); + *buf_len_new = strlen(buf_new); + tmp_len = *buf_len_new; + + if (decimal > 0) { + for (i = 0; i < *buf_len_new; i++) { + if (buf_new[i] == '.') { + if ( i + decimal + 2 <= *buf_len_new ) { + buf_new[i + decimal + 1 ] = '\n'; + buf_new[i + decimal + 2 ] = '\0'; + *buf_len_new = strlen(buf_new); + DBG_DEBUG(DBG_VERBOSE, "deal decimal[%d] ok, str len:%d, value:%s\n", + decimal, *buf_len_new, buf_new); + } + break; + } + } + if (tmp_len == *buf_len_new) { + DBG_DEBUG(DBG_WARN, "deal decimal[%d] failed, use original value:%s\n", decimal, + buf_new); + } + } + return DFD_RV_OK; +} + +static int dfd_get_sensor_info(uint8_t main_dev_id, uint8_t dev_index, uint8_t sensor_type, + uint8_t sensor_index, uint8_t sensor_attr, char *buf, size_t count) +{ + uint32_t key; + uint16_t key_index1; + uint8_t key_index2; + int rv; + info_hwmon_buf_f pfunc; + + key_index1 = DFD_GET_TEMP_SENSOR_KEY1(dev_index, sensor_index); + key_index2 = DFD_GET_TEMP_SENSOR_KEY2(main_dev_id, sensor_attr); + if (sensor_type == RG_MINOR_DEV_TEMP ) { + key = DFD_CFG_KEY(DFD_CFG_ITEM_HWMON_TEMP, key_index1, key_index2); + } else if (sensor_type == RG_MINOR_DEV_IN) { + key = DFD_CFG_KEY(DFD_CFG_ITEM_HWMON_IN, key_index1, key_index2); + }else if (sensor_type == RG_MINOR_DEV_CURR) { + key = DFD_CFG_KEY(DFD_CFG_ITEM_HWMON_CURR, key_index1, key_index2); + } else { + DFD_SENSOR_DEBUG(DBG_ERROR, "Unknow sensor type: %u\n",sensor_type); + return -DFD_RV_INVALID_VALUE; + } + + DFD_SENSOR_DEBUG(DBG_VERBOSE, "main_dev_id: %u, dev_index: 0x%x, sensor_index: 0x%x, \ + sensor_attr: 0x%x, key: 0x%x\n", main_dev_id, dev_index, sensor_index, sensor_attr, key); + + pfunc = dfd_deal_hwmon_buf; + rv = dfd_info_get_sensor(key, buf, count, pfunc); + return rv; +} + +ssize_t dfd_get_temp_info(uint8_t main_dev_id, uint8_t dev_index, uint8_t temp_index, + uint8_t temp_attr, char *buf, size_t count) +{ + int rv; + + if (buf == NULL) { + DFD_SENSOR_DEBUG(DBG_ERROR, "param error, buf is NULL\n"); + return -DFD_RV_INVALID_VALUE; + } + + if (count <= 0) { + DFD_SENSOR_DEBUG(DBG_ERROR, "buf size error, count: %lu\n", count); + return -DFD_RV_INVALID_VALUE; + } + + rv = dfd_get_sensor_info(main_dev_id, dev_index, RG_MINOR_DEV_TEMP, temp_index, temp_attr, + buf, count); + if (rv < 0) { + DFD_SENSOR_DEBUG(DBG_ERROR, "get temp info error, rv: %d\n", rv); + } else { + DFD_SENSOR_DEBUG(DBG_VERBOSE, "get temp info success, value: %s\n", buf); + } + return rv; +} + +ssize_t dfd_get_voltage_info(uint8_t main_dev_id, uint8_t dev_index, uint8_t in_index, + uint8_t in_attr, char *buf, size_t count) +{ + int rv; + + if (buf == NULL) { + DFD_SENSOR_DEBUG(DBG_ERROR, "param error buf is NULL.\n"); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DFD_SENSOR_DEBUG(DBG_ERROR, "buf size error, count: %lu\n", count); + return -DFD_RV_INVALID_VALUE; + } + rv = dfd_get_sensor_info(main_dev_id, dev_index, RG_MINOR_DEV_IN, in_index, in_attr, buf, + count); + if (rv < 0) { + DFD_SENSOR_DEBUG(DBG_ERROR, "get voltage info error, rv: %d\n", rv); + } else { + DFD_SENSOR_DEBUG(DBG_VERBOSE, "get voltage info success, value: %s\n", buf); + } + return rv; +} + +ssize_t dfd_get_current_info(uint8_t main_dev_id, uint8_t dev_index, uint8_t curr_index, + uint8_t curr_attr, char *buf, size_t count) +{ + int rv; + + if (buf == NULL) { + DFD_SENSOR_DEBUG(DBG_ERROR, "param error buf is NULL.\n"); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DFD_SENSOR_DEBUG(DBG_ERROR, "buf size error, count: %lu\n", count); + return -DFD_RV_INVALID_VALUE; + } + rv = dfd_get_sensor_info(main_dev_id, dev_index, RG_MINOR_DEV_CURR, curr_index, curr_attr, + buf, count); + if (rv < 0) { + DFD_SENSOR_DEBUG(DBG_ERROR, "get current info error, rv: %d\n", rv); + } else { + DFD_SENSOR_DEBUG(DBG_VERBOSE, "get current info success, value: %s\n", buf); + } + return rv; +} + +ssize_t dfd_get_psu_sensor_info(uint8_t psu_index, uint8_t sensor_type, char *buf, size_t count) +{ + int rv, key; + info_hwmon_buf_f pfunc; + + if (buf == NULL) { + DFD_SENSOR_DEBUG(DBG_ERROR, "param error. buf is NULL.\n"); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DFD_SENSOR_DEBUG(DBG_ERROR, "buf size error, count: %lu\n", count); + return -DFD_RV_INVALID_VALUE; + } + key = DFD_CFG_KEY(DFD_CFG_ITEM_HWMON_PSU, psu_index, sensor_type); + DFD_SENSOR_DEBUG(DBG_VERBOSE, "psu index: %d, sensor type: %d, key: 0x%x,\n", psu_index, + sensor_type, key); + pfunc = dfd_deal_hwmon_buf; + rv = dfd_info_get_sensor(key, buf, count, pfunc); + if (rv < 0) { + DFD_SENSOR_DEBUG(DBG_ERROR, "get psu sensor info error, key: 0x%x, rv: %d\n", key, rv); + } else { + DFD_SENSOR_DEBUG(DBG_VERBOSE, "get psu sensor info success, value: %s\n", buf); + } + return rv; +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_sff_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_sff_driver.c new file mode 100644 index 000000000000..3a05b131d4a0 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_sff_driver.c @@ -0,0 +1,69 @@ +/* + * Copyright(C) 2001-2022 Ruijie Network. All rights reserved. + */ +/* + * rg_sff_driver.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * History + * [Version] [Author] [Date] [Description] + * * v1.0 sonic_rd@ruijie.com.cn 2020-02-17 Initial version + */ + +#include + +#include "rg_module.h" +#include "dfd_cfg.h" +#include "dfd_cfg_info.h" +#include "dfd_cfg_adapter.h" + +int g_dfd_sff_dbg_level = 0; +module_param(g_dfd_sff_dbg_level, int, S_IRUGO | S_IWUSR); + +int dfd_set_sff_cpld_info(unsigned int sff_index, int cpld_reg_type, int value) +{ + int key, ret; + + if ((value != 0) && (value != 1)) { + DFD_SFF_DEBUG(DBG_ERROR, "sff%u cpld reg type %d, can't set invalid value: %d\n", + sff_index, cpld_reg_type, value); + return -DFD_RV_INVALID_VALUE; + } + key = DFD_CFG_KEY(DFD_CFG_ITEM_SFF_CPLD_REG, sff_index, cpld_reg_type); + ret = dfd_info_set_int(key, value); + if (ret < 0) { + DFD_SFF_DEBUG(DBG_ERROR, "set sff%u cpld reg type %d error, key: 0x%x, ret: %d.\n", + sff_index, cpld_reg_type, key, ret); + return ret; + } + + return DFD_RV_OK; +} + +ssize_t dfd_get_sff_cpld_info(unsigned int sff_index, int cpld_reg_type, char *buf, size_t count) +{ + int key, ret, value; + + if (buf == NULL) { + DFD_SFF_DEBUG(DBG_ERROR, "param error, buf is NULL. sff_index: %u, cpld_reg_type: %d\n", + sff_index, cpld_reg_type); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DFD_SFF_DEBUG(DBG_ERROR, "buf size error, count: %lu, sff index: %u, cpld_reg_type: %d\n", + count, sff_index, cpld_reg_type); + return -DFD_RV_INVALID_VALUE; + } + memset(buf, 0 , count); + key = DFD_CFG_KEY(DFD_CFG_ITEM_SFF_CPLD_REG, sff_index, cpld_reg_type); + ret = dfd_info_get_int(key, &value, NULL); + if (ret < 0) { + DFD_SFF_DEBUG(DBG_ERROR, "get sff%u cpld reg type %d error, key: 0x%x, ret: %d\n", + sff_index, cpld_reg_type, key, ret); + if (ret == -DFD_RV_DEV_NOTSUPPORT) { + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + return ret; + } + return (ssize_t)snprintf(buf, count, "%d\n", value); +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_slot_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_slot_driver.c new file mode 100644 index 000000000000..ee934fd5d47d --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_slot_driver.c @@ -0,0 +1,104 @@ +/* + * Copyright(C) 2001-2022 Ruijie Network. All rights reserved. + */ +/* + * rg_slot_driver.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * History + * [Version] [Author] [Date] [Description] + * * v1.0 sonic_rd@ruijie.com.cn 2020-02-17 Initial version + */ + +#include +#include + +#include "rg_module.h" +#include "dfd_cfg.h" +#include "dfd_cfg_adapter.h" +#include "dfd_cfg_info.h" +#include "dfd_frueeprom.h" + +#define SLOT_SIZE (256) + +int g_dfd_slot_dbg_level = 0; +module_param(g_dfd_slot_dbg_level, int, S_IRUGO | S_IWUSR); + +static char *dfd_get_slot_sysfs_name(void) +{ + int key; + char *sysfs_name; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_SLOT_SYSFS_NAME, 0, 0); + sysfs_name = dfd_ko_cfg_get_item(key); + if (sysfs_name == NULL) { + DFD_SLOT_DEBUG(DBG_VERBOSE, "key=0x%08x, sysfs_name is NULL, use default way.\n", key); + } else { + DFD_SLOT_DEBUG(DBG_VERBOSE, "sysfs_name: %s.\n", sysfs_name); + } + return sysfs_name; +} + +static int dfd_get_slot_status(unsigned int slot_index) +{ + int key, ret; + int status; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_DEV_PRESENT_STATUS, RG_MAIN_DEV_SLOT, slot_index); + ret = dfd_info_get_int(key, &status, NULL); + if (ret < 0) { + DFD_SLOT_DEBUG(DBG_ERROR, "get slot status error, key:0x%x\n",key); + return ret; + } + return status; +} + +ssize_t dfd_get_slot_status_str(unsigned int slot_index, char *buf, size_t count) +{ + int ret; + if (buf == NULL) { + DFD_SLOT_DEBUG(DBG_ERROR, "params error.slot_index:%d.",slot_index); + return -DFD_RV_INVALID_VALUE; + } + ret = dfd_get_slot_status(slot_index); + if (ret < 0) { + DFD_SLOT_DEBUG(DBG_ERROR, "get slot status error,ret:%d, slot_index:%d\n", ret, slot_index); + return ret; + } + memset(buf, 0 , count); + return (ssize_t)snprintf(buf, count, "%d\n", ret); +} + +ssize_t dfd_get_slot_info(unsigned int slot_index, uint8_t cmd, char *buf, size_t count) +{ + int key, rv; + char slot_buf[SLOT_SIZE]; + dfd_i2c_dev_t *i2c_dev; + const char *sysfs_name; + + if (buf == NULL) { + DFD_SLOT_DEBUG(DBG_ERROR, "buf is NULL, slot index:%d, cmd:%d\n", slot_index, cmd); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, count); + memset(slot_buf, 0, SLOT_SIZE); + + key = DFD_CFG_KEY(DFD_CFG_ITEM_OTHER_I2C_DEV, RG_MAIN_DEV_SLOT, slot_index); + i2c_dev = dfd_ko_cfg_get_item(key); + if (i2c_dev == NULL) { + DFD_SLOT_DEBUG(DBG_ERROR, "slot i2c dev config error, key=0x%08x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + sysfs_name = dfd_get_slot_sysfs_name(); + rv = dfd_get_fru_board_data(i2c_dev->bus, i2c_dev->addr, cmd, slot_buf, SLOT_SIZE, sysfs_name); + + if (rv < 0) { + DFD_SLOT_DEBUG(DBG_ERROR, "slot eeprom read failed"); + return -DFD_RV_DEV_FAIL; + } + + DFD_SLOT_DEBUG(DBG_VERBOSE, "%s\n", slot_buf); + snprintf(buf, count, "%s\n", slot_buf); + return strlen(buf); +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_watchdog_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_watchdog_driver.c new file mode 100644 index 000000000000..2207ebf7cf54 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_watchdog_driver.c @@ -0,0 +1,155 @@ +/* + * Copyright(C) 2001-2022 Ruijie Network. All rights reserved. + */ +/* + * rg_watchdog_driver.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * History + * [Version] [Author] [Date] [Description] + * * v1.0 sonic_rd@ruijie.com.cn 2021-09-05 S3IP sysfs Initial version + */ + +#include +#include +#include + +#include "rg_module.h" +#include "dfd_cfg.h" +#include "dfd_cfg_info.h" +#include "dfd_cfg_adapter.h" + +#define WDT_FILE_NAME_LEN (64) +#define WDT_ABSOLUTE_PATH_NAME_LEN (256) +#define WDT_SYSFS_FILE_DIR ("/sys/class/watchdog/watchdog%d/") + +typedef enum rg_wdt_enable_status_e { + RG_WDT_DISENABLE = 0, /* close watchdog */ + RG_WDT_ENABLE = 1, /* open watchdog */ +} rg_wdt_enable_status_t; + +struct wdt_file_enable_status_s { + rg_wdt_enable_status_t value; + char state[WDT_FILE_NAME_LEN]; +}; + +struct wdt_file_enable_status_s wdt_file_enable_status_match[] = { + {RG_WDT_DISENABLE, "inactive"}, + {RG_WDT_ENABLE, "active"}, +}; + +int g_dfd_watchdog_dbg_level = 0; +module_param(g_dfd_watchdog_dbg_level, int, S_IRUGO | S_IWUSR); + +static int watchdog_file_read(char *fpath, char *buf, int size) +{ + int ret; + struct file *filp; + loff_t pos; + + filp = filp_open(fpath, O_RDONLY, 0); + if (IS_ERR(filp)) { + DFD_WDT_DEBUG(DBG_ERROR, "watchdog can't open %s.\n", fpath); + filp = NULL; + ret = -ENOENT; + return ret; + } + + memset(buf, 0, size); + pos = 0; + ret = kernel_read(filp, buf, size - 1, &pos); + if (ret < 0) { + DFD_WDT_DEBUG(DBG_ERROR, "kernel_read failed, path=%s, addr=0, size=%d, ret=%d\n", + fpath, size -1, ret); + } + + filp_close(filp, NULL); + filp = NULL; + return ret; +} + +static int dfd_get_watchdog_id(unsigned int wdt_index) +{ + int key; + int *p_watchdog_id; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_WATCHDOG_ID, wdt_index, 0); + p_watchdog_id = dfd_ko_cfg_get_item(key); + if (p_watchdog_id == NULL) { + DFD_WDT_DEBUG(DBG_ERROR, "get watchdog id error, key: 0x%x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + DFD_WDT_DEBUG(DBG_VERBOSE, "get watchdog id ok, watchdog index:%u, id:0x%x.\n", + wdt_index, *p_watchdog_id); + return *p_watchdog_id; +} + +static int watchdog_get_file_name(unsigned int wdt_index, rg_wdt_type_t type, char *buf, int len) +{ + int key; + char *watchdog_name; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_WATCHDOG_NAME, wdt_index, type); + watchdog_name = dfd_ko_cfg_get_item(key); + if (watchdog_name == NULL) { + DFD_WDT_DEBUG(DBG_ERROR, "watchdog name config error, key: 0x%08x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + + DFD_WDT_DEBUG(DBG_VERBOSE, "get watchdog%u %s\n", wdt_index, watchdog_name); + snprintf(buf, len, "%s", watchdog_name); + return DFD_RV_OK; +} + +ssize_t dfd_get_watchdog_info(uint8_t type, char *buf, size_t count) +{ + char fpath[WDT_ABSOLUTE_PATH_NAME_LEN]; + int watchdog_id, len, ret; + + watchdog_id = dfd_get_watchdog_id(0); + memset(fpath, 0, WDT_ABSOLUTE_PATH_NAME_LEN); + snprintf(fpath, WDT_ABSOLUTE_PATH_NAME_LEN - 1, WDT_SYSFS_FILE_DIR, watchdog_id); + len = strlen(fpath); + ret = watchdog_get_file_name(watchdog_id, type, &fpath[len], WDT_ABSOLUTE_PATH_NAME_LEN - len); + if (ret < 0) { + DFD_WDT_DEBUG(DBG_WARN, "watchdog type[%u] don't support to get sysfs name.\n", type); + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + + ret = watchdog_file_read(fpath, buf, count - 1); + if (ret < 0) { + DFD_WDT_DEBUG(DBG_ERROR, "watchdog read file %s error, ret: %d\n", fpath, ret); + } + + return ret; +} + +ssize_t dfd_watchdog_get_status_str(char *buf, size_t count) +{ + int ret, i; + int enable_status; + + ret = dfd_get_watchdog_info(RG_WDT_TYPE_STATE, buf, count); + if (ret < 0) { + DFD_WDT_DEBUG(DBG_ERROR, "watchdog type[%d] get sysfs name failed.\n", RG_WDT_TYPE_STATE); + return -DFD_RV_DEV_FAIL; + } + + enable_status = -1; + for (i = 0; i < ARRAY_SIZE(wdt_file_enable_status_match); i++) { + if (strncmp(wdt_file_enable_status_match[i].state, buf, \ + strlen(wdt_file_enable_status_match[i].state)) == 0) { + enable_status = wdt_file_enable_status_match[i].value; + DFD_WDT_DEBUG(DBG_VERBOSE, "watchdog read state file %s match enable status[%d].\n", + buf, enable_status); + break; + } + } + + if (enable_status < 0) { + DFD_WDT_DEBUG(DBG_ERROR, "watchdog read state file %s don't match enable status\n", buf); + return -DFD_RV_DEV_FAIL; + } + + return (ssize_t)snprintf(buf, count, "%d\n", enable_status); +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/switch_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/switch_driver.c new file mode 100644 index 000000000000..bdef9840a9dc --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/switch_driver.c @@ -0,0 +1,2546 @@ +/* + * switch_driver.c + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ +#include + +#include "dfd_sysfs_common.h" +#include "switch_driver.h" +#include "rg_module.h" +#include "rg_fan_driver.h" +#include "rg_eeprom_driver.h" +#include "rg_cpld_driver.h" +#include "rg_fpga_driver.h" +#include "rg_led_driver.h" +#include "rg_slot_driver.h" +#include "rg_sensors_driver.h" +#include "rg_psu_driver.h" +#include "rg_sff_driver.h" +#include "rg_watchdog_driver.h" + +int g_switch_dbg_level = 0; + +/* change the following parameter by your switch. */ +#define MAIN_BOARD_TEMP_SENSOR_NUMBER (10) +#define MAIN_BOARD_VOL_SENSOR_NUMBER (10) +#define MAIN_BOARD_CURR_SENSOR_NUMBER (0) +#define SYSEEPROM_SIZE (256) +#define FAN_NUMBER (6) +#define FAN_MOTOR_NUMBER (2) +#define PSU_NUMBER (2) +#define PSU_TEMP_SENSOR_NUMBER (3) +#define ETH_NUMBER (32) +#define ETH_EEPROM_SIZE (0x8180) +#define MAIN_BOARD_FPGA_NUMBER (1) +#define MAIN_BOARD_CPLD_NUMBER (5) +#define SLOT_NUMBER (0) +#define SLOT_TEMP_NUMBER (0) +#define SLOT_VOL_NUMBER (0) +#define SLOT_CURR_NUMBER (0) +#define SLOT_FPGA_NUMBER (0) +#define SLOT_CPLD_NUMBER (0) + +/***************************************main board temp*****************************************/ +/* + * dfd_get_main_board_temp_number - Used to get main board temperature sensors number, + * + * This function returns main board temperature sensors by your switch, + * If there is no main board temperature sensors, returns 0, + * otherwise it returns a negative value on failed. + */ +static int dfd_get_main_board_temp_number(void) +{ + int ret; + + ret = dfd_get_dev_number(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_TEMP); + return ret; +} + +/* + * dfd_get_main_board_temp_alias - Used to identify the location of the temperature sensor, + * such as air_inlet, air_outlet and so on. + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_temp_alias(unsigned int temp_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_temp_info(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE, temp_index, RG_SENSOR_ALIAS, + buf, count); + return ret; +} + +/* + * dfd_get_main_board_temp_type - Used to get the model of temperature sensor, + * such as lm75, tmp411 and so on + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_temp_type(unsigned int temp_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_temp_info(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE, temp_index, RG_SENSOR_TYPE, + buf, count); + return ret; +} + +/* + * dfd_get_main_board_temp_max - Used to get the maximum threshold of temperature sensor + * filled the value to buf, the value is integer with millidegree Celsius + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_temp_max(unsigned int temp_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_temp_info(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE, temp_index, RG_SENSOR_MAX, + buf, count); + return ret; +} + +/* + * dfd_get_main_board_temp_min - Used to get the minimum threshold of temperature sensor + * filled the value to buf, the value is integer with millidegree Celsius + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_temp_min(unsigned int temp_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_temp_info(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE, temp_index, RG_SENSOR_MIN, + buf, count); + return ret; +} + +/* + * dfd_get_main_board_temp_value - Used to get the input value of temperature sensor + * filled the value to buf, the value is integer with millidegree Celsius + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_temp_value(unsigned int temp_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_temp_info(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE, temp_index, RG_SENSOR_INPUT, + buf, count); + return ret; +} +/***********************************end of main board temp*************************************/ + +/*************************************main board voltage***************************************/ +static int dfd_get_main_board_vol_number(void) +{ + int ret; + + ret = dfd_get_dev_number(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_IN); + return ret; +} + +/* + * dfd_get_main_board_vol_alias - Used to identify the location of the voltage sensor, + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_vol_alias(unsigned int vol_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_voltage_info(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE, vol_index, RG_SENSOR_ALIAS, + buf, count); + return ret; +} + +/* + * dfd_get_main_board_vol_type - Used to get the model of voltage sensor, + * such as udc90160, tps53622 and so on + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_vol_type(unsigned int vol_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_voltage_info(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE, vol_index, RG_SENSOR_TYPE, + buf, count); + return ret; +} + +/* + * dfd_get_main_board_vol_max - Used to get the maximum threshold of voltage sensor + * filled the value to buf, the value is integer with mV + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_vol_max(unsigned int vol_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_voltage_info(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE, vol_index, RG_SENSOR_MAX, + buf, count); + return ret; +} + +/* + * dfd_get_main_board_vol_min - Used to get the minimum threshold of voltage sensor + * filled the value to buf, the value is integer with mV + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_vol_min(unsigned int vol_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_voltage_info(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE, vol_index, RG_SENSOR_MIN, + buf, count); + return ret; +} + +/* + * dfd_get_main_board_vol_range - Used to get the output error value of voltage sensor + * filled the value to buf + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_vol_range(unsigned int vol_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_voltage_info(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE, vol_index, + RG_SENSOR_RANGE, buf, count); + return ret; +} + +/* + * dfd_get_main_board_vol_nominal_value - Used to get the nominal value of voltage sensor + * filled the value to buf + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_vol_nominal_value(unsigned int vol_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_voltage_info(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE, vol_index, + RG_SENSOR_NOMINAL_VAL, buf, count); + return ret; +} + +/* + * dfd_get_main_board_vol_value - Used to get the input value of voltage sensor + * filled the value to buf, the value is integer with mV + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_vol_value(unsigned int vol_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_voltage_info(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE, vol_index, RG_SENSOR_INPUT, + buf, count); + return ret; +} +/*********************************end of main board voltage************************************/ +/*************************************main board current***************************************/ +static int dfd_get_main_board_curr_number(void) +{ + int ret; + + ret = dfd_get_dev_number(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_CURR); + return ret; +} + +/* + * dfd_get_main_board_curr_alias - Used to identify the location of the current sensor, + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_curr_alias(unsigned int curr_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_current_info(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE, curr_index, RG_SENSOR_ALIAS, + buf, count); + return ret; +} + +/* + * dfd_get_main_board_curr_type - Used to get the model of current sensor, + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_curr_type(unsigned int curr_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_current_info(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE, curr_index, RG_SENSOR_TYPE, + buf, count); + return ret; +} + +/* + * dfd_get_main_board_curr_max - Used to get the maximum threshold of current sensor + * filled the value to buf, the value is integer with mA + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_curr_max(unsigned int curr_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_current_info(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE, curr_index, RG_SENSOR_MAX, + buf, count); + return ret; +} + +/* + * dfd_get_main_board_curr_min - Used to get the minimum threshold of current sensor + * filled the value to buf, the value is integer with mA + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_curr_min(unsigned int curr_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_current_info(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE, curr_index, RG_SENSOR_MIN, + buf, count); + return ret; +} + +/* + * dfd_get_main_board_curr_value - Used to get the input value of current sensor + * filled the value to buf, the value is integer with mA + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_curr_value(unsigned int curr_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_current_info(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE, curr_index, RG_SENSOR_INPUT, + buf, count); + return ret; +} +/*********************************end of main board current************************************/ + +/*****************************************syseeprom*******************************************/ +/* + * dfd_get_syseeprom_size - Used to get syseeprom size + * + * This function returns the size of syseeprom by your switch, + * otherwise it returns a negative value on failed. + */ +static int dfd_get_syseeprom_size(void) +{ + int ret; + + ret = dfd_get_eeprom_size(RG_MAIN_DEV_MAINBOARD, 0); + return ret; +} + +/* + * dfd_read_syseeprom_data - Used to read syseeprom data, + * @buf: Data read buffer + * @offset: offset address to read syseeprom data + * @count: length of buf + * + * This function returns the length of the filled buffer, + * returns 0 means EOF, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_read_syseeprom_data(char *buf, loff_t offset, size_t count) +{ + ssize_t ret; + + ret = dfd_read_eeprom_data(RG_MAIN_DEV_MAINBOARD, 0, buf, offset, count); + return ret; +} + +/* + * dfd_write_syseeprom_data - Used to write syseeprom data + * @buf: Data write buffer + * @offset: offset address to write syseeprom data + * @count: length of buf + * + * This function returns the written length of syseeprom, + * returns 0 means EOF, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_write_syseeprom_data(char *buf, loff_t offset, size_t count) +{ + ssize_t ret; + + ret = dfd_write_eeprom_data(RG_MAIN_DEV_MAINBOARD, 0, buf, offset, count); + return ret; +} +/*************************************end of syseeprom****************************************/ + +/********************************************fan**********************************************/ +static int dfd_get_fan_number(void) +{ + int ret; + + ret = dfd_get_dev_number(RG_MAIN_DEV_FAN, RG_MINOR_DEV_NONE); + return ret; +} + +static int dfd_get_fan_motor_number(unsigned int fan_index) +{ + int ret; + + ret = dfd_get_dev_number(RG_MAIN_DEV_FAN, RG_MINOR_DEV_MOTOR); + return ret; +} + +/* + * dfd_get_fan_model_name - Used to get fan model name, + * @fan_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_fan_model_name(unsigned int fan_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fan_info(fan_index, DFD_DEV_INFO_TYPE_NAME, buf, count); + return ret; +} + +/* + * dfd_get_fan_serial_number - Used to get fan serial number, + * @fan_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_fan_serial_number(unsigned int fan_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fan_info(fan_index, DFD_DEV_INFO_TYPE_SN, buf, count); + return ret; +} + +/* + * dfd_get_fan_part_number - Used to get fan part number, + * @fan_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_fan_part_number(unsigned int fan_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fan_info(fan_index, DFD_DEV_INFO_TYPE_PART_NUMBER, buf, count); + return ret; +} + +/* + * dfd_get_fan_hardware_version - Used to get fan hardware version, + * @fan_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_fan_hardware_version(unsigned int fan_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fan_info(fan_index, DFD_DEV_INFO_TYPE_HW_INFO, buf, count); + return ret; +} + +/* + * dfd_get_fan_status - Used to get fan status, + * filled the value to buf, fan status define see enum status_e + * @fan_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_fan_status(unsigned int fan_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fan_status_str(fan_index, buf, count); + return ret; +} + +/* + * dfd_get_fan_led_status - Used to get fan led status + * filled the value to buf, led status value define see enum fan_status_e + * @fan_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_fan_led_status(unsigned int fan_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_led_status(RG_FAN_LED_MODULE, fan_index, buf, count); + return ret; +} + +/* + * dfd_set_fan_led_status - Used to set fan led status + * @fan_index: start with 1 + * @status: led status, led status value define see enum led_status_e + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int dfd_set_fan_led_status(unsigned int fan_index, int status) +{ + int ret; + + ret = dfd_set_led_status(RG_FAN_LED_MODULE, fan_index, status); + return ret; +} + +/* + * dfd_get_fan_direction - Used to get fan air flow direction, + * filled the value to buf, air flow direction define see enum air_flow_direction_e + * @fan_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_fan_direction(unsigned int fan_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fan_direction_str(fan_index, buf, count); + return ret; +} + +/* + * dfd_get_fan_motor_speed - Used to get fan motor speed + * filled the value to buf + * @fan_index: start with 1 + * @motor_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_fan_motor_speed(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fan_speed_str(fan_index, motor_index, buf, count); + return ret; +} + +/* + * dfd_get_fan_motor_speed_tolerance - Used to get fan motor speed tolerance + * filled the value to buf + * @fan_index: start with 1 + * @motor_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_fan_motor_speed_tolerance(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fan_motor_speed_tolerance_str(fan_index, motor_index, buf, count); + return ret; +} + +/* + * dfd_get_fan_motor_speed_target - Used to get fan motor speed target + * filled the value to buf + * @fan_index: start with 1 + * @motor_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_fan_motor_speed_target(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fan_motor_speed_target_str(fan_index, motor_index, buf, count); + return ret; +} + +/* + * dfd_get_fan_motor_speed_max - Used to get the maximum threshold of fan motor + * filled the value to buf + * @fan_index: start with 1 + * @motor_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_fan_motor_speed_max(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fan_motor_speed_max_str(fan_index, motor_index, buf, count); + return ret; +} + +/* + * dfd_get_fan_motor_speed_min - Used to get the minimum threshold of fan motor + * filled the value to buf + * @fan_index: start with 1 + * @motor_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_fan_motor_speed_min(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fan_motor_speed_min_str(fan_index, motor_index, buf, count); + return ret; +} + +/* + * dfd_get_fan_ratio - Used to get the ratio of fan + * filled the value to buf + * @fan_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_fan_ratio(unsigned int fan_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fan_pwm_str(fan_index, buf, count); + return ret; +} + +/* + * dfd_set_fan_ratio - Used to set the ratio of fan + * @fan_index: start with 1 + * @ratio: motor speed ratio, from 0 to 100 + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int dfd_set_fan_ratio(unsigned int fan_index, int ratio) +{ + int ret; + + /* add vendor codes here */ + ret = dfd_set_fan_pwm(fan_index, ratio); + return ret; +} +/****************************************end of fan*******************************************/ +/********************************************psu**********************************************/ +static int dfd_get_psu_number(void) +{ + int ret; + + ret = dfd_get_dev_number(RG_MAIN_DEV_PSU, RG_MINOR_DEV_NONE); + return ret; +} + +static int dfd_get_psu_temp_number(unsigned int psu_index) +{ + int ret; + + ret = dfd_get_dev_number(RG_MAIN_DEV_PSU, RG_MINOR_DEV_TEMP); + return ret; +} + +/* Similar to dfd_get_psu_model_name */ +static ssize_t dfd_get_psu_model_name(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_psu_info(psu_index, DFD_DEV_INFO_TYPE_PART_NAME, buf, count); + return ret; +} + +/* Similar to rg_get_fan_serial_number */ +static ssize_t dfd_get_psu_serial_number(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_psu_info(psu_index, DFD_DEV_INFO_TYPE_SN, buf, count); + return ret; +} + +/* Similar to rg_get_fan_part_number */ +static ssize_t dfd_get_psu_part_number(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_psu_info(psu_index, DFD_DEV_INFO_TYPE_PART_NUMBER, buf, count); + return ret; +} + +/* Similar to rg_get_fan_hardware_version */ +static ssize_t dfd_get_psu_hardware_version(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_psu_info(psu_index, DFD_DEV_INFO_TYPE_HW_INFO, buf, count); + return ret; +} + +/* + * dfd_get_psu_type - Used to get the input type of psu + * filled the value to buf, input type value define see enum psu_input_type_e + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_psu_type(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_psu_input_type(psu_index, buf, count); + return ret; +} + +/* + * dfd_get_psu_in_curr - Used to get the input current of psu + * filled the value to buf, the value is integer with mA + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_psu_in_curr(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_psu_sensor_info(psu_index, PSU_IN_CURR, buf, count); + return ret; +} + +/* + * dfd_get_psu_in_vol - Used to get the input voltage of psu + * filled the value to buf, the value is integer with mV + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_psu_in_vol(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_psu_sensor_info(psu_index, PSU_IN_VOL, buf, count); + return ret; +} + +/* + * dfd_get_psu_in_power - Used to get the input power of psu + * filled the value to buf, the value is integer with uW + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_psu_in_power(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_psu_sensor_info(psu_index, PSU_IN_POWER, buf, count); + return ret; +} + +/* + * dfd_get_psu_out_curr - Used to get the output current of psu + * filled the value to buf, the value is integer with mA + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_psu_out_curr(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_psu_sensor_info(psu_index, PSU_OUT_CURR, buf, count); + return ret; +} + +/* + * dfd_get_psu_out_vol - Used to get the output voltage of psu + * filled the value to buf, the value is integer with mV + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_psu_out_vol(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_psu_sensor_info(psu_index, PSU_OUT_VOL, buf, count); + return ret; +} + +/* + * dfd_get_psu_out_power - Used to get the output power of psu + * filled the value to buf, the value is integer with uW + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_psu_out_power(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_psu_sensor_info(psu_index, PSU_OUT_POWER, buf, count); + return ret; +} + +/* + * dfd_get_psu_out_max_power - Used to get the output max power of psu + * filled the value to buf, the value is integer with uW + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_psu_out_max_power(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_psu_info(psu_index, DFD_DEV_INFO_TYPE_MAX_OUTPUT_POWRER, buf, count); + return ret; +} + +/* + * dfd_get_psu_present_status - Used to get psu present status + * filled the value to buf, psu present status define see enum psu_status_e + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_psu_present_status(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_psu_present_status_str(psu_index, buf, count); + return ret; +} + +/* + * dfd_get_psu_in_status - Used to get psu input status + * filled the value to buf, psu input status define see enum psu_io_status_e + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_psu_in_status(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_psu_in_status_str(psu_index, buf, count); + return ret; +} + +/* + * dfd_get_psu_out_status - Used to get psu output status + * filled the value to buf, psu output status define see enum psu_io_status_e + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_psu_out_status(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_psu_out_status_str(psu_index, buf, count); + return ret; +} + +/* + * dfd_get_psu_fan_speed - Used to get psu fan speed + * filled the value to buf + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_psu_fan_speed(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_psu_sensor_info(psu_index, PSU_FAN_SPEED, buf, count); + return ret; +} + +/* + * dfd_get_psu_fan_ratio - Used to get the ratio of psu fan + * filled the value to buf + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_psu_fan_ratio(unsigned int psu_index, char *buf, size_t count) +{ + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); +} + +/* + * dfd_set_psu_fan_ratio - Used to set the ratio of psu fan + * @psu_index: start with 1 + * @ratio: from 0 to 100 + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int dfd_set_psu_fan_ratio(unsigned int psu_index, int ratio) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * dfd_get_psu_fan_direction - Used to get psu air flow direction, + * filled the value to buf, air flow direction define enum air_flow_direction_e + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_psu_fan_direction(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_psu_info(psu_index, DFD_DEV_INFO_TYPE_FAN_DIRECTION, buf, count); + return ret; +} + +/* Similar to dfd_get_fan_led_status */ +static ssize_t dfd_get_psu_led_status(unsigned int psu_index, char *buf, size_t count) +{ + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); +} + +/* Similar to dfd_get_main_board_temp_alias */ +static ssize_t dfd_get_psu_temp_alias(unsigned int psu_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_temp_info(RG_MAIN_DEV_PSU, psu_index, temp_index, RG_SENSOR_ALIAS, + buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_temp_type */ +static ssize_t dfd_get_psu_temp_type(unsigned int psu_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_temp_info(RG_MAIN_DEV_PSU, psu_index, temp_index, RG_SENSOR_TYPE, + buf, count); + return ret; + +} + +/* Similar to dfd_get_main_board_temp_max */ +static ssize_t dfd_get_psu_temp_max(unsigned int psu_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_temp_info(RG_MAIN_DEV_PSU, psu_index, temp_index, RG_SENSOR_MAX, + buf, count); + return ret; +} + +/* Similar to dfd_set_main_board_temp_max */ +static int dfd_set_psu_temp_max(unsigned int psu_index, unsigned int temp_index, + const char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* Similar to dfd_get_main_board_temp_min */ +static ssize_t dfd_get_psu_temp_min(unsigned int psu_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_temp_info(RG_MAIN_DEV_PSU, psu_index, temp_index, RG_SENSOR_MIN, + buf, count); + return ret; +} + +/* Similar to dfd_set_main_board_temp_min */ +static int dfd_set_psu_temp_min(unsigned int psu_index, unsigned int temp_index, + const char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* Similar to dfd_get_main_board_temp_value */ +static ssize_t dfd_get_psu_temp_value(unsigned int psu_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_temp_info(RG_MAIN_DEV_PSU, psu_index, temp_index, RG_SENSOR_INPUT, + buf, count); + return ret; +} +/****************************************end of psu*******************************************/ +/****************************************transceiver******************************************/ +static int dfd_get_eth_number(void) +{ + int ret; + + ret = dfd_get_dev_number(RG_MAIN_DEV_SFF, RG_MINOR_DEV_NONE); + return ret; +} + +/* + * dfd_get_transceiver_power_on_status - Used to get the whole machine port power on status, + * filled the value to buf, 0: power off, 1: power on + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_transceiver_power_on_status(char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_sff_cpld_info(0, RG_SFF_POWER_ON, buf, count); + return ret; +} + +/* + * dfd_set_transceiver_power_on_status - Used to set the whole machine port power on status, + * @status: power on status, 0: power off, 1: power on + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int dfd_set_transceiver_power_on_status(int status) +{ + int ret; + + ret = dfd_set_sff_cpld_info(0, RG_SFF_POWER_ON, status); + return ret; +} + +/* + * dfd_get_eth_power_on_status - Used to get single port power on status, + * filled the value to buf, 0: power off, 1: power on + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_eth_power_on_status(unsigned int eth_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_sff_cpld_info(eth_index, RG_SFF_POWER_ON, buf, count); + return ret; +} + +/* + * dfd_set_eth_power_on_status - Used to set single port power on status, + * @eth_index: start with 1 + * @status: power on status, 0: power off, 1: power on + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int dfd_set_eth_power_on_status(unsigned int eth_index, int status) +{ + int ret; + + ret = dfd_set_sff_cpld_info(eth_index, RG_SFF_POWER_ON, status); + return ret; +} + +/* + * dfd_get_eth_tx_fault_status - Used to get port tx_fault status, + * filled the value to buf, 0: normal, 1: abnormal + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_eth_tx_fault_status(unsigned int eth_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_sff_cpld_info(eth_index, RG_SFF_TX_FAULT, buf, count); + return ret; +} + +/* + * dfd_get_eth_tx_disable_status - Used to get port tx_disable status, + * filled the value to buf, 0: tx_enable, 1: tx_disable + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_eth_tx_disable_status(unsigned int eth_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_sff_cpld_info(eth_index, RG_SFF_TX_DIS, buf, count); + return ret; +} + +/* + * dfd_set_eth_tx_disable_status - Used to set port tx_disable status, + * @eth_index: start with 1 + * @status: tx_disable status, 0: tx_enable, 1: tx_disable + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int dfd_set_eth_tx_disable_status(unsigned int eth_index, int status) +{ + int ret; + + ret = dfd_set_sff_cpld_info(eth_index, RG_SFF_TX_DIS, status); + return ret; +} + +/* + * dfd_get_eth_present_status - Used to get port present status, + * filled the value to buf, 1: present, 0: absent + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_eth_present_status(unsigned int eth_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_sff_cpld_info(eth_index, RG_SFF_MODULE_PRESENT, buf, count); + return ret; +} + +/* + * dfd_get_eth_rx_los_status - Used to get port rx_los status, + * filled the value to buf, 0: normal, 1: abnormal + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_eth_rx_los_status(unsigned int eth_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_sff_cpld_info(eth_index, RG_SFF_RX_LOS, buf, count); + return ret; +} + +/* + * dfd_get_eth_reset_status - Used to get port reset status, + * filled the value to buf, 0: unreset, 1: reset + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_eth_reset_status(unsigned int eth_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_sff_cpld_info(eth_index, RG_SFF_RESET, buf, count); + return ret; +} + +/* + * dfd_set_eth_reset_status - Used to set port reset status, + * @eth_index: start with 1 + * @status: reset status, 0: unreset, 1: reset + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int dfd_set_eth_reset_status(unsigned int eth_index, int status) +{ + int ret; + + ret = dfd_set_sff_cpld_info(eth_index, RG_SFF_RESET, status); + return ret; +} + +/* + * dfd_get_eth_low_power_mode_status - Used to get port low power mode status, + * filled the value to buf, 0: high power mode, 1: low power mode + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_eth_low_power_mode_status(unsigned int eth_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_sff_cpld_info(eth_index, RG_SFF_LPMODE, buf, count); + return ret; +} + +/* + * dfd_get_eth_interrupt_status - Used to get port interruption status, + * filled the value to buf, 0: no interruption, 1: interruption + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_eth_interrupt_status(unsigned int eth_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_sff_cpld_info(eth_index, RG_SFF_INTERRUPT, buf, count); + return ret; +} + +/* + * dfd_get_eth_eeprom_size - Used to get port eeprom size + * + * This function returns the size of port eeprom, + * otherwise it returns a negative value on failed. + */ +static int dfd_get_eth_eeprom_size(unsigned int eth_index) +{ + int ret; + + ret = dfd_get_eeprom_size(RG_MAIN_DEV_SFF, eth_index); + return ret; +} + +/* + * dfd_read_eth_eeprom_data - Used to read port eeprom data, + * @buf: Data read buffer + * @offset: offset address to read port eeprom data + * @count: length of buf + * + * This function returns the length of the filled buffer, + * returns 0 means EOF, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_read_eth_eeprom_data(unsigned int eth_index, char *buf, loff_t offset, + size_t count) +{ + ssize_t ret; + + ret = dfd_read_eeprom_data(RG_MAIN_DEV_SFF, eth_index, buf, offset, count); + return ret; +} + +/* + * dfd_write_eth_eeprom_data - Used to write port eeprom data + * @buf: Data write buffer + * @offset: offset address to write port eeprom data + * @count: length of buf + * + * This function returns the written length of port eeprom, + * returns 0 means EOF, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_write_eth_eeprom_data(unsigned int eth_index, char *buf, loff_t offset, + size_t count) +{ + ssize_t ret; + + ret = dfd_write_eeprom_data(RG_MAIN_DEV_SFF, eth_index, buf, offset, count); + return ret; +} +/************************************end of transceiver***************************************/ +/*****************************************sysled**********************************************/ +/* + * dfd_get_sys_led_status - Used to get sys led status + * filled the value to buf, led status value define see enum fan_status_e + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_sys_led_status(char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_led_status(RG_SYS_LED_FRONT, RG_MINOR_DEV_NONE, buf, count); + return ret; +} + +/* + * dfd_set_sys_led_status - Used to set sys led status + * @status: led status, led status value define see enum led_status_e + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int dfd_set_sys_led_status(int status) +{ + int ret; + + ret = dfd_set_led_status(RG_SYS_LED_FRONT, RG_MINOR_DEV_NONE, status); + return ret; +} + +/* Similar to dfd_get_sys_led_status */ +static ssize_t dfd_get_bmc_led_status(char *buf, size_t count) +{ + int ret; + + ret = dfd_get_led_status(RG_BMC_LED_FRONT, RG_MINOR_DEV_NONE, buf, count); + return ret; +} + +/* Similar to dfd_set_sys_led_status */ +static int dfd_set_bmc_led_status(int status) +{ + int ret; + + ret = dfd_set_led_status(RG_BMC_LED_FRONT, RG_MINOR_DEV_NONE, status); + return ret; +} + +/* Similar to dfd_get_sys_led_status */ +static ssize_t dfd_get_sys_fan_led_status(char *buf, size_t count) +{ + int ret; + + ret = dfd_get_led_status(RG_FAN_LED_FRONT, RG_MINOR_DEV_NONE, buf, count); + return ret; +} + +/* Similar to dfd_set_sys_led_status */ +static int dfd_set_sys_fan_led_status(int status) +{ + int ret; + + ret = dfd_set_led_status(RG_FAN_LED_FRONT, RG_MINOR_DEV_NONE, status); + return ret; +} + +/* Similar to dfd_get_sys_led_status */ +static ssize_t dfd_get_sys_psu_led_status(char *buf, size_t count) +{ + int ret; + + ret = dfd_get_led_status(RG_PSU_LED_FRONT, RG_MINOR_DEV_NONE, buf, count); + return ret; +} + +/* Similar to dfd_set_sys_led_status */ +static int dfd_set_sys_psu_led_status(int status) +{ + int ret; + + ret = dfd_set_led_status(RG_PSU_LED_FRONT, RG_MINOR_DEV_NONE, status); + return ret; +} + +/* Similar to dfd_get_sys_led_status */ +static ssize_t dfd_get_id_led_status(char *buf, size_t count) +{ + int ret; + + ret = dfd_get_led_status(RG_ID_LED_FRONT, RG_MINOR_DEV_NONE, buf, count); + return ret; +} + +/* Similar to dfd_set_sys_led_status */ +static int dfd_set_id_led_status(int status) +{ + int ret; + + ret = dfd_set_led_status(RG_ID_LED_FRONT, RG_MINOR_DEV_NONE, status); + return ret; +} + +/**************************************end of sysled******************************************/ +/******************************************FPGA***********************************************/ +static int dfd_get_main_board_fpga_number(void) +{ + int ret; + + ret = dfd_get_dev_number(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_FPGA); + return ret; +} + +/* + * dfd_get_main_board_fpga_alias - Used to identify the location of fpga, + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_fpga_alias(unsigned int fpga_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fpga_name(RG_MAIN_DEV_MAINBOARD, fpga_index - 1, buf, count); + return ret; +} + +/* + * dfd_get_main_board_fpga_type - Used to get fpga model name + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_fpga_type(unsigned int fpga_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fpga_type(RG_MAIN_DEV_MAINBOARD, fpga_index - 1, buf, count); + return ret; +} + +/* + * dfd_get_main_board_fpga_firmware_version - Used to get fpga firmware version, + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_fpga_firmware_version(unsigned int fpga_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fpga_fw_version(RG_MAIN_DEV_MAINBOARD, fpga_index - 1, buf, count); + return ret; +} + +/* + * dfd_get_main_board_fpga_board_version - Used to get fpga board version, + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_fpga_board_version(unsigned int fpga_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fpga_hw_version(RG_MAIN_DEV_MAINBOARD, fpga_index - 1, buf, count); + return ret; +} + +/* + * dfd_get_main_board_fpga_test_reg - Used to test fpga register read + * filled the value to buf, value is hexadecimal, start with 0x + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_fpga_test_reg(unsigned int fpga_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fpga_testreg_str(RG_MAIN_DEV_MAINBOARD, fpga_index - 1, buf, count); + return ret; +} + +/* + * dfd_set_main_board_fpga_test_reg - Used to test fpga register write + * @fpga_index: start with 1 + * @value: value write to fpga + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int dfd_set_main_board_fpga_test_reg(unsigned int fpga_index, unsigned int value) +{ + int ret; + + ret = dfd_set_fpga_testreg(RG_MAIN_DEV_MAINBOARD, fpga_index - 1, value); + return ret; +} +/***************************************end of FPGA*******************************************/ +/******************************************CPLD***********************************************/ +static int dfd_get_main_board_cpld_number(void) +{ + int ret; + + ret = dfd_get_dev_number(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_CPLD); + return ret; +} + +/* + * dfd_get_main_board_cpld_alias - Used to identify the location of cpld, + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_cpld_alias(unsigned int cpld_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_cpld_name(RG_MAIN_DEV_MAINBOARD, cpld_index - 1, buf, count); + return ret; +} + +/* + * dfd_get_main_board_cpld_type - Used to get cpld model name + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_cpld_type(unsigned int cpld_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_cpld_type(RG_MAIN_DEV_MAINBOARD, cpld_index - 1, buf, count); + return ret; +} + +/* + * dfd_get_main_board_cpld_firmware_version - Used to get cpld firmware version, + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_cpld_firmware_version(unsigned int cpld_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_cpld_fw_version(RG_MAIN_DEV_MAINBOARD, cpld_index - 1, buf, count); + return ret; +} + +/* + * dfd_get_main_board_cpld_board_version - Used to get cpld board version, + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_cpld_board_version(unsigned int cpld_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_cpld_hw_version(RG_MAIN_DEV_MAINBOARD, cpld_index - 1, buf, count); + return ret; +} + +/* + * dfd_get_main_board_cpld_test_reg - Used to test cpld register read + * filled the value to buf, value is hexadecimal, start with 0x + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_cpld_test_reg(unsigned int cpld_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_cpld_testreg_str(RG_MAIN_DEV_MAINBOARD, cpld_index - 1, buf, count); + return ret; +} + +/* + * dfd_set_main_board_cpld_test_reg - Used to test cpld register write + * @cpld_index: start with 1 + * @value: value write to cpld + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int dfd_set_main_board_cpld_test_reg(unsigned int cpld_index, unsigned int value) +{ + int ret; + + ret = dfd_set_cpld_testreg(RG_MAIN_DEV_MAINBOARD, cpld_index - 1, value); + return ret; +} +/***************************************end of CPLD*******************************************/ +/****************************************watchdog*********************************************/ +/* + * dfd_get_watchdog_identify - Used to get watchdog identify, such as iTCO_wdt + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_watchdog_identify(char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_watchdog_info(RG_WDT_TYPE_NAME, buf, count); + return ret; +} + +/* + * dfd_get_watchdog_timeleft - Used to get watchdog timeleft, + * filled the value to buf + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_watchdog_timeleft(char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_watchdog_info(RG_WDT_TYPE_TIMELEFT, buf, count); + return ret; +} + +/* + * dfd_get_watchdog_timeout - Used to get watchdog timeout, + * filled the value to buf + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_watchdog_timeout(char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_watchdog_info(RG_WDT_TYPE_TIMEOUT, buf, count); + return ret; +} + +/* + * dfd_set_watchdog_timeout - Used to set watchdog timeout, + * @value: timeout value + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int dfd_set_watchdog_timeout(int value) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * dfd_get_watchdog_enable_status - Used to get watchdog enable status, + * filled the value to buf, 0: disable, 1: enable + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_watchdog_enable_status(char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_watchdog_get_status_str(buf, count); + return ret; +} + +/* + * dfd_set_watchdog_enable_status - Used to set watchdog enable status, + * @value: enable status value, 0: disable, 1: enable + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int dfd_set_watchdog_enable_status(int value) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * dfd_set_watchdog_reset - Used to feed watchdog, + * @value: any value to feed watchdog + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int dfd_set_watchdog_reset(int value) +{ + /* add vendor codes here */ + return -ENOSYS; +} +/*************************************end of watchdog*****************************************/ +/******************************************slot***********************************************/ +static int dfd_get_slot_number(void) +{ + int ret; + + ret = dfd_get_dev_number(RG_MAIN_DEV_SLOT, RG_MINOR_DEV_NONE); + return ret; +} + +static int dfd_get_slot_temp_number(unsigned int slot_index) +{ + int ret; + + ret = dfd_get_dev_number(RG_MAIN_DEV_SLOT, RG_MINOR_DEV_TEMP); + return ret; +} + +static int dfd_get_slot_vol_number(unsigned int slot_index) +{ + int ret; + + ret = dfd_get_dev_number(RG_MAIN_DEV_SLOT, RG_MINOR_DEV_IN); + return ret; +} + +static int dfd_get_slot_curr_number(unsigned int slot_index) +{ + int ret; + + ret = dfd_get_dev_number(RG_MAIN_DEV_SLOT, RG_MINOR_DEV_CURR); + return ret; +} + +static int dfd_get_slot_fpga_number(unsigned int slot_index) +{ + int ret; + + ret = dfd_get_dev_number(RG_MAIN_DEV_SLOT, RG_MINOR_DEV_FPGA); + return ret; +} + +static int dfd_get_slot_cpld_number(unsigned int slot_index) +{ + int ret; + + ret = dfd_get_dev_number(RG_MAIN_DEV_SLOT, RG_MINOR_DEV_CPLD); + return ret; +} + +/* Similar to dfd_get_fan_model_name */ +static ssize_t dfd_get_slot_model_name(unsigned int slot_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_slot_info(slot_index, DFD_DEV_INFO_TYPE_NAME, buf, count); + return ret; +} + +/* Similar to rg_get_fan_serial_number */ +static ssize_t dfd_get_slot_serial_number(unsigned int slot_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_slot_info(slot_index, DFD_DEV_INFO_TYPE_SN, buf, count); + return ret; +} + +/* Similar to rg_get_fan_part_number */ +static ssize_t dfd_get_slot_part_number(unsigned int slot_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_slot_info(slot_index, DFD_DEV_INFO_TYPE_PART_NUMBER, buf, count); + return ret; +} + +/* Similar to rg_get_fan_hardware_version */ +static ssize_t dfd_get_slot_hardware_version(unsigned int slot_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_slot_info(slot_index, DFD_DEV_INFO_TYPE_HW_INFO, buf, count); + return ret; +} + +/* Similar to dfd_get_fan_status */ +static ssize_t dfd_get_slot_status(unsigned int slot_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_slot_status_str(slot_index, buf, count); + return ret; +} + +/* Similar to dfd_get_fan_led_status */ +static ssize_t dfd_get_slot_led_status(unsigned int slot_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_led_status(RG_SLOT_LED_MODULE, slot_index, buf, count); + return ret; +} + +/* Similar to dfd_set_fan_led_status */ +static int dfd_set_slot_led_status(unsigned int slot_index, int status) +{ + int ret; + + ret = dfd_set_led_status(RG_SLOT_LED_MODULE, slot_index, status); + return ret; +} + +/* Similar to dfd_get_main_board_temp_alias */ +static ssize_t dfd_get_slot_temp_alias(unsigned int slot_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_temp_info(RG_MAIN_DEV_SLOT, slot_index, temp_index, RG_SENSOR_ALIAS, + buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_temp_type */ +static ssize_t dfd_get_slot_temp_type(unsigned int slot_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_temp_info(RG_MAIN_DEV_SLOT, slot_index, temp_index, RG_SENSOR_TYPE, + buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_temp_max */ +static ssize_t dfd_get_slot_temp_max(unsigned int slot_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_temp_info(RG_MAIN_DEV_SLOT, slot_index, temp_index, RG_SENSOR_MAX, + buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_temp_min */ +static ssize_t dfd_get_slot_temp_min(unsigned int slot_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_temp_info(RG_MAIN_DEV_SLOT, slot_index, temp_index, RG_SENSOR_MIN, + buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_temp_value */ +static ssize_t dfd_get_slot_temp_value(unsigned int slot_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_temp_info(RG_MAIN_DEV_SLOT, slot_index, temp_index, RG_SENSOR_INPUT, + buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_vol_alias */ +static ssize_t dfd_get_slot_vol_alias(unsigned int slot_index, unsigned int vol_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_voltage_info(RG_MAIN_DEV_SLOT, slot_index, vol_index, RG_SENSOR_ALIAS, + buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_vol_type */ +static ssize_t dfd_get_slot_vol_type(unsigned int slot_index, unsigned int vol_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_voltage_info(RG_MAIN_DEV_SLOT, slot_index, vol_index, RG_SENSOR_TYPE, + buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_vol_max */ +static ssize_t dfd_get_slot_vol_max(unsigned int slot_index, unsigned int vol_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_voltage_info(RG_MAIN_DEV_SLOT, slot_index, vol_index, RG_SENSOR_MAX, + buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_vol_min */ +static ssize_t dfd_get_slot_vol_min(unsigned int slot_index, unsigned int vol_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_voltage_info(RG_MAIN_DEV_SLOT, slot_index, vol_index, RG_SENSOR_MIN, + buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_vol_range */ +static ssize_t dfd_get_slot_vol_range(unsigned int slot_index, unsigned int vol_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_voltage_info(RG_MAIN_DEV_SLOT, slot_index, vol_index, RG_SENSOR_RANGE, + buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_vol_nominal_value */ +static ssize_t dfd_get_slot_vol_nominal_value(unsigned int slot_index, + unsigned int vol_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_voltage_info(RG_MAIN_DEV_SLOT, slot_index, vol_index, RG_SENSOR_NOMINAL_VAL, + buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_vol_value */ +static ssize_t dfd_get_slot_vol_value(unsigned int slot_index, unsigned int vol_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_voltage_info(RG_MAIN_DEV_SLOT, slot_index, vol_index, RG_SENSOR_INPUT, + buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_curr_alias */ +static ssize_t dfd_get_slot_curr_alias(unsigned int slot_index, unsigned int curr_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_current_info(RG_MAIN_DEV_SLOT, slot_index, curr_index, RG_SENSOR_ALIAS, + buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_curr_type */ +static ssize_t dfd_get_slot_curr_type(unsigned int slot_index, unsigned int curr_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_current_info(RG_MAIN_DEV_SLOT, slot_index, curr_index, RG_SENSOR_TYPE, + buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_curr_max */ +static ssize_t dfd_get_slot_curr_max(unsigned int slot_index, unsigned int curr_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_current_info(RG_MAIN_DEV_SLOT, slot_index, curr_index, RG_SENSOR_MAX, + buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_curr_min */ +static ssize_t dfd_get_slot_curr_min(unsigned int slot_index, unsigned int curr_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_current_info(RG_MAIN_DEV_SLOT, slot_index, curr_index, RG_SENSOR_MIN, + buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_curr_value */ +static ssize_t dfd_get_slot_curr_value(unsigned int slot_index, unsigned int curr_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_current_info(RG_MAIN_DEV_SLOT, slot_index, curr_index, RG_SENSOR_INPUT, + buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_fpga_alias */ +static ssize_t dfd_get_slot_fpga_alias(unsigned int slot_index, unsigned int fpga_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fpga_name(slot_index, fpga_index - 1, buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_fpga_type */ +static ssize_t dfd_get_slot_fpga_type(unsigned int slot_index, unsigned int fpga_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fpga_type(slot_index, fpga_index - 1, buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_fpga_firmware_version */ +static ssize_t dfd_get_slot_fpga_firmware_version(unsigned int slot_index, unsigned int fpga_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fpga_fw_version(slot_index, fpga_index - 1, buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_fpga_board_version */ +static ssize_t dfd_get_slot_fpga_board_version(unsigned int slot_index, unsigned int fpga_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fpga_hw_version(slot_index, fpga_index - 1, buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_fpga_test_reg */ +static ssize_t dfd_get_slot_fpga_test_reg(unsigned int slot_index, unsigned int fpga_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fpga_testreg_str(slot_index, fpga_index - 1, buf, count); + return ret; +} + +/* Similar to dfd_set_main_board_fpga_test_reg */ +static int dfd_set_slot_fpga_test_reg(unsigned int slot_index, unsigned int fpga_index, + unsigned int value) +{ + int ret; + + ret = dfd_set_fpga_testreg(slot_index, fpga_index - 1, value); + return ret; +} + +/* Similar to dfd_get_main_board_cpld_alias */ +static ssize_t dfd_get_slot_cpld_alias(unsigned int slot_index, unsigned int cpld_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_cpld_name(slot_index, cpld_index - 1, buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_cpld_type */ +static ssize_t dfd_get_slot_cpld_type(unsigned int slot_index, unsigned int cpld_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_cpld_type(slot_index, cpld_index - 1, buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_cpld_firmware_version */ +static ssize_t dfd_get_slot_cpld_firmware_version(unsigned int slot_index, unsigned int cpld_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_cpld_fw_version(slot_index, cpld_index - 1, buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_cpld_board_version */ +static ssize_t dfd_get_slot_cpld_board_version(unsigned int slot_index, unsigned int cpld_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_cpld_hw_version(slot_index, cpld_index - 1, buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_cpld_test_reg */ +static ssize_t dfd_get_slot_cpld_test_reg(unsigned int slot_index, unsigned int cpld_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_cpld_testreg_str(slot_index, cpld_index - 1, buf, count); + return ret; +} + +/* Similar to dfd_set_main_board_cpld_test_reg */ +static int dfd_set_slot_cpld_test_reg(unsigned int slot_index, unsigned int cpld_index, + unsigned int value) +{ + int ret; + + ret = dfd_set_cpld_testreg(slot_index, cpld_index - 1, value); + return ret; +} +/***************************************end of slot*******************************************/ +static struct switch_drivers_s switch_drivers = { + /* + * set odm switch drivers, + * if not support the function, set corresponding hook to NULL. + */ + /* temperature sensors */ + .get_main_board_temp_number = dfd_get_main_board_temp_number, + .get_main_board_temp_alias = dfd_get_main_board_temp_alias, + .get_main_board_temp_type = dfd_get_main_board_temp_type, + .get_main_board_temp_max = dfd_get_main_board_temp_max, + .get_main_board_temp_min = dfd_get_main_board_temp_min, + .get_main_board_temp_value = dfd_get_main_board_temp_value, + /* voltage sensors */ + .get_main_board_vol_number = dfd_get_main_board_vol_number, + .get_main_board_vol_alias = dfd_get_main_board_vol_alias, + .get_main_board_vol_type = dfd_get_main_board_vol_type, + .get_main_board_vol_max = dfd_get_main_board_vol_max, + .get_main_board_vol_min = dfd_get_main_board_vol_min, + .get_main_board_vol_range = dfd_get_main_board_vol_range, + .get_main_board_vol_nominal_value = dfd_get_main_board_vol_nominal_value, + .get_main_board_vol_value = dfd_get_main_board_vol_value, + /* current sensors */ + .get_main_board_curr_number = dfd_get_main_board_curr_number, + .get_main_board_curr_alias = dfd_get_main_board_curr_alias, + .get_main_board_curr_type = dfd_get_main_board_curr_type, + .get_main_board_curr_max = dfd_get_main_board_curr_max, + .get_main_board_curr_min = dfd_get_main_board_curr_min, + .get_main_board_curr_value = dfd_get_main_board_curr_value, + /* syseeprom */ + .get_syseeprom_size = dfd_get_syseeprom_size, + .read_syseeprom_data = dfd_read_syseeprom_data, + .write_syseeprom_data = dfd_write_syseeprom_data, + /* fan */ + .get_fan_number = dfd_get_fan_number, + .get_fan_motor_number = dfd_get_fan_motor_number, + .get_fan_model_name = dfd_get_fan_model_name, + .get_fan_serial_number = dfd_get_fan_serial_number, + .get_fan_part_number = dfd_get_fan_part_number, + .get_fan_hardware_version = dfd_get_fan_hardware_version, + .get_fan_status = dfd_get_fan_status, + .get_fan_led_status = dfd_get_fan_led_status, + .set_fan_led_status = dfd_set_fan_led_status, + .get_fan_direction = dfd_get_fan_direction, + .get_fan_motor_speed = dfd_get_fan_motor_speed, + .get_fan_motor_speed_tolerance = dfd_get_fan_motor_speed_tolerance, + .get_fan_motor_speed_target = dfd_get_fan_motor_speed_target, + .get_fan_motor_speed_max = dfd_get_fan_motor_speed_max, + .get_fan_motor_speed_min = dfd_get_fan_motor_speed_min, + .get_fan_ratio = dfd_get_fan_ratio, + .set_fan_ratio = dfd_set_fan_ratio, + /* psu */ + .get_psu_number = dfd_get_psu_number, + .get_psu_temp_number = dfd_get_psu_temp_number, + .get_psu_model_name = dfd_get_psu_model_name, + .get_psu_serial_number = dfd_get_psu_serial_number, + .get_psu_part_number = dfd_get_psu_part_number, + .get_psu_hardware_version = dfd_get_psu_hardware_version, + .get_psu_type = dfd_get_psu_type, + .get_psu_in_curr = dfd_get_psu_in_curr, + .get_psu_in_vol = dfd_get_psu_in_vol, + .get_psu_in_power = dfd_get_psu_in_power, + .get_psu_out_curr = dfd_get_psu_out_curr, + .get_psu_out_vol = dfd_get_psu_out_vol, + .get_psu_out_power = dfd_get_psu_out_power, + .get_psu_out_max_power = dfd_get_psu_out_max_power, + .get_psu_present_status = dfd_get_psu_present_status, + .get_psu_in_status = dfd_get_psu_in_status, + .get_psu_out_status = dfd_get_psu_out_status, + .get_psu_fan_speed = dfd_get_psu_fan_speed, + .get_psu_fan_ratio = dfd_get_psu_fan_ratio, + .set_psu_fan_ratio = dfd_set_psu_fan_ratio, + .get_psu_fan_direction = dfd_get_psu_fan_direction, + .get_psu_led_status = dfd_get_psu_led_status, + .get_psu_temp_alias = dfd_get_psu_temp_alias, + .get_psu_temp_type = dfd_get_psu_temp_type, + .get_psu_temp_max = dfd_get_psu_temp_max, + .set_psu_temp_max = dfd_set_psu_temp_max, + .get_psu_temp_min = dfd_get_psu_temp_min, + .set_psu_temp_min = dfd_set_psu_temp_min, + .get_psu_temp_value = dfd_get_psu_temp_value, + /* transceiver */ + .get_eth_number = dfd_get_eth_number, + .get_transceiver_power_on_status = dfd_get_transceiver_power_on_status, + .set_transceiver_power_on_status = dfd_set_transceiver_power_on_status, + .get_eth_power_on_status = dfd_get_eth_power_on_status, + .set_eth_power_on_status = dfd_set_eth_power_on_status, + .get_eth_tx_fault_status = dfd_get_eth_tx_fault_status, + .get_eth_tx_disable_status = dfd_get_eth_tx_disable_status, + .set_eth_tx_disable_status = dfd_set_eth_tx_disable_status, + .get_eth_present_status = dfd_get_eth_present_status, + .get_eth_rx_los_status = dfd_get_eth_rx_los_status, + .get_eth_reset_status = dfd_get_eth_reset_status, + .set_eth_reset_status = dfd_set_eth_reset_status, + .get_eth_low_power_mode_status = dfd_get_eth_low_power_mode_status, + .get_eth_interrupt_status = dfd_get_eth_interrupt_status, + .get_eth_eeprom_size = dfd_get_eth_eeprom_size, + .read_eth_eeprom_data = dfd_read_eth_eeprom_data, + .write_eth_eeprom_data = dfd_write_eth_eeprom_data, + /* sysled */ + .get_sys_led_status = dfd_get_sys_led_status, + .set_sys_led_status = dfd_set_sys_led_status, + .get_bmc_led_status = dfd_get_bmc_led_status, + .set_bmc_led_status = dfd_set_bmc_led_status, + .get_sys_fan_led_status = dfd_get_sys_fan_led_status, + .set_sys_fan_led_status = dfd_set_sys_fan_led_status, + .get_sys_psu_led_status = dfd_get_sys_psu_led_status, + .set_sys_psu_led_status = dfd_set_sys_psu_led_status, + .get_id_led_status = dfd_get_id_led_status, + .set_id_led_status = dfd_set_id_led_status, + /* FPGA */ + .get_main_board_fpga_number = dfd_get_main_board_fpga_number, + .get_main_board_fpga_alias = dfd_get_main_board_fpga_alias, + .get_main_board_fpga_type = dfd_get_main_board_fpga_type, + .get_main_board_fpga_firmware_version = dfd_get_main_board_fpga_firmware_version, + .get_main_board_fpga_board_version = dfd_get_main_board_fpga_board_version, + .get_main_board_fpga_test_reg = dfd_get_main_board_fpga_test_reg, + .set_main_board_fpga_test_reg = dfd_set_main_board_fpga_test_reg, + /* CPLD */ + .get_main_board_cpld_number = dfd_get_main_board_cpld_number, + .get_main_board_cpld_alias = dfd_get_main_board_cpld_alias, + .get_main_board_cpld_type = dfd_get_main_board_cpld_type, + .get_main_board_cpld_firmware_version = dfd_get_main_board_cpld_firmware_version, + .get_main_board_cpld_board_version = dfd_get_main_board_cpld_board_version, + .get_main_board_cpld_test_reg = dfd_get_main_board_cpld_test_reg, + .set_main_board_cpld_test_reg = dfd_set_main_board_cpld_test_reg, + /* watchdog */ + .get_watchdog_identify = dfd_get_watchdog_identify, + .get_watchdog_timeleft = dfd_get_watchdog_timeleft, + .get_watchdog_timeout = dfd_get_watchdog_timeout, + .set_watchdog_timeout = dfd_set_watchdog_timeout, + .get_watchdog_enable_status = dfd_get_watchdog_enable_status, + .set_watchdog_enable_status = dfd_set_watchdog_enable_status, + .set_watchdog_reset = dfd_set_watchdog_reset, + /* slot */ + .get_slot_number = dfd_get_slot_number, + .get_slot_temp_number = dfd_get_slot_temp_number, + .get_slot_vol_number = dfd_get_slot_vol_number, + .get_slot_curr_number = dfd_get_slot_curr_number, + .get_slot_cpld_number = dfd_get_slot_cpld_number, + .get_slot_fpga_number = dfd_get_slot_fpga_number, + .get_slot_model_name = dfd_get_slot_model_name, + .get_slot_serial_number = dfd_get_slot_serial_number, + .get_slot_part_number = dfd_get_slot_part_number, + .get_slot_hardware_version = dfd_get_slot_hardware_version, + .get_slot_status = dfd_get_slot_status, + .get_slot_led_status = dfd_get_slot_led_status, + .set_slot_led_status = dfd_set_slot_led_status, + .get_slot_temp_alias = dfd_get_slot_temp_alias, + .get_slot_temp_type = dfd_get_slot_temp_type, + .get_slot_temp_max = dfd_get_slot_temp_max, + .get_slot_temp_min = dfd_get_slot_temp_min, + .get_slot_temp_value = dfd_get_slot_temp_value, + .get_slot_vol_alias = dfd_get_slot_vol_alias, + .get_slot_vol_type = dfd_get_slot_vol_type, + .get_slot_vol_max = dfd_get_slot_vol_max, + .get_slot_vol_min = dfd_get_slot_vol_min, + .get_slot_vol_range = dfd_get_slot_vol_range, + .get_slot_vol_nominal_value = dfd_get_slot_vol_nominal_value, + .get_slot_vol_value = dfd_get_slot_vol_value, + .get_slot_curr_alias = dfd_get_slot_curr_alias, + .get_slot_curr_type = dfd_get_slot_curr_type, + .get_slot_curr_max = dfd_get_slot_curr_max, + .get_slot_curr_min = dfd_get_slot_curr_min, + .get_slot_curr_value = dfd_get_slot_curr_value, + .get_slot_fpga_alias = dfd_get_slot_fpga_alias, + .get_slot_fpga_type = dfd_get_slot_fpga_type, + .get_slot_fpga_firmware_version = dfd_get_slot_fpga_firmware_version, + .get_slot_fpga_board_version = dfd_get_slot_fpga_board_version, + .get_slot_fpga_test_reg = dfd_get_slot_fpga_test_reg, + .set_slot_fpga_test_reg = dfd_set_slot_fpga_test_reg, + .get_slot_cpld_alias = dfd_get_slot_cpld_alias, + .get_slot_cpld_type = dfd_get_slot_cpld_type, + .get_slot_cpld_firmware_version = dfd_get_slot_cpld_firmware_version, + .get_slot_cpld_board_version = dfd_get_slot_cpld_board_version, + .get_slot_cpld_test_reg = dfd_get_slot_cpld_test_reg, + .set_slot_cpld_test_reg = dfd_set_slot_cpld_test_reg, +}; + +struct switch_drivers_s * switch_driver_get(void) { + return &switch_drivers; +} + +static int32_t __init switch_driver_init(void) +{ + int ret; + + SWITCH_DEBUG(DBG_VERBOSE, "Enter.\n"); + ret = rg_dev_cfg_init(); + if (ret < 0) { + SWITCH_DEBUG(DBG_ERROR, "rg_dev_cfg_init failed ret %d.\n", ret); + return ret; + } + SWITCH_DEBUG(DBG_VERBOSE, "success.\n"); + return 0; +} + +static void __exit switch_driver_exit(void) +{ + SWITCH_DEBUG(DBG_VERBOSE, "switch_driver_exit.\n"); + rg_dev_cfg_exit(); + return; +} + +module_init(switch_driver_init); +module_exit(switch_driver_exit); +EXPORT_SYMBOL(switch_driver_get); +module_param(g_switch_dbg_level, int, S_IRUGO | S_IWUSR); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_LICENSE("GPL"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/Makefile b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/Makefile new file mode 100755 index 000000000000..23d988470719 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/Makefile @@ -0,0 +1,27 @@ +PWD = $(shell pwd) + +EXTRA_CFLAGS:= -I$(M)/include +EXTRA_CFLAGS+= -Wall + +s3ip_sysfs-objs := switch.o cpld_sysfs.o \ +curr_sensor_sysfs.o \ +fan_sysfs.o \ +fpga_sysfs.o \ +psu_sysfs.o \ +slot_sysfs.o \ +sysled_sysfs.o \ +temp_sensor_sysfs.o \ +transceiver_sysfs.o \ +vol_sensor_sysfs.o \ +watchdog_sysfs.o \ + +obj-m := s3ip_sysfs.o + +all: + $(MAKE) -C $(KERNEL_SRC)/build M=$(PWD) modules + @if [ ! -d $(sysfs_out_put_dir) ]; then mkdir -p $(sysfs_out_put_dir) ;fi + cp -p $(PWD)/*.ko $(sysfs_out_put_dir) +clean: + rm -f $(PWD)/*.o $(PWD)/*.ko $(PWD)/*.mod.c $(PWD)/.*.cmd $(PWD)/*.mod + rm -f $(PWD)/Module.markers $(PWD)/Module.symvers $(PWD)/modules.order + rm -rf $(PWD)/.tmp_versions diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/cpld_sysfs.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/cpld_sysfs.c new file mode 100644 index 000000000000..9e3efaca497a --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/cpld_sysfs.c @@ -0,0 +1,365 @@ +/* + * cpld_sysfs.c + * + * This module create cpld kobjects and attributes in /sys/s3ip/cpld + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "switch.h" +#include "cpld_sysfs.h" + +static int g_cpld_loglevel = 0; + +#define CPLD_INFO(fmt, args...) do { \ + if (g_cpld_loglevel & INFO) { \ + printk(KERN_INFO "[CPLD_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define CPLD_ERR(fmt, args...) do { \ + if (g_cpld_loglevel & ERR) { \ + printk(KERN_ERR "[CPLD_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define CPLD_DBG(fmt, args...) do { \ + if (g_cpld_loglevel & DBG) { \ + printk(KERN_DEBUG "[CPLD_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +struct cpld_obj_s { + struct switch_obj *obj; +}; + +struct cpld_s { + unsigned int cpld_number; + struct cpld_obj_s *cpld; +}; + +static struct cpld_s g_cpld; +static struct switch_obj *g_cpld_obj = NULL; +static struct s3ip_sysfs_cpld_drivers_s *g_cpld_drv = NULL; + +static ssize_t cpld_number_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + return (ssize_t)snprintf(buf, PAGE_SIZE, "%u\n", g_cpld.cpld_number); +} + +static ssize_t cpld_alias_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int cpld_index; + int ret; + + check_p(g_cpld_drv); + check_p(g_cpld_drv->get_main_board_cpld_alias); + + cpld_index = obj->index; + CPLD_DBG("cpld index: %u\n", cpld_index); + ret = g_cpld_drv->get_main_board_cpld_alias(cpld_index, buf, PAGE_SIZE); + if (ret < 0) { + CPLD_ERR("get cpld%u alias failed, ret: %d\n", cpld_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t cpld_type_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int cpld_index; + int ret; + + check_p(g_cpld_drv); + check_p(g_cpld_drv->get_main_board_cpld_type); + + cpld_index = obj->index; + CPLD_DBG("cpld index: %u\n", cpld_index); + ret = g_cpld_drv->get_main_board_cpld_type(cpld_index, buf, PAGE_SIZE); + if (ret < 0) { + CPLD_ERR("get cpld%u type failed, ret: %d\n", cpld_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t cpld_fw_version_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int cpld_index; + int ret; + + check_p(g_cpld_drv); + check_p(g_cpld_drv->get_main_board_cpld_firmware_version); + + cpld_index = obj->index; + CPLD_DBG("cpld index: %u\n", cpld_index); + ret = g_cpld_drv->get_main_board_cpld_firmware_version(cpld_index, buf, PAGE_SIZE); + if (ret < 0) { + CPLD_ERR("get cpld%u firmware version failed, ret: %d\n", cpld_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t cpld_board_version_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int cpld_index; + int ret; + + check_p(g_cpld_drv); + check_p(g_cpld_drv->get_main_board_cpld_board_version); + + cpld_index = obj->index; + CPLD_DBG("cpld index: %u\n", cpld_index); + ret = g_cpld_drv->get_main_board_cpld_board_version(cpld_index, buf, PAGE_SIZE); + if (ret < 0) { + CPLD_ERR("get cpld%u board version failed, ret: %d\n", cpld_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t cpld_test_reg_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int cpld_index; + int ret; + + check_p(g_cpld_drv); + check_p(g_cpld_drv->get_main_board_cpld_test_reg); + + cpld_index = obj->index; + CPLD_DBG("cpld index: %u\n", cpld_index); + ret = g_cpld_drv->get_main_board_cpld_test_reg(cpld_index, buf, PAGE_SIZE); + if (ret < 0) { + CPLD_ERR("get cpld%u test register failed, ret: %d\n", cpld_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t cpld_test_reg_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int cpld_index, value; + int ret; + + check_p(g_cpld_drv); + check_p(g_cpld_drv->set_main_board_cpld_test_reg); + + cpld_index = obj->index; + sscanf(buf, "0x%x", &value); + ret = g_cpld_drv->set_main_board_cpld_test_reg(cpld_index, value); + if (ret < 0) { + CPLD_ERR("set cpld%u test reg failed, value:0x%x, ret: %d.\n", cpld_index, value, ret); + return -EIO; + } + CPLD_DBG("set cpld%u test reg success, value: 0x%x.\n", cpld_index, value); + return count; +} + +/************************************cpld dir and attrs*******************************************/ +static struct switch_attribute cpld_number_att = __ATTR(number, S_IRUGO, cpld_number_show, NULL); + +static struct attribute *cpld_dir_attrs[] = { + &cpld_number_att.attr, + NULL, +}; + +static struct attribute_group cpld_root_attr_group = { + .attrs = cpld_dir_attrs, +}; + +/*******************************cpld[1-n] dir and attrs*******************************************/ +static struct switch_attribute cpld_alias_attr = __ATTR(alias, S_IRUGO, cpld_alias_show, NULL); +static struct switch_attribute cpld_type_attr = __ATTR(type, S_IRUGO, cpld_type_show, NULL); +static struct switch_attribute cpld_fw_version_attr = __ATTR(firmware_version, S_IRUGO, cpld_fw_version_show, NULL); +static struct switch_attribute cpld_board_version_attr = __ATTR(board_version, S_IRUGO, cpld_board_version_show, NULL); +static struct switch_attribute cpld_test_reg_attr = __ATTR(reg_test, S_IRUGO | S_IWUSR, cpld_test_reg_show, cpld_test_reg_store); + +static struct attribute *cpld_attrs[] = { + &cpld_alias_attr.attr, + &cpld_type_attr.attr, + &cpld_fw_version_attr.attr, + &cpld_board_version_attr.attr, + &cpld_test_reg_attr.attr, + NULL, +}; + +static struct attribute_group cpld_attr_group = { + .attrs = cpld_attrs, +}; + +static int cpld_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct cpld_obj_s *curr_cpld; + + curr_cpld = &g_cpld.cpld[index - 1]; + if (curr_cpld->obj) { + sysfs_remove_group(&curr_cpld->obj->kobj, &cpld_attr_group); + switch_kobject_delete(&curr_cpld->obj); + CPLD_DBG("delete cpld%u dir and attrs success.\n", index); + } + + return 0; +} + +static int cpld_sub_single_create_kobj_and_attrs(struct kobject *parent, unsigned int index) +{ + char name[8]; + struct cpld_obj_s *curr_cpld; + + curr_cpld = &g_cpld.cpld[index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "cpld%u", index); + curr_cpld->obj = switch_kobject_create(name, parent); + if (!curr_cpld->obj) { + CPLD_ERR("create %s object error!\n", name); + return -EBADRQC; + } + curr_cpld->obj->index = index; + if (sysfs_create_group(&curr_cpld->obj->kobj, &cpld_attr_group) != 0) { + CPLD_ERR("create %s attrs error.\n", name); + switch_kobject_delete(&curr_cpld->obj); + return -EBADRQC; + } + CPLD_DBG("create %s dir and attrs success.\n", name); + return 0; +} + +static int cpld_sub_create_kobj_and_attrs(struct kobject *parent, int cpld_num) +{ + unsigned int cpld_index, i; + + g_cpld.cpld = kzalloc(sizeof(struct cpld_obj_s) * cpld_num, GFP_KERNEL); + if (!g_cpld.cpld) { + CPLD_ERR("kzalloc g_cpld.cpld error, cpld number = %d.\n", cpld_num); + return -ENOMEM; + } + + for(cpld_index = 1; cpld_index <= cpld_num; cpld_index++) { + if(cpld_sub_single_create_kobj_and_attrs(parent, cpld_index) != 0) { + goto error; + } + } + return 0; +error: + for(i = cpld_index; i > 0; i--) { + cpld_sub_single_remove_kobj_and_attrs(i); + } + kfree(g_cpld.cpld); + g_cpld.cpld = NULL; + return -EBADRQC; +} + +/* create cpld[1-n] directory and attributes*/ +static int cpld_sub_create(void) +{ + int ret; + + ret = cpld_sub_create_kobj_and_attrs(&g_cpld_obj->kobj, g_cpld.cpld_number); + return ret; +} + +/* delete cpld[1-n] directory and attributes*/ +static void cpld_sub_remove(void) +{ + unsigned int cpld_index; + + if (g_cpld.cpld) { + for (cpld_index = g_cpld.cpld_number; cpld_index > 0; cpld_index--) { + cpld_sub_single_remove_kobj_and_attrs(cpld_index); + } + kfree(g_cpld.cpld); + g_cpld.cpld = NULL; + } + g_cpld.cpld_number = 0; + return; +} + +/* create cpld directory and number attributes */ +static int cpld_root_create(void) +{ + g_cpld_obj = switch_kobject_create("cpld", NULL); + if (!g_cpld_obj) { + CPLD_ERR("switch_kobject_create cpld error!\n"); + return -ENOMEM; + } + + if (sysfs_create_group(&g_cpld_obj->kobj, &cpld_root_attr_group) != 0) { + switch_kobject_delete(&g_cpld_obj); + CPLD_ERR("create cpld dir attrs error!\n"); + return -EBADRQC; + } + return 0; +} + +/* delete cpld directory and number attributes */ +static void cpld_root_remove(void) +{ + if (g_cpld_obj) { + sysfs_remove_group(&g_cpld_obj->kobj, &cpld_root_attr_group); + switch_kobject_delete(&g_cpld_obj); + } + + return; +} + +int s3ip_sysfs_cpld_drivers_register(struct s3ip_sysfs_cpld_drivers_s *drv) +{ + int ret, cpld_num; + + CPLD_INFO("s3ip_sysfs_cpld_drivers_register...\n"); + if (g_cpld_drv) { + CPLD_ERR("g_cpld_drv is not NULL, can't register\n"); + return -EPERM; + } + + check_p(drv); + check_p(drv->get_main_board_cpld_number); + g_cpld_drv = drv; + + cpld_num = g_cpld_drv->get_main_board_cpld_number(); + if (cpld_num <= 0) { + CPLD_ERR("cpld number: %d, don't need to create cpld dirs and attrs.\n", cpld_num); + g_cpld_drv = NULL; + return -EINVAL; + } + + memset(&g_cpld, 0, sizeof(struct cpld_s)); + g_cpld.cpld_number = cpld_num; + ret = cpld_root_create(); + if (ret < 0) { + CPLD_ERR("create cpld root dir and attrs failed, ret: %d\n", ret); + g_cpld_drv = NULL; + return ret; + } + ret = cpld_sub_create(); + if (ret < 0) { + CPLD_ERR("create cpld sub dir and attrs failed, ret: %d\n", ret); + cpld_root_remove(); + g_cpld_drv = NULL; + return ret; + } + CPLD_INFO("s3ip_sysfs_cpld_drivers_register success\n"); + return 0; +} + +void s3ip_sysfs_cpld_drivers_unregister(void) +{ + if (g_cpld_drv) { + cpld_sub_remove(); + cpld_root_remove(); + g_cpld_drv = NULL; + CPLD_DBG("s3ip_sysfs_cpld_drivers_unregister success.\n"); + } + return; +} + +EXPORT_SYMBOL(s3ip_sysfs_cpld_drivers_register); +EXPORT_SYMBOL(s3ip_sysfs_cpld_drivers_unregister); +module_param(g_cpld_loglevel, int, 0644); +MODULE_PARM_DESC(g_cpld_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/curr_sensor_sysfs.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/curr_sensor_sysfs.c new file mode 100644 index 000000000000..7972dd9b3ee1 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/curr_sensor_sysfs.c @@ -0,0 +1,391 @@ +/* + * curr_sensor_sysfs.c + * + * This module create curr sensor kobjects and attributes in /sys/s3ip/curr_sensor + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "switch.h" +#include "curr_sensor_sysfs.h" + +static int g_curr_sensor_loglevel = 0; + +#define CURR_SENSOR_INFO(fmt, args...) do { \ + if (g_curr_sensor_loglevel & INFO) { \ + printk(KERN_INFO "[CURR_SENSOR][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define CURR_SENSOR_ERR(fmt, args...) do { \ + if (g_curr_sensor_loglevel & ERR) { \ + printk(KERN_ERR "[CURR_SENSOR][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define CURR_SENSOR_DBG(fmt, args...) do { \ + if (g_curr_sensor_loglevel & DBG) { \ + printk(KERN_DEBUG "[CURR_SENSOR][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +struct curr_sensor_obj_s { + struct switch_obj *obj; +}; + +struct curr_sensor_s { + unsigned int curr_number; + struct curr_sensor_obj_s *curr; +}; + +static struct s3ip_sysfs_curr_sensor_drivers_s *g_curr_sensor_drv = NULL; +static struct curr_sensor_s g_curr_sensor; +static struct switch_obj *g_curr_sensor_obj = NULL; + +static ssize_t curr_sensor_number_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + return (ssize_t)snprintf(buf, PAGE_SIZE, "%u\n", g_curr_sensor.curr_number); +} + +static ssize_t curr_sensor_value_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int curr_index; + int ret; + + check_p(g_curr_sensor_drv); + check_p(g_curr_sensor_drv->get_main_board_curr_value); + + curr_index = obj->index; + CURR_SENSOR_DBG("curr index: %u\n", curr_index); + ret = g_curr_sensor_drv->get_main_board_curr_value(curr_index, buf, PAGE_SIZE); + if (ret < 0) { + CURR_SENSOR_ERR("get curr%u value failed, ret: %d\n", curr_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t curr_sensor_alias_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int curr_index; + int ret; + + check_p(g_curr_sensor_drv); + check_p(g_curr_sensor_drv->get_main_board_curr_alias); + + curr_index = obj->index; + CURR_SENSOR_DBG("curr index: %u\n", curr_index); + ret = g_curr_sensor_drv->get_main_board_curr_alias(curr_index, buf, PAGE_SIZE); + if (ret < 0) { + CURR_SENSOR_ERR("get curr%u alias failed, ret: %d\n", curr_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t curr_sensor_type_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int curr_index; + int ret; + + check_p(g_curr_sensor_drv); + check_p(g_curr_sensor_drv->get_main_board_curr_type); + + curr_index = obj->index; + CURR_SENSOR_DBG("curr index: %u\n", curr_index); + ret = g_curr_sensor_drv->get_main_board_curr_type(curr_index, buf, PAGE_SIZE); + if (ret < 0) { + CURR_SENSOR_ERR("get curr%u type failed, ret: %d\n", curr_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t curr_sensor_max_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int curr_index; + int ret; + + check_p(g_curr_sensor_drv); + check_p(g_curr_sensor_drv->get_main_board_curr_max); + + curr_index = obj->index; + CURR_SENSOR_DBG("curr index: %u\n", curr_index); + ret = g_curr_sensor_drv->get_main_board_curr_max(curr_index, buf, PAGE_SIZE); + if (ret < 0) { + CURR_SENSOR_ERR("get curr%u max threshold failed, ret: %d\n", curr_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t curr_sensor_max_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int curr_index; + int ret; + + check_p(g_curr_sensor_drv); + check_p(g_curr_sensor_drv->set_main_board_curr_max); + + curr_index = obj->index; + CURR_SENSOR_DBG("curr index: %u\n", curr_index); + ret = g_curr_sensor_drv->set_main_board_curr_max(curr_index, buf, count); + if (ret < 0) { + CURR_SENSOR_ERR("set curr%u max threshold failed, value: %s, count: %lu, ret: %d\n", + curr_index, buf, count, ret); + return -EIO; + } + CURR_SENSOR_DBG("set curr%u max threshold success, value: %s, count: %lu, ret: %d\n", + curr_index, buf, count, ret); + return count; +} + +static ssize_t curr_sensor_min_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int curr_index; + int ret; + + check_p(g_curr_sensor_drv); + check_p(g_curr_sensor_drv->get_main_board_curr_min); + + curr_index = obj->index; + CURR_SENSOR_DBG("curr index: %u\n", curr_index); + ret = g_curr_sensor_drv->get_main_board_curr_min(curr_index, buf, PAGE_SIZE); + if (ret < 0) { + CURR_SENSOR_ERR("get curr%u min threshold failed, ret: %d\n", curr_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t curr_sensor_min_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int curr_index; + int ret; + + check_p(g_curr_sensor_drv); + check_p(g_curr_sensor_drv->set_main_board_curr_min); + + curr_index = obj->index; + CURR_SENSOR_DBG("curr index: %u\n", curr_index); + ret = g_curr_sensor_drv->set_main_board_curr_min(curr_index, buf, count); + if (ret < 0) { + CURR_SENSOR_ERR("set curr%u min threshold failed, value: %s, count: %lu, ret: %d\n", + curr_index, buf, count, ret); + return -EIO; + } + CURR_SENSOR_DBG("set curr%u min threshold success, value: %s, count: %lu, ret: %d\n", + curr_index, buf, count, ret); + return count; +} + +/************************************curr_sensor dir and attrs*******************************************/ +static struct switch_attribute num_curr_att = __ATTR(number, S_IRUGO, curr_sensor_number_show, NULL); + +static struct attribute *curr_sensor_dir_attrs[] = { + &num_curr_att.attr, + NULL, +}; + +static struct attribute_group curr_sensor_root_attr_group = { + .attrs = curr_sensor_dir_attrs, +}; + +/*******************************curr1 curr2 dir and attrs*******************************************/ +static struct switch_attribute curr_value_attr = __ATTR(value, S_IRUGO, curr_sensor_value_show, NULL); +static struct switch_attribute curr_alias_attr = __ATTR(alias, S_IRUGO, curr_sensor_alias_show, NULL); +static struct switch_attribute curr_type_attr = __ATTR(type, S_IRUGO, curr_sensor_type_show, NULL); +static struct switch_attribute curr_max_attr = __ATTR(max, S_IRUGO | S_IWUSR, curr_sensor_max_show, curr_sensor_max_store); +static struct switch_attribute curr_min_attr = __ATTR(min, S_IRUGO | S_IWUSR, curr_sensor_min_show, curr_sensor_min_store); + +static struct attribute *curr_sensor_attrs[] = { + &curr_value_attr.attr, + &curr_alias_attr.attr, + &curr_type_attr.attr, + &curr_max_attr.attr, + &curr_min_attr.attr, + NULL, +}; + +static struct attribute_group curr_sensor_attr_group = { + .attrs = curr_sensor_attrs, +}; + +static int curr_sensor_sub_single_create_kobj_and_attrs(struct kobject *parent, unsigned int index) +{ + char name[DIR_NAME_MAX_LEN]; + struct curr_sensor_obj_s *curr_sensor; + + curr_sensor = &g_curr_sensor.curr[index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "curr%u", index); + curr_sensor->obj = switch_kobject_create(name, parent); + if (!curr_sensor->obj) { + CURR_SENSOR_ERR("create %s object error.\n", name); + return -ENOMEM; + } + curr_sensor->obj->index = index; + if (sysfs_create_group(&curr_sensor->obj->kobj, &curr_sensor_attr_group) != 0) { + CURR_SENSOR_ERR("create %s attrs error.\n", name); + switch_kobject_delete(&curr_sensor->obj); + return -EBADRQC; + } + CURR_SENSOR_DBG("create %s dir and attrs success.\n", name); + return 0; +} + +static void curr_sensor_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct curr_sensor_obj_s *curr_sensor; + + curr_sensor = &g_curr_sensor.curr[index - 1]; + if (curr_sensor->obj) { + sysfs_remove_group(&curr_sensor->obj->kobj, &curr_sensor_attr_group); + switch_kobject_delete(&curr_sensor->obj); + CURR_SENSOR_DBG("delete curr%u dir and attrs success.\n", index); + } + + return; +} + +static int curr_sensor_sub_create_kobj_and_attrs(struct kobject *parent, int curr_num) +{ + unsigned int curr_index, i; + + g_curr_sensor.curr = kzalloc(sizeof(struct curr_sensor_obj_s) * curr_num, GFP_KERNEL); + if (!g_curr_sensor.curr) { + CURR_SENSOR_ERR("kzalloc g_curr_sensor.curr error, curr number: %d.\n", curr_num); + return -ENOMEM; + } + + for (curr_index = 1; curr_index <= curr_num; curr_index++) { + if (curr_sensor_sub_single_create_kobj_and_attrs(parent, curr_index) != 0) { + goto error; + } + } + return 0; +error: + for (i = curr_index; i > 0; i--) { + curr_sensor_sub_single_remove_kobj_and_attrs(i); + } + kfree(g_curr_sensor.curr); + g_curr_sensor.curr = NULL; + return -EBADRQC; +} + +/* create curr[1-n] directory and attributes*/ +static int curr_sensor_sub_create(void) +{ + int ret; + + ret = curr_sensor_sub_create_kobj_and_attrs(&g_curr_sensor_obj->kobj, + g_curr_sensor.curr_number); + return ret; +} + +/* delete curr[1-n] directory and attributes*/ +static void curr_sensor_sub_remove(void) +{ + unsigned int curr_index; + + if (g_curr_sensor.curr) { + for (curr_index = g_curr_sensor.curr_number; curr_index > 0; curr_index--) { + curr_sensor_sub_single_remove_kobj_and_attrs(curr_index); + } + kfree(g_curr_sensor.curr); + g_curr_sensor.curr = NULL; + } + g_curr_sensor.curr_number = 0; + return; +} + +/* create curr_sensor directory and number attributes */ +static int curr_sensor_root_create(void) +{ + g_curr_sensor_obj = switch_kobject_create("curr_sensor", NULL); + if (!g_curr_sensor_obj) { + CURR_SENSOR_ERR("switch_kobject_create curr_sensor error!\n"); + return -ENOMEM; + } + + if (sysfs_create_group(&g_curr_sensor_obj->kobj, &curr_sensor_root_attr_group) != 0) { + switch_kobject_delete(&g_curr_sensor_obj); + CURR_SENSOR_ERR("create curr_sensor dir attrs error!\n"); + return -EBADRQC; + } + return 0; +} + +/* delete curr_sensor directory and number attributes */ +static void curr_sensor_root_remove(void) +{ + if (g_curr_sensor_obj) { + sysfs_remove_group(&g_curr_sensor_obj->kobj, &curr_sensor_root_attr_group); + switch_kobject_delete(&g_curr_sensor_obj); + } + + return; +} + +int s3ip_sysfs_curr_sensor_drivers_register(struct s3ip_sysfs_curr_sensor_drivers_s *drv) +{ + int ret, curr_num; + + CURR_SENSOR_INFO("s3ip_sysfs_curr_sensor_drivers_register...\n"); + if (g_curr_sensor_drv) { + CURR_SENSOR_ERR("g_curr_sensor_drv is not NULL, can't register\n"); + return -EPERM; + } + + check_p(drv); + check_p(drv->get_main_board_curr_number); + g_curr_sensor_drv = drv; + + curr_num = g_curr_sensor_drv->get_main_board_curr_number(); + if (curr_num <= 0) { + CURR_SENSOR_ERR("curr sensor number: %d, don't need to create curr_sensor dirs and attrs.\n", + curr_num); + return -EINVAL; + } + memset(&g_curr_sensor, 0, sizeof(struct curr_sensor_s)); + g_curr_sensor.curr_number = curr_num; + ret = curr_sensor_root_create(); + if (ret < 0) { + CURR_SENSOR_ERR("create curr_sensor root dir and attrs failed, ret: %d\n", ret); + g_curr_sensor_drv = NULL; + return ret; + } + + ret = curr_sensor_sub_create(); + if (ret < 0) { + CURR_SENSOR_ERR("create curr_sensor sub dir and attrs failed, ret: %d\n", ret); + curr_sensor_root_remove(); + g_curr_sensor_drv = NULL; + return ret; + } + CURR_SENSOR_INFO("s3ip_sysfs_curr_sensor_drivers_register success\n"); + return ret; +} + +void s3ip_sysfs_curr_sensor_drivers_unregister(void) +{ + if (g_curr_sensor_drv) { + curr_sensor_sub_remove(); + curr_sensor_root_remove(); + g_curr_sensor_drv = NULL; + CURR_SENSOR_DBG("s3ip_sysfs_curr_sensor_drivers_unregister success.\n"); + } + return; +} + +EXPORT_SYMBOL(s3ip_sysfs_curr_sensor_drivers_register); +EXPORT_SYMBOL(s3ip_sysfs_curr_sensor_drivers_unregister); +module_param(g_curr_sensor_loglevel, int, 0644); +MODULE_PARM_DESC(g_curr_sensor_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/fan_sysfs.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/fan_sysfs.c new file mode 100644 index 000000000000..ec3c85b68dcb --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/fan_sysfs.c @@ -0,0 +1,753 @@ +/* + * fan_sysfs.c + * + * This module create fan kobjects and attributes in /sys/s3ip/fan + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "switch.h" +#include "fan_sysfs.h" + +static int g_fan_loglevel = 0; + +#define FAN_INFO(fmt, args...) do { \ + if (g_fan_loglevel & INFO) { \ + printk(KERN_INFO "[FAN_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define FAN_ERR(fmt, args...) do { \ + if (g_fan_loglevel & ERR) { \ + printk(KERN_ERR "[FAN_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define FAN_DBG(fmt, args...) do { \ + if (g_fan_loglevel & DBG) { \ + printk(KERN_DEBUG "[FAN_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +struct motor_obj_s { + struct switch_obj *obj; +}; + +struct fan_obj_s { + unsigned int motor_number; + struct motor_obj_s *motor; + struct switch_obj *obj; +}; + +struct fan_s { + unsigned int fan_number; + struct fan_obj_s *fan; +}; + +static struct fan_s g_fan; +static struct switch_obj *g_fan_obj = NULL; +static struct s3ip_sysfs_fan_drivers_s *g_fan_drv = NULL; + +static ssize_t fan_number_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", g_fan.fan_number); +} + +static ssize_t fan_motor_number_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int index; + + index = obj->index; + FAN_DBG("fan_motor_number_show, fan index: %u\n", index); + + return (ssize_t)snprintf(buf, PAGE_SIZE, "%u\n", g_fan.fan[index - 1].motor_number); +} + +static ssize_t fan_model_name_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int fan_index; + int ret; + + check_p(g_fan_drv); + check_p(g_fan_drv->get_fan_model_name); + + fan_index = obj->index; + FAN_DBG("fan index: %u\n", fan_index); + ret = g_fan_drv->get_fan_model_name(fan_index, buf, PAGE_SIZE); + if (ret < 0) { + FAN_ERR("get fan%u model name failed, ret: %d\n", fan_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fan_sn_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int fan_index; + int ret; + + check_p(g_fan_drv); + check_p(g_fan_drv->get_fan_serial_number); + + fan_index = obj->index; + FAN_DBG("fan index: %u\n", fan_index); + ret = g_fan_drv->get_fan_serial_number(fan_index, buf, PAGE_SIZE); + if (ret < 0) { + FAN_ERR("get fan%u serial number failed, ret: %d\n", fan_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fan_pn_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int fan_index; + int ret; + + check_p(g_fan_drv); + check_p(g_fan_drv->get_fan_part_number); + + fan_index = obj->index; + FAN_DBG("fan index: %u\n", fan_index); + ret = g_fan_drv->get_fan_part_number(fan_index, buf, PAGE_SIZE); + if (ret < 0) { + FAN_ERR("get fan%u part number failed, ret: %d\n", fan_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fan_hw_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int fan_index; + int ret; + + check_p(g_fan_drv); + check_p(g_fan_drv->get_fan_hardware_version); + + fan_index = obj->index; + FAN_DBG("fan index: %u\n", fan_index); + ret = g_fan_drv->get_fan_hardware_version(fan_index, buf, PAGE_SIZE); + if (ret < 0) { + FAN_ERR("get fan%u hardware version failed, ret: %d\n", fan_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fan_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int fan_index; + int ret; + + check_p(g_fan_drv); + check_p(g_fan_drv->get_fan_status); + + fan_index = obj->index; + FAN_DBG("fan index: %u\n", fan_index); + ret = g_fan_drv->get_fan_status(fan_index, buf, PAGE_SIZE); + if (ret < 0) { + FAN_ERR("get fan%u status failed, ret: %d\n", fan_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fan_led_status_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int fan_index; + int ret; + + check_p(g_fan_drv); + check_p(g_fan_drv->get_fan_led_status); + + fan_index = obj->index; + FAN_DBG("fan index: %u\n", fan_index); + ret = g_fan_drv->get_fan_led_status(fan_index, buf, PAGE_SIZE); + if (ret < 0) { + FAN_ERR("get fan%u led status failed, ret: %d\n", fan_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fan_led_status_store(struct switch_obj *obj, struct switch_attribute *attr, + const char *buf, size_t count) +{ + unsigned int fan_index; + int ret, led_status; + + check_p(g_fan_drv); + check_p(g_fan_drv->set_fan_led_status); + + fan_index = obj->index; + sscanf(buf, "%d", &led_status); + FAN_DBG("fan index: %u, led_status: %d\n", fan_index, led_status); + ret = g_fan_drv->set_fan_led_status(fan_index, led_status); + if (ret < 0) { + FAN_ERR("set fan%u led_status: %d failed, ret: %d\n", fan_index, led_status, ret); + return -EIO; + } + FAN_DBG("set fan%u led_status: %d success\n", fan_index, led_status); + return count; +} + +static ssize_t fan_motor_speed_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int fan_index, motor_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_fan_drv); + check_p(g_fan_drv->get_fan_motor_speed); + + p_obj = to_switch_obj(obj->kobj.parent); + fan_index = p_obj->index; + motor_index = obj->index; + FAN_DBG("fan index: %u, motor index: %d\n", fan_index, motor_index); + ret = g_fan_drv->get_fan_motor_speed(fan_index, motor_index, buf, PAGE_SIZE); + if (ret < 0) { + FAN_ERR("get fan%u motor%u speed failed, ret: %d\n", fan_index, motor_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fan_motor_speed_tolerance_show(struct switch_obj *obj, + struct switch_attribute *attr, char *buf) +{ + unsigned int fan_index, motor_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_fan_drv); + check_p(g_fan_drv->get_fan_motor_speed_tolerance); + + p_obj = to_switch_obj(obj->kobj.parent); + fan_index = p_obj->index; + motor_index = obj->index; + FAN_DBG("fan index: %u, motor index: %d\n", fan_index, motor_index); + ret = g_fan_drv->get_fan_motor_speed_tolerance(fan_index, motor_index, buf, PAGE_SIZE); + if (ret < 0) { + FAN_ERR("get fan%u motor%u speed tolerance failed, ret: %d\n", + fan_index, motor_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fan_motor_speed_target_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int fan_index, motor_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_fan_drv); + check_p(g_fan_drv->get_fan_motor_speed_target); + + p_obj = to_switch_obj(obj->kobj.parent); + fan_index = p_obj->index; + motor_index = obj->index; + FAN_DBG("fan index: %u, motor index: %d\n", fan_index, motor_index); + ret = g_fan_drv->get_fan_motor_speed_target(fan_index, motor_index, buf, PAGE_SIZE); + if (ret < 0) { + FAN_ERR("get fan%u motor%u speed target failed, ret: %d\n", fan_index, motor_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fan_motor_speed_max_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int fan_index, motor_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_fan_drv); + check_p(g_fan_drv->get_fan_motor_speed_max); + + p_obj = to_switch_obj(obj->kobj.parent); + fan_index = p_obj->index; + motor_index = obj->index; + FAN_DBG("fan index: %u, motor index: %d\n", fan_index, motor_index); + ret = g_fan_drv->get_fan_motor_speed_max(fan_index, motor_index, buf, PAGE_SIZE); + if (ret < 0) { + FAN_ERR("get fan%u motor%u speed max threshold failed, ret: %d\n", + fan_index, motor_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fan_motor_speed_min_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int fan_index, motor_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_fan_drv); + check_p(g_fan_drv->get_fan_motor_speed_min); + + p_obj = to_switch_obj(obj->kobj.parent); + fan_index = p_obj->index; + motor_index = obj->index; + FAN_DBG("fan index: %u, motor index: %d\n", fan_index, motor_index); + ret = g_fan_drv->get_fan_motor_speed_min(fan_index, motor_index, buf, PAGE_SIZE); + if (ret < 0) { + FAN_ERR("get fan%u motor%u speed min threshold failed, ret: %d\n", + fan_index, motor_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +ssize_t fan_ratio_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int fan_index; + int ret; + + check_p(g_fan_drv); + check_p(g_fan_drv->get_fan_ratio); + + fan_index = obj->index; + FAN_DBG("fan index: %u\n", fan_index); + ret = g_fan_drv->get_fan_ratio(fan_index, buf, PAGE_SIZE); + if (ret < 0) { + FAN_ERR("get fan%u ratio failed, ret: %d\n", fan_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fan_ratio_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int fan_index; + int ret, ratio; + + check_p(g_fan_drv); + check_p(g_fan_drv->set_fan_ratio); + + fan_index = obj->index; + sscanf(buf, "%d", &ratio); + if (ratio < 0 || ratio > 100) { + FAN_ERR("param invalid, can not set ratio: %d.\n", ratio); + return -EINVAL; + } + FAN_DBG("fan index: %u, ratio: %d\n", fan_index, ratio); + ret = g_fan_drv->set_fan_ratio(fan_index, ratio); + if (ret < 0) { + FAN_ERR("set fan%u ratio: %d failed, ret: %d\n", fan_index, ratio, ret); + return -EIO; + } + FAN_DBG("set fan%u, ratio: %d success\n", fan_index, ratio); + return count; +} + +ssize_t fan_direction_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int fan_index; + int ret; + + check_p(g_fan_drv); + check_p(g_fan_drv->get_fan_direction); + + fan_index = obj->index; + FAN_DBG("fan index: %u\n", fan_index); + ret = g_fan_drv->get_fan_direction(fan_index, buf, PAGE_SIZE); + if (ret < 0) { + FAN_ERR("get fan%u direction failed, ret: %d\n", fan_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +/************************************fan dir and attrs*******************************************/ +static struct switch_attribute fan_number_att = __ATTR(number, S_IRUGO, fan_number_show, NULL); + +static struct attribute *fan_dir_attrs[] = { + &fan_number_att.attr, + NULL, +}; + +static struct attribute_group fan_root_attr_group = { + .attrs = fan_dir_attrs, +}; + +/*******************************fan1 fan2 dir and attrs*******************************************/ +static struct switch_attribute fan_model_name_attr = __ATTR(model_name, S_IRUGO, fan_model_name_show, NULL); +static struct switch_attribute fan_sn_attr = __ATTR(serial_number, S_IRUGO, fan_sn_show, NULL); +static struct switch_attribute fan_pn_attr = __ATTR(part_number, S_IRUGO, fan_pn_show, NULL); +static struct switch_attribute fan_hw_attr = __ATTR(hardware_version, S_IRUGO, fan_hw_show, NULL); +static struct switch_attribute fan_num_motors_attr = __ATTR(motor_number, S_IRUGO, fan_motor_number_show, NULL); +static struct switch_attribute fan_status_attr = __ATTR(status, S_IRUGO, fan_status_show, NULL); +static struct switch_attribute fan_led_status_attr = __ATTR(led_status, S_IRUGO | S_IWUSR, fan_led_status_show, fan_led_status_store); +static struct switch_attribute fan_direction_attr = __ATTR(direction, S_IRUGO, fan_direction_show, NULL); +static struct switch_attribute fan_ratio_attr = __ATTR(ratio, S_IRUGO | S_IWUSR, fan_ratio_show, fan_ratio_store); + +static struct attribute *fan_attrs[] = { + &fan_model_name_attr.attr, + &fan_sn_attr.attr, + &fan_pn_attr.attr, + &fan_hw_attr.attr, + &fan_num_motors_attr.attr, + &fan_status_attr.attr, + &fan_led_status_attr.attr, + &fan_direction_attr.attr, + &fan_ratio_attr.attr, + NULL, +}; + +static struct attribute_group fan_attr_group = { + .attrs = fan_attrs, +}; + +/*******************************motor1 motor2 dir and attrs*******************************************/ +static struct switch_attribute motor_speed_attr = __ATTR(speed, S_IRUGO, fan_motor_speed_show, NULL); +static struct switch_attribute motor_speed_tolerance_attr = __ATTR(speed_tolerance, S_IRUGO, fan_motor_speed_tolerance_show, NULL); +static struct switch_attribute motor_speed_target_attr = __ATTR(speed_target, S_IRUGO, fan_motor_speed_target_show, NULL); +static struct switch_attribute motor_speed_max_attr = __ATTR(speed_max, S_IRUGO, fan_motor_speed_max_show, NULL); +static struct switch_attribute motor_speed_min_attr = __ATTR(speed_min, S_IRUGO, fan_motor_speed_min_show, NULL); + +static struct attribute *motor_attrs[] = { + &motor_speed_attr.attr, + &motor_speed_tolerance_attr.attr, + &motor_speed_target_attr.attr, + &motor_speed_max_attr.attr, + &motor_speed_min_attr.attr, + NULL, +}; + +static struct attribute_group motor_attr_group = { + .attrs = motor_attrs, +}; + +static void fanindex_single_motor_remove_kobj_and_attrs(struct fan_obj_s *curr_fan, unsigned int motor_index) +{ + struct motor_obj_s *curr_motor; /* point to motor1 motor2...*/ + + curr_motor = &curr_fan->motor[motor_index - 1]; + if (curr_motor->obj) { + sysfs_remove_group(&curr_motor->obj->kobj, &motor_attr_group); + switch_kobject_delete(&curr_motor->obj); + FAN_DBG("delete fan%u motor%u dir and attrs success.\n", curr_fan->obj->index, + motor_index); + } + return; +} + +static int fanindex_single_motor_create_kobj_and_attrs(struct fan_obj_s *curr_fan, unsigned int motor_index) +{ + char name[8]; + struct motor_obj_s *curr_motor; /* point to motor1 motor2...*/ + + curr_motor = &curr_fan->motor[motor_index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "motor%u", motor_index); + curr_motor->obj = switch_kobject_create(name, &curr_fan->obj->kobj); + if (!curr_motor->obj) { + FAN_ERR("create fan%u, motor%u object error!\n", curr_fan->obj->index, motor_index); + return -ENOMEM; + } + + curr_motor->obj->index = motor_index; + if (sysfs_create_group(&curr_motor->obj->kobj, &motor_attr_group) != 0) { + FAN_ERR("create fan%u, motor%u attrs error.\n", curr_fan->obj->index, motor_index); + switch_kobject_delete(&curr_motor->obj); + return -EBADRQC; + } + FAN_DBG("create fan%u, motor%u dir and attrs success.\n", curr_fan->obj->index, motor_index); + return 0; +} + +/* create motor[1-n] directory and attributes in fan directory */ +static int fanindex_motor_create_kobj_and_attrs(struct fan_obj_s *curr_fan) +{ + unsigned int motor_index, i, motor_num; + + motor_num = curr_fan->motor_number; + curr_fan->motor = kzalloc(sizeof(struct motor_obj_s) * motor_num, GFP_KERNEL); + if (!curr_fan->motor) { + FAN_ERR("kzalloc motor error, fan index: %u, motor number: %d.\n", + curr_fan->obj->index, motor_num); + return -ENOMEM; + } + for(motor_index = 1; motor_index <= motor_num; motor_index++) { + if(fanindex_single_motor_create_kobj_and_attrs(curr_fan, motor_index) != 0 ) { + goto motor_error; + } + } + return 0; +motor_error: + for(i = motor_index; i > 0; i--) { + fanindex_single_motor_remove_kobj_and_attrs(curr_fan, i); + } + kfree(curr_fan->motor); + curr_fan->motor = NULL; + return -EBADRQC; +} + +/* delete motor[1-n] directory and attributes in fan directory */ +static void fanindex_motor_remove_kobj_and_attrs(struct fan_obj_s *curr_fan) +{ + unsigned int motor_index, motor_num; + + if (curr_fan->motor) { + motor_num = curr_fan->motor_number; + for(motor_index = motor_num; motor_index > 0; motor_index--) { + fanindex_single_motor_remove_kobj_and_attrs(curr_fan, motor_index); + } + kfree(curr_fan->motor); + curr_fan->motor = NULL; + } + + return; +} + +/* create motor[1-n] directory and attributes */ +static int fan_motor_create(void) +{ + int fan_num, motor_num; + unsigned int fan_index, i; + struct fan_obj_s *curr_fan; /* point to fan1 fan2...*/ + + fan_num = g_fan.fan_number; + if (fan_num <= 0) { + FAN_DBG("fan number: %d, skip to create motor* dirs and attrs.\n", fan_num); + return 0; + } + + check_p(g_fan_drv->get_fan_motor_number); + + for(fan_index = 1; fan_index <= fan_num; fan_index++) { + motor_num = g_fan_drv->get_fan_motor_number(fan_index); + if (motor_num <= 0) { + FAN_DBG("fan%u motor number: %d, don't need to create motor* dirs and attrs.\n", + fan_index, motor_num); + continue; + } + curr_fan = &g_fan.fan[fan_index - 1]; + curr_fan->motor_number = motor_num; + if(fanindex_motor_create_kobj_and_attrs(curr_fan) != 0) { + goto error; + } + } + return 0; +error: + for(i = fan_index; i > 0; i--) { + curr_fan = &g_fan.fan[i - 1]; + fanindex_motor_remove_kobj_and_attrs(curr_fan); + } + return -EBADRQC; +} + +/* delete motor[1-n] directory and attributes */ +static void fan_motor_remove(void) +{ + unsigned int fan_index; + struct fan_obj_s *curr_fan; + + if (g_fan.fan) { + for (fan_index = g_fan.fan_number; fan_index > 0; fan_index--) { + curr_fan = &g_fan.fan[fan_index - 1]; + fanindex_motor_remove_kobj_and_attrs(curr_fan); + curr_fan->motor_number = 0; + } + } + return; +} + +static int fan_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct fan_obj_s *curr_fan; + + curr_fan = &g_fan.fan[index - 1]; + if (curr_fan->obj) { + sysfs_remove_group(&curr_fan->obj->kobj, &fan_attr_group); + switch_kobject_delete(&curr_fan->obj); + FAN_DBG("delete fan%u dir and attrs success.\n", index); + } + return 0; +} + +static int fan_sub_single_create_kobj_and_attrs(struct kobject *parent, unsigned int index) +{ + char name[8]; + struct fan_obj_s *curr_fan; + + curr_fan = &g_fan.fan[index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "fan%u", index); + curr_fan->obj = switch_kobject_create(name, parent); + if (!curr_fan->obj) { + FAN_ERR("create %s object error!\n", name); + return -ENOMEM; + } + + curr_fan->obj->index = index; + if (sysfs_create_group(&curr_fan->obj->kobj, &fan_attr_group) != 0) { + FAN_ERR("create %s attrs error.\n", name); + switch_kobject_delete(&curr_fan->obj); + return -EBADRQC; + } + FAN_DBG("create %s dir and attrs success.\n", name); + return 0; +} + +/* create fan[1-n] directory and attributes */ +static int fan_sub_create_kobj_and_attrs(struct kobject *parent, int fan_num) +{ + unsigned int fan_index, i; + + g_fan.fan = kzalloc(sizeof(struct fan_obj_s) * fan_num, GFP_KERNEL); + if (!g_fan.fan) { + FAN_ERR("kzalloc fan.fan error, fan number: %d.\n", fan_num); + return -ENOMEM; + } + + for(fan_index = 1; fan_index <= fan_num; fan_index++) { + if(fan_sub_single_create_kobj_and_attrs(parent, fan_index) != 0 ) { + goto error; + } + } + return 0; +error: + for(i = fan_index; i > 0; i--) { + fan_sub_single_remove_kobj_and_attrs(i); + } + kfree(g_fan.fan); + g_fan.fan = NULL; + return -EBADRQC; +} + +static int fan_sub_create(void) +{ + int ret; + + ret = fan_sub_create_kobj_and_attrs(&g_fan_obj->kobj, g_fan.fan_number); + return ret; +} + +/* delete fan[1-n] directory and attributes */ +static void fan_sub_remove(void) +{ + unsigned int fan_index; + + if (g_fan.fan) { + for (fan_index = g_fan.fan_number; fan_index > 0; fan_index--) { + fan_sub_single_remove_kobj_and_attrs(fan_index); + } + kfree(g_fan.fan); + g_fan.fan = NULL; + } + g_fan.fan_number = 0; + + return; +} + +/* create fan directory and number attributes */ +static int fan_root_create(void) +{ + g_fan_obj = switch_kobject_create("fan", NULL); + if (!g_fan_obj) { + FAN_ERR("switch_kobject_create fan error!\n"); + return -ENOMEM; + } + + if (sysfs_create_group(&g_fan_obj->kobj, &fan_root_attr_group) != 0) { + switch_kobject_delete(&g_fan_obj); + FAN_ERR("create fan dir attrs error!\n"); + return -EBADRQC; + } + return 0; +} + +/* delete fan directory and number attributes */ +static void fan_root_remove(void) +{ + if (g_fan_obj) { + sysfs_remove_group(&g_fan_obj->kobj, &fan_root_attr_group); + switch_kobject_delete(&g_fan_obj); + FAN_DBG("delete fan dir and attrs success.\n"); + } + return; +} + +int s3ip_sysfs_fan_drivers_register(struct s3ip_sysfs_fan_drivers_s *drv) +{ + int ret, fan_num; + + FAN_INFO("s3ip_sysfs_fan_drivers_register...\n"); + if (g_fan_drv) { + FAN_ERR("g_fan_drv is not NULL, can't register\n"); + return -EPERM; + } + + check_p(drv); + check_p(drv->get_fan_number); + g_fan_drv = drv; + + fan_num = g_fan_drv->get_fan_number(); + if (fan_num <= 0) { + FAN_ERR("fan number: %d, don't need to create fan dirs and attrs.\n", fan_num); + g_fan_drv = NULL; + return -EINVAL; + } + + memset(&g_fan, 0, sizeof(struct fan_s)); + g_fan.fan_number = fan_num; + ret = fan_root_create(); + if (ret < 0) { + FAN_ERR("create fan root dir and attrs failed, ret: %d\n", ret); + g_fan_drv = NULL; + return ret; + } + + ret = fan_sub_create(); + if (ret < 0) { + FAN_ERR("create fan sub dir and attrs failed, ret: %d\n", ret); + fan_root_remove(); + g_fan_drv = NULL; + return ret; + } + + ret = fan_motor_create(); + if (ret < 0) { + FAN_ERR("create fan motor dir and attrs failed, ret: %d\n", ret); + fan_sub_remove(); + fan_root_remove(); + g_fan_drv = NULL; + return ret; + } + FAN_INFO("s3ip_sysfs_fan_drivers_register success.\n"); + return 0; +} + +void s3ip_sysfs_fan_drivers_unregister(void) +{ + if (g_fan_drv) { + fan_motor_remove(); + fan_sub_remove(); + fan_root_remove(); + g_fan_drv = NULL; + FAN_DBG("s3ip_sysfs_fan_drivers_unregister success.\n"); + } + return; +} + +EXPORT_SYMBOL(s3ip_sysfs_fan_drivers_register); +EXPORT_SYMBOL(s3ip_sysfs_fan_drivers_unregister); +module_param(g_fan_loglevel, int, 0644); +MODULE_PARM_DESC(g_fan_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/fpga_sysfs.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/fpga_sysfs.c new file mode 100644 index 000000000000..8a202c767acc --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/fpga_sysfs.c @@ -0,0 +1,365 @@ +/* + * fpga_sysfs.c + * + * This module create fpga kobjects and attributes in /sys/s3ip/fpga + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "switch.h" +#include "fpga_sysfs.h" + +static int g_fpga_loglevel = 0; + +#define FPGA_INFO(fmt, args...) do { \ + if (g_fpga_loglevel & INFO) { \ + printk(KERN_INFO "[FPGA_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define FPGA_ERR(fmt, args...) do { \ + if (g_fpga_loglevel & ERR) { \ + printk(KERN_ERR "[FPGA_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define FPGA_DBG(fmt, args...) do { \ + if (g_fpga_loglevel & DBG) { \ + printk(KERN_DEBUG "[FPGA_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +struct fpga_obj_s { + struct switch_obj *obj; +}; + +struct fpga_s { + unsigned int fpga_number; + struct fpga_obj_s *fpga; +}; + +static struct fpga_s g_fpga; +static struct switch_obj *g_fpga_obj = NULL; +static struct s3ip_sysfs_fpga_drivers_s *g_fpga_drv = NULL; + +static ssize_t fpga_number_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + return (ssize_t)snprintf(buf, PAGE_SIZE, "%u\n", g_fpga.fpga_number); +} + +static ssize_t fpga_alias_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int fpga_index; + int ret; + + check_p(g_fpga_drv); + check_p(g_fpga_drv->get_main_board_fpga_alias); + + fpga_index = obj->index; + FPGA_DBG("fpga index: %u\n", fpga_index); + ret = g_fpga_drv->get_main_board_fpga_alias(fpga_index, buf, PAGE_SIZE); + if (ret < 0) { + FPGA_ERR("get fpga%u alias failed, ret: %d\n", fpga_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fpga_type_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int fpga_index; + int ret; + + check_p(g_fpga_drv); + check_p(g_fpga_drv->get_main_board_fpga_type); + + fpga_index = obj->index; + FPGA_DBG("fpga index: %u\n", fpga_index); + ret = g_fpga_drv->get_main_board_fpga_type(fpga_index, buf, PAGE_SIZE); + if (ret < 0) { + FPGA_ERR("get fpga%u type failed, ret: %d\n", fpga_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fpga_fw_version_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int fpga_index; + int ret; + + check_p(g_fpga_drv); + check_p(g_fpga_drv->get_main_board_fpga_firmware_version); + + fpga_index = obj->index; + FPGA_DBG("fpga index: %u\n", fpga_index); + ret = g_fpga_drv->get_main_board_fpga_firmware_version(fpga_index, buf, PAGE_SIZE); + if (ret < 0) { + FPGA_ERR("get fpga%u firmware version failed, ret: %d\n", fpga_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fpga_board_version_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int fpga_index; + int ret; + + check_p(g_fpga_drv); + check_p(g_fpga_drv->get_main_board_fpga_board_version); + + fpga_index = obj->index; + FPGA_DBG("fpga index: %u\n", fpga_index); + ret = g_fpga_drv->get_main_board_fpga_board_version(fpga_index, buf, PAGE_SIZE); + if (ret < 0) { + FPGA_ERR("get fpga%u board version failed, ret: %d\n", fpga_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fpga_test_reg_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int fpga_index; + int ret; + + check_p(g_fpga_drv); + check_p(g_fpga_drv->get_main_board_fpga_test_reg); + + fpga_index = obj->index; + FPGA_DBG("fpga index: %u\n", fpga_index); + ret = g_fpga_drv->get_main_board_fpga_test_reg(fpga_index, buf, PAGE_SIZE); + if (ret < 0) { + FPGA_ERR("get fpga%u test register failed, ret: %d\n", fpga_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fpga_test_reg_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int fpga_index, value; + int ret; + + check_p(g_fpga_drv); + check_p(g_fpga_drv->set_main_board_fpga_test_reg); + + fpga_index = obj->index; + sscanf(buf, "0x%x", &value); + ret = g_fpga_drv->set_main_board_fpga_test_reg(fpga_index, value); + if (ret < 0) { + FPGA_ERR("set fpga%u test reg failed, value:0x%x, ret: %d.\n", fpga_index, value, ret); + return -EIO; + } + FPGA_DBG("set fpga%u test reg success, value: 0x%x.\n", fpga_index, value); + return count; +} + +/************************************fpga dir and attrs*******************************************/ +static struct switch_attribute fpga_number_att = __ATTR(number, S_IRUGO, fpga_number_show, NULL); + +static struct attribute *fpga_dir_attrs[] = { + &fpga_number_att.attr, + NULL, +}; + +static struct attribute_group fpga_root_attr_group = { + .attrs = fpga_dir_attrs, +}; + +/*******************************fpga[1-n] dir and attrs*******************************************/ +static struct switch_attribute fpga_alias_attr = __ATTR(alias, S_IRUGO, fpga_alias_show, NULL); +static struct switch_attribute fpga_type_attr = __ATTR(type, S_IRUGO, fpga_type_show, NULL); +static struct switch_attribute fpga_fw_version_attr = __ATTR(firmware_version, S_IRUGO, fpga_fw_version_show, NULL); +static struct switch_attribute fpga_board_version_attr = __ATTR(board_version, S_IRUGO, fpga_board_version_show, NULL); +static struct switch_attribute fpga_test_reg_attr = __ATTR(reg_test, S_IRUGO | S_IWUSR, fpga_test_reg_show, fpga_test_reg_store); + +static struct attribute *fpga_attrs[] = { + &fpga_alias_attr.attr, + &fpga_type_attr.attr, + &fpga_fw_version_attr.attr, + &fpga_board_version_attr.attr, + &fpga_test_reg_attr.attr, + NULL, +}; + +static struct attribute_group fpga_attr_group = { + .attrs = fpga_attrs, +}; + +static int fpga_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct fpga_obj_s *curr_fpga; + + curr_fpga = &g_fpga.fpga[index - 1]; + if (curr_fpga->obj) { + sysfs_remove_group(&curr_fpga->obj->kobj, &fpga_attr_group); + switch_kobject_delete(&curr_fpga->obj); + FPGA_DBG("delete fpga%u dir and attrs success.\n", index); + } + return 0; +} + +static int fpga_sub_single_create_kobj_and_attrs(struct kobject *parent, unsigned int index) +{ + char name[8]; + struct fpga_obj_s *curr_fpga; + + curr_fpga = &g_fpga.fpga[index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "fpga%u", index); + curr_fpga->obj = switch_kobject_create(name, parent); + if (!curr_fpga->obj) { + FPGA_ERR("create %s object error!\n", name); + return -EBADRQC; + } + curr_fpga->obj->index = index; + if (sysfs_create_group(&curr_fpga->obj->kobj, &fpga_attr_group) != 0) { + FPGA_ERR("create %s attrs error.\n", name); + switch_kobject_delete(&curr_fpga->obj); + return -EBADRQC; + } + FPGA_DBG("create %s dir and attrs success.\n", name); + return 0; +} + +static int fpga_sub_create_kobj_and_attrs(struct kobject *parent, int fpga_num) +{ + unsigned int fpga_index, i; + + g_fpga.fpga = kzalloc(sizeof(struct fpga_obj_s) * fpga_num, GFP_KERNEL); + if (!g_fpga.fpga) { + FPGA_ERR("kzalloc g_fpga.fpga error, fpga number = %d.\n", fpga_num); + return -ENOMEM; + } + + for(fpga_index = 1; fpga_index <= fpga_num; fpga_index++) { + if(fpga_sub_single_create_kobj_and_attrs(parent, fpga_index) != 0 ) { + goto error; + } + } + return 0; +error: + for(i = fpga_index; i > 0; i--) { + fpga_sub_single_remove_kobj_and_attrs(i); + } + kfree(g_fpga.fpga); + g_fpga.fpga = NULL; + return -EBADRQC; +} + +/* create fpga[1-n] directory and attributes*/ +static int fpga_sub_create(void) +{ + int ret; + + ret = fpga_sub_create_kobj_and_attrs(&g_fpga_obj->kobj, g_fpga.fpga_number); + return ret; +} + +/* delete fpga[1-n] directory and attributes*/ +static void fpga_sub_remove(void) +{ + unsigned int fpga_index; + + if (g_fpga.fpga) { + for (fpga_index = g_fpga.fpga_number; fpga_index > 0; fpga_index--) { + fpga_sub_single_remove_kobj_and_attrs(fpga_index); + } + kfree(g_fpga.fpga); + g_fpga.fpga = NULL; + } + g_fpga.fpga_number = 0; + return; +} + +/* create fpga directory and number attributes */ +static int fpga_root_create(void) +{ + g_fpga_obj = switch_kobject_create("fpga", NULL); + if (!g_fpga_obj) { + FPGA_ERR("switch_kobject_create fpga error!\n"); + return -ENOMEM; + } + + if (sysfs_create_group(&g_fpga_obj->kobj, &fpga_root_attr_group) != 0) { + switch_kobject_delete(&g_fpga_obj); + FPGA_ERR("create fpga dir attrs error!\n"); + return -EBADRQC; + } + return 0; +} + +/* delete fpga directory and number attributes */ +static void fpga_root_remove(void) +{ + if (g_fpga_obj) { + sysfs_remove_group(&g_fpga_obj->kobj, &fpga_root_attr_group); + switch_kobject_delete(&g_fpga_obj); + } + + return; +} + +int s3ip_sysfs_fpga_drivers_register(struct s3ip_sysfs_fpga_drivers_s *drv) +{ + int ret, fpga_num; + + FPGA_INFO("s3ip_sysfs_fpga_drivers_register...\n"); + if (g_fpga_drv) { + FPGA_ERR("g_fpga_drv is not NULL, can't register\n"); + return -EPERM; + } + + check_p(drv); + check_p(drv->get_main_board_fpga_number); + g_fpga_drv = drv; + + fpga_num = g_fpga_drv->get_main_board_fpga_number(); + if (fpga_num <= 0) { + FPGA_ERR("fpga number: %d, don't need to create fpga dirs and attrs.\n", fpga_num); + g_fpga_drv = NULL; + return -EINVAL; + } + + memset(&g_fpga, 0, sizeof(struct fpga_s)); + g_fpga.fpga_number = fpga_num; + ret = fpga_root_create(); + if (ret < 0) { + FPGA_ERR("create fpga root dir and attrs failed, ret: %d\n", ret); + g_fpga_drv = NULL; + return ret; + } + ret = fpga_sub_create(); + if (ret < 0) { + FPGA_ERR("create fpga sub dir and attrs failed, ret: %d\n", ret); + fpga_root_remove(); + g_fpga_drv = NULL; + return ret; + } + FPGA_INFO("s3ip_sysfs_fpga_drivers_register success\n"); + return 0; +} + +void s3ip_sysfs_fpga_drivers_unregister(void) +{ + if (g_fpga_drv) { + fpga_sub_remove(); + fpga_root_remove(); + g_fpga_drv = NULL; + FPGA_DBG("s3ip_sysfs_fpga_drivers_unregister success.\n"); + } + + return; +} + +EXPORT_SYMBOL(s3ip_sysfs_fpga_drivers_register); +EXPORT_SYMBOL(s3ip_sysfs_fpga_drivers_unregister); +module_param(g_fpga_loglevel, int, 0644); +MODULE_PARM_DESC(g_fpga_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/cpld_sysfs.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/cpld_sysfs.h new file mode 100644 index 000000000000..3d47a422ae01 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/cpld_sysfs.h @@ -0,0 +1,16 @@ +#ifndef _CPLD_SYSFS_H_ +#define _CPLD_SYSFS_H_ + +struct s3ip_sysfs_cpld_drivers_s { + int (*get_main_board_cpld_number)(void); + ssize_t (*get_main_board_cpld_alias)(unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_main_board_cpld_type)(unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_main_board_cpld_firmware_version)(unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_main_board_cpld_board_version)(unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_main_board_cpld_test_reg)(unsigned int cpld_index, char *buf, size_t count); + int (*set_main_board_cpld_test_reg)(unsigned int cpld_index, unsigned int value); +}; + +extern int s3ip_sysfs_cpld_drivers_register(struct s3ip_sysfs_cpld_drivers_s *drv); +extern void s3ip_sysfs_cpld_drivers_unregister(void); +#endif /*_CPLD_SYSFS_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/curr_sensor_sysfs.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/curr_sensor_sysfs.h new file mode 100644 index 000000000000..7a0b85a0fc3c --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/curr_sensor_sysfs.h @@ -0,0 +1,17 @@ +#ifndef _CURR_SENSOR_SYSFS_H_ +#define _CURR_SENSOR_SYSFS_H_ + +struct s3ip_sysfs_curr_sensor_drivers_s { + int (*get_main_board_curr_number)(void); + ssize_t (*get_main_board_curr_alias)(unsigned int curr_index, char *buf, size_t count); + ssize_t (*get_main_board_curr_type)(unsigned int curr_index, char *buf, size_t count); + ssize_t (*get_main_board_curr_max)(unsigned int curr_index, char *buf, size_t count); + int (*set_main_board_curr_max)(unsigned int curr_index, const char *buf, size_t count); + ssize_t (*get_main_board_curr_min)(unsigned int curr_index, char *buf, size_t count); + int (*set_main_board_curr_min)(unsigned int curr_index, const char *buf, size_t count); + ssize_t (*get_main_board_curr_value)(unsigned int curr_index, char *buf, size_t count); +}; + +extern int s3ip_sysfs_curr_sensor_drivers_register(struct s3ip_sysfs_curr_sensor_drivers_s *drv); +extern void s3ip_sysfs_curr_sensor_drivers_unregister(void); +#endif /*_CURR_SENSOR_SYSFS_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/fan_sysfs.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/fan_sysfs.h new file mode 100644 index 000000000000..fbd5ea82eca0 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/fan_sysfs.h @@ -0,0 +1,26 @@ +#ifndef _FAN_SYSFS_H_ +#define _FAN_SYSFS_H_ + +struct s3ip_sysfs_fan_drivers_s { + int (*get_fan_number)(void); + int (*get_fan_motor_number)(unsigned int fan_index); + ssize_t (*get_fan_model_name)(unsigned int fan_index, char *buf, size_t count); + ssize_t (*get_fan_serial_number)(unsigned int fan_index, char *buf, size_t count); + ssize_t (*get_fan_part_number)(unsigned int fan_index, char *buf, size_t count); + ssize_t (*get_fan_hardware_version)(unsigned int fan_index, char *buf, size_t count); + ssize_t (*get_fan_status)(unsigned int fan_index, char *buf, size_t count); + ssize_t (*get_fan_led_status)(unsigned int fan_index, char *buf, size_t count); + int (*set_fan_led_status)(unsigned int fan_index, int status); + ssize_t (*get_fan_direction)(unsigned int fan_index, char *buf, size_t count); + ssize_t (*get_fan_motor_speed)(unsigned int fan_index, unsigned int motor_index, char *buf, size_t count); + ssize_t (*get_fan_motor_speed_tolerance)(unsigned int fan_index, unsigned int motor_index, char *buf, size_t count); + ssize_t (*get_fan_motor_speed_target)(unsigned int fan_index, unsigned int motor_index, char *buf, size_t count); + ssize_t (*get_fan_motor_speed_max)(unsigned int fan_index, unsigned int motor_index, char *buf, size_t count); + ssize_t (*get_fan_motor_speed_min)(unsigned int fan_index, unsigned int motor_index, char *buf, size_t count); + ssize_t (*get_fan_ratio)(unsigned int fan_index, char *buf, size_t count); + int (*set_fan_ratio)(unsigned int fan_index, int ratio); +}; + +extern int s3ip_sysfs_fan_drivers_register(struct s3ip_sysfs_fan_drivers_s *drv); +extern void s3ip_sysfs_fan_drivers_unregister(void); +#endif /*_FAN_SYSFS_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/fpga_sysfs.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/fpga_sysfs.h new file mode 100644 index 000000000000..c8a6935e4638 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/fpga_sysfs.h @@ -0,0 +1,16 @@ +#ifndef _FPGA_SYSFS_H_ +#define _FPGA_SYSFS_H_ + +struct s3ip_sysfs_fpga_drivers_s { + int (*get_main_board_fpga_number)(void); + ssize_t (*get_main_board_fpga_alias)(unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_main_board_fpga_type)(unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_main_board_fpga_firmware_version)(unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_main_board_fpga_board_version)(unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_main_board_fpga_test_reg)(unsigned int fpga_index, char *buf, size_t count); + int (*set_main_board_fpga_test_reg)(unsigned int fpga_index, unsigned int value); +}; + +extern int s3ip_sysfs_fpga_drivers_register(struct s3ip_sysfs_fpga_drivers_s *drv); +extern void s3ip_sysfs_fpga_drivers_unregister(void); +#endif /*_FPGA_SYSFS_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/psu_sysfs.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/psu_sysfs.h new file mode 100644 index 000000000000..4f6d1aba3d92 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/psu_sysfs.h @@ -0,0 +1,38 @@ +#ifndef _PSU_SYSFS_H_ +#define _PSU_SYSFS_H_ + +struct s3ip_sysfs_psu_drivers_s { + int (*get_psu_number)(void); + int (*get_psu_temp_number)(unsigned int psu_index); + ssize_t (*get_psu_model_name)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_serial_number)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_part_number)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_hardware_version)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_type)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_in_curr)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_in_vol)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_in_power)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_out_curr)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_out_vol)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_out_power)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_out_max_power)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_present_status)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_in_status)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_out_status)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_fan_speed)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_fan_ratio)(unsigned int psu_index, char *buf, size_t count); + int (*set_psu_fan_ratio)(unsigned int psu_index, int ratio); + ssize_t (*get_psu_fan_direction)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_led_status)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_temp_alias)(unsigned int psu_index, unsigned int temp_index, char *buf, size_t count); + ssize_t (*get_psu_temp_type)(unsigned int psu_index, unsigned int temp_index, char *buf, size_t count); + ssize_t (*get_psu_temp_max)(unsigned int psu_index, unsigned int temp_index, char *buf, size_t count); + int (*set_psu_temp_max)(unsigned int psu_index, unsigned int temp_index, const char *buf, size_t count); + ssize_t (*get_psu_temp_min)(unsigned int psu_index, unsigned int temp_index, char *buf, size_t count); + int (*set_psu_temp_min)(unsigned int psu_index, unsigned int temp_index, const char *buf, size_t count); + ssize_t (*get_psu_temp_value)(unsigned int psu_index, unsigned int temp_index, char *buf, size_t count); +}; + +extern int s3ip_sysfs_psu_drivers_register(struct s3ip_sysfs_psu_drivers_s *drv); +extern void s3ip_sysfs_psu_drivers_unregister(void); +#endif /*_PSU_SYSFS_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/slot_sysfs.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/slot_sysfs.h new file mode 100644 index 000000000000..058ee450598b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/slot_sysfs.h @@ -0,0 +1,57 @@ +#ifndef _SLOT_SYSFS_H_ +#define _SLOT_SYSFS_H_ + +struct s3ip_sysfs_slot_drivers_s { + int (*get_slot_number)(void); + int (*get_slot_temp_number)(unsigned int slot_index); + int (*get_slot_vol_number)(unsigned int slot_index); + int (*get_slot_curr_number)(unsigned int slot_index); + int (*get_slot_cpld_number)(unsigned int slot_index); + int (*get_slot_fpga_number)(unsigned int slot_index); + ssize_t (*get_slot_model_name)(unsigned int slot_index, char *buf, size_t count); + ssize_t (*get_slot_serial_number)(unsigned int slot_index, char *buf, size_t count); + ssize_t (*get_slot_part_number)(unsigned int slot_index, char *buf, size_t count); + ssize_t (*get_slot_hardware_version)(unsigned int slot_index, char *buf, size_t count); + ssize_t (*get_slot_status)(unsigned int slot_index, char *buf, size_t count); + ssize_t (*get_slot_led_status)(unsigned int slot_index, char *buf, size_t count); + int (*set_slot_led_status)(unsigned int slot_index, int status); + ssize_t (*get_slot_temp_alias)(unsigned int slot_index, unsigned int temp_index, char *buf, size_t count); + ssize_t (*get_slot_temp_type)(unsigned int slot_index, unsigned int temp_index, char *buf, size_t count); + ssize_t (*get_slot_temp_max)(unsigned int slot_index, unsigned int temp_index, char *buf, size_t count); + int (*set_slot_temp_max)(unsigned int slot_index, unsigned int temp_index, const char *buf, size_t count); + ssize_t (*get_slot_temp_min)(unsigned int slot_index, unsigned int temp_index, char *buf, size_t count); + int (*set_slot_temp_min)(unsigned int slot_index, unsigned int temp_index, const char *buf, size_t count); + ssize_t (*get_slot_temp_value)(unsigned int slot_index, unsigned int temp_index, char *buf, size_t count); + ssize_t (*get_slot_vol_alias)(unsigned int slot_index, unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_slot_vol_type)(unsigned int slot_index, unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_slot_vol_max)(unsigned int slot_index, unsigned int vol_index, char *buf, size_t count); + int (*set_slot_vol_max)(unsigned int slot_index, unsigned int vol_index, const char *buf, size_t count); + ssize_t (*get_slot_vol_min)(unsigned int slot_index, unsigned int vol_index, char *buf, size_t count); + int (*set_slot_vol_min)(unsigned int slot_index, unsigned int vol_index, const char *buf, size_t count); + ssize_t (*get_slot_vol_range)(unsigned int slot_index, unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_slot_vol_nominal_value)(unsigned int slot_index, unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_slot_vol_value)(unsigned int slot_index, unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_slot_curr_alias)(unsigned int slot_index, unsigned int curr_index, char *buf, size_t count); + ssize_t (*get_slot_curr_type)(unsigned int slot_index, unsigned int curr_index, char *buf, size_t count); + ssize_t (*get_slot_curr_max)(unsigned int slot_index, unsigned int curr_index, char *buf, size_t count); + int (*set_slot_curr_max)(unsigned int slot_index, unsigned int curr_index, const char *buf, size_t count); + ssize_t (*get_slot_curr_min)(unsigned int slot_index, unsigned int curr_index, char *buf, size_t count); + int (*set_slot_curr_min)(unsigned int slot_index, unsigned int curr_index, const char *buf, size_t count); + ssize_t (*get_slot_curr_value)(unsigned int slot_index, unsigned int curr_index, char *buf, size_t count); + ssize_t (*get_slot_fpga_alias)(unsigned int slot_index, unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_slot_fpga_type)(unsigned int slot_index, unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_slot_fpga_firmware_version)(unsigned int slot_index, unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_slot_fpga_board_version)(unsigned int slot_index, unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_slot_fpga_test_reg)(unsigned int slot_index, unsigned int fpga_index, char *buf, size_t count); + int (*set_slot_fpga_test_reg)(unsigned int slot_index, unsigned int fpga_index, unsigned int value); + ssize_t (*get_slot_cpld_alias)(unsigned int slot_index, unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_slot_cpld_type)(unsigned int slot_index, unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_slot_cpld_firmware_version)(unsigned int slot_index, unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_slot_cpld_board_version)(unsigned int slot_index, unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_slot_cpld_test_reg)(unsigned int slot_index, unsigned int cpld_index, char *buf, size_t count); + int (*set_slot_cpld_test_reg)(unsigned int slot_index, unsigned int cpld_index, unsigned int value); +}; + +extern int s3ip_sysfs_slot_drivers_register(struct s3ip_sysfs_slot_drivers_s *drv); +extern void s3ip_sysfs_slot_drivers_unregister(void); +#endif /*_SLOT_SYSFS_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/switch.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/switch.h new file mode 100644 index 000000000000..ea0b1a266b1f --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/switch.h @@ -0,0 +1,68 @@ +#ifndef _SWITCH_H_ +#define _SWITCH_H_ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define DIR_NAME_MAX_LEN (64) +#define SYSFS_DEV_ERROR "NA" + +enum LOG_LEVEL{ + INFO = 0x1, + ERR = 0x2, + DBG = 0x4, + ALL = 0xf +}; + +extern int g_switch_loglevel; + +#define check_pfun(p) do { \ + if (p == NULL) { \ + if (g_switch_loglevel & ERR) { \ + printk( KERN_ERR "%s, %s is NULL.\n", __FUNCTION__, #p); \ + } \ + return -ENOSYS; \ + } \ +} while(0) + +#define check_p(p) check_pfun(p) + +#define to_switch_obj(x) container_of(x, struct switch_obj, kobj) +#define to_switch_attr(x) container_of(x, struct switch_attribute, attr) +#define to_switch_device_attr(x) container_of(x, struct switch_device_attribute, switch_attr) + +#define SWITCH_ATTR(_name, _mode, _show, _store, _type) \ + { .switch_attr = __ATTR(_name, _mode, _show, _store), \ + .type = _type } + +#define SWITCH_DEVICE_ATTR(_name, _mode, _show, _store, _type) \ +struct switch_device_attribute switch_dev_attr_##_name \ + = SWITCH_ATTR(_name, _mode, _show, _store, _type) + +struct switch_obj { + struct kobject kobj; + unsigned int index; +}; + +/* a custom attribute that works just for a struct switch_obj. */ +struct switch_attribute { + struct attribute attr; + ssize_t (*show)(struct switch_obj *foo, struct switch_attribute *attr, char *buf); + ssize_t (*store)(struct switch_obj *foo, struct switch_attribute *attr, const char *buf, size_t count); +}; + +struct switch_device_attribute { + struct switch_attribute switch_attr; + int type; +}; + +struct switch_obj *switch_kobject_create(const char *name, struct kobject *parent); +void switch_kobject_delete(struct switch_obj **obj); + +#endif /* _SWITCH_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/syseeprom_sysfs.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/syseeprom_sysfs.h new file mode 100644 index 000000000000..c6b2c5c3456f --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/syseeprom_sysfs.h @@ -0,0 +1,12 @@ +#ifndef _SYSEEPROM_SYSFS_H_ +#define _SYSEEPROM_SYSFS_H_ + +struct s3ip_sysfs_syseeprom_drivers_s { + int (*get_syseeprom_size)(void); + ssize_t (*read_syseeprom_data)(char *buf, loff_t offset, size_t count); + ssize_t (*write_syseeprom_data)(char *buf, loff_t offset, size_t count); +}; + +extern int s3ip_sysfs_syseeprom_drivers_register(struct s3ip_sysfs_syseeprom_drivers_s *drv); +extern void s3ip_sysfs_syseeprom_drivers_unregister(void); +#endif /*_SYSEEPROM_SYSFS_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/sysled_sysfs.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/sysled_sysfs.h new file mode 100644 index 000000000000..e4383a4eea27 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/sysled_sysfs.h @@ -0,0 +1,19 @@ +#ifndef _SYSLED_SYSFS_H_ +#define _SYSLED_SYSFS_H_ + +struct s3ip_sysfs_sysled_drivers_s { + ssize_t (*get_sys_led_status)(char *buf, size_t count); + int (*set_sys_led_status)(int status); + ssize_t (*get_bmc_led_status)(char *buf, size_t count); + int (*set_bmc_led_status)(int status); + ssize_t (*get_sys_fan_led_status)(char *buf, size_t count); + int (*set_sys_fan_led_status)(int status); + ssize_t (*get_sys_psu_led_status)(char *buf, size_t count); + int (*set_sys_psu_led_status)(int status); + ssize_t (*get_id_led_status)(char *buf, size_t count); + int (*set_id_led_status)(int status); +}; + +extern int s3ip_sysfs_sysled_drivers_register(struct s3ip_sysfs_sysled_drivers_s *drv); +extern void s3ip_sysfs_sysled_drivers_unregister(void); +#endif /*_SYSLED_SYSFS_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/temp_sensor_sysfs.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/temp_sensor_sysfs.h new file mode 100644 index 000000000000..db03a96a0cba --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/temp_sensor_sysfs.h @@ -0,0 +1,17 @@ +#ifndef _TEMP_SENSOR_SYSFS_H_ +#define _TEMP_SENSOR_SYSFS_H_ + +struct s3ip_sysfs_temp_sensor_drivers_s { + int (*get_main_board_temp_number)(void); + ssize_t (*get_main_board_temp_alias)(unsigned int temp_index, char *buf, size_t count); + ssize_t (*get_main_board_temp_type)(unsigned int temp_index, char *buf, size_t count); + ssize_t (*get_main_board_temp_max)(unsigned int temp_index, char *buf, size_t count); + int (*set_main_board_temp_max)(unsigned int temp_index, const char *buf, size_t count); + ssize_t (*get_main_board_temp_min)(unsigned int temp_index, char *buf, size_t count); + int (*set_main_board_temp_min)(unsigned int temp_index, const char *buf, size_t count); + ssize_t (*get_main_board_temp_value)(unsigned int temp_index, char *buf, size_t count); +}; + +extern int s3ip_sysfs_temp_sensor_drivers_register(struct s3ip_sysfs_temp_sensor_drivers_s *drv); +extern void s3ip_sysfs_temp_sensor_drivers_unregister(void); +#endif /*_TEMP_SENSOR_SYSFS_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/transceiver_sysfs.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/transceiver_sysfs.h new file mode 100644 index 000000000000..7e8634c1ef01 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/transceiver_sysfs.h @@ -0,0 +1,26 @@ +#ifndef _TRANSCEIVER_SYSFS_H_ +#define _TRANSCEIVER_SYSFS_H_ + +struct s3ip_sysfs_transceiver_drivers_s { + int (*get_eth_number)(void); + ssize_t (*get_transceiver_power_on_status)(char *buf, size_t count); + int (*set_transceiver_power_on_status)(int status); + ssize_t (*get_eth_power_on_status)(unsigned int eth_index, char *buf, size_t count); + int (*set_eth_power_on_status)(unsigned int eth_index, int status); + ssize_t (*get_eth_tx_fault_status)(unsigned int eth_index, char *buf, size_t count); + ssize_t (*get_eth_tx_disable_status)(unsigned int eth_index, char *buf, size_t count); + int (*set_eth_tx_disable_status)(unsigned int eth_index, int status); + ssize_t (*get_eth_present_status)(unsigned int eth_index, char *buf, size_t count); + ssize_t (*get_eth_rx_los_status)(unsigned int eth_index, char *buf, size_t count); + ssize_t (*get_eth_reset_status)(unsigned int eth_index, char *buf, size_t count); + int (*set_eth_reset_status)(unsigned int eth_index, int status); + ssize_t (*get_eth_low_power_mode_status)(unsigned int eth_index, char *buf, size_t count); + ssize_t (*get_eth_interrupt_status)(unsigned int eth_index, char *buf, size_t count); + int (*get_eth_eeprom_size)(unsigned int eth_index); + ssize_t (*read_eth_eeprom_data)(unsigned int eth_index, char *buf, loff_t offset, size_t count); + ssize_t (*write_eth_eeprom_data)(unsigned int eth_index, char *buf, loff_t offset, size_t count); +}; + +extern int s3ip_sysfs_sff_drivers_register(struct s3ip_sysfs_transceiver_drivers_s *drv); +extern void s3ip_sysfs_sff_drivers_unregister(void); +#endif /*_TRANSCEIVER_SYSFS_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/vol_sensor_sysfs.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/vol_sensor_sysfs.h new file mode 100644 index 000000000000..b2d7d615c421 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/vol_sensor_sysfs.h @@ -0,0 +1,19 @@ +#ifndef _VOL_SENSOR_SYSFS_H_ +#define _VOL_SENSOR_SYSFS_H_ + +struct s3ip_sysfs_vol_sensor_drivers_s { + int (*get_main_board_vol_number)(void); + ssize_t (*get_main_board_vol_alias)(unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_main_board_vol_type)(unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_main_board_vol_max)(unsigned int vol_index, char *buf, size_t count); + int (*set_main_board_vol_max)(unsigned int vol_index, const char *buf, size_t count); + ssize_t (*get_main_board_vol_min)(unsigned int vol_index, char *buf, size_t count); + int (*set_main_board_vol_min)(unsigned int vol_index, const char *buf, size_t count); + ssize_t (*get_main_board_vol_range)(unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_main_board_vol_nominal_value)(unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_main_board_vol_value)(unsigned int vol_index, char *buf, size_t count); +}; + +extern int s3ip_sysfs_vol_sensor_drivers_register(struct s3ip_sysfs_vol_sensor_drivers_s *drv); +extern void s3ip_sysfs_vol_sensor_drivers_unregister(void); +#endif /*_VOL_SENSOR_SYSFS_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/watchdog_sysfs.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/watchdog_sysfs.h new file mode 100644 index 000000000000..7e86e4c006d9 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/watchdog_sysfs.h @@ -0,0 +1,16 @@ +#ifndef _WATCHDOG_SYSFS_H_ +#define _WATCHDOG_SYSFS_H_ + +struct s3ip_sysfs_watchdog_drivers_s { + ssize_t (*get_watchdog_identify)(char *buf, size_t count); + ssize_t (*get_watchdog_timeleft)(char *buf, size_t count); + ssize_t (*get_watchdog_timeout)(char *buf, size_t count); + int (*set_watchdog_timeout)(int value); + ssize_t (*get_watchdog_enable_status)(char *buf, size_t count); + int (*set_watchdog_enable_status)(int value); + int (*set_watchdog_reset)(int value); +}; + +extern int s3ip_sysfs_watchdog_drivers_register(struct s3ip_sysfs_watchdog_drivers_s *drv); +extern void s3ip_sysfs_watchdog_drivers_unregister(void); +#endif /*_WATCHDOG_SYSFS_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/psu_sysfs.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/psu_sysfs.c new file mode 100644 index 000000000000..50005f875345 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/psu_sysfs.c @@ -0,0 +1,990 @@ +/* + * psu_sysfs.c + * + * This module create psu kobjects and attributes in /sys/s3ip/psu + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "switch.h" +#include "psu_sysfs.h" + +static int g_psu_loglevel = 0; + +#define PSU_INFO(fmt, args...) do { \ + if (g_psu_loglevel & INFO) { \ + printk(KERN_INFO "[PSU_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define PSU_ERR(fmt, args...) do { \ + if (g_psu_loglevel & ERR) { \ + printk(KERN_ERR "[PSU_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define PSU_DBG(fmt, args...) do { \ + if (g_psu_loglevel & DBG) { \ + printk(KERN_DEBUG "[PSU_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +struct temp_obj_s { + struct switch_obj *obj; +}; + +struct psu_obj_s { + unsigned int temp_number; + struct temp_obj_s *temp; + struct switch_obj *obj; +}; + +struct psu_s{ + unsigned int psu_number; + struct psu_obj_s *psu; +}; + +static struct psu_s g_psu; +static struct switch_obj *g_psu_obj = NULL; +static struct s3ip_sysfs_psu_drivers_s *g_psu_drv = NULL; + +static ssize_t psu_number_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", g_psu.psu_number); +} + +static ssize_t psu_temp_number_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int index; + + index = obj->index; + PSU_DBG("psu index: %u\n",index); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%u\n", g_psu.psu[index - 1].temp_number); +} + +static ssize_t psu_model_name_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_model_name); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_model_name(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u model name failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_hw_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_hardware_version); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_hardware_version(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u hardware version failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_sn_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_serial_number); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_serial_number(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u serial number failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_pn_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_part_number); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_part_number(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u part number failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_type_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_type); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_type(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u type failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_in_curr_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_in_curr); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_in_curr(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u input current failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_in_vol_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_in_vol); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_in_vol(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u input voltage failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_in_power_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_in_power); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_in_power(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u input power failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_out_curr_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_out_curr); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_out_curr(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u output current failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_out_vol_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_out_vol); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_out_vol(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u output voltage failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_out_power_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_out_power); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_out_power(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u outout power failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_out_max_power_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_out_max_power); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_out_max_power(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u outout max power failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_present_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_present_status); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_present_status(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u present status failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_out_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_out_status); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_out_status(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u outout status failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_in_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_in_status); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_in_status(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u input status failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_fan_speed_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_fan_speed); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_fan_speed(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u fan speed failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +ssize_t psu_fan_ratio_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_fan_ratio); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_fan_ratio(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u fan ratio failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_fan_ratio_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int psu_index; + int ret, ratio; + + check_p(g_psu_drv); + check_p(g_psu_drv->set_psu_fan_ratio); + + psu_index = obj->index; + sscanf(buf, "%d", &ratio); + if (ratio < 0 || ratio > 100) { + PSU_ERR("param invalid, can not set ratio: %d.\n", ratio); + return -EINVAL; + } + PSU_DBG("psu index: %u, ratio: %d\n", psu_index, ratio); + ret = g_psu_drv->set_psu_fan_ratio(psu_index, ratio); + if (ret < 0) { + PSU_ERR("set psu%u ratio: %d failed, ret: %d\n", + psu_index, ratio, ret); + return -EIO; + } + PSU_DBG("set psu%u, ratio: %d success\n", psu_index, ratio); + return count; +} + +static ssize_t psu_fan_direction_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_fan_direction); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_fan_direction(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u fan direction failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_led_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_led_status); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_led_status(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u led status failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_temp_value_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_temp_value); + + p_obj = to_switch_obj(obj->kobj.parent); + psu_index = p_obj->index; + temp_index = obj->index; + + PSU_DBG("psu index: %u, temp index: %u\n", psu_index, temp_index); + ret = g_psu_drv->get_psu_temp_value(psu_index, temp_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u temp%u value failed, ret: %d\n", psu_index, temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_temp_alias_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_temp_alias); + + p_obj = to_switch_obj(obj->kobj.parent); + psu_index = p_obj->index; + temp_index = obj->index; + + PSU_DBG("psu index: %u, temp index: %u\n", psu_index, temp_index); + ret = g_psu_drv->get_psu_temp_alias(psu_index, temp_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u temp%u alias failed, ret: %d\n", psu_index, temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_temp_type_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_temp_type); + + p_obj = to_switch_obj(obj->kobj.parent); + psu_index = p_obj->index; + temp_index = obj->index; + + PSU_DBG("psu index: %u, temp index: %u\n", psu_index, temp_index); + ret = g_psu_drv->get_psu_temp_type(psu_index, temp_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u temp%u type failed, ret: %d\n", psu_index, temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_temp_max_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_temp_max); + + p_obj = to_switch_obj(obj->kobj.parent); + psu_index = p_obj->index; + temp_index = obj->index; + + PSU_DBG("psu index: %u, temp index: %u\n", psu_index, temp_index); + ret = g_psu_drv->get_psu_temp_max(psu_index, temp_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u temp%u max threshold failed, ret: %d\n", + psu_index, temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_temp_max_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int psu_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_psu_drv); + check_p(g_psu_drv->set_psu_temp_max); + + p_obj = to_switch_obj(obj->kobj.parent); + psu_index = p_obj->index; + temp_index = obj->index; + ret = g_psu_drv->set_psu_temp_max(psu_index, temp_index, buf, count); + if (ret < 0) { + PSU_ERR("set psu%u temp%u max threshold failed, value: %s, count: %lu, ret: %d\n", + psu_index, temp_index, buf, count, ret); + return -EIO; + } + PSU_DBG("set psu%u temp%u max threshold success, value: %s, count: %lu, ret: %d\n", + psu_index, temp_index, buf, count, ret); + return count; +} + +static ssize_t psu_temp_min_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_temp_min); + + p_obj = to_switch_obj(obj->kobj.parent); + psu_index = p_obj->index; + temp_index = obj->index; + + PSU_DBG("psu index: %u, temp index: %u\n", psu_index, temp_index); + ret = g_psu_drv->get_psu_temp_min(psu_index, temp_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u temp%u min threshold failed, ret: %d\n", + psu_index, temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_temp_min_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int psu_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_psu_drv); + check_p(g_psu_drv->set_psu_temp_min); + + p_obj = to_switch_obj(obj->kobj.parent); + psu_index = p_obj->index; + temp_index = obj->index; + ret = g_psu_drv->set_psu_temp_min(psu_index, temp_index, buf, count); + if (ret < 0) { + PSU_ERR("set psu%u temp%u min threshold failed, value: %s, count: %lu, ret: %d\n", + psu_index, temp_index, buf, count, ret); + return -EIO; + } + PSU_DBG("set psu%u temp%u min threshold success, value: %s, count: %lu, ret: %d\n", + psu_index, temp_index, buf, count, ret); + return count; +} + +/************************************psu dir and attrs*******************************************/ +static struct switch_attribute psu_number_att = __ATTR(number, S_IRUGO, psu_number_show, NULL); + +static struct attribute *psu_dir_attrs[] = { + &psu_number_att.attr, + NULL, +}; + +static struct attribute_group psu_root_attr_group = { + .attrs = psu_dir_attrs, +}; + +/*******************************psu[1-n] dir and attrs*******************************************/ +static struct switch_attribute psu_model_name_attr = __ATTR(model_name, S_IRUGO, psu_model_name_show, NULL); +static struct switch_attribute psu_hw_attr = __ATTR(hardware_version, S_IRUGO, psu_hw_show, NULL); +static struct switch_attribute psu_sn_attr = __ATTR(serial_number, S_IRUGO, psu_sn_show, NULL); +static struct switch_attribute psu_pn_attr = __ATTR(part_number, S_IRUGO, psu_pn_show, NULL); +static struct switch_attribute psu_type_attr = __ATTR(type, S_IRUGO, psu_type_show, NULL); +static struct switch_attribute psu_in_curr_attr = __ATTR(in_curr, S_IRUGO, psu_in_curr_show, NULL); +static struct switch_attribute psu_in_vol_attr = __ATTR(in_vol, S_IRUGO, psu_in_vol_show, NULL); +static struct switch_attribute psu_in_power_attr = __ATTR(in_power, S_IRUGO, psu_in_power_show, NULL); +static struct switch_attribute psu_out_curr_attr = __ATTR(out_curr, S_IRUGO, psu_out_curr_show, NULL); +static struct switch_attribute psu_out_vol_attr = __ATTR(out_vol, S_IRUGO, psu_out_vol_show, NULL); +static struct switch_attribute psu_out_power_attr = __ATTR(out_power, S_IRUGO, psu_out_power_show, NULL); +static struct switch_attribute psu_out_max_power_attr = __ATTR(out_max_power, S_IRUGO, psu_out_max_power_show, NULL); +static struct switch_attribute psu_num_temps_attr = __ATTR(num_temp_sensors, S_IRUGO, psu_temp_number_show, NULL); +static struct switch_attribute psu_present_attr = __ATTR(present, S_IRUGO, psu_present_status_show, NULL); +static struct switch_attribute psu_out_status_attr = __ATTR(out_status, S_IRUGO, psu_out_status_show, NULL); +static struct switch_attribute psu_in_status_attr = __ATTR(in_status, S_IRUGO, psu_in_status_show, NULL); +static struct switch_attribute psu_fan_speed_attr = __ATTR(fan_speed, S_IRUGO, psu_fan_speed_show, NULL); +static struct switch_attribute psu_fan_ratio_attr = __ATTR(fan_ratio, S_IRUGO | S_IWUSR, psu_fan_ratio_show, psu_fan_ratio_store); +static struct switch_attribute psu_fan_direction_attr = __ATTR(fan_direction, S_IRUGO, psu_fan_direction_show, NULL); +static struct switch_attribute psu_led_status_attr = __ATTR(led_status, S_IRUGO, psu_led_status_show, NULL); + +static struct attribute *psu_attrs[] = { + &psu_model_name_attr.attr, + &psu_hw_attr.attr, + &psu_sn_attr.attr, + &psu_pn_attr.attr, + &psu_type_attr.attr, + &psu_in_curr_attr.attr, + &psu_in_vol_attr.attr, + &psu_in_power_attr.attr, + &psu_out_curr_attr.attr, + &psu_out_vol_attr.attr, + &psu_out_power_attr.attr, + &psu_out_max_power_attr.attr, + &psu_num_temps_attr.attr, + &psu_present_attr.attr, + &psu_out_status_attr.attr, + &psu_in_status_attr.attr, + &psu_fan_speed_attr.attr, + &psu_fan_ratio_attr.attr, + &psu_fan_direction_attr.attr, + &psu_led_status_attr.attr, + NULL, +}; + +static struct attribute_group psu_attr_group = { + .attrs = psu_attrs, +}; + +/*******************************psu temp[1-n] dir and attrs*******************************************/ +static struct switch_attribute psu_temp_alias_attr = __ATTR(alias, S_IRUGO, psu_temp_alias_show, NULL); +static struct switch_attribute psu_temp_type_attr = __ATTR(type, S_IRUGO, psu_temp_type_show, NULL); +static struct switch_attribute psu_temp_max_attr = __ATTR(max, S_IRUGO | S_IWUSR, psu_temp_max_show, psu_temp_max_store); +static struct switch_attribute psu_temp_min_attr = __ATTR(min, S_IRUGO | S_IWUSR, psu_temp_min_show, psu_temp_min_store); +static struct switch_attribute psu_temp_value_attr = __ATTR(value, S_IRUGO, psu_temp_value_show, NULL); + +static struct attribute *psu_temp_attrs[] = { + &psu_temp_alias_attr.attr, + &psu_temp_type_attr.attr, + &psu_temp_max_attr.attr, + &psu_temp_min_attr.attr, + &psu_temp_value_attr.attr, + NULL, +}; + +static struct attribute_group psu_temp_attr_group = { + .attrs = psu_temp_attrs, +}; + +static void psuindex_single_temp_remove_kobj_and_attrs(struct psu_obj_s *curr_psu, unsigned int temp_index) +{ + struct temp_obj_s *curr_temp; /* point to temp1 temp2...*/ + + curr_temp = &curr_psu->temp[temp_index - 1]; + if (curr_temp->obj) { + sysfs_remove_group(&curr_temp->obj->kobj, &psu_temp_attr_group); + switch_kobject_delete(&curr_temp->obj); + PSU_DBG("delete psu%u temp%u dir and attrs success.\n", curr_psu->obj->index, temp_index); + } + return; +} + +static int psuindex_single_temp_create_kobj_and_attrs(struct psu_obj_s *curr_psu, unsigned int temp_index) +{ + char name[DIR_NAME_MAX_LEN]; + struct temp_obj_s *curr_temp; /* point to temp1 temp2...*/ + + curr_temp = &curr_psu->temp[temp_index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "temp%u", temp_index); + curr_temp->obj = switch_kobject_create(name, &curr_psu->obj->kobj); + if (!curr_temp->obj) { + PSU_ERR("create psu%u, %s object error!\n", curr_psu->obj->index, name); + return -ENOMEM; + } + curr_temp->obj->index = temp_index; + if (sysfs_create_group(&curr_temp->obj->kobj, &psu_temp_attr_group) != 0) { + PSU_ERR("create psu%u, %s attrs error.\n", curr_psu->obj->index, name); + switch_kobject_delete(&curr_temp->obj); + return -EBADRQC; + } + PSU_DBG("create psu%u, %s success.\n", curr_psu->obj->index, name); + return 0; +} + +static int psuindex_temp_create_kobj_and_attrs(struct psu_obj_s *curr_psu) +{ + unsigned int temp_index, i, temp_num; + + temp_num = curr_psu->temp_number; + curr_psu->temp = kzalloc(sizeof(struct temp_obj_s) * temp_num, GFP_KERNEL); + if (!curr_psu->temp) { + PSU_ERR("kzalloc temp error, psu index: %u, temp number: %u.\n", + curr_psu->obj->index, temp_num); + return -ENOMEM; + } + for(temp_index = 1; temp_index <= temp_num; temp_index++) { + if(psuindex_single_temp_create_kobj_and_attrs(curr_psu, temp_index) != 0 ) { + goto temp_error; + } + } + return 0; +temp_error: + for(i = temp_index; i > 0; i--) { + psuindex_single_temp_remove_kobj_and_attrs(curr_psu, i); + } + kfree(curr_psu->temp); + curr_psu->temp = NULL; + return -EBADRQC; +} + +static void psuindex_temp_remove_kobj_and_attrs(struct psu_obj_s *curr_psu) +{ + unsigned int temp_index, temp_num; + + if (curr_psu->temp) { + temp_num = curr_psu->temp_number; + for (temp_index = temp_num; temp_index > 0; temp_index--) { + psuindex_single_temp_remove_kobj_and_attrs(curr_psu, temp_index); + } + kfree(curr_psu->temp); + curr_psu->temp = NULL; + } + return; +} + +/* create psu temp[1-n] directory and attributes*/ +static int psu_temp_create(void) +{ + int psu_num, temp_num; + unsigned int psu_index, i; + struct psu_obj_s *curr_psu; /* point to psu1 psu2...*/ + + psu_num = g_psu.psu_number; + if (psu_num <= 0) { + PSU_DBG("psu number: %d, skip to create temp* dirs and attrs.\n", psu_num); + return 0; + } + + check_p(g_psu_drv->get_psu_temp_number); + for(psu_index = 1; psu_index <= psu_num; psu_index++) { + temp_num = g_psu_drv->get_psu_temp_number(psu_index); + if (temp_num <= 0) { + PSU_DBG("psu%u temp number: %d, don't need to create temp* dirs and attrs.\n", + psu_index, temp_num); + continue; + } + curr_psu = &g_psu.psu[psu_index - 1]; + curr_psu->temp_number = temp_num; + if(psuindex_temp_create_kobj_and_attrs(curr_psu) != 0) { + goto error; + } + } + return 0; +error: + for(i = psu_index; i > 0; i--) { + curr_psu = &g_psu.psu[i - 1]; + psuindex_temp_remove_kobj_and_attrs(curr_psu); + } + return -EBADRQC; +} + +/* delete psu temp[1-n] directory and attributes*/ +static void psu_temp_remove(void) +{ + unsigned int psu_index; + struct psu_obj_s *curr_psu; + + if (g_psu.psu) { + for(psu_index = g_psu.psu_number; psu_index > 0; psu_index--) { + curr_psu = &g_psu.psu[psu_index - 1]; + psuindex_temp_remove_kobj_and_attrs(curr_psu); + curr_psu->temp_number = 0; + } + } + return; +} + +static int psu_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct psu_obj_s *curr_psu; + + curr_psu = &g_psu.psu[index - 1]; + if (curr_psu->obj) { + sysfs_remove_group(&curr_psu->obj->kobj, &psu_attr_group); + switch_kobject_delete(&curr_psu->obj); + PSU_DBG("delete psu%u dir and attrs success.\n", index); + } + return 0; +} + +static int psu_sub_single_create_kobj_and_attrs(struct kobject *parent, unsigned int index) +{ + char name[DIR_NAME_MAX_LEN]; + struct psu_obj_s *curr_psu; + + curr_psu = &g_psu.psu[index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "psu%u", index); + curr_psu->obj = switch_kobject_create(name, parent); + if (!curr_psu->obj) { + PSU_ERR("create %s object error!\n", name); + return -ENOMEM; + } + curr_psu->obj->index = index; + if (sysfs_create_group(&curr_psu->obj->kobj, &psu_attr_group) != 0) { + PSU_ERR("create %s attrs error.\n", name); + switch_kobject_delete(&curr_psu->obj); + return -EBADRQC; + } + PSU_DBG("create %s dir and attrs success.\n", name); + return 0; +} + +static int psu_sub_create_kobj_and_attrs(struct kobject *parent, int psu_num) +{ + unsigned int psu_index, i; + + g_psu.psu = kzalloc(sizeof(struct psu_obj_s) * psu_num, GFP_KERNEL); + if (!g_psu.psu) { + PSU_ERR("kzalloc psu.psu error, psu number = %d.\n", psu_num); + return -ENOMEM; + } + + for(psu_index = 1; psu_index <= psu_num; psu_index++) { + if(psu_sub_single_create_kobj_and_attrs(parent, psu_index) != 0 ) { + goto error; + } + } + return 0; +error: + for(i = psu_index; i > 0; i--) { + psu_sub_single_remove_kobj_and_attrs(i); + } + kfree(g_psu.psu); + g_psu.psu = NULL; + return -EBADRQC; +} + +/* create psu[1-n] directory and attributes*/ +static int psu_sub_create(void) +{ + int ret; + + ret = psu_sub_create_kobj_and_attrs(&g_psu_obj->kobj, g_psu.psu_number); + return ret; +} + +/* delete psu[1-n] directory and attributes*/ +static void psu_sub_remove(void) +{ + unsigned int psu_index; + + if (g_psu.psu) { + for (psu_index = g_psu.psu_number; psu_index > 0; psu_index--) { + psu_sub_single_remove_kobj_and_attrs(psu_index); + } + kfree(g_psu.psu); + g_psu.psu = NULL; + } + g_psu.psu_number = 0; + return; +} + +/* create psu directory and number attributes*/ +static int psu_root_create(void) +{ + g_psu_obj = switch_kobject_create("psu", NULL); + if (!g_psu_obj) { + PSU_ERR("switch_kobject_create psu error!\n"); + return -ENOMEM; + } + + if (sysfs_create_group(&g_psu_obj->kobj, &psu_root_attr_group) != 0) { + switch_kobject_delete(&g_psu_obj); + PSU_ERR("create psu dir attrs error!\n"); + return -EBADRQC; + } + return 0; +} + +/* delete psu directory and number attributes*/ +static void psu_root_remove(void) +{ + if (g_psu_obj) { + sysfs_remove_group(&g_psu_obj->kobj, &psu_root_attr_group); + switch_kobject_delete(&g_psu_obj); + PSU_DBG("delete psu dir and attrs success.\n"); + } + return; +} + +int s3ip_sysfs_psu_drivers_register(struct s3ip_sysfs_psu_drivers_s *drv) +{ + int ret, psu_num; + + PSU_INFO("s3ip_sysfs_psu_drivers_register...\n"); + if (g_psu_drv) { + PSU_ERR("g_psu_drv is not NULL, can't register\n"); + return -EPERM; + } + + check_p(drv); + check_p(drv->get_psu_number); + g_psu_drv = drv; + + psu_num = g_psu_drv->get_psu_number(); + if (psu_num <= 0) { + PSU_ERR("psu number: %d, don't need to create psu dirs and attrs.\n", psu_num); + g_psu_drv = NULL; + return -EINVAL; + } + + memset(&g_psu, 0, sizeof(struct psu_s)); + g_psu.psu_number = psu_num; + ret = psu_root_create(); + if (ret < 0) { + PSU_ERR("create psu root dir and attrs failed, ret: %d\n", ret); + g_psu_drv = NULL; + return ret; + } + + ret = psu_sub_create(); + if (ret < 0) { + PSU_ERR("create psu sub dir and attrs failed, ret: %d\n", ret); + psu_root_remove(); + g_psu_drv = NULL; + return ret; + } + + ret = psu_temp_create(); + if (ret < 0) { + PSU_ERR("create psu temp dir and attrs failed, ret: %d\n", ret); + psu_sub_remove(); + psu_root_remove(); + g_psu_drv = NULL; + return ret; + } + PSU_INFO("s3ip_sysfs_psu_drivers_register success.\n"); + return 0; +} + +void s3ip_sysfs_psu_drivers_unregister(void) +{ + if (g_psu_drv) { + psu_temp_remove(); + psu_sub_remove(); + psu_root_remove(); + g_psu_drv = NULL; + PSU_DBG("s3ip_sysfs_psu_drivers_unregister success.\n"); + } + + return; +} + +EXPORT_SYMBOL(s3ip_sysfs_psu_drivers_register); +EXPORT_SYMBOL(s3ip_sysfs_psu_drivers_unregister); +module_param(g_psu_loglevel, int, 0644); +MODULE_PARM_DESC(g_psu_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/slot_sysfs.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/slot_sysfs.c new file mode 100644 index 000000000000..b0186ac6ad29 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/slot_sysfs.c @@ -0,0 +1,2099 @@ +/* + * slot_sysfs.c + * + * This module create slot kobjects and attributes in /sys/s3ip/slot + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "switch.h" +#include "slot_sysfs.h" + +static int g_slot_loglevel = 0; + +#define SLOT_INFO(fmt, args...) do { \ + if (g_slot_loglevel & INFO) { \ + printk(KERN_INFO "[SLOT_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define SLOT_ERR(fmt, args...) do { \ + if (g_slot_loglevel & ERR) { \ + printk(KERN_ERR "[SLOT_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define SLOT_DBG(fmt, args...) do { \ + if (g_slot_loglevel & DBG) { \ + printk(KERN_DEBUG "[SLOT_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +struct slot_temp_obj_s { + struct switch_obj *obj; +}; + +struct slot_vol_obj_s { + struct switch_obj *obj; +}; + +struct slot_curr_obj_s { + struct switch_obj *obj; +}; + +struct slot_fpga_obj_s { + struct switch_obj *obj; +}; + +struct slot_cpld_obj_s { + struct switch_obj *obj; +}; + +struct slot_obj_s { + unsigned int temp_number; + unsigned int vol_number; + unsigned int curr_number; + unsigned int fpga_number; + unsigned int cpld_number; + struct slot_temp_obj_s *temp; + struct slot_vol_obj_s *vol; + struct slot_curr_obj_s *curr; + struct slot_fpga_obj_s *fpga; + struct slot_cpld_obj_s *cpld; + struct switch_obj *obj; +}; + +struct slot_s { + unsigned int slot_number; + struct slot_obj_s *slot; +}; + +static struct slot_s g_slot; +static struct switch_obj *g_slot_obj = NULL; +static struct s3ip_sysfs_slot_drivers_s *g_slot_drv = NULL; + +static ssize_t slot_number_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + return (ssize_t)snprintf(buf, PAGE_SIZE, "%u\n", g_slot.slot_number); +} + +static ssize_t slot_temp_number_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int index; + + index = obj->index; + return (ssize_t)snprintf(buf, PAGE_SIZE, "%u\n", g_slot.slot[index - 1].temp_number); +} + +static ssize_t slot_vol_number_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int index; + + index = obj->index; + return (ssize_t)snprintf(buf, PAGE_SIZE, "%u\n", g_slot.slot[index - 1].vol_number); +} + +static ssize_t slot_curr_number_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int index; + + index = obj->index; + return (ssize_t)snprintf(buf, PAGE_SIZE, "%u\n", g_slot.slot[index - 1].curr_number); +} + +static ssize_t slot_fpga_number_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int index; + + index = obj->index; + return (ssize_t)snprintf(buf, PAGE_SIZE, "%u\n", g_slot.slot[index - 1].fpga_number); +} + +static ssize_t slot_cpld_number_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int index; + + index = obj->index; + return (ssize_t)snprintf(buf, PAGE_SIZE, "%u\n", g_slot.slot[index - 1].cpld_number); +} + +static ssize_t slot_model_name_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int slot_index; + int ret; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_model_name); + + slot_index = obj->index; + SLOT_DBG("slot index: %u\n", slot_index); + ret = g_slot_drv->get_slot_model_name(slot_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u model name failed, ret: %d\n", slot_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_sn_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int slot_index; + int ret; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_serial_number); + + slot_index = obj->index; + SLOT_DBG("slot index: %u\n", slot_index); + ret = g_slot_drv->get_slot_serial_number(slot_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u serial number failed, ret: %d\n", slot_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_pn_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index; + int ret; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_part_number); + + slot_index = obj->index; + SLOT_DBG("slot index: %u\n", slot_index); + ret = g_slot_drv->get_slot_part_number(slot_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u part number failed, ret: %d\n", slot_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_hw_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index; + int ret; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_hardware_version); + + slot_index = obj->index; + SLOT_DBG("slot index: %u\n", slot_index); + ret = g_slot_drv->get_slot_hardware_version(slot_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u hardware version failed, ret: %d\n", slot_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index; + int ret; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_status); + + slot_index = obj->index; + SLOT_DBG("slot index: %u\n", slot_index); + ret = g_slot_drv->get_slot_status(slot_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u status failed, ret: %d\n", slot_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_led_status_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int slot_index; + int ret; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_led_status); + + slot_index = obj->index; + SLOT_DBG("slot index: %u\n", slot_index); + ret = g_slot_drv->get_slot_led_status(slot_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u led status failed, ret: %d\n", slot_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_led_status_store(struct switch_obj *obj, struct switch_attribute *attr, + const char *buf, size_t count) +{ + unsigned int slot_index; + int ret, led_status; + + check_p(g_slot_drv); + check_p(g_slot_drv->set_slot_led_status); + + slot_index = obj->index; + sscanf(buf, "%d", &led_status); + SLOT_DBG("slot index: %u, led_status: %d\n", slot_index, led_status); + ret = g_slot_drv->set_slot_led_status(slot_index, led_status); + if (ret < 0) { + SLOT_ERR("set slot%u led_status: %d failed, ret: %d\n", slot_index, led_status, ret); + return -EIO; + } + SLOT_DBG("set slot%u led_status: %d success\n", slot_index, led_status); + return count; +} + +/*************************************slot temp*************************************************/ +static ssize_t slot_temp_value_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_temp_value); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + temp_index = obj->index; + + SLOT_DBG("slot index: %u, temp index: %u\n", slot_index, temp_index); + ret = g_slot_drv->get_slot_temp_value(slot_index, temp_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u temp%u value failed, ret: %d\n", slot_index, temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_temp_alias_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_temp_alias); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + temp_index = obj->index; + + SLOT_DBG("slot index: %u, temp index: %u\n", slot_index, temp_index); + ret = g_slot_drv->get_slot_temp_alias(slot_index, temp_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u temp%u alias failed, ret: %d\n", slot_index, temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_temp_type_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_temp_type); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + temp_index = obj->index; + + SLOT_DBG("slot index: %u, temp index: %u\n", slot_index, temp_index); + ret = g_slot_drv->get_slot_temp_type(slot_index, temp_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u temp%u type failed, ret: %d\n", slot_index, temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_temp_max_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_temp_max); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + temp_index = obj->index; + + SLOT_DBG("slot index: %u, temp index: %u\n", slot_index, temp_index); + ret = g_slot_drv->get_slot_temp_max(slot_index, temp_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u temp%u max threshold failed, ret: %d\n", + slot_index, temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_temp_max_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int slot_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->set_slot_temp_max); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + temp_index = obj->index; + ret = g_slot_drv->set_slot_temp_max(slot_index, temp_index, buf, count); + if (ret < 0) { + SLOT_ERR("set slot%u temp%u max threshold failed, value: %s, count: %lu, ret: %d\n", + slot_index, temp_index, buf, count, ret); + return -EIO; + } + SLOT_DBG("set slot%u temp%u max threshold success, value: %s, count: %lu, ret: %d\n", + slot_index, temp_index, buf, count, ret); + return count; +} + +static ssize_t slot_temp_min_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_temp_min); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + temp_index = obj->index; + + SLOT_DBG("slot index: %u, temp index: %u\n", slot_index, temp_index); + ret = g_slot_drv->get_slot_temp_min(slot_index, temp_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u temp%u min threshold failed, ret: %d\n", + slot_index, temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_temp_min_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int slot_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->set_slot_temp_min); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + temp_index = obj->index; + ret = g_slot_drv->set_slot_temp_min(slot_index, temp_index, buf, count); + if (ret < 0) { + SLOT_ERR("set slot%u temp%u min threshold failed, value: %s, count: %lu, ret: %d\n", + slot_index, temp_index, buf, count, ret); + return -EIO; + } + SLOT_DBG("set slot%u temp%u min threshold success, value: %s, count: %lu, ret: %d\n", + slot_index, temp_index, buf, count, ret); + return count; +} +/**********************************end of slot temp**********************************************/ + +/*************************************slot vol*************************************************/ +static ssize_t slot_vol_value_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, vol_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_vol_value); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + vol_index = obj->index; + + SLOT_DBG("slot index: %u, vol index: %u\n", slot_index, vol_index); + ret = g_slot_drv->get_slot_vol_value(slot_index, vol_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u vol%u value failed, ret: %d\n", slot_index, vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_vol_alias_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, vol_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_vol_alias); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + vol_index = obj->index; + + SLOT_DBG("slot index: %u, vol index: %u\n", slot_index, vol_index); + ret = g_slot_drv->get_slot_vol_alias(slot_index, vol_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u vol%u alias failed, ret: %d\n", slot_index, vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_vol_type_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, vol_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_vol_type); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + vol_index = obj->index; + + SLOT_DBG("slot index: %u, vol index: %u\n", slot_index, vol_index); + ret = g_slot_drv->get_slot_vol_type(slot_index, vol_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u vol%u type failed, ret: %d\n", slot_index, vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_vol_max_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, vol_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_vol_max); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + vol_index = obj->index; + + SLOT_DBG("slot index: %u, vol index: %u\n", slot_index, vol_index); + ret = g_slot_drv->get_slot_vol_max(slot_index, vol_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u vol%u max threshold failed, ret: %d\n", + slot_index, vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_vol_max_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int slot_index, vol_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->set_slot_vol_max); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + vol_index = obj->index; + ret = g_slot_drv->set_slot_vol_max(slot_index, vol_index, buf, count); + if (ret < 0) { + SLOT_ERR("set slot%u vol%u max threshold failed, value: %s, count: %lu, ret: %d\n", + slot_index, vol_index, buf, count, ret); + return -EIO; + } + SLOT_DBG("set slot%u vol%u max threshold success, value: %s, count: %lu, ret: %d\n", + slot_index, vol_index, buf, count, ret); + return count; +} + +static ssize_t slot_vol_min_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, vol_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_vol_min); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + vol_index = obj->index; + + SLOT_DBG("slot index: %u, vol index: %u\n", slot_index, vol_index); + ret = g_slot_drv->get_slot_vol_min(slot_index, vol_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u vol%u min threshold failed, ret: %d\n", + slot_index, vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_vol_min_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int slot_index, vol_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->set_slot_vol_min); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + vol_index = obj->index; + ret = g_slot_drv->set_slot_vol_min(slot_index, vol_index, buf, count); + if (ret < 0) { + SLOT_ERR("set slot%u vol%u min threshold failed, value: %s, count: %lu, ret: %d\n", + slot_index, vol_index, buf, count, ret); + return -EIO; + } + SLOT_DBG("set slot%u vol%u min threshold success, value: %s, count: %lu, ret: %d\n", + slot_index, vol_index, buf, count, ret); + return count; +} + +static ssize_t slot_vol_range_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, vol_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_vol_range); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + vol_index = obj->index; + + SLOT_DBG("slot index: %u, vol index: %u\n", slot_index, vol_index); + ret = g_slot_drv->get_slot_vol_range(slot_index, vol_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u vol%u voltage range failed, ret: %d\n", + slot_index, vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_vol_nominal_value_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, vol_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_vol_nominal_value); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + vol_index = obj->index; + + SLOT_DBG("slot index: %u, vol index: %u\n", slot_index, vol_index); + ret = g_slot_drv->get_slot_vol_nominal_value(slot_index, vol_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u vol%u voltage nominal value failed, ret: %d\n", + slot_index, vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} +/**********************************end of slot vol**********************************************/ +/*************************************slot curr*************************************************/ +static ssize_t slot_curr_value_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, curr_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_curr_value); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + curr_index = obj->index; + + SLOT_DBG("slot index: %u, curr index: %u\n", slot_index, curr_index); + ret = g_slot_drv->get_slot_curr_value(slot_index, curr_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u curr%u value failed, ret: %d\n", slot_index, curr_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_curr_alias_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, curr_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_curr_alias); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + curr_index = obj->index; + + SLOT_DBG("slot index: %u, curr index: %u\n", slot_index, curr_index); + ret = g_slot_drv->get_slot_curr_alias(slot_index, curr_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u curr%u alias failed, ret: %d\n", slot_index, curr_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_curr_type_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, curr_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_curr_type); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + curr_index = obj->index; + + SLOT_DBG("slot index: %u, curr index: %u\n", slot_index, curr_index); + ret = g_slot_drv->get_slot_curr_type(slot_index, curr_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u curr%u type failed, ret: %d\n", slot_index, curr_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_curr_max_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, curr_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_curr_max); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + curr_index = obj->index; + + SLOT_DBG("slot index: %u, curr index: %u\n", slot_index, curr_index); + ret = g_slot_drv->get_slot_curr_max(slot_index, curr_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u curr%u max threshold failed, ret: %d\n", + slot_index, curr_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_curr_max_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int slot_index, curr_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->set_slot_curr_max); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + curr_index = obj->index; + ret = g_slot_drv->set_slot_curr_max(slot_index, curr_index, buf, count); + if (ret < 0) { + SLOT_ERR("set slot%u curr%u max threshold failed, value: %s, count: %lu, ret: %d\n", + slot_index, curr_index, buf, count, ret); + return -EIO; + } + SLOT_DBG("set slot%u curr%u max threshold success, value: %s, count: %lu, ret: %d\n", + slot_index, curr_index, buf, count, ret); + return count; +} + +static ssize_t slot_curr_min_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, curr_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_curr_min); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + curr_index = obj->index; + + SLOT_DBG("slot index: %u, curr index: %u\n", slot_index, curr_index); + ret = g_slot_drv->get_slot_curr_min(slot_index, curr_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u curr%u min threshold failed, ret: %d\n", + slot_index, curr_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_curr_min_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int slot_index, curr_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->set_slot_curr_min); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + curr_index = obj->index; + ret = g_slot_drv->set_slot_curr_min(slot_index, curr_index, buf, count); + if (ret < 0) { + SLOT_ERR("set slot%u curr%u min threshold failed, value: %s, count: %lu, ret: %d\n", + slot_index, curr_index, buf, count, ret); + return -EIO; + } + SLOT_DBG("set slot%u curr%u min threshold success, value: %s, count: %lu, ret: %d\n", + slot_index, curr_index, buf, count, ret); + return count; +} +/**********************************end of slot curr**********************************************/ +/*************************************slot fpga*************************************************/ +static ssize_t slot_fpga_alias_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, fpga_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_fpga_alias); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + fpga_index = obj->index; + + SLOT_DBG("slot index: %u, fpga index: %u\n", slot_index, fpga_index); + ret = g_slot_drv->get_slot_fpga_alias(slot_index, fpga_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u fpga%u alias failed, ret: %d\n", slot_index, fpga_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_fpga_type_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, fpga_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_fpga_type); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + fpga_index = obj->index; + + SLOT_DBG("slot index: %u, fpga index: %u\n", slot_index, fpga_index); + ret = g_slot_drv->get_slot_fpga_type(slot_index, fpga_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u fpga%u type failed, ret: %d\n", slot_index, fpga_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_fpga_fw_version_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int slot_index, fpga_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_fpga_firmware_version); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + fpga_index = obj->index; + + SLOT_DBG("slot index: %u, fpga index: %u\n", slot_index, fpga_index); + ret = g_slot_drv->get_slot_fpga_firmware_version(slot_index, fpga_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u fpga%u firmware version failed, ret: %d\n", slot_index, fpga_index, + ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_fpga_board_version_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int slot_index, fpga_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_fpga_board_version); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + fpga_index = obj->index; + + SLOT_DBG("slot index: %u, fpga index: %u\n", slot_index, fpga_index); + ret = g_slot_drv->get_slot_fpga_board_version(slot_index, fpga_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u fpga%u board version failed, ret: %d\n", slot_index, fpga_index, + ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_fpga_test_reg_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int slot_index, fpga_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_fpga_test_reg); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + fpga_index = obj->index; + + SLOT_DBG("slot index: %u, fpga index: %u\n", slot_index, fpga_index); + ret = g_slot_drv->get_slot_fpga_test_reg(slot_index, fpga_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u fpga%u test register failed, ret: %d\n", slot_index, fpga_index, + ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_fpga_test_reg_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int slot_index, fpga_index, value; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->set_slot_fpga_test_reg); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + fpga_index = obj->index; + sscanf(buf, "0x%x", &value); + ret = g_slot_drv->set_slot_fpga_test_reg(slot_index, fpga_index, value); + if (ret < 0) { + SLOT_ERR("set slot%u fpga%u test reg failed, value:0x%x, ret: %d.\n", + slot_index, fpga_index, value, ret); + return -EIO; + } + SLOT_DBG("set slot%u fpga%u test reg success, value: 0x%x.\n", slot_index, fpga_index, value); + return count; +} +/**********************************end of slot fpga**********************************************/ +/*************************************slot cpld*************************************************/ +static ssize_t slot_cpld_alias_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, cpld_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_cpld_alias); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + cpld_index = obj->index; + + SLOT_DBG("slot index: %u, cpld index: %u\n", slot_index, cpld_index); + ret = g_slot_drv->get_slot_cpld_alias(slot_index, cpld_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u cpld%u alias failed, ret: %d\n", slot_index, cpld_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_cpld_type_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, cpld_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_cpld_type); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + cpld_index = obj->index; + + SLOT_DBG("slot index: %u, cpld index: %u\n", slot_index, cpld_index); + ret = g_slot_drv->get_slot_cpld_type(slot_index, cpld_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u cpld%u type failed, ret: %d\n", slot_index, cpld_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_cpld_fw_version_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int slot_index, cpld_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_cpld_firmware_version); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + cpld_index = obj->index; + + SLOT_DBG("slot index: %u, cpld index: %u\n", slot_index, cpld_index); + ret = g_slot_drv->get_slot_cpld_firmware_version(slot_index, cpld_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u cpld%u firmware version failed, ret: %d\n", slot_index, cpld_index, + ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_cpld_board_version_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int slot_index, cpld_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_cpld_board_version); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + cpld_index = obj->index; + + SLOT_DBG("slot index: %u, cpld index: %u\n", slot_index, cpld_index); + ret = g_slot_drv->get_slot_cpld_board_version(slot_index, cpld_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u cpld%u board version failed, ret: %d\n", slot_index, cpld_index, + ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_cpld_test_reg_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int slot_index, cpld_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_cpld_test_reg); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + cpld_index = obj->index; + + SLOT_DBG("slot index: %u, cpld index: %u\n", slot_index, cpld_index); + ret = g_slot_drv->get_slot_cpld_test_reg(slot_index, cpld_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u cpld%u test register failed, ret: %d\n", slot_index, cpld_index, + ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_cpld_test_reg_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int slot_index, cpld_index, value; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->set_slot_cpld_test_reg); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + cpld_index = obj->index; + sscanf(buf, "0x%x", &value); + ret = g_slot_drv->set_slot_cpld_test_reg(slot_index, cpld_index, value); + if (ret < 0) { + SLOT_ERR("set slot%u cpld%u test reg failed, value:0x%x, ret: %d.\n", + slot_index, cpld_index, value, ret); + return -EIO; + } + SLOT_DBG("set slot%u cpld%u test reg success, value: 0x%x.\n", slot_index, cpld_index, value); + return count; +} +/**********************************end of slot cpld**********************************************/ +/**********************************slot dir and attrs********************************************/ +static struct switch_attribute slot_number_attr = __ATTR(number, S_IRUGO, slot_number_show, NULL); + +static struct attribute *slot_dir_attrs[] = { + &slot_number_attr.attr, + NULL, +}; + +static struct attribute_group slot_root_attr_group = { + .attrs = slot_dir_attrs, +}; + +/*******************************slot[1-n] dir and attrs*******************************************/ +static struct switch_attribute slot_model_name_attr = __ATTR(model_name, S_IRUGO, slot_model_name_show, NULL); +static struct switch_attribute slot_hw_attr = __ATTR(hardware_version, S_IRUGO, slot_hw_show, NULL); +static struct switch_attribute slot_sn_attr = __ATTR(serial_number, S_IRUGO, slot_sn_show, NULL); +static struct switch_attribute slot_pn_attr = __ATTR(part_number, S_IRUGO, slot_pn_show, NULL); +static struct switch_attribute slot_status_attr = __ATTR(status, S_IRUGO, slot_status_show, NULL); +static struct switch_attribute slot_led_status_attr = __ATTR(led_status, S_IRUGO | S_IWUSR, slot_led_status_show, slot_led_status_store); +static struct switch_attribute num_temp_sensors_attr = __ATTR(num_temp_sensors, S_IRUGO, slot_temp_number_show, NULL); +static struct switch_attribute num_vol_sensors_attr = __ATTR(num_vol_sensors, S_IRUGO, slot_vol_number_show, NULL); +static struct switch_attribute num_curr_sensors_attr = __ATTR(num_curr_sensors, S_IRUGO, slot_curr_number_show, NULL); +static struct switch_attribute num_fpga_attr = __ATTR(num_fpgas, S_IRUGO, slot_fpga_number_show, NULL); +static struct switch_attribute num_cpld_attr = __ATTR(num_cplds, S_IRUGO, slot_cpld_number_show, NULL); + +static struct attribute *slot_attrs[] = { + &slot_model_name_attr.attr, + &slot_hw_attr.attr, + &slot_sn_attr.attr, + &slot_pn_attr.attr, + &slot_status_attr.attr, + &slot_led_status_attr.attr, + &num_temp_sensors_attr.attr, + &num_vol_sensors_attr.attr, + &num_curr_sensors_attr.attr, + &num_fpga_attr.attr, + &num_cpld_attr.attr, + NULL, +}; + +static struct attribute_group slot_attr_group = { + .attrs = slot_attrs, +}; + +/*******************************slot temp[1-n] dir and attrs*******************************************/ +static struct switch_attribute slot_temp_alias_attr = __ATTR(alias, S_IRUGO, slot_temp_alias_show, NULL); +static struct switch_attribute slot_temp_type_attr = __ATTR(type, S_IRUGO, slot_temp_type_show, NULL); +static struct switch_attribute slot_temp_max_attr = __ATTR(max, S_IRUGO | S_IWUSR, slot_temp_max_show, slot_temp_max_store); +static struct switch_attribute slot_temp_min_attr = __ATTR(min, S_IRUGO | S_IWUSR, slot_temp_min_show, slot_temp_min_store); +static struct switch_attribute slot_temp_value_attr = __ATTR(value, S_IRUGO, slot_temp_value_show, NULL); + +static struct attribute *slot_temp_attrs[] = { + &slot_temp_alias_attr.attr, + &slot_temp_type_attr.attr, + &slot_temp_max_attr.attr, + &slot_temp_min_attr.attr, + &slot_temp_value_attr.attr, + NULL, +}; + +static struct attribute_group slot_temp_attr_group = { + .attrs = slot_temp_attrs, +}; + +/*******************************slot vol[1-n] dir and attrs*******************************************/ +static struct switch_attribute slot_vol_alias_attr = __ATTR(alias, S_IRUGO, slot_vol_alias_show, NULL); +static struct switch_attribute slot_vol_type_attr = __ATTR(type, S_IRUGO, slot_vol_type_show, NULL); +static struct switch_attribute slot_vol_max_attr = __ATTR(max, S_IRUGO | S_IWUSR, slot_vol_max_show, slot_vol_max_store); +static struct switch_attribute slot_vol_min_attr = __ATTR(min, S_IRUGO | S_IWUSR, slot_vol_min_show, slot_vol_min_store); +static struct switch_attribute slot_vol_value_attr = __ATTR(value, S_IRUGO, slot_vol_value_show, NULL); +static struct switch_attribute slot_vol_range_attr = __ATTR(range, S_IRUGO, slot_vol_range_show, NULL); +static struct switch_attribute slot_vol_nominal_value_attr = __ATTR(nominal_value, S_IRUGO, slot_vol_nominal_value_show, NULL); + +static struct attribute *slot_vol_attrs[] = { + &slot_vol_alias_attr.attr, + &slot_vol_type_attr.attr, + &slot_vol_max_attr.attr, + &slot_vol_min_attr.attr, + &slot_vol_value_attr.attr, + &slot_vol_range_attr.attr, + &slot_vol_nominal_value_attr.attr, + NULL, +}; + +static struct attribute_group slot_vol_attr_group = { + .attrs = slot_vol_attrs, +}; + +/*******************************slot curr[1-n] dir and attrs*******************************************/ +static struct switch_attribute slot_curr_alias_attr = __ATTR(alias, S_IRUGO, slot_curr_alias_show, NULL); +static struct switch_attribute slot_curr_type_attr = __ATTR(type, S_IRUGO, slot_curr_type_show, NULL); +static struct switch_attribute slot_curr_max_attr = __ATTR(max, S_IRUGO | S_IWUSR, slot_curr_max_show, slot_curr_max_store); +static struct switch_attribute slot_curr_min_attr = __ATTR(min, S_IRUGO | S_IWUSR, slot_curr_min_show, slot_curr_min_store); +static struct switch_attribute slot_curr_value_attr = __ATTR(value, S_IRUGO, slot_curr_value_show, NULL); + +static struct attribute *slot_curr_attrs[] = { + &slot_curr_alias_attr.attr, + &slot_curr_type_attr.attr, + &slot_curr_max_attr.attr, + &slot_curr_min_attr.attr, + &slot_curr_value_attr.attr, + NULL, +}; + +static struct attribute_group slot_curr_attr_group = { + .attrs = slot_curr_attrs, +}; + +/*******************************slot fpga[1-n] dir and attrs*******************************************/ +static struct switch_attribute slot_fpga_alias_attr = __ATTR(alias, S_IRUGO, slot_fpga_alias_show, NULL); +static struct switch_attribute slot_fpga_type_attr = __ATTR(type, S_IRUGO, slot_fpga_type_show, NULL); +static struct switch_attribute slot_fpga_fw_version_attr = __ATTR(firmware_version, S_IRUGO, slot_fpga_fw_version_show, NULL); +static struct switch_attribute slot_fpga_board_version_attr = __ATTR(board_version, S_IRUGO, slot_fpga_board_version_show, NULL); +static struct switch_attribute slot_fpga_test_reg_attr = __ATTR(reg_test, S_IRUGO | S_IWUSR, slot_fpga_test_reg_show, slot_fpga_test_reg_store); + +static struct attribute *slot_fpga_attrs[] = { + &slot_fpga_alias_attr.attr, + &slot_fpga_type_attr.attr, + &slot_fpga_fw_version_attr.attr, + &slot_fpga_board_version_attr.attr, + &slot_fpga_test_reg_attr.attr, + NULL, +}; + +static struct attribute_group slot_fpga_attr_group = { + .attrs = slot_fpga_attrs, +}; + +/*******************************slot cpld[1-n] dir and attrs*******************************************/ +static struct switch_attribute slot_cpld_alias_attr = __ATTR(alias, S_IRUGO, slot_cpld_alias_show, NULL); +static struct switch_attribute slot_cpld_type_attr = __ATTR(type, S_IRUGO, slot_cpld_type_show, NULL); +static struct switch_attribute slot_cpld_fw_version_attr = __ATTR(firmware_version, S_IRUGO, slot_cpld_fw_version_show, NULL); +static struct switch_attribute slot_cpld_board_version_attr = __ATTR(board_version, S_IRUGO, slot_cpld_board_version_show, NULL); +static struct switch_attribute slot_cpld_test_reg_attr = __ATTR(reg_test, S_IRUGO | S_IWUSR, slot_cpld_test_reg_show, slot_cpld_test_reg_store); + +static struct attribute *slot_cpld_attrs[] = { + &slot_cpld_alias_attr.attr, + &slot_cpld_type_attr.attr, + &slot_cpld_fw_version_attr.attr, + &slot_cpld_board_version_attr.attr, + &slot_cpld_test_reg_attr.attr, + NULL, +}; + +static struct attribute_group slot_cpld_attr_group = { + .attrs = slot_cpld_attrs, +}; + +/***************************************slot cpld*****************************************/ +static void slotindex_single_cpld_remove_kobj_and_attrs(struct slot_obj_s *curr_slot, + unsigned int cpld_index) +{ + struct slot_cpld_obj_s *curr_cpld; + + curr_cpld = &curr_slot->cpld[cpld_index - 1]; + if (curr_cpld->obj) { + sysfs_remove_group(&curr_cpld->obj->kobj, &slot_cpld_attr_group); + switch_kobject_delete(&curr_cpld->obj); + SLOT_DBG("delete slot%u cpld%u dir and attrs success.\n", curr_slot->obj->index, + cpld_index); + } + return; +} + +static int slotindex_single_cpld_create_kobj_and_attrs(struct slot_obj_s *curr_slot, + unsigned int cpld_index) +{ + char name[DIR_NAME_MAX_LEN]; + struct slot_cpld_obj_s *curr_cpld; + + curr_cpld = &curr_slot->cpld[cpld_index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "cpld%u", cpld_index); + curr_cpld->obj = switch_kobject_create(name, &curr_slot->obj->kobj); + if (!curr_cpld->obj) { + SLOT_ERR("create slot%u %s object error!\n", curr_slot->obj->index, name); + return -ENOMEM; + } + curr_cpld->obj->index = cpld_index; + if (sysfs_create_group(&curr_cpld->obj->kobj, &slot_cpld_attr_group) != 0) { + SLOT_ERR("create slot%u %s attrs error.\n", curr_slot->obj->index, name); + switch_kobject_delete(&curr_cpld->obj); + return -EBADRQC; + } + SLOT_DBG("create slot%u %s success.\n", curr_slot->obj->index, name); + return 0; +} + +static void slotindex_cpld_remove_kobj_and_attrs(struct slot_obj_s *curr_slot) +{ + unsigned int cpld_index, cpld_num; + + if (curr_slot->cpld) { + cpld_num = curr_slot->cpld_number; + for (cpld_index = cpld_num; cpld_index > 0; cpld_index--) { + slotindex_single_cpld_remove_kobj_and_attrs(curr_slot, cpld_index); + } + kfree(curr_slot->cpld); + curr_slot->cpld = NULL; + } + return; +} + +static int slotindex_cpld_create_kobj_and_attrs(struct slot_obj_s *curr_slot) +{ + unsigned int cpld_index, i, cpld_num; + + cpld_num = curr_slot->cpld_number; + curr_slot->cpld = kzalloc(sizeof(struct slot_cpld_obj_s) * cpld_num, GFP_KERNEL); + if (!curr_slot->cpld) { + SLOT_ERR("kzalloc slot cpld error, slot index: %u, cpld number: %u.\n", + curr_slot->obj->index, cpld_num); + return -ENOMEM; + } + + for (cpld_index = 1; cpld_index <= cpld_num; cpld_index++) { + if (slotindex_single_cpld_create_kobj_and_attrs(curr_slot, cpld_index) != 0) { + goto error; + } + } + return 0; +error: + for (i = cpld_index; i > 0; i--) { + slotindex_single_cpld_remove_kobj_and_attrs(curr_slot, i); + } + kfree(curr_slot->cpld); + curr_slot->cpld = NULL; + return -EBADRQC; +} + +/* create slot cpld[1-n] directory and attributes*/ +static int slot_cpld_create(void) +{ + int cpld_num; + unsigned int slot_index, i; + struct slot_obj_s *curr_slot; + + check_p(g_slot_drv->get_slot_cpld_number); + for (slot_index = 1; slot_index <= g_slot.slot_number; slot_index++) { + cpld_num = g_slot_drv->get_slot_cpld_number(slot_index); + if (cpld_num <= 0) { + SLOT_DBG("slot%u cpld number: %d, don't need to create cpld* dirs and attrs.\n", + slot_index, cpld_num); + continue; + } + curr_slot = &g_slot.slot[slot_index - 1]; + curr_slot->cpld_number = cpld_num; + if (slotindex_cpld_create_kobj_and_attrs(curr_slot) != 0) { + goto error; + } + } + return 0; +error: + for (i = slot_index; i > 0; i--) { + curr_slot = &g_slot.slot[i - 1]; + slotindex_cpld_remove_kobj_and_attrs(curr_slot); + } + return -EBADRQC; +} + +/* delete slot cpld[1-n] directory and attributes*/ +static void slot_cpld_remove(void) +{ + unsigned int slot_index; + struct slot_obj_s *curr_slot; + + if (g_slot.slot) { + for (slot_index = g_slot.slot_number; slot_index > 0; slot_index--) { + curr_slot = &g_slot.slot[slot_index - 1]; + slotindex_cpld_remove_kobj_and_attrs(curr_slot); + curr_slot->cpld_number = 0; + } + } + return; +} +/************************************end of slot cpld**************************************/ +/***************************************slot fpga*****************************************/ +static void slotindex_single_fpga_remove_kobj_and_attrs(struct slot_obj_s *curr_slot, + unsigned int fpga_index) +{ + struct slot_fpga_obj_s *curr_fpga; + + curr_fpga = &curr_slot->fpga[fpga_index - 1]; + if (curr_fpga->obj) { + sysfs_remove_group(&curr_fpga->obj->kobj, &slot_fpga_attr_group); + switch_kobject_delete(&curr_fpga->obj); + SLOT_DBG("delete slot%u fpga%u dir and attrs success.\n", curr_slot->obj->index, + fpga_index); + } + return; +} + +static int slotindex_single_fpga_create_kobj_and_attrs(struct slot_obj_s *curr_slot, + unsigned int fpga_index) +{ + char name[DIR_NAME_MAX_LEN]; + struct slot_fpga_obj_s *curr_fpga; + + curr_fpga = &curr_slot->fpga[fpga_index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "fpga%u", fpga_index); + curr_fpga->obj = switch_kobject_create(name, &curr_slot->obj->kobj); + if (!curr_fpga->obj) { + SLOT_ERR("create slot%u %s object error!\n", curr_slot->obj->index, name); + return -ENOMEM; + } + curr_fpga->obj->index = fpga_index; + if (sysfs_create_group(&curr_fpga->obj->kobj, &slot_fpga_attr_group) != 0) { + SLOT_ERR("create slot%u %s attrs error.\n", curr_slot->obj->index, name); + switch_kobject_delete(&curr_fpga->obj); + return -EBADRQC; + } + SLOT_DBG("create slot%u %s success.\n", curr_slot->obj->index, name); + return 0; +} + +static void slotindex_fpga_remove_kobj_and_attrs(struct slot_obj_s *curr_slot) +{ + unsigned int fpga_index, fpga_num; + + if (curr_slot->fpga) { + fpga_num = curr_slot->fpga_number; + for (fpga_index = fpga_num; fpga_index > 0; fpga_index--) { + slotindex_single_fpga_remove_kobj_and_attrs(curr_slot, fpga_index); + } + kfree(curr_slot->fpga); + curr_slot->fpga = NULL; + } + return; +} + +static int slotindex_fpga_create_kobj_and_attrs(struct slot_obj_s *curr_slot) +{ + unsigned int fpga_index, i, fpga_num; + + fpga_num = curr_slot->fpga_number; + curr_slot->fpga = kzalloc(sizeof(struct slot_fpga_obj_s) * fpga_num, GFP_KERNEL); + if (!curr_slot->fpga) { + SLOT_ERR("kzalloc slot fpga error, slot index: %u, fpga number: %u.\n", + curr_slot->obj->index, fpga_num); + return -ENOMEM; + } + + for (fpga_index = 1; fpga_index <= fpga_num; fpga_index++) { + if (slotindex_single_fpga_create_kobj_and_attrs(curr_slot, fpga_index) != 0) { + goto error; + } + } + return 0; +error: + for (i = fpga_index; i > 0; i--) { + slotindex_single_fpga_remove_kobj_and_attrs(curr_slot, i); + } + kfree(curr_slot->fpga); + curr_slot->fpga = NULL; + return -EBADRQC; +} + +/* create slot fpga[1-n] directory and attributes*/ +static int slot_fpga_create(void) +{ + int fpga_num; + unsigned int slot_index, i; + struct slot_obj_s *curr_slot; + + check_p(g_slot_drv->get_slot_fpga_number); + for (slot_index = 1; slot_index <= g_slot.slot_number; slot_index++) { + fpga_num = g_slot_drv->get_slot_fpga_number(slot_index); + if (fpga_num <= 0) { + SLOT_DBG("slot%u fpga number: %d, don't need to create fpga* dirs and attrs.\n", + slot_index, fpga_num); + continue; + } + curr_slot = &g_slot.slot[slot_index - 1]; + curr_slot->fpga_number = fpga_num; + if (slotindex_fpga_create_kobj_and_attrs(curr_slot) != 0) { + goto error; + } + } + return 0; +error: + for (i = slot_index; i > 0; i--) { + curr_slot = &g_slot.slot[i - 1]; + slotindex_fpga_remove_kobj_and_attrs(curr_slot); + } + return -EBADRQC; +} + +/* delete slot fpga[1-n] directory and attributes*/ +static void slot_fpga_remove(void) +{ + unsigned int slot_index; + struct slot_obj_s *curr_slot; + + if (g_slot.slot) { + for (slot_index = g_slot.slot_number; slot_index > 0; slot_index--) { + curr_slot = &g_slot.slot[slot_index - 1]; + slotindex_fpga_remove_kobj_and_attrs(curr_slot); + curr_slot->fpga_number = 0; + } + } + return; +} +/************************************end of slot fpga**************************************/ +/*************************************slot current*****************************************/ +static void slotindex_single_curr_remove_kobj_and_attrs(struct slot_obj_s *curr_slot, + unsigned int curr_index) +{ + struct slot_curr_obj_s *curr; + + curr = &curr_slot->curr[curr_index - 1]; + if (curr->obj) { + sysfs_remove_group(&curr->obj->kobj, &slot_curr_attr_group); + switch_kobject_delete(&curr->obj); + SLOT_DBG("delete slot%u curr_sensor%u dir and attrs success.\n", curr_slot->obj->index, + curr_index); + } + return; +} + +static int slotindex_single_curr_create_kobj_and_attrs(struct slot_obj_s *curr_slot, + unsigned int curr_index) +{ + char name[DIR_NAME_MAX_LEN]; + struct slot_curr_obj_s *curr; + + curr = &curr_slot->curr[curr_index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "curr_sensor%u", curr_index); + curr->obj = switch_kobject_create(name, &curr_slot->obj->kobj); + if (!curr->obj) { + SLOT_ERR("create slot%u %s object error!\n", curr_slot->obj->index, name); + return -ENOMEM; + } + curr->obj->index = curr_index; + if (sysfs_create_group(&curr->obj->kobj, &slot_curr_attr_group) != 0) { + SLOT_ERR("create slot%u %s attrs error.\n", curr_slot->obj->index, name); + switch_kobject_delete(&curr->obj); + return -EBADRQC; + } + SLOT_DBG("create slot%u %s success.\n", curr_slot->obj->index, name); + return 0; +} + +static void slotindex_curr_remove_kobj_and_attrs(struct slot_obj_s *curr_slot) +{ + unsigned int curr_index, curr_num; + + if (curr_slot->curr) { + curr_num = curr_slot->curr_number; + for (curr_index = curr_num; curr_index > 0; curr_index--) { + slotindex_single_curr_remove_kobj_and_attrs(curr_slot, curr_index); + } + kfree(curr_slot->curr); + curr_slot->curr = NULL; + } + return; +} + +static int slotindex_curr_create_kobj_and_attrs(struct slot_obj_s *curr_slot) +{ + unsigned int curr_index, i, curr_num; + + curr_num = curr_slot->curr_number; + curr_slot->curr = kzalloc(sizeof(struct slot_curr_obj_s) * curr_num, GFP_KERNEL); + if (!curr_slot->curr) { + SLOT_ERR("kzalloc slot curr error, slot index: %u, curr number: %u.\n", + curr_slot->obj->index, curr_num); + return -ENOMEM; + } + + for (curr_index = 1; curr_index <= curr_num; curr_index++) { + if (slotindex_single_curr_create_kobj_and_attrs(curr_slot, curr_index) != 0) { + goto error; + } + } + return 0; +error: + for (i = curr_index; i > 0; i--) { + slotindex_single_curr_remove_kobj_and_attrs(curr_slot, i); + } + kfree(curr_slot->curr); + curr_slot->curr = NULL; + return -EBADRQC; +} + +/* create slot curr_snesor[1-n] directory and attributes*/ +static int slot_curr_create(void) +{ + int curr_num; + unsigned int slot_index, i; + struct slot_obj_s *curr_slot; + + check_p(g_slot_drv->get_slot_curr_number); + for (slot_index = 1; slot_index <= g_slot.slot_number; slot_index++) { + curr_num = g_slot_drv->get_slot_curr_number(slot_index); + if (curr_num <= 0) { + SLOT_DBG("slot%u curr number: %d, don't need to create curr_sensor* dirs and attrs.\n", + slot_index, curr_num); + continue; + } + curr_slot = &g_slot.slot[slot_index - 1]; + curr_slot->curr_number = curr_num; + if (slotindex_curr_create_kobj_and_attrs(curr_slot) != 0) { + goto error; + } + } + return 0; +error: + for (i = slot_index; i > 0; i--) { + curr_slot = &g_slot.slot[i - 1]; + slotindex_curr_remove_kobj_and_attrs(curr_slot); + } + return -EBADRQC; +} + +/* delete slot curr_sensor[1-n] directory and attributes*/ +static void slot_curr_remove(void) +{ + unsigned int slot_index; + struct slot_obj_s *curr_slot; + + if (g_slot.slot) { + for (slot_index = g_slot.slot_number; slot_index > 0; slot_index--) { + curr_slot = &g_slot.slot[slot_index - 1]; + slotindex_curr_remove_kobj_and_attrs(curr_slot); + curr_slot->curr_number = 0; + } + } + return; +} +/**********************************end of slot current************************************/ +/*************************************slot voltage****************************************/ +static void slotindex_single_vol_remove_kobj_and_attrs(struct slot_obj_s *curr_slot, + unsigned int vol_index) +{ + struct slot_vol_obj_s *curr_vol; + + curr_vol = &curr_slot->vol[vol_index - 1]; + if (curr_vol->obj) { + sysfs_remove_group(&curr_vol->obj->kobj, &slot_vol_attr_group); + switch_kobject_delete(&curr_vol->obj); + SLOT_DBG("delete slot%u vol_sensor%u dir and attrs success.\n", curr_slot->obj->index, + vol_index); + } + return; +} + +static int slotindex_single_vol_create_kobj_and_attrs(struct slot_obj_s *curr_slot, + unsigned int vol_index) +{ + char name[DIR_NAME_MAX_LEN]; + struct slot_vol_obj_s *curr_vol; + + curr_vol = &curr_slot->vol[vol_index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "vol_sensor%u", vol_index); + curr_vol->obj = switch_kobject_create(name, &curr_slot->obj->kobj); + if (!curr_vol->obj) { + SLOT_ERR("create slot%u %s object error!\n", curr_slot->obj->index, name); + return -ENOMEM; + } + curr_vol->obj->index = vol_index; + if (sysfs_create_group(&curr_vol->obj->kobj, &slot_vol_attr_group) != 0) { + SLOT_ERR("create slot%u %s attrs error.\n", curr_slot->obj->index, name); + switch_kobject_delete(&curr_vol->obj); + return -EBADRQC; + } + SLOT_DBG("create slot%u %s success.\n", curr_slot->obj->index, name); + return 0; +} + +static void slotindex_vol_remove_kobj_and_attrs(struct slot_obj_s *curr_slot) +{ + unsigned int vol_index, vol_num; + + if (curr_slot->vol) { + vol_num = curr_slot->vol_number; + for (vol_index = vol_num; vol_index > 0; vol_index--) { + slotindex_single_vol_remove_kobj_and_attrs(curr_slot, vol_index); + } + kfree(curr_slot->vol); + curr_slot->vol = NULL; + } + return; +} + +static int slotindex_vol_create_kobj_and_attrs(struct slot_obj_s *curr_slot) +{ + unsigned int vol_index, i, vol_num; + + vol_num = curr_slot->vol_number; + curr_slot->vol = kzalloc(sizeof(struct slot_vol_obj_s) * vol_num, GFP_KERNEL); + if (!curr_slot->vol) { + SLOT_ERR("kzalloc slot vol error, slot index: %u, vol number: %u.\n", + curr_slot->obj->index, vol_num); + return -ENOMEM; + } + + for (vol_index = 1; vol_index <= vol_num; vol_index++) { + if (slotindex_single_vol_create_kobj_and_attrs(curr_slot, vol_index) != 0) { + goto error; + } + } + return 0; +error: + for (i = vol_index; i > 0; i--) { + slotindex_single_vol_remove_kobj_and_attrs(curr_slot, i); + } + kfree(curr_slot->vol); + curr_slot->vol = NULL; + return -EBADRQC; +} + +/* create slot vol_snesor[1-n] directory and attributes*/ +static int slot_vol_create(void) +{ + int vol_num; + unsigned int slot_index, i; + struct slot_obj_s *curr_slot; + + check_p(g_slot_drv->get_slot_vol_number); + for (slot_index = 1; slot_index <= g_slot.slot_number; slot_index++) { + vol_num = g_slot_drv->get_slot_vol_number(slot_index); + if (vol_num <= 0) { + SLOT_DBG("slot%u vol number: %d, don't need to create vol_sensor* dirs and attrs.\n", + slot_index, vol_num); + continue; + } + curr_slot = &g_slot.slot[slot_index - 1]; + curr_slot->vol_number = vol_num; + if (slotindex_vol_create_kobj_and_attrs(curr_slot) != 0) { + goto error; + } + } + return 0; +error: + for (i = slot_index; i > 0; i--) { + curr_slot = &g_slot.slot[i - 1]; + slotindex_vol_remove_kobj_and_attrs(curr_slot); + } + return -EBADRQC; +} + +/* delete slot vol_sensor[1-n] directory and attributes*/ +static void slot_vol_remove(void) +{ + unsigned int slot_index; + struct slot_obj_s *curr_slot; + + if (g_slot.slot) { + for (slot_index = g_slot.slot_number; slot_index > 0; slot_index--) { + curr_slot = &g_slot.slot[slot_index - 1]; + slotindex_vol_remove_kobj_and_attrs(curr_slot); + curr_slot->vol_number = 0; + } + } + return; +} +/**********************************end of slot voltage************************************/ +/***************************************slot temp*****************************************/ +static void slotindex_single_temp_remove_kobj_and_attrs(struct slot_obj_s *curr_slot, + unsigned int temp_index) +{ + struct slot_temp_obj_s *curr_temp; + + curr_temp = &curr_slot->temp[temp_index - 1]; + if (curr_temp->obj) { + sysfs_remove_group(&curr_temp->obj->kobj, &slot_temp_attr_group); + switch_kobject_delete(&curr_temp->obj); + SLOT_DBG("delete slot%u temp_sensor%u dir and attrs success.\n", curr_slot->obj->index, + temp_index); + } + return; +} + +static int slotindex_single_temp_create_kobj_and_attrs(struct slot_obj_s *curr_slot, + unsigned int temp_index) +{ + char name[DIR_NAME_MAX_LEN]; + struct slot_temp_obj_s *curr_temp; + + curr_temp = &curr_slot->temp[temp_index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "temp_sensor%u", temp_index); + curr_temp->obj = switch_kobject_create(name, &curr_slot->obj->kobj); + if (!curr_temp->obj) { + SLOT_ERR("create slot%u %s object error!\n", curr_slot->obj->index, name); + return -ENOMEM; + } + curr_temp->obj->index = temp_index; + if (sysfs_create_group(&curr_temp->obj->kobj, &slot_temp_attr_group) != 0) { + SLOT_ERR("create slot%u %s attrs error.\n", curr_slot->obj->index, name); + switch_kobject_delete(&curr_temp->obj); + return -EBADRQC; + } + SLOT_DBG("create slot%u %s success.\n", curr_slot->obj->index, name); + return 0; +} + +static void slotindex_temp_remove_kobj_and_attrs(struct slot_obj_s *curr_slot) +{ + unsigned int temp_index, temp_num; + + if (curr_slot->temp) { + temp_num = curr_slot->temp_number; + for (temp_index = temp_num; temp_index > 0; temp_index--) { + slotindex_single_temp_remove_kobj_and_attrs(curr_slot, temp_index); + } + kfree(curr_slot->temp); + curr_slot->temp = NULL; + } + return; +} + +static int slotindex_temp_create_kobj_and_attrs(struct slot_obj_s *curr_slot) +{ + unsigned int temp_index, i, temp_num; + + temp_num = curr_slot->temp_number; + curr_slot->temp = kzalloc(sizeof(struct slot_temp_obj_s) * temp_num, GFP_KERNEL); + if (!curr_slot->temp) { + SLOT_ERR("kzalloc slot temp error, slot index: %u, temp number: %u.\n", + curr_slot->obj->index, temp_num); + return -ENOMEM; + } + + for (temp_index = 1; temp_index <= temp_num; temp_index++) { + if (slotindex_single_temp_create_kobj_and_attrs(curr_slot, temp_index) != 0) { + goto error; + } + } + return 0; +error: + for (i = temp_index; i > 0; i--) { + slotindex_single_temp_remove_kobj_and_attrs(curr_slot, i); + } + kfree(curr_slot->temp); + curr_slot->temp = NULL; + return -EBADRQC; +} + +/* create slot temp_sensor[1-n] directory and attributes*/ +static int slot_temp_create(void) +{ + int temp_num; + unsigned int slot_index, i; + struct slot_obj_s *curr_slot; + + check_p(g_slot_drv->get_slot_temp_number); + for (slot_index = 1; slot_index <= g_slot.slot_number; slot_index++) { + temp_num = g_slot_drv->get_slot_temp_number(slot_index); + if (temp_num <= 0) { + SLOT_DBG("slot%u temp number: %d, don't need to create temp_sensor* dirs and attrs.\n", + slot_index, temp_num); + continue; + } + curr_slot = &g_slot.slot[slot_index - 1]; + curr_slot->temp_number = temp_num; + if (slotindex_temp_create_kobj_and_attrs(curr_slot) != 0) { + goto error; + } + } + return 0; +error: + for (i = slot_index; i > 0; i--) { + curr_slot = &g_slot.slot[i - 1]; + slotindex_temp_remove_kobj_and_attrs(curr_slot); + } + return -EBADRQC; +} + +/* delete slot temp_sensor[1-n] directory and attributes*/ +static void slot_temp_remove(void) +{ + unsigned int slot_index; + struct slot_obj_s *curr_slot; + + if (g_slot.slot) { + for (slot_index = g_slot.slot_number; slot_index > 0; slot_index--) { + curr_slot = &g_slot.slot[slot_index - 1]; + slotindex_temp_remove_kobj_and_attrs(curr_slot); + curr_slot->temp_number = 0; + } + } + return; +} +/************************************end of slot temp**************************************/ + +static int slot_child_obj_create(void) +{ + int ret; + + if (g_slot.slot_number <= 0) { + SLOT_DBG("slot number: %u, skip to create slot child dirs and attrs.\n", + g_slot.slot_number); + return 0; + } + /* temp create */ + ret = slot_temp_create(); + if (ret < 0) { + goto temp_err; + } + /* Voltage create */ + ret = slot_vol_create(); + if(ret < 0) { + goto vol_err; + } + /* current create */ + ret = slot_curr_create(); + if(ret < 0) { + goto curr_err; + } + /* fpga create */ + ret = slot_fpga_create(); + if(ret < 0) { + goto fpga_err; + } + /* cplf create */ + ret = slot_cpld_create(); + if(ret < 0) { + goto cpld_err; + } + return 0; +cpld_err: + slot_fpga_remove(); +fpga_err: + slot_curr_remove(); +curr_err: + slot_vol_remove(); +vol_err: + slot_temp_remove(); +temp_err: + return ret; +} + +static void slot_child_obj_remove(void) +{ + slot_cpld_remove(); + slot_fpga_remove(); + slot_curr_remove(); + slot_vol_remove(); + slot_temp_remove(); + return; +} + +static void slot_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct slot_obj_s *curr_slot; + + curr_slot = &g_slot.slot[index - 1]; + if (curr_slot->obj) { + sysfs_remove_group(&curr_slot->obj->kobj, &slot_attr_group); + switch_kobject_delete(&curr_slot->obj); + SLOT_DBG("delete slot%u dir and attrs success.\n", index); + } + + return; +} + +static int slot_sub_single_create_kobj_and_attrs(struct kobject *parent, unsigned int index) +{ + char name[DIR_NAME_MAX_LEN]; + struct slot_obj_s * curr_slot; + + curr_slot = &g_slot.slot[index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "slot%u", index); + curr_slot->obj = switch_kobject_create(name, parent); + if (!curr_slot->obj) { + SLOT_ERR("create %s object error!\n", name); + return -EBADRQC; + } + curr_slot->obj->index = index; + if (sysfs_create_group(&curr_slot->obj->kobj, &slot_attr_group) != 0) { + SLOT_ERR("create %s attrs error.\n", name); + switch_kobject_delete(&curr_slot->obj); + return -EBADRQC; + } + SLOT_DBG("create %s dir and attrs success.\n", name); + return 0; +} + +static int slot_sub_create_kobj_and_attrs(struct kobject *parent, int slot_num) +{ + unsigned int slot_index, i; + + g_slot.slot = kzalloc(sizeof(struct slot_obj_s) * slot_num, GFP_KERNEL); + if (!g_slot.slot) { + SLOT_ERR("kzalloc slot.slot error, slot number = %d.\n", slot_num); + return -ENOMEM; + } + + for(slot_index = 1; slot_index <= slot_num; slot_index++) { + if(slot_sub_single_create_kobj_and_attrs(parent, slot_index) != 0 ) { + goto error; + } + } + return 0; +error: + for(i = slot_index; i > 0; i--) { + slot_sub_single_remove_kobj_and_attrs(i); + } + kfree(g_slot.slot); + g_slot.slot = NULL; + return -EBADRQC; +} + +/* create slot[1-n] directory and attributes*/ +static int slot_sub_create(void) +{ + int ret; + + ret = slot_sub_create_kobj_and_attrs(&g_slot_obj->kobj, g_slot.slot_number); + return ret; +} + +/* delete slot[1-n] directory and attributes*/ +static void slot_sub_remove(void) +{ + unsigned int slot_index; + + if (g_slot.slot) { + for (slot_index = g_slot.slot_number; slot_index > 0; slot_index--) { + slot_sub_single_remove_kobj_and_attrs(slot_index); + } + kfree(g_slot.slot); + g_slot.slot = NULL; + } + g_slot.slot_number = 0; + return; +} + +/* create slot directory and number attributes*/ +static int slot_root_create(void) +{ + g_slot_obj = switch_kobject_create("slot", NULL); + if (!g_slot_obj) { + SLOT_ERR("switch_kobject_create slot error!\n"); + return -ENOMEM; + } + + if (sysfs_create_group(&g_slot_obj->kobj, &slot_root_attr_group) != 0) { + switch_kobject_delete(&g_slot_obj); + SLOT_ERR("create slot dir attrs error!\n"); + return -EBADRQC; + } + return 0; +} + +/* delete slot directory and number attributes*/ +static void slot_root_remove(void) +{ + if (g_slot_obj) { + sysfs_remove_group(&g_slot_obj->kobj, &slot_root_attr_group); + switch_kobject_delete(&g_slot_obj); + } + + return; +} + +int s3ip_sysfs_slot_drivers_register(struct s3ip_sysfs_slot_drivers_s *drv) +{ + int ret, slot_num; + + SLOT_INFO("s3ip_sysfs_slot_drivers_register...\n"); + if (g_slot_drv) { + SLOT_ERR("g_slot_drv is not NULL, can't register\n"); + return -EPERM; + } + + check_p(drv); + check_p(drv->get_slot_number); + g_slot_drv = drv; + + slot_num = g_slot_drv->get_slot_number(); + if (slot_num <= 0) { + SLOT_ERR("slot number: %d, don't need to create slot dirs and attrs.\n", slot_num); + g_slot_drv = NULL; + return -EINVAL; + } + + memset(&g_slot, 0, sizeof(struct slot_s)); + g_slot.slot_number = slot_num; + ret = slot_root_create(); + if (ret < 0) { + SLOT_ERR("create slot root dir and attrs failed, ret: %d\n", ret); + g_slot_drv = NULL; + return ret; + } + + ret = slot_sub_create(); + if (ret < 0) { + SLOT_ERR("create slot sub dir and attrs failed, ret: %d\n", ret); + slot_root_remove(); + g_slot_drv = NULL; + return ret; + } + + ret = slot_child_obj_create(); + if (ret < 0) { + SLOT_ERR("create slot child dir and attrs failed, ret: %d\n", ret); + slot_sub_remove(); + slot_root_remove(); + g_slot_drv = NULL; + return ret; + } + SLOT_INFO("s3ip_sysfs_slot_drivers_register success.\n"); + return 0; +} + +void s3ip_sysfs_slot_drivers_unregister(void) +{ + if (g_slot_drv) { + slot_child_obj_remove(); + slot_sub_remove(); + slot_root_remove(); + g_slot_drv = NULL; + SLOT_DBG("s3ip_sysfs_slot_drivers_unregister success.\n"); + } + return; +} + +EXPORT_SYMBOL(s3ip_sysfs_slot_drivers_register); +EXPORT_SYMBOL(s3ip_sysfs_slot_drivers_unregister); +module_param(g_slot_loglevel, int, 0644); +MODULE_PARM_DESC(g_slot_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/switch.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/switch.c new file mode 100644 index 000000000000..6bd07cfa0c65 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/switch.c @@ -0,0 +1,270 @@ +/* + * switch.c + * + * This module create a kset in sysfs called /sys/s3ip + * Then other switch kobjects are created and assigned to this kset, + * such as "cpld", "fan", "psu", ... + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include "switch.h" +#include "syseeprom_sysfs.h" + +int g_switch_loglevel = 0; + +#define SWITCH_INFO(fmt, args...) do { \ + if (g_switch_loglevel & INFO) { \ + printk(KERN_INFO "[SWITCH][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define SWITCH_ERR(fmt, args...) do { \ + if (g_switch_loglevel & ERR) { \ + printk(KERN_ERR "[SWITCH][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define SWITCH_DBG(fmt, args...) do { \ + if (g_switch_loglevel & DBG) { \ + printk(KERN_DEBUG "[SWITCH][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +struct syseeprom_s { + struct bin_attribute bin; + int creat_eeprom_bin_flag; +}; + +static struct s3ip_sysfs_syseeprom_drivers_s *g_syseeprom_drv = NULL; +static struct kset *switch_kset; +static struct syseeprom_s g_syseeprom; + +static ssize_t switch_attr_show(struct kobject *kobj, struct attribute *attr, char *buf) +{ + struct switch_attribute *attribute; + struct switch_obj *device; + + attribute = to_switch_attr(attr); + device = to_switch_obj(kobj); + + if (!attribute->show) { + return -ENOSYS; + } + + return attribute->show(device, attribute, buf); +} + +static ssize_t switch_attr_store(struct kobject *kobj, struct attribute *attr, const char *buf, + size_t len) +{ + struct switch_attribute *attribute; + struct switch_obj *obj; + + attribute = to_switch_attr(attr); + obj = to_switch_obj(kobj); + + if (!attribute->store) { + return -ENOSYS; + } + + return attribute->store(obj, attribute, buf, len); +} + +static const struct sysfs_ops switch_sysfs_ops = { + .show = switch_attr_show, + .store = switch_attr_store, +}; + +static void switch_obj_release(struct kobject *kobj) +{ + struct switch_obj *obj; + + obj = to_switch_obj(kobj); + kfree(obj); + return; +} + +static struct kobj_type switch_ktype = { + .sysfs_ops = &switch_sysfs_ops, + .release = switch_obj_release, + .default_attrs = NULL, +}; + +static ssize_t syseeprom_read(struct file *filp, struct kobject *kobj, struct bin_attribute *attr, + char *buf, loff_t offset, size_t count) +{ + ssize_t rd_len; + + check_p(g_syseeprom_drv); + check_p(g_syseeprom_drv->read_syseeprom_data); + + memset(buf, 0, count); + rd_len = g_syseeprom_drv->read_syseeprom_data(buf, offset, count); + if (rd_len < 0) { + SWITCH_ERR("read syseeprom data error, offset: 0x%llx, read len: %lu, ret: %ld.\n", + offset, count, rd_len); + return -EIO; + } + SWITCH_DBG("read syseeprom data success, offset:0x%llx, read len:%lu, really read len:%ld.\n", + offset, count, rd_len); + return rd_len; +} + +static ssize_t syseeprom_write(struct file *filp, struct kobject *kobj, struct bin_attribute *attr, + char *buf, loff_t offset, size_t count) +{ + ssize_t wr_len; + + check_p(g_syseeprom_drv); + check_p(g_syseeprom_drv->write_syseeprom_data); + + wr_len = g_syseeprom_drv->write_syseeprom_data(buf, offset, count); + if (wr_len < 0) { + SWITCH_ERR("write syseeprom data error, offset: 0x%llx, read len: %lu, ret: %ld.\n", + offset, count, wr_len); + return -EIO; + } + SWITCH_DBG("write syseeprom data success, offset:0x%llx, write len:%lu, really write len:%ld.\n", + offset, count, wr_len); + return wr_len; +} + +static int syseeprom_create_eeprom_attrs(void) +{ + int ret, eeprom_size; + + eeprom_size = g_syseeprom_drv->get_syseeprom_size(); + if (eeprom_size <= 0) { + SWITCH_ERR("syseeprom size: %d, invalid.\n", eeprom_size); + return -EINVAL; + } + + sysfs_bin_attr_init(&g_syseeprom.bin); + g_syseeprom.bin.attr.name = "syseeprom"; + g_syseeprom.bin.attr.mode = 0644; + g_syseeprom.bin.read = syseeprom_read; + g_syseeprom.bin.write = syseeprom_write; + g_syseeprom.bin.size = eeprom_size; + + ret = sysfs_create_bin_file(&switch_kset->kobj, &g_syseeprom.bin); + if (ret) { + SWITCH_ERR("create syseeprom bin error, ret: %d. \n", ret); + return -EBADRQC; + } + SWITCH_DBG("create syseeprom bin file success, eeprom size:%d.\n", eeprom_size); + g_syseeprom.creat_eeprom_bin_flag = 1; + return 0; +} + +static void syseeprom_remove_eeprom_attrs(void) +{ + if (g_syseeprom.creat_eeprom_bin_flag) { + sysfs_remove_bin_file(&switch_kset->kobj, &g_syseeprom.bin); + g_syseeprom.creat_eeprom_bin_flag = 0; + } + + return; +} + +int s3ip_sysfs_syseeprom_drivers_register(struct s3ip_sysfs_syseeprom_drivers_s *drv) +{ + int ret; + + SWITCH_INFO("s3ip_sysfs_syseeprom_drivers_register...\n"); + if (g_syseeprom_drv) { + SWITCH_ERR("g_syseeprom_drv is not NULL, can't register\n"); + return -EPERM; + } + + check_p(drv); + check_p(drv->get_syseeprom_size); + g_syseeprom_drv = drv; + + ret = syseeprom_create_eeprom_attrs(); + if (ret < 0) { + SWITCH_ERR("create syseeprom attributes failed, ret: %d\n", ret); + g_syseeprom_drv = NULL; + return ret; + } + SWITCH_INFO("s3ip_sysfs_syseeprom_drivers_register success.\n"); + return 0; +} + +void s3ip_sysfs_syseeprom_drivers_unregister(void) +{ + if (g_syseeprom_drv) { + syseeprom_remove_eeprom_attrs(); + g_syseeprom_drv = NULL; + SWITCH_DBG("s3ip_sysfs_syseeprom_drivers_unregister success.\n"); + } + + return; +} + +struct switch_obj *switch_kobject_create(const char *name, struct kobject *parent) +{ + struct switch_obj *obj; + int ret; + + obj = kzalloc(sizeof(*obj), GFP_KERNEL); + if (!obj) { + SWITCH_DBG("switch_kobject_create %s kzalloc error", name); + return NULL; + } + + obj->kobj.kset = switch_kset; + + ret = kobject_init_and_add(&obj->kobj, &switch_ktype, parent, "%s", name); + if (ret) { + kobject_put(&obj->kobj); + SWITCH_DBG("kobject_init_and_add %s error", name); + return NULL; + } + + return obj; +} + +void switch_kobject_delete(struct switch_obj **obj) +{ + if (*obj) { + SWITCH_DBG("%s delete %s.\n", (*obj)->kobj.parent->name, (*obj)->kobj.name); + kobject_put(&((*obj)->kobj)); + *obj = NULL; + } +} + +static int __init switch_init(void) +{ + SWITCH_INFO("switch_init...\n"); + + switch_kset = kset_create_and_add("s3ip", NULL, NULL); + if (!switch_kset) { + SWITCH_ERR("create switch_kset error.\n"); + return -ENOMEM; + } + + SWITCH_INFO("switch_init success.\n"); + return 0; +} + +static void __exit switch_exit(void) +{ + if (switch_kset) { + kset_unregister(switch_kset); + } + + SWITCH_INFO("switch_exit success.\n"); +} + +module_init(switch_init); +module_exit(switch_exit); +EXPORT_SYMBOL(s3ip_sysfs_syseeprom_drivers_register); +EXPORT_SYMBOL(s3ip_sysfs_syseeprom_drivers_unregister); +module_param(g_switch_loglevel, int, 0644); +MODULE_PARM_DESC(g_switch_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_DESCRIPTION("switch driver"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/sysled_sysfs.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/sysled_sysfs.c new file mode 100644 index 000000000000..e42d40a755a2 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/sysled_sysfs.c @@ -0,0 +1,314 @@ +/* + * sysled_sysfs.c + * + * This module create sysled kobjects and attributes in /sys/s3ip/sysled + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "switch.h" +#include "sysled_sysfs.h" + +static int g_sysled_loglevel = 0; + +#define SYSLED_INFO(fmt, args...) do { \ + if (g_sysled_loglevel & INFO) { \ + printk(KERN_INFO "[SYSLED_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define SYSLED_ERR(fmt, args...) do { \ + if (g_sysled_loglevel & ERR) { \ + printk(KERN_ERR "[SYSLED_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define SYSLED_DBG(fmt, args...) do { \ + if (g_sysled_loglevel & DBG) { \ + printk(KERN_DEBUG "[SYSLED_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static struct switch_obj *g_sysled_obj = NULL; +static struct s3ip_sysfs_sysled_drivers_s *g_sysled_drv = NULL; + +static ssize_t sys_led_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + int ret; + + check_p(g_sysled_drv); + check_p(g_sysled_drv->get_sys_led_status); + + ret = g_sysled_drv->get_sys_led_status(buf, PAGE_SIZE); + if (ret < 0) { + SYSLED_ERR("get sys led status failed, ret: %d:\n", ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + SYSLED_DBG("get sys led status success:\n"); + return ret; +} + +static ssize_t sys_led_status_store(struct switch_obj *obj, struct switch_attribute *attr, + const char *buf, size_t count) +{ + int ret, value; + + check_p(g_sysled_drv); + check_p(g_sysled_drv->set_sys_led_status); + + sscanf(buf, "%d", &value); + if (value < 0) { + SYSLED_ERR("invaild led status value: %d, can't set sys led status\n", value); + return -EINVAL; + } + ret = g_sysled_drv->set_sys_led_status(value); + if (ret < 0) { + SYSLED_ERR("set sys led status %d faield, ret: %d\n", value, ret); + return -EIO; + } + SYSLED_DBG("set sys led status %d success\n", value); + return count; +} + +static ssize_t bmc_led_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + int ret; + + check_p(g_sysled_drv); + check_p(g_sysled_drv->get_bmc_led_status); + + ret = g_sysled_drv->get_bmc_led_status(buf, PAGE_SIZE); + if (ret < 0) { + SYSLED_ERR("get bmc led status failed, ret: %d:\n", ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + SYSLED_DBG("get bmc led status success:\n"); + return ret; +} + +static ssize_t bmc_led_status_store(struct switch_obj *obj, struct switch_attribute *attr, + const char *buf, size_t count) +{ + int ret, value; + + check_p(g_sysled_drv); + check_p(g_sysled_drv->set_bmc_led_status); + + sscanf(buf, "%d", &value); + if (value < 0) { + SYSLED_ERR("invaild led status value: %d, can't set bmc led status\n", value); + return -EINVAL; + } + ret = g_sysled_drv->set_bmc_led_status(value); + if (ret < 0) { + SYSLED_ERR("set bmc led status %d faield, ret: %d\n", value, ret); + return -EIO; + } + SYSLED_DBG("set bmc led status %d success\n", value); + return count; +} + +static ssize_t sys_fan_led_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + int ret; + + check_p(g_sysled_drv); + check_p(g_sysled_drv->get_sys_fan_led_status); + + ret = g_sysled_drv->get_sys_fan_led_status(buf, PAGE_SIZE); + if (ret < 0) { + SYSLED_ERR("get sys fan led status failed, ret: %d:\n", ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + SYSLED_DBG("get sys fan led status success:\n"); + return ret; +} + +static ssize_t sys_fan_led_status_store(struct switch_obj *obj, struct switch_attribute *attr, + const char *buf, size_t count) +{ + int ret, value; + + check_p(g_sysled_drv); + check_p(g_sysled_drv->set_sys_fan_led_status); + + sscanf(buf, "%d", &value); + if (value < 0) { + SYSLED_ERR("invaild led status value: %d, can't set sys fan led status\n", value); + return -EINVAL; + } + ret = g_sysled_drv->set_sys_fan_led_status(value); + if (ret < 0) { + SYSLED_ERR("set sys fan led status %d faield, ret: %d\n", value, ret); + return -EIO; + } + SYSLED_DBG("set sys fan led status %d success\n", value); + return count; +} + +static ssize_t sys_psu_led_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + int ret; + + check_p(g_sysled_drv); + check_p(g_sysled_drv->get_sys_psu_led_status); + + ret = g_sysled_drv->get_sys_psu_led_status(buf, PAGE_SIZE); + if (ret < 0) { + SYSLED_ERR("get sys psu led status failed, ret: %d:\n", ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + SYSLED_DBG("get sys psu led status success:\n"); + return ret; +} + +static ssize_t sys_psu_led_status_store(struct switch_obj *obj, struct switch_attribute *attr, + const char *buf, size_t count) +{ + int ret, value; + + check_p(g_sysled_drv); + check_p(g_sysled_drv->set_sys_psu_led_status); + + sscanf(buf, "%d", &value); + if (value < 0) { + SYSLED_ERR("invaild led status value: %d, can't set sys psu led status\n", value); + return -EINVAL; + } + ret = g_sysled_drv->set_sys_psu_led_status(value); + if (ret < 0) { + SYSLED_ERR("set sys psu led status %d faield, ret: %d\n", value, ret); + return -EIO; + } + SYSLED_DBG("set sys psu led status %d success\n", value); + return count; +} + +static ssize_t id_led_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + int ret; + + check_p(g_sysled_drv); + check_p(g_sysled_drv->get_id_led_status); + + ret = g_sysled_drv->get_id_led_status(buf, PAGE_SIZE); + if (ret < 0) { + SYSLED_ERR("get id led status failed, ret: %d:\n", ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + SYSLED_DBG("get id led status success:\n"); + return ret; +} + +static ssize_t id_led_status_store(struct switch_obj *obj, struct switch_attribute *attr, + const char *buf, size_t count) +{ + int ret, value; + + check_p(g_sysled_drv); + check_p(g_sysled_drv->set_id_led_status); + + sscanf(buf, "%d", &value); + if (value < 0) { + SYSLED_ERR("invaild led status value: %d, can't set id led status\n", value); + return -EINVAL; + } + ret = g_sysled_drv->set_id_led_status(value); + if (ret < 0) { + SYSLED_ERR("set id led status %d faield, ret: %d\n", value, ret); + return -EIO; + } + SYSLED_DBG("set id led status %d success\n", value); + return count; +} + +/************************************syseeprom dir and attrs*******************************************/ +static struct switch_attribute sys_led_attr = __ATTR(sys_led_status, S_IRUGO | S_IWUSR, sys_led_status_show, sys_led_status_store); +static struct switch_attribute bmc_led_attr = __ATTR(bmc_led_status, S_IRUGO | S_IWUSR, bmc_led_status_show, bmc_led_status_store); +static struct switch_attribute fan_led_attr = __ATTR(fan_led_status, S_IRUGO | S_IWUSR, sys_fan_led_status_show, sys_fan_led_status_store); +static struct switch_attribute psu_led_attr = __ATTR(psu_led_status, S_IRUGO | S_IWUSR, sys_psu_led_status_show, sys_psu_led_status_store); +static struct switch_attribute id_led_attr = __ATTR(id_led_status, S_IRUGO | S_IWUSR, id_led_status_show, id_led_status_store); + +static struct attribute *sysled_dir_attrs[] = { + &sys_led_attr.attr, + &bmc_led_attr.attr, + &fan_led_attr.attr, + &psu_led_attr.attr, + &id_led_attr.attr, + NULL, +}; + +static struct attribute_group sysled_attr_group = { + .attrs = sysled_dir_attrs, +}; + +/* create syseled directory and attributes*/ +static int sysled_root_create(void) +{ + g_sysled_obj = switch_kobject_create("sysled", NULL); + if (!g_sysled_obj) { + SYSLED_ERR("switch_kobject_create sysled error!\n"); + return -ENOMEM; + } + + if (sysfs_create_group(&g_sysled_obj->kobj, &sysled_attr_group) != 0) { + switch_kobject_delete(&g_sysled_obj); + SYSLED_ERR("create sysled dir attrs error!\n"); + return -EBADRQC; + } + + return 0; +} + +/* delete syseled directory and attributes*/ +static void sysled_root_remove(void) +{ + if (g_sysled_obj) { + sysfs_remove_group(&g_sysled_obj->kobj, &sysled_attr_group); + switch_kobject_delete(&g_sysled_obj); + } + + return; +} + +int s3ip_sysfs_sysled_drivers_register(struct s3ip_sysfs_sysled_drivers_s *drv) +{ + int ret; + + SYSLED_INFO("s3ip_sysfs_sysled_drivers_register...\n"); + if (g_sysled_drv) { + SYSLED_ERR("g_sysled_drv is not NULL, can't register\n"); + return -EPERM; + } + + check_p(drv); + g_sysled_drv = drv; + + ret = sysled_root_create(); + if (ret < 0) { + SYSLED_ERR("sysled create error.\n"); + g_sysled_drv = NULL; + return ret; + } + SYSLED_INFO("s3ip_sysfs_sysled_drivers_register success\n"); + return 0; +} + +void s3ip_sysfs_sysled_drivers_unregister(void) +{ + if (g_sysled_drv) { + sysled_root_remove(); + g_sysled_drv = NULL; + SYSLED_DBG("s3ip_sysfs_sysled_drivers_unregister success.\n"); + } + return; +} + +EXPORT_SYMBOL(s3ip_sysfs_sysled_drivers_register); +EXPORT_SYMBOL(s3ip_sysfs_sysled_drivers_unregister); +module_param(g_sysled_loglevel, int, 0644); +MODULE_PARM_DESC(g_sysled_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/temp_sensor_sysfs.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/temp_sensor_sysfs.c new file mode 100644 index 000000000000..3bb229a5bf04 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/temp_sensor_sysfs.c @@ -0,0 +1,391 @@ +/* + * temp_sensor_sysfs.c + * + * This module create temp sensor kobjects and attributes in /sys/s3ip/temp_sensor + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "switch.h" +#include "temp_sensor_sysfs.h" + +static int g_temp_sensor_loglevel = 0; + +#define TEMP_SENSOR_INFO(fmt, args...) do { \ + if (g_temp_sensor_loglevel & INFO) { \ + printk(KERN_INFO "[TEMP_SENSOR][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define TEMP_SENSOR_ERR(fmt, args...) do { \ + if (g_temp_sensor_loglevel & ERR) { \ + printk(KERN_ERR "[TEMP_SENSOR][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define TEMP_SENSOR_DBG(fmt, args...) do { \ + if (g_temp_sensor_loglevel & DBG) { \ + printk(KERN_DEBUG "[TEMP_SENSOR][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +struct temp_sensor_obj_s { + struct switch_obj *obj; +}; + +struct temp_sensor_s { + unsigned int temp_number; + struct temp_sensor_obj_s *temp; +}; + +static struct s3ip_sysfs_temp_sensor_drivers_s *g_temp_sensor_drv = NULL; +static struct temp_sensor_s g_temp_sensor; +static struct switch_obj *g_temp_sensor_obj = NULL; + +static ssize_t temp_sensor_number_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + return (ssize_t)snprintf(buf, PAGE_SIZE, "%u\n", g_temp_sensor.temp_number); +} + +static ssize_t temp_sensor_value_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int temp_index; + int ret; + + check_p(g_temp_sensor_drv); + check_p(g_temp_sensor_drv->get_main_board_temp_value); + + temp_index = obj->index; + TEMP_SENSOR_DBG("temp index: %u\n", temp_index); + ret = g_temp_sensor_drv->get_main_board_temp_value(temp_index, buf, PAGE_SIZE); + if (ret < 0) { + TEMP_SENSOR_ERR("get temp%u value failed, ret: %d\n", temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t temp_sensor_alias_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int temp_index; + int ret; + + check_p(g_temp_sensor_drv); + check_p(g_temp_sensor_drv->get_main_board_temp_alias); + + temp_index = obj->index; + TEMP_SENSOR_DBG("temp index: %u\n", temp_index); + ret = g_temp_sensor_drv->get_main_board_temp_alias(temp_index, buf, PAGE_SIZE); + if (ret < 0) { + TEMP_SENSOR_ERR("get temp%u alias failed, ret: %d\n", temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t temp_sensor_type_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int temp_index; + int ret; + + check_p(g_temp_sensor_drv); + check_p(g_temp_sensor_drv->get_main_board_temp_type); + + temp_index = obj->index; + TEMP_SENSOR_DBG("temp index: %u\n", temp_index); + ret = g_temp_sensor_drv->get_main_board_temp_type(temp_index, buf, PAGE_SIZE); + if (ret < 0) { + TEMP_SENSOR_ERR("get temp%u type failed, ret: %d\n", temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t temp_sensor_max_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int temp_index; + int ret; + + check_p(g_temp_sensor_drv); + check_p(g_temp_sensor_drv->get_main_board_temp_max); + + temp_index = obj->index; + TEMP_SENSOR_DBG("temp index: %u\n", temp_index); + ret = g_temp_sensor_drv->get_main_board_temp_max(temp_index, buf, PAGE_SIZE); + if (ret < 0) { + TEMP_SENSOR_ERR("get temp%u max threshold failed, ret: %d\n", temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t temp_sensor_max_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int temp_index; + int ret; + + check_p(g_temp_sensor_drv); + check_p(g_temp_sensor_drv->set_main_board_temp_max); + + temp_index = obj->index; + TEMP_SENSOR_DBG("temp index: %u\n", temp_index); + ret = g_temp_sensor_drv->set_main_board_temp_max(temp_index, buf, count); + if (ret < 0) { + TEMP_SENSOR_ERR("set temp%u max threshold failed, value: %s, count: %lu, ret: %d\n", + temp_index, buf, count, ret); + return -EIO; + } + TEMP_SENSOR_DBG("set temp%u max threshold success, value: %s, count: %lu, ret: %d\n", + temp_index, buf, count, ret); + return count; +} + +static ssize_t temp_sensor_min_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int temp_index; + int ret; + + check_p(g_temp_sensor_drv); + check_p(g_temp_sensor_drv->get_main_board_temp_min); + + temp_index = obj->index; + TEMP_SENSOR_DBG("temp index: %u\n", temp_index); + ret = g_temp_sensor_drv->get_main_board_temp_min(temp_index, buf, PAGE_SIZE); + if (ret < 0) { + TEMP_SENSOR_ERR("get temp%u min threshold failed, ret: %d\n", temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t temp_sensor_min_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int temp_index; + int ret; + + check_p(g_temp_sensor_drv); + check_p(g_temp_sensor_drv->set_main_board_temp_min); + + temp_index = obj->index; + TEMP_SENSOR_DBG("temp index: %u\n", temp_index); + ret = g_temp_sensor_drv->set_main_board_temp_min(temp_index, buf, count); + if (ret < 0) { + TEMP_SENSOR_ERR("set temp%u min threshold failed, value: %s, count: %lu, ret: %d\n", + temp_index, buf, count, ret); + return -EIO; + } + TEMP_SENSOR_DBG("set temp%u min threshold success, value: %s, count: %lu, ret: %d\n", + temp_index, buf, count, ret); + return count; +} + +/************************************temp_sensor dir and attrs*******************************************/ +static struct switch_attribute num_temp_att = __ATTR(number, S_IRUGO, temp_sensor_number_show, NULL); + +static struct attribute *temp_sensor_dir_attrs[] = { + &num_temp_att.attr, + NULL, +}; + +static struct attribute_group temp_sensor_root_attr_group = { + .attrs = temp_sensor_dir_attrs, +}; + +/*******************************temp1 temp2 dir and attrs*******************************************/ +static struct switch_attribute temp_value_attr = __ATTR(value, S_IRUGO, temp_sensor_value_show, NULL); +static struct switch_attribute temp_alias_attr = __ATTR(alias, S_IRUGO, temp_sensor_alias_show, NULL); +static struct switch_attribute temp_type_attr = __ATTR(type, S_IRUGO, temp_sensor_type_show, NULL); +static struct switch_attribute temp_max_attr = __ATTR(max, S_IRUGO | S_IWUSR, temp_sensor_max_show, temp_sensor_max_store); +static struct switch_attribute temp_min_attr = __ATTR(min, S_IRUGO | S_IWUSR, temp_sensor_min_show, temp_sensor_min_store); + +static struct attribute *temp_sensor_attrs[] = { + &temp_value_attr.attr, + &temp_alias_attr.attr, + &temp_type_attr.attr, + &temp_max_attr.attr, + &temp_min_attr.attr, + NULL, +}; + +static struct attribute_group temp_sensor_attr_group = { + .attrs = temp_sensor_attrs, +}; + +static int temp_sensor_sub_single_create_kobj_and_attrs(struct kobject *parent, unsigned int index) +{ + char name[DIR_NAME_MAX_LEN]; + struct temp_sensor_obj_s *temp_sensor; + + temp_sensor = &g_temp_sensor.temp[index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "temp%u", index); + temp_sensor->obj = switch_kobject_create(name, parent); + if (!temp_sensor->obj) { + TEMP_SENSOR_ERR("create %s object error.\n", name); + return -ENOMEM; + } + temp_sensor->obj->index = index; + if (sysfs_create_group(&temp_sensor->obj->kobj, &temp_sensor_attr_group) != 0) { + TEMP_SENSOR_ERR("create %s attrs error.\n", name); + switch_kobject_delete(&temp_sensor->obj); + return -EBADRQC; + } + TEMP_SENSOR_DBG("create %s dir and attrs success.\n", name); + return 0; +} + +static void temp_sensor_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct temp_sensor_obj_s *temp_sensor; + + temp_sensor = &g_temp_sensor.temp[index - 1]; + if (temp_sensor->obj) { + sysfs_remove_group(&temp_sensor->obj->kobj, &temp_sensor_attr_group); + switch_kobject_delete(&temp_sensor->obj); + TEMP_SENSOR_DBG("delete temp%u dir and attrs success.\n", index); + } + + return; +} + +static int temp_sensor_sub_create_kobj_and_attrs(struct kobject *parent, int temp_num) +{ + unsigned int temp_index, i; + + g_temp_sensor.temp = kzalloc(sizeof(struct temp_sensor_obj_s) * temp_num, GFP_KERNEL); + if (!g_temp_sensor.temp) { + TEMP_SENSOR_ERR("kzalloc g_temp_sensor.temp error, temp number: %d.\n", temp_num); + return -ENOMEM; + } + + for (temp_index = 1; temp_index <= temp_num; temp_index++) { + if (temp_sensor_sub_single_create_kobj_and_attrs(parent, temp_index) != 0) { + goto error; + } + } + return 0; +error: + for (i = temp_index; i > 0; i--) { + temp_sensor_sub_single_remove_kobj_and_attrs(i); + } + kfree(g_temp_sensor.temp); + g_temp_sensor.temp = NULL; + return -EBADRQC; +} + +/* create temp[1-n] directory and attributes*/ +static int temp_sensor_sub_create(void) +{ + int ret; + + ret = temp_sensor_sub_create_kobj_and_attrs(&g_temp_sensor_obj->kobj, + g_temp_sensor.temp_number); + return ret; +} + +/* delete temp[1-n] directory and attributes*/ +static void temp_sensor_sub_remove(void) +{ + unsigned int temp_index; + + if (g_temp_sensor.temp) { + for (temp_index = g_temp_sensor.temp_number; temp_index > 0; temp_index--) { + temp_sensor_sub_single_remove_kobj_and_attrs(temp_index); + } + kfree(g_temp_sensor.temp); + g_temp_sensor.temp = NULL; + } + + return; +} + +/* create temp_sensor directory and number attributes */ +static int temp_sensor_root_create(void) +{ + g_temp_sensor_obj = switch_kobject_create("temp_sensor", NULL); + if (!g_temp_sensor_obj) { + TEMP_SENSOR_ERR("switch_kobject_create temp_sensor error!\n"); + return -ENOMEM; + } + + if (sysfs_create_group(&g_temp_sensor_obj->kobj, &temp_sensor_root_attr_group) != 0) { + switch_kobject_delete(&g_temp_sensor_obj); + TEMP_SENSOR_ERR("create temp_sensor dir attrs error!\n"); + return -EBADRQC; + } + return 0; +} + +/* delete temp_sensor directory and number attributes */ +static void temp_sensor_root_remove(void) +{ + if (g_temp_sensor_obj) { + sysfs_remove_group(&g_temp_sensor_obj->kobj, &temp_sensor_root_attr_group); + switch_kobject_delete(&g_temp_sensor_obj); + } + + return; +} + +int s3ip_sysfs_temp_sensor_drivers_register(struct s3ip_sysfs_temp_sensor_drivers_s *drv) +{ + int ret, temp_num; + + TEMP_SENSOR_INFO("s3ip_sysfs_temp_sensor_drivers_register...\n"); + if (g_temp_sensor_drv) { + TEMP_SENSOR_ERR("g_temp_sensor_drv is not NULL, can't register\n"); + return -EPERM; + } + + check_p(drv); + check_p(drv->get_main_board_temp_number); + g_temp_sensor_drv = drv; + + temp_num = g_temp_sensor_drv->get_main_board_temp_number(); + if (temp_num <= 0) { + TEMP_SENSOR_ERR("temp sensor number: %d, don't need to create temp_sensor dirs and attrs.\n", + temp_num); + return -EINVAL; + } + memset(&g_temp_sensor, 0, sizeof(struct temp_sensor_s)); + g_temp_sensor.temp_number = temp_num; + ret = temp_sensor_root_create(); + if (ret < 0) { + TEMP_SENSOR_ERR("create temp_sensor root dir and attrs failed, ret: %d\n", ret); + g_temp_sensor_drv = NULL; + return ret; + } + + ret = temp_sensor_sub_create(); + if (ret < 0) { + TEMP_SENSOR_ERR("create temp_sensor sub dir and attrs failed, ret: %d\n", ret); + temp_sensor_root_remove(); + g_temp_sensor_drv = NULL; + return ret; + } + TEMP_SENSOR_INFO("s3ip_sysfs_temp_sensor_drivers_register success\n"); + return ret; +} + +void s3ip_sysfs_temp_sensor_drivers_unregister(void) +{ + if (g_temp_sensor_drv) { + temp_sensor_sub_remove(); + temp_sensor_root_remove(); + g_temp_sensor_drv = NULL; + TEMP_SENSOR_DBG("s3ip_sysfs_temp_sensor_drivers_unregister success.\n"); + } + return; +} + +EXPORT_SYMBOL(s3ip_sysfs_temp_sensor_drivers_register); +EXPORT_SYMBOL(s3ip_sysfs_temp_sensor_drivers_unregister); +module_param(g_temp_sensor_loglevel, int, 0644); +MODULE_PARM_DESC(g_temp_sensor_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/transceiver_sysfs.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/transceiver_sysfs.c new file mode 100644 index 000000000000..02ad4d7a8688 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/transceiver_sysfs.c @@ -0,0 +1,618 @@ +/* + * transceiver_sysfs.c + * + * This module create eth kobjects and attributes in /sys/s3ip/transceiver + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "switch.h" +#include "transceiver_sysfs.h" + +static int g_sff_loglevel = 0; + +#define SFF_INFO(fmt, args...) do { \ + if (g_sff_loglevel & INFO) { \ + printk(KERN_INFO "[SFF_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define SFF_ERR(fmt, args...) do { \ + if (g_sff_loglevel & ERR) { \ + printk(KERN_ERR "[SFF_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define SFF_DBG(fmt, args...) do { \ + if (g_sff_loglevel & DBG) { \ + printk(KERN_DEBUG "[SFF_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +struct sff_obj_s { + struct switch_obj *sff_obj; + struct bin_attribute bin; + int sff_creat_bin_flag; +}; + +struct sff_s { + unsigned int sff_number; + struct sff_obj_s *sff; +}; + +static struct sff_s g_sff; +static struct switch_obj *g_sff_obj = NULL; +static struct s3ip_sysfs_transceiver_drivers_s *g_sff_drv = NULL; + +static ssize_t transceiver_power_on_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + int ret; + + check_p(g_sff_drv); + check_p(g_sff_drv->get_transceiver_power_on_status); + + ret = g_sff_drv->get_transceiver_power_on_status(buf, PAGE_SIZE); + if (ret < 0) { + SFF_ERR("get transceiver power on status failed, ret: %d\n", ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t transceiver_power_on_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + int ret, value; + + check_p(g_sff_drv); + check_p(g_sff_drv->set_transceiver_power_on_status); + + sscanf(buf, "%d", &value); + if (value < 0 || value > 1) { + SFF_ERR("invalid value: %d, can't set transceiver power on status.\n", value); + return -EINVAL; + } + + ret = g_sff_drv->set_transceiver_power_on_status(value); + if (ret < 0) { + SFF_ERR("set transceiver power on status %d failed, ret: %d\n", value, ret); + return -EIO; + } + return count; +} + +static ssize_t eth_power_on_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int eth_index; + int ret; + + check_p(g_sff_drv); + check_p(g_sff_drv->get_eth_power_on_status); + + eth_index = obj->index; + SFF_DBG("eth index: %u\n", eth_index); + ret = g_sff_drv->get_eth_power_on_status(eth_index, buf, PAGE_SIZE); + if (ret < 0) { + SFF_ERR("get eth%u power on status failed, ret: %d\n", eth_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t eth_power_on_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int eth_index; + int ret, value; + + check_p(g_sff_drv); + check_p(g_sff_drv->set_eth_power_on_status); + + sscanf(buf, "%d", &value); + eth_index = obj->index; + if (value < 0 || value > 1) { + SFF_ERR("invalid value: %d, can't set eth%u power on status.\n", value, eth_index); + return -EINVAL; + } + + ret = g_sff_drv->set_eth_power_on_status(eth_index, value); + if (ret < 0) { + SFF_ERR("set eth%u power on status %d failed, ret: %d\n", eth_index, value, ret); + return -EIO; + } + SFF_DBG("set eth%u power on status %d success\n", eth_index, value); + return count; +} + +static ssize_t eth_tx_fault_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int eth_index; + int ret; + + check_p(g_sff_drv); + check_p(g_sff_drv->get_eth_tx_fault_status); + + eth_index = obj->index; + SFF_DBG("eth index: %u\n", eth_index); + ret = g_sff_drv->get_eth_tx_fault_status(eth_index, buf, PAGE_SIZE); + if (ret < 0) { + SFF_ERR("get eth%u tx fault status failed, ret: %d\n", eth_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t eth_tx_disable_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int eth_index; + int ret; + + check_p(g_sff_drv); + check_p(g_sff_drv->get_eth_tx_disable_status); + + eth_index = obj->index; + SFF_DBG("eth index: %u\n", eth_index); + ret = g_sff_drv->get_eth_tx_disable_status(eth_index, buf, PAGE_SIZE); + if (ret < 0) { + SFF_ERR("get eth%u tx disable status failed, ret: %d\n", eth_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t eth_tx_disable_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int eth_index; + int ret, value; + + check_p(g_sff_drv); + check_p(g_sff_drv->set_eth_tx_disable_status); + + sscanf(buf, "%d", &value); + eth_index = obj->index; + if (value < 0 || value > 1) { + SFF_ERR("invalid value: %d, can't set eth%u tx disable status.\n", value, eth_index); + return -EINVAL; + } + + ret = g_sff_drv->set_eth_tx_disable_status(eth_index, value); + if (ret < 0) { + SFF_ERR("set eth%u tx disable status %d failed, ret: %d\n", eth_index, value, ret); + return -EIO; + } + SFF_DBG("set eth%u tx disable status %d success\n", eth_index, value); + return count; +} + +static ssize_t eth_present_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int eth_index; + int ret; + + check_p(g_sff_drv); + check_p(g_sff_drv->get_eth_present_status); + + eth_index = obj->index; + SFF_DBG("eth index: %u\n", eth_index); + ret = g_sff_drv->get_eth_present_status(eth_index, buf, PAGE_SIZE); + if (ret < 0) { + SFF_ERR("get eth%u present status failed, ret: %d\n", eth_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t eth_rx_los_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int eth_index; + int ret; + + check_p(g_sff_drv); + check_p(g_sff_drv->get_eth_rx_los_status); + + eth_index = obj->index; + SFF_DBG("eth index: %u\n", eth_index); + ret = g_sff_drv->get_eth_rx_los_status(eth_index, buf, PAGE_SIZE); + if (ret < 0) { + SFF_ERR("get eth%u rx los status failed, ret: %d\n", eth_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t eth_reset_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int eth_index; + int ret; + + check_p(g_sff_drv); + check_p(g_sff_drv->get_eth_reset_status); + + eth_index = obj->index; + SFF_DBG("eth index: %u\n", eth_index); + ret = g_sff_drv->get_eth_reset_status(eth_index, buf, PAGE_SIZE); + if (ret < 0) { + SFF_ERR("get eth%u reset status failed, ret: %d\n", eth_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t eth_reset_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int eth_index; + int ret, value; + + check_p(g_sff_drv); + check_p(g_sff_drv->set_eth_reset_status); + + sscanf(buf, "%d", &value); + eth_index = obj->index; + if (value < 0 || value > 1) { + SFF_ERR("invalid value: %d, can't set eth%u reset status.\n", value, eth_index); + return -EINVAL; + } + + ret = g_sff_drv->set_eth_reset_status(eth_index, value); + if (ret < 0) { + SFF_ERR("set eth%u reset status %d failed, ret: %d\n", eth_index, value, ret); + return -EIO; + } + SFF_DBG("set eth%u reset status %d success\n", eth_index, value); + return count; +} + +static ssize_t eth_low_power_mode_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int eth_index; + int ret; + + check_p(g_sff_drv); + check_p(g_sff_drv->get_eth_low_power_mode_status); + + eth_index = obj->index; + SFF_DBG("eth index: %u\n", eth_index); + ret = g_sff_drv->get_eth_low_power_mode_status(eth_index, buf, PAGE_SIZE); + if (ret < 0) { + SFF_ERR("get eth%u low power mode status failed, ret: %d\n", eth_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t eth_interrupt_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int eth_index; + int ret; + + check_p(g_sff_drv); + check_p(g_sff_drv->get_eth_interrupt_status); + + eth_index = obj->index; + SFF_DBG("eth index: %u\n", eth_index); + ret = g_sff_drv->get_eth_interrupt_status(eth_index, buf, PAGE_SIZE); + if (ret < 0) { + SFF_ERR("get eth%u interrupt status failed, ret: %d\n", eth_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t eth_eeprom_read(struct file *filp, struct kobject *kobj, struct bin_attribute *attr, + char *buf, loff_t offset, size_t count) +{ + struct switch_obj *eth_obj; + ssize_t rd_len; + unsigned int eth_index; + + check_p(g_sff_drv); + check_p(g_sff_drv->read_eth_eeprom_data); + + eth_obj = to_switch_obj(kobj); + eth_index = eth_obj->index; + memset(buf, 0, count); + rd_len = g_sff_drv->read_eth_eeprom_data(eth_index, buf, offset, count); + if (rd_len < 0) { + SFF_ERR("read eth%u eeprom data error, offset: 0x%llx, read len: %lu, ret: %ld.\n", + eth_index, offset, count, rd_len); + return -EIO; + } + + SFF_DBG("read eth%u eeprom data success, offset:0x%llx, read len:%lu, really read len:%ld.\n", + eth_index, offset, count, rd_len); + + return rd_len; +} + +static ssize_t eth_eeprom_write(struct file *filp, struct kobject *kobj, struct bin_attribute *attr, + char *buf, loff_t offset, size_t count) +{ + struct switch_obj *eth_obj; + ssize_t wr_len; + unsigned int eth_index; + + check_p(g_sff_drv); + check_p(g_sff_drv->write_eth_eeprom_data); + + eth_obj = to_switch_obj(kobj); + eth_index = eth_obj->index; + wr_len = g_sff_drv->write_eth_eeprom_data(eth_index, buf, offset, count); + if (wr_len < 0) { + SFF_ERR("write eth%u eeprom data error, offset: 0x%llx, read len: %lu, ret: %ld.\n", + eth_index, offset, count, wr_len); + return -EIO; + } + + SFF_DBG("write eth%u eeprom data success, offset:0x%llx, write len:%lu, really write len:%ld.\n", + eth_index, offset, count, wr_len); + + return wr_len; +} + +/************************************eth* signal attrs*******************************************/ +static struct switch_attribute eth_power_on_attr = __ATTR(power_on, S_IRUGO | S_IWUSR, eth_power_on_show, eth_power_on_store); +static struct switch_attribute eth_tx_fault_attr = __ATTR(tx_fault, S_IRUGO, eth_tx_fault_show, NULL); +static struct switch_attribute eth_tx_disable_attr = __ATTR(tx_disable, S_IRUGO | S_IWUSR, eth_tx_disable_show, eth_tx_disable_store); +static struct switch_attribute eth_present_attr = __ATTR(present, S_IRUGO, eth_present_show, NULL); +static struct switch_attribute eth_rx_los_attr = __ATTR(rx_los, S_IRUGO, eth_rx_los_show, NULL); +static struct switch_attribute eth_reset_attr = __ATTR(reset, S_IRUGO | S_IWUSR, eth_reset_show, eth_reset_store); +static struct switch_attribute eth_low_power_mode_attr = __ATTR(low_power_mode, S_IRUGO, eth_low_power_mode_show, NULL); +static struct switch_attribute eth_interrupt_attr = __ATTR(interrupt, S_IRUGO, eth_interrupt_show, NULL); + +static struct attribute *sff_signal_attrs[] = { + ð_power_on_attr.attr, + ð_tx_fault_attr.attr, + ð_tx_disable_attr.attr, + ð_present_attr.attr, + ð_rx_los_attr.attr, + ð_reset_attr.attr, + ð_low_power_mode_attr.attr, + ð_interrupt_attr.attr, + NULL, +}; + +static struct attribute_group sff_signal_attr_group = { + .attrs = sff_signal_attrs, +}; + +/*******************************transceiver dir and attrs*******************************************/ +static struct switch_attribute transceiver_power_on_attr = __ATTR(power_on, S_IRUGO | S_IWUSR, transceiver_power_on_show, transceiver_power_on_store); + +static struct attribute *transceiver_dir_attrs[] = { + &transceiver_power_on_attr.attr, + NULL, +}; + +static struct attribute_group sff_transceiver_attr_group = { + .attrs = transceiver_dir_attrs, +}; + +/* create eth* eeprom attributes */ +static int sff_sub_single_create_eeprom_attrs(unsigned int index) +{ + int ret, eeprom_size; + struct sff_obj_s *curr_sff; + + check_p(g_sff_drv->get_eth_eeprom_size); + eeprom_size = g_sff_drv->get_eth_eeprom_size(index); + if (eeprom_size <= 0) { + SFF_INFO("eth%u, eeprom_size: %d, don't need to creat eeprom attr.\n", + index, eeprom_size); + return 0; + } + + curr_sff = &g_sff.sff[index - 1]; + sysfs_bin_attr_init(&curr_sff->bin); + curr_sff->bin.attr.name = "eeprom"; + curr_sff->bin.attr.mode = 0644; + curr_sff->bin.read = eth_eeprom_read; + curr_sff->bin.write = eth_eeprom_write; + curr_sff->bin.size = eeprom_size; + + ret = sysfs_create_bin_file(&curr_sff->sff_obj->kobj, &curr_sff->bin); + if (ret) { + SFF_ERR("eth%u, create eeprom bin error, ret: %d. \n", index, ret); + return -EBADRQC; + } + + SFF_DBG("eth%u, create bin file success, eeprom size:%d.\n", index, eeprom_size); + curr_sff->sff_creat_bin_flag = 1; + return 0; +} + +static int sff_sub_single_create_kobj(struct kobject *parent, unsigned int index) +{ + struct sff_obj_s *curr_sff; + char sff_dir_name[DIR_NAME_MAX_LEN]; + + curr_sff = &g_sff.sff[index - 1]; + memset(sff_dir_name, 0, sizeof(sff_dir_name)); + snprintf(sff_dir_name, sizeof(sff_dir_name), "eth%d", index); + curr_sff->sff_obj = switch_kobject_create(sff_dir_name, parent); + if (!curr_sff->sff_obj) { + SFF_ERR("create eth%d object error! \n", index); + return -EBADRQC; + } + curr_sff->sff_obj->index = index; + if (sysfs_create_group(&curr_sff->sff_obj->kobj, &sff_signal_attr_group) != 0) { + switch_kobject_delete(&curr_sff->sff_obj); + return -EBADRQC; + } + + SFF_DBG("create eth%d dir and attrs success\n", index); + return 0; +} + +/* remove eth directory and attributes */ +static void sff_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct sff_obj_s *curr_sff; + + curr_sff = &g_sff.sff[index - 1]; + if (curr_sff->sff_obj) { + if (curr_sff->sff_creat_bin_flag) { + sysfs_remove_bin_file(&curr_sff->sff_obj->kobj, &curr_sff->bin); + curr_sff->sff_creat_bin_flag = 0; + } + sysfs_remove_group(&curr_sff->sff_obj->kobj, &sff_signal_attr_group); + switch_kobject_delete(&curr_sff->sff_obj); + } + + return; +} + +static int sff_sub_single_create_kobj_and_attrs(struct kobject *parent, unsigned int index) +{ + int ret; + + ret = sff_sub_single_create_kobj(parent, index); + if (ret < 0) { + SFF_ERR("create eth%d dir error.\n", index); + return ret; + } + + sff_sub_single_create_eeprom_attrs(index); + return 0; +} + +static int sff_sub_create_kobj_and_attrs(struct kobject *parent, int sff_num) +{ + unsigned int sff_index, i; + + g_sff.sff = kzalloc(sizeof(struct sff_obj_s) * sff_num, GFP_KERNEL); + if (!g_sff.sff) { + SFF_ERR("kzalloc g_sff.sff error, sff number = %d.\n", sff_num); + return -ENOMEM; + } + + for (sff_index = 1; sff_index <= sff_num; sff_index++) { + if (sff_sub_single_create_kobj_and_attrs(parent, sff_index) != 0 ) { + goto error; + } + } + return 0; +error: + for (i = sff_index; i > 0; i--) { + sff_sub_single_remove_kobj_and_attrs(i); + } + kfree(g_sff.sff); + g_sff.sff = NULL; + return -EBADRQC; +} + +/* create eth directory and attributes */ +static int sff_sub_create(void) +{ + int ret; + + ret = sff_sub_create_kobj_and_attrs(&g_sff_obj->kobj, g_sff.sff_number); + return ret; +} + +/* delete eth directory and attributes */ +static void sff_sub_remove(void) +{ + unsigned int sff_index; + + if (g_sff.sff) { + for (sff_index = g_sff.sff_number; sff_index > 0; sff_index--) { + sff_sub_single_remove_kobj_and_attrs(sff_index); + } + kfree(g_sff.sff); + g_sff.sff = NULL; + } + g_sff.sff_number = 0; + return; +} + +/* create transceiver directory and attributes */ +static int sff_transceiver_create(void) +{ + g_sff_obj = switch_kobject_create("transceiver", NULL); + if (!g_sff_obj) { + SFF_ERR("switch_kobject_create transceiver error!\n"); + return -ENOMEM; + } + g_sff_obj->index = 0; + if (sysfs_create_group(&g_sff_obj->kobj, &sff_transceiver_attr_group) != 0) { + switch_kobject_delete(&g_sff_obj); + SFF_ERR("create transceiver dir attrs error!\n"); + return -EBADRQC; + } + return 0; +} + +/* delete transceiver directory and attributes */ +static void sff_transceiver_remove(void) +{ + if (g_sff_obj) { + sysfs_remove_group(&g_sff_obj->kobj, &sff_transceiver_attr_group); + switch_kobject_delete(&g_sff_obj); + } + + return; +} + +int s3ip_sysfs_sff_drivers_register(struct s3ip_sysfs_transceiver_drivers_s *drv) +{ + int ret, sff_num; + + SFF_INFO("s3ip_sysfs_sff_drivers_register...\n"); + if (g_sff_drv) { + SFF_ERR("g_sff_drv is not NULL, can't register\n"); + return -EPERM; + } + + check_p(drv); + check_p(drv->get_eth_number); + g_sff_drv = drv; + + sff_num = g_sff_drv->get_eth_number(); + if (sff_num <= 0) { + SFF_ERR("eth number: %d, don't need to create transceiver dirs and attrs.\n", sff_num); + g_sff_drv = NULL; + return -EINVAL; + } + + memset(&g_sff, 0, sizeof(struct sff_s)); + g_sff.sff_number = sff_num; + ret = sff_transceiver_create(); + if (ret < 0) { + SFF_ERR("create transceiver root dir and attrs failed, ret: %d\n", ret); + g_sff_drv = NULL; + return ret; + } + ret = sff_sub_create(); + if (ret < 0) { + SFF_ERR("create transceiver sub dir and attrs failed, ret: %d\n", ret); + sff_transceiver_remove(); + g_sff_drv = NULL; + return ret; + } + SFF_INFO("s3ip_sysfs_sff_drivers_register success\n"); + return ret; +} + +void s3ip_sysfs_sff_drivers_unregister(void) +{ + if (g_sff_drv) { + sff_sub_remove(); + sff_transceiver_remove(); + g_sff_drv = NULL; + SFF_DBG("s3ip_sysfs_sff_drivers_unregister success.\n"); + } + return; +} + +EXPORT_SYMBOL(s3ip_sysfs_sff_drivers_register); +EXPORT_SYMBOL(s3ip_sysfs_sff_drivers_unregister); +module_param(g_sff_loglevel, int, 0644); +MODULE_PARM_DESC(g_sff_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/vol_sensor_sysfs.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/vol_sensor_sysfs.c new file mode 100644 index 000000000000..ac1b115061cc --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/vol_sensor_sysfs.c @@ -0,0 +1,433 @@ +/* + * vol_sensor_sysfs.c + * + * This module create vol sensor kobjects and attributes in /sys/s3ip/vol_sensor + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "switch.h" +#include "vol_sensor_sysfs.h" + +static int g_vol_sensor_loglevel = 0; + +#define VOL_SENSOR_INFO(fmt, args...) do { \ + if (g_vol_sensor_loglevel & INFO) { \ + printk(KERN_INFO "[VOL_SENSOR][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define VOL_SENSOR_ERR(fmt, args...) do { \ + if (g_vol_sensor_loglevel & ERR) { \ + printk(KERN_ERR "[VOL_SENSOR][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define VOL_SENSOR_DBG(fmt, args...) do { \ + if (g_vol_sensor_loglevel & DBG) { \ + printk(KERN_DEBUG "[VOL_SENSOR][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +struct vol_sensor_obj_s { + struct switch_obj *obj; +}; + +struct vol_sensor_s { + unsigned int vol_number; + struct vol_sensor_obj_s *vol; +}; + +static struct s3ip_sysfs_vol_sensor_drivers_s *g_vol_sensor_drv = NULL; +static struct vol_sensor_s g_vol_sensor; +static struct switch_obj *g_vol_sensor_obj = NULL; + +static ssize_t vol_sensor_number_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + return (ssize_t)snprintf(buf, PAGE_SIZE, "%u\n", g_vol_sensor.vol_number); +} + +static ssize_t vol_sensor_value_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int vol_index; + int ret; + + check_p(g_vol_sensor_drv); + check_p(g_vol_sensor_drv->get_main_board_vol_value); + + vol_index = obj->index; + VOL_SENSOR_DBG("vol index: %u\n", vol_index); + ret = g_vol_sensor_drv->get_main_board_vol_value(vol_index, buf, PAGE_SIZE); + if (ret < 0) { + VOL_SENSOR_ERR("get vol%u value failed, ret: %d\n", vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t vol_sensor_alias_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int vol_index; + int ret; + + check_p(g_vol_sensor_drv); + check_p(g_vol_sensor_drv->get_main_board_vol_alias); + + vol_index = obj->index; + VOL_SENSOR_DBG("vol index: %u\n", vol_index); + ret = g_vol_sensor_drv->get_main_board_vol_alias(vol_index, buf, PAGE_SIZE); + if (ret < 0) { + VOL_SENSOR_ERR("get vol%u alias failed, ret: %d\n", vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t vol_sensor_type_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int vol_index; + int ret; + + check_p(g_vol_sensor_drv); + check_p(g_vol_sensor_drv->get_main_board_vol_type); + + vol_index = obj->index; + VOL_SENSOR_DBG("vol index: %u\n", vol_index); + ret = g_vol_sensor_drv->get_main_board_vol_type(vol_index, buf, PAGE_SIZE); + if (ret < 0) { + VOL_SENSOR_ERR("get vol%u type failed, ret: %d\n", vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t vol_sensor_max_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int vol_index; + int ret; + + check_p(g_vol_sensor_drv); + check_p(g_vol_sensor_drv->get_main_board_vol_max); + + vol_index = obj->index; + VOL_SENSOR_DBG("vol index: %u\n", vol_index); + ret = g_vol_sensor_drv->get_main_board_vol_max(vol_index, buf, PAGE_SIZE); + if (ret < 0) { + VOL_SENSOR_ERR("get vol%u max threshold failed, ret: %d\n", vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t vol_sensor_max_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int vol_index; + int ret; + + check_p(g_vol_sensor_drv); + check_p(g_vol_sensor_drv->set_main_board_vol_max); + + vol_index = obj->index; + VOL_SENSOR_DBG("vol index: %u\n", vol_index); + ret = g_vol_sensor_drv->set_main_board_vol_max(vol_index, buf, count); + if (ret < 0) { + VOL_SENSOR_ERR("set vol%u max threshold failed, value: %s, count: %lu, ret: %d\n", + vol_index, buf, count, ret); + return -EIO; + } + VOL_SENSOR_DBG("set vol%u max threshold success, value: %s, count: %lu, ret: %d\n", + vol_index, buf, count, ret); + return count; +} + +static ssize_t vol_sensor_min_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int vol_index; + int ret; + + check_p(g_vol_sensor_drv); + check_p(g_vol_sensor_drv->get_main_board_vol_min); + + vol_index = obj->index; + VOL_SENSOR_DBG("vol index: %u\n", vol_index); + ret = g_vol_sensor_drv->get_main_board_vol_min(vol_index, buf, PAGE_SIZE); + if (ret < 0) { + VOL_SENSOR_ERR("get vol%u min threshold failed, ret: %d\n", vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t vol_sensor_min_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int vol_index; + int ret; + + check_p(g_vol_sensor_drv); + check_p(g_vol_sensor_drv->set_main_board_vol_min); + + vol_index = obj->index; + VOL_SENSOR_DBG("vol index: %u\n", vol_index); + ret = g_vol_sensor_drv->set_main_board_vol_min(vol_index, buf, count); + if (ret < 0) { + VOL_SENSOR_ERR("set vol%u min threshold failed, value: %s, count: %lu, ret: %d\n", + vol_index, buf, count, ret); + return -EIO; + } + VOL_SENSOR_DBG("set vol%u min threshold success, value: %s, count: %lu, ret: %d\n", + vol_index, buf, count, ret); + return count; +} + +static ssize_t vol_sensor_range_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int vol_index; + int ret; + + check_p(g_vol_sensor_drv); + check_p(g_vol_sensor_drv->get_main_board_vol_range); + + vol_index = obj->index; + VOL_SENSOR_DBG("vol index: %u\n", vol_index); + ret = g_vol_sensor_drv->get_main_board_vol_range(vol_index, buf, PAGE_SIZE); + if (ret < 0) { + VOL_SENSOR_ERR("get vol%u range failed, ret: %d\n", vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t vol_sensor_nominal_value_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int vol_index; + int ret; + + check_p(g_vol_sensor_drv); + check_p(g_vol_sensor_drv->get_main_board_vol_nominal_value); + + vol_index = obj->index; + VOL_SENSOR_DBG("vol index: %u\n", vol_index); + ret = g_vol_sensor_drv->get_main_board_vol_nominal_value(vol_index, buf, PAGE_SIZE); + if (ret < 0) { + VOL_SENSOR_ERR("get vol%u nominal value failed, ret: %d\n", vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +/************************************vol_sensor dir and attrs*******************************************/ +static struct switch_attribute num_vol_att = __ATTR(number, S_IRUGO, vol_sensor_number_show, NULL); + +static struct attribute *vol_sensor_dir_attrs[] = { + &num_vol_att.attr, + NULL, +}; + +static struct attribute_group vol_sensor_root_attr_group = { + .attrs = vol_sensor_dir_attrs, +}; + +/*******************************vol1 vol2 dir and attrs*******************************************/ +static struct switch_attribute vol_value_attr = __ATTR(value, S_IRUGO, vol_sensor_value_show, NULL); +static struct switch_attribute vol_alias_attr = __ATTR(alias, S_IRUGO, vol_sensor_alias_show, NULL); +static struct switch_attribute vol_type_attr = __ATTR(type, S_IRUGO, vol_sensor_type_show, NULL); +static struct switch_attribute vol_max_attr = __ATTR(max, S_IRUGO | S_IWUSR, vol_sensor_max_show, vol_sensor_max_store); +static struct switch_attribute vol_min_attr = __ATTR(min, S_IRUGO | S_IWUSR, vol_sensor_min_show, vol_sensor_min_store); +static struct switch_attribute vol_range_attr = __ATTR(range, S_IRUGO, vol_sensor_range_show, NULL); +static struct switch_attribute vol_nominal_value_attr = __ATTR(nominal_value, S_IRUGO, vol_sensor_nominal_value_show, NULL); + +static struct attribute *vol_sensor_attrs[] = { + &vol_value_attr.attr, + &vol_alias_attr.attr, + &vol_type_attr.attr, + &vol_max_attr.attr, + &vol_min_attr.attr, + &vol_range_attr.attr, + &vol_nominal_value_attr.attr, + NULL, +}; + +static struct attribute_group vol_sensor_attr_group = { + .attrs = vol_sensor_attrs, +}; + +static int vol_sensor_sub_single_create_kobj_and_attrs(struct kobject *parent, unsigned int index) +{ + char name[DIR_NAME_MAX_LEN]; + struct vol_sensor_obj_s *vol_sensor; + + vol_sensor = &g_vol_sensor.vol[index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "vol%u", index); + vol_sensor->obj = switch_kobject_create(name, parent); + if (!vol_sensor->obj) { + VOL_SENSOR_ERR("create %s object error.\n", name); + return -ENOMEM; + } + + vol_sensor->obj->index = index; + if (sysfs_create_group(&vol_sensor->obj->kobj, &vol_sensor_attr_group) != 0) { + VOL_SENSOR_ERR("create %s attrs error.\n", name); + switch_kobject_delete(&vol_sensor->obj); + return -EBADRQC; + } + VOL_SENSOR_DBG("create %s dir and attrs success.\n", name); + + return 0; +} + +static void vol_sensor_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct vol_sensor_obj_s *vol_sensor; + + vol_sensor = &g_vol_sensor.vol[index - 1]; + if (vol_sensor->obj) { + sysfs_remove_group(&vol_sensor->obj->kobj, &vol_sensor_attr_group); + switch_kobject_delete(&vol_sensor->obj); + VOL_SENSOR_DBG("delete vol%u dir and attrs success.\n", index); + } + + return; +} + +static int vol_sensor_sub_create_kobj_and_attrs(struct kobject *parent, int vol_num) +{ + unsigned int vol_index, i; + + g_vol_sensor.vol = kzalloc(sizeof(struct vol_sensor_obj_s) * vol_num, GFP_KERNEL); + if (!g_vol_sensor.vol) { + VOL_SENSOR_ERR("kzalloc g_vol_sensor.vol error, vol number: %d.\n", vol_num); + return -ENOMEM; + } + + for (vol_index = 1; vol_index <= vol_num; vol_index++) { + if (vol_sensor_sub_single_create_kobj_and_attrs(parent, vol_index) != 0) { + goto error; + } + } + return 0; +error: + for (i = vol_index; i > 0; i--) { + vol_sensor_sub_single_remove_kobj_and_attrs(i); + } + kfree(g_vol_sensor.vol); + g_vol_sensor.vol = NULL; + return -EBADRQC; +} + +/* create vol[1-n] directory and attributes*/ +static int vol_sensor_sub_create(void) +{ + int ret; + + ret = vol_sensor_sub_create_kobj_and_attrs(&g_vol_sensor_obj->kobj, g_vol_sensor.vol_number); + return ret; +} + +/* delete vol[1-n] directory and attributes*/ +static void vol_sensor_sub_remove(void) +{ + unsigned int vol_index; + + if (g_vol_sensor.vol) { + for (vol_index = g_vol_sensor.vol_number; vol_index > 0; vol_index--) { + vol_sensor_sub_single_remove_kobj_and_attrs(vol_index); + } + kfree(g_vol_sensor.vol); + g_vol_sensor.vol = NULL; + } + + return; +} + +/* create vol_sensor directory and number attributes */ +static int vol_sensor_root_create(void) +{ + g_vol_sensor_obj = switch_kobject_create("vol_sensor", NULL); + if (!g_vol_sensor_obj) { + VOL_SENSOR_ERR("switch_kobject_create vol_sensor error!\n"); + return -ENOMEM; + } + + if (sysfs_create_group(&g_vol_sensor_obj->kobj, &vol_sensor_root_attr_group) != 0) { + switch_kobject_delete(&g_vol_sensor_obj); + VOL_SENSOR_ERR("create vol_sensor dir attrs error!\n"); + return -EBADRQC; + } + + return 0; +} + +/* delete vol_sensor directory and number attributes */ +static void vol_sensor_root_remove(void) +{ + if (g_vol_sensor_obj) { + sysfs_remove_group(&g_vol_sensor_obj->kobj, &vol_sensor_root_attr_group); + switch_kobject_delete(&g_vol_sensor_obj); + } + + return; +} + +int s3ip_sysfs_vol_sensor_drivers_register(struct s3ip_sysfs_vol_sensor_drivers_s *drv) +{ + int ret, vol_num; + + VOL_SENSOR_INFO("s3ip_sysfs_vol_sensor_drivers_register...\n"); + if (g_vol_sensor_drv) { + VOL_SENSOR_ERR("g_vol_sensor_drv is not NULL, can't register\n"); + return -EPERM; + } + + check_p(drv); + check_p(drv->get_main_board_vol_number); + g_vol_sensor_drv = drv; + + vol_num = g_vol_sensor_drv->get_main_board_vol_number(); + if (vol_num <= 0) { + VOL_SENSOR_ERR("vol sensor number: %d, don't need to create vol_sensor dirs and attrs.\n", + vol_num); + return -EINVAL; + } + memset(&g_vol_sensor, 0, sizeof(struct vol_sensor_s)); + g_vol_sensor.vol_number = vol_num; + ret = vol_sensor_root_create(); + if (ret < 0) { + VOL_SENSOR_ERR("create vol_sensor root dir and attrs failed, ret: %d\n", ret); + g_vol_sensor_drv = NULL; + return ret; + } + + ret = vol_sensor_sub_create(); + if (ret < 0) { + VOL_SENSOR_ERR("create vol_sensor sub dir and attrs failed, ret: %d\n", ret); + vol_sensor_root_remove(); + g_vol_sensor_drv = NULL; + return ret; + } + VOL_SENSOR_INFO("s3ip_sysfs_vol_sensor_drivers_register success\n"); + return ret; +} + +void s3ip_sysfs_vol_sensor_drivers_unregister(void) +{ + if (g_vol_sensor_drv) { + vol_sensor_sub_remove(); + vol_sensor_root_remove(); + g_vol_sensor_drv = NULL; + VOL_SENSOR_DBG("s3ip_sysfs_vol_sensor_drivers_unregister success.\n"); + } + return; +} + +EXPORT_SYMBOL(s3ip_sysfs_vol_sensor_drivers_register); +EXPORT_SYMBOL(s3ip_sysfs_vol_sensor_drivers_unregister); +module_param(g_vol_sensor_loglevel, int, 0644); +MODULE_PARM_DESC(g_vol_sensor_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/watchdog_sysfs.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/watchdog_sysfs.c new file mode 100644 index 000000000000..4487d5d19ac7 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/watchdog_sysfs.c @@ -0,0 +1,263 @@ +/* + * watchdog_sysfs.c + * + * This module create watchdog kobjects and attributes in /sys/s3ip/watchdog + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "switch.h" +#include "watchdog_sysfs.h" + +static int g_wdt_loglevel = 0; + +#define WDT_INFO(fmt, args...) do { \ + if (g_wdt_loglevel & INFO) { \ + printk(KERN_INFO "[WDT_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define WDT_ERR(fmt, args...) do { \ + if (g_wdt_loglevel & ERR) { \ + printk(KERN_ERR "[WDT_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define WDT_DBG(fmt, args...) do { \ + if (g_wdt_loglevel & DBG) { \ + printk(KERN_DEBUG "[WDT_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +typedef enum wdt_enable_status_e { + WDT_DISENABLE = 0, /* close watchdog */ + WDT_ENABLE = 1, /* open watchdog */ +} wdt_enable_status_t; + +static struct switch_obj *g_watchdog_obj = NULL; +static struct s3ip_sysfs_watchdog_drivers_s *g_wdt_drv = NULL; + +static ssize_t watchdog_identify_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + int ret; + + check_p(g_wdt_drv); + check_p(g_wdt_drv->get_watchdog_identify); + + ret = g_wdt_drv->get_watchdog_identify(buf, PAGE_SIZE); + if (ret < 0) { + WDT_ERR("get watchdog identify failed, ret: %d\n", ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + WDT_DBG("get watchdog identify success\n"); + return ret; +} + +static ssize_t watchdog_timeleft_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + int ret; + + check_p(g_wdt_drv); + check_p(g_wdt_drv->get_watchdog_timeleft); + + ret = g_wdt_drv->get_watchdog_timeleft(buf, PAGE_SIZE); + if (ret < 0) { + WDT_ERR("get watchdog timeleft failed, ret: %d\n", ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + WDT_DBG("get watchdog timeleft success\n"); + return ret; +} + +static ssize_t watchdog_timeout_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + int ret; + + check_p(g_wdt_drv); + check_p(g_wdt_drv->get_watchdog_timeout); + + ret = g_wdt_drv->get_watchdog_timeout(buf, PAGE_SIZE); + if (ret < 0) { + WDT_ERR("get watchdog timeout failed, ret: %d\n", ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + WDT_DBG("get watchdog timeout success\n"); + return ret; +} + +static ssize_t watchdog_timeout_store(struct switch_obj *obj, struct switch_attribute *attr, + const char *buf, size_t count) +{ + int ret, value; + + check_p(g_wdt_drv); + check_p(g_wdt_drv->set_watchdog_timeout); + + sscanf(buf, "%d", &value); + if (value < 0) { + WDT_ERR("invaild timeout value: %d, can't set watchdog timeout\n", value); + return -EINVAL; + } + + ret = g_wdt_drv->set_watchdog_timeout(value); + if (ret < 0) { + WDT_ERR("set watchdog timeout value: %d failed, ret: %d\n", value, ret); + return -EIO; + } + WDT_DBG("set watchdog timeout value: %d success\n", ret); + return count; +} + +static ssize_t watchdog_enable_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + int ret; + + check_p(g_wdt_drv); + check_p(g_wdt_drv->get_watchdog_enable_status); + + ret = g_wdt_drv->get_watchdog_enable_status(buf, PAGE_SIZE); + if (ret < 0) { + WDT_ERR("get watchdog enable status failed, ret: %d\n", ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + WDT_DBG("get watchdog enable status success\n"); + return ret; +} + +static ssize_t watchdog_enable_status_store(struct switch_obj *obj, struct switch_attribute *attr, + const char *buf, size_t count) +{ + int ret, value; + + check_p(g_wdt_drv); + check_p(g_wdt_drv->set_watchdog_enable_status); + + sscanf(buf, "%d", &value); + if ((value != WDT_DISENABLE) && (value != WDT_ENABLE)) { + WDT_ERR("invaild enable value: %d, can't set watchdog enable status\n", value); + return -EINVAL; + } + + ret = g_wdt_drv->set_watchdog_enable_status(value); + if (ret < 0) { + WDT_ERR("set watchdog enable status %d failed, ret: %d\n", value, ret); + return -EIO; + } + WDT_DBG("set watchdog enable status %d success\n", ret); + return count; +} + +static ssize_t watchdog_reset_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + int ret, value; + + check_p(g_wdt_drv); + check_p(g_wdt_drv->set_watchdog_reset); + + ret = kstrtoint(buf, 0, &value); + if (ret) { + WDT_ERR("invalid value: %s \n", buf); + return -EINVAL; + } + + ret = g_wdt_drv->set_watchdog_reset(value); + if (ret < 0) { + WDT_ERR("set watchdog reset %d failed, ret: %d\n", value, ret); + return -EIO; + } + WDT_DBG("set watchdog reset %d success\n", ret); + return count; +} + +/************************************watchdog*******************************************/ +static struct switch_attribute watchdog_identify_attr = __ATTR(identify, S_IRUGO, watchdog_identify_show, NULL); +static struct switch_attribute watchdog_timeleft_attr = __ATTR(timeleft, S_IRUGO, watchdog_timeleft_show, NULL); +static struct switch_attribute watchdog_timeout_attr = __ATTR(timeout, S_IRUGO | S_IWUSR, watchdog_timeout_show, watchdog_timeout_store); +static struct switch_attribute watchdog_enable_attr = __ATTR(enable, S_IRUGO | S_IWUSR, watchdog_enable_status_show, watchdog_enable_status_store); +static struct switch_attribute watchdog_reset_attr = __ATTR(reset, S_IWUSR, NULL, watchdog_reset_store); + +static struct attribute *watchdog_dir_attrs[] = { + &watchdog_identify_attr.attr, + &watchdog_timeleft_attr.attr, + &watchdog_timeout_attr.attr, + &watchdog_enable_attr.attr, + &watchdog_reset_attr.attr, + NULL, +}; + +static struct attribute_group watchdog_attr_group = { + .attrs = watchdog_dir_attrs, +}; + +/* create watchdog directory and attributes */ +static int watchdog_root_create(void) +{ + g_watchdog_obj = switch_kobject_create("watchdog", NULL); + if (!g_watchdog_obj) { + WDT_ERR("switch_kobject_create watchdog error!\n"); + return -ENOMEM; + } + + if (sysfs_create_group(&g_watchdog_obj->kobj, &watchdog_attr_group) != 0) { + switch_kobject_delete(&g_watchdog_obj); + WDT_ERR("create fan dir attrs error!\n"); + return -EBADRQC; + } + + return 0; +} + +/* delete watchdog directory and attributes */ +static void watchdog_root_remove(void) +{ + if (g_watchdog_obj) { + sysfs_remove_group(&g_watchdog_obj->kobj, &watchdog_attr_group); + switch_kobject_delete(&g_watchdog_obj); + } + + return; +} + +int s3ip_sysfs_watchdog_drivers_register(struct s3ip_sysfs_watchdog_drivers_s *drv) +{ + int ret; + + WDT_INFO("s3ip_sysfs_watchdog_drivers_register...\n"); + if (g_wdt_drv) { + WDT_ERR("g_wdt_drv is not NULL, can't register\n"); + return -EPERM; + } + + check_p(drv); + g_wdt_drv = drv; + + ret = watchdog_root_create(); + if (ret < 0) { + WDT_ERR("watchdog create error.\n"); + g_wdt_drv = NULL; + return ret; + } + WDT_INFO("s3ip_sysfs_watchdog_drivers_register success\n"); + return 0; +} + +void s3ip_sysfs_watchdog_drivers_unregister(void) +{ + if (g_wdt_drv) { + watchdog_root_remove(); + g_wdt_drv = NULL; + WDT_DBG("s3ip_sysfs_watchdog_drivers_unregister success.\n"); + } + + return; +} + +EXPORT_SYMBOL(s3ip_sysfs_watchdog_drivers_register); +EXPORT_SYMBOL(s3ip_sysfs_watchdog_drivers_unregister); +module_param(g_wdt_loglevel, int, 0644); +MODULE_PARM_DESC(g_wdt_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/script/s3ip_load.py b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/script/s3ip_load.py new file mode 100755 index 000000000000..3f359289f64a --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/script/s3ip_load.py @@ -0,0 +1,30 @@ +#!/usr/bin/python3 +import json +import os + +if __name__ == '__main__': + os.system("sudo rm -rf /sys_switch/*;sudo mkdir -p -m 777 /sys_switch") + + with open('/etc/s3ip/customer_sysfs.json', 'r') as jsonfile: + json_string = json.load(jsonfile) + for s3ip_sysfs_path in json_string['s3ip_syfs_paths']: + #print('path:' + s3ip_sysfs_path['path']) + #print('type:' + s3ip_sysfs_path['type']) + #print('value:' + s3ip_sysfs_path['value']) + + if s3ip_sysfs_path['type'] == "string" : + (path, file) = os.path.split(s3ip_sysfs_path['path']) + command = "sudo mkdir -p -m 777 " + path + #print(command) + os.system(command) + command = "sudo echo " + "\"" + s3ip_sysfs_path['value'] + "\"" + " > " + s3ip_sysfs_path['path'] + #print(command) + os.system(command) + elif s3ip_sysfs_path['type'] == "path" : + command = "sudo ln -s " + s3ip_sysfs_path['value'] + " " + s3ip_sysfs_path['path'] + #print(command) + os.system(command) + else: + print('error type:' + s3ip_sysfs_path['type']) + #os.system("tree -l /sys_switch") + diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/script/s3ip_sysfs_tool.sh b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/script/s3ip_sysfs_tool.sh new file mode 100755 index 000000000000..ca42b4586daf --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/script/s3ip_sysfs_tool.sh @@ -0,0 +1,33 @@ +#! /bin/bash + +s3ip_start(){ + sudo rm -rf /sys_switch/* + sudo /usr/local/bin/s3ip_load.py + echo "s3ip service start" +} +s3ip_stop(){ + sudo rm -rf /sys_switch/* + echo "s3ip service stop" + +} + +case "$1" in + start) + s3ip_start + ;; + stop) + s3ip_stop + ;; + status) + sudo tree -l /sys_switch + ;; + restart) + s3ip_stop + s3ip_start + ;; + *) + echo "Usage: $0 {start|stop|status|restart}" + exit 1 +esac +exit + diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/service/s3ip_sysfs.service b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/service/s3ip_sysfs.service new file mode 100755 index 000000000000..db557fefd149 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/service/s3ip_sysfs.service @@ -0,0 +1,17 @@ +[Unit] +Description=s3ip sysfs service +Wants=network-online.target +After=network-online.target rg_platform_driver.service +Before=pmon.service rg_platform_process.service +Requires=rg_platform_driver.service + +[Service] +Type=oneshot +User=root +ExecStart=/usr/local/bin/s3ip_sysfs_tool.sh start +ExecStop=/usr/local/bin/s3ip_sysfs_tool.sh stop +RemainAfterExit=yes + +[Install] +WantedBy=default.target + diff --git a/platform/broadcom/sonic-platform-modules-tencent/debian/changelog b/platform/broadcom/sonic-platform-modules-tencent/debian/changelog new file mode 100644 index 000000000000..c987c3560017 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/debian/changelog @@ -0,0 +1,5 @@ +sonic-ruijie-platform-modules (1.0) unstable; urgency=low + + * Initial release + + -- sonic_rd Fri, 21 APR 2017 11:11:11 -0800 diff --git a/platform/broadcom/sonic-platform-modules-tencent/debian/compat b/platform/broadcom/sonic-platform-modules-tencent/debian/compat new file mode 100644 index 000000000000..f599e28b8ab0 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/debian/compat @@ -0,0 +1 @@ +10 diff --git a/platform/broadcom/sonic-platform-modules-tencent/debian/control b/platform/broadcom/sonic-platform-modules-tencent/debian/control new file mode 100755 index 000000000000..8815bfb5512d --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/debian/control @@ -0,0 +1,13 @@ +Source: sonic-ruijie-platform-modules +Section: main +Priority: extra +Maintainer: Ruijie Network +Standards-Version: 3.9.3 + +Package: platform-modules-ruijie-tcs8400 +Architecture: amd64 +Description: kernel modules for platform devices such as fan, led, sfp + +Package: platform-modules-ruijie-tcs9400 +Architecture: amd64 +Description: kernel modules for platform devices such as fan, led, sfp diff --git a/platform/broadcom/sonic-platform-modules-tencent/debian/copyright b/platform/broadcom/sonic-platform-modules-tencent/debian/copyright new file mode 100755 index 000000000000..675157697ad9 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/debian/copyright @@ -0,0 +1,16 @@ +Copyright (C) 2016 Microsoft, Inc +Copyright (C) 2022 Ruijie Network 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 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. diff --git a/platform/broadcom/sonic-platform-modules-tencent/debian/platform-modules-ruijie-tcs8400.install b/platform/broadcom/sonic-platform-modules-tencent/debian/platform-modules-ruijie-tcs8400.install new file mode 100644 index 000000000000..5fbd8e13c6b7 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/debian/platform-modules-ruijie-tcs8400.install @@ -0,0 +1 @@ +tcs8400/modules/sonic_platform-1.0-py3-none-any.whl /usr/share/sonic/device/x86_64-tencent_tcs8400-r0 diff --git a/platform/broadcom/sonic-platform-modules-tencent/debian/platform-modules-ruijie-tcs8400.postinst b/platform/broadcom/sonic-platform-modules-tencent/debian/platform-modules-ruijie-tcs8400.postinst new file mode 100755 index 000000000000..a8132f4f65a9 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/debian/platform-modules-ruijie-tcs8400.postinst @@ -0,0 +1,10 @@ +#!/bin/sh +# postinst + +kernel_version=$(uname -r) + +if [ -e /boot/System.map-${kernel_version} ]; then + depmod -a -F /boot/System.map-${kernel_version} ${kernel_version} || true +fi + +#DEBHELPER# diff --git a/platform/broadcom/sonic-platform-modules-tencent/debian/rule-tx.mk b/platform/broadcom/sonic-platform-modules-tencent/debian/rule-tx.mk new file mode 100755 index 000000000000..06596c412270 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/debian/rule-tx.mk @@ -0,0 +1,6 @@ +currentdir = $(shell pwd) +CUSTOMS_DIRS = $(currentdir)/common_custom/common_tx +MODULE_DIRS := tcs8400 tcs9400 +export CUSTOMS_DIRS MODULE_DIRS + + diff --git a/platform/broadcom/sonic-platform-modules-tencent/debian/rules b/platform/broadcom/sonic-platform-modules-tencent/debian/rules new file mode 100755 index 000000000000..251b1bed958f --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/debian/rules @@ -0,0 +1,100 @@ +#!/usr/bin/make -f +CC=gcc +INSTALL_MOD_DIR:=extra +KVERSION ?= $(shell uname -r) +KERNEL_SRC := /lib/modules/$(KVERSION) +MOD_SRC_DIR:= $(shell pwd) +KBUILD_OUTPUT=$(KERNEL_SRC)/build + +LIB_DIR = usr/lib/python3/dist-packages +CUSTOM_RULES_DIR := $(shell pwd)/debian + +export INSTALL_MOD_DIR top_srcdir KVERSION KERNEL_SRC CC KBUILD_OUTPUT CUSTOM_RULES_DIR + +include $(CUSTOM_RULES_DIR)/rule-tx.mk + +#all product need common +COMPILE_DIRS = $(MODULE_DIRS) + +clean_dirs = $(MODULE_DIRS) +clean_dirs += common + +custom_clean_dirs := $(addprefix _clean_,$(clean_dirs) ) +complie_clean_dirs := $(addprefix _clean_,$(CUSTOMS_DIRS) ) + + +%: + dh $@ +build: $(CUSTOMS_DIRS) + @echo "build success" + +$(custom_clean_dirs): + $(MAKE) -C $(patsubst _clean_%,%,$@) clean + +$(complie_clean_dirs): + $(MAKE) -C $(patsubst _clean_%,%,$@) clean + +common_build : + $(MAKE) -C $(MOD_SRC_DIR)/common + +$(COMPILE_DIRS): common_build + $(MAKE) -C $(MOD_SRC_DIR)/$@ + dh_testdir + dh_installdirs + #dh_installdirs -pplatform-modules-ruijie-$@ usr/local/bin + cp -r $(MOD_SRC_DIR)/common/build/* debian/platform-modules-ruijie-$@/ + cp -r $(MOD_SRC_DIR)/$@/build/* debian/platform-modules-ruijie-$@/ + +$(CUSTOMS_DIRS): $(COMPILE_DIRS) + $(MAKE) -C $@ + @(for mod in $(MODULE_DIRS); do \ + cp -r $@/build/* $(MOD_SRC_DIR)/debian/platform-modules-ruijie-$${mod}/; \ + cd $(MOD_SRC_DIR)/$${mod}; \ + cp -r $(MOD_SRC_DIR)/common/lib/plat_hal $(MOD_SRC_DIR)/$${mod}/; \ + cp -r $(MOD_SRC_DIR)/common/lib/rjutil $(MOD_SRC_DIR)/$${mod}/; \ + cp -r $(MOD_SRC_DIR)/common/lib/eepromutil $(MOD_SRC_DIR)/$${mod}/; \ + cp -r $(MOD_SRC_DIR)/common/sonic_platform $(MOD_SRC_DIR)/$${mod}/; \ + cp $(MOD_SRC_DIR)/common/script/hal_pltfm.py $(MOD_SRC_DIR)/$${mod}/hal_pltfm.py; \ + cp $(MOD_SRC_DIR)/common/script/platform_util.py $(MOD_SRC_DIR)/$${mod}/platform_util.py; \ + cp $(MOD_SRC_DIR)/common/script/platform_intf.py $(MOD_SRC_DIR)/$${mod}/platform_intf.py; \ + python3 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \ + rm -rf $(MOD_SRC_DIR)/$${mod}/plat_hal; \ + rm -rf $(MOD_SRC_DIR)/$${mod}/rjutil; \ + rm -rf $(MOD_SRC_DIR)/$${mod}/eepromutil; \ + rm -rf $(MOD_SRC_DIR)/$${mod}/sonic_platform; \ + rm -rf $(MOD_SRC_DIR)/$${mod}/hal_pltfm.py; \ + rm -rf $(MOD_SRC_DIR)/$${mod}/platform_intf.py; \ + rm -rf $(MOD_SRC_DIR)/$${mod}/platform_util.py; \ + cd $(MOD_SRC_DIR); \ + done) + +binary: binary-indep + @echo "=======================================================" + +binary-indep: + # Resuming debhelper scripts + dh_testroot + dh_install + dh_installchangelogs + dh_installdocs + dh_systemd_enable + dh_installinit + dh_systemd_start + dh_link + dh_fixperms + dh_compress + dh_strip + dh_installdeb + dh_gencontrol + dh_md5sums + dh_builddeb +override_dh_usrlocal: + +override_dh_pysupport: + +clean: $(custom_clean_dirs) $(complie_clean_dirs) + dh_testdir + dh_testroot + dh_clean + +.PHONY: build $(COMPILE_DIRS) $(CUSTOMS_DIRS) binary binary-arch binary-indep clean \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/Makefile b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/Makefile new file mode 100755 index 000000000000..d4e576cf6a3f --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/Makefile @@ -0,0 +1,28 @@ +PWD = $(shell pwd) +DIR_KERNEL_SRC = $(PWD)/modules/driver +EXTRA_CFLAGS:= -I$(M)/include +EXTRA_CFLAGS+= -Wall +SUB_BUILD_DIR = $(PWD)/build +INSTALL_DIR = $(SUB_BUILD_DIR)/$(KERNEL_SRC)/$(INSTALL_MOD_DIR) +INSTALL_SCRIPT_DIR = $(SUB_BUILD_DIR)/usr/local/bin +INSTALL_LIB_DIR = $(SUB_BUILD_DIR)/usr/lib/python3/dist-packages +INSTALL_SYSFS_CFG_DIR = $(SUB_BUILD_DIR)/etc/plat_sysfs_cfg +INSTALL_S3IP_CONFIG_DIR = $(SUB_BUILD_DIR)/etc/s3ip + +all: + $(MAKE) -C $(KBUILD_OUTPUT) M=$(DIR_KERNEL_SRC) modules + @if [ ! -d ${INSTALL_DIR} ]; then mkdir -p ${INSTALL_DIR} ;fi + cp -r $(DIR_KERNEL_SRC)/*.ko $(INSTALL_DIR) + @if [ ! -d ${INSTALL_SCRIPT_DIR} ]; then mkdir -p ${INSTALL_SCRIPT_DIR} ;fi + cp -r $(PWD)/config/* $(INSTALL_SCRIPT_DIR) + @if [ ! -d ${INSTALL_LIB_DIR} ]; then mkdir -p ${INSTALL_LIB_DIR} ;fi + @if [ -d $(PWD)/hal-config/ ]; then cp -r $(PWD)/hal-config/* ${INSTALL_LIB_DIR} ;fi + @if [ ! -d ${INSTALL_SYSFS_CFG_DIR} ]; then mkdir -p ${INSTALL_SYSFS_CFG_DIR} ;fi + @if [ -d $(PWD)/plat_sysfs_cfg/ ]; then cp -r $(PWD)/plat_sysfs_cfg/* ${INSTALL_SYSFS_CFG_DIR} ;fi + @if [ ! -d ${INSTALL_S3IP_CONFIG_DIR} ]; then mkdir -p ${INSTALL_S3IP_CONFIG_DIR} ;fi + @if [ -d $(PWD)/s3ip_config/ ]; then cp -r $(PWD)/s3ip_config/* ${INSTALL_S3IP_CONFIG_DIR} ;fi +clean: + rm -f ${DIR_KERNEL_SRC}/*.o ${DIR_KERNEL_SRC}/*.ko ${DIR_KERNEL_SRC}/*.mod.c ${DIR_KERNEL_SRC}/.*.cmd ${DIR_KERNEL_SRC}/.*.mod + rm -f ${DIR_KERNEL_SRC}/Module.markers ${DIR_KERNEL_SRC}/Module.symvers ${DIR_KERNEL_SRC}/modules.order + rm -rf ${DIR_KERNEL_SRC}/.tmp_versions + rm -rf $(SUB_BUILD_DIR) diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/config/x86_64_tencent_tcs8400_r0_0x407b_config.py b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/config/x86_64_tencent_tcs8400_r0_0x407b_config.py new file mode 100755 index 000000000000..f221dd6d6a67 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/config/x86_64_tencent_tcs8400_r0_0x407b_config.py @@ -0,0 +1,975 @@ +#!/usr/bin/python3 +from ruijiecommon import * + + +STARTMODULE = { + "xdpe_avscontrol":1, + "dev_monitor": 1, + "hal_fanctrl":1, + "hal_ledctrl":1, + "sff_temp_polling":1, + "rg_pmon_syslog":1, +} + +DEV_MONITOR_PARAM = { + "polling_time" : 10, + "psus": [ + {"name": "psu1", + "present": {"gettype": "i2c", "bus": 2, "loc": 0x1d, "offset": 0x34, "presentbit": 0, "okval": 0}, + "device": [ + {"id": "psu1pmbus", "name": "rg_fsp1200", "bus": 41, "loc": 0x58, "attr": "hwmon"}, + {"id": "psu1frue2", "name": "24c02", "bus": 41, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "psu2", + "present": {"gettype": "i2c", "bus": 2, "loc": 0x1d, "offset": 0x34, "presentbit": 4, "okval": 0}, + "device": [ + {"id": "psu2pmbus", "name": "rg_fsp1200", "bus": 42, "loc": 0x58, "attr": "hwmon"}, + {"id": "psu2frue2", "name": "24c02", "bus": 42, "loc": 0x50, "attr": "eeprom"}, + ], + }, + ], + "fans": [ + {"name": "fan1", + "present": {"gettype": "i2c", "bus": 4, "loc": 0x3d, "offset": 0x37, "presentbit": 5, "okval": 0}, + "device": [ + {"id": "fan1frue2", "name": "24c64", "bus": 35, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan2", + "present": {"gettype": "i2c", "bus": 4, "loc": 0x3d, "offset": 0x37, "presentbit": 4, "okval": 0}, + "device": [ + {"id": "fan2frue2", "name": "24c64", "bus": 34, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan3", + "present": {"gettype": "i2c", "bus": 4, "loc": 0x3d, "offset": 0x37, "presentbit": 3, "okval": 0}, + "device": [ + {"id": "fan3frue2", "name": "24c64", "bus": 33, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan4", + "present": {"gettype": "i2c", "bus": 4, "loc": 0x3d, "offset": 0x37, "presentbit": 2, "okval": 0}, + "device": [ + {"id": "fan4frue2", "name": "24c64", "bus": 32, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan5", + "present": {"gettype": "i2c", "bus": 4, "loc": 0x3d, "offset": 0x37, "presentbit": 1, "okval": 0}, + "device": [ + {"id": "fan5frue2", "name": "24c64", "bus": 31, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan6", + "present": {"gettype": "i2c", "bus": 4, "loc": 0x3d, "offset": 0x37, "presentbit": 0, "okval": 0}, + "device": [ + {"id": "fan6frue2", "name": "24c64", "bus": 30, "loc": 0x50, "attr": "eeprom"}, + ], + }, + ], + "others": [ + {"name":"eeprom", + "device":[ + {"id":"eeprom_1", "name":"24c02","bus":1, "loc":0x56, "attr":"eeprom"}, + ], + }, + {"name":"lm75", + "device":[ + {"id":"lm75_1", "name":"lm75","bus":36, "loc":0x48, "attr":"hwmon"}, + {"id":"lm75_2", "name":"lm75","bus":36, "loc":0x49, "attr":"hwmon"}, + {"id":"lm75_3", "name":"lm75","bus":39, "loc":0x4b, "attr":"hwmon"}, + {"id":"lm75_4", "name":"lm75","bus":40, "loc":0x4e, "attr":"hwmon"}, + {"id":"lm75_5", "name":"lm75","bus":40, "loc":0x4f, "attr":"hwmon"}, + ], + }, + {"name":"mac_bsc", + "device":[ + {"id":"mac_bsc_1", "name":"rg_mac_bsc_td4","bus":44, "loc":0x44, "attr":"hwmon"}, + ], + }, + {"name":"ina3221", + "device":[ + {"id":"ina3221_1", "name":"rg_ina3221","bus":25, "loc":0x43, "attr":"hwmon"}, + ], + }, + {"name":"tps53622", + "device":[ + {"id":"tps53622_1", "name":"rg_tps53622","bus":25, "loc":0x60, "attr":"hwmon"}, + {"id":"tps53622_2", "name":"rg_tps53622","bus":25, "loc":0x6c, "attr":"hwmon"}, + ], + }, + {"name":"ucd90160", + "device":[ + {"id":"ucd90160_1", "name":"rg_ucd90160","bus":24, "loc":0x5b, "attr":"hwmon"}, + {"id":"ucd90160_2", "name":"rg_ucd90160","bus":45, "loc":0x5b, "attr":"hwmon"}, + ], + }, + {"name":"tmp411", + "device":[ + {"id":"tmp411_1", "name":"tmp411","bus":39, "loc":0x4c, "attr":"hwmon"}, + {"id":"tmp411_2", "name":"tmp411","bus":40, "loc":0x4c, "attr":"hwmon"}, + ], + }, + ], +} + +CPLDVERSIONS = [ ] +MANUINFO_CONF = { + "bios": { + "key": "BIOS", + "head": True, + "next": "bmc" + }, + "bios_vendor": { + "parent": "bios", + "key": "Vendor", + "cmd": "dmidecode -t 0 |grep Vendor", + "pattern": r".*Vendor", + "separator": ":", + "arrt_index" : 1, + }, + "bios_version": { + "parent": "bios", + "key": "Version", + "cmd": "dmidecode -t 0 |grep Version", + "pattern": r".*Version", + "separator": ":", + "arrt_index" : 2, + }, + "bios_date": { + "parent": "bios", + "key": "Release Date", + "cmd": "dmidecode -t 0 |grep Release", + "pattern": r".*Release Date", + "separator": ":", + "arrt_index" : 3, + }, + + "bmc": { + "key": "BMC", + "next": "onie" + }, + "bmc_version": { + "parent": "bmc", + "key": "Version", + "cmd": "ipmitool mc info |grep \"Firmware Revision\"", + "pattern": r".*Firmware Revision", + "separator": ":", + "arrt_index" : 1, + }, + + "onie": { + "key": "ONIE", + "next": "cpu" + }, + "onie_date": { + "parent": "onie", + "key": "Build Date", + "file": "/host/machine.conf", + "pattern": r"^onie_build_date", + "separator": "=", + "arrt_index" : 1, + }, + "onie_version": { + "parent": "onie", + "key": "Version", + "file": "/host/machine.conf", + "pattern": r"^onie_version", + "separator": "=", + "arrt_index" : 2, + }, + "onie_sub_version": { + "parent": "onie", + "key": "Sub Version", + "file": "/host/machine.conf", + "pattern": r"^onie_sub_version", + "separator": "=", + "arrt_index" : 3, + }, + + "cpu": { + "key": "CPU", + "next": "ssd" + }, + "cpu_vendor": { + "parent": "cpu", + "key": "Vendor", + "cmd": "dmidecode --type processor |grep Manufacturer", + "pattern": r".*Manufacturer", + "separator": ":", + "arrt_index" : 1, + }, + "cpu_model": { + "parent": "cpu", + "key": "Device Model", + "cmd": "dmidecode --type processor | grep Version", + "pattern": r".*Version", + "separator": ":", + "arrt_index" : 2, + }, + "cpu_core": { + "parent": "cpu", + "key": "Core Count", + "cmd": "dmidecode --type processor | grep \"Core Count\"", + "pattern": r".*Core Count", + "separator": ":", + "arrt_index" : 3, + }, + "cpu_thread": { + "parent": "cpu", + "key": "Thread Count", + "cmd": "dmidecode --type processor | grep \"Thread Count\"", + "pattern": r".*Thread Count", + "separator": ":", + "arrt_index" : 4, + }, + + "ssd": { + "key": "SSD", + "next": "cpld" + }, + "ssd_model": { + "parent": "ssd", + "key": "Device Model", + "cmd": "smartctl -i /dev/sda |grep \"Device Model\"", + "pattern": r".*Device Model", + "separator": ":", + "arrt_index" : 1, + }, + "ssd_fw": { + "parent": "ssd", + "key": "Firmware Version", + "cmd": "smartctl -i /dev/sda |grep \"Firmware Version\"", + "pattern": r".*Firmware Version", + "separator": ":", + "arrt_index" : 2, + }, + "ssd_user_cap": { + "parent": "ssd", + "key": "User Capacity", + "cmd": "smartctl -i /dev/sda |grep \"User Capacity\"", + "pattern": r".*User Capacity", + "separator": ":", + "arrt_index" : 3, + }, + + "cpld": { + "key": "CPLD", + "next": "psu" + }, + + "cpld1": { + "key": "CPLD1", + "parent": "cpld", + "arrt_index" : 1, + }, + "cpld1_model": { + "key": "Device Model", + "parent": "cpld1", + "config" : "LCMXO3LF-2100C-5BG256C", + "arrt_index" : 1, + }, + "cpld1_vender": { + "key": "Vendor", + "parent": "cpld1", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld1_desc": { + "key": "Description", + "parent": "cpld1", + "config" : "CPU_CPLD", + "arrt_index" : 3, + }, + "cpld1_version": { + "key": "Firmware Version", + "parent": "cpld1", + "reg": { + "loc": "/dev/port", + "offset": 0x700, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld2": { + "key": "CPLD2", + "parent": "cpld", + "arrt_index" : 2, + }, + "cpld2_model": { + "key": "Device Model", + "parent": "cpld2", + "config" : "LCMXO3LF-2100C-5BG256C", + "arrt_index" : 1, + }, + "cpld2_vender": { + "key": "Vendor", + "parent": "cpld2", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld2_desc": { + "key": "Description", + "parent": "cpld2", + "config" : "BASE_CPLD", + "arrt_index" : 3, + }, + "cpld2_version": { + "key": "Firmware Version", + "parent": "cpld2", + "reg": { + "loc": "/dev/port", + "offset": 0x900, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld3": { + "key": "CPLD3", + "parent": "cpld", + "arrt_index" : 3, + }, + "cpld3_model": { + "key": "Device Model", + "parent": "cpld3", + "config" : "LCMXO3LF-2100C-5BG256C", + "arrt_index" : 1, + }, + "cpld3_vender": { + "key": "Vendor", + "parent": "cpld3", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld3_desc": { + "key": "Description", + "parent": "cpld3", + "config" : "MAC_CPLDA", + "arrt_index" : 3, + }, + "cpld3_version": { + "key": "Firmware Version", + "parent": "cpld3", + "i2c": { + "bus": "2", + "loc": "0x1d", + "offset": 0, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld4": { + "key": "CPLD4", + "parent": "cpld", + "arrt_index" : 4, + }, + "cpld4_model": { + "key": "Device Model", + "parent": "cpld4", + "config" : "LCMXO3LF-2100C-5BG256C", + "arrt_index" : 1, + }, + "cpld4_vender": { + "key": "Vendor", + "parent": "cpld4", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld4_desc": { + "key": "Description", + "parent": "cpld4", + "config" : "MAC_CPLDB", + "arrt_index" : 3, + }, + "cpld4_version": { + "key": "Firmware Version", + "parent": "cpld4", + "i2c": { + "bus": "2", + "loc": "0x2d", + "offset": 0, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld5": { + "key": "CPLD5", + "parent": "cpld", + "arrt_index" : 5, + }, + "cpld5_model": { + "key": "Device Model", + "parent": "cpld5", + "config" : "LCMXO3LF-2100C-5BG256C", + "arrt_index" : 1, + }, + "cpld5_vender": { + "key": "Vendor", + "parent": "cpld5", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld5_desc": { + "key": "Description", + "parent": "cpld5", + "config" : "FAN_CPLD", + "arrt_index" : 3, + }, + "cpld5_version": { + "key": "Firmware Version", + "parent": "cpld5", + "i2c": { + "bus": "4", + "loc": "0x3d", + "offset": 0, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "psu": { + "key": "PSU", + "next": "fan" + }, + + "psu1": { + "parent": "psu", + "key": "PSU1", + "arrt_index" : 1, + }, + "psu1_hw_version": { + "key": "Hardware Version", + "parent": "psu1", + "extra": { + "funcname": "getPsu", + "id": "psu1", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "psu1_fw_version": { + "key": "Firmware Version", + "parent": "psu1", + "config" : "NA", + "arrt_index" : 2, + }, + + "psu2": { + "parent": "psu", + "key": "PSU2", + "arrt_index" : 2, + }, + "psu2_hw_version": { + "key": "Hardware Version", + "parent": "psu2", + "extra": { + "funcname": "getPsu", + "id": "psu2", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "psu2_fw_version": { + "key": "Firmware Version", + "parent": "psu2", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan": { + "key": "FAN", + "next": "i210" + }, + + "fan1": { + "key": "FAN1", + "parent": "fan", + "arrt_index" : 1, + }, + "fan1_hw_version": { + "key": "Hardware Version", + "parent": "fan1", + "extra": { + "funcname": "checkFan", + "id": "fan1", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan1_fw_version": { + "key": "Firmware Version", + "parent": "fan1", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan2": { + "key": "FAN2", + "parent": "fan", + "arrt_index" : 2, + }, + "fan2_hw_version": { + "key": "Hardware Version", + "parent": "fan2", + "extra": { + "funcname": "checkFan", + "id": "fan2", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan2_fw_version": { + "key": "Firmware Version", + "parent": "fan2", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan3": { + "key": "FAN3", + "parent": "fan", + "arrt_index" : 3, + }, + "fan3_hw_version": { + "key": "Hardware Version", + "parent": "fan3", + "extra": { + "funcname": "checkFan", + "id": "fan3", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan3_fw_version": { + "key": "Firmware Version", + "parent": "fan3", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan4": { + "key": "FAN4", + "parent": "fan", + "arrt_index" : 4, + }, + "fan4_hw_version": { + "key": "Hardware Version", + "parent": "fan4", + "extra": { + "funcname": "checkFan", + "id": "fan4", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan4_fw_version": { + "key": "Firmware Version", + "parent": "fan4", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan5": { + "key": "FAN5", + "parent": "fan", + "arrt_index" : 5, + }, + "fan5_hw_version": { + "key": "Hardware Version", + "parent": "fan5", + "extra": { + "funcname": "checkFan", + "id": "fan5", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan5_fw_version": { + "key": "Firmware Version", + "parent": "fan5", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan6": { + "key": "FAN6", + "parent": "fan", + "arrt_index" : 6, + }, + "fan6_hw_version": { + "key": "Hardware Version", + "parent": "fan6", + "extra": { + "funcname": "checkFan", + "id": "fan6", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan6_fw_version": { + "key": "Firmware Version", + "parent": "fan6", + "config" : "NA", + "arrt_index" : 2, + }, + + "i210": { + "key": "NIC", + "next": "fpga" + }, + "i210_model": { + "parent": "i210", + "config": "NA", + "key": "Device Model", + "arrt_index" : 1, + }, + "i210_vendor": { + "parent": "i210", + "config": "INTEL", + "key": "Vendor", + "arrt_index" : 2, + }, + "i210_version": { + "parent": "i210", + "cmd": "ethtool -i eth0", + "pattern": r"firmware-version", + "separator": ":", + "key": "Firmware Version", + "arrt_index" : 3, + }, + + "fpga": { + "key": "FPGA", + "next": "others" + }, + "fpga_model": { + "parent": "fpga", + "devfile": { + "loc": "/dev/fpga0", + "offset":0xd8, + "len":4, + "bit_width":4 + }, + "decode": { + "0x00000000": "XC7A100T-2FGG484C", + "0x00000200": "XC7A200T-2FBG484I" + }, + "key": "Device Model", + "arrt_index" : 1, + }, + "fpga_vendor": { + "parent": "fpga", + "config" : "XILINX", + "key": "Vendor", + "arrt_index" : 2, + }, + "fpga_desc": { + "parent": "fpga", + "config" : "NA", + "key": "Description", + "arrt_index" : 3, + }, + "fpga_hw_version": { + "parent": "fpga", + "config" : "NA", + "key": "Hardware Version", + "arrt_index" : 4, + }, + "fpga_fw_version": { + "parent": "fpga", + "pci": { + "bus" : 8, + "slot" : 0, + "fn" : 0, + "bar" : 0, + "offset" : 0 + }, + "key": "Firmware Version", + "arrt_index" : 5, + }, + + "others": { + "key": "OTHERS", + }, + "5387": { + "parent": "others", + "key": "CPU-BMC-SWITCH", + "arrt_index" : 1, + }, + "5387_model": { + "parent": "5387", + "config": "BCM53134O", + "key": "Device Model", + "arrt_index" : 1, + }, + "5387_vendor": { + "parent": "5387", + "config": "Broadcom", + "key": "Vendor", + "arrt_index" : 2, + }, + "5387_hw_version": { + "parent": "5387", + "key": "Hardware Version", + "func": { + "funcname": "get_bcm5387_version", + "params" : { + "before": [ + {"dealtype": "io_wr", "io_addr": 0x94d, "value":0xfe}, + ], + "get_version" : "md5sum /sys/bus/spi/devices/spi0.0/eeprom | awk '{print $1}'", + "finally": [ + {"dealtype": "io_wr", "io_addr": 0x94d, "value":0xff}, + ], + }, + }, + "arrt_index" : 3, + }, +} + +MAC_AVS_PARAM ={ + 0x72:0.90000, + 0x73:0.89375, + 0x74:0.88750, + 0x75:0.88125, + 0x76:0.87500, + 0x77:0.86875, + 0x78:0.86250, + 0x79:0.85625, + 0x7a:0.85000, + 0x7b:0.84375, + 0x7c:0.83750, + 0x7d:0.83125, + 0x7e:0.82500, + 0x7f:0.81875, + 0x80:0.81250, + 0x81:0.80625, + 0x82:0.80000, + 0x83:0.79375, + 0x84:0.78750, + 0x85:0.78125, + 0x86:0.77500, + 0x87:0.76875, + 0x88:0.76250, + 0x89:0.75625, + 0x8A:0.75000, + 0x8B:0.74375, + 0x8C:0.73750, + 0x8D:0.73125, + 0x8E:0.72500, +} + +AVS_VOUT_MODE_PARAM ={ + 0x18:256, # 2^8 + 0x17:512, # 2^9 + 0x16:1024, # 2^10 + 0x15:2048, # 2^11 + 0x14:4096, # 2^12 +} + +MAC_DEFAULT_PARAM = { + "type": 1, + "default":0x82, + "bus":43, + "devno":0x5b, + "loopaddr":0xff, + "loop":0x06, + "vout_cmd_addr":0x42, + "vout_mode_addr":0x40, + "sdktype": 0, + "macregloc":24 , + "mask": 0xff, + "rov_source":0, + "cpld_avs":{"bus":2, "loc":0x2d, "offset":0x3f, "gettype":"i2c"}, + "set_avs": {"loc": "/sys/bus/i2c/devices/43-005b/avs_vout", "gettype": "sysfs", "formula": "int((%f)*1000000)"}, +} + +## +DRIVERLISTS = [ + {"name": "rg_gpio_d1500", "delay": 0}, + {"name": "i2c_dev", "delay": 0}, + {"name": "i2c_gpio", "delay":0}, + {"name": "i2c_mux", "delay":0}, + {"name": "rg_fpga_pcie", "delay": 0}, + {"name": "rg_pcie_dev", "delay": 0}, + {"name": "rg_lpc_drv", "delay": 0}, + {"name": "rg_io_dev", "delay": 0}, + {"name": "rg_i2c_dev", "delay": 0}, + {"name": "rg_fpga_i2c_bus_drv", "delay": 0}, + {"name": "rg_fpga_pca954x_drv", "delay": 0}, + {"name": "rg_wdt", "delay": 0}, + {"name": "rg_gpio_device", "delay": 0}, + {"name": "rg_i2c_gpio_device", "delay":0}, + {"name": "rg_pcie_dev_device", "delay": 0}, + {"name": "rg_lpc_drv_device", "delay": 0}, + {"name": "rg_io_dev_device", "delay": 0}, + {"name": "rg_fpga_i2c_bus_device", "delay": 0}, + {"name": "rg_fpga_pca954x_device", "delay": 0}, + {"name": "rg_i2c_dev_device", "delay": 0}, + {"name": "rg_wdt_device", "delay": 0}, + {"name": "ruijie_common dfd_my_type_i2c_bus=1 dfd_my_type_i2c_addr=0x56", "delay": 1}, + {"name": "rg_spi_gpio_device", "delay": 0}, + {"name": "rg_eeprom_93xx46", "delay": 0}, + {"name": "lm75", "delay":0}, + {"name": "tmp401", "delay":0}, + {"name": "rg_optoe", "delay": 0}, + {"name": "at24", "delay": 0}, + {"name": "rg_mac_bsc", "delay": 0}, + {"name": "rg_pmbus_core", "delay":0}, + {"name": "rg_csu550", "delay": 0}, + {"name": "rg_ina3221", "delay": 0}, + {"name": "rg_tps53622", "delay": 0}, + {"name": "rg_ucd9000", "delay": 0}, + {"name": "rg_xdpe132g5c", "delay": 0}, + {"name": "s3ip_sysfs", "delay": 0}, + {"name": "rg_switch_driver", "delay": 0}, + {"name": "syseeprom_device_driver", "delay": 0}, + {"name": "fan_device_driver", "delay": 0}, + {"name": "cpld_device_driver", "delay": 0}, + {"name": "sysled_device_driver", "delay": 0}, + {"name": "psu_device_driver", "delay": 0}, + {"name": "transceiver_device_driver", "delay": 0}, + {"name": "temp_sensor_device_driver", "delay": 0}, + {"name": "vol_sensor_device_driver", "delay": 0}, + {"name": "curr_sensor_device_driver", "delay": 0}, + {"name": "fpga_device_driver", "delay": 0}, + {"name": "watchdog_device_driver", "delay": 0}, + {"name": "rg_plat_dfd", "delay":0}, + {"name": "rg_plat_switch", "delay":0}, + {"name": "rg_plat_fan", "delay":0}, + {"name": "rg_plat_psu", "delay":0}, + {"name": "rg_plat_sff", "delay":0}, +] + +DEVICE = [ + {"name": "24c02","bus":1,"loc":0x56 }, + {"name": "rg_mac_bsc_td4","bus":44,"loc":0x44 }, + {"name": "24c64","bus":30,"loc":0x50 }, + {"name": "24c64","bus":31,"loc":0x50 }, + {"name": "24c64","bus":32,"loc":0x50 }, + {"name": "24c64","bus":33,"loc":0x50 }, + {"name": "24c64","bus":34,"loc":0x50 }, + {"name": "24c64","bus":35,"loc":0x50 }, + {"name": "24c02", "bus":41, "loc":0x50}, + {"name":"rg_fsp1200","bus":41, "loc":0x58 }, + {"name": "24c02", "bus":42, "loc": 0x50}, + {"name":"rg_fsp1200","bus":42, "loc":0x58 }, + {"name": "lm75", "bus": 36, "loc": 0x48}, + {"name": "lm75", "bus": 36, "loc": 0x49}, + {"name": "lm75", "bus": 39, "loc": 0x4b}, + {"name": "tmp411", "bus": 39, "loc": 0x4c}, + {"name": "tmp411", "bus": 40, "loc": 0x4c}, + {"name": "lm75", "bus": 40, "loc": 0x4e}, + {"name": "lm75", "bus": 40, "loc": 0x4f}, + # dcdc + {"name": "rg_ucd90160", "bus": 24, "loc": 0x5b}, + {"name": "rg_ucd90160", "bus": 45, "loc": 0x5b}, + {"name": "rg_ina3221", "bus": 25, "loc": 0x43}, + {"name": "rg_tps53622", "bus": 25, "loc": 0x60}, + {"name": "rg_tps53622", "bus": 25, "loc": 0x6c}, + # xdpe avs + {"name": "rg_xdpe132g5c", "bus": 43, "loc": 0x5b}, +] + +OPTOE = [ + {"name": "rg_optoe1", "startbus": 46, "endbus": 69}, + {"name": "rg_optoe3", "startbus": 70, "endbus": 77}, +] + +PMON_SYSLOG_STATUS = { + "polling_time": 3, + "sffs": { + "present": {"path": ["/sys/s3ip/transceiver/*/present"], "ABSENT":0}, + "nochangedmsgflag": 0, + "nochangedmsgtime": 60, + "noprintfirsttimeflag": 1, + "alias": { + "eth1": "Eth200GE1", + "eth2": "Eth200GE2", + "eth3": "Eth200GE3", + "eth4": "Eth200GE4", + "eth5": "Eth200GE5", + "eth6": "Eth200GE6", + "eth7": "Eth200GE7", + "eth8": "Eth200GE8", + "eth9": "Eth200GE9", + "eth10": "Eth200GE10", + "eth11": "Eth200GE11", + "eth12": "Eth200GE12", + "eth13": "Eth200GE13", + "eth14": "Eth200GE14", + "eth15": "Eth200GE15", + "eth16": "Eth200GE16", + "eth17": "Eth200GE17", + "eth18": "Eth200GE18", + "eth19": "Eth200GE19", + "eth20": "Eth200GE20", + "eth21": "Eth200GE21", + "eth22": "Eth200GE22", + "eth23": "Eth200GE23", + "eth24": "Eth200GE24", + "eth25": "Eth400GE25", + "eth26": "Eth400GE26", + "eth27": "Eth400GE27", + "eth28": "Eth400GE28", + "eth29": "Eth400GE29", + "eth30": "Eth400GE30", + "eth31": "Eth400GE31", + "eth32": "Eth400GE32", + } + }, + "fans": { + "present": {"path": ["/sys/s3ip/fan/*/status"], "ABSENT":0}, + "status": [ + {"path": "/sys/s3ip/fan/%s/status", 'okval': 1}, + ], + "nochangedmsgflag": 1, + "nochangedmsgtime": 60, + "noprintfirsttimeflag": 0 + }, + "psus": { + "present" : {"path": ["/sys/s3ip/psu/*/present"], "ABSENT":0}, + "status" : [ + {"path": "/sys/s3ip/psu/%s/out_status", "okval":1}, + ], + "nochangedmsgflag": 1, + "nochangedmsgtime": 60, + "noprintfirsttimeflag": 0 + }, + "temps": { + "temps_list":[ + {"name":"air_inlet_TL", "input_path":"/sys/bus/i2c/devices/40-004f/hwmon/*/temp1_input", "input_accuracy":1000, "warning":43, "critical":53}, + {"name":"air_outlet_L", "input_path":"/sys/bus/i2c/devices/36-0048/hwmon/*/temp1_input", "input_accuracy":1000, "warning":70, "critical":75}, + {"name":"CPU_TEMP", "input_path":"/sys/devices/platform/coretemp.0/hwmon/*/temp1_input", "input_accuracy":1000, "warning":100, "critical":102}, + {"name":"SWITCH_TEMP", "input_path":"/sys/bus/i2c/devices/44-0044/hwmon/*/temp1_input", "input_accuracy":1000, "warning":100, "critical":105}, + ], + "over_temps_polling_seconds": 60, + }, +} + +INIT_PARAM = [ ] +INIT_COMMAND = [ + "i2cset -f -y 2 0x2d 0x45 0xff", + "i2cset -f -y 2 0x2d 0x46 0xff", + "i2cset -f -y 2 0x2d 0x34 0xff", + "i2cset -f -y 2 0x2d 0x35 0xff", + "i2cset -f -y 2 0x1d 0x39 0xff", + "i2cset -f -y 2 0x1d 0x3a 0xff", + "i2cset -f -y 2 0x2d 0x3a 0xff", + "i2cset -f -y 2 0x1d 0x3b 0xff", +] + +INIT_PARAM_PRE = [ + {"loc":"43-005b/avs_vout_max","value": "900000"}, + {"loc":"43-005b/avs_vout_min","value": "725000"}, +] +INIT_COMMAND_PRE = [ ] diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/config/x86_64_tencent_tcs8400_r0_config.py b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/config/x86_64_tencent_tcs8400_r0_config.py new file mode 100755 index 000000000000..a1a0b17752d6 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/config/x86_64_tencent_tcs8400_r0_config.py @@ -0,0 +1,975 @@ +#!/usr/bin/python3 +from ruijiecommon import * + + +STARTMODULE = { + "xdpe_avscontrol":1, + "dev_monitor": 1, + "hal_fanctrl":1, + "hal_ledctrl":1, + "sff_temp_polling":1, + "rg_pmon_syslog":1, +} + +DEV_MONITOR_PARAM = { + "polling_time" : 10, + "psus": [ + {"name": "psu1", + "present": {"gettype": "i2c", "bus": 2, "loc": 0x1d, "offset": 0x34, "presentbit": 0, "okval": 0}, + "device": [ + {"id": "psu1pmbus", "name": "rg_fsp1200", "bus": 41, "loc": 0x58, "attr": "hwmon"}, + {"id": "psu1frue2", "name": "24c02", "bus": 41, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "psu2", + "present": {"gettype": "i2c", "bus": 2, "loc": 0x1d, "offset": 0x34, "presentbit": 4, "okval": 0}, + "device": [ + {"id": "psu2pmbus", "name": "rg_fsp1200", "bus": 42, "loc": 0x58, "attr": "hwmon"}, + {"id": "psu2frue2", "name": "24c02", "bus": 42, "loc": 0x50, "attr": "eeprom"}, + ], + }, + ], + "fans": [ + {"name": "fan1", + "present": {"gettype": "i2c", "bus": 4, "loc": 0x3d, "offset": 0x37, "presentbit": 5, "okval": 0}, + "device": [ + {"id": "fan1frue2", "name": "24c64", "bus": 35, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan2", + "present": {"gettype": "i2c", "bus": 4, "loc": 0x3d, "offset": 0x37, "presentbit": 4, "okval": 0}, + "device": [ + {"id": "fan2frue2", "name": "24c64", "bus": 34, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan3", + "present": {"gettype": "i2c", "bus": 4, "loc": 0x3d, "offset": 0x37, "presentbit": 3, "okval": 0}, + "device": [ + {"id": "fan3frue2", "name": "24c64", "bus": 33, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan4", + "present": {"gettype": "i2c", "bus": 4, "loc": 0x3d, "offset": 0x37, "presentbit": 2, "okval": 0}, + "device": [ + {"id": "fan4frue2", "name": "24c64", "bus": 32, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan5", + "present": {"gettype": "i2c", "bus": 4, "loc": 0x3d, "offset": 0x37, "presentbit": 1, "okval": 0}, + "device": [ + {"id": "fan5frue2", "name": "24c64", "bus": 31, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan6", + "present": {"gettype": "i2c", "bus": 4, "loc": 0x3d, "offset": 0x37, "presentbit": 0, "okval": 0}, + "device": [ + {"id": "fan6frue2", "name": "24c64", "bus": 30, "loc": 0x50, "attr": "eeprom"}, + ], + }, + ], + "others": [ + {"name":"eeprom", + "device":[ + {"id":"eeprom_1", "name":"24c02","bus":1, "loc":0x56, "attr":"eeprom"}, + ], + }, + {"name":"lm75", + "device":[ + {"id":"lm75_1", "name":"lm75","bus":36, "loc":0x48, "attr":"hwmon"}, + {"id":"lm75_2", "name":"lm75","bus":36, "loc":0x49, "attr":"hwmon"}, + {"id":"lm75_3", "name":"lm75","bus":39, "loc":0x4b, "attr":"hwmon"}, + {"id":"lm75_4", "name":"lm75","bus":40, "loc":0x4e, "attr":"hwmon"}, + {"id":"lm75_5", "name":"lm75","bus":40, "loc":0x4f, "attr":"hwmon"}, + ], + }, + {"name":"mac_bsc", + "device":[ + {"id":"mac_bsc_1", "name":"rg_mac_bsc_td4","bus":44, "loc":0x44, "attr":"hwmon"}, + ], + }, + {"name":"ina3221", + "device":[ + {"id":"ina3221_1", "name":"rg_ina3221","bus":25, "loc":0x43, "attr":"hwmon"}, + ], + }, + {"name":"tps53622", + "device":[ + {"id":"tps53622_1", "name":"rg_tps53622","bus":25, "loc":0x60, "attr":"hwmon"}, + {"id":"tps53622_2", "name":"rg_tps53622","bus":25, "loc":0x6c, "attr":"hwmon"}, + ], + }, + {"name":"ucd90160", + "device":[ + {"id":"ucd90160_1", "name":"rg_ucd90160","bus":24, "loc":0x5b, "attr":"hwmon"}, + {"id":"ucd90160_2", "name":"rg_ucd90160","bus":45, "loc":0x5b, "attr":"hwmon"}, + ], + }, + {"name":"tmp411", + "device":[ + {"id":"tmp411_1", "name":"tmp411","bus":39, "loc":0x4c, "attr":"hwmon"}, + {"id":"tmp411_2", "name":"tmp411","bus":40, "loc":0x4c, "attr":"hwmon"}, + ], + }, + ], +} + +CPLDVERSIONS = [ ] +MANUINFO_CONF = { + "bios": { + "key": "BIOS", + "head": True, + "next": "bmc" + }, + "bios_vendor": { + "parent": "bios", + "key": "Vendor", + "cmd": "dmidecode -t 0 |grep Vendor", + "pattern": r".*Vendor", + "separator": ":", + "arrt_index" : 1, + }, + "bios_version": { + "parent": "bios", + "key": "Version", + "cmd": "dmidecode -t 0 |grep Version", + "pattern": r".*Version", + "separator": ":", + "arrt_index" : 2, + }, + "bios_date": { + "parent": "bios", + "key": "Release Date", + "cmd": "dmidecode -t 0 |grep Release", + "pattern": r".*Release Date", + "separator": ":", + "arrt_index" : 3, + }, + + "bmc": { + "key": "BMC", + "next": "onie" + }, + "bmc_version": { + "parent": "bmc", + "key": "Version", + "cmd": "ipmitool mc info |grep \"Firmware Revision\"", + "pattern": r".*Firmware Revision", + "separator": ":", + "arrt_index" : 1, + }, + + "onie": { + "key": "ONIE", + "next": "cpu" + }, + "onie_date": { + "parent": "onie", + "key": "Build Date", + "file": "/host/machine.conf", + "pattern": r"^onie_build_date", + "separator": "=", + "arrt_index" : 1, + }, + "onie_version": { + "parent": "onie", + "key": "Version", + "file": "/host/machine.conf", + "pattern": r"^onie_version", + "separator": "=", + "arrt_index" : 2, + }, + "onie_sub_version": { + "parent": "onie", + "key": "Sub Version", + "file": "/host/machine.conf", + "pattern": r"^onie_sub_version", + "separator": "=", + "arrt_index" : 3, + }, + + "cpu": { + "key": "CPU", + "next": "ssd" + }, + "cpu_vendor": { + "parent": "cpu", + "key": "Vendor", + "cmd": "dmidecode --type processor |grep Manufacturer", + "pattern": r".*Manufacturer", + "separator": ":", + "arrt_index" : 1, + }, + "cpu_model": { + "parent": "cpu", + "key": "Device Model", + "cmd": "dmidecode --type processor | grep Version", + "pattern": r".*Version", + "separator": ":", + "arrt_index" : 2, + }, + "cpu_core": { + "parent": "cpu", + "key": "Core Count", + "cmd": "dmidecode --type processor | grep \"Core Count\"", + "pattern": r".*Core Count", + "separator": ":", + "arrt_index" : 3, + }, + "cpu_thread": { + "parent": "cpu", + "key": "Thread Count", + "cmd": "dmidecode --type processor | grep \"Thread Count\"", + "pattern": r".*Thread Count", + "separator": ":", + "arrt_index" : 4, + }, + + "ssd": { + "key": "SSD", + "next": "cpld" + }, + "ssd_model": { + "parent": "ssd", + "key": "Device Model", + "cmd": "smartctl -i /dev/sda |grep \"Device Model\"", + "pattern": r".*Device Model", + "separator": ":", + "arrt_index" : 1, + }, + "ssd_fw": { + "parent": "ssd", + "key": "Firmware Version", + "cmd": "smartctl -i /dev/sda |grep \"Firmware Version\"", + "pattern": r".*Firmware Version", + "separator": ":", + "arrt_index" : 2, + }, + "ssd_user_cap": { + "parent": "ssd", + "key": "User Capacity", + "cmd": "smartctl -i /dev/sda |grep \"User Capacity\"", + "pattern": r".*User Capacity", + "separator": ":", + "arrt_index" : 3, + }, + + "cpld": { + "key": "CPLD", + "next": "psu" + }, + + "cpld1": { + "key": "CPLD1", + "parent": "cpld", + "arrt_index" : 1, + }, + "cpld1_model": { + "key": "Device Model", + "parent": "cpld1", + "config" : "LCMXO3LF-2100C-5BG256C", + "arrt_index" : 1, + }, + "cpld1_vender": { + "key": "Vendor", + "parent": "cpld1", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld1_desc": { + "key": "Description", + "parent": "cpld1", + "config" : "CPU_CPLD", + "arrt_index" : 3, + }, + "cpld1_version": { + "key": "Firmware Version", + "parent": "cpld1", + "reg": { + "loc": "/dev/port", + "offset": 0x700, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld2": { + "key": "CPLD2", + "parent": "cpld", + "arrt_index" : 2, + }, + "cpld2_model": { + "key": "Device Model", + "parent": "cpld2", + "config" : "LCMXO3LF-2100C-5BG256C", + "arrt_index" : 1, + }, + "cpld2_vender": { + "key": "Vendor", + "parent": "cpld2", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld2_desc": { + "key": "Description", + "parent": "cpld2", + "config" : "BASE_CPLD", + "arrt_index" : 3, + }, + "cpld2_version": { + "key": "Firmware Version", + "parent": "cpld2", + "reg": { + "loc": "/dev/port", + "offset": 0x900, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld3": { + "key": "CPLD3", + "parent": "cpld", + "arrt_index" : 3, + }, + "cpld3_model": { + "key": "Device Model", + "parent": "cpld3", + "config" : "LCMXO3LF-2100C-5BG256C", + "arrt_index" : 1, + }, + "cpld3_vender": { + "key": "Vendor", + "parent": "cpld3", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld3_desc": { + "key": "Description", + "parent": "cpld3", + "config" : "MAC_CPLDA", + "arrt_index" : 3, + }, + "cpld3_version": { + "key": "Firmware Version", + "parent": "cpld3", + "i2c": { + "bus": "2", + "loc": "0x1d", + "offset": 0, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld4": { + "key": "CPLD4", + "parent": "cpld", + "arrt_index" : 4, + }, + "cpld4_model": { + "key": "Device Model", + "parent": "cpld4", + "config" : "LCMXO3LF-2100C-5BG256C", + "arrt_index" : 1, + }, + "cpld4_vender": { + "key": "Vendor", + "parent": "cpld4", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld4_desc": { + "key": "Description", + "parent": "cpld4", + "config" : "MAC_CPLDB", + "arrt_index" : 3, + }, + "cpld4_version": { + "key": "Firmware Version", + "parent": "cpld4", + "i2c": { + "bus": "2", + "loc": "0x2d", + "offset": 0, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld5": { + "key": "CPLD5", + "parent": "cpld", + "arrt_index" : 5, + }, + "cpld5_model": { + "key": "Device Model", + "parent": "cpld5", + "config" : "LCMXO3LF-2100C-5BG256C", + "arrt_index" : 1, + }, + "cpld5_vender": { + "key": "Vendor", + "parent": "cpld5", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld5_desc": { + "key": "Description", + "parent": "cpld5", + "config" : "FAN_CPLD", + "arrt_index" : 3, + }, + "cpld5_version": { + "key": "Firmware Version", + "parent": "cpld5", + "i2c": { + "bus": "4", + "loc": "0x3d", + "offset": 0, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "psu": { + "key": "PSU", + "next": "fan" + }, + + "psu1": { + "parent": "psu", + "key": "PSU1", + "arrt_index" : 1, + }, + "psu1_hw_version": { + "key": "Hardware Version", + "parent": "psu1", + "extra": { + "funcname": "getPsu", + "id": "psu1", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "psu1_fw_version": { + "key": "Firmware Version", + "parent": "psu1", + "config" : "NA", + "arrt_index" : 2, + }, + + "psu2": { + "parent": "psu", + "key": "PSU2", + "arrt_index" : 2, + }, + "psu2_hw_version": { + "key": "Hardware Version", + "parent": "psu2", + "extra": { + "funcname": "getPsu", + "id": "psu2", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "psu2_fw_version": { + "key": "Firmware Version", + "parent": "psu2", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan": { + "key": "FAN", + "next": "i210" + }, + + "fan1": { + "key": "FAN1", + "parent": "fan", + "arrt_index" : 1, + }, + "fan1_hw_version": { + "key": "Hardware Version", + "parent": "fan1", + "extra": { + "funcname": "checkFan", + "id": "fan1", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan1_fw_version": { + "key": "Firmware Version", + "parent": "fan1", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan2": { + "key": "FAN2", + "parent": "fan", + "arrt_index" : 2, + }, + "fan2_hw_version": { + "key": "Hardware Version", + "parent": "fan2", + "extra": { + "funcname": "checkFan", + "id": "fan2", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan2_fw_version": { + "key": "Firmware Version", + "parent": "fan2", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan3": { + "key": "FAN3", + "parent": "fan", + "arrt_index" : 3, + }, + "fan3_hw_version": { + "key": "Hardware Version", + "parent": "fan3", + "extra": { + "funcname": "checkFan", + "id": "fan3", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan3_fw_version": { + "key": "Firmware Version", + "parent": "fan3", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan4": { + "key": "FAN4", + "parent": "fan", + "arrt_index" : 4, + }, + "fan4_hw_version": { + "key": "Hardware Version", + "parent": "fan4", + "extra": { + "funcname": "checkFan", + "id": "fan4", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan4_fw_version": { + "key": "Firmware Version", + "parent": "fan4", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan5": { + "key": "FAN5", + "parent": "fan", + "arrt_index" : 5, + }, + "fan5_hw_version": { + "key": "Hardware Version", + "parent": "fan5", + "extra": { + "funcname": "checkFan", + "id": "fan5", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan5_fw_version": { + "key": "Firmware Version", + "parent": "fan5", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan6": { + "key": "FAN6", + "parent": "fan", + "arrt_index" : 6, + }, + "fan6_hw_version": { + "key": "Hardware Version", + "parent": "fan6", + "extra": { + "funcname": "checkFan", + "id": "fan6", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan6_fw_version": { + "key": "Firmware Version", + "parent": "fan6", + "config" : "NA", + "arrt_index" : 2, + }, + + "i210": { + "key": "NIC", + "next": "fpga" + }, + "i210_model": { + "parent": "i210", + "config": "NA", + "key": "Device Model", + "arrt_index" : 1, + }, + "i210_vendor": { + "parent": "i210", + "config": "INTEL", + "key": "Vendor", + "arrt_index" : 2, + }, + "i210_version": { + "parent": "i210", + "cmd": "ethtool -i eth0", + "pattern": r"firmware-version", + "separator": ":", + "key": "Firmware Version", + "arrt_index" : 3, + }, + + "fpga": { + "key": "FPGA", + "next": "others" + }, + "fpga_model": { + "parent": "fpga", + "devfile": { + "loc": "/dev/fpga0", + "offset":0xd8, + "len":4, + "bit_width":4 + }, + "decode": { + "0x00000000": "XC7A100T-2FGG484C", + "0x00000200": "XC7A200T-2FBG484I" + }, + "key": "Device Model", + "arrt_index" : 1, + }, + "fpga_vendor": { + "parent": "fpga", + "config" : "XILINX", + "key": "Vendor", + "arrt_index" : 2, + }, + "fpga_desc": { + "parent": "fpga", + "config" : "NA", + "key": "Description", + "arrt_index" : 3, + }, + "fpga_hw_version": { + "parent": "fpga", + "config" : "NA", + "key": "Hardware Version", + "arrt_index" : 4, + }, + "fpga_fw_version": { + "parent": "fpga", + "pci": { + "bus" : 8, + "slot" : 0, + "fn" : 0, + "bar" : 0, + "offset" : 0 + }, + "key": "Firmware Version", + "arrt_index" : 5, + }, + + "others": { + "key": "OTHERS", + }, + "5387": { + "parent": "others", + "key": "CPU-BMC-SWITCH", + "arrt_index" : 1, + }, + "5387_model": { + "parent": "5387", + "config": "BCM5387", + "key": "Device Model", + "arrt_index" : 1, + }, + "5387_vendor": { + "parent": "5387", + "config": "Broadcom", + "key": "Vendor", + "arrt_index" : 2, + }, + "5387_hw_version": { + "parent": "5387", + "key": "Hardware Version", + "func": { + "funcname": "get_bcm5387_version", + "params" : { + "before": [ + {"dealtype": "io_wr", "io_addr": 0x94d, "value":0xfe}, + ], + "get_version" : "md5sum /sys/bus/spi/devices/spi0.0/eeprom | awk '{print $1}'", + "finally": [ + {"dealtype": "io_wr", "io_addr": 0x94d, "value":0xff}, + ], + }, + }, + "arrt_index" : 3, + }, +} + +MAC_AVS_PARAM ={ + 0x72:0.90000, + 0x73:0.89375, + 0x74:0.88750, + 0x75:0.88125, + 0x76:0.87500, + 0x77:0.86875, + 0x78:0.86250, + 0x79:0.85625, + 0x7a:0.85000, + 0x7b:0.84375, + 0x7c:0.83750, + 0x7d:0.83125, + 0x7e:0.82500, + 0x7f:0.81875, + 0x80:0.81250, + 0x81:0.80625, + 0x82:0.80000, + 0x83:0.79375, + 0x84:0.78750, + 0x85:0.78125, + 0x86:0.77500, + 0x87:0.76875, + 0x88:0.76250, + 0x89:0.75625, + 0x8A:0.75000, + 0x8B:0.74375, + 0x8C:0.73750, + 0x8D:0.73125, + 0x8E:0.72500, +} + +AVS_VOUT_MODE_PARAM ={ + 0x18:256, # 2^8 + 0x17:512, # 2^9 + 0x16:1024, # 2^10 + 0x15:2048, # 2^11 + 0x14:4096, # 2^12 +} + +MAC_DEFAULT_PARAM = { + "type": 1, + "default":0x82, + "bus":43, + "devno":0x5b, + "loopaddr":0xff, + "loop":0x06, + "vout_cmd_addr":0x42, + "vout_mode_addr":0x40, + "sdktype": 0, + "macregloc":24 , + "mask": 0xff, + "rov_source":0, + "cpld_avs":{"bus":2, "loc":0x2d, "offset":0x3f, "gettype":"i2c"}, + "set_avs": {"loc": "/sys/bus/i2c/devices/43-005b/avs_vout", "gettype": "sysfs", "formula": "int((%f)*1000000)"}, +} + +## +DRIVERLISTS = [ + {"name": "rg_gpio_d1500", "delay": 0}, + {"name": "i2c_dev", "delay": 0}, + {"name": "i2c_gpio", "delay":0}, + {"name": "i2c_mux", "delay":0}, + {"name": "rg_fpga_pcie", "delay": 0}, + {"name": "rg_pcie_dev", "delay": 0}, + {"name": "rg_lpc_drv", "delay": 0}, + {"name": "rg_io_dev", "delay": 0}, + {"name": "rg_i2c_dev", "delay": 0}, + {"name": "rg_fpga_i2c_bus_drv", "delay": 0}, + {"name": "rg_fpga_pca954x_drv", "delay": 0}, + {"name": "rg_wdt", "delay": 0}, + {"name": "rg_gpio_device", "delay": 0}, + {"name": "rg_i2c_gpio_device", "delay":0}, + {"name": "rg_pcie_dev_device", "delay": 0}, + {"name": "rg_lpc_drv_device", "delay": 0}, + {"name": "rg_io_dev_device", "delay": 0}, + {"name": "rg_fpga_i2c_bus_device", "delay": 0}, + {"name": "rg_fpga_pca954x_device", "delay": 0}, + {"name": "rg_i2c_dev_device", "delay": 0}, + {"name": "rg_wdt_device", "delay": 0}, + {"name": "ruijie_common dfd_my_type_i2c_bus=1 dfd_my_type_i2c_addr=0x56", "delay": 1}, + {"name": "rg_spi_gpio_device", "delay": 0}, + {"name": "rg_eeprom_93xx46", "delay": 0}, + {"name": "lm75", "delay":0}, + {"name": "tmp401", "delay":0}, + {"name": "rg_optoe", "delay": 0}, + {"name": "at24", "delay": 0}, + {"name": "rg_mac_bsc", "delay": 0}, + {"name": "rg_pmbus_core", "delay":0}, + {"name": "rg_csu550", "delay": 0}, + {"name": "rg_ina3221", "delay": 0}, + {"name": "rg_tps53622", "delay": 0}, + {"name": "rg_ucd9000", "delay": 0}, + {"name": "rg_xdpe132g5c", "delay": 0}, + {"name": "s3ip_sysfs", "delay": 0}, + {"name": "rg_switch_driver", "delay": 0}, + {"name": "syseeprom_device_driver", "delay": 0}, + {"name": "fan_device_driver", "delay": 0}, + {"name": "cpld_device_driver", "delay": 0}, + {"name": "sysled_device_driver", "delay": 0}, + {"name": "psu_device_driver", "delay": 0}, + {"name": "transceiver_device_driver", "delay": 0}, + {"name": "temp_sensor_device_driver", "delay": 0}, + {"name": "vol_sensor_device_driver", "delay": 0}, + {"name": "curr_sensor_device_driver", "delay": 0}, + {"name": "fpga_device_driver", "delay": 0}, + {"name": "watchdog_device_driver", "delay": 0}, + {"name": "rg_plat_dfd", "delay":0}, + {"name": "rg_plat_switch", "delay":0}, + {"name": "rg_plat_fan", "delay":0}, + {"name": "rg_plat_psu", "delay":0}, + {"name": "rg_plat_sff", "delay":0}, +] + +DEVICE = [ + {"name": "24c02","bus":1,"loc":0x56 }, + {"name": "rg_mac_bsc_td4","bus":44,"loc":0x44 }, + {"name": "24c64","bus":30,"loc":0x50 }, + {"name": "24c64","bus":31,"loc":0x50 }, + {"name": "24c64","bus":32,"loc":0x50 }, + {"name": "24c64","bus":33,"loc":0x50 }, + {"name": "24c64","bus":34,"loc":0x50 }, + {"name": "24c64","bus":35,"loc":0x50 }, + {"name": "24c02", "bus":41, "loc":0x50}, + {"name":"rg_fsp1200","bus":41, "loc":0x58 }, + {"name": "24c02", "bus":42, "loc": 0x50}, + {"name":"rg_fsp1200","bus":42, "loc":0x58 }, + {"name": "lm75", "bus": 36, "loc": 0x48}, + {"name": "lm75", "bus": 36, "loc": 0x49}, + {"name": "lm75", "bus": 39, "loc": 0x4b}, + {"name": "tmp411", "bus": 39, "loc": 0x4c}, + {"name": "tmp411", "bus": 40, "loc": 0x4c}, + {"name": "lm75", "bus": 40, "loc": 0x4e}, + {"name": "lm75", "bus": 40, "loc": 0x4f}, + # dcdc + {"name": "rg_ucd90160", "bus": 24, "loc": 0x5b}, + {"name": "rg_ucd90160", "bus": 45, "loc": 0x5b}, + {"name": "rg_ina3221", "bus": 25, "loc": 0x43}, + {"name": "rg_tps53622", "bus": 25, "loc": 0x60}, + {"name": "rg_tps53622", "bus": 25, "loc": 0x6c}, + # xdpe avs + {"name": "rg_xdpe132g5c", "bus": 43, "loc": 0x5b}, +] + +OPTOE = [ + {"name": "rg_optoe1", "startbus": 46, "endbus": 69}, + {"name": "rg_optoe3", "startbus": 70, "endbus": 77}, +] + +PMON_SYSLOG_STATUS = { + "polling_time": 3, + "sffs": { + "present": {"path": ["/sys/s3ip/transceiver/*/present"], "ABSENT":0}, + "nochangedmsgflag": 0, + "nochangedmsgtime": 60, + "noprintfirsttimeflag": 1, + "alias": { + "eth1": "Eth200GE1", + "eth2": "Eth200GE2", + "eth3": "Eth200GE3", + "eth4": "Eth200GE4", + "eth5": "Eth200GE5", + "eth6": "Eth200GE6", + "eth7": "Eth200GE7", + "eth8": "Eth200GE8", + "eth9": "Eth200GE9", + "eth10": "Eth200GE10", + "eth11": "Eth200GE11", + "eth12": "Eth200GE12", + "eth13": "Eth200GE13", + "eth14": "Eth200GE14", + "eth15": "Eth200GE15", + "eth16": "Eth200GE16", + "eth17": "Eth200GE17", + "eth18": "Eth200GE18", + "eth19": "Eth200GE19", + "eth20": "Eth200GE20", + "eth21": "Eth200GE21", + "eth22": "Eth200GE22", + "eth23": "Eth200GE23", + "eth24": "Eth200GE24", + "eth25": "Eth400GE25", + "eth26": "Eth400GE26", + "eth27": "Eth400GE27", + "eth28": "Eth400GE28", + "eth29": "Eth400GE29", + "eth30": "Eth400GE30", + "eth31": "Eth400GE31", + "eth32": "Eth400GE32", + } + }, + "fans": { + "present": {"path": ["/sys/s3ip/fan/*/status"], "ABSENT":0}, + "status": [ + {"path": "/sys/s3ip/fan/%s/status", 'okval': 1}, + ], + "nochangedmsgflag": 1, + "nochangedmsgtime": 60, + "noprintfirsttimeflag": 0 + }, + "psus": { + "present" : {"path": ["/sys/s3ip/psu/*/present"], "ABSENT":0}, + "status" : [ + {"path": "/sys/s3ip/psu/%s/out_status", "okval":1}, + ], + "nochangedmsgflag": 1, + "nochangedmsgtime": 60, + "noprintfirsttimeflag": 0 + }, + "temps": { + "temps_list":[ + {"name":"air_inlet_TL", "input_path":"/sys/bus/i2c/devices/40-004f/hwmon/*/temp1_input", "input_accuracy":1000, "warning":43, "critical":53}, + {"name":"air_outlet_L", "input_path":"/sys/bus/i2c/devices/36-0048/hwmon/*/temp1_input", "input_accuracy":1000, "warning":70, "critical":75}, + {"name":"CPU_TEMP", "input_path":"/sys/devices/platform/coretemp.0/hwmon/*/temp1_input", "input_accuracy":1000, "warning":100, "critical":102}, + {"name":"SWITCH_TEMP", "input_path":"/sys/bus/i2c/devices/44-0044/hwmon/*/temp1_input", "input_accuracy":1000, "warning":100, "critical":105}, + ], + "over_temps_polling_seconds": 60, + }, +} + +INIT_PARAM = [ ] +INIT_COMMAND = [ + "i2cset -f -y 2 0x2d 0x45 0xff", + "i2cset -f -y 2 0x2d 0x46 0xff", + "i2cset -f -y 2 0x2d 0x34 0xff", + "i2cset -f -y 2 0x2d 0x35 0xff", + "i2cset -f -y 2 0x1d 0x39 0xff", + "i2cset -f -y 2 0x1d 0x3a 0xff", + "i2cset -f -y 2 0x2d 0x3a 0xff", + "i2cset -f -y 2 0x1d 0x3b 0xff", +] + +INIT_PARAM_PRE = [ + {"loc":"43-005b/avs_vout_max","value": "900000"}, + {"loc":"43-005b/avs_vout_min","value": "725000"}, +] +INIT_COMMAND_PRE = [ ] diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/config/x86_64_tencent_tcs8400_r0_port_config.py b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/config/x86_64_tencent_tcs8400_r0_port_config.py new file mode 100755 index 000000000000..e75633f5d701 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/config/x86_64_tencent_tcs8400_r0_port_config.py @@ -0,0 +1,6 @@ +#!/usr/bin/python3 + +PLATFORM_INTF_OPTOE = { + "port_num": 32, + "optoe_start_bus": 46, +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/hal-config/x86_64_tencent_tcs8400_r0_0x407b_device.py b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/hal-config/x86_64_tencent_tcs8400_r0_0x407b_device.py new file mode 100755 index 000000000000..76174fd8a9c7 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/hal-config/x86_64_tencent_tcs8400_r0_0x407b_device.py @@ -0,0 +1,1108 @@ +#!/usr/bin/python3 + +psu_fan_airflow = { + "F2B": ["DPS-1300AB-6 F", "GW-CRPS1300D"], + "B2F": ["DPS-1300AB-11 C", "CRPS1300D3R"] +} + +psu_display_name = { + "PSA1300CRPS-F": ["DPS-1300AB-6 F", "GW-CRPS1300D"], + "PSA1300CRPS-R": ["DPS-1300AB-11 C", "CRPS1300D3R"] +} + +fanairflow = { + "F2B": ["FAN24K4056-F", "FAN24K4056S-F"], + "B2F": ["FAN24K4056S-R"], +} + +fan_display_name = { + "FAN24K4056-F": ["FAN24K4056-F", "FAN24K4056S-F"], + "FAN24K4056-R": ["FAN24K4056S-R"] +} + +psutypedecode = { + 0x00: 'N/A', + 0x01: 'AC', + 0x02: 'DC', +} + + +class Unit: + Temperature = "C" + Voltage = "V" + Current = "A" + Power = "W" + Speed = "RPM" + + +PSU_NOT_PRESENT_PWM = 100 + + +class threshold: + PSU_TEMP_MIN = -10 * 1000 + PSU_TEMP_MAX = 60 * 1000 + + PSU_FAN_SPEED_MIN = 2000 + PSU_FAN_SPEED_MAX = 28000 + + PSU_OUTPUT_VOLTAGE_MIN = 11 * 1000 + PSU_OUTPUT_VOLTAGE_MAX = 14 * 1000 + + PSU_AC_INPUT_VOLTAGE_MIN = 200 * 1000 + PSU_AC_INPUT_VOLTAGE_MAX = 240 * 1000 + + PSU_DC_INPUT_VOLTAGE_MIN = 190 * 1000 + PSU_DC_INPUT_VOLTAGE_MAX = 290 * 1000 + + ERR_VALUE = -9999999 + + PSU_OUTPUT_POWER_MIN = 10 * 1000 * 1000 + PSU_OUTPUT_POWER_MAX = 1300 * 1000 * 1000 + + PSU_INPUT_POWER_MIN = 10 * 1000 * 1000 + PSU_INPUT_POWER_MAX = 1444 * 1000 * 1000 + + PSU_OUTPUT_CURRENT_MIN = 2 * 1000 + PSU_OUTPUT_CURRENT_MAX = 107 * 1000 + + PSU_INPUT_CURRENT_MIN = 0.2 * 1000 + PSU_INPUT_CURRENT_MAX = 7 * 1000 + + FRONT_FAN_SPEED_MAX = 25000 + REAR_FAN_SPEED_MAX = 22000 + FAN_SPEED_MIN = 2000 + + +class Description: + CPLD = "Used for managing IO modules, SFP+ modules and system LEDs" + BIOS = "Performs initialization of hardware components during booting" + FPGA = "Platform management controller for on-board temperature monitoring, in-chassis power" + + +devices = { + "onie_e2": [ + { + "name": "ONIE_E2", + "e2loc": {"loc": "/sys/bus/i2c/devices/1-0056/eeprom", "way": "sysfs"}, + }, + ], + "psus": [ + { + "e2loc": {"loc": "/sys/bus/i2c/devices/41-0050/eeprom", "way": "sysfs"}, + "pmbusloc": {"bus": 41, "addr": 0x58, "way": "i2c"}, + "present": {"loc": "/sys/rg_plat/psu/psu1/present", "way": "sysfs", "mask": 0x01, "okval": 1}, + "name": "PSU1", + "psu_display_name": psu_display_name, + "airflow": psu_fan_airflow, + "psu_not_present_pwm": PSU_NOT_PRESENT_PWM, + "TempStatus": {"bus": 41, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0004}, + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": threshold.PSU_TEMP_MIN, + "Max": threshold.PSU_TEMP_MAX, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + }, + "FanStatus": {"bus": 41, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0400}, + "FanSpeed": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/fan1_input", "way": "sysfs"}, + "Min": threshold.PSU_FAN_SPEED_MIN, + "Max": threshold.PSU_FAN_SPEED_MAX, + "Unit": Unit.Speed + }, + "InputsStatus": {"bus": 41, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x2000}, + "InputsType": {"bus": 41, "addr": 0x58, "offset": 0x80, "way": "i2c", 'psutypedecode': psutypedecode}, + "InputsVoltage": { + 'AC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_AC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_AC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + + }, + 'DC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_DC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_DC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + 'other': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.ERR_VALUE, + "Max": threshold.ERR_VALUE, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + } + }, + "InputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/curr1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_CURRENT_MIN, + "Max": threshold.PSU_INPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "InputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/power1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_POWER_MIN, + "Max": threshold.PSU_INPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + "OutputsStatus": {"bus": 41, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x8800}, + "OutputsVoltage": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/in2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_VOLTAGE_MIN, + "Max": threshold.PSU_OUTPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + "OutputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/curr2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_CURRENT_MIN, + "Max": threshold.PSU_OUTPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "OutputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/power2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_POWER_MIN, + "Max": threshold.PSU_OUTPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + }, + { + "e2loc": {"loc": "/sys/bus/i2c/devices/42-0050/eeprom", "way": "sysfs"}, + "pmbusloc": {"bus": 42, "addr": 0x58, "way": "i2c"}, + "present": {"loc": "/sys/rg_plat/psu/psu2/present", "way": "sysfs", "mask": 0x01, "okval": 1}, + "name": "PSU2", + "psu_display_name": psu_display_name, + "airflow": psu_fan_airflow, + "psu_not_present_pwm": PSU_NOT_PRESENT_PWM, + "TempStatus": {"bus": 42, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0004}, + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": threshold.PSU_TEMP_MIN, + "Max": threshold.PSU_TEMP_MAX, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + }, + "FanStatus": {"bus": 42, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0400}, + "FanSpeed": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/fan1_input", "way": "sysfs"}, + "Min": threshold.PSU_FAN_SPEED_MIN, + "Max": threshold.PSU_FAN_SPEED_MAX, + "Unit": Unit.Speed + }, + "InputsStatus": {"bus": 42, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x2000}, + "InputsType": {"bus": 42, "addr": 0x58, "offset": 0x80, "way": "i2c", 'psutypedecode': psutypedecode}, + "InputsVoltage": { + 'AC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_AC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_AC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + + }, + 'DC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_DC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_DC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + 'other': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.ERR_VALUE, + "Max": threshold.ERR_VALUE, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + } + }, + "InputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/curr1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_CURRENT_MIN, + "Max": threshold.PSU_INPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "InputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/power1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_POWER_MIN, + "Max": threshold.PSU_INPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + "OutputsStatus": {"bus": 42, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x8800}, + "OutputsVoltage": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/in2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_VOLTAGE_MIN, + "Max": threshold.PSU_OUTPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + "OutputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/curr2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_CURRENT_MIN, + "Max": threshold.PSU_OUTPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "OutputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/power2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_POWER_MIN, + "Max": threshold.PSU_OUTPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + } + ], + "temps": [ + { + "name": "BOARD_TEMP", + "temp_id": "TEMP1", + "api_name": "Board", + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/40-004e/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": -10000, + "Low": 0, + "High": 70000, + "Max": 80000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + { + "name": "CPU_TEMP", + "temp_id": "TEMP2", + "api_name": "CPU", + "Temperature": { + "value": {"loc": "/sys/bus/platform/devices/coretemp.0/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": 2000, + "Low": 10000, + "High": 100000, + "Max": 104000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + { + "name": "INLET_TEMP", + "temp_id": "TEMP3", + "api_name": "Inlet", + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/40-004f/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": -10000, + "Low": 0, + "High": 40000, + "Max": 50000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + { + "name": "OUTLET_TEMP", + "temp_id": "TEMP4", + "api_name": "Outlet", + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/36-0048/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": -10000, + "Low": 0, + "High": 70000, + "Max": 80000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + { + "name": "SWITCH_TEMP", + "temp_id": "TEMP5", + "api_name": "Switch ASIC", + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/44-0044/hwmon/hwmon*/temp99_input", "way": "sysfs"}, + "Min": 2000, + "Low": 10000, + "High": 100000, + "Max": 105000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + { + "name": "SFF_TEMP", + "Temperature": { + "value": {"loc": "/tmp/highest_sff_temp", "way": "sysfs", "flock_path": "/tmp/highest_sff_temp"}, + "Min": -15000, + "Low": 0, + "High": 80000, + "Max": 100000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + ], + "leds": [ + { + "name": "FRONT_SYS_LED", + "led_type": "SYS_LED", + "led": {"bus": 2, "addr": 0x2d, "offset": 0x40, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + }, + { + "name": "FRONT_PSU_LED", + "led_type": "PSU_LED", + "led": {"bus": 2, "addr": 0x2d, "offset": 0x43, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + }, + { + "name": "FRONT_FAN_LED", + "led_type": "FAN_LED", + "led": {"bus": 2, "addr": 0x2d, "offset": 0x42, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + }, + ], + "fans": [ + { + "name": "FAN1", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-35/35-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"bus": 4, "addr": 0x3d, "offset": 0x37, "way": "i2c", "mask": 0x20}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 4, "addr": 0x3d, "offset": 0x41, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x65, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x20, "is_runing": 0x20}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x20, "no_alarm": 0x20}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan1/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x65, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x20, "is_runing": 0x20}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x20, "no_alarm": 0x20}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan1/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN2", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-34/34-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"bus": 4, "addr": 0x3d, "offset": 0x37, "way": "i2c", "mask": 0x10}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 4, "addr": 0x3d, "offset": 0x40, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x64, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x10, "is_runing": 0x10}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x10, "no_alarm": 0x10}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan2/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x64, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x10, "is_runing": 0x10}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x10, "no_alarm": 0x10}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan2/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN3", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-33/33-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"bus": 4, "addr": 0x3d, "offset": 0x37, "way": "i2c", "mask": 0x08}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 4, "addr": 0x3d, "offset": 0x3f, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x63, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x08, "is_runing": 0x08}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x08, "no_alarm": 0x08}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan3/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x63, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x08, "is_runing": 0x08}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x08, "no_alarm": 0x08}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan3/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN4", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-32/32-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"bus": 4, "addr": 0x3d, "offset": 0x37, "way": "i2c", "mask": 0x04}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 4, "addr": 0x3d, "offset": 0x3e, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x62, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x04, "is_runing": 0x04}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x04, "no_alarm": 0x04}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan4/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x62, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x04, "is_runing": 0x04}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x04, "no_alarm": 0x04}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan4/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN5", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-31/31-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"bus": 4, "addr": 0x3d, "offset": 0x37, "way": "i2c", "mask": 0x02}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 4, "addr": 0x3d, "offset": 0x3d, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x61, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x02, "is_runing": 0x02}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x02, "no_alarm": 0x02}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan5/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x61, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x02, "is_runing": 0x02}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x02, "no_alarm": 0x02}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan5/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN6", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-30/30-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"bus": 4, "addr": 0x3d, "offset": 0x37, "way": "i2c", "mask": 0x01}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 4, "addr": 0x3d, "offset": 0x3c, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x60, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x01, "is_runing": 0x01}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x01, "no_alarm": 0x01}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan6/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x60, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x01, "is_runing": 0x01}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x01, "no_alarm": 0x01}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan6/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + ], + "cplds": [ + { + "name": "CPU_CPLD", + "cpld_id": "CPLD1", + "VersionFile": {"loc": "/dev/cpld0", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for system power", + "slot": 0, + }, + { + "name": "BASE_CPLD", + "cpld_id": "CPLD2", + "VersionFile": {"loc": "/dev/cpld1", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for base functions", + "slot": 0, + }, + { + "name": "MAC_CPLDA", + "cpld_id": "CPLD3", + "VersionFile": {"loc": "/dev/cpld4", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for sff modules", + "slot": 0, + }, + { + "name": "MAC_CPLDB", + "cpld_id": "CPLD4", + "VersionFile": {"loc": "/dev/cpld5", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for sff modules", + "slot": 0, + }, + { + "name": "FAN_CPLD", + "cpld_id": "CPLD5", + "VersionFile": {"loc": "/dev/cpld6", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for fan modules", + "slot": 0, + }, + { + "name": "FPGA", + "cpld_id": "CPLD6", + "VersionFile": {"loc": "/dev/fpga0", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for base functions", + "slot": 0, + "format": "little_endian", + }, + ], + "dcdc": [ + { + "name": "VDD5V_CLK_MCU", + "dcdc_id": "DCDC1", + "Min": 4840, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in1_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 5345, + "format": "float(float(%s)/1000)", + }, + { + "name": "VDD3.3_CLK", + "dcdc_id": "DCDC2", + "Min": 3220, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in2_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3560, + "format": "float(float(%s)/1000)", + }, + { + "name": "VDD1.0V", + "dcdc_id": "DCDC3", + "Min": 950, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1049, + "format": "float(float(%s)/1000)", + }, + { + "name": "VDD1.8V", + "dcdc_id": "DCDC4", + "Min": 1720, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1903, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_BOARD_VDD3.3V", + "dcdc_id": "DCDC5", + "Min": 3170, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in5_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3499, + "format": "float(float(%s)/1000)", + }, + { + "name": "VDD1.2V", + "dcdc_id": "DCDC6", + "Min": 1150, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in6_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1272, + "format": "float(float(%s)/1000)", + }, + { + "name": "VDD_CORE", + "dcdc_id": "DCDC7", + "Min": 670, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in7_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 950, + "format": "float(float(%s)/1000)", + }, + { + "name": "ANALOG0.75V", + "dcdc_id": "DCDC8", + "Min": 700, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in8_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 800, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD1.2V", + "dcdc_id": "DCDC9", + "Min": 1140, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in9_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1259, + "format": "float(float(%s)/1000)", + }, + { + "name": "VDDO1.8V", + "dcdc_id": "DCDC10", + "Min": 1750, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in10_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1937, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_ANA1.2V", + "dcdc_id": "DCDC11", + "Min": 1150, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in11_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1276, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_ANA1.8V", + "dcdc_id": "DCDC12", + "Min": 1730, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in12_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1910, + "format": "float(float(%s)/1000)", + }, + { + "name": "QSFP56_VDD3.3V_A", + "dcdc_id": "DCDC13", + "Min": 3250, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in13_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3595, + "format": "float(float(%s)/1000)", + }, + { + "name": "QSFP56_VDD3.3V_B", + "dcdc_id": "DCDC14", + "Min": 3260, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in14_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3601, + "format": "float(float(%s)/1000)", + }, + { + "name": "QSFPDD_VDD3.3V_A", + "dcdc_id": "DCDC15", + "Min": 3230, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in15_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3565, + "format": "float(float(%s)/1000)", + }, + { + "name": "QSFPDD_VDD3.3V_B", + "dcdc_id": "DCDC16", + "Min": 3220, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in16_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3564, + "format": "float(float(%s)/1000)", + }, + { + "name": "VDD5.0V", + "dcdc_id": "DCDC17", + "Min": 4910, + "value": { + "loc": "/sys/bus/i2c/devices/24-005b/hwmon/hwmon*/in1_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 5429, + "format": "float(float(%s)/1000)", + }, + { + "name": "CONNECT_BOARD_VDD3.3V", + "dcdc_id": "DCDC18", + "Min": 3110, + "value": { + "loc": "/sys/bus/i2c/devices/24-005b/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3437, + "format": "float(float(%s)/1000)", + }, + { + "name": "VDD12V", + "dcdc_id": "DCDC19", + "Min": 11300, + "value": { + "loc": "/sys/bus/i2c/devices/24-005b/hwmon/hwmon*/in6_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 12700, + "format": "float(float(%s)/1000)", + }, + { + "name": "VDD3.3_STBY", + "dcdc_id": "DCDC20", + "Min": 3160, + "value": { + "loc": "/sys/bus/i2c/devices/24-005b/hwmon/hwmon*/in7_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3489, + "format": "float(float(%s)/1000)", + }, + { + "name": "SSD_VDD3.3V", + "dcdc_id": "DCDC21", + "Min": 3140, + "value": { + "loc": "/sys/bus/i2c/devices/24-005b/hwmon/hwmon*/in8_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3475, + "format": "float(float(%s)/1000)", + }, + { + "name": "PHY_VDD1V0", + "dcdc_id": "DCDC22", + "Min": 950, + "value": { + "loc": "/sys/bus/i2c/devices/24-005b/hwmon/hwmon*/in9_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1050, + "format": "float(float(%s)/1000)", + }, + { + "name": "ODD_PHY_M", + "dcdc_id": "DCDC23", + "Min": 3116, + "value": { + "loc": "/sys/bus/i2c/devices/24-005b/hwmon/hwmon*/in11_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3444, + "format": "float(float(%s)/1000)", + }, + { + "name": "VCCIN", + "dcdc_id": "DCDC24", + "Min": 1700, + "value": { + "loc": "/sys/bus/i2c/devices/25-0060/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1879, + "format": "float(float(%s)/1000)", + }, + { + "name": "P1V05", + "dcdc_id": "DCDC25", + "Min": 1000, + "value": { + "loc": "/sys/bus/i2c/devices/25-0060/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1103, + "format": "float(float(%s)/1000)", + }, + { + "name": "P1V2_VDDQ", + "dcdc_id": "DCDC26", + "Min": 1140, + "value": { + "loc": "/sys/bus/i2c/devices/25-006c/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1258, + "format": "float(float(%s)/1000)", + }, + { + "name": "P2V5_VPP", + "dcdc_id": "DCDC27", + "Min": 2117, + "value": { + "loc": "/sys/bus/i2c/devices/25-006c/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 2342, + "format": "float(float(%s)/1000) * 1.124", + }, + { + "name": "P3V3_STBY", + "dcdc_id": "DCDC28", + "Min": 3140, + "value": { + "loc": "/sys/bus/i2c/devices/25-0043/hwmon/hwmon*/in1_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3476, + "format": "float(float(%s)/1000)", + }, + { + "name": "P5V_AUX_IN", + "dcdc_id": "DCDC29", + "Min": 4730, + "value": { + "loc": "/sys/bus/i2c/devices/25-0043/hwmon/hwmon*/in2_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 5229, + "format": "float(float(%s)/1000)", + }, + { + "name": "P1V7_VCCSCFUSESUS_IN", + "dcdc_id": "DCDC30", + "Min": 1620, + "value": { + "loc": "/sys/bus/i2c/devices/25-0043/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1789, + "format": "float(float(%s)/1000)", + }, + ], + "cpu": [ + { + "name": "cpu", + "CpuResetCntReg": {"loc": "/dev/cpld1", "offset": 0x88, "len": 1, "way": "devfile_ascii"}, + } + ], + "sfps": { + "port_start": 1, + "port_end": 32, + } +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/hal-config/x86_64_tencent_tcs8400_r0_device.py b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/hal-config/x86_64_tencent_tcs8400_r0_device.py new file mode 100755 index 000000000000..2a7b99b47fdc --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/hal-config/x86_64_tencent_tcs8400_r0_device.py @@ -0,0 +1,1108 @@ +#!/usr/bin/python3 + +psu_fan_airflow = { + "F2B": ["DPS-1300AB-6 F", "GW-CRPS1300D"], + "B2F": ["DPS-1300AB-11 C", "CRPS1300D3R"] +} + +psu_display_name = { + "PSA1300CRPS-F": ["DPS-1300AB-6 F", "GW-CRPS1300D"], + "PSA1300CRPS-R": ["DPS-1300AB-11 C", "CRPS1300D3R"] +} + +fanairflow = { + "F2B": ["FAN24K4056-F", "FAN24K4056S-F"], + "B2F": ["FAN24K4056S-R"], +} + +fan_display_name = { + "FAN24K4056-F": ["FAN24K4056-F", "FAN24K4056S-F"], + "FAN24K4056-R": ["FAN24K4056S-R"] +} + +psutypedecode = { + 0x00: 'N/A', + 0x01: 'AC', + 0x02: 'DC', +} + + +class Unit: + Temperature = "C" + Voltage = "V" + Current = "A" + Power = "W" + Speed = "RPM" + + +PSU_NOT_PRESENT_PWM = 100 + + +class threshold: + PSU_TEMP_MIN = -10 * 1000 + PSU_TEMP_MAX = 60 * 1000 + + PSU_FAN_SPEED_MIN = 2000 + PSU_FAN_SPEED_MAX = 28000 + + PSU_OUTPUT_VOLTAGE_MIN = 11 * 1000 + PSU_OUTPUT_VOLTAGE_MAX = 14 * 1000 + + PSU_AC_INPUT_VOLTAGE_MIN = 200 * 1000 + PSU_AC_INPUT_VOLTAGE_MAX = 240 * 1000 + + PSU_DC_INPUT_VOLTAGE_MIN = 190 * 1000 + PSU_DC_INPUT_VOLTAGE_MAX = 290 * 1000 + + ERR_VALUE = -9999999 + + PSU_OUTPUT_POWER_MIN = 10 * 1000 * 1000 + PSU_OUTPUT_POWER_MAX = 1300 * 1000 * 1000 + + PSU_INPUT_POWER_MIN = 10 * 1000 * 1000 + PSU_INPUT_POWER_MAX = 1444 * 1000 * 1000 + + PSU_OUTPUT_CURRENT_MIN = 2 * 1000 + PSU_OUTPUT_CURRENT_MAX = 107 * 1000 + + PSU_INPUT_CURRENT_MIN = 0.2 * 1000 + PSU_INPUT_CURRENT_MAX = 7 * 1000 + + FRONT_FAN_SPEED_MAX = 25000 + REAR_FAN_SPEED_MAX = 22000 + FAN_SPEED_MIN = 2000 + + +class Description: + CPLD = "Used for managing IO modules, SFP+ modules and system LEDs" + BIOS = "Performs initialization of hardware components during booting" + FPGA = "Platform management controller for on-board temperature monitoring, in-chassis power" + + +devices = { + "onie_e2": [ + { + "name": "ONIE_E2", + "e2loc": {"loc": "/sys/bus/i2c/devices/1-0056/eeprom", "way": "sysfs"}, + }, + ], + "psus": [ + { + "e2loc": {"loc": "/sys/bus/i2c/devices/41-0050/eeprom", "way": "sysfs"}, + "pmbusloc": {"bus": 41, "addr": 0x58, "way": "i2c"}, + "present": {"loc": "/sys/rg_plat/psu/psu1/present", "way": "sysfs", "mask": 0x01, "okval": 1}, + "name": "PSU1", + "psu_display_name": psu_display_name, + "airflow": psu_fan_airflow, + "psu_not_present_pwm": PSU_NOT_PRESENT_PWM, + "TempStatus": {"bus": 41, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0004}, + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": threshold.PSU_TEMP_MIN, + "Max": threshold.PSU_TEMP_MAX, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + }, + "FanStatus": {"bus": 41, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0400}, + "FanSpeed": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/fan1_input", "way": "sysfs"}, + "Min": threshold.PSU_FAN_SPEED_MIN, + "Max": threshold.PSU_FAN_SPEED_MAX, + "Unit": Unit.Speed + }, + "InputsStatus": {"bus": 41, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x2000}, + "InputsType": {"bus": 41, "addr": 0x58, "offset": 0x80, "way": "i2c", 'psutypedecode': psutypedecode}, + "InputsVoltage": { + 'AC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_AC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_AC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + + }, + 'DC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_DC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_DC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + 'other': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.ERR_VALUE, + "Max": threshold.ERR_VALUE, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + } + }, + "InputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/curr1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_CURRENT_MIN, + "Max": threshold.PSU_INPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "InputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/power1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_POWER_MIN, + "Max": threshold.PSU_INPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + "OutputsStatus": {"bus": 41, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x8800}, + "OutputsVoltage": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/in2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_VOLTAGE_MIN, + "Max": threshold.PSU_OUTPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + "OutputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/curr2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_CURRENT_MIN, + "Max": threshold.PSU_OUTPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "OutputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/power2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_POWER_MIN, + "Max": threshold.PSU_OUTPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + }, + { + "e2loc": {"loc": "/sys/bus/i2c/devices/42-0050/eeprom", "way": "sysfs"}, + "pmbusloc": {"bus": 42, "addr": 0x58, "way": "i2c"}, + "present": {"loc": "/sys/rg_plat/psu/psu2/present", "way": "sysfs", "mask": 0x01, "okval": 1}, + "name": "PSU2", + "psu_display_name": psu_display_name, + "airflow": psu_fan_airflow, + "psu_not_present_pwm": PSU_NOT_PRESENT_PWM, + "TempStatus": {"bus": 42, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0004}, + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": threshold.PSU_TEMP_MIN, + "Max": threshold.PSU_TEMP_MAX, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + }, + "FanStatus": {"bus": 42, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0400}, + "FanSpeed": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/fan1_input", "way": "sysfs"}, + "Min": threshold.PSU_FAN_SPEED_MIN, + "Max": threshold.PSU_FAN_SPEED_MAX, + "Unit": Unit.Speed + }, + "InputsStatus": {"bus": 42, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x2000}, + "InputsType": {"bus": 42, "addr": 0x58, "offset": 0x80, "way": "i2c", 'psutypedecode': psutypedecode}, + "InputsVoltage": { + 'AC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_AC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_AC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + + }, + 'DC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_DC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_DC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + 'other': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.ERR_VALUE, + "Max": threshold.ERR_VALUE, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + } + }, + "InputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/curr1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_CURRENT_MIN, + "Max": threshold.PSU_INPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "InputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/power1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_POWER_MIN, + "Max": threshold.PSU_INPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + "OutputsStatus": {"bus": 42, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x8800}, + "OutputsVoltage": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/in2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_VOLTAGE_MIN, + "Max": threshold.PSU_OUTPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + "OutputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/curr2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_CURRENT_MIN, + "Max": threshold.PSU_OUTPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "OutputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/power2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_POWER_MIN, + "Max": threshold.PSU_OUTPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + } + ], + "temps": [ + { + "name": "BOARD_TEMP", + "temp_id": "TEMP1", + "api_name": "Board", + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/40-004e/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": -10000, + "Low": 0, + "High": 70000, + "Max": 80000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + { + "name": "CPU_TEMP", + "temp_id": "TEMP2", + "api_name": "CPU", + "Temperature": { + "value": {"loc": "/sys/bus/platform/devices/coretemp.0/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": 2000, + "Low": 10000, + "High": 100000, + "Max": 104000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + { + "name": "INLET_TEMP", + "temp_id": "TEMP3", + "api_name": "Inlet", + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/40-004f/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": -10000, + "Low": 0, + "High": 40000, + "Max": 50000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + { + "name": "OUTLET_TEMP", + "temp_id": "TEMP4", + "api_name": "Outlet", + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/36-0048/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": -10000, + "Low": 0, + "High": 70000, + "Max": 80000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + { + "name": "SWITCH_TEMP", + "temp_id": "TEMP5", + "api_name": "Switch ASIC", + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/44-0044/hwmon/hwmon*/temp99_input", "way": "sysfs"}, + "Min": 2000, + "Low": 10000, + "High": 100000, + "Max": 105000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + { + "name": "SFF_TEMP", + "Temperature": { + "value": {"loc": "/tmp/highest_sff_temp", "way": "sysfs", "flock_path": "/tmp/highest_sff_temp"}, + "Min": -15000, + "Low": 0, + "High": 80000, + "Max": 100000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + ], + "leds": [ + { + "name": "FRONT_SYS_LED", + "led_type": "SYS_LED", + "led": {"bus": 2, "addr": 0x2d, "offset": 0x40, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + }, + { + "name": "FRONT_PSU_LED", + "led_type": "PSU_LED", + "led": {"bus": 2, "addr": 0x2d, "offset": 0x43, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + }, + { + "name": "FRONT_FAN_LED", + "led_type": "FAN_LED", + "led": {"bus": 2, "addr": 0x2d, "offset": 0x42, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + }, + ], + "fans": [ + { + "name": "FAN1", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-35/35-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"bus": 4, "addr": 0x3d, "offset": 0x37, "way": "i2c", "mask": 0x20}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 4, "addr": 0x3d, "offset": 0x41, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x65, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x20, "is_runing": 0x20}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x20, "no_alarm": 0x20}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan1/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x65, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x20, "is_runing": 0x20}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x20, "no_alarm": 0x20}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan1/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN2", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-34/34-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"bus": 4, "addr": 0x3d, "offset": 0x37, "way": "i2c", "mask": 0x10}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 4, "addr": 0x3d, "offset": 0x40, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x64, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x10, "is_runing": 0x10}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x10, "no_alarm": 0x10}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan2/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x64, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x10, "is_runing": 0x10}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x10, "no_alarm": 0x10}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan2/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN3", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-33/33-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"bus": 4, "addr": 0x3d, "offset": 0x37, "way": "i2c", "mask": 0x08}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 4, "addr": 0x3d, "offset": 0x3f, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x63, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x08, "is_runing": 0x08}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x08, "no_alarm": 0x08}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan3/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x63, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x08, "is_runing": 0x08}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x08, "no_alarm": 0x08}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan3/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN4", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-32/32-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"bus": 4, "addr": 0x3d, "offset": 0x37, "way": "i2c", "mask": 0x04}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 4, "addr": 0x3d, "offset": 0x3e, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x62, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x04, "is_runing": 0x04}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x04, "no_alarm": 0x04}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan4/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x62, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x04, "is_runing": 0x04}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x04, "no_alarm": 0x04}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan4/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN5", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-31/31-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"bus": 4, "addr": 0x3d, "offset": 0x37, "way": "i2c", "mask": 0x02}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 4, "addr": 0x3d, "offset": 0x3d, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x61, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x02, "is_runing": 0x02}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x02, "no_alarm": 0x02}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan5/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x61, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x02, "is_runing": 0x02}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x02, "no_alarm": 0x02}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan5/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN6", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-30/30-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"bus": 4, "addr": 0x3d, "offset": 0x37, "way": "i2c", "mask": 0x01}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 4, "addr": 0x3d, "offset": 0x3c, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x60, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x01, "is_runing": 0x01}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x01, "no_alarm": 0x01}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan6/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x60, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x01, "is_runing": 0x01}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x01, "no_alarm": 0x01}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan6/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + ], + "cplds": [ + { + "name": "CPU_CPLD", + "cpld_id": "CPLD1", + "VersionFile": {"loc": "/dev/cpld0", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for system power", + "slot": 0, + }, + { + "name": "BASE_CPLD", + "cpld_id": "CPLD2", + "VersionFile": {"loc": "/dev/cpld1", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for base functions", + "slot": 0, + }, + { + "name": "MAC_CPLDA", + "cpld_id": "CPLD3", + "VersionFile": {"loc": "/dev/cpld4", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for sff modules", + "slot": 0, + }, + { + "name": "MAC_CPLDB", + "cpld_id": "CPLD4", + "VersionFile": {"loc": "/dev/cpld5", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for sff modules", + "slot": 0, + }, + { + "name": "FAN_CPLD", + "cpld_id": "CPLD5", + "VersionFile": {"loc": "/dev/cpld6", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for fan modules", + "slot": 0, + }, + { + "name": "FPGA", + "cpld_id": "CPLD6", + "VersionFile": {"loc": "/dev/fpga0", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for base functions", + "slot": 0, + "format": "little_endian", + }, + ], + "dcdc": [ + { + "name": "VDD5V_CLK_MCU", + "dcdc_id": "DCDC1", + "Min": 4840, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in1_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 5345, + "format": "float(float(%s)/1000)", + }, + { + "name": "VDD3.3_CLK", + "dcdc_id": "DCDC2", + "Min": 3220, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in2_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3560, + "format": "float(float(%s)/1000)", + }, + { + "name": "VDD1.0V", + "dcdc_id": "DCDC3", + "Min": 950, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1049, + "format": "float(float(%s)/1000)", + }, + { + "name": "VDD1.8V", + "dcdc_id": "DCDC4", + "Min": 1720, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1903, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_BOARD_VDD3.3V", + "dcdc_id": "DCDC5", + "Min": 3170, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in5_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3499, + "format": "float(float(%s)/1000)", + }, + { + "name": "VDD1.2V", + "dcdc_id": "DCDC6", + "Min": 1150, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in6_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1272, + "format": "float(float(%s)/1000)", + }, + { + "name": "VDD_CORE", + "dcdc_id": "DCDC7", + "Min": 670, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in7_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 950, + "format": "float(float(%s)/1000)", + }, + { + "name": "ANALOG0.75V", + "dcdc_id": "DCDC8", + "Min": 700, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in8_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 800, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD1.2V", + "dcdc_id": "DCDC9", + "Min": 1140, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in9_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1259, + "format": "float(float(%s)/1000)", + }, + { + "name": "VDDO1.8V", + "dcdc_id": "DCDC10", + "Min": 1750, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in10_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1937, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_ANA1.2V", + "dcdc_id": "DCDC11", + "Min": 1150, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in11_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1276, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_ANA1.8V", + "dcdc_id": "DCDC12", + "Min": 1730, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in12_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1910, + "format": "float(float(%s)/1000)", + }, + { + "name": "QSFP56_VDD3.3V_A", + "dcdc_id": "DCDC13", + "Min": 3250, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in13_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3595, + "format": "float(float(%s)/1000)", + }, + { + "name": "QSFP56_VDD3.3V_B", + "dcdc_id": "DCDC14", + "Min": 3260, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in14_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3601, + "format": "float(float(%s)/1000)", + }, + { + "name": "QSFPDD_VDD3.3V_A", + "dcdc_id": "DCDC15", + "Min": 3230, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in15_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3565, + "format": "float(float(%s)/1000)", + }, + { + "name": "QSFPDD_VDD3.3V_B", + "dcdc_id": "DCDC16", + "Min": 3220, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in16_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3564, + "format": "float(float(%s)/1000)", + }, + { + "name": "VDD5.0V", + "dcdc_id": "DCDC17", + "Min": 4910, + "value": { + "loc": "/sys/bus/i2c/devices/24-005b/hwmon/hwmon*/in1_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 5429, + "format": "float(float(%s)/1000)", + }, + { + "name": "SW_VDD1.2V", + "dcdc_id": "DCDC18", + "Min": 1160, + "value": { + "loc": "/sys/bus/i2c/devices/24-005b/hwmon/hwmon*/in2_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1284, + "format": "float(float(%s)/1000)", + }, + { + "name": "VDD2.5V", + "dcdc_id": "DCDC19", + "Min": 2370, + "value": { + "loc": "/sys/bus/i2c/devices/24-005b/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 2620, + "format": "float(float(%s)/1000)", + }, + { + "name": "CONNECT_BOARD_VDD3.3V", + "dcdc_id": "DCDC20", + "Min": 3110, + "value": { + "loc": "/sys/bus/i2c/devices/24-005b/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3437, + "format": "float(float(%s)/1000)", + }, + { + "name": "VDD12V", + "dcdc_id": "DCDC21", + "Min": 11300, + "value": { + "loc": "/sys/bus/i2c/devices/24-005b/hwmon/hwmon*/in6_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 12700, + "format": "float(float(%s)/1000)", + }, + { + "name": "VDD3.3_STBY", + "dcdc_id": "DCDC22", + "Min": 3160, + "value": { + "loc": "/sys/bus/i2c/devices/24-005b/hwmon/hwmon*/in7_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3489, + "format": "float(float(%s)/1000)", + }, + { + "name": "SSD_VDD3.3V", + "dcdc_id": "DCDC23", + "Min": 3140, + "value": { + "loc": "/sys/bus/i2c/devices/24-005b/hwmon/hwmon*/in8_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3475, + "format": "float(float(%s)/1000)", + }, + { + "name": "VCCIN", + "dcdc_id": "DCDC24", + "Min": 1700, + "value": { + "loc": "/sys/bus/i2c/devices/25-0060/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1879, + "format": "float(float(%s)/1000)", + }, + { + "name": "P1V05", + "dcdc_id": "DCDC25", + "Min": 1000, + "value": { + "loc": "/sys/bus/i2c/devices/25-0060/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1103, + "format": "float(float(%s)/1000)", + }, + { + "name": "P1V2_VDDQ", + "dcdc_id": "DCDC26", + "Min": 1140, + "value": { + "loc": "/sys/bus/i2c/devices/25-006c/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1258, + "format": "float(float(%s)/1000)", + }, + { + "name": "P2V5_VPP", + "dcdc_id": "DCDC27", + "Min": 2117, + "value": { + "loc": "/sys/bus/i2c/devices/25-006c/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 2342, + "format": "float(float(%s)/1000) * 1.124", + }, + { + "name": "P3V3_STBY", + "dcdc_id": "DCDC28", + "Min": 3140, + "value": { + "loc": "/sys/bus/i2c/devices/25-0043/hwmon/hwmon*/in1_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3476, + "format": "float(float(%s)/1000)", + }, + { + "name": "P5V_AUX_IN", + "dcdc_id": "DCDC29", + "Min": 4730, + "value": { + "loc": "/sys/bus/i2c/devices/25-0043/hwmon/hwmon*/in2_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 5229, + "format": "float(float(%s)/1000)", + }, + { + "name": "P1V7_VCCSCFUSESUS_IN", + "dcdc_id": "DCDC30", + "Min": 1620, + "value": { + "loc": "/sys/bus/i2c/devices/25-0043/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1789, + "format": "float(float(%s)/1000)", + }, + ], + "cpu": [ + { + "name": "cpu", + "CpuResetCntReg": {"loc": "/dev/cpld1", "offset": 0x88, "len": 1, "way": "devfile_ascii"}, + } + ], + "sfps": { + "port_start": 1, + "port_end": 32, + } +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/hal-config/x86_64_tencent_tcs8400_r0_monitor.py b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/hal-config/x86_64_tencent_tcs8400_r0_monitor.py new file mode 100755 index 000000000000..4cb28cf8bb66 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/hal-config/x86_64_tencent_tcs8400_r0_monitor.py @@ -0,0 +1,212 @@ +#!/usr/bin/python3 + +monitor = { + "openloop": { + "linear": { + "name": "linear", + "flag": 0, + "pwm_min": 0x80, + "pwm_max": 0xff, + "K": 11, + "tin_min": 38, + }, + "curve": { + "name": "curve", + "flag": 1, + "pwm_min": 0x80, + "pwm_max": 0xff, + "a": 0.369, + "b": -15.657, + "c": 289, + "tin_min": 25, + }, + }, + + "pid": { + "CPU_TEMP": { + "name": "CPU_TEMP", + "flag": 1, + "type": "duty", + "pwm_min": 0x80, + "pwm_max": 0xff, + "Kp": 1.5, + "Ki": 1, + "Kd": 0.3, + "target": 80, + "value": [None, None, None], + }, + "SWITCH_TEMP": { + "name": "SWITCH_TEMP", + "flag": 1, + "type": "duty", + "pwm_min": 0x80, + "pwm_max": 0xff, + "Kp": 1.5, + "Ki": 1, + "Kd": 0.3, + "target": 90, + "value": [None, None, None], + }, + "OUTLET_TEMP": { + "name": "OUTLET_TEMP", + "flag": 1, + "type": "duty", + "pwm_min": 0x80, + "pwm_max": 0xff, + "Kp": 2, + "Ki": 0.4, + "Kd": 0.3, + "target": 65, + "value": [None, None, None], + }, + "BOARD_TEMP": { + "name": "BOARD_TEMP", + "flag": 0, + "type": "duty", + "pwm_min": 0x80, + "pwm_max": 0xff, + "Kp": 2, + "Ki": 0.4, + "Kd": 0.3, + "target": 65, + "value": [None, None, None], + }, + "SFF_TEMP": { + "name": "SFF_TEMP", + "flag": 1, + "type": "duty", + "pwm_min": 0x80, + "pwm_max": 0xff, + "Kp": 0.1, + "Ki": 0.4, + "Kd": 0, + "target": 60, + "value": [None, None, None], + }, + }, + + "temps_threshold": { + "SWITCH_TEMP": {"name": "SWITCH_TEMP", "warning": 100, "critical": 105, "invalid": -100000, "error": -99999}, + "INLET_TEMP": {"name": "INLET_TEMP", "warning": 40, "critical": 50, "fix": -3}, + "BOARD_TEMP": {"name": "BOARD_TEMP", "warning": 70, "critical": 75}, + "OUTLET_TEMP": {"name": "OUTLET_TEMP", "warning": 70, "critical": 75}, + "CPU_TEMP": {"name": "CPU_TEMP", "warning": 100, "critical": 102}, + "SFF_TEMP": {"name": "SFF_TEMP", "warning": 999, "critical": 1000, "ignore_threshold": 1, "invalid": -10000, "error": -9999}, + }, + + "fancontrol_para": { + "interval": 5, + "fan_status_interval": 0.5, + "fan_air_flow_monitor": 1, + "max_pwm": 0xff, + "min_pwm": 0x80, + "abnormal_pwm": 0xff, + "warning_pwm": 0xff, + "temp_invalid_pid_pwm": 0x80, + "temp_error_pid_pwm": 0x80, + "temp_fail_num": 3, + "check_temp_fail": [ + {"temp_name": "INLET_TEMP"}, + {"temp_name": "SWITCH_TEMP"}, + {"temp_name": "CPU_TEMP"}, + ], + "temp_warning_num": 3, # temp over warning 3 times continuously + "temp_critical_num": 3, # temp over critical 3 times continuously + "temp_warning_countdown": 60, # 5 min warning speed after not warning + "temp_critical_countdown": 60, # 5 min full speed after not critical + "rotor_error_count": 2, # fan rotor error 2 times continuously + "inlet_mac_diff": 999, + "check_crit_reboot_flag": 1, + "check_crit_reboot_num": 3, + "check_crit_sleep_time": 20, + "psu_absent_fullspeed_num": 0xFF, + "fan_absent_fullspeed_num": 1, + "rotor_error_fullspeed_num": 1, + "fan_plug_in_default_countdown": 0, # no use + "fan_plug_in_pwm": 0x80, # fan plug in pwd + "deal_fan_error": 1, + "deal_fan_error_conf": { + "countdown": 2, + "FAN1": [ + {"name":"FAN1", "pwm":0xff}, + {"name":"FAN2", "pwm":0x80}, + {"name":"FAN3", "pwm":0x80}, + {"name":"FAN4", "pwm":0x80}, + {"name":"FAN5", "pwm":0x80}, + {"name":"FAN6", "pwm":0x80}, + ], + "FAN2": [ + {"name":"FAN1", "pwm":0x80}, + {"name":"FAN2", "pwm":0xff}, + {"name":"FAN3", "pwm":0x80}, + {"name":"FAN4", "pwm":0x80}, + {"name":"FAN5", "pwm":0x80}, + {"name":"FAN6", "pwm":0x80}, + ], + "FAN3": [ + {"name":"FAN1", "pwm":0x80}, + {"name":"FAN2", "pwm":0x80}, + {"name":"FAN3", "pwm":0xff}, + {"name":"FAN4", "pwm":0x80}, + {"name":"FAN5", "pwm":0x80}, + {"name":"FAN6", "pwm":0x80}, + ], + "FAN4": [ + {"name":"FAN1", "pwm":0x80}, + {"name":"FAN2", "pwm":0x80}, + {"name":"FAN3", "pwm":0x80}, + {"name":"FAN4", "pwm":0xff}, + {"name":"FAN5", "pwm":0x80}, + {"name":"FAN6", "pwm":0x80}, + ], + "FAN5": [ + {"name":"FAN1", "pwm":0x80}, + {"name":"FAN2", "pwm":0x80}, + {"name":"FAN3", "pwm":0x80}, + {"name":"FAN4", "pwm":0x80}, + {"name":"FAN5", "pwm":0xff}, + {"name":"FAN6", "pwm":0x80}, + ], + "FAN6": [ + {"name":"FAN1", "pwm":0x80}, + {"name":"FAN2", "pwm":0x80}, + {"name":"FAN3", "pwm":0x80}, + {"name":"FAN4", "pwm":0x80}, + {"name":"FAN5", "pwm":0x80}, + {"name":"FAN6", "pwm":0xff}, + ], + }, + }, + + "ledcontrol_para": { + "interval": 5, + "checkpsu": 1, + "checkfan": 1, + "psu_yellow_num": 1, + "fan_yellow_num": 1, + "board_sys_led": [ + {"led_name": "FRONT_SYS_LED"}, + ], + "board_psu_led": [ + {"led_name": "FRONT_PSU_LED"}, + ], + "board_fan_led": [ + {"led_name": "FRONT_FAN_LED"}, + ], + "psu_air_flow_monitor": 1, + "fan_air_flow_monitor": 1, + "fan_mix_list": [ + {"FAN24K4056-F", "FAN24K4056S-F"} + ] + }, + "intelligent_monitor_para": { + "interval": 60, + }, + + "dcdc_monitor_whitelist": { #not monitor when checkbit equal okval + "QSFP56_VDD3.3V_A": {"gettype": "i2c", "bus": 2, "addr": 0x2d, "offset": 0x45, "checkbit": 0, "okval": 0}, + "QSFP56_VDD3.3V_B": {"gettype": "i2c", "bus": 2, "addr": 0x2d, "offset": 0x45, "checkbit": 1, "okval": 0}, + "QSFPDD_VDD3.3V_A": {"gettype": "i2c", "bus": 2, "addr": 0x2d, "offset": 0x46, "checkbit": 0, "okval": 0}, + "QSFPDD_VDD3.3V_B": {"gettype": "i2c", "bus": 2, "addr": 0x2d, "offset": 0x46, "checkbit": 1, "okval": 0}, + }, +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/Makefile b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/Makefile new file mode 100755 index 000000000000..873cb472f957 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/Makefile @@ -0,0 +1,12 @@ +MAKEFILE_FILE_PATH = $(abspath $(lastword $(MAKEFILE_LIST))) +MODULES_DIR = $(abspath $(MAKEFILE_FILE_PATH)/../../../../common/modules) + +EXTRA_CFLAGS+= -I$(MODULES_DIR) + +obj-m += rg_pcie_dev_device.o +obj-m += rg_fpga_i2c_bus_device.o +obj-m += rg_fpga_pca954x_device.o +obj-m += rg_lpc_drv_device.o +obj-m += rg_i2c_dev_device.o +obj-m += rg_io_dev_device.o +obj-m += rg_wdt_device.o \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_fpga_i2c_bus_device.c b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_fpga_i2c_bus_device.c new file mode 100644 index 000000000000..22e8a1ddf19d --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_fpga_i2c_bus_device.c @@ -0,0 +1,874 @@ +#include +#include +#include +#include +#include + +#include + +static int g_rg_fpga_i2c_debug = 0; +static int g_rg_fpga_i2c_error = 0; + +module_param(g_rg_fpga_i2c_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_fpga_i2c_error, int, S_IRUGO | S_IWUSR); + +#define RG_FPGA_I2C_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_rg_fpga_i2c_debug) { \ + printk(KERN_INFO "[RG_FPGA_I2C][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RG_FPGA_I2C_DEBUG_ERROR(fmt, args...) do { \ + if (g_rg_fpga_i2c_error) { \ + printk(KERN_ERR "[RG_FPGA_I2C][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static fpga_i2c_bus_device_t fpga_i2c_bus_device_data0 = { + .adap_nr = 2, + .i2c_timeout = 3000, + .i2c_scale = 0x500, + .i2c_filter = 0x504, + .i2c_stretch = 0x508, + .i2c_ext_9548_exits_flag = 0x50c, + .i2c_ext_9548_addr = 0x510, + .i2c_ext_9548_chan = 0x514, + .i2c_in_9548_chan = 0x518, + .i2c_slave = 0x51c, + .i2c_reg = 0x520, + .i2c_reg_len = 0x530, + .i2c_data_len = 0x534, + .i2c_ctrl = 0x538, + .i2c_status = 0x53c, + .i2c_err_vec = 0x548, + .i2c_data_buf = 0x580, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x80, + .i2c_reset_on = 0x00000001, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, +}; + +static fpga_i2c_bus_device_t fpga_i2c_bus_device_data1 = { + .adap_nr = 3, + .i2c_timeout = 3000, + .i2c_scale = 0x600, + .i2c_filter = 0x604, + .i2c_stretch = 0x608, + .i2c_ext_9548_exits_flag = 0x60c, + .i2c_ext_9548_addr = 0x610, + .i2c_ext_9548_chan = 0x614, + .i2c_in_9548_chan = 0x618, + .i2c_slave = 0x61c, + .i2c_reg = 0x620, + .i2c_reg_len = 0x630, + .i2c_data_len = 0x634, + .i2c_ctrl = 0x638, + .i2c_status = 0x63c, + .i2c_err_vec = 0x648, + .i2c_data_buf = 0x680, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x84, + .i2c_reset_on = 0x00000001, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, +}; + +static fpga_i2c_bus_device_t fpga_i2c_bus_device_data2 = { + .adap_nr = 4, + .i2c_timeout = 3000, + .i2c_scale = 0x700, + .i2c_filter = 0x704, + .i2c_stretch = 0x708, + .i2c_ext_9548_exits_flag = 0x70c, + .i2c_ext_9548_addr = 0x710, + .i2c_ext_9548_chan = 0x714, + .i2c_in_9548_chan = 0x718, + .i2c_slave = 0x71c, + .i2c_reg = 0x720, + .i2c_reg_len = 0x730, + .i2c_data_len = 0x734, + .i2c_ctrl = 0x738, + .i2c_status = 0x73c, + .i2c_err_vec = 0x748, + .i2c_data_buf = 0x780, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x88, + .i2c_reset_on = 0x00000001, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, +}; +static fpga_i2c_bus_device_t fpga_i2c_bus_device_data3 = { + .adap_nr = 5, + .i2c_timeout = 3000, + .i2c_scale = 0x800, + .i2c_filter = 0x804, + .i2c_stretch = 0x808, + .i2c_ext_9548_exits_flag = 0x80c, + .i2c_ext_9548_addr = 0x810, + .i2c_ext_9548_chan = 0x814, + .i2c_in_9548_chan = 0x818, + .i2c_slave = 0x81c, + .i2c_reg = 0x820, + .i2c_reg_len = 0x830, + .i2c_data_len = 0x834, + .i2c_ctrl = 0x838, + .i2c_status = 0x83c, + .i2c_err_vec = 0x848, + .i2c_data_buf = 0x880, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x8c, + .i2c_reset_on = 0x00000001, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, + .i2c_offset_reg = 0xd4, + .i2c_data_buf_len_reg = 0xac, +}; + +static fpga_i2c_bus_device_t fpga_dom_i2c_bus_device_data0 = { + .adap_nr = 6, + .i2c_timeout = 3000, + .i2c_scale = 0x2c00, + .i2c_filter = 0x2c04, + .i2c_stretch = 0x2c08, + .i2c_ext_9548_exits_flag = 0x2c0c, + .i2c_ext_9548_addr = 0x2c10, + .i2c_ext_9548_chan = 0x2c14, + .i2c_in_9548_chan = 0x2c18, + .i2c_slave = 0x2c1c, + .i2c_reg = 0x2c20, + .i2c_reg_len = 0x2c30, + .i2c_data_len = 0x2c34, + .i2c_ctrl = 0x2c38, + .i2c_status = 0x2c3c, + .i2c_err_vec = 0x2c48, + .i2c_data_buf = 0x2c80, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000001, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, +}; + +static fpga_i2c_bus_device_t fpga_dom_i2c_bus_device_data1 = { + .adap_nr = 7, + .i2c_timeout = 3000, + .i2c_scale = 0x2d00, + .i2c_filter = 0x2d04, + .i2c_stretch = 0x2d08, + .i2c_ext_9548_exits_flag = 0x2d0c, + .i2c_ext_9548_addr = 0x2d10, + .i2c_ext_9548_chan = 0x2d14, + .i2c_in_9548_chan = 0x2d18, + .i2c_slave = 0x2d1c, + .i2c_reg = 0x2d20, + .i2c_reg_len = 0x2d30, + .i2c_data_len = 0x2d34, + .i2c_ctrl = 0x2d38, + .i2c_status = 0x2d3c, + .i2c_err_vec = 0x2d48, + .i2c_data_buf = 0x2d80, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000002, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, +}; + +static fpga_i2c_bus_device_t fpga_dom_i2c_bus_device_data2 = { + .adap_nr = 8, + .i2c_timeout = 3000, + .i2c_scale = 0x2e00, + .i2c_filter = 0x2e04, + .i2c_stretch = 0x2e08, + .i2c_ext_9548_exits_flag = 0x2e0c, + .i2c_ext_9548_addr = 0x2e10, + .i2c_ext_9548_chan = 0x2e14, + .i2c_in_9548_chan = 0x2e18, + .i2c_slave = 0x2e1c, + .i2c_reg = 0x2e20, + .i2c_reg_len = 0x2e30, + .i2c_data_len = 0x2e34, + .i2c_ctrl = 0x2e38, + .i2c_status = 0x2e3c, + .i2c_err_vec = 0x2e48, + .i2c_data_buf = 0x2e80, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000004, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, +}; + +static fpga_i2c_bus_device_t fpga_dom_i2c_bus_device_data3 = { + .adap_nr = 9, + .i2c_timeout = 3000, + .i2c_scale = 0x2f00, + .i2c_filter = 0x2f04, + .i2c_stretch = 0x2f08, + .i2c_ext_9548_exits_flag = 0x2f0c, + .i2c_ext_9548_addr = 0x2f10, + .i2c_ext_9548_chan = 0x2f14, + .i2c_in_9548_chan = 0x2f18, + .i2c_slave = 0x2f1c, + .i2c_reg = 0x2f20, + .i2c_reg_len = 0x2f30, + .i2c_data_len = 0x2f34, + .i2c_ctrl = 0x2f38, + .i2c_status = 0x2f3c, + .i2c_err_vec = 0x2f48, + .i2c_data_buf = 0x2f80, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000008, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, +}; + +static fpga_i2c_bus_device_t fpga_dom_i2c_bus_device_data4 = { + .adap_nr = 10, + .i2c_timeout = 3000, + .i2c_scale = 0x3000, + .i2c_filter = 0x3004, + .i2c_stretch = 0x3008, + .i2c_ext_9548_exits_flag = 0x300c, + .i2c_ext_9548_addr = 0x3010, + .i2c_ext_9548_chan = 0x3014, + .i2c_in_9548_chan = 0x3018, + .i2c_slave = 0x301c, + .i2c_reg = 0x3020, + .i2c_reg_len = 0x3030, + .i2c_data_len = 0x3034, + .i2c_ctrl = 0x3038, + .i2c_status = 0x303c, + .i2c_err_vec = 0x3048, + .i2c_data_buf = 0x3080, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000010, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, +}; + +static fpga_i2c_bus_device_t fpga_dom_i2c_bus_device_data5 = { + .adap_nr = 11, + .i2c_timeout = 3000, + .i2c_scale = 0x3100, + .i2c_filter = 0x3104, + .i2c_stretch = 0x3108, + .i2c_ext_9548_exits_flag = 0x310c, + .i2c_ext_9548_addr = 0x3110, + .i2c_ext_9548_chan = 0x3114, + .i2c_in_9548_chan = 0x3118, + .i2c_slave = 0x311c, + .i2c_reg = 0x3120, + .i2c_reg_len = 0x3130, + .i2c_data_len = 0x3134, + .i2c_ctrl = 0x3138, + .i2c_status = 0x313c, + .i2c_data_buf = 0x3180, + .i2c_err_vec = 0x3148, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000020, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, +}; + +static fpga_i2c_bus_device_t fpga_dom_i2c_bus_device_data6 = { + .adap_nr = 12, + .i2c_timeout = 3000, + .i2c_scale = 0x3200, + .i2c_filter = 0x3204, + .i2c_stretch = 0x3208, + .i2c_ext_9548_exits_flag = 0x320c, + .i2c_ext_9548_addr = 0x3210, + .i2c_ext_9548_chan = 0x3214, + .i2c_in_9548_chan = 0x3218, + .i2c_slave = 0x321c, + .i2c_reg = 0x3220, + .i2c_reg_len = 0x3230, + .i2c_data_len = 0x3234, + .i2c_ctrl = 0x3238, + .i2c_status = 0x323c, + .i2c_err_vec = 0x3248, + .i2c_data_buf = 0x3280, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000040, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, +}; + +static fpga_i2c_bus_device_t fpga_dom_i2c_bus_device_data7 = { + .adap_nr = 13, + .i2c_timeout = 3000, + .i2c_scale = 0x3300, + .i2c_filter = 0x3304, + .i2c_stretch = 0x3308, + .i2c_ext_9548_exits_flag = 0x330c, + .i2c_ext_9548_addr = 0x3310, + .i2c_ext_9548_chan = 0x3314, + .i2c_in_9548_chan = 0x3318, + .i2c_slave = 0x331c, + .i2c_reg = 0x3320, + .i2c_reg_len = 0x3330, + .i2c_data_len = 0x3334, + .i2c_ctrl = 0x3338, + .i2c_status = 0x333c, + .i2c_err_vec = 0x3348, + .i2c_data_buf = 0x3380, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000080, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, +}; + +static fpga_i2c_bus_device_t fpga_dom_i2c_bus_device_data8 = { + .adap_nr = 14, + .i2c_timeout = 3000, + .i2c_scale = 0x3400, + .i2c_filter = 0x3404, + .i2c_stretch = 0x3408, + .i2c_ext_9548_exits_flag = 0x340c, + .i2c_ext_9548_addr = 0x3410, + .i2c_ext_9548_chan = 0x3414, + .i2c_in_9548_chan = 0x3418, + .i2c_slave = 0x341c, + .i2c_reg = 0x3420, + .i2c_reg_len = 0x3430, + .i2c_data_len = 0x3434, + .i2c_ctrl = 0x3438, + .i2c_status = 0x343c, + .i2c_err_vec = 0x3448, + .i2c_data_buf = 0x3480, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000100, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, +}; + +static fpga_i2c_bus_device_t fpga_dom_i2c_bus_device_data9 = { + .adap_nr = 15, + .i2c_timeout = 3000, + .i2c_scale = 0x3500, + .i2c_filter = 0x3504, + .i2c_stretch = 0x3508, + .i2c_ext_9548_exits_flag = 0x350c, + .i2c_ext_9548_addr = 0x3510, + .i2c_ext_9548_chan = 0x3514, + .i2c_in_9548_chan = 0x3518, + .i2c_slave = 0x351c, + .i2c_reg = 0x3520, + .i2c_reg_len = 0x3530, + .i2c_data_len = 0x3534, + .i2c_ctrl = 0x3538, + .i2c_status = 0x353c, + .i2c_err_vec = 0x3548, + .i2c_data_buf = 0x3580, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000200, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, +}; + +static fpga_i2c_bus_device_t fpga_dom_i2c_bus_device_data10 = { + .adap_nr = 16, + .i2c_timeout = 3000, + .i2c_scale = 0x3600, + .i2c_filter = 0x3604, + .i2c_stretch = 0x3608, + .i2c_ext_9548_exits_flag = 0x360c, + .i2c_ext_9548_addr = 0x3610, + .i2c_ext_9548_chan = 0x3614, + .i2c_in_9548_chan = 0x3618, + .i2c_slave = 0x361c, + .i2c_reg = 0x3620, + .i2c_reg_len = 0x3630, + .i2c_data_len = 0x3634, + .i2c_ctrl = 0x3638, + .i2c_status = 0x363c, + .i2c_err_vec = 0x3648, + .i2c_data_buf = 0x3680, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000400, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, +}; + +static fpga_i2c_bus_device_t fpga_dom_i2c_bus_device_data11 = { + .adap_nr = 17, + .i2c_timeout = 3000, + .i2c_scale = 0x3700, + .i2c_filter = 0x3704, + .i2c_stretch = 0x3708, + .i2c_ext_9548_exits_flag = 0x370c, + .i2c_ext_9548_addr = 0x3710, + .i2c_ext_9548_chan = 0x3714, + .i2c_in_9548_chan = 0x3718, + .i2c_slave = 0x371c, + .i2c_reg = 0x3720, + .i2c_reg_len = 0x3730, + .i2c_data_len = 0x3734, + .i2c_ctrl = 0x3738, + .i2c_status = 0x373c, + .i2c_err_vec = 0x3748, + .i2c_data_buf = 0x3780, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000800, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, +}; + +static fpga_i2c_bus_device_t fpga_dom_i2c_bus_device_data12 = { + .adap_nr = 18, + .i2c_timeout = 3000, + .i2c_scale = 0x3800, + .i2c_filter = 0x3804, + .i2c_stretch = 0x3808, + .i2c_ext_9548_exits_flag = 0x380c, + .i2c_ext_9548_addr = 0x3810, + .i2c_ext_9548_chan = 0x3814, + .i2c_in_9548_chan = 0x3818, + .i2c_slave = 0x381c, + .i2c_reg = 0x3820, + .i2c_reg_len = 0x3830, + .i2c_data_len = 0x3834, + .i2c_ctrl = 0x3838, + .i2c_status = 0x383c, + .i2c_err_vec = 0x3848, + .i2c_data_buf = 0x3880, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00001000, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, +}; + +static fpga_i2c_bus_device_t fpga_dom_i2c_bus_device_data13 = { + .adap_nr = 19, + .i2c_timeout = 3000, + .i2c_scale = 0x3900, + .i2c_filter = 0x3904, + .i2c_stretch = 0x3908, + .i2c_ext_9548_exits_flag = 0x390c, + .i2c_ext_9548_addr = 0x3910, + .i2c_ext_9548_chan = 0x3914, + .i2c_in_9548_chan = 0x3918, + .i2c_slave = 0x391c, + .i2c_reg = 0x3920, + .i2c_reg_len = 0x3930, + .i2c_data_len = 0x3934, + .i2c_ctrl = 0x3938, + .i2c_status = 0x393c, + .i2c_err_vec = 0x3948, + .i2c_data_buf = 0x3980, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00002000, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, +}; + +static fpga_i2c_bus_device_t fpga_dom_i2c_bus_device_data14 = { + .adap_nr = 20, + .i2c_timeout = 3000, + .i2c_scale = 0x3a00, + .i2c_filter = 0x3a04, + .i2c_stretch = 0x3a08, + .i2c_ext_9548_exits_flag = 0x3a0c, + .i2c_ext_9548_addr = 0x3a10, + .i2c_ext_9548_chan = 0x3a14, + .i2c_in_9548_chan = 0x3a18, + .i2c_slave = 0x3a1c, + .i2c_reg = 0x3a20, + .i2c_reg_len = 0x3a30, + .i2c_data_len = 0x3a34, + .i2c_ctrl = 0x3a38, + .i2c_status = 0x3a3c, + .i2c_err_vec = 0x3a48, + .i2c_data_buf = 0x3a80, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00004000, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, +}; + +static fpga_i2c_bus_device_t fpga_dom_i2c_bus_device_data15 = { + .adap_nr = 21, + .i2c_timeout = 3000, + .i2c_scale = 0x3b00, + .i2c_filter = 0x3b04, + .i2c_stretch = 0x3b08, + .i2c_ext_9548_exits_flag = 0x3b0c, + .i2c_ext_9548_addr = 0x3b10, + .i2c_ext_9548_chan = 0x3b14, + .i2c_in_9548_chan = 0x3b18, + .i2c_slave = 0x3b1c, + .i2c_reg = 0x3b20, + .i2c_reg_len = 0x3b30, + .i2c_data_len = 0x3b34, + .i2c_ctrl = 0x3b38, + .i2c_status = 0x3b3c, + .i2c_err_vec = 0x3b48, + .i2c_data_buf = 0x3b80, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00008000, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, +}; + +static void rg_fpga_i2c_bus_device_release(struct device *dev) +{ + return; +} + +static struct platform_device fpga_i2c_bus_device[] = { + { + .name = "rg-fpga-i2c", + .id = 1, + .dev = { + .platform_data = &fpga_i2c_bus_device_data0, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 2, + .dev = { + .platform_data = &fpga_i2c_bus_device_data1, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 3, + .dev = { + .platform_data = &fpga_i2c_bus_device_data2, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 4, + .dev = { + .platform_data = &fpga_i2c_bus_device_data3, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 5, + .dev = { + .platform_data = &fpga_dom_i2c_bus_device_data0, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 6, + .dev = { + .platform_data = &fpga_dom_i2c_bus_device_data1, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 7, + .dev = { + .platform_data = &fpga_dom_i2c_bus_device_data2, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 8, + .dev = { + .platform_data = &fpga_dom_i2c_bus_device_data3, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 9, + .dev = { + .platform_data = &fpga_dom_i2c_bus_device_data4, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 10, + .dev = { + .platform_data = &fpga_dom_i2c_bus_device_data5, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 11, + .dev = { + .platform_data = &fpga_dom_i2c_bus_device_data6, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 12, + .dev = { + .platform_data = &fpga_dom_i2c_bus_device_data7, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 13, + .dev = { + .platform_data = &fpga_dom_i2c_bus_device_data8, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 14, + .dev = { + .platform_data = &fpga_dom_i2c_bus_device_data9, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 15, + .dev = { + .platform_data = &fpga_dom_i2c_bus_device_data10, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 16, + .dev = { + .platform_data = &fpga_dom_i2c_bus_device_data11, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 17, + .dev = { + .platform_data = &fpga_dom_i2c_bus_device_data12, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 18, + .dev = { + .platform_data = &fpga_dom_i2c_bus_device_data13, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 19, + .dev = { + .platform_data = &fpga_dom_i2c_bus_device_data14, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 20, + .dev = { + .platform_data = &fpga_dom_i2c_bus_device_data15, + .release = rg_fpga_i2c_bus_device_release, + }, + }, +}; + +static int __init rg_fpga_i2c_bus_device_init(void) +{ + int i; + int ret = 0; + fpga_i2c_bus_device_t *fpga_i2c_bus_device_data; + + RG_FPGA_I2C_DEBUG_VERBOSE("enter!\n"); + for (i = 0; i < ARRAY_SIZE(fpga_i2c_bus_device); i++) { + fpga_i2c_bus_device_data = fpga_i2c_bus_device[i].dev.platform_data; + ret = platform_device_register(&fpga_i2c_bus_device[i]); + if (ret < 0) { + fpga_i2c_bus_device_data->device_flag = -1; /* device register failed, set flag -1 */ + printk(KERN_ERR "rg-fpga-i2c.%d register failed!\n", i + 1); + } else { + fpga_i2c_bus_device_data->device_flag = 0; /* device register suucess, set flag 0 */ + } + } + return 0; +} + +static void __exit rg_fpga_i2c_bus_device_exit(void) +{ + int i; + fpga_i2c_bus_device_t *fpga_i2c_bus_device_data; + + RG_FPGA_I2C_DEBUG_VERBOSE("enter!\n"); + for (i = ARRAY_SIZE(fpga_i2c_bus_device) - 1; i >= 0; i--) { + fpga_i2c_bus_device_data = fpga_i2c_bus_device[i].dev.platform_data; + if (fpga_i2c_bus_device_data->device_flag == 0) { /* device register success, need unregister */ + platform_device_unregister(&fpga_i2c_bus_device[i]); + } + } +} + +module_init(rg_fpga_i2c_bus_device_init); +module_exit(rg_fpga_i2c_bus_device_exit); +MODULE_DESCRIPTION("FPGA I2C Devices"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd@ruijie.com.cn"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_fpga_pca954x_device.c b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_fpga_pca954x_device.c new file mode 100644 index 000000000000..c9b4f6a871d2 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_fpga_pca954x_device.c @@ -0,0 +1,308 @@ +#include +#include +#include +#include +#include +#include + +#include + +static int g_rg_fpga_pca954x_device_debug = 0; +static int g_rg_fpga_pca954x_device_error = 0; + +module_param(g_rg_fpga_pca954x_device_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_fpga_pca954x_device_error, int, S_IRUGO | S_IWUSR); + +#define RG_FPGA_PCA954X_DEVICE_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_rg_fpga_pca954x_device_debug) { \ + printk(KERN_INFO "[RG_FPGA_PCA954X_DEVICE][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RG_FPGA_PCA954X_DEVICE_DEBUG_ERROR(fmt, args...) do { \ + if (g_rg_fpga_pca954x_device_error) { \ + printk(KERN_ERR "[RG_FPGA_PCA954X_DEVICE][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static fpga_pca954x_device_t fpga_pca954x_device_data0 = { + .i2c_bus = 3, + .i2c_addr = 0x77, + .pca9548_base_nr = 22, + .fpga_9548_flag = 2, + .fpga_9548_reset_flag = 1, +}; + +static fpga_pca954x_device_t fpga_pca954x_device_data1 = { + .i2c_bus = 4, + .i2c_addr = 0x71, + .pca9548_base_nr = 30, + .fpga_9548_flag = 2, + .fpga_9548_reset_flag = 1, +}; + +static fpga_pca954x_device_t fpga_pca954x_device_data2 = { + .i2c_bus = 5, + .i2c_addr = 0x77, + .pca9548_base_nr = 38, + .fpga_9548_flag = 2, + .fpga_9548_reset_flag = 1, +}; + +static fpga_pca954x_device_t fpga_pca954x_device_data3 = { + .i2c_bus = 6, + .i2c_addr = 0x70, + .pca9548_base_nr = 46, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga_pca954x_device_data4 = { + .i2c_bus = 7, + .i2c_addr = 0x70, + .pca9548_base_nr = 48, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga_pca954x_device_data5 = { + .i2c_bus = 8, + .i2c_addr = 0x70, + .pca9548_base_nr = 50, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga_pca954x_device_data6 = { + .i2c_bus = 9, + .i2c_addr = 0x70, + .pca9548_base_nr = 52, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga_pca954x_device_data7 = { + .i2c_bus = 10, + .i2c_addr = 0x70, + .pca9548_base_nr = 54, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga_pca954x_device_data8 = { + .i2c_bus = 11, + .i2c_addr = 0x70, + .pca9548_base_nr = 56, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga_pca954x_device_data9 = { + .i2c_bus = 12, + .i2c_addr = 0x70, + .pca9548_base_nr = 58, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga_pca954x_device_data10 = { + .i2c_bus = 13, + .i2c_addr = 0x70, + .pca9548_base_nr = 60, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga_pca954x_device_data11 = { + .i2c_bus = 14, + .i2c_addr = 0x70, + .pca9548_base_nr = 62, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga_pca954x_device_data12 = { + .i2c_bus = 15, + .i2c_addr = 0x70, + .pca9548_base_nr = 64, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga_pca954x_device_data13 = { + .i2c_bus = 16, + .i2c_addr = 0x70, + .pca9548_base_nr = 66, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga_pca954x_device_data14 = { + .i2c_bus = 17, + .i2c_addr = 0x70, + .pca9548_base_nr = 68, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga_pca954x_device_data15 = { + .i2c_bus = 18, + .i2c_addr = 0x70, + .pca9548_base_nr = 70, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga_pca954x_device_data16 = { + .i2c_bus = 19, + .i2c_addr = 0x70, + .pca9548_base_nr = 72, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga_pca954x_device_data17 = { + .i2c_bus = 20, + .i2c_addr = 0x70, + .pca9548_base_nr = 74, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga_pca954x_device_data18 = { + .i2c_bus = 21, + .i2c_addr = 0x70, + .pca9548_base_nr = 76, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +struct i2c_board_info fpga_pca954x_device_info[] = { + { + .type = "rg_fpga_pca9548", + .platform_data = &fpga_pca954x_device_data0, + }, + { + .type = "rg_fpga_pca9548", + .platform_data = &fpga_pca954x_device_data1, + }, + { + .type = "rg_fpga_pca9548", + .platform_data = &fpga_pca954x_device_data2, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga_pca954x_device_data3, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga_pca954x_device_data4, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga_pca954x_device_data5, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga_pca954x_device_data6, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga_pca954x_device_data7, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga_pca954x_device_data8, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga_pca954x_device_data9, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga_pca954x_device_data10, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga_pca954x_device_data11, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga_pca954x_device_data12, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga_pca954x_device_data13, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga_pca954x_device_data14, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga_pca954x_device_data15, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga_pca954x_device_data16, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga_pca954x_device_data17, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga_pca954x_device_data18, + }, +}; + +static int __init rg_fpga_pca954x_device_init(void) +{ + int i; + struct i2c_adapter *adap; + struct i2c_client *client; + fpga_pca954x_device_t *fpga_pca954x_device_data; + + RG_FPGA_PCA954X_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = 0; i < ARRAY_SIZE(fpga_pca954x_device_info); i++) { + fpga_pca954x_device_data = fpga_pca954x_device_info[i].platform_data; + fpga_pca954x_device_info[i].addr = fpga_pca954x_device_data->i2c_addr; + adap = i2c_get_adapter(fpga_pca954x_device_data->i2c_bus); + if (adap == NULL) { + fpga_pca954x_device_data->client = NULL; + printk(KERN_ERR "get i2c bus %d adapter fail.\n", fpga_pca954x_device_data->i2c_bus); + continue; + } + client = i2c_new_client_device(adap, &fpga_pca954x_device_info[i]); + if (!client) { + fpga_pca954x_device_data->client = NULL; + printk(KERN_ERR "Failed to register fpga pca954x device %d at bus %d!\n", + fpga_pca954x_device_data->i2c_addr, fpga_pca954x_device_data->i2c_bus); + } else { + fpga_pca954x_device_data->client = client; + } + i2c_put_adapter(adap); + } + return 0; +} + +static void __exit rg_fpga_pca954x_device_exit(void) +{ + int i; + fpga_pca954x_device_t *fpga_pca954x_device_data; + + RG_FPGA_PCA954X_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = ARRAY_SIZE(fpga_pca954x_device_info) - 1; i >= 0; i--) { + fpga_pca954x_device_data = fpga_pca954x_device_info[i].platform_data; + if (fpga_pca954x_device_data->client) { + i2c_unregister_device(fpga_pca954x_device_data->client); + fpga_pca954x_device_data->client = NULL; + } + } +} + +module_init(rg_fpga_pca954x_device_init); +module_exit(rg_fpga_pca954x_device_exit); +MODULE_DESCRIPTION("RG FPGA PCA954X Devices"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd@ruijie.com.cn"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_i2c_dev_device.c b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_i2c_dev_device.c new file mode 100644 index 000000000000..84140e8c6cad --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_i2c_dev_device.c @@ -0,0 +1,155 @@ +#include +#include +#include +#include +#include +#include + +#include + +static int g_rg_i2c_dev_device_debug = 0; +static int g_rg_i2c_dev_device_error = 0; + +module_param(g_rg_i2c_dev_device_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_i2c_dev_device_error, int, S_IRUGO | S_IWUSR); + +#define RG_I2C_DEV_DEVICE_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_rg_i2c_dev_device_debug) { \ + printk(KERN_INFO "[RG_I2C_DEV_DEVICE][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RG_I2C_DEV_DEVICE_DEBUG_ERROR(fmt, args...) do { \ + if (g_rg_i2c_dev_device_error) { \ + printk(KERN_ERR "[RG_I2C_DEV_DEVICE][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static i2c_dev_device_t i2c_dev_device_data0 = { + .i2c_bus = 2, + .i2c_addr = 0x1d, + .i2c_name = "cpld4", + .data_bus_width = 1, + .addr_bus_width = 1, + .per_rd_len = 256, + .per_wr_len = 256, + .i2c_len = 256, +}; + +static i2c_dev_device_t i2c_dev_device_data1 = { + .i2c_bus = 2, + .i2c_addr = 0x2d, + .i2c_name = "cpld5", + .data_bus_width = 1, + .addr_bus_width = 1, + .per_rd_len = 256, + .per_wr_len = 256, + .i2c_len = 256, +}; + +static i2c_dev_device_t i2c_dev_device_data2 = { + .i2c_bus = 4, + .i2c_addr = 0x3d, + .i2c_name = "cpld6", + .data_bus_width = 1, + .addr_bus_width = 1, + .per_rd_len = 256, + .per_wr_len = 256, + .i2c_len = 256, +}; + +static i2c_dev_device_t i2c_dev_device_data3 = { + .i2c_bus = 2, + .i2c_addr = 0x1e, + .i2c_name = "cpld7", + .data_bus_width = 1, + .addr_bus_width = 2, + .per_rd_len = 256, + .per_wr_len = 256, + .i2c_len = 0x2000, +}; + +static i2c_dev_device_t i2c_dev_device_data4 = { + .i2c_bus = 4, + .i2c_addr = 0x3e, + .i2c_name = "cpld8", + .data_bus_width = 1, + .addr_bus_width = 2, + .per_rd_len = 256, + .per_wr_len = 256, + .i2c_len = 0x2000, +}; + +struct i2c_board_info i2c_dev_device_info[] = { + { + .type = "rg-i2c-dev", + .platform_data = &i2c_dev_device_data0, + }, + { + .type = "rg-i2c-dev", + .platform_data = &i2c_dev_device_data1, + }, + { + .type = "rg-i2c-dev", + .platform_data = &i2c_dev_device_data2, + }, + { + .type = "rg-i2c-dev", + .platform_data = &i2c_dev_device_data3, + }, + { + .type = "rg-i2c-dev", + .platform_data = &i2c_dev_device_data4, + }, +}; + +static int __init rg_i2c_dev_device_init(void) +{ + int i; + struct i2c_adapter *adap; + struct i2c_client *client; + i2c_dev_device_t *i2c_dev_device_data; + + RG_I2C_DEV_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = 0; i < ARRAY_SIZE(i2c_dev_device_info); i++) { + i2c_dev_device_data = i2c_dev_device_info[i].platform_data; + i2c_dev_device_info[i].addr = i2c_dev_device_data->i2c_addr; + adap = i2c_get_adapter(i2c_dev_device_data->i2c_bus); + if (adap == NULL) { + i2c_dev_device_data->client = NULL; + printk(KERN_ERR "get i2c bus %d adapter fail.\n", i2c_dev_device_data->i2c_bus); + continue; + } + client = i2c_new_client_device(adap, &i2c_dev_device_info[i]); + if (!client) { + i2c_dev_device_data->client = NULL; + printk(KERN_ERR "Failed to register i2c dev device %d at bus %d!\n", + i2c_dev_device_data->i2c_addr, i2c_dev_device_data->i2c_bus); + } else { + i2c_dev_device_data->client = client; + } + i2c_put_adapter(adap); + } + return 0; +} + +static void __exit rg_i2c_dev_device_exit(void) +{ + int i; + i2c_dev_device_t *i2c_dev_device_data; + + RG_I2C_DEV_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = ARRAY_SIZE(i2c_dev_device_info) - 1; i >= 0; i--) { + i2c_dev_device_data = i2c_dev_device_info[i].platform_data; + if (i2c_dev_device_data->client) { + i2c_unregister_device(i2c_dev_device_data->client); + i2c_dev_device_data->client = NULL; + } + } +} + +module_init(rg_i2c_dev_device_init); +module_exit(rg_i2c_dev_device_exit); +MODULE_DESCRIPTION("RG I2C DEV Devices"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd@ruijie.com.cn"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_io_dev_device.c b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_io_dev_device.c new file mode 100644 index 000000000000..104fcfb8ad4b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_io_dev_device.c @@ -0,0 +1,138 @@ +#include +#include +#include +#include +#include + +#include + +static int g_rg_io_dev_device_debug = 0; +static int g_rg_io_dev_device_error = 0; + +module_param(g_rg_io_dev_device_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_io_dev_device_error, int, S_IRUGO | S_IWUSR); + +#define RG_IO_DEV_DEVICE_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_rg_io_dev_device_debug) { \ + printk(KERN_INFO "[RG_IO_DEV_DEVICE][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RG_IO_DEV_DEVICE_DEBUG_ERROR(fmt, args...) do { \ + if (g_rg_io_dev_device_error) { \ + printk(KERN_ERR "[RG_IO_DEV_DEVICE][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static io_dev_device_t io_dev_device_data0 = { + .io_dev_name = "cpld0", + .io_base = 0x700, + .io_len = 0x100, + .indirect_addr = 0, +}; + +static io_dev_device_t io_dev_device_data1 = { + .io_dev_name = "cpld1", + .io_base = 0x900, + .io_len = 0x100, + .indirect_addr = 0, +}; + +static io_dev_device_t io_dev_device_data2 = { + .io_dev_name = "cpld2", + .io_base = 0xb00, + .io_len = 0x100, + .indirect_addr = 0, +}; + +static io_dev_device_t io_dev_device_data3 = { + .io_dev_name = "cpld3", + .io_base = 0x900, + .io_len = 0x2000, + .indirect_addr = 1, + .wr_data = 0xfb, + .addr_low = 0xfc, + .addr_high = 0xfd, + .rd_data = 0xfe, + .opt_ctl = 0xff, +}; + +static void rg_io_dev_device_release(struct device *dev) +{ + return; +} + +static struct platform_device io_dev_device[] = { + { + .name = "rg-io-dev", + .id = 1, + .dev = { + .platform_data = &io_dev_device_data0, + .release = rg_io_dev_device_release, + }, + }, + { + .name = "rg-io-dev", + .id = 2, + .dev = { + .platform_data = &io_dev_device_data1, + .release = rg_io_dev_device_release, + }, + }, + { + .name = "rg-io-dev", + .id = 3, + .dev = { + .platform_data = &io_dev_device_data2, + .release = rg_io_dev_device_release, + }, + }, + { + .name = "rg-io-dev", + .id = 4, + .dev = { + .platform_data = &io_dev_device_data3, + .release = rg_io_dev_device_release, + }, + }, +}; + +static int __init rg_io_dev_device_init(void) +{ + int i; + int ret = 0; + io_dev_device_t *io_dev_device_data; + + RG_IO_DEV_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = 0; i < ARRAY_SIZE(io_dev_device); i++) { + io_dev_device_data = io_dev_device[i].dev.platform_data; + ret = platform_device_register(&io_dev_device[i]); + if (ret < 0) { + io_dev_device_data->device_flag = -1; /* device register failed, set flag -1 */ + printk(KERN_ERR "rg-io-dev.%d register failed!\n", i + 1); + } else { + io_dev_device_data->device_flag = 0; /* device register suucess, set flag 0 */ + } + } + return 0; +} + +static void __exit rg_io_dev_device_exit(void) +{ + int i; + io_dev_device_t *io_dev_device_data; + + RG_IO_DEV_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = ARRAY_SIZE(io_dev_device) - 1; i >= 0; i--) { + io_dev_device_data = io_dev_device[i].dev.platform_data; + if (io_dev_device_data->device_flag == 0) { /* device register success, need unregister */ + platform_device_unregister(&io_dev_device[i]); + } + } +} + +module_init(rg_io_dev_device_init); +module_exit(rg_io_dev_device_exit); +MODULE_DESCRIPTION("RG IO DEV Devices"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd@ruijie.com.cn"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_lpc_drv_device.c b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_lpc_drv_device.c new file mode 100644 index 000000000000..fb34291555a0 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_lpc_drv_device.c @@ -0,0 +1,130 @@ +#include +#include +#include +#include +#include + +#include + +static int g_rg_lpc_drv_device_debug = 0; +static int g_rg_lpc_drv_device_error = 0; + +module_param(g_rg_lpc_drv_device_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_lpc_drv_device_error, int, S_IRUGO | S_IWUSR); + +#define RG_LPC_DRV_DEVICE_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_rg_lpc_drv_device_debug) { \ + printk(KERN_INFO "[RG_LPC_DRV_DEVICE][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RG_LPC_DRV_DEVICE_DEBUG_ERROR(fmt, args...) do { \ + if (g_rg_lpc_drv_device_error) { \ + printk(KERN_ERR "[RG_LPC_DRV_DEVICE][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static lpc_drv_device_t lpc_drv_device_data_0 = { + .lpc_io_name = "rg_lpc", + .pci_domain = 0x0000, + .pci_bus = 0x00, + .pci_slot = 0x1f, + .pci_fn = 0, + .lpc_io_base = 0x700, + .lpc_io_size = 0x100, + .lpc_gen_dec = 0x84, +}; + +static lpc_drv_device_t lpc_drv_device_data_1 = { + .lpc_io_name = "rg_lpc", + .pci_domain = 0x0000, + .pci_bus = 0x00, + .pci_slot = 0x1f, + .pci_fn = 0, + .lpc_io_base = 0x900, + .lpc_io_size = 0x100, + .lpc_gen_dec = 0x88, +}; + +static lpc_drv_device_t lpc_drv_device_data_2 = { + .lpc_io_name = "rg_lpc", + .pci_domain = 0x0000, + .pci_bus = 0x00, + .pci_slot = 0x1f, + .pci_fn = 0, + .lpc_io_base = 0xb00, + .lpc_io_size = 0x100, + .lpc_gen_dec = 0x90, +}; + +static void rg_lpc_drv_device_release(struct device *dev) +{ + return; +} + +static struct platform_device lpc_drv_device[] = { + { + .name = "rg-lpc", + .id = 1, + .dev = { + .platform_data = &lpc_drv_device_data_0, + .release = rg_lpc_drv_device_release, + }, + }, + { + .name = "rg-lpc", + .id = 2, + .dev = { + .platform_data = &lpc_drv_device_data_1, + .release = rg_lpc_drv_device_release, + }, + }, + { + .name = "rg-lpc", + .id = 3, + .dev = { + .platform_data = &lpc_drv_device_data_2, + .release = rg_lpc_drv_device_release, + }, + }, +}; + +static int __init rg_lpc_drv_device_init(void) +{ + int i; + int ret = 0; + lpc_drv_device_t *lpc_drv_device_data; + + RG_LPC_DRV_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = 0; i < ARRAY_SIZE(lpc_drv_device); i++) { + lpc_drv_device_data = lpc_drv_device[i].dev.platform_data; + ret = platform_device_register(&lpc_drv_device[i]); + if (ret < 0) { + lpc_drv_device_data->device_flag = -1; /* device register failed, set flag -1 */ + printk(KERN_ERR "rg-lpc.%d register failed!\n", i + 1); + } else { + lpc_drv_device_data->device_flag = 0; /* device register suucess, set flag 0 */ + } + } + return 0; +} + +static void __exit rg_lpc_drv_device_exit(void) +{ + int i; + lpc_drv_device_t *lpc_drv_device_data; + + RG_LPC_DRV_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = ARRAY_SIZE(lpc_drv_device) - 1; i >= 0; i--) { + lpc_drv_device_data = lpc_drv_device[i].dev.platform_data; + if (lpc_drv_device_data->device_flag == 0) { /* device register success, need unregister */ + platform_device_unregister(&lpc_drv_device[i]); + } + } +} + +module_init(rg_lpc_drv_device_init); +module_exit(rg_lpc_drv_device_exit); +MODULE_DESCRIPTION("RG LPC DRV Devices"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd@ruijie.com.cn"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_pcie_dev_device.c b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_pcie_dev_device.c new file mode 100644 index 000000000000..ee7992c0e96f --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_pcie_dev_device.c @@ -0,0 +1,93 @@ +#include +#include +#include +#include +#include + +#include + +static int g_rg_pcie_dev_device_debug = 0; +static int g_rg_pcie_dev_device_error = 0; + +module_param(g_rg_pcie_dev_device_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_pcie_dev_device_error, int, S_IRUGO | S_IWUSR); + +#define RG_PCIE_DEV_DEVICE_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_rg_pcie_dev_device_debug) { \ + printk(KERN_INFO "[RG_PCIE_DEV_DEVICE][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RG_PCIE_DEV_DEVICE_DEBUG_ERROR(fmt, args...) do { \ + if (g_rg_pcie_dev_device_error) { \ + printk(KERN_ERR "[RG_PCIE_DEV_DEVICE][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static pci_dev_device_t pcie_dev_device_data0 = { + .pci_dev_name = "fpga0", + .pci_domain = 0x0000, + .pci_bus = 0x08, + .pci_slot = 0x00, + .pci_fn = 0, + .pci_bar = 0, + .bus_width = 4, + .upg_ctrl_base = 0xa00, + .upg_flash_base = 0x2f0000, +}; + +static void rg_pcie_dev_device_release(struct device *dev) +{ + return; +} + +static struct platform_device pcie_dev_device[] = { + { + .name = "rg-pci-dev", + .id = 1, + .dev = { + .platform_data = &pcie_dev_device_data0, + .release = rg_pcie_dev_device_release, + }, + }, +}; + +static int __init rg_pcie_dev_device_init(void) +{ + int i; + int ret = 0; + pci_dev_device_t *pcie_dev_device_data; + + RG_PCIE_DEV_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = 0; i < ARRAY_SIZE(pcie_dev_device); i++) { + pcie_dev_device_data = pcie_dev_device[i].dev.platform_data; + ret = platform_device_register(&pcie_dev_device[i]); + if (ret < 0) { + pcie_dev_device_data->device_flag = -1; /* device register failed, set flag -1 */ + printk(KERN_ERR "rg-pci-dev.%d register failed!\n", i + 1); + } else { + pcie_dev_device_data->device_flag = 0; /* device register suucess, set flag 0 */ + } + } + return 0; +} + +static void __exit rg_pcie_dev_device_exit(void) +{ + int i; + pci_dev_device_t *pcie_dev_device_data; + + RG_PCIE_DEV_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = ARRAY_SIZE(pcie_dev_device) - 1; i >= 0; i--) { + pcie_dev_device_data = pcie_dev_device[i].dev.platform_data; + if (pcie_dev_device_data->device_flag == 0) { /* device register success, need unregister */ + platform_device_unregister(&pcie_dev_device[i]); + } + } +} + +module_init(rg_pcie_dev_device_init); +module_exit(rg_pcie_dev_device_exit); +MODULE_DESCRIPTION("RG PCIE DEV Devices"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd@ruijie.com.cn"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_wdt_device.c b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_wdt_device.c new file mode 100644 index 000000000000..5296c239fd8e --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_wdt_device.c @@ -0,0 +1,104 @@ +#include +#include +#include +#include +#include + +#include + +static int g_rg_wdt_device_debug = 0; +static int g_rg_wdt_device_error = 0; + +module_param(g_rg_wdt_device_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_wdt_device_error, int, S_IRUGO | S_IWUSR); + +#define RG_WDT_DEVICE_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_rg_wdt_device_debug) { \ + printk(KERN_INFO "[RG_WDT_DEVICE][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RG_WDT_DEVICE_DEBUG_ERROR(fmt, args...) do { \ + if (g_rg_wdt_device_error) { \ + printk(KERN_ERR "[RG_WDT_DEVICE][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static rg_wdt_device_t rg_wdt_device_data_0 = { + .feed_wdt_type = 2, + .hw_margin = 180000, + .feed_time = 30000, + .config_dev_name = "/dev/cpld5", + .config_mode = 2, + .priv_func_mode = 4, + .enable_reg = 0x4c, + .enable_val = 0x1, + .disable_val = 0x0, + .enable_mask = 0x1, + .timeout_cfg_reg = 0x4d, + .hw_algo = "toggle", + .wdt_config_mode.logic_wdt = { + .feed_dev_name = "/dev/cpld5", + .feed_reg = 0x4c, + .active_val = 0x1, + .logic_func_mode = 0x1, + }, + .timer_accuracy = 6000, /* 6s */ + .sysfs_index = SYSFS_NO_CFG, +}; + +static void rg_wdt_device_release(struct device *dev) +{ + return; +} + +static struct platform_device rg_wdt_device[] = { + { + .name = "rg_wdt", + .id = 0, + .dev = { + .platform_data = &rg_wdt_device_data_0, + .release = rg_wdt_device_release, + }, + }, +}; + +static int __init rg_wdt_device_init(void) +{ + int i; + int ret = 0; + rg_wdt_device_t *rg_wdt_device_data; + + RG_WDT_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = 0; i < ARRAY_SIZE(rg_wdt_device); i++) { + rg_wdt_device_data = rg_wdt_device[i].dev.platform_data; + ret = platform_device_register(&rg_wdt_device[i]); + if (ret < 0) { + rg_wdt_device_data->device_flag = -1; /* device register failed, set flag -1 */ + printk(KERN_ERR "rg-wdt.%d register failed!\n", i + 1); + } else { + rg_wdt_device_data->device_flag = 0; /* device register suucess, set flag 0 */ + } + } + return 0; +} + +static void __exit rg_wdt_device_exit(void) +{ + int i; + rg_wdt_device_t *rg_wdt_device_data; + + RG_WDT_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = ARRAY_SIZE(rg_wdt_device) - 1; i >= 0; i--) { + rg_wdt_device_data = rg_wdt_device[i].dev.platform_data; + if (rg_wdt_device_data->device_flag == 0) { /* device register success, need unregister */ + platform_device_unregister(&rg_wdt_device[i]); + } + } +} + +module_init(rg_wdt_device_init); +module_exit(rg_wdt_device_exit); +MODULE_DESCRIPTION("RG WDT Devices"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd@ruijie.com.cn"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/plat_sysfs_cfg/TCS8400-CPLD.cfg b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/plat_sysfs_cfg/TCS8400-CPLD.cfg new file mode 100755 index 000000000000..a5f56d5cddb2 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/plat_sysfs_cfg/TCS8400-CPLD.cfg @@ -0,0 +1,20 @@ +#cpld_id: 0:CPLD_A 1:CPLD_B +cpld_i2c_dev.bus_0_2=2 +cpld_i2c_dev.addr_0_2=0x1d +cpld_i2c_dev.bus_0_3=2 +cpld_i2c_dev.addr_0_3=0x2d +cpld_i2c_dev.bus_0_4=4 +cpld_i2c_dev.addr_0_4=0x3d + +#cpld_id: 0:X86_CPLD, 1:MAC_CPLDA, 2:MAC_CPLDB +cpld_lpc_dev_0_0=0x700 +cpld_lpc_dev_0_1=0x900 + +mode_cpld_0_0=lpc +mode_cpld_0_1=lpc +mode_cpld_0_2=i2c +mode_cpld_0_3=i2c +mode_cpld_0_4=i2c + +# cpld number +dev_num_4_0=5 diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/plat_sysfs_cfg/TCS8400-FAN.cfg b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/plat_sysfs_cfg/TCS8400-FAN.cfg new file mode 100755 index 000000000000..9a95a177d00b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/plat_sysfs_cfg/TCS8400-FAN.cfg @@ -0,0 +1,413 @@ +# fan number +dev_num_1_0=6 + +# fan motor number +dev_num_1_5=2 + +dev_present_status.mode_1_1=config +dev_present_status.src_1_1=cpld +dev_present_status.frmt_1_1=bit +dev_present_status.pola_1_1=negative +dev_present_status.addr_1_1=0x00040037 +dev_present_status.len_1_1=1 +dev_present_status.bit_offset_1_1=5 + +dev_present_status.mode_1_2=config +dev_present_status.src_1_2=cpld +dev_present_status.frmt_1_2=bit +dev_present_status.pola_1_2=negative +dev_present_status.addr_1_2=0x00040037 +dev_present_status.len_1_2=1 +dev_present_status.bit_offset_1_2=4 + +dev_present_status.mode_1_3=config +dev_present_status.src_1_3=cpld +dev_present_status.frmt_1_3=bit +dev_present_status.pola_1_3=negative +dev_present_status.addr_1_3=0x00040037 +dev_present_status.len_1_3=1 +dev_present_status.bit_offset_1_3=3 + +dev_present_status.mode_1_4=config +dev_present_status.src_1_4=cpld +dev_present_status.frmt_1_4=bit +dev_present_status.pola_1_4=negative +dev_present_status.addr_1_4=0x00040037 +dev_present_status.len_1_4=1 +dev_present_status.bit_offset_1_4=2 + +dev_present_status.mode_1_5=config +dev_present_status.src_1_5=cpld +dev_present_status.frmt_1_5=bit +dev_present_status.pola_1_5=negative +dev_present_status.addr_1_5=0x00040037 +dev_present_status.len_1_5=1 +dev_present_status.bit_offset_1_5=1 + +dev_present_status.mode_1_6=config +dev_present_status.src_1_6=cpld +dev_present_status.frmt_1_6=bit +dev_present_status.pola_1_6=negative +dev_present_status.addr_1_6=0x00040037 +dev_present_status.len_1_6=1 +dev_present_status.bit_offset_1_6=0 + +fan_roll_status.mode_1_0=config +fan_roll_status.int_cons_1_0= +fan_roll_status.src_1_0=cpld +fan_roll_status.frmt_1_0=bit +fan_roll_status.pola_1_0=positive +fan_roll_status.fpath_1_0= +fan_roll_status.addr_1_0=0x00040038 +fan_roll_status.len_1_0=1 +fan_roll_status.bit_offset_1_0=5 + +fan_roll_status.mode_1_1=config +fan_roll_status.int_cons_1_1= +fan_roll_status.src_1_1=cpld +fan_roll_status.frmt_1_1=bit +fan_roll_status.pola_1_1=positive +fan_roll_status.fpath_1_1= +fan_roll_status.addr_1_1=0x00040039 +fan_roll_status.len_1_1=1 +fan_roll_status.bit_offset_1_1=5 + +fan_roll_status.mode_2_0=config +fan_roll_status.int_cons_2_0= +fan_roll_status.src_2_0=cpld +fan_roll_status.frmt_2_0=bit +fan_roll_status.pola_2_0=positive +fan_roll_status.fpath_2_0= +fan_roll_status.addr_2_0=0x00040038 +fan_roll_status.len_2_0=1 +fan_roll_status.bit_offset_2_0=4 + +fan_roll_status.mode_2_1=config +fan_roll_status.int_cons_2_1= +fan_roll_status.src_2_1=cpld +fan_roll_status.frmt_2_1=bit +fan_roll_status.pola_2_1=positive +fan_roll_status.fpath_2_1= +fan_roll_status.addr_2_1=0x00040039 +fan_roll_status.len_2_1=1 +fan_roll_status.bit_offset_2_1=4 + +fan_roll_status.mode_3_0=config +fan_roll_status.int_cons_3_0= +fan_roll_status.src_3_0=cpld +fan_roll_status.frmt_3_0=bit +fan_roll_status.pola_3_0=positive +fan_roll_status.fpath_3_0= +fan_roll_status.addr_3_0=0x00040038 +fan_roll_status.len_3_0=1 +fan_roll_status.bit_offset_3_0=3 + +fan_roll_status.mode_3_1=config +fan_roll_status.int_cons_3_1= +fan_roll_status.src_3_1=cpld +fan_roll_status.frmt_3_1=bit +fan_roll_status.pola_3_1=positive +fan_roll_status.fpath_3_1= +fan_roll_status.addr_3_1=0x00040039 +fan_roll_status.len_3_1=1 +fan_roll_status.bit_offset_3_1=3 + +fan_roll_status.mode_4_0=config +fan_roll_status.int_cons_4_0= +fan_roll_status.src_4_0=cpld +fan_roll_status.frmt_4_0=bit +fan_roll_status.pola_4_0=positive +fan_roll_status.fpath_4_0= +fan_roll_status.addr_4_0=0x00040038 +fan_roll_status.len_4_0=1 +fan_roll_status.bit_offset_4_0=2 + +fan_roll_status.mode_4_1=config +fan_roll_status.int_cons_4_1= +fan_roll_status.src_4_1=cpld +fan_roll_status.frmt_4_1=bit +fan_roll_status.pola_4_1=positive +fan_roll_status.fpath_4_1= +fan_roll_status.addr_4_1=0x00040039 +fan_roll_status.len_4_1=1 +fan_roll_status.bit_offset_4_1=2 + +fan_roll_status.mode_5_0=config +fan_roll_status.int_cons_5_0= +fan_roll_status.src_5_0=cpld +fan_roll_status.frmt_5_0=bit +fan_roll_status.pola_5_0=positive +fan_roll_status.fpath_5_0= +fan_roll_status.addr_5_0=0x00040038 +fan_roll_status.len_5_0=1 +fan_roll_status.bit_offset_5_0=1 + +fan_roll_status.mode_5_1=config +fan_roll_status.int_cons_5_1= +fan_roll_status.src_5_1=cpld +fan_roll_status.frmt_5_1=bit +fan_roll_status.pola_5_1=positive +fan_roll_status.fpath_5_1= +fan_roll_status.addr_5_1=0x00040039 +fan_roll_status.len_5_1=1 +fan_roll_status.bit_offset_5_1=1 + +fan_roll_status.mode_6_0=config +fan_roll_status.int_cons_6_0= +fan_roll_status.src_6_0=cpld +fan_roll_status.frmt_6_0=bit +fan_roll_status.pola_6_0=positive +fan_roll_status.fpath_6_0= +fan_roll_status.addr_6_0=0x00040038 +fan_roll_status.len_6_0=1 +fan_roll_status.bit_offset_6_0=0 + +fan_roll_status.mode_6_1=config +fan_roll_status.int_cons_6_1= +fan_roll_status.src_6_1=cpld +fan_roll_status.frmt_6_1=bit +fan_roll_status.pola_6_1=positive +fan_roll_status.fpath_6_1= +fan_roll_status.addr_6_1=0x00040039 +fan_roll_status.len_6_1=1 +fan_roll_status.bit_offset_6_1=0 + +fan_speed.mode_1_0=config +fan_speed.int_cons_1_0= +fan_speed.src_1_0=cpld +fan_speed.frmt_1_0=num_bytes +fan_speed.pola_1_0=negative +fan_speed.fpath_1_0= +fan_speed.addr_1_0=0x00040070 +fan_speed.len_1_0=2 +fan_speed.bit_offset_1_0= + +fan_speed.mode_1_1=config +fan_speed.int_cons_1_1= +fan_speed.src_1_1=cpld +fan_speed.frmt_1_1=num_bytes +fan_speed.pola_1_1=negative +fan_speed.fpath_1_1= +fan_speed.addr_1_1=0x0004007c +fan_speed.len_1_1=2 +fan_speed.bit_offset_1_1= + +fan_speed.mode_2_0=config +fan_speed.int_cons_2_0= +fan_speed.src_2_0=cpld +fan_speed.frmt_2_0=num_bytes +fan_speed.pola_2_0=negative +fan_speed.fpath_2_0= +fan_speed.addr_2_0=0x0004006e +fan_speed.len_2_0=2 +fan_speed.bit_offset_2_0= + +fan_speed.mode_2_1=config +fan_speed.int_cons_2_1= +fan_speed.src_2_1=cpld +fan_speed.frmt_2_1=num_bytes +fan_speed.pola_2_1=negative +fan_speed.fpath_2_1= +fan_speed.addr_2_1=0x0004007a +fan_speed.len_2_1=2 +fan_speed.bit_offset_2_1= + +fan_speed.mode_3_0=config +fan_speed.int_cons_3_0= +fan_speed.src_3_0=cpld +fan_speed.frmt_3_0=num_bytes +fan_speed.pola_3_0=negative +fan_speed.fpath_3_0= +fan_speed.addr_3_0=0x0004006c +fan_speed.len_3_0=2 +fan_speed.bit_offset_3_0= + +fan_speed.mode_3_1=config +fan_speed.int_cons_3_1= +fan_speed.src_3_1=cpld +fan_speed.frmt_3_1=num_bytes +fan_speed.pola_3_1=negative +fan_speed.fpath_3_1= +fan_speed.addr_3_1=0x00040078 +fan_speed.len_3_1=2 +fan_speed.bit_offset_3_1= + +fan_speed.mode_4_0=config +fan_speed.int_cons_4_0= +fan_speed.src_4_0=cpld +fan_speed.frmt_4_0=num_bytes +fan_speed.pola_4_0=negative +fan_speed.fpath_4_0= +fan_speed.addr_4_0=0x0004006a +fan_speed.len_4_0=2 +fan_speed.bit_offset_4_0= + +fan_speed.mode_4_1=config +fan_speed.int_cons_4_1= +fan_speed.src_4_1=cpld +fan_speed.frmt_4_1=num_bytes +fan_speed.pola_4_1=negative +fan_speed.fpath_4_1= +fan_speed.addr_4_1=0x00040076 +fan_speed.len_4_1=2 +fan_speed.bit_offset_4_1= + +fan_speed.mode_5_0=config +fan_speed.int_cons_5_0= +fan_speed.src_5_0=cpld +fan_speed.frmt_5_0=num_bytes +fan_speed.pola_5_0=negative +fan_speed.fpath_5_0= +fan_speed.addr_5_0=0x00040068 +fan_speed.len_5_0=2 +fan_speed.bit_offset_5_0= + +fan_speed.mode_5_1=config +fan_speed.int_cons_5_1= +fan_speed.src_5_1=cpld +fan_speed.frmt_5_1=num_bytes +fan_speed.pola_5_1=negative +fan_speed.fpath_5_1= +fan_speed.addr_5_1=0x00040074 +fan_speed.len_5_1=2 +fan_speed.bit_offset_5_1= + +fan_speed.mode_6_0=config +fan_speed.int_cons_6_0= +fan_speed.src_6_0=cpld +fan_speed.frmt_6_0=num_bytes +fan_speed.pola_6_0=negative +fan_speed.fpath_6_0= +fan_speed.addr_6_0=0x00040066 +fan_speed.len_6_0=2 +fan_speed.bit_offset_6_0= + +fan_speed.mode_6_1=config +fan_speed.int_cons_6_1= +fan_speed.src_6_1=cpld +fan_speed.frmt_6_1=num_bytes +fan_speed.pola_6_1=negative +fan_speed.fpath_6_1= +fan_speed.addr_6_1=0x00040072 +fan_speed.len_6_1=2 +fan_speed.bit_offset_6_1= + +fan_ratio.mode_1_0=config +fan_ratio.int_cons_1_0= +fan_ratio.src_1_0=cpld +fan_ratio.frmt_1_0=byte +fan_ratio.pola_1_0= +fan_ratio.fpath_1_0= +fan_ratio.addr_1_0=0x00040065 +fan_ratio.len_1_0=1 +fan_ratio.bit_offset_1_0= + +fan_ratio.mode_1_1=config +fan_ratio.int_cons_1_1= +fan_ratio.src_1_1=cpld +fan_ratio.frmt_1_1=byte +fan_ratio.pola_1_1= +fan_ratio.fpath_1_1= +fan_ratio.addr_1_1=0x00040065 +fan_ratio.len_1_1=1 +fan_ratio.bit_offset_1_1= + +fan_ratio.mode_2_0=config +fan_ratio.int_cons_2_0= +fan_ratio.src_2_0=cpld +fan_ratio.frmt_2_0=byte +fan_ratio.pola_2_0= +fan_ratio.fpath_2_0= +fan_ratio.addr_2_0=0x00040064 +fan_ratio.len_2_0=1 +fan_ratio.bit_offset_2_0= + +fan_ratio.mode_2_1=config +fan_ratio.int_cons_2_1= +fan_ratio.src_2_1=cpld +fan_ratio.frmt_2_1=byte +fan_ratio.pola_2_1= +fan_ratio.fpath_2_1= +fan_ratio.addr_2_1=0x00040064 +fan_ratio.len_2_1=1 +fan_ratio.bit_offset_2_1= + +fan_ratio.mode_3_0=config +fan_ratio.int_cons_3_0= +fan_ratio.src_3_0=cpld +fan_ratio.frmt_3_0=byte +fan_ratio.pola_3_0= +fan_ratio.fpath_3_0= +fan_ratio.addr_3_0=0x00040063 +fan_ratio.len_3_0=1 +fan_ratio.bit_offset_3_0= + +fan_ratio.mode_3_1=config +fan_ratio.int_cons_3_1= +fan_ratio.src_3_1=cpld +fan_ratio.frmt_3_1=byte +fan_ratio.pola_3_1= +fan_ratio.fpath_3_1= +fan_ratio.addr_3_1=0x00040063 +fan_ratio.len_3_1=1 +fan_ratio.bit_offset_3_1= + +fan_ratio.mode_4_0=config +fan_ratio.int_cons_4_0= +fan_ratio.src_4_0=cpld +fan_ratio.frmt_4_0=byte +fan_ratio.pola_4_0= +fan_ratio.fpath_4_0= +fan_ratio.addr_4_0=0x00040062 +fan_ratio.len_4_0=1 +fan_ratio.bit_offset_4_0= + +fan_ratio.mode_4_1=config +fan_ratio.int_cons_4_1= +fan_ratio.src_4_1=cpld +fan_ratio.frmt_4_1=byte +fan_ratio.pola_4_1= +fan_ratio.fpath_4_1= +fan_ratio.addr_4_1=0x00040062 +fan_ratio.len_4_1=1 +fan_ratio.bit_offset_4_1= + +fan_ratio.mode_5_0=config +fan_ratio.int_cons_5_0= +fan_ratio.src_5_0=cpld +fan_ratio.frmt_5_0=byte +fan_ratio.pola_5_0= +fan_ratio.fpath_5_0= +fan_ratio.addr_5_0=0x00040061 +fan_ratio.len_5_0=1 +fan_ratio.bit_offset_5_0= + +fan_ratio.mode_5_1=config +fan_ratio.int_cons_5_1= +fan_ratio.src_5_1=cpld +fan_ratio.frmt_5_1=byte +fan_ratio.pola_5_1= +fan_ratio.fpath_5_1= +fan_ratio.addr_5_1=0x00040061 +fan_ratio.len_5_1=1 +fan_ratio.bit_offset_5_1= + +fan_ratio.mode_6_0=config +fan_ratio.int_cons_6_0= +fan_ratio.src_6_0=cpld +fan_ratio.frmt_6_0=byte +fan_ratio.pola_6_0= +fan_ratio.fpath_6_0= +fan_ratio.addr_6_0=0x00040060 +fan_ratio.len_6_0=1 +fan_ratio.bit_offset_6_0= + +fan_ratio.mode_6_1=config +fan_ratio.int_cons_6_1= +fan_ratio.src_6_1=cpld +fan_ratio.frmt_6_1=byte +fan_ratio.pola_6_1= +fan_ratio.fpath_6_1= +fan_ratio.addr_6_1=0x00040060 +fan_ratio.len_6_1=1 +fan_ratio.bit_offset_6_1= \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/plat_sysfs_cfg/TCS8400-PSU.cfg b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/plat_sysfs_cfg/TCS8400-PSU.cfg new file mode 100755 index 000000000000..687d9037d09e --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/plat_sysfs_cfg/TCS8400-PSU.cfg @@ -0,0 +1,50 @@ +#psu number +dev_num_2_0=2 + +psu_status.mode_1_0=config +psu_status.src_1_0=cpld +psu_status.frmt_1_0=bit +psu_status.pola_1_0=negative +psu_status.addr_1_0=0x00020034 +psu_status.len_1_0=1 +psu_status.bit_offset_1_0=0 + +psu_status.mode_1_1=config +psu_status.src_1_1=cpld +psu_status.frmt_1_1=bit +psu_status.pola_1_1=positive +psu_status.addr_1_1=0x00020034 +psu_status.len_1_1=1 +psu_status.bit_offset_1_1=1 + +psu_status.mode_1_2=config +psu_status.src_1_2=cpld +psu_status.frmt_1_2=bit +psu_status.pola_1_2=negative +psu_status.addr_1_2=0x00020034 +psu_status.len_1_2=1 +psu_status.bit_offset_1_2=2 + +psu_status.mode_2_0=config +psu_status.src_2_0=cpld +psu_status.frmt_2_0=bit +psu_status.pola_2_0=negative +psu_status.addr_2_0=0x00020034 +psu_status.len_2_0=1 +psu_status.bit_offset_2_0=4 + +psu_status.mode_2_1=config +psu_status.src_2_1=cpld +psu_status.frmt_2_1=bit +psu_status.pola_2_1=positive +psu_status.addr_2_1=0x00020034 +psu_status.len_2_1=1 +psu_status.bit_offset_2_1=5 + +psu_status.mode_2_2=config +psu_status.src_2_2=cpld +psu_status.frmt_2_2=bit +psu_status.pola_2_2=negative +psu_status.addr_2_2=0x00020034 +psu_status.len_2_2=1 +psu_status.bit_offset_2_2=6 \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/plat_sysfs_cfg/TCS8400-SFF.cfg b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/plat_sysfs_cfg/TCS8400-SFF.cfg new file mode 100755 index 000000000000..20c37e3d66e8 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/plat_sysfs_cfg/TCS8400-SFF.cfg @@ -0,0 +1,292 @@ +# sff number +dev_num_3_0=32 + +sff_dir_name_1 =sff1 +sff_dir_name_2 =sff2 +sff_dir_name_3 =sff3 +sff_dir_name_4 =sff4 +sff_dir_name_5 =sff5 +sff_dir_name_6 =sff6 +sff_dir_name_7 =sff7 +sff_dir_name_8 =sff8 +sff_dir_name_9 =sff9 +sff_dir_name_10 =sff10 +sff_dir_name_11 =sff11 +sff_dir_name_12 =sff12 +sff_dir_name_13 =sff13 +sff_dir_name_14 =sff14 +sff_dir_name_15 =sff15 +sff_dir_name_16 =sff16 +sff_dir_name_17 =sff17 +sff_dir_name_18 =sff18 +sff_dir_name_19 =sff19 +sff_dir_name_20 =sff20 +sff_dir_name_21 =sff21 +sff_dir_name_22 =sff22 +sff_dir_name_23 =sff23 +sff_dir_name_24 =sff24 +sff_dir_name_25 =sff25 +sff_dir_name_26 =sff26 +sff_dir_name_27 =sff27 +sff_dir_name_28 =sff28 +sff_dir_name_29 =sff29 +sff_dir_name_30 =sff30 +sff_dir_name_31 =sff31 +sff_dir_name_32 =sff32 + +# present +sff_cpld_reg.mode_1_8=config +sff_cpld_reg.src_1_8=cpld +sff_cpld_reg.frmt_1_8=bit +sff_cpld_reg.pola_1_8=negative +sff_cpld_reg.addr_1_8=0x00020030 +sff_cpld_reg.len_1_8=1 +sff_cpld_reg.bit_offset_1_8=0 + +sff_cpld_reg.mode_2_8=config +sff_cpld_reg.src_2_8=cpld +sff_cpld_reg.frmt_2_8=bit +sff_cpld_reg.pola_2_8=negative +sff_cpld_reg.addr_2_8=0x00020030 +sff_cpld_reg.len_2_8=1 +sff_cpld_reg.bit_offset_2_8=1 + +sff_cpld_reg.mode_3_8=config +sff_cpld_reg.src_3_8=cpld +sff_cpld_reg.frmt_3_8=bit +sff_cpld_reg.pola_3_8=negative +sff_cpld_reg.addr_3_8=0x00020030 +sff_cpld_reg.len_3_8=1 +sff_cpld_reg.bit_offset_3_8=2 + +sff_cpld_reg.mode_4_8=config +sff_cpld_reg.src_4_8=cpld +sff_cpld_reg.frmt_4_8=bit +sff_cpld_reg.pola_4_8=negative +sff_cpld_reg.addr_4_8=0x00020030 +sff_cpld_reg.len_4_8=1 +sff_cpld_reg.bit_offset_4_8=3 + +sff_cpld_reg.mode_5_8=config +sff_cpld_reg.src_5_8=cpld +sff_cpld_reg.frmt_5_8=bit +sff_cpld_reg.pola_5_8=negative +sff_cpld_reg.addr_5_8=0x00020030 +sff_cpld_reg.len_5_8=1 +sff_cpld_reg.bit_offset_5_8=4 + +sff_cpld_reg.mode_6_8=config +sff_cpld_reg.src_6_8=cpld +sff_cpld_reg.frmt_6_8=bit +sff_cpld_reg.pola_6_8=negative +sff_cpld_reg.addr_6_8=0x00020030 +sff_cpld_reg.len_6_8=1 +sff_cpld_reg.bit_offset_6_8=5 + +sff_cpld_reg.mode_7_8=config +sff_cpld_reg.src_7_8=cpld +sff_cpld_reg.frmt_7_8=bit +sff_cpld_reg.pola_7_8=negative +sff_cpld_reg.addr_7_8=0x00020030 +sff_cpld_reg.len_7_8=1 +sff_cpld_reg.bit_offset_7_8=6 + +sff_cpld_reg.mode_8_8=config +sff_cpld_reg.src_8_8=cpld +sff_cpld_reg.frmt_8_8=bit +sff_cpld_reg.pola_8_8=negative +sff_cpld_reg.addr_8_8=0x00020030 +sff_cpld_reg.len_8_8=1 +sff_cpld_reg.bit_offset_8_8=7 + +sff_cpld_reg.mode_9_8=config +sff_cpld_reg.src_9_8=cpld +sff_cpld_reg.frmt_9_8=bit +sff_cpld_reg.pola_9_8=negative +sff_cpld_reg.addr_9_8=0x00020031 +sff_cpld_reg.len_9_8=1 +sff_cpld_reg.bit_offset_9_8=0 + +sff_cpld_reg.mode_10_8=config +sff_cpld_reg.src_10_8=cpld +sff_cpld_reg.frmt_10_8=bit +sff_cpld_reg.pola_10_8=negative +sff_cpld_reg.addr_10_8=0x00020031 +sff_cpld_reg.len_10_8=1 +sff_cpld_reg.bit_offset_10_8=1 + +sff_cpld_reg.mode_11_8=config +sff_cpld_reg.src_11_8=cpld +sff_cpld_reg.frmt_11_8=bit +sff_cpld_reg.pola_11_8=negative +sff_cpld_reg.addr_11_8=0x00020031 +sff_cpld_reg.len_11_8=1 +sff_cpld_reg.bit_offset_11_8=2 + +sff_cpld_reg.mode_12_8=config +sff_cpld_reg.src_12_8=cpld +sff_cpld_reg.frmt_12_8=bit +sff_cpld_reg.pola_12_8=negative +sff_cpld_reg.addr_12_8=0x00020031 +sff_cpld_reg.len_12_8=1 +sff_cpld_reg.bit_offset_12_8=3 + +sff_cpld_reg.mode_13_8=config +sff_cpld_reg.src_13_8=cpld +sff_cpld_reg.frmt_13_8=bit +sff_cpld_reg.pola_13_8=negative +sff_cpld_reg.addr_13_8=0x00020031 +sff_cpld_reg.len_13_8=1 +sff_cpld_reg.bit_offset_13_8=4 + +sff_cpld_reg.mode_14_8=config +sff_cpld_reg.src_14_8=cpld +sff_cpld_reg.frmt_14_8=bit +sff_cpld_reg.pola_14_8=negative +sff_cpld_reg.addr_14_8=0x00020031 +sff_cpld_reg.len_14_8=1 +sff_cpld_reg.bit_offset_14_8=5 + +sff_cpld_reg.mode_15_8=config +sff_cpld_reg.src_15_8=cpld +sff_cpld_reg.frmt_15_8=bit +sff_cpld_reg.pola_15_8=negative +sff_cpld_reg.addr_15_8=0x00020031 +sff_cpld_reg.len_15_8=1 +sff_cpld_reg.bit_offset_15_8=6 + +sff_cpld_reg.mode_16_8=config +sff_cpld_reg.src_16_8=cpld +sff_cpld_reg.frmt_16_8=bit +sff_cpld_reg.pola_16_8=negative +sff_cpld_reg.addr_16_8=0x00020031 +sff_cpld_reg.len_16_8=1 +sff_cpld_reg.bit_offset_16_8=7 + +sff_cpld_reg.mode_17_8=config +sff_cpld_reg.src_17_8=cpld +sff_cpld_reg.frmt_17_8=bit +sff_cpld_reg.pola_17_8=negative +sff_cpld_reg.addr_17_8=0x00020032 +sff_cpld_reg.len_17_8=1 +sff_cpld_reg.bit_offset_17_8=0 + +sff_cpld_reg.mode_18_8=config +sff_cpld_reg.src_18_8=cpld +sff_cpld_reg.frmt_18_8=bit +sff_cpld_reg.pola_18_8=negative +sff_cpld_reg.addr_18_8=0x00020032 +sff_cpld_reg.len_18_8=1 +sff_cpld_reg.bit_offset_18_8=1 + +sff_cpld_reg.mode_19_8=config +sff_cpld_reg.src_19_8=cpld +sff_cpld_reg.frmt_19_8=bit +sff_cpld_reg.pola_19_8=negative +sff_cpld_reg.addr_19_8=0x00020032 +sff_cpld_reg.len_19_8=1 +sff_cpld_reg.bit_offset_19_8=2 + +sff_cpld_reg.mode_20_8=config +sff_cpld_reg.src_20_8=cpld +sff_cpld_reg.frmt_20_8=bit +sff_cpld_reg.pola_20_8=negative +sff_cpld_reg.addr_20_8=0x00020032 +sff_cpld_reg.len_20_8=1 +sff_cpld_reg.bit_offset_20_8=3 + +sff_cpld_reg.mode_21_8=config +sff_cpld_reg.src_21_8=cpld +sff_cpld_reg.frmt_21_8=bit +sff_cpld_reg.pola_21_8=negative +sff_cpld_reg.addr_21_8=0x00020032 +sff_cpld_reg.len_21_8=1 +sff_cpld_reg.bit_offset_21_8=4 + +sff_cpld_reg.mode_22_8=config +sff_cpld_reg.src_22_8=cpld +sff_cpld_reg.frmt_22_8=bit +sff_cpld_reg.pola_22_8=negative +sff_cpld_reg.addr_22_8=0x00020032 +sff_cpld_reg.len_22_8=1 +sff_cpld_reg.bit_offset_22_8=5 + +sff_cpld_reg.mode_23_8=config +sff_cpld_reg.src_23_8=cpld +sff_cpld_reg.frmt_23_8=bit +sff_cpld_reg.pola_23_8=negative +sff_cpld_reg.addr_23_8=0x00020032 +sff_cpld_reg.len_23_8=1 +sff_cpld_reg.bit_offset_23_8=6 + +sff_cpld_reg.mode_24_8=config +sff_cpld_reg.src_24_8=cpld +sff_cpld_reg.frmt_24_8=bit +sff_cpld_reg.pola_24_8=negative +sff_cpld_reg.addr_24_8=0x00020032 +sff_cpld_reg.len_24_8=1 +sff_cpld_reg.bit_offset_24_8=7 + +sff_cpld_reg.mode_25_8=config +sff_cpld_reg.src_25_8=cpld +sff_cpld_reg.frmt_25_8=bit +sff_cpld_reg.pola_25_8=negative +sff_cpld_reg.addr_25_8=0x00020033 +sff_cpld_reg.len_25_8=1 +sff_cpld_reg.bit_offset_25_8=0 + +sff_cpld_reg.mode_26_8=config +sff_cpld_reg.src_26_8=cpld +sff_cpld_reg.frmt_26_8=bit +sff_cpld_reg.pola_26_8=negative +sff_cpld_reg.addr_26_8=0x00020033 +sff_cpld_reg.len_26_8=1 +sff_cpld_reg.bit_offset_26_8=1 + +sff_cpld_reg.mode_27_8=config +sff_cpld_reg.src_27_8=cpld +sff_cpld_reg.frmt_27_8=bit +sff_cpld_reg.pola_27_8=negative +sff_cpld_reg.addr_27_8=0x00020033 +sff_cpld_reg.len_27_8=1 +sff_cpld_reg.bit_offset_27_8=2 + +sff_cpld_reg.mode_28_8=config +sff_cpld_reg.src_28_8=cpld +sff_cpld_reg.frmt_28_8=bit +sff_cpld_reg.pola_28_8=negative +sff_cpld_reg.addr_28_8=0x00020033 +sff_cpld_reg.len_28_8=1 +sff_cpld_reg.bit_offset_28_8=3 + +sff_cpld_reg.mode_29_8=config +sff_cpld_reg.src_29_8=cpld +sff_cpld_reg.frmt_29_8=bit +sff_cpld_reg.pola_29_8=negative +sff_cpld_reg.addr_29_8=0x00020033 +sff_cpld_reg.len_29_8=1 +sff_cpld_reg.bit_offset_29_8=4 + +sff_cpld_reg.mode_30_8=config +sff_cpld_reg.src_30_8=cpld +sff_cpld_reg.frmt_30_8=bit +sff_cpld_reg.pola_30_8=negative +sff_cpld_reg.addr_30_8=0x00020033 +sff_cpld_reg.len_30_8=1 +sff_cpld_reg.bit_offset_30_8=5 + +sff_cpld_reg.mode_31_8=config +sff_cpld_reg.src_31_8=cpld +sff_cpld_reg.frmt_31_8=bit +sff_cpld_reg.pola_31_8=negative +sff_cpld_reg.addr_31_8=0x00020033 +sff_cpld_reg.len_31_8=1 +sff_cpld_reg.bit_offset_31_8=6 + +sff_cpld_reg.mode_32_8=config +sff_cpld_reg.src_32_8=cpld +sff_cpld_reg.frmt_32_8=bit +sff_cpld_reg.pola_32_8=negative +sff_cpld_reg.addr_32_8=0x00020033 +sff_cpld_reg.len_32_8=1 +sff_cpld_reg.bit_offset_32_8=7 \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/plat_sysfs_cfg/cfg_file_name b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/plat_sysfs_cfg/cfg_file_name new file mode 100755 index 000000000000..f1a342c5ce58 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/plat_sysfs_cfg/cfg_file_name @@ -0,0 +1,4 @@ +TCS8400-CPLD +TCS8400-FAN +TCS8400-PSU +TCS8400-SFF \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/s3ip_config/customer_sysfs.json b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/s3ip_config/customer_sysfs.json new file mode 100755 index 000000000000..cc02b9e68b50 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/s3ip_config/customer_sysfs.json @@ -0,0 +1,70 @@ +{ + "s3ip_syfs_paths": [ + { + "path": "/sys_switch/temp_sensor", + "type" : "path", + "value" : "/sys/s3ip/temp_sensor", + "description": "temperature sensor information" + }, + { + "path": "/sys_switch/vol_sensor", + "type" : "path", + "value" : "/sys/s3ip/vol_sensor", + "description": "voltage sensor information" + }, + { + "path": "/sys_switch/curr_sensor", + "type" : "path", + "value" : "/sys/s3ip/curr_sensor", + "description": "current sensor information" + }, + { + "path": "/sys_switch/syseeprom", + "type" : "path", + "value" : "/sys/s3ip/syseeprom", + "description": "ONIE EEPROM" + }, + { + "path": "/sys_switch/fan", + "type" : "path", + "value" : "/sys/s3ip/fan", + "description": "fan information" + }, + { + "path": "/sys_switch/psu", + "type" : "path", + "value" : "/sys/s3ip/psu", + "description": "psu information" + }, + { + "path": "/sys_switch/transceiver", + "type" : "path", + "value" : "/sys/s3ip/transceiver", + "description": "transceiver information" + }, + { + "path": "/sys_switch/sysled", + "type" : "path", + "value" : "/sys/s3ip/sysled", + "description": "sysled information" + }, + { + "path": "/sys_switch/fpga", + "type" : "path", + "value" : "/sys/s3ip/fpga", + "description": "FPGA information" + }, + { + "path": "/sys_switch/cpld", + "type" : "path", + "value" : "/sys/s3ip/cpld", + "description": "CPLD information" + }, + { + "path": "/sys_switch/watchdog", + "type" : "path", + "value" : "/sys/s3ip/watchdog", + "description": "watchdog information" + } + ] +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/setup.py b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/setup.py new file mode 100755 index 000000000000..c0875b78fcde --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/setup.py @@ -0,0 +1,40 @@ +from setuptools import setup + +setup( + name='sonic-platform', + version='1.0', + description='SONiC platform API implementation on Ruijie TCS8400 Platforms', + license='Apache 2.0', + author='SONiC Team', + author_email='sonic_rd@ruijie.com.cn', + url='', + maintainer='Ruijie TCS8400', + maintainer_email='', + packages=[ + 'sonic_platform', + 'plat_hal', + 'rjutil', + 'eepromutil', + 'hal-config', + 'config', + ], + py_modules=[ + 'hal_pltfm', + 'platform_util', + 'platform_intf', + ], + 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.9', + 'Topic :: Utilities', + ], + keywords='sonic SONiC platform PLATFORM', +) + diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/Makefile b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/Makefile new file mode 100755 index 000000000000..d4e576cf6a3f --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/Makefile @@ -0,0 +1,28 @@ +PWD = $(shell pwd) +DIR_KERNEL_SRC = $(PWD)/modules/driver +EXTRA_CFLAGS:= -I$(M)/include +EXTRA_CFLAGS+= -Wall +SUB_BUILD_DIR = $(PWD)/build +INSTALL_DIR = $(SUB_BUILD_DIR)/$(KERNEL_SRC)/$(INSTALL_MOD_DIR) +INSTALL_SCRIPT_DIR = $(SUB_BUILD_DIR)/usr/local/bin +INSTALL_LIB_DIR = $(SUB_BUILD_DIR)/usr/lib/python3/dist-packages +INSTALL_SYSFS_CFG_DIR = $(SUB_BUILD_DIR)/etc/plat_sysfs_cfg +INSTALL_S3IP_CONFIG_DIR = $(SUB_BUILD_DIR)/etc/s3ip + +all: + $(MAKE) -C $(KBUILD_OUTPUT) M=$(DIR_KERNEL_SRC) modules + @if [ ! -d ${INSTALL_DIR} ]; then mkdir -p ${INSTALL_DIR} ;fi + cp -r $(DIR_KERNEL_SRC)/*.ko $(INSTALL_DIR) + @if [ ! -d ${INSTALL_SCRIPT_DIR} ]; then mkdir -p ${INSTALL_SCRIPT_DIR} ;fi + cp -r $(PWD)/config/* $(INSTALL_SCRIPT_DIR) + @if [ ! -d ${INSTALL_LIB_DIR} ]; then mkdir -p ${INSTALL_LIB_DIR} ;fi + @if [ -d $(PWD)/hal-config/ ]; then cp -r $(PWD)/hal-config/* ${INSTALL_LIB_DIR} ;fi + @if [ ! -d ${INSTALL_SYSFS_CFG_DIR} ]; then mkdir -p ${INSTALL_SYSFS_CFG_DIR} ;fi + @if [ -d $(PWD)/plat_sysfs_cfg/ ]; then cp -r $(PWD)/plat_sysfs_cfg/* ${INSTALL_SYSFS_CFG_DIR} ;fi + @if [ ! -d ${INSTALL_S3IP_CONFIG_DIR} ]; then mkdir -p ${INSTALL_S3IP_CONFIG_DIR} ;fi + @if [ -d $(PWD)/s3ip_config/ ]; then cp -r $(PWD)/s3ip_config/* ${INSTALL_S3IP_CONFIG_DIR} ;fi +clean: + rm -f ${DIR_KERNEL_SRC}/*.o ${DIR_KERNEL_SRC}/*.ko ${DIR_KERNEL_SRC}/*.mod.c ${DIR_KERNEL_SRC}/.*.cmd ${DIR_KERNEL_SRC}/.*.mod + rm -f ${DIR_KERNEL_SRC}/Module.markers ${DIR_KERNEL_SRC}/Module.symvers ${DIR_KERNEL_SRC}/modules.order + rm -rf ${DIR_KERNEL_SRC}/.tmp_versions + rm -rf $(SUB_BUILD_DIR) diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/config/x86_64_tencent_tcs9400_r0_0x407c_config.py b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/config/x86_64_tencent_tcs9400_r0_0x407c_config.py new file mode 100755 index 000000000000..71fcb0ab43d6 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/config/x86_64_tencent_tcs9400_r0_0x407c_config.py @@ -0,0 +1,1422 @@ +#!/usr/bin/python3 +from ruijiecommon import * + + +STARTMODULE = { + "xdpe_avscontrol":1, + "dev_monitor": 1, + "hal_fanctrl":1, + "hal_ledctrl":1, + "sff_temp_polling":1, + "rg_pmon_syslog":1, +} + +DEV_MONITOR_PARAM = { + "polling_time" : 10, + "psus": [ + {"name": "psu1", + "present": {"gettype": "io", "io_addr": 0x964, "presentbit": 0, "okval": 0}, + "device": [ + {"id": "psu1pmbus", "name": "rg_fsp1200", "bus": 79, "loc": 0x58, "attr": "hwmon"}, + {"id": "psu1frue2", "name": "24c02", "bus": 79, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "psu2", + "present": {"gettype": "io", "io_addr": 0x964, "presentbit": 4, "okval": 0}, + "device": [ + {"id": "psu2pmbus", "name": "rg_fsp1200", "bus": 80, "loc": 0x58, "attr": "hwmon"}, + {"id": "psu2frue2", "name": "24c02", "bus": 80, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "psu3", + "present": {"gettype": "io", "io_addr": 0x965, "presentbit": 4, "okval": 0}, + "device": [ + {"id": "psu3pmbus", "name": "rg_fsp1200", "bus": 82, "loc": 0x58, "attr": "hwmon"}, + {"id": "psu3frue2", "name": "24c02", "bus": 82, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "psu4", + "present": {"gettype": "io", "io_addr": 0x965, "presentbit": 0, "okval": 0}, + "device": [ + {"id": "psu4pmbus", "name": "rg_fsp1200", "bus": 81, "loc": 0x58, "attr": "hwmon"}, + {"id": "psu4frue2", "name": "24c02", "bus": 81, "loc": 0x50, "attr": "eeprom"}, + ], + }, + ], + "fans": [ + {"name": "fan1", + "present": {"gettype": "i2c", "bus": 87, "loc": 0x0d, "offset": 0x30, "presentbit": 0, "okval": 0}, + "device": [ + {"id": "fan1frue2", "name": "24c64", "bus": 90, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan2", + "present": {"gettype": "i2c", "bus": 95, "loc": 0x0d, "offset": 0x30, "presentbit": 0, "okval": 0}, + "device": [ + {"id": "fan2frue2", "name": "24c64", "bus": 98, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan3", + "present": {"gettype": "i2c", "bus": 87, "loc": 0x0d, "offset": 0x30, "presentbit": 1, "okval": 0}, + "device": [ + {"id": "fan3frue2", "name": "24c64", "bus": 91, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan4", + "present": {"gettype": "i2c", "bus": 95, "loc": 0x0d, "offset": 0x30, "presentbit": 1, "okval": 0}, + "device": [ + {"id": "fan4frue2", "name": "24c64", "bus": 99, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan5", + "present": {"gettype": "i2c", "bus": 87, "loc": 0x0d, "offset": 0x30, "presentbit": 2, "okval": 0}, + "device": [ + {"id": "fan5frue2", "name": "24c64", "bus": 92, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan6", + "present": {"gettype": "i2c", "bus": 95, "loc": 0x0d, "offset": 0x30, "presentbit": 2, "okval": 0}, + "device": [ + {"id": "fan6frue2", "name": "24c64", "bus": 100, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan7", + "present": {"gettype": "i2c", "bus": 87, "loc": 0x0d, "offset": 0x30, "presentbit": 3, "okval": 0}, + "device": [ + {"id": "fan7frue2", "name": "24c64", "bus": 93, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan8", + "present": {"gettype": "i2c", "bus": 95, "loc": 0x0d, "offset": 0x30, "presentbit": 3, "okval": 0}, + "device": [ + {"id": "fan8frue2", "name": "24c64", "bus": 101, "loc": 0x50, "attr": "eeprom"}, + ], + }, + ], + "others": [ + {"name":"eeprom", + "device":[ + {"id":"eeprom_1", "name":"24c02","bus":1, "loc":0x56, "attr":"eeprom"}, + ], + }, + {"name":"lm75", + "device":[ + {"id":"lm75_1", "name":"lm75","bus":63, "loc":0x4b, "attr":"hwmon"}, + {"id":"lm75_2", "name":"lm75","bus":64, "loc":0x4f, "attr":"hwmon"}, + {"id":"lm75_3", "name":"lm75","bus":88, "loc":0x48, "attr":"hwmon"}, + {"id":"lm75_4", "name":"lm75","bus":89, "loc":0x49, "attr":"hwmon"}, + {"id":"lm75_5", "name":"lm75","bus":96, "loc":0x48, "attr":"hwmon"}, + {"id":"lm75_6", "name":"lm75","bus":97, "loc":0x49, "attr":"hwmon"}, + {"id":"lm75_7", "name":"lm75","bus":107, "loc":0x4b, "attr":"hwmon"}, + {"id":"lm75_8", "name":"lm75","bus":109, "loc":0x4b, "attr":"hwmon"}, + {"id":"lm75_9", "name":"lm75","bus":69, "loc":0x4b, "attr":"hwmon"}, + {"id":"lm75_10", "name":"lm75","bus":70, "loc":0x4f, "attr":"hwmon"}, + {"id":"lm75_11", "name":"lm75","bus":114, "loc":0x4b, "attr":"hwmon"}, + {"id":"lm75_12", "name":"lm75","bus":115, "loc":0x4f, "attr":"hwmon"}, + ], + }, + {"name":"mac_bsc", + "device":[ + {"id":"mac_bsc_1", "name":"rg_mac_bsc_th4","bus":74, "loc":0x44, "attr":"hwmon"}, + ], + }, + {"name":"ina3221", + "device":[ + {"id":"ina3221_1", "name":"rg_ina3221","bus":106, "loc":0x43, "attr":"hwmon"}, + ], + }, + {"name":"tps53622", + "device":[ + {"id":"tps53622_1", "name":"rg_tps53622","bus":106, "loc":0x60, "attr":"hwmon"}, + {"id":"tps53622_2", "name":"rg_tps53622","bus":106, "loc":0x6c, "attr":"hwmon"}, + ], + }, + {"name":"ucd90160", + "device":[ + {"id":"ucd90160_1", "name":"rg_ucd90160","bus":62, "loc":0x5b, "attr":"hwmon"}, + {"id":"ucd90160_2", "name":"rg_ucd90160","bus":105, "loc":0x5b, "attr":"hwmon"}, + {"id":"ucd90160_3", "name":"rg_ucd90160","bus":73, "loc":0x5b, "attr":"hwmon"}, + {"id":"ucd90160_4", "name":"rg_ucd90160","bus":113, "loc":0x5b, "attr":"hwmon"}, + ], + }, + {"name":"tmp411", + "device":[ + {"id":"tmp411_1", "name":"tmp411","bus":71, "loc":0x4c, "attr":"hwmon"}, + {"id":"tmp411_2", "name":"tmp411","bus":72, "loc":0x4c, "attr":"hwmon"}, + ], + }, + ], +} + +CPLDVERSIONS = [ ] +MANUINFO_CONF = { + "bios": { + "key": "BIOS", + "head": True, + "next": "bmc" + }, + "bios_vendor": { + "parent": "bios", + "key": "Vendor", + "cmd": "dmidecode -t 0 |grep Vendor", + "pattern": r".*Vendor", + "separator": ":", + "arrt_index" : 1, + }, + "bios_version": { + "parent": "bios", + "key": "Version", + "cmd": "dmidecode -t 0 |grep Version", + "pattern": r".*Version", + "separator": ":", + "arrt_index" : 2, + }, + "bios_date": { + "parent": "bios", + "key": "Release Date", + "cmd": "dmidecode -t 0 |grep Release", + "pattern": r".*Release Date", + "separator": ":", + "arrt_index" : 3, + }, + + "bmc": { + "key": "BMC", + "next": "onie" + }, + "bmc_version": { + "parent": "bmc", + "key": "Version", + "cmd": "ipmitool mc info |grep \"Firmware Revision\"", + "pattern": r".*Firmware Revision", + "separator": ":", + "arrt_index" : 1, + }, + + "onie": { + "key": "ONIE", + "next": "cpu" + }, + "onie_date": { + "parent": "onie", + "key": "Build Date", + "file": "/host/machine.conf", + "pattern": r"^onie_build_date", + "separator": "=", + "arrt_index" : 1, + }, + "onie_version": { + "parent": "onie", + "key": "Version", + "file": "/host/machine.conf", + "pattern": r"^onie_version", + "separator": "=", + "arrt_index" : 2, + }, + "onie_sub_version": { + "parent": "onie", + "key": "Sub Version", + "file": "/host/machine.conf", + "pattern": r"^onie_sub_version", + "separator": "=", + "arrt_index" : 3, + }, + + "cpu": { + "key": "CPU", + "next": "ssd" + }, + "cpu_vendor": { + "parent": "cpu", + "key": "Vendor", + "cmd": "dmidecode --type processor |grep Manufacturer", + "pattern": r".*Manufacturer", + "separator": ":", + "arrt_index" : 1, + }, + "cpu_model": { + "parent": "cpu", + "key": "Device Model", + "cmd": "dmidecode --type processor | grep Version", + "pattern": r".*Version", + "separator": ":", + "arrt_index" : 2, + }, + "cpu_core": { + "parent": "cpu", + "key": "Core Count", + "cmd": "dmidecode --type processor | grep \"Core Count\"", + "pattern": r".*Core Count", + "separator": ":", + "arrt_index" : 3, + }, + "cpu_thread": { + "parent": "cpu", + "key": "Thread Count", + "cmd": "dmidecode --type processor | grep \"Thread Count\"", + "pattern": r".*Thread Count", + "separator": ":", + "arrt_index" : 4, + }, + + "ssd": { + "key": "SSD", + "next": "cpld" + }, + "ssd_model": { + "parent": "ssd", + "key": "Device Model", + "cmd": "smartctl -i /dev/sda |grep \"Device Model\"", + "pattern": r".*Device Model", + "separator": ":", + "arrt_index" : 1, + }, + "ssd_fw": { + "parent": "ssd", + "key": "Firmware Version", + "cmd": "smartctl -i /dev/sda |grep \"Firmware Version\"", + "pattern": r".*Firmware Version", + "separator": ":", + "arrt_index" : 2, + }, + "ssd_user_cap": { + "parent": "ssd", + "key": "User Capacity", + "cmd": "smartctl -i /dev/sda |grep \"User Capacity\"", + "pattern": r".*User Capacity", + "separator": ":", + "arrt_index" : 3, + }, + + "cpld": { + "key": "CPLD", + "next": "psu" + }, + + "cpld1": { + "key": "CPLD1", + "parent": "cpld", + "arrt_index" : 1, + }, + "cpld1_model": { + "key": "Device Model", + "parent": "cpld1", + "config" : "LCMXO3LF-2100C-5BG256C", + "arrt_index" : 1, + }, + "cpld1_vender": { + "key": "Vendor", + "parent": "cpld1", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld1_desc": { + "key": "Description", + "parent": "cpld1", + "config" : "CPU_CPLD", + "arrt_index" : 3, + }, + "cpld1_version": { + "key": "Firmware Version", + "parent": "cpld1", + "reg": { + "loc": "/dev/port", + "offset": 0x700, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld2": { + "key": "CPLD2", + "parent": "cpld", + "arrt_index" : 2, + }, + "cpld2_model": { + "key": "Device Model", + "parent": "cpld2", + "config" : "LCMXO3LF-4300C-6BG324I", + "arrt_index" : 1, + }, + "cpld2_vender": { + "key": "Vendor", + "parent": "cpld2", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld2_desc": { + "key": "Description", + "parent": "cpld2", + "config" : "BASE_CPLD", + "arrt_index" : 3, + }, + "cpld2_version": { + "key": "Firmware Version", + "parent": "cpld2", + "reg": { + "loc": "/dev/port", + "offset": 0x900, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld3": { + "key": "CPLD3", + "parent": "cpld", + "arrt_index" : 3, + }, + "cpld3_model": { + "key": "Device Model", + "parent": "cpld3", + "config" : "LCMXO3LF-4300C-6BG324I", + "arrt_index" : 1, + }, + "cpld3_vender": { + "key": "Vendor", + "parent": "cpld3", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld3_desc": { + "key": "Description", + "parent": "cpld3", + "config" : "UPORT_CPLD", + "arrt_index" : 3, + }, + "cpld3_version": { + "key": "Firmware Version", + "parent": "cpld3", + "i2c": { + "bus": "60", + "loc": "0x3d", + "offset": 0, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld4": { + "key": "CPLD4", + "parent": "cpld", + "arrt_index" : 4, + }, + "cpld4_model": { + "key": "Device Model", + "parent": "cpld4", + "config" : "LCMXO3LF-2100C-5BG256C", + "arrt_index" : 1, + }, + "cpld4_vender": { + "key": "Vendor", + "parent": "cpld4", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld4_desc": { + "key": "Description", + "parent": "cpld4", + "config" : "UFCB_CPLD", + "arrt_index" : 3, + }, + "cpld4_version": { + "key": "Firmware Version", + "parent": "cpld4", + "i2c": { + "bus": "87", + "loc": "0x0d", + "offset": 0, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld5": { + "key": "CPLD5", + "parent": "cpld", + "arrt_index" : 5, + }, + "cpld5_model": { + "key": "Device Model", + "parent": "cpld5", + "config" : "LCMXO3LF-2100C-5BG256C", + "arrt_index" : 1, + }, + "cpld5_vender": { + "key": "Vendor", + "parent": "cpld5", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld5_desc": { + "key": "Description", + "parent": "cpld5", + "config" : "DFCB_CPLD", + "arrt_index" : 3, + }, + "cpld5_version": { + "key": "Firmware Version", + "parent": "cpld5", + "i2c": { + "bus": "95", + "loc": "0x0d", + "offset": 0, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld6": { + "key": "CPLD6", + "parent": "cpld", + "arrt_index" : 6, + }, + "cpld6_model": { + "key": "Device Model", + "parent": "cpld6", + "config" : "LCMXO3LF-4300C-6BG324I", + "arrt_index" : 1, + }, + "cpld6_vender": { + "key": "Vendor", + "parent": "cpld6", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld6_desc": { + "key": "Description", + "parent": "cpld6", + "config" : "MAC_CPLDA", + "arrt_index" : 3, + }, + "cpld6_version": { + "key": "Firmware Version", + "parent": "cpld6", + "i2c": { + "bus": "77", + "loc": "0x1d", + "offset": 0, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld7": { + "key": "CPLD7", + "parent": "cpld", + "arrt_index" : 7, + }, + "cpld7_model": { + "key": "Device Model", + "parent": "cpld7", + "config" : "LCMXO3LF-4300C-6BG324I", + "arrt_index" : 1, + }, + "cpld7_vender": { + "key": "Vendor", + "parent": "cpld7", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld7_desc": { + "key": "Description", + "parent": "cpld7", + "config" : "MAC_CPLDB", + "arrt_index" : 3, + }, + "cpld7_version": { + "key": "Firmware Version", + "parent": "cpld7", + "i2c": { + "bus": "77", + "loc": "0x2d", + "offset": 0, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld8": { + "key": "CPLD8", + "parent": "cpld", + "arrt_index" : 8, + }, + "cpld8_model": { + "key": "Device Model", + "parent": "cpld8", + "config" : "LCMXO3LF-4300C-6BG324I", + "arrt_index" : 1, + }, + "cpld8_vender": { + "key": "Vendor", + "parent": "cpld8", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld8_desc": { + "key": "Description", + "parent": "cpld8", + "config" : "DPORT_CPLD", + "arrt_index" : 3, + }, + "cpld8_version": { + "key": "Firmware Version", + "parent": "cpld8", + "i2c": { + "bus": "111", + "loc": "0x3d", + "offset": 0, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "psu": { + "key": "PSU", + "next": "fan" + }, + + "psu1": { + "parent": "psu", + "key": "PSU1", + "arrt_index" : 1, + }, + "psu1_hw_version": { + "key": "Hardware Version", + "parent": "psu1", + "extra": { + "funcname": "getPsu", + "id": "psu1", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "psu1_fw_version": { + "key": "Firmware Version", + "parent": "psu1", + "config" : "NA", + "arrt_index" : 2, + }, + + "psu2": { + "parent": "psu", + "key": "PSU2", + "arrt_index" : 2, + }, + "psu2_hw_version": { + "key": "Hardware Version", + "parent": "psu2", + "extra": { + "funcname": "getPsu", + "id": "psu2", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "psu2_fw_version": { + "key": "Firmware Version", + "parent": "psu2", + "config" : "NA", + "arrt_index" : 2, + }, + + "psu3": { + "parent": "psu", + "key": "PSU3", + "arrt_index" : 3, + }, + "psu3_hw_version": { + "key": "Hardware Version", + "parent": "psu3", + "extra": { + "funcname": "getPsu", + "id": "psu3", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "psu3_fw_version": { + "key": "Firmware Version", + "parent": "psu3", + "config" : "NA", + "arrt_index" : 2, + }, + + "psu4": { + "parent": "psu", + "key": "PSU4", + "arrt_index" : 4, + }, + "psu4_hw_version": { + "key": "Hardware Version", + "parent": "psu4", + "extra": { + "funcname": "getPsu", + "id": "psu4", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "psu4_fw_version": { + "key": "Firmware Version", + "parent": "psu4", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan": { + "key": "FAN", + "next": "i210" + }, + + "fan1": { + "key": "FAN1", + "parent": "fan", + "arrt_index" : 1, + }, + "fan1_hw_version": { + "key": "Hardware Version", + "parent": "fan1", + "extra": { + "funcname": "checkFan", + "id": "fan1", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan1_fw_version": { + "key": "Firmware Version", + "parent": "fan1", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan2": { + "key": "FAN2", + "parent": "fan", + "arrt_index" : 2, + }, + "fan2_hw_version": { + "key": "Hardware Version", + "parent": "fan2", + "extra": { + "funcname": "checkFan", + "id": "fan2", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan2_fw_version": { + "key": "Firmware Version", + "parent": "fan2", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan3": { + "key": "FAN3", + "parent": "fan", + "arrt_index" : 3, + }, + "fan3_hw_version": { + "key": "Hardware Version", + "parent": "fan3", + "extra": { + "funcname": "checkFan", + "id": "fan3", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan3_fw_version": { + "key": "Firmware Version", + "parent": "fan3", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan4": { + "key": "FAN4", + "parent": "fan", + "arrt_index" : 4, + }, + "fan4_hw_version": { + "key": "Hardware Version", + "parent": "fan4", + "extra": { + "funcname": "checkFan", + "id": "fan4", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan4_fw_version": { + "key": "Firmware Version", + "parent": "fan4", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan5": { + "key": "FAN5", + "parent": "fan", + "arrt_index" : 5, + }, + "fan5_hw_version": { + "key": "Hardware Version", + "parent": "fan5", + "extra": { + "funcname": "checkFan", + "id": "fan5", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan5_fw_version": { + "key": "Firmware Version", + "parent": "fan5", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan6": { + "key": "FAN6", + "parent": "fan", + "arrt_index" : 6, + }, + "fan6_hw_version": { + "key": "Hardware Version", + "parent": "fan6", + "extra": { + "funcname": "checkFan", + "id": "fan6", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan6_fw_version": { + "key": "Firmware Version", + "parent": "fan6", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan7": { + "key": "FAN7", + "parent": "fan", + "arrt_index" : 7, + }, + "fan7_hw_version": { + "key": "Hardware Version", + "parent": "fan7", + "extra": { + "funcname": "checkFan", + "id": "fan7", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan7_fw_version": { + "key": "Firmware Version", + "parent": "fan7", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan8": { + "key": "FAN8", + "parent": "fan", + "arrt_index" : 8, + }, + "fan8_hw_version": { + "key": "Hardware Version", + "parent": "fan8", + "extra": { + "funcname": "checkFan", + "id": "fan8", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan8_fw_version": { + "key": "Firmware Version", + "parent": "fan8", + "config" : "NA", + "arrt_index" : 2, + }, + + "i210": { + "key": "NIC", + "next": "fpga" + }, + "i210_model": { + "parent": "i210", + "config": "NA", + "key": "Device Model", + "arrt_index" : 1, + }, + "i210_vendor": { + "parent": "i210", + "config": "INTEL", + "key": "Vendor", + "arrt_index" : 2, + }, + "i210_version": { + "parent": "i210", + "cmd": "ethtool -i eth0", + "pattern": r"firmware-version", + "separator": ":", + "key": "Firmware Version", + "arrt_index" : 3, + }, + + "fpga": { + "key": "FPGA", + "next": "others" + }, + + "fpga1": { + "key": "FPGA1", + "parent": "fpga", + "arrt_index" : 1, + }, + "fpga1_model": { + "parent": "fpga1", + "devfile": { + "loc": "/dev/fpga0", + "offset":0x98, + "len":4, + "bit_width":4 + }, + "decode": { + "0x00000000": "XC7A100T-2FGG484C", + "0x00000200": "XC7A200T-2FBG484I" + }, + "key": "Device Model", + "arrt_index" : 1, + }, + "fpga1_vender": { + "parent": "fpga1", + "config" : "XILINX", + "key": "Vendor", + "arrt_index" : 2, + }, + "fpga1_desc": { + "key": "Description", + "parent": "fpga1", + "config" : "UPORT_FPGA", + "arrt_index" : 3, + }, + "fpga1_hw_version": { + "parent": "fpga1", + "config" : "NA", + "key": "Hardware Version", + "arrt_index" : 4, + }, + "fpga1_fw_version": { + "parent": "fpga1", + "pci": { + "bus" : 0x0a, + "slot" : 0, + "fn" : 0, + "bar" : 0, + "offset" : 0 + }, + "key": "Firmware Version", + "arrt_index" : 5, + }, + + "fpga2": { + "key": "FPGA2", + "parent": "fpga", + "arrt_index" : 2, + }, + "fpga2_model": { + "parent": "fpga2", + "devfile": { + "loc": "/dev/fpga1", + "offset":0xb0, + "len":4, + "bit_width":4 + }, + "decode": { + "0x00000000": "XC7A100T-2FGG484C", + "0x00000200": "XC7A200T-2FBG484I" + }, + "key": "Device Model", + "arrt_index" : 1, + }, + "fpga2_vender": { + "parent": "fpga2", + "config" : "XILINX", + "key": "Vendor", + "arrt_index" : 2, + }, + "fpga2_desc": { + "key": "Description", + "parent": "fpga2", + "config" : "MAC_FPGA", + "arrt_index" : 3, + }, + "fpga2_hw_version": { + "parent": "fpga2", + "config" : "NA", + "key": "Hardware Version", + "arrt_index" : 4, + }, + "fpga2_fw_version": { + "parent": "fpga2", + "pci": { + "bus" : 8, + "slot" : 0, + "fn" : 0, + "bar" : 0, + "offset" : 0 + }, + "key": "Firmware Version", + "arrt_index" : 5, + }, + + "fpga3": { + "key": "FPGA3", + "parent": "fpga", + "arrt_index" : 3, + }, + "fpga3_model": { + "parent": "fpga3", + "devfile": { + "loc": "/dev/fpga2", + "offset":0x98, + "len":4, + "bit_width":4 + }, + "decode": { + "0x00000000": "XC7A100T-2FGG484C", + "0x00000200": "XC7A200T-2FBG484I" + }, + "key": "Device Model", + "arrt_index" : 1, + }, + "fpga3_vender": { + "parent": "fpga3", + "config" : "XILINX", + "key": "Vendor", + "arrt_index" : 2, + }, + "fpga3_desc": { + "key": "Description", + "parent": "fpga3", + "config" : "DPORT_FPGA", + "arrt_index" : 3, + }, + "fpga3_hw_version": { + "parent": "fpga3", + "config" : "NA", + "key": "Hardware Version", + "arrt_index" : 4, + }, + "fpga3_fw_version": { + "parent": "fpga3", + "pci": { + "bus" : 0xb, + "slot" : 0, + "fn" : 0, + "bar" : 0, + "offset" : 0 + }, + "key": "Firmware Version", + "arrt_index" : 5, + }, + + "others": { + "key": "OTHERS", + }, + "5387": { + "parent": "others", + "key": "CPU-BMC-SWITCH", + "arrt_index" : 1, + }, + "5387_model": { + "parent": "5387", + "config": "BCM53134O", + "key": "Device Model", + "arrt_index" : 1, + }, + "5387_vendor": { + "parent": "5387", + "config": "Broadcom", + "key": "Vendor", + "arrt_index" : 2, + }, + "5387_hw_version": { + "parent": "5387", + "key": "Hardware Version", + "func": { + "funcname": "get_bcm5387_version", + "params" : { + "before": [ + {"dealtype": "shell", "cmd": "echo 50 > /sys/class/gpio/export"}, + {"dealtype": "shell", "cmd": "echo high > /sys/class/gpio/gpio50/direction"}, + {"dealtype": "shell", "cmd": "echo 48 > /sys/class/gpio/export"}, + {"dealtype": "shell", "cmd": "echo high > /sys/class/gpio/gpio48/direction"}, + {"dealtype": "io_wr", "io_addr": 0x918, "value":0x06}, + {"dealtype": "io_wr", "io_addr": 0x943, "value":0x00}, + ], + "get_version" : "md5sum /sys/bus/spi/devices/spi0.0/eeprom | awk '{print $1}'", + "after": [ + {"dealtype": "shell", "cmd": "echo 0 > /sys/class/gpio/gpio48/value"}, + {"dealtype": "shell", "cmd": "echo 48 > /sys/class/gpio/unexport"}, + {"dealtype": "shell", "cmd": "echo 0 > /sys/class/gpio/gpio50/value"}, + {"dealtype": "shell", "cmd": "echo 50 > /sys/class/gpio/unexport"}, + ], + "finally": [ + {"dealtype": "io_wr", "io_addr": 0x943, "value":0x01}, + {"dealtype": "io_wr", "io_addr": 0x918, "value":0x00}, + ], + }, + }, + "arrt_index" : 3, + }, +} + +MAC_AVS_PARAM = { + 0x7e: 0.882564, + 0x82: 0.859436, + 0x86: 0.836776, + 0x8A: 0.813531, + 0x8E: 0.789233, +} + +AVS_VOUT_MODE_PARAM ={ + 0x18:256, # 2^8 + 0x17:512, # 2^9 + 0x16:1024, # 2^10 + 0x15:2048, # 2^11 + 0x14:4096, # 2^12 +} + +MAC_DEFAULT_PARAM = { + "type": 0, + "default":0x82, + "bus":75, + "devno":0x10, + "loopaddr":0xff, + "loop":0x06, + "vout_cmd_addr":0x42, + "vout_mode_addr":0x40, + "sdktype": 0, + "macregloc":24 , + "mask": 0xff, + "rov_source":0, + "cpld_avs":{"bus":77, "loc":0x1d, "offset":0x24, "gettype":"i2c"}, + "set_avs": {"loc": "/sys/bus/i2c/devices/75-0010/avs_vout", "gettype": "sysfs", "formula": "int((%f)*1000000)"}, +} + +## +DRIVERLISTS = [ + {"name": "rg_gpio_d1500", "delay": 0}, + {"name": "i2c_dev", "delay": 0}, + {"name": "i2c_gpio", "delay":0}, + {"name": "i2c_mux", "delay":0}, + {"name": "rg_fpga_pcie", "delay": 0}, + {"name": "rg_pcie_dev", "delay": 0}, + {"name": "rg_lpc_drv", "delay": 0}, + {"name": "rg_io_dev", "delay": 0}, + {"name": "rg_i2c_dev", "delay": 0}, + {"name": "rg_fpga_i2c_bus_drv", "delay": 0}, + {"name": "rg_fpga_pca954x_drv", "delay": 0}, + {"name": "rg_wdt", "delay": 0}, + {"name": "rg_gpio_device", "delay": 0}, + {"name": "rg_i2c_gpio_device", "delay":0}, + {"name": "rg_pcie_dev_device", "delay": 0}, + {"name": "rg_lpc_drv_device", "delay": 0}, + {"name": "rg_io_dev_device", "delay": 0}, + {"name": "rg_fpga_i2c_bus_device", "delay": 0}, + {"name": "rg_fpga_pca954x_device", "delay": 0}, + {"name": "rg_i2c_dev_device", "delay": 0}, + {"name": "rg_wdt_device", "delay": 0}, + {"name": "ruijie_common dfd_my_type_i2c_bus=1 dfd_my_type_i2c_addr=0x56", "delay": 1}, + {"name": "rg_spi_gpio_device", "delay": 0}, + {"name": "rg_eeprom_93xx46", "delay": 0}, + {"name": "lm75", "delay":0}, + {"name": "tmp401", "delay":0}, + {"name": "rg_optoe", "delay": 0}, + {"name": "at24", "delay": 0}, + {"name": "rg_mac_bsc", "delay": 0}, + {"name": "rg_pmbus_core", "delay":0}, + {"name": "rg_csu550", "delay": 0}, + {"name": "rg_ina3221", "delay": 0}, + {"name": "rg_tps53622", "delay": 0}, + {"name": "rg_ucd9000", "delay": 0}, + {"name": "rg_xdpe132g5c", "delay": 0}, + {"name": "s3ip_sysfs", "delay": 0}, + {"name": "rg_switch_driver", "delay": 0}, + {"name": "syseeprom_device_driver", "delay": 0}, + {"name": "fan_device_driver", "delay": 0}, + {"name": "cpld_device_driver", "delay": 0}, + {"name": "sysled_device_driver", "delay": 0}, + {"name": "psu_device_driver", "delay": 0}, + {"name": "transceiver_device_driver", "delay": 0}, + {"name": "temp_sensor_device_driver", "delay": 0}, + {"name": "vol_sensor_device_driver", "delay": 0}, + {"name": "curr_sensor_device_driver", "delay": 0}, + {"name": "fpga_device_driver", "delay": 0}, + {"name": "watchdog_device_driver", "delay": 0}, + {"name": "rg_plat_dfd", "delay":0}, + {"name": "rg_plat_switch", "delay":0}, + {"name": "rg_plat_fan", "delay":0}, + {"name": "rg_plat_psu", "delay":0}, + {"name": "rg_plat_sff", "delay":0}, + {"name": "rg_plat_sensor", "delay": 0}, +] + +DEVICE = [ + # GPIO-I2C + {"name": "24c02", "bus":1, "loc":0x56 }, + # UP port board + {"name": "rg_ucd90160", "bus": 62, "loc": 0x5b}, + {"name": "lm75", "bus": 63, "loc": 0x4b}, + {"name": "lm75", "bus": 64, "loc": 0x4f}, + # MAC board + # PSU + {"name": "24c02", "bus":79, "loc":0x50}, + {"name": "rg_fsp1200","bus":79, "loc":0x58 }, + {"name": "24c02", "bus":80, "loc": 0x50}, + {"name": "rg_fsp1200","bus":80, "loc":0x58 }, + {"name": "24c02", "bus":81, "loc":0x50}, + {"name": "rg_fsp1200","bus":81, "loc":0x58 }, + {"name": "24c02", "bus":82, "loc": 0x50}, + {"name": "rg_fsp1200","bus":82, "loc":0x58 }, + # FAN + {"name": "24c64","bus":90,"loc":0x50 }, + {"name": "24c64","bus":91,"loc":0x50 }, + {"name": "24c64","bus":92,"loc":0x50 }, + {"name": "24c64","bus":93,"loc":0x50 }, + {"name": "24c64","bus":98,"loc":0x50 }, + {"name": "24c64","bus":99,"loc":0x50 }, + {"name": "24c64","bus":100,"loc":0x50 }, + {"name": "24c64","bus":101,"loc":0x50 }, + # fan temp + {"name": "lm75", "bus": 88, "loc": 0x48}, + {"name": "lm75", "bus": 89, "loc": 0x49}, + {"name": "lm75", "bus": 96, "loc": 0x48}, + {"name": "lm75", "bus": 97, "loc": 0x49}, + # base temp + {"name": "lm75", "bus": 107, "loc": 0x4b}, + {"name": "lm75", "bus": 109, "loc": 0x4b}, + {"name": "lm75", "bus": 69, "loc": 0x4b}, + {"name": "lm75", "bus": 70, "loc": 0x4f}, + {"name": "tmp411", "bus": 71, "loc": 0x4c}, + {"name": "tmp411", "bus": 72, "loc": 0x4c}, + # base dcdc + {"name": "rg_ucd90160", "bus": 105, "loc": 0x5b}, + {"name": "rg_tps53622", "bus": 106, "loc": 0x60}, + {"name": "rg_tps53622", "bus": 106, "loc": 0x6c}, + {"name": "rg_ina3221", "bus": 106, "loc": 0x43}, + {"name": "rg_ucd90160", "bus": 73, "loc": 0x5b}, + # mac bsc + {"name": "rg_mac_bsc_th4", "bus":74, "loc":0x44 }, + # DOWN port board + {"name": "rg_ucd90160", "bus": 113, "loc": 0x5b}, + {"name": "lm75", "bus": 114, "loc": 0x4b}, + {"name": "lm75", "bus": 115, "loc": 0x4f}, + # xdpe avs + {"name": "rg_xdpe132g5c", "bus": 75, "loc": 0x10}, + {"name": "rg_xdpe132g5c", "bus": 76, "loc": 0x5a}, +] + +OPTOE = [ + {"name": "rg_optoe1", "startbus": 124, "endbus": 251}, +] + +PMON_SYSLOG_STATUS = { + "polling_time": 3, + "sffs": { + "present": {"path": ["/sys/s3ip/transceiver/*/present"], "ABSENT":0}, + "nochangedmsgflag": 0, + "nochangedmsgtime": 60, + "noprintfirsttimeflag": 1, + "alias": { + "eth1": "Eth200GE1", + "eth2": "Eth200GE2", + "eth3": "Eth200GE3", + "eth4": "Eth200GE4", + "eth5": "Eth200GE5", + "eth6": "Eth200GE6", + "eth7": "Eth200GE7", + "eth8": "Eth200GE8", + "eth9": "Eth200GE9", + "eth10": "Eth200GE10", + "eth11": "Eth200GE11", + "eth12": "Eth200GE12", + "eth13": "Eth200GE13", + "eth14": "Eth200GE14", + "eth15": "Eth200GE15", + "eth16": "Eth200GE16", + "eth17": "Eth200GE17", + "eth18": "Eth200GE18", + "eth19": "Eth200GE19", + "eth20": "Eth200GE20", + "eth21": "Eth200GE21", + "eth22": "Eth200GE22", + "eth23": "Eth200GE23", + "eth24": "Eth200GE24", + "eth25": "Eth200GE25", + "eth26": "Eth200GE26", + "eth27": "Eth200GE27", + "eth28": "Eth200GE28", + "eth29": "Eth200GE29", + "eth30": "Eth200GE30", + "eth31": "Eth200GE31", + "eth32": "Eth200GE32", + "eth33": "Eth200GE33", + "eth34": "Eth200GE34", + "eth35": "Eth200GE35", + "eth36": "Eth200GE36", + "eth37": "Eth200GE37", + "eth38": "Eth200GE38", + "eth39": "Eth200GE39", + "eth40": "Eth200GE40", + "eth41": "Eth200GE41", + "eth42": "Eth200GE42", + "eth43": "Eth200GE43", + "eth44": "Eth200GE44", + "eth45": "Eth200GE45", + "eth46": "Eth200GE46", + "eth47": "Eth200GE47", + "eth48": "Eth200GE48", + "eth49": "Eth200GE49", + "eth50": "Eth200GE50", + "eth51": "Eth200GE51", + "eth52": "Eth200GE52", + "eth53": "Eth200GE53", + "eth54": "Eth200GE54", + "eth55": "Eth200GE55", + "eth56": "Eth200GE56", + "eth57": "Eth200GE57", + "eth58": "Eth200GE58", + "eth59": "Eth200GE59", + "eth60": "Eth200GE60", + "eth61": "Eth200GE61", + "eth62": "Eth200GE62", + "eth63": "Eth200GE63", + "eth64": "Eth200GE64", + "eth65": "Eth200GE65", + "eth66": "Eth200GE66", + "eth67": "Eth200GE67", + "eth68": "Eth200GE68", + "eth69": "Eth200GE69", + "eth70": "Eth200GE70", + "eth71": "Eth200GE71", + "eth72": "Eth200GE72", + "eth73": "Eth200GE73", + "eth74": "Eth200GE74", + "eth75": "Eth200GE75", + "eth76": "Eth200GE76", + "eth77": "Eth200GE77", + "eth78": "Eth200GE78", + "eth79": "Eth200GE79", + "eth80": "Eth200GE80", + "eth81": "Eth200GE81", + "eth82": "Eth200GE82", + "eth83": "Eth200GE83", + "eth84": "Eth200GE84", + "eth85": "Eth200GE85", + "eth86": "Eth200GE86", + "eth87": "Eth200GE87", + "eth88": "Eth200GE88", + "eth89": "Eth200GE89", + "eth90": "Eth200GE90", + "eth91": "Eth200GE91", + "eth92": "Eth200GE92", + "eth93": "Eth200GE93", + "eth94": "Eth200GE94", + "eth95": "Eth200GE95", + "eth96": "Eth200GE96", + "eth97": "Eth200GE97", + "eth98": "Eth200GE98", + "eth99": "Eth200GE99", + "eth100": "Eth200GE100", + "eth101": "Eth200GE101", + "eth102": "Eth200GE102", + "eth103": "Eth200GE103", + "eth104": "Eth200GE104", + "eth105": "Eth200GE105", + "eth106": "Eth200GE106", + "eth107": "Eth200GE107", + "eth108": "Eth200GE108", + "eth109": "Eth200GE109", + "eth110": "Eth200GE110", + "eth111": "Eth200GE111", + "eth112": "Eth200GE112", + "eth113": "Eth200GE113", + "eth114": "Eth200GE114", + "eth115": "Eth200GE115", + "eth116": "Eth200GE116", + "eth117": "Eth200GE117", + "eth118": "Eth200GE118", + "eth119": "Eth200GE119", + "eth120": "Eth200GE120", + "eth121": "Eth200GE121", + "eth122": "Eth200GE122", + "eth123": "Eth200GE123", + "eth124": "Eth200GE124", + "eth125": "Eth200GE125", + "eth126": "Eth200GE126", + "eth127": "Eth200GE127", + "eth128": "Eth200GE128", + } + }, + "fans": { + "present": {"path": ["/sys/s3ip/fan/*/status"], "ABSENT":0}, + "status": [ + {"path": "/sys/s3ip/fan/%s/status", 'okval': 1}, + ], + "nochangedmsgflag": 1, + "nochangedmsgtime": 60, + "noprintfirsttimeflag": 0 + }, + "psus": { + "present" : {"path": ["/sys/s3ip/psu/*/present"], "ABSENT":0}, + "status" : [ + {"path": "/sys/s3ip/psu/%s/out_status", "okval":1}, + ], + "nochangedmsgflag": 1, + "nochangedmsgtime": 60, + "noprintfirsttimeflag": 0 + }, + "temps": { + "temps_list":[ + {"name":"air_inlet", "input_path":"/sys/bus/i2c/devices/107-004b/hwmon/*/temp1_input", "input_accuracy":1000, "warning":43, "critical":53}, + {"name":"MAC_air_outlet", "input_path":"/sys/bus/i2c/devices/70-004f/hwmon/*/temp1_input", "input_accuracy":1000, "warning":70, "critical":75}, + {"name":"CPU_TEMP", "input_path":"/sys/devices/platform/coretemp.0/hwmon/*/temp1_input", "input_accuracy":1000, "warning":100, "critical":102}, + {"name":"SWITCH_TEMP", "input_path":"/sys/bus/i2c/devices/74-0044/hwmon/*/temp99_input", "input_accuracy":1000, "warning":100, "critical":105}, + ], + "over_temps_polling_seconds": 60, + }, +} + +INIT_PARAM = [ ] +INIT_COMMAND = [ + "i2cset -f -y 60 0x3d 0x80 0xff", + "i2cset -f -y 77 0x1d 0x7c 0xff", + "i2cset -f -y 111 0x3d 0x80 0xff", + "i2cset -f -y 60 0x3d 0xd0 0xff", + "i2cset -f -y 77 0x1d 0xca 0xff", + "i2cset -f -y 77 0x2d 0xd6 0xff", + "i2cset -f -y 111 0x3d 0xd0 0xff", +] + +INIT_PARAM_PRE = [ + {"loc":"75-0010/avs_vout_max","value": "882564"}, + {"loc":"75-0010/avs_vout_min","value": "789233"}, +] +INIT_COMMAND_PRE = [ ] diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/config/x86_64_tencent_tcs9400_r0_config.py b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/config/x86_64_tencent_tcs9400_r0_config.py new file mode 100755 index 000000000000..cb1c18c03717 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/config/x86_64_tencent_tcs9400_r0_config.py @@ -0,0 +1,1422 @@ +#!/usr/bin/python3 +from ruijiecommon import * + + +STARTMODULE = { + "xdpe_avscontrol":1, + "dev_monitor": 1, + "hal_fanctrl":1, + "hal_ledctrl":1, + "sff_temp_polling":1, + "rg_pmon_syslog":1, +} + +DEV_MONITOR_PARAM = { + "polling_time" : 10, + "psus": [ + {"name": "psu1", + "present": {"gettype": "io", "io_addr": 0x964, "presentbit": 0, "okval": 0}, + "device": [ + {"id": "psu1pmbus", "name": "rg_fsp1200", "bus": 79, "loc": 0x58, "attr": "hwmon"}, + {"id": "psu1frue2", "name": "24c02", "bus": 79, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "psu2", + "present": {"gettype": "io", "io_addr": 0x964, "presentbit": 4, "okval": 0}, + "device": [ + {"id": "psu2pmbus", "name": "rg_fsp1200", "bus": 80, "loc": 0x58, "attr": "hwmon"}, + {"id": "psu2frue2", "name": "24c02", "bus": 80, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "psu3", + "present": {"gettype": "io", "io_addr": 0x965, "presentbit": 4, "okval": 0}, + "device": [ + {"id": "psu3pmbus", "name": "rg_fsp1200", "bus": 82, "loc": 0x58, "attr": "hwmon"}, + {"id": "psu3frue2", "name": "24c02", "bus": 82, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "psu4", + "present": {"gettype": "io", "io_addr": 0x965, "presentbit": 0, "okval": 0}, + "device": [ + {"id": "psu4pmbus", "name": "rg_fsp1200", "bus": 81, "loc": 0x58, "attr": "hwmon"}, + {"id": "psu4frue2", "name": "24c02", "bus": 81, "loc": 0x50, "attr": "eeprom"}, + ], + }, + ], + "fans": [ + {"name": "fan1", + "present": {"gettype": "i2c", "bus": 87, "loc": 0x0d, "offset": 0x30, "presentbit": 0, "okval": 0}, + "device": [ + {"id": "fan1frue2", "name": "24c64", "bus": 90, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan2", + "present": {"gettype": "i2c", "bus": 95, "loc": 0x0d, "offset": 0x30, "presentbit": 0, "okval": 0}, + "device": [ + {"id": "fan2frue2", "name": "24c64", "bus": 98, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan3", + "present": {"gettype": "i2c", "bus": 87, "loc": 0x0d, "offset": 0x30, "presentbit": 1, "okval": 0}, + "device": [ + {"id": "fan3frue2", "name": "24c64", "bus": 91, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan4", + "present": {"gettype": "i2c", "bus": 95, "loc": 0x0d, "offset": 0x30, "presentbit": 1, "okval": 0}, + "device": [ + {"id": "fan4frue2", "name": "24c64", "bus": 99, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan5", + "present": {"gettype": "i2c", "bus": 87, "loc": 0x0d, "offset": 0x30, "presentbit": 2, "okval": 0}, + "device": [ + {"id": "fan5frue2", "name": "24c64", "bus": 92, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan6", + "present": {"gettype": "i2c", "bus": 95, "loc": 0x0d, "offset": 0x30, "presentbit": 2, "okval": 0}, + "device": [ + {"id": "fan6frue2", "name": "24c64", "bus": 100, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan7", + "present": {"gettype": "i2c", "bus": 87, "loc": 0x0d, "offset": 0x30, "presentbit": 3, "okval": 0}, + "device": [ + {"id": "fan7frue2", "name": "24c64", "bus": 93, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan8", + "present": {"gettype": "i2c", "bus": 95, "loc": 0x0d, "offset": 0x30, "presentbit": 3, "okval": 0}, + "device": [ + {"id": "fan8frue2", "name": "24c64", "bus": 101, "loc": 0x50, "attr": "eeprom"}, + ], + }, + ], + "others": [ + {"name":"eeprom", + "device":[ + {"id":"eeprom_1", "name":"24c02","bus":1, "loc":0x56, "attr":"eeprom"}, + ], + }, + {"name":"lm75", + "device":[ + {"id":"lm75_1", "name":"lm75","bus":63, "loc":0x4b, "attr":"hwmon"}, + {"id":"lm75_2", "name":"lm75","bus":64, "loc":0x4f, "attr":"hwmon"}, + {"id":"lm75_3", "name":"lm75","bus":88, "loc":0x48, "attr":"hwmon"}, + {"id":"lm75_4", "name":"lm75","bus":89, "loc":0x49, "attr":"hwmon"}, + {"id":"lm75_5", "name":"lm75","bus":96, "loc":0x48, "attr":"hwmon"}, + {"id":"lm75_6", "name":"lm75","bus":97, "loc":0x49, "attr":"hwmon"}, + {"id":"lm75_7", "name":"lm75","bus":107, "loc":0x4b, "attr":"hwmon"}, + {"id":"lm75_8", "name":"lm75","bus":109, "loc":0x4b, "attr":"hwmon"}, + {"id":"lm75_9", "name":"lm75","bus":69, "loc":0x4b, "attr":"hwmon"}, + {"id":"lm75_10", "name":"lm75","bus":70, "loc":0x4f, "attr":"hwmon"}, + {"id":"lm75_11", "name":"lm75","bus":114, "loc":0x4b, "attr":"hwmon"}, + {"id":"lm75_12", "name":"lm75","bus":115, "loc":0x4f, "attr":"hwmon"}, + ], + }, + {"name":"mac_bsc", + "device":[ + {"id":"mac_bsc_1", "name":"rg_mac_bsc_th4","bus":74, "loc":0x44, "attr":"hwmon"}, + ], + }, + {"name":"ina3221", + "device":[ + {"id":"ina3221_1", "name":"rg_ina3221","bus":106, "loc":0x43, "attr":"hwmon"}, + ], + }, + {"name":"tps53622", + "device":[ + {"id":"tps53622_1", "name":"rg_tps53622","bus":106, "loc":0x60, "attr":"hwmon"}, + {"id":"tps53622_2", "name":"rg_tps53622","bus":106, "loc":0x6c, "attr":"hwmon"}, + ], + }, + {"name":"ucd90160", + "device":[ + {"id":"ucd90160_1", "name":"rg_ucd90160","bus":62, "loc":0x5b, "attr":"hwmon"}, + {"id":"ucd90160_2", "name":"rg_ucd90160","bus":105, "loc":0x5b, "attr":"hwmon"}, + {"id":"ucd90160_3", "name":"rg_ucd90160","bus":73, "loc":0x5b, "attr":"hwmon"}, + {"id":"ucd90160_4", "name":"rg_ucd90160","bus":113, "loc":0x5b, "attr":"hwmon"}, + ], + }, + {"name":"tmp411", + "device":[ + {"id":"tmp411_1", "name":"tmp411","bus":71, "loc":0x4c, "attr":"hwmon"}, + {"id":"tmp411_2", "name":"tmp411","bus":72, "loc":0x4c, "attr":"hwmon"}, + ], + }, + ], +} + +CPLDVERSIONS = [ ] +MANUINFO_CONF = { + "bios": { + "key": "BIOS", + "head": True, + "next": "bmc" + }, + "bios_vendor": { + "parent": "bios", + "key": "Vendor", + "cmd": "dmidecode -t 0 |grep Vendor", + "pattern": r".*Vendor", + "separator": ":", + "arrt_index" : 1, + }, + "bios_version": { + "parent": "bios", + "key": "Version", + "cmd": "dmidecode -t 0 |grep Version", + "pattern": r".*Version", + "separator": ":", + "arrt_index" : 2, + }, + "bios_date": { + "parent": "bios", + "key": "Release Date", + "cmd": "dmidecode -t 0 |grep Release", + "pattern": r".*Release Date", + "separator": ":", + "arrt_index" : 3, + }, + + "bmc": { + "key": "BMC", + "next": "onie" + }, + "bmc_version": { + "parent": "bmc", + "key": "Version", + "cmd": "ipmitool mc info |grep \"Firmware Revision\"", + "pattern": r".*Firmware Revision", + "separator": ":", + "arrt_index" : 1, + }, + + "onie": { + "key": "ONIE", + "next": "cpu" + }, + "onie_date": { + "parent": "onie", + "key": "Build Date", + "file": "/host/machine.conf", + "pattern": r"^onie_build_date", + "separator": "=", + "arrt_index" : 1, + }, + "onie_version": { + "parent": "onie", + "key": "Version", + "file": "/host/machine.conf", + "pattern": r"^onie_version", + "separator": "=", + "arrt_index" : 2, + }, + "onie_sub_version": { + "parent": "onie", + "key": "Sub Version", + "file": "/host/machine.conf", + "pattern": r"^onie_sub_version", + "separator": "=", + "arrt_index" : 3, + }, + + "cpu": { + "key": "CPU", + "next": "ssd" + }, + "cpu_vendor": { + "parent": "cpu", + "key": "Vendor", + "cmd": "dmidecode --type processor |grep Manufacturer", + "pattern": r".*Manufacturer", + "separator": ":", + "arrt_index" : 1, + }, + "cpu_model": { + "parent": "cpu", + "key": "Device Model", + "cmd": "dmidecode --type processor | grep Version", + "pattern": r".*Version", + "separator": ":", + "arrt_index" : 2, + }, + "cpu_core": { + "parent": "cpu", + "key": "Core Count", + "cmd": "dmidecode --type processor | grep \"Core Count\"", + "pattern": r".*Core Count", + "separator": ":", + "arrt_index" : 3, + }, + "cpu_thread": { + "parent": "cpu", + "key": "Thread Count", + "cmd": "dmidecode --type processor | grep \"Thread Count\"", + "pattern": r".*Thread Count", + "separator": ":", + "arrt_index" : 4, + }, + + "ssd": { + "key": "SSD", + "next": "cpld" + }, + "ssd_model": { + "parent": "ssd", + "key": "Device Model", + "cmd": "smartctl -i /dev/sda |grep \"Device Model\"", + "pattern": r".*Device Model", + "separator": ":", + "arrt_index" : 1, + }, + "ssd_fw": { + "parent": "ssd", + "key": "Firmware Version", + "cmd": "smartctl -i /dev/sda |grep \"Firmware Version\"", + "pattern": r".*Firmware Version", + "separator": ":", + "arrt_index" : 2, + }, + "ssd_user_cap": { + "parent": "ssd", + "key": "User Capacity", + "cmd": "smartctl -i /dev/sda |grep \"User Capacity\"", + "pattern": r".*User Capacity", + "separator": ":", + "arrt_index" : 3, + }, + + "cpld": { + "key": "CPLD", + "next": "psu" + }, + + "cpld1": { + "key": "CPLD1", + "parent": "cpld", + "arrt_index" : 1, + }, + "cpld1_model": { + "key": "Device Model", + "parent": "cpld1", + "config" : "LCMXO3LF-2100C-5BG256C", + "arrt_index" : 1, + }, + "cpld1_vender": { + "key": "Vendor", + "parent": "cpld1", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld1_desc": { + "key": "Description", + "parent": "cpld1", + "config" : "CPU_CPLD", + "arrt_index" : 3, + }, + "cpld1_version": { + "key": "Firmware Version", + "parent": "cpld1", + "reg": { + "loc": "/dev/port", + "offset": 0x700, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld2": { + "key": "CPLD2", + "parent": "cpld", + "arrt_index" : 2, + }, + "cpld2_model": { + "key": "Device Model", + "parent": "cpld2", + "config" : "LCMXO3LF-4300C-6BG324I", + "arrt_index" : 1, + }, + "cpld2_vender": { + "key": "Vendor", + "parent": "cpld2", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld2_desc": { + "key": "Description", + "parent": "cpld2", + "config" : "BASE_CPLD", + "arrt_index" : 3, + }, + "cpld2_version": { + "key": "Firmware Version", + "parent": "cpld2", + "reg": { + "loc": "/dev/port", + "offset": 0x900, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld3": { + "key": "CPLD3", + "parent": "cpld", + "arrt_index" : 3, + }, + "cpld3_model": { + "key": "Device Model", + "parent": "cpld3", + "config" : "LCMXO3LF-4300C-6BG324I", + "arrt_index" : 1, + }, + "cpld3_vender": { + "key": "Vendor", + "parent": "cpld3", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld3_desc": { + "key": "Description", + "parent": "cpld3", + "config" : "UPORT_CPLD", + "arrt_index" : 3, + }, + "cpld3_version": { + "key": "Firmware Version", + "parent": "cpld3", + "i2c": { + "bus": "60", + "loc": "0x3d", + "offset": 0, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld4": { + "key": "CPLD4", + "parent": "cpld", + "arrt_index" : 4, + }, + "cpld4_model": { + "key": "Device Model", + "parent": "cpld4", + "config" : "LCMXO3LF-2100C-5BG256C", + "arrt_index" : 1, + }, + "cpld4_vender": { + "key": "Vendor", + "parent": "cpld4", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld4_desc": { + "key": "Description", + "parent": "cpld4", + "config" : "UFCB_CPLD", + "arrt_index" : 3, + }, + "cpld4_version": { + "key": "Firmware Version", + "parent": "cpld4", + "i2c": { + "bus": "87", + "loc": "0x0d", + "offset": 0, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld5": { + "key": "CPLD5", + "parent": "cpld", + "arrt_index" : 5, + }, + "cpld5_model": { + "key": "Device Model", + "parent": "cpld5", + "config" : "LCMXO3LF-2100C-5BG256C", + "arrt_index" : 1, + }, + "cpld5_vender": { + "key": "Vendor", + "parent": "cpld5", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld5_desc": { + "key": "Description", + "parent": "cpld5", + "config" : "DFCB_CPLD", + "arrt_index" : 3, + }, + "cpld5_version": { + "key": "Firmware Version", + "parent": "cpld5", + "i2c": { + "bus": "95", + "loc": "0x0d", + "offset": 0, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld6": { + "key": "CPLD6", + "parent": "cpld", + "arrt_index" : 6, + }, + "cpld6_model": { + "key": "Device Model", + "parent": "cpld6", + "config" : "LCMXO3LF-4300C-6BG324I", + "arrt_index" : 1, + }, + "cpld6_vender": { + "key": "Vendor", + "parent": "cpld6", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld6_desc": { + "key": "Description", + "parent": "cpld6", + "config" : "MAC_CPLDA", + "arrt_index" : 3, + }, + "cpld6_version": { + "key": "Firmware Version", + "parent": "cpld6", + "i2c": { + "bus": "77", + "loc": "0x1d", + "offset": 0, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld7": { + "key": "CPLD7", + "parent": "cpld", + "arrt_index" : 7, + }, + "cpld7_model": { + "key": "Device Model", + "parent": "cpld7", + "config" : "LCMXO3LF-4300C-6BG324I", + "arrt_index" : 1, + }, + "cpld7_vender": { + "key": "Vendor", + "parent": "cpld7", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld7_desc": { + "key": "Description", + "parent": "cpld7", + "config" : "MAC_CPLDB", + "arrt_index" : 3, + }, + "cpld7_version": { + "key": "Firmware Version", + "parent": "cpld7", + "i2c": { + "bus": "77", + "loc": "0x2d", + "offset": 0, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld8": { + "key": "CPLD8", + "parent": "cpld", + "arrt_index" : 8, + }, + "cpld8_model": { + "key": "Device Model", + "parent": "cpld8", + "config" : "LCMXO3LF-4300C-6BG324I", + "arrt_index" : 1, + }, + "cpld8_vender": { + "key": "Vendor", + "parent": "cpld8", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld8_desc": { + "key": "Description", + "parent": "cpld8", + "config" : "DPORT_CPLD", + "arrt_index" : 3, + }, + "cpld8_version": { + "key": "Firmware Version", + "parent": "cpld8", + "i2c": { + "bus": "111", + "loc": "0x3d", + "offset": 0, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "psu": { + "key": "PSU", + "next": "fan" + }, + + "psu1": { + "parent": "psu", + "key": "PSU1", + "arrt_index" : 1, + }, + "psu1_hw_version": { + "key": "Hardware Version", + "parent": "psu1", + "extra": { + "funcname": "getPsu", + "id": "psu1", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "psu1_fw_version": { + "key": "Firmware Version", + "parent": "psu1", + "config" : "NA", + "arrt_index" : 2, + }, + + "psu2": { + "parent": "psu", + "key": "PSU2", + "arrt_index" : 2, + }, + "psu2_hw_version": { + "key": "Hardware Version", + "parent": "psu2", + "extra": { + "funcname": "getPsu", + "id": "psu2", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "psu2_fw_version": { + "key": "Firmware Version", + "parent": "psu2", + "config" : "NA", + "arrt_index" : 2, + }, + + "psu3": { + "parent": "psu", + "key": "PSU3", + "arrt_index" : 3, + }, + "psu3_hw_version": { + "key": "Hardware Version", + "parent": "psu3", + "extra": { + "funcname": "getPsu", + "id": "psu3", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "psu3_fw_version": { + "key": "Firmware Version", + "parent": "psu3", + "config" : "NA", + "arrt_index" : 2, + }, + + "psu4": { + "parent": "psu", + "key": "PSU4", + "arrt_index" : 4, + }, + "psu4_hw_version": { + "key": "Hardware Version", + "parent": "psu4", + "extra": { + "funcname": "getPsu", + "id": "psu4", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "psu4_fw_version": { + "key": "Firmware Version", + "parent": "psu4", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan": { + "key": "FAN", + "next": "i210" + }, + + "fan1": { + "key": "FAN1", + "parent": "fan", + "arrt_index" : 1, + }, + "fan1_hw_version": { + "key": "Hardware Version", + "parent": "fan1", + "extra": { + "funcname": "checkFan", + "id": "fan1", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan1_fw_version": { + "key": "Firmware Version", + "parent": "fan1", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan2": { + "key": "FAN2", + "parent": "fan", + "arrt_index" : 2, + }, + "fan2_hw_version": { + "key": "Hardware Version", + "parent": "fan2", + "extra": { + "funcname": "checkFan", + "id": "fan2", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan2_fw_version": { + "key": "Firmware Version", + "parent": "fan2", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan3": { + "key": "FAN3", + "parent": "fan", + "arrt_index" : 3, + }, + "fan3_hw_version": { + "key": "Hardware Version", + "parent": "fan3", + "extra": { + "funcname": "checkFan", + "id": "fan3", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan3_fw_version": { + "key": "Firmware Version", + "parent": "fan3", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan4": { + "key": "FAN4", + "parent": "fan", + "arrt_index" : 4, + }, + "fan4_hw_version": { + "key": "Hardware Version", + "parent": "fan4", + "extra": { + "funcname": "checkFan", + "id": "fan4", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan4_fw_version": { + "key": "Firmware Version", + "parent": "fan4", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan5": { + "key": "FAN5", + "parent": "fan", + "arrt_index" : 5, + }, + "fan5_hw_version": { + "key": "Hardware Version", + "parent": "fan5", + "extra": { + "funcname": "checkFan", + "id": "fan5", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan5_fw_version": { + "key": "Firmware Version", + "parent": "fan5", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan6": { + "key": "FAN6", + "parent": "fan", + "arrt_index" : 6, + }, + "fan6_hw_version": { + "key": "Hardware Version", + "parent": "fan6", + "extra": { + "funcname": "checkFan", + "id": "fan6", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan6_fw_version": { + "key": "Firmware Version", + "parent": "fan6", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan7": { + "key": "FAN7", + "parent": "fan", + "arrt_index" : 7, + }, + "fan7_hw_version": { + "key": "Hardware Version", + "parent": "fan7", + "extra": { + "funcname": "checkFan", + "id": "fan7", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan7_fw_version": { + "key": "Firmware Version", + "parent": "fan7", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan8": { + "key": "FAN8", + "parent": "fan", + "arrt_index" : 8, + }, + "fan8_hw_version": { + "key": "Hardware Version", + "parent": "fan8", + "extra": { + "funcname": "checkFan", + "id": "fan8", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan8_fw_version": { + "key": "Firmware Version", + "parent": "fan8", + "config" : "NA", + "arrt_index" : 2, + }, + + "i210": { + "key": "NIC", + "next": "fpga" + }, + "i210_model": { + "parent": "i210", + "config": "NA", + "key": "Device Model", + "arrt_index" : 1, + }, + "i210_vendor": { + "parent": "i210", + "config": "INTEL", + "key": "Vendor", + "arrt_index" : 2, + }, + "i210_version": { + "parent": "i210", + "cmd": "ethtool -i eth0", + "pattern": r"firmware-version", + "separator": ":", + "key": "Firmware Version", + "arrt_index" : 3, + }, + + "fpga": { + "key": "FPGA", + "next": "others" + }, + + "fpga1": { + "key": "FPGA1", + "parent": "fpga", + "arrt_index" : 1, + }, + "fpga1_model": { + "parent": "fpga1", + "devfile": { + "loc": "/dev/fpga0", + "offset":0x98, + "len":4, + "bit_width":4 + }, + "decode": { + "0x00000000": "XC7A100T-2FGG484C", + "0x00000200": "XC7A200T-2FBG484I" + }, + "key": "Device Model", + "arrt_index" : 1, + }, + "fpga1_vender": { + "parent": "fpga1", + "config" : "XILINX", + "key": "Vendor", + "arrt_index" : 2, + }, + "fpga1_desc": { + "key": "Description", + "parent": "fpga1", + "config" : "UPORT_FPGA", + "arrt_index" : 3, + }, + "fpga1_hw_version": { + "parent": "fpga1", + "config" : "NA", + "key": "Hardware Version", + "arrt_index" : 4, + }, + "fpga1_fw_version": { + "parent": "fpga1", + "pci": { + "bus" : 0x0a, + "slot" : 0, + "fn" : 0, + "bar" : 0, + "offset" : 0 + }, + "key": "Firmware Version", + "arrt_index" : 5, + }, + + "fpga2": { + "key": "FPGA2", + "parent": "fpga", + "arrt_index" : 2, + }, + "fpga2_model": { + "parent": "fpga2", + "devfile": { + "loc": "/dev/fpga1", + "offset":0xb0, + "len":4, + "bit_width":4 + }, + "decode": { + "0x00000000": "XC7A100T-2FGG484C", + "0x00000200": "XC7A200T-2FBG484I" + }, + "key": "Device Model", + "arrt_index" : 1, + }, + "fpga2_vender": { + "parent": "fpga2", + "config" : "XILINX", + "key": "Vendor", + "arrt_index" : 2, + }, + "fpga2_desc": { + "key": "Description", + "parent": "fpga2", + "config" : "MAC_FPGA", + "arrt_index" : 3, + }, + "fpga2_hw_version": { + "parent": "fpga2", + "config" : "NA", + "key": "Hardware Version", + "arrt_index" : 4, + }, + "fpga2_fw_version": { + "parent": "fpga2", + "pci": { + "bus" : 8, + "slot" : 0, + "fn" : 0, + "bar" : 0, + "offset" : 0 + }, + "key": "Firmware Version", + "arrt_index" : 5, + }, + + "fpga3": { + "key": "FPGA3", + "parent": "fpga", + "arrt_index" : 3, + }, + "fpga3_model": { + "parent": "fpga3", + "devfile": { + "loc": "/dev/fpga2", + "offset":0x98, + "len":4, + "bit_width":4 + }, + "decode": { + "0x00000000": "XC7A100T-2FGG484C", + "0x00000200": "XC7A200T-2FBG484I" + }, + "key": "Device Model", + "arrt_index" : 1, + }, + "fpga3_vender": { + "parent": "fpga3", + "config" : "XILINX", + "key": "Vendor", + "arrt_index" : 2, + }, + "fpga3_desc": { + "key": "Description", + "parent": "fpga3", + "config" : "DPORT_FPGA", + "arrt_index" : 3, + }, + "fpga3_hw_version": { + "parent": "fpga3", + "config" : "NA", + "key": "Hardware Version", + "arrt_index" : 4, + }, + "fpga3_fw_version": { + "parent": "fpga3", + "pci": { + "bus" : 0xb, + "slot" : 0, + "fn" : 0, + "bar" : 0, + "offset" : 0 + }, + "key": "Firmware Version", + "arrt_index" : 5, + }, + + "others": { + "key": "OTHERS", + }, + "5387": { + "parent": "others", + "key": "CPU-BMC-SWITCH", + "arrt_index" : 1, + }, + "5387_model": { + "parent": "5387", + "config": "BCM5387", + "key": "Device Model", + "arrt_index" : 1, + }, + "5387_vendor": { + "parent": "5387", + "config": "Broadcom", + "key": "Vendor", + "arrt_index" : 2, + }, + "5387_hw_version": { + "parent": "5387", + "key": "Hardware Version", + "func": { + "funcname": "get_bcm5387_version", + "params" : { + "before": [ + {"dealtype": "shell", "cmd": "echo 50 > /sys/class/gpio/export"}, + {"dealtype": "shell", "cmd": "echo high > /sys/class/gpio/gpio50/direction"}, + {"dealtype": "shell", "cmd": "echo 48 > /sys/class/gpio/export"}, + {"dealtype": "shell", "cmd": "echo high > /sys/class/gpio/gpio48/direction"}, + {"dealtype": "io_wr", "io_addr": 0x918, "value":0x06}, + {"dealtype": "io_wr", "io_addr": 0x943, "value":0x00}, + ], + "get_version" : "md5sum /sys/bus/spi/devices/spi0.0/eeprom | awk '{print $1}'", + "after": [ + {"dealtype": "shell", "cmd": "echo 0 > /sys/class/gpio/gpio48/value"}, + {"dealtype": "shell", "cmd": "echo 48 > /sys/class/gpio/unexport"}, + {"dealtype": "shell", "cmd": "echo 0 > /sys/class/gpio/gpio50/value"}, + {"dealtype": "shell", "cmd": "echo 50 > /sys/class/gpio/unexport"}, + ], + "finally": [ + {"dealtype": "io_wr", "io_addr": 0x943, "value":0x01}, + {"dealtype": "io_wr", "io_addr": 0x918, "value":0x00}, + ], + }, + }, + "arrt_index" : 3, + }, +} + +MAC_AVS_PARAM = { + 0x7e: 0.882564, + 0x82: 0.859436, + 0x86: 0.836776, + 0x8A: 0.813531, + 0x8E: 0.789233, +} + +AVS_VOUT_MODE_PARAM ={ + 0x18:256, # 2^8 + 0x17:512, # 2^9 + 0x16:1024, # 2^10 + 0x15:2048, # 2^11 + 0x14:4096, # 2^12 +} + +MAC_DEFAULT_PARAM = { + "type": 0, + "default":0x82, + "bus":75, + "devno":0x10, + "loopaddr":0xff, + "loop":0x06, + "vout_cmd_addr":0x42, + "vout_mode_addr":0x40, + "sdktype": 0, + "macregloc":24 , + "mask": 0xff, + "rov_source":0, + "cpld_avs":{"bus":77, "loc":0x1d, "offset":0x24, "gettype":"i2c"}, + "set_avs": {"loc": "/sys/bus/i2c/devices/75-0010/avs_vout", "gettype": "sysfs", "formula": "int((%f)*1000000)"}, +} + +## +DRIVERLISTS = [ + {"name": "rg_gpio_d1500", "delay": 0}, + {"name": "i2c_dev", "delay": 0}, + {"name": "i2c_gpio", "delay":0}, + {"name": "i2c_mux", "delay":0}, + {"name": "rg_fpga_pcie", "delay": 0}, + {"name": "rg_pcie_dev", "delay": 0}, + {"name": "rg_lpc_drv", "delay": 0}, + {"name": "rg_io_dev", "delay": 0}, + {"name": "rg_i2c_dev", "delay": 0}, + {"name": "rg_fpga_i2c_bus_drv", "delay": 0}, + {"name": "rg_fpga_pca954x_drv", "delay": 0}, + {"name": "rg_wdt", "delay": 0}, + {"name": "rg_gpio_device", "delay": 0}, + {"name": "rg_i2c_gpio_device", "delay":0}, + {"name": "rg_pcie_dev_device", "delay": 0}, + {"name": "rg_lpc_drv_device", "delay": 0}, + {"name": "rg_io_dev_device", "delay": 0}, + {"name": "rg_fpga_i2c_bus_device", "delay": 0}, + {"name": "rg_fpga_pca954x_device", "delay": 0}, + {"name": "rg_i2c_dev_device", "delay": 0}, + {"name": "rg_wdt_device", "delay": 0}, + {"name": "ruijie_common dfd_my_type_i2c_bus=1 dfd_my_type_i2c_addr=0x56", "delay": 1}, + {"name": "rg_spi_gpio_device", "delay": 0}, + {"name": "rg_eeprom_93xx46", "delay": 0}, + {"name": "lm75", "delay":0}, + {"name": "tmp401", "delay":0}, + {"name": "rg_optoe", "delay": 0}, + {"name": "at24", "delay": 0}, + {"name": "rg_mac_bsc", "delay": 0}, + {"name": "rg_pmbus_core", "delay":0}, + {"name": "rg_csu550", "delay": 0}, + {"name": "rg_ina3221", "delay": 0}, + {"name": "rg_tps53622", "delay": 0}, + {"name": "rg_ucd9000", "delay": 0}, + {"name": "rg_xdpe132g5c", "delay": 0}, + {"name": "s3ip_sysfs", "delay": 0}, + {"name": "rg_switch_driver", "delay": 0}, + {"name": "syseeprom_device_driver", "delay": 0}, + {"name": "fan_device_driver", "delay": 0}, + {"name": "cpld_device_driver", "delay": 0}, + {"name": "sysled_device_driver", "delay": 0}, + {"name": "psu_device_driver", "delay": 0}, + {"name": "transceiver_device_driver", "delay": 0}, + {"name": "temp_sensor_device_driver", "delay": 0}, + {"name": "vol_sensor_device_driver", "delay": 0}, + {"name": "curr_sensor_device_driver", "delay": 0}, + {"name": "fpga_device_driver", "delay": 0}, + {"name": "watchdog_device_driver", "delay": 0}, + {"name": "rg_plat_dfd", "delay":0}, + {"name": "rg_plat_switch", "delay":0}, + {"name": "rg_plat_fan", "delay":0}, + {"name": "rg_plat_psu", "delay":0}, + {"name": "rg_plat_sff", "delay":0}, + {"name": "rg_plat_sensor", "delay": 0}, +] + +DEVICE = [ + # GPIO-I2C + {"name": "24c02", "bus":1, "loc":0x56 }, + # UP port board + {"name": "rg_ucd90160", "bus": 62, "loc": 0x5b}, + {"name": "lm75", "bus": 63, "loc": 0x4b}, + {"name": "lm75", "bus": 64, "loc": 0x4f}, + # MAC board + # PSU + {"name": "24c02", "bus":79, "loc":0x50}, + {"name": "rg_fsp1200","bus":79, "loc":0x58 }, + {"name": "24c02", "bus":80, "loc": 0x50}, + {"name": "rg_fsp1200","bus":80, "loc":0x58 }, + {"name": "24c02", "bus":81, "loc":0x50}, + {"name": "rg_fsp1200","bus":81, "loc":0x58 }, + {"name": "24c02", "bus":82, "loc": 0x50}, + {"name": "rg_fsp1200","bus":82, "loc":0x58 }, + # FAN + {"name": "24c64","bus":90,"loc":0x50 }, + {"name": "24c64","bus":91,"loc":0x50 }, + {"name": "24c64","bus":92,"loc":0x50 }, + {"name": "24c64","bus":93,"loc":0x50 }, + {"name": "24c64","bus":98,"loc":0x50 }, + {"name": "24c64","bus":99,"loc":0x50 }, + {"name": "24c64","bus":100,"loc":0x50 }, + {"name": "24c64","bus":101,"loc":0x50 }, + # fan temp + {"name": "lm75", "bus": 88, "loc": 0x48}, + {"name": "lm75", "bus": 89, "loc": 0x49}, + {"name": "lm75", "bus": 96, "loc": 0x48}, + {"name": "lm75", "bus": 97, "loc": 0x49}, + # base temp + {"name": "lm75", "bus": 107, "loc": 0x4b}, + {"name": "lm75", "bus": 109, "loc": 0x4b}, + {"name": "lm75", "bus": 69, "loc": 0x4b}, + {"name": "lm75", "bus": 70, "loc": 0x4f}, + {"name": "tmp411", "bus": 71, "loc": 0x4c}, + {"name": "tmp411", "bus": 72, "loc": 0x4c}, + # base dcdc + {"name": "rg_ucd90160", "bus": 105, "loc": 0x5b}, + {"name": "rg_tps53622", "bus": 106, "loc": 0x60}, + {"name": "rg_tps53622", "bus": 106, "loc": 0x6c}, + {"name": "rg_ina3221", "bus": 106, "loc": 0x43}, + {"name": "rg_ucd90160", "bus": 73, "loc": 0x5b}, + # mac bsc + {"name": "rg_mac_bsc_th4", "bus":74, "loc":0x44 }, + # DOWN port board + {"name": "rg_ucd90160", "bus": 113, "loc": 0x5b}, + {"name": "lm75", "bus": 114, "loc": 0x4b}, + {"name": "lm75", "bus": 115, "loc": 0x4f}, + # xdpe avs + {"name": "rg_xdpe132g5c", "bus": 75, "loc": 0x10}, + {"name": "rg_xdpe132g5c", "bus": 76, "loc": 0x5a}, +] + +OPTOE = [ + {"name": "rg_optoe1", "startbus": 124, "endbus": 251}, +] + +PMON_SYSLOG_STATUS = { + "polling_time": 3, + "sffs": { + "present": {"path": ["/sys/s3ip/transceiver/*/present"], "ABSENT":0}, + "nochangedmsgflag": 0, + "nochangedmsgtime": 60, + "noprintfirsttimeflag": 1, + "alias": { + "eth1": "Eth200GE1", + "eth2": "Eth200GE2", + "eth3": "Eth200GE3", + "eth4": "Eth200GE4", + "eth5": "Eth200GE5", + "eth6": "Eth200GE6", + "eth7": "Eth200GE7", + "eth8": "Eth200GE8", + "eth9": "Eth200GE9", + "eth10": "Eth200GE10", + "eth11": "Eth200GE11", + "eth12": "Eth200GE12", + "eth13": "Eth200GE13", + "eth14": "Eth200GE14", + "eth15": "Eth200GE15", + "eth16": "Eth200GE16", + "eth17": "Eth200GE17", + "eth18": "Eth200GE18", + "eth19": "Eth200GE19", + "eth20": "Eth200GE20", + "eth21": "Eth200GE21", + "eth22": "Eth200GE22", + "eth23": "Eth200GE23", + "eth24": "Eth200GE24", + "eth25": "Eth200GE25", + "eth26": "Eth200GE26", + "eth27": "Eth200GE27", + "eth28": "Eth200GE28", + "eth29": "Eth200GE29", + "eth30": "Eth200GE30", + "eth31": "Eth200GE31", + "eth32": "Eth200GE32", + "eth33": "Eth200GE33", + "eth34": "Eth200GE34", + "eth35": "Eth200GE35", + "eth36": "Eth200GE36", + "eth37": "Eth200GE37", + "eth38": "Eth200GE38", + "eth39": "Eth200GE39", + "eth40": "Eth200GE40", + "eth41": "Eth200GE41", + "eth42": "Eth200GE42", + "eth43": "Eth200GE43", + "eth44": "Eth200GE44", + "eth45": "Eth200GE45", + "eth46": "Eth200GE46", + "eth47": "Eth200GE47", + "eth48": "Eth200GE48", + "eth49": "Eth200GE49", + "eth50": "Eth200GE50", + "eth51": "Eth200GE51", + "eth52": "Eth200GE52", + "eth53": "Eth200GE53", + "eth54": "Eth200GE54", + "eth55": "Eth200GE55", + "eth56": "Eth200GE56", + "eth57": "Eth200GE57", + "eth58": "Eth200GE58", + "eth59": "Eth200GE59", + "eth60": "Eth200GE60", + "eth61": "Eth200GE61", + "eth62": "Eth200GE62", + "eth63": "Eth200GE63", + "eth64": "Eth200GE64", + "eth65": "Eth200GE65", + "eth66": "Eth200GE66", + "eth67": "Eth200GE67", + "eth68": "Eth200GE68", + "eth69": "Eth200GE69", + "eth70": "Eth200GE70", + "eth71": "Eth200GE71", + "eth72": "Eth200GE72", + "eth73": "Eth200GE73", + "eth74": "Eth200GE74", + "eth75": "Eth200GE75", + "eth76": "Eth200GE76", + "eth77": "Eth200GE77", + "eth78": "Eth200GE78", + "eth79": "Eth200GE79", + "eth80": "Eth200GE80", + "eth81": "Eth200GE81", + "eth82": "Eth200GE82", + "eth83": "Eth200GE83", + "eth84": "Eth200GE84", + "eth85": "Eth200GE85", + "eth86": "Eth200GE86", + "eth87": "Eth200GE87", + "eth88": "Eth200GE88", + "eth89": "Eth200GE89", + "eth90": "Eth200GE90", + "eth91": "Eth200GE91", + "eth92": "Eth200GE92", + "eth93": "Eth200GE93", + "eth94": "Eth200GE94", + "eth95": "Eth200GE95", + "eth96": "Eth200GE96", + "eth97": "Eth200GE97", + "eth98": "Eth200GE98", + "eth99": "Eth200GE99", + "eth100": "Eth200GE100", + "eth101": "Eth200GE101", + "eth102": "Eth200GE102", + "eth103": "Eth200GE103", + "eth104": "Eth200GE104", + "eth105": "Eth200GE105", + "eth106": "Eth200GE106", + "eth107": "Eth200GE107", + "eth108": "Eth200GE108", + "eth109": "Eth200GE109", + "eth110": "Eth200GE110", + "eth111": "Eth200GE111", + "eth112": "Eth200GE112", + "eth113": "Eth200GE113", + "eth114": "Eth200GE114", + "eth115": "Eth200GE115", + "eth116": "Eth200GE116", + "eth117": "Eth200GE117", + "eth118": "Eth200GE118", + "eth119": "Eth200GE119", + "eth120": "Eth200GE120", + "eth121": "Eth200GE121", + "eth122": "Eth200GE122", + "eth123": "Eth200GE123", + "eth124": "Eth200GE124", + "eth125": "Eth200GE125", + "eth126": "Eth200GE126", + "eth127": "Eth200GE127", + "eth128": "Eth200GE128", + } + }, + "fans": { + "present": {"path": ["/sys/s3ip/fan/*/status"], "ABSENT":0}, + "status": [ + {"path": "/sys/s3ip/fan/%s/status", 'okval': 1}, + ], + "nochangedmsgflag": 1, + "nochangedmsgtime": 60, + "noprintfirsttimeflag": 0 + }, + "psus": { + "present" : {"path": ["/sys/s3ip/psu/*/present"], "ABSENT":0}, + "status" : [ + {"path": "/sys/s3ip/psu/%s/out_status", "okval":1}, + ], + "nochangedmsgflag": 1, + "nochangedmsgtime": 60, + "noprintfirsttimeflag": 0 + }, + "temps": { + "temps_list":[ + {"name":"air_inlet", "input_path":"/sys/bus/i2c/devices/107-004b/hwmon/*/temp1_input", "input_accuracy":1000, "warning":43, "critical":53}, + {"name":"MAC_air_outlet", "input_path":"/sys/bus/i2c/devices/70-004f/hwmon/*/temp1_input", "input_accuracy":1000, "warning":70, "critical":75}, + {"name":"CPU_TEMP", "input_path":"/sys/devices/platform/coretemp.0/hwmon/*/temp1_input", "input_accuracy":1000, "warning":100, "critical":102}, + {"name":"SWITCH_TEMP", "input_path":"/sys/bus/i2c/devices/74-0044/hwmon/*/temp99_input", "input_accuracy":1000, "warning":100, "critical":105}, + ], + "over_temps_polling_seconds": 60, + }, +} + +INIT_PARAM = [ ] +INIT_COMMAND = [ + "i2cset -f -y 60 0x3d 0x80 0xff", + "i2cset -f -y 77 0x1d 0x7c 0xff", + "i2cset -f -y 111 0x3d 0x80 0xff", + "i2cset -f -y 60 0x3d 0xd0 0xff", + "i2cset -f -y 77 0x1d 0xca 0xff", + "i2cset -f -y 77 0x2d 0xd6 0xff", + "i2cset -f -y 111 0x3d 0xd0 0xff", +] + +INIT_PARAM_PRE = [ + {"loc":"75-0010/avs_vout_max","value": "882564"}, + {"loc":"75-0010/avs_vout_min","value": "789233"}, +] +INIT_COMMAND_PRE = [ ] diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/config/x86_64_tencent_tcs9400_r0_port_config.py b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/config/x86_64_tencent_tcs9400_r0_port_config.py new file mode 100755 index 000000000000..e5a878918a42 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/config/x86_64_tencent_tcs9400_r0_port_config.py @@ -0,0 +1,6 @@ +#!/usr/bin/python3 + +PLATFORM_INTF_OPTOE = { + "port_num": 128, + "optoe_start_bus": 124, +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/hal-config/x86_64_tencent_tcs9400_r0_0x407c_device.py b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/hal-config/x86_64_tencent_tcs9400_r0_0x407c_device.py new file mode 100755 index 000000000000..d5467528e437 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/hal-config/x86_64_tencent_tcs9400_r0_0x407c_device.py @@ -0,0 +1,1739 @@ +#!/usr/bin/python3 + +psu_fan_airflow = { + "F2B": ["DPS-1300AB-6 F", "GW-CRPS1300D"], + "B2F": ["DPS-1300AB-11 C", "CRPS1300D3R"] +} + +psu_display_name = { + "PSA1300CRPS-F": ["DPS-1300AB-6 F", "GW-CRPS1300D"], + "PSA1300CRPS-R": ["DPS-1300AB-11 C", "CRPS1300D3R"] +} + +fanairflow = { + "F2B": ["FAN12K8080-F"], +} + +fan_display_name = { + "FAN12K8080-F": ["FAN12K8080-F"], +} + +psutypedecode = { + 0x00: 'N/A', + 0x01: 'AC', + 0x02: 'DC', +} + + +class Unit: + Temperature = "C" + Voltage = "V" + Current = "A" + Power = "W" + Speed = "RPM" + + +PSU_NOT_PRESENT_PWM = 100 + + +class threshold: + PSU_TEMP_MIN = -10 * 1000 + PSU_TEMP_MAX = 60 * 1000 + + PSU_FAN_SPEED_MIN = 2000 + PSU_FAN_SPEED_MAX = 28000 + + PSU_OUTPUT_VOLTAGE_MIN = 11 * 1000 + PSU_OUTPUT_VOLTAGE_MAX = 14 * 1000 + + PSU_AC_INPUT_VOLTAGE_MIN = 200 * 1000 + PSU_AC_INPUT_VOLTAGE_MAX = 240 * 1000 + + PSU_DC_INPUT_VOLTAGE_MIN = 190 * 1000 + PSU_DC_INPUT_VOLTAGE_MAX = 290 * 1000 + + ERR_VALUE = -9999999 + + PSU_OUTPUT_POWER_MIN = 10 * 1000 * 1000 + PSU_OUTPUT_POWER_MAX = 1300 * 1000 * 1000 + + PSU_INPUT_POWER_MIN = 10 * 1000 * 1000 + PSU_INPUT_POWER_MAX = 1444 * 1000 * 1000 + + PSU_OUTPUT_CURRENT_MIN = 2 * 1000 + PSU_OUTPUT_CURRENT_MAX = 107 * 1000 + + PSU_INPUT_CURRENT_MIN = 0.2 * 1000 + PSU_INPUT_CURRENT_MAX = 7 * 1000 + + FRONT_FAN_SPEED_MAX = 13530 + REAR_FAN_SPEED_MAX = 11770 + FAN_SPEED_MIN = 1650 + + +class Description: + CPLD = "Used for managing IO modules, SFP+ modules and system LEDs" + BIOS = "Performs initialization of hardware components during booting" + FPGA = "Platform management controller for on-board temperature monitoring, in-chassis power" + + +devices = { + "onie_e2": [ + { + "name": "ONIE_E2", + "e2loc": {"loc": "/sys/bus/i2c/devices/1-0056/eeprom", "way": "sysfs"}, + }, + ], + "psus": [ + { + "e2loc": {"loc": "/sys/bus/i2c/devices/79-0050/eeprom", "way": "sysfs"}, + "pmbusloc": {"bus": 79, "addr": 0x58, "way": "i2c"}, + "present": {"loc": "/sys/rg_plat/psu/psu1/present", "way": "sysfs", "mask": 0x01, "okval": 1}, + "name": "PSU1", + "psu_display_name": psu_display_name, + "airflow": psu_fan_airflow, + "psu_not_present_pwm": PSU_NOT_PRESENT_PWM, + "TempStatus": {"bus": 79, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0004}, + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": threshold.PSU_TEMP_MIN, + "Max": threshold.PSU_TEMP_MAX, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + }, + "FanStatus": {"bus": 79, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0400}, + "FanSpeed": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/fan1_input", "way": "sysfs"}, + "Min": threshold.PSU_FAN_SPEED_MIN, + "Max": threshold.PSU_FAN_SPEED_MAX, + "Unit": Unit.Speed + }, + "InputsStatus": {"bus": 79, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x2000}, + "InputsType": {"bus": 79, "addr": 0x58, "offset": 0x80, "way": "i2c", 'psutypedecode': psutypedecode}, + "InputsVoltage": { + 'AC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_AC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_AC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + + }, + 'DC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_DC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_DC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + 'other': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.ERR_VALUE, + "Max": threshold.ERR_VALUE, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + } + }, + "InputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/curr1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_CURRENT_MIN, + "Max": threshold.PSU_INPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "InputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/power1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_POWER_MIN, + "Max": threshold.PSU_INPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + "OutputsStatus": {"bus": 79, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x8800}, + "OutputsVoltage": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/in2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_VOLTAGE_MIN, + "Max": threshold.PSU_OUTPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + "OutputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/curr2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_CURRENT_MIN, + "Max": threshold.PSU_OUTPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "OutputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/power2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_POWER_MIN, + "Max": threshold.PSU_OUTPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + }, + { + "e2loc": {"loc": "/sys/bus/i2c/devices/80-0050/eeprom", "way": "sysfs"}, + "pmbusloc": {"bus": 80, "addr": 0x58, "way": "i2c"}, + "present": {"loc": "/sys/rg_plat/psu/psu2/present", "way": "sysfs", "mask": 0x01, "okval": 1}, + "name": "PSU2", + "psu_display_name": psu_display_name, + "airflow": psu_fan_airflow, + "psu_not_present_pwm": PSU_NOT_PRESENT_PWM, + "TempStatus": {"bus": 80, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0004}, + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": threshold.PSU_TEMP_MIN, + "Max": threshold.PSU_TEMP_MAX, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + }, + "FanStatus": {"bus": 80, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0400}, + "FanSpeed": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/fan1_input", "way": "sysfs"}, + "Min": threshold.PSU_FAN_SPEED_MIN, + "Max": threshold.PSU_FAN_SPEED_MAX, + "Unit": Unit.Speed + }, + "InputsStatus": {"bus": 80, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x2000}, + "InputsType": {"bus": 80, "addr": 0x58, "offset": 0x80, "way": "i2c", 'psutypedecode': psutypedecode}, + "InputsVoltage": { + 'AC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_AC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_AC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + + }, + 'DC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_DC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_DC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + 'other': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.ERR_VALUE, + "Max": threshold.ERR_VALUE, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + } + }, + "InputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/curr1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_CURRENT_MIN, + "Max": threshold.PSU_INPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "InputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/power1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_POWER_MIN, + "Max": threshold.PSU_INPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + "OutputsStatus": {"bus": 80, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x8800}, + "OutputsVoltage": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/in2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_VOLTAGE_MIN, + "Max": threshold.PSU_OUTPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + "OutputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/curr2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_CURRENT_MIN, + "Max": threshold.PSU_OUTPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "OutputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/power2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_POWER_MIN, + "Max": threshold.PSU_OUTPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + }, + { + "e2loc": {"loc": "/sys/bus/i2c/devices/82-0050/eeprom", "way": "sysfs"}, + "pmbusloc": {"bus": 82, "addr": 0x58, "way": "i2c"}, + "present": {"loc": "/sys/rg_plat/psu/psu3/present", "way": "sysfs", "mask": 0x01, "okval": 1}, + "name": "PSU3", + "psu_display_name": psu_display_name, + "airflow": psu_fan_airflow, + "psu_not_present_pwm": PSU_NOT_PRESENT_PWM, + "TempStatus": {"bus": 82, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0004}, + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": threshold.PSU_TEMP_MIN, + "Max": threshold.PSU_TEMP_MAX, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + }, + "FanStatus": {"bus": 82, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0400}, + "FanSpeed": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/fan1_input", "way": "sysfs"}, + "Min": threshold.PSU_FAN_SPEED_MIN, + "Max": threshold.PSU_FAN_SPEED_MAX, + "Unit": Unit.Speed + }, + "InputsStatus": {"bus": 82, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x2000}, + "InputsType": {"bus": 82, "addr": 0x58, "offset": 0x80, "way": "i2c", 'psutypedecode': psutypedecode}, + "InputsVoltage": { + 'AC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_AC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_AC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + + }, + 'DC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_DC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_DC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + 'other': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.ERR_VALUE, + "Max": threshold.ERR_VALUE, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + } + }, + "InputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/curr1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_CURRENT_MIN, + "Max": threshold.PSU_INPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "InputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/power1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_POWER_MIN, + "Max": threshold.PSU_INPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + "OutputsStatus": {"bus": 82, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x8800}, + "OutputsVoltage": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/in2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_VOLTAGE_MIN, + "Max": threshold.PSU_OUTPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + "OutputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/curr2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_CURRENT_MIN, + "Max": threshold.PSU_OUTPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "OutputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/power2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_POWER_MIN, + "Max": threshold.PSU_OUTPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + }, + { + "e2loc": {"loc": "/sys/bus/i2c/devices/81-0050/eeprom", "way": "sysfs"}, + "pmbusloc": {"bus": 81, "addr": 0x58, "way": "i2c"}, + "present": {"loc": "/sys/rg_plat/psu/psu4/present", "way": "sysfs", "mask": 0x01, "okval": 1}, + "name": "PSU4", + "psu_display_name": psu_display_name, + "airflow": psu_fan_airflow, + "psu_not_present_pwm": PSU_NOT_PRESENT_PWM, + "TempStatus": {"bus": 81, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0004}, + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": threshold.PSU_TEMP_MIN, + "Max": threshold.PSU_TEMP_MAX, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + }, + "FanStatus": {"bus": 81, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0400}, + "FanSpeed": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/fan1_input", "way": "sysfs"}, + "Min": threshold.PSU_FAN_SPEED_MIN, + "Max": threshold.PSU_FAN_SPEED_MAX, + "Unit": Unit.Speed + }, + "InputsStatus": {"bus": 81, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x2000}, + "InputsType": {"bus": 81, "addr": 0x58, "offset": 0x80, "way": "i2c", 'psutypedecode': psutypedecode}, + "InputsVoltage": { + 'AC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_AC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_AC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + + }, + 'DC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_DC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_DC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + 'other': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.ERR_VALUE, + "Max": threshold.ERR_VALUE, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + } + }, + "InputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/curr1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_CURRENT_MIN, + "Max": threshold.PSU_INPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "InputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/power1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_POWER_MIN, + "Max": threshold.PSU_INPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + "OutputsStatus": {"bus": 81, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x8800}, + "OutputsVoltage": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/in2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_VOLTAGE_MIN, + "Max": threshold.PSU_OUTPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + "OutputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/curr2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_CURRENT_MIN, + "Max": threshold.PSU_OUTPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "OutputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/power2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_POWER_MIN, + "Max": threshold.PSU_OUTPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + }, + ], + "temps":[ + { + "name": "CPU_TEMP", + "temp_id": "TEMP1", + "api_name": "CPU", + "Temperature": { + "value": {"loc": "/sys/bus/platform/devices/coretemp.0/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": 2000, + "Low": 10000, + "High": 100000, + "Max": 102000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + { + "name": "INLET_TEMP", + "temp_id": "TEMP2", + "api_name": "Inlet", + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/107-004b/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": -10000, + "Low": 0, + "High": 40000, + "Max": 50000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + { + "name": "OUTLET_TEMP", + "temp_id": "TEMP3", + "api_name": "Outlet", + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/70-004f/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": -10000, + "Low": 0, + "High": 70000, + "Max": 75000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + { + "name": "SWITCH_TEMP", + "temp_id": "TEMP4", + "api_name": "Switch ASIC", + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/74-0044/hwmon/hwmon*/temp99_input", "way": "sysfs"}, + "Min": 2000, + "Low": 10000, + "High": 100000, + "Max": 105000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + { + "name": "SFF_TEMP", + "Temperature": { + "value": {"loc": "/tmp/highest_sff_temp", "way": "sysfs", "flock_path": "/tmp/highest_sff_temp"}, + "Min": -15000, + "Low": 0, + "High": 80000, + "Max": 100000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + ], + "leds": [ + { + "name": "FRONT_SYS_LED", + "led_type": "SYS_LED", + "led": {"bus": 77, "addr": 0x1d, "offset": 0x08, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + }, + { + "name": "FRONT_PSU_LED", + "led_type": "PSU_LED", + "led": {"bus": 77, "addr": 0x1d, "offset": 0x09, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + }, + { + "name": "FRONT_FAN_LED", + "led_type": "FAN_LED", + "led": {"bus": 77, "addr": 0x1d, "offset": 0x0a, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + }, + ], + "fans": [ + { + "name": "FAN1", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-90/90-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"loc":"/sys/rg_plat/fan/fan1/present","way":"sysfs", "mask": 0x01, "okval": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 87, "addr": 0x0d, "offset": 0x3b, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 87, "addr": 0x0d, "offset": 0x14, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan1/motor0/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan1/motor0/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan1/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 87, "addr": 0x0d, "offset": 0x14, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan1/motor1/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan1/motor1/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan1/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN2", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-98/98-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"loc":"/sys/rg_plat/fan/fan2/present","way":"sysfs", "mask": 0x01, "okval": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 95, "addr": 0x0d, "offset": 0x3b, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 95, "addr": 0x0d, "offset": 0x14, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan2/motor0/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan2/motor0/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan2/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 95, "addr": 0x0d, "offset": 0x14, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan2/motor1/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan2/motor1/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan2/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN3", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-91/91-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"loc":"/sys/rg_plat/fan/fan3/present","way":"sysfs", "mask": 0x01, "okval": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 87, "addr": 0x0d, "offset": 0x3c, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 87, "addr": 0x0d, "offset": 0x15, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan3/motor0/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan3/motor0/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan3/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 87, "addr": 0x0d, "offset": 0x15, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan3/motor1/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan3/motor1/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan3/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN4", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-99/99-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"loc":"/sys/rg_plat/fan/fan4/present","way":"sysfs", "mask": 0x01, "okval": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 95, "addr": 0x0d, "offset": 0x3c, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 95, "addr": 0x0d, "offset": 0x15, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan4/motor0/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan4/motor0/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan4/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 95, "addr": 0x0d, "offset": 0x15, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan4/motor1/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan4/motor1/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan4/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN5", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-92/92-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"loc":"/sys/rg_plat/fan/fan5/present","way":"sysfs", "mask": 0x01, "okval": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 87, "addr": 0x0d, "offset": 0x3d, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 87, "addr": 0x0d, "offset": 0x16, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan5/motor0/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan5/motor0/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan5/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 87, "addr": 0x0d, "offset": 0x16, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan5/motor1/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan5/motor1/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan5/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN6", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-100/100-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"loc":"/sys/rg_plat/fan/fan6/present","way":"sysfs", "mask": 0x01, "okval": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 95, "addr": 0x0d, "offset": 0x3d, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 95, "addr": 0x0d, "offset": 0x16, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan6/motor0/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan6/motor0/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan6/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 95, "addr": 0x0d, "offset": 0x16, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan6/motor1/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan6/motor1/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan6/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN7", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-93/93-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"loc":"/sys/rg_plat/fan/fan7/present","way":"sysfs", "mask": 0x01, "okval": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 87, "addr": 0x0d, "offset": 0x3e, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 87, "addr": 0x0d, "offset": 0x17, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan7/motor0/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan7/motor0/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan7/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 87, "addr": 0x0d, "offset": 0x17, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan7/motor1/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan7/motor1/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan7/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN8", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-101/101-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"loc":"/sys/rg_plat/fan/fan8/present","way":"sysfs", "mask": 0x01, "okval": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 95, "addr": 0x0d, "offset": 0x3e, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 95, "addr": 0x0d, "offset": 0x17, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan8/motor0/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan8/motor0/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan8/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 95, "addr": 0x0d, "offset": 0x17, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan8/motor1/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan8/motor1/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan8/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + ], + "cplds": [ + { + "name": "CPU_CPLD", + "cpld_id": "CPLD1", + "VersionFile": {"loc": "/dev/cpld0", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for system power", + "slot": 0, + }, + { + "name": "BASE_CPLD", + "cpld_id": "CPLD2", + "VersionFile": {"loc": "/dev/cpld1", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for base functions", + "slot": 0, + }, + { + "name": "UPORT_CPLD", + "cpld_id": "CPLD3", + "VersionFile": {"loc": "/dev/cpld2", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for sff modules", + "slot": 0, + }, + { + "name": "UFCB_CPLD", + "cpld_id": "CPLD4", + "VersionFile": {"loc": "/dev/cpld3", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for fan modules", + "slot": 0, + }, + { + "name": "DFCB_CPLD", + "cpld_id": "CPLD5", + "VersionFile": {"loc": "/dev/cpld4", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for fan modules", + "slot": 0, + }, + { + "name": "MAC_CPLDA", + "cpld_id": "CPLD6", + "VersionFile": {"loc": "/dev/cpld5", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for sff modules", + "slot": 0, + }, + { + "name": "MAC_CPLDB", + "cpld_id": "CPLD7", + "VersionFile": {"loc": "/dev/cpld6", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for sff modules", + "slot": 0, + }, + { + "name": "DPORT_CPLD", + "cpld_id": "CPLD8", + "VersionFile": {"loc": "/dev/cpld6", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for sff modules", + "slot": 0, + }, + { + "name": "UPORT_FPGA", + "cpld_id": "CPLD9", + "VersionFile": {"loc": "/dev/fpga0", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for base functions", + "slot": 0, + "format": "little_endian", + }, + { + "name": "MAC_FPGA", + "cpld_id": "CPLD10", + "VersionFile": {"loc": "/dev/fpga1", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for base functions", + "slot": 0, + "format": "little_endian", + }, + { + "name": "DPORT_FPGA", + "cpld_id": "CPLD11", + "VersionFile": {"loc": "/dev/fpga2", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for base functions", + "slot": 0, + "format": "little_endian", + }, + ], + "dcdc": [ + { + "name": "MAC_VDD_ANALOG1", + "dcdc_id": "DCDC1", + "Min": 731, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in1_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 809, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD12V", + "dcdc_id": "DCDC2", + "Min": 11400, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in2_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 12600, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD1.0V_FPGA", + "dcdc_id": "DCDC3", + "Min": 969, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1071, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD1.8V_FPGA", + "dcdc_id": "DCDC4", + "Min": 1710, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1890, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD1.2V_FPGA", + "dcdc_id": "DCDC5", + "Min": 1140, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in5_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1260, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD3.3V", + "dcdc_id": "DCDC6", + "Min": 3135, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in6_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3465, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_SW_VDD1.2V", + "dcdc_id": "DCDC7", + "Min": 1140, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in7_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1260, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD5V_CLK_MCU", + "dcdc_id": "DCDC8", + "Min": 4826, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in8_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 5334, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD5V_VR", + "dcdc_id": "DCDC9", + "Min": 4826, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in9_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 5334, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD3.3_CLK", + "dcdc_id": "DCDC10", + "Min": 3154, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in10_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3486, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDDO1.8V", + "dcdc_id": "DCDC11", + "Min": 1719, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in11_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1901, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDDO1.2V", + "dcdc_id": "DCDC12", + "Min": 1140, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in12_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1260, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD_CORE", + "dcdc_id": "DCDC13", + "Min": 700, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in13_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 950, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD_ANALOG", + "dcdc_id": "DCDC14", + "Min": 731, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in14_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 809, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD1.2V_MAC", + "dcdc_id": "DCDC15", + "Min": 1140, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in15_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1260, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_AVDD1.8V", + "dcdc_id": "DCDC16", + "Min": 1710, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in16_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1890, + "format": "float(float(%s)/1000)", + }, + { + "name": "BASE_VDD12V", + "dcdc_id": "DCDC17", + "Min": 11400, + "value": { + "loc": "/sys/bus/i2c/devices/105-005b/hwmon/hwmon*/in1_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 12600, + "format": "float(float(%s)/1000)", + }, + { + "name": "BASE_SW_VDD1.0V", + "dcdc_id": "DCDC18", + "Min": 950, + "value": { + "loc": "/sys/bus/i2c/devices/105-005b/hwmon/hwmon*/in2_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1050, + "format": "float(float(%s)/1000)", + }, + { + "name": "BASE_VDD3.3V", + "dcdc_id": "DCDC19", + "Min": 3116, + "value": { + "loc": "/sys/bus/i2c/devices/105-005b/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3444, + "format": "float(float(%s)/1000)", + }, + { + "name": "BASE_SW_OVDD", + "dcdc_id": "DCDC20", + "Min": 3116, + "value": { + "loc": "/sys/bus/i2c/devices/105-005b/hwmon/hwmon*/in5_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3444, + "format": "float(float(%s)/1000)", + }, + { + "name": "BASE_SSD_VDD3.3V", + "dcdc_id": "DCDC21", + "Min": 3135, + "value": { + "loc": "/sys/bus/i2c/devices/105-005b/hwmon/hwmon*/in6_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3465, + "format": "float(float(%s)/1000)", + }, + { + "name": "CPU_VCCIN", + "dcdc_id": "DCDC22", + "Min": 1600, + "value": { + "loc": "/sys/bus/i2c/devices/106-0060/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1950, + "format": "float(float(%s)/1000)", + }, + { + "name": "CPU_P1V05", + "dcdc_id": "DCDC23", + "Min": 1000, + "value": { + "loc": "/sys/bus/i2c/devices/106-0060/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1100, + "format": "float(float(%s)/1000)", + }, + { + "name": "CPU_P1V2_VDDQ", + "dcdc_id": "DCDC24", + "Min": 1160, + "value": { + "loc": "/sys/bus/i2c/devices/106-006c/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1260, + "format": "float(float(%s)/1000)", + }, + { + "name": "CPU_P2V5_VPP", + "dcdc_id": "DCDC25", + "Min": 2113, + "value": { + "loc": "/sys/bus/i2c/devices/106-006c/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 2447, + "format": "float(float(%s)/1000) * 1.124", + }, + { + "name": "CPU_P3V3_STBY", + "dcdc_id": "DCDC26", + "Min": 3135, + "value": { + "loc": "/sys/bus/i2c/devices/106-0043/hwmon/hwmon*/in1_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3465, + "format": "float(float(%s)/1000)", + }, + { + "name": "CPU_P5V_AUX_IN", + "dcdc_id": "DCDC27", + "Min": 4250, + "value": { + "loc": "/sys/bus/i2c/devices/106-0043/hwmon/hwmon*/in2_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 5500, + "format": "float(float(%s)/1000)", + }, + { + "name": "CPU_P1V7_VCCSCFUSESUS_IN", + "dcdc_id": "DCDC28", + "Min": 1615, + "value": { + "loc": "/sys/bus/i2c/devices/106-0043/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1785, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_VDD1.0V_FPGA", + "dcdc_id": "DCDC29", + "Min": 959, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in1_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1061, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_VDD1.8V_FPGA", + "dcdc_id": "DCDC30", + "Min": 1719, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in2_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1901, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_VDD1.2V_FPGA", + "dcdc_id": "DCDC31", + "Min": 1140, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1260, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_VDD3.3V", + "dcdc_id": "DCDC32", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_QSFP56_VDD3.3V_A", + "dcdc_id": "DCDC33", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in5_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_QSFP56_VDD3.3V_B", + "dcdc_id": "DCDC34", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in6_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_QSFP56_VDD3.3V_C", + "dcdc_id": "DCDC35", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in7_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_QSFP56_VDD3.3V_D", + "dcdc_id": "DCDC36", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in8_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_VDD3.3_MON", + "dcdc_id": "DCDC37", + "Min": 3135, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in9_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3465, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_VDD12V", + "dcdc_id": "DCDC38", + "Min": 11400, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in10_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 12600, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_VDD1.0V_FPGA", + "dcdc_id": "DCDC39", + "Min": 959, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in1_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1061, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_VDD1.8V_FPGA", + "dcdc_id": "DCDC40", + "Min": 1719, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in2_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1901, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_VDD1.2V_FPGA", + "dcdc_id": "DCDC41", + "Min": 1140, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1260, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_VDD3.3V", + "dcdc_id": "DCDC42", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_QSFP56_VDD3.3V_A", + "dcdc_id": "DCDC43", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in5_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_QSFP56_VDD3.3V_B", + "dcdc_id": "DCDC44", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in6_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_QSFP56_VDD3.3V_C", + "dcdc_id": "DCDC45", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in7_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_QSFP56_VDD3.3V_D", + "dcdc_id": "DCDC46", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in8_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_VDD3.3_MON", + "dcdc_id": "DCDC47", + "Min": 3135, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in9_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3465, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_VDD12V", + "dcdc_id": "DCDC48", + "Min": 11400, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in10_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 12600, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_QSFPDD_VDD3.3V_A", + "dcdc_id": "DCDC49", + "Min": 3.200, + "value": { + "loc": "/sys/rg_plat/sensor/in0/in_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3.600, + "format": "%s", + }, + { + "name": "MAC_QSFPDD_VDD3.3V_B", + "dcdc_id": "DCDC50", + "Min": 3.200, + "value": { + "loc": "/sys/rg_plat/sensor/in1/in_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3.600, + "format": "%s", + }, + { + "name": "MAC_QSFPDD_VDD3.3V_C", + "dcdc_id": "DCDC51", + "Min": 3.200, + "value": { + "loc": "/sys/rg_plat/sensor/in2/in_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3.600, + "format": "%s", + }, + { + "name": "MAC_QSFPDD_VDD3.3V_D", + "dcdc_id": "DCDC52", + "Min": 3.200, + "value": { + "loc": "/sys/rg_plat/sensor/in3/in_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3.600, + "format": "%s", + }, + { + "name": "MAC_QSFPDD_VDD3.3V_E", + "dcdc_id": "DCDC53", + "Min": 3.200, + "value": { + "loc": "/sys/rg_plat/sensor/in4/in_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3.600, + "format": "%s", + }, + { + "name": "MAC_QSFPDD_VDD3.3V_F", + "dcdc_id": "DCDC54", + "Min": 3.200, + "value": { + "loc": "/sys/rg_plat/sensor/in5/in_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3.600, + "format": "%s", + }, + { + "name": "MAC_QSFPDD_VDD3.3V_G", + "dcdc_id": "DCDC55", + "Min": 3.200, + "value": { + "loc": "/sys/rg_plat/sensor/in6/in_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3.600, + "format": "%s", + }, + { + "name": "MAC_QSFPDD_VDD3.3V_H", + "dcdc_id": "DCDC56", + "Min": 3.200, + "value": { + "loc": "/sys/rg_plat/sensor/in7/in_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3.600, + "format": "%s", + }, + ], + "cpu": [ + { + "name": "cpu", + "CpuResetCntReg": {"loc": "/dev/cpld1", "offset": 0x10, "len": 1, "way": "devfile_ascii"}, + } + ], + "sfps": { + "port_start": 1, + "port_end": 127, + } +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/hal-config/x86_64_tencent_tcs9400_r0_device.py b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/hal-config/x86_64_tencent_tcs9400_r0_device.py new file mode 100755 index 000000000000..182d7e3ddef8 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/hal-config/x86_64_tencent_tcs9400_r0_device.py @@ -0,0 +1,1739 @@ +#!/usr/bin/python3 + +psu_fan_airflow = { + "F2B": ["DPS-1300AB-6 F", "GW-CRPS1300D"], + "B2F": ["DPS-1300AB-11 C", "CRPS1300D3R"] +} + +psu_display_name = { + "PSA1300CRPS-F": ["DPS-1300AB-6 F", "GW-CRPS1300D"], + "PSA1300CRPS-R": ["DPS-1300AB-11 C", "CRPS1300D3R"] +} + +fanairflow = { + "F2B": ["FAN12K8080-F"], +} + +fan_display_name = { + "FAN12K8080-F": ["FAN12K8080-F"], +} + +psutypedecode = { + 0x00: 'N/A', + 0x01: 'AC', + 0x02: 'DC', +} + + +class Unit: + Temperature = "C" + Voltage = "V" + Current = "A" + Power = "W" + Speed = "RPM" + + +PSU_NOT_PRESENT_PWM = 100 + + +class threshold: + PSU_TEMP_MIN = -10 * 1000 + PSU_TEMP_MAX = 60 * 1000 + + PSU_FAN_SPEED_MIN = 2000 + PSU_FAN_SPEED_MAX = 28000 + + PSU_OUTPUT_VOLTAGE_MIN = 11 * 1000 + PSU_OUTPUT_VOLTAGE_MAX = 14 * 1000 + + PSU_AC_INPUT_VOLTAGE_MIN = 200 * 1000 + PSU_AC_INPUT_VOLTAGE_MAX = 240 * 1000 + + PSU_DC_INPUT_VOLTAGE_MIN = 190 * 1000 + PSU_DC_INPUT_VOLTAGE_MAX = 290 * 1000 + + ERR_VALUE = -9999999 + + PSU_OUTPUT_POWER_MIN = 10 * 1000 * 1000 + PSU_OUTPUT_POWER_MAX = 1300 * 1000 * 1000 + + PSU_INPUT_POWER_MIN = 10 * 1000 * 1000 + PSU_INPUT_POWER_MAX = 1444 * 1000 * 1000 + + PSU_OUTPUT_CURRENT_MIN = 2 * 1000 + PSU_OUTPUT_CURRENT_MAX = 107 * 1000 + + PSU_INPUT_CURRENT_MIN = 0.2 * 1000 + PSU_INPUT_CURRENT_MAX = 7 * 1000 + + FRONT_FAN_SPEED_MAX = 13530 + REAR_FAN_SPEED_MAX = 11770 + FAN_SPEED_MIN = 1650 + + +class Description: + CPLD = "Used for managing IO modules, SFP+ modules and system LEDs" + BIOS = "Performs initialization of hardware components during booting" + FPGA = "Platform management controller for on-board temperature monitoring, in-chassis power" + + +devices = { + "onie_e2": [ + { + "name": "ONIE_E2", + "e2loc": {"loc": "/sys/bus/i2c/devices/1-0056/eeprom", "way": "sysfs"}, + }, + ], + "psus": [ + { + "e2loc": {"loc": "/sys/bus/i2c/devices/79-0050/eeprom", "way": "sysfs"}, + "pmbusloc": {"bus": 79, "addr": 0x58, "way": "i2c"}, + "present": {"loc": "/sys/rg_plat/psu/psu1/present", "way": "sysfs", "mask": 0x01, "okval": 1}, + "name": "PSU1", + "psu_display_name": psu_display_name, + "airflow": psu_fan_airflow, + "psu_not_present_pwm": PSU_NOT_PRESENT_PWM, + "TempStatus": {"bus": 79, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0004}, + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": threshold.PSU_TEMP_MIN, + "Max": threshold.PSU_TEMP_MAX, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + }, + "FanStatus": {"bus": 79, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0400}, + "FanSpeed": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/fan1_input", "way": "sysfs"}, + "Min": threshold.PSU_FAN_SPEED_MIN, + "Max": threshold.PSU_FAN_SPEED_MAX, + "Unit": Unit.Speed + }, + "InputsStatus": {"bus": 79, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x2000}, + "InputsType": {"bus": 79, "addr": 0x58, "offset": 0x80, "way": "i2c", 'psutypedecode': psutypedecode}, + "InputsVoltage": { + 'AC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_AC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_AC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + + }, + 'DC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_DC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_DC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + 'other': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.ERR_VALUE, + "Max": threshold.ERR_VALUE, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + } + }, + "InputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/curr1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_CURRENT_MIN, + "Max": threshold.PSU_INPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "InputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/power1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_POWER_MIN, + "Max": threshold.PSU_INPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + "OutputsStatus": {"bus": 79, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x8800}, + "OutputsVoltage": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/in2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_VOLTAGE_MIN, + "Max": threshold.PSU_OUTPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + "OutputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/curr2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_CURRENT_MIN, + "Max": threshold.PSU_OUTPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "OutputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/power2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_POWER_MIN, + "Max": threshold.PSU_OUTPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + }, + { + "e2loc": {"loc": "/sys/bus/i2c/devices/80-0050/eeprom", "way": "sysfs"}, + "pmbusloc": {"bus": 80, "addr": 0x58, "way": "i2c"}, + "present": {"loc": "/sys/rg_plat/psu/psu2/present", "way": "sysfs", "mask": 0x01, "okval": 1}, + "name": "PSU2", + "psu_display_name": psu_display_name, + "airflow": psu_fan_airflow, + "psu_not_present_pwm": PSU_NOT_PRESENT_PWM, + "TempStatus": {"bus": 80, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0004}, + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": threshold.PSU_TEMP_MIN, + "Max": threshold.PSU_TEMP_MAX, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + }, + "FanStatus": {"bus": 80, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0400}, + "FanSpeed": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/fan1_input", "way": "sysfs"}, + "Min": threshold.PSU_FAN_SPEED_MIN, + "Max": threshold.PSU_FAN_SPEED_MAX, + "Unit": Unit.Speed + }, + "InputsStatus": {"bus": 80, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x2000}, + "InputsType": {"bus": 80, "addr": 0x58, "offset": 0x80, "way": "i2c", 'psutypedecode': psutypedecode}, + "InputsVoltage": { + 'AC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_AC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_AC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + + }, + 'DC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_DC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_DC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + 'other': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.ERR_VALUE, + "Max": threshold.ERR_VALUE, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + } + }, + "InputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/curr1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_CURRENT_MIN, + "Max": threshold.PSU_INPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "InputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/power1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_POWER_MIN, + "Max": threshold.PSU_INPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + "OutputsStatus": {"bus": 80, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x8800}, + "OutputsVoltage": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/in2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_VOLTAGE_MIN, + "Max": threshold.PSU_OUTPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + "OutputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/curr2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_CURRENT_MIN, + "Max": threshold.PSU_OUTPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "OutputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/power2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_POWER_MIN, + "Max": threshold.PSU_OUTPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + }, + { + "e2loc": {"loc": "/sys/bus/i2c/devices/82-0050/eeprom", "way": "sysfs"}, + "pmbusloc": {"bus": 82, "addr": 0x58, "way": "i2c"}, + "present": {"loc": "/sys/rg_plat/psu/psu3/present", "way": "sysfs", "mask": 0x01, "okval": 1}, + "name": "PSU3", + "psu_display_name": psu_display_name, + "airflow": psu_fan_airflow, + "psu_not_present_pwm": PSU_NOT_PRESENT_PWM, + "TempStatus": {"bus": 82, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0004}, + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": threshold.PSU_TEMP_MIN, + "Max": threshold.PSU_TEMP_MAX, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + }, + "FanStatus": {"bus": 82, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0400}, + "FanSpeed": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/fan1_input", "way": "sysfs"}, + "Min": threshold.PSU_FAN_SPEED_MIN, + "Max": threshold.PSU_FAN_SPEED_MAX, + "Unit": Unit.Speed + }, + "InputsStatus": {"bus": 82, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x2000}, + "InputsType": {"bus": 82, "addr": 0x58, "offset": 0x80, "way": "i2c", 'psutypedecode': psutypedecode}, + "InputsVoltage": { + 'AC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_AC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_AC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + + }, + 'DC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_DC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_DC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + 'other': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.ERR_VALUE, + "Max": threshold.ERR_VALUE, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + } + }, + "InputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/curr1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_CURRENT_MIN, + "Max": threshold.PSU_INPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "InputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/power1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_POWER_MIN, + "Max": threshold.PSU_INPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + "OutputsStatus": {"bus": 82, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x8800}, + "OutputsVoltage": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/in2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_VOLTAGE_MIN, + "Max": threshold.PSU_OUTPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + "OutputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/curr2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_CURRENT_MIN, + "Max": threshold.PSU_OUTPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "OutputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/power2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_POWER_MIN, + "Max": threshold.PSU_OUTPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + }, + { + "e2loc": {"loc": "/sys/bus/i2c/devices/81-0050/eeprom", "way": "sysfs"}, + "pmbusloc": {"bus": 81, "addr": 0x58, "way": "i2c"}, + "present": {"loc": "/sys/rg_plat/psu/psu4/present", "way": "sysfs", "mask": 0x01, "okval": 1}, + "name": "PSU4", + "psu_display_name": psu_display_name, + "airflow": psu_fan_airflow, + "psu_not_present_pwm": PSU_NOT_PRESENT_PWM, + "TempStatus": {"bus": 81, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0004}, + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": threshold.PSU_TEMP_MIN, + "Max": threshold.PSU_TEMP_MAX, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + }, + "FanStatus": {"bus": 81, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0400}, + "FanSpeed": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/fan1_input", "way": "sysfs"}, + "Min": threshold.PSU_FAN_SPEED_MIN, + "Max": threshold.PSU_FAN_SPEED_MAX, + "Unit": Unit.Speed + }, + "InputsStatus": {"bus": 81, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x2000}, + "InputsType": {"bus": 81, "addr": 0x58, "offset": 0x80, "way": "i2c", 'psutypedecode': psutypedecode}, + "InputsVoltage": { + 'AC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_AC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_AC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + + }, + 'DC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_DC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_DC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + 'other': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.ERR_VALUE, + "Max": threshold.ERR_VALUE, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + } + }, + "InputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/curr1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_CURRENT_MIN, + "Max": threshold.PSU_INPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "InputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/power1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_POWER_MIN, + "Max": threshold.PSU_INPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + "OutputsStatus": {"bus": 81, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x8800}, + "OutputsVoltage": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/in2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_VOLTAGE_MIN, + "Max": threshold.PSU_OUTPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + "OutputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/curr2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_CURRENT_MIN, + "Max": threshold.PSU_OUTPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "OutputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/power2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_POWER_MIN, + "Max": threshold.PSU_OUTPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + }, + ], + "temps":[ + { + "name": "CPU_TEMP", + "temp_id": "TEMP1", + "api_name": "CPU", + "Temperature": { + "value": {"loc": "/sys/bus/platform/devices/coretemp.0/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": 2000, + "Low": 10000, + "High": 100000, + "Max": 102000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + { + "name": "INLET_TEMP", + "temp_id": "TEMP2", + "api_name": "Inlet", + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/107-004b/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": -10000, + "Low": 0, + "High": 40000, + "Max": 50000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + { + "name": "OUTLET_TEMP", + "temp_id": "TEMP3", + "api_name": "Outlet", + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/70-004f/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": -10000, + "Low": 0, + "High": 70000, + "Max": 75000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + { + "name": "SWITCH_TEMP", + "temp_id": "TEMP4", + "api_name": "Switch ASIC", + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/74-0044/hwmon/hwmon*/temp99_input", "way": "sysfs"}, + "Min": 2000, + "Low": 10000, + "High": 100000, + "Max": 105000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + { + "name": "SFF_TEMP", + "Temperature": { + "value": {"loc": "/tmp/highest_sff_temp", "way": "sysfs", "flock_path": "/tmp/highest_sff_temp"}, + "Min": -15000, + "Low": 0, + "High": 80000, + "Max": 100000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + ], + "leds": [ + { + "name": "FRONT_SYS_LED", + "led_type": "SYS_LED", + "led": {"bus": 77, "addr": 0x1d, "offset": 0x08, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + }, + { + "name": "FRONT_PSU_LED", + "led_type": "PSU_LED", + "led": {"bus": 77, "addr": 0x1d, "offset": 0x09, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + }, + { + "name": "FRONT_FAN_LED", + "led_type": "FAN_LED", + "led": {"bus": 77, "addr": 0x1d, "offset": 0x0a, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + }, + ], + "fans": [ + { + "name": "FAN1", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-90/90-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"loc":"/sys/rg_plat/fan/fan1/present","way":"sysfs", "mask": 0x01, "okval": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 87, "addr": 0x0d, "offset": 0x3b, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 87, "addr": 0x0d, "offset": 0x14, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan1/motor0/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan1/motor0/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan1/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 87, "addr": 0x0d, "offset": 0x14, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan1/motor1/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan1/motor1/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan1/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN2", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-98/98-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"loc":"/sys/rg_plat/fan/fan2/present","way":"sysfs", "mask": 0x01, "okval": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 95, "addr": 0x0d, "offset": 0x3b, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 95, "addr": 0x0d, "offset": 0x14, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan2/motor0/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan2/motor0/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan2/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 95, "addr": 0x0d, "offset": 0x14, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan2/motor1/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan2/motor1/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan2/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN3", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-91/91-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"loc":"/sys/rg_plat/fan/fan3/present","way":"sysfs", "mask": 0x01, "okval": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 87, "addr": 0x0d, "offset": 0x3c, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 87, "addr": 0x0d, "offset": 0x15, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan3/motor0/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan3/motor0/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan3/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 87, "addr": 0x0d, "offset": 0x15, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan3/motor1/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan3/motor1/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan3/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN4", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-99/99-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"loc":"/sys/rg_plat/fan/fan4/present","way":"sysfs", "mask": 0x01, "okval": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 95, "addr": 0x0d, "offset": 0x3c, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 95, "addr": 0x0d, "offset": 0x15, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan4/motor0/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan4/motor0/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan4/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 95, "addr": 0x0d, "offset": 0x15, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan4/motor1/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan4/motor1/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan4/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN5", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-92/92-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"loc":"/sys/rg_plat/fan/fan5/present","way":"sysfs", "mask": 0x01, "okval": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 87, "addr": 0x0d, "offset": 0x3d, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 87, "addr": 0x0d, "offset": 0x16, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan5/motor0/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan5/motor0/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan5/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 87, "addr": 0x0d, "offset": 0x16, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan5/motor1/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan5/motor1/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan5/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN6", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-100/100-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"loc":"/sys/rg_plat/fan/fan6/present","way":"sysfs", "mask": 0x01, "okval": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 95, "addr": 0x0d, "offset": 0x3d, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 95, "addr": 0x0d, "offset": 0x16, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan6/motor0/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan6/motor0/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan6/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 95, "addr": 0x0d, "offset": 0x16, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan6/motor1/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan6/motor1/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan6/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN7", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-93/93-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"loc":"/sys/rg_plat/fan/fan7/present","way":"sysfs", "mask": 0x01, "okval": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 87, "addr": 0x0d, "offset": 0x3e, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 87, "addr": 0x0d, "offset": 0x17, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan7/motor0/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan7/motor0/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan7/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 87, "addr": 0x0d, "offset": 0x17, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan7/motor1/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan7/motor1/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan7/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN8", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-101/101-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"loc":"/sys/rg_plat/fan/fan8/present","way":"sysfs", "mask": 0x01, "okval": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 95, "addr": 0x0d, "offset": 0x3e, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 95, "addr": 0x0d, "offset": 0x17, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan8/motor0/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan8/motor0/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan8/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 95, "addr": 0x0d, "offset": 0x17, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan8/motor1/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan8/motor1/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan8/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + ], + "cplds": [ + { + "name": "CPU_CPLD", + "cpld_id": "CPLD1", + "VersionFile": {"loc": "/dev/cpld0", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for system power", + "slot": 0, + }, + { + "name": "BASE_CPLD", + "cpld_id": "CPLD2", + "VersionFile": {"loc": "/dev/cpld1", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for base functions", + "slot": 0, + }, + { + "name": "UPORT_CPLD", + "cpld_id": "CPLD3", + "VersionFile": {"loc": "/dev/cpld2", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for sff modules", + "slot": 0, + }, + { + "name": "UFCB_CPLD", + "cpld_id": "CPLD4", + "VersionFile": {"loc": "/dev/cpld3", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for fan modules", + "slot": 0, + }, + { + "name": "DFCB_CPLD", + "cpld_id": "CPLD5", + "VersionFile": {"loc": "/dev/cpld4", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for fan modules", + "slot": 0, + }, + { + "name": "MAC_CPLDA", + "cpld_id": "CPLD6", + "VersionFile": {"loc": "/dev/cpld5", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for sff modules", + "slot": 0, + }, + { + "name": "MAC_CPLDB", + "cpld_id": "CPLD7", + "VersionFile": {"loc": "/dev/cpld6", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for sff modules", + "slot": 0, + }, + { + "name": "DPORT_CPLD", + "cpld_id": "CPLD8", + "VersionFile": {"loc": "/dev/cpld6", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for sff modules", + "slot": 0, + }, + { + "name": "UPORT_FPGA", + "cpld_id": "CPLD9", + "VersionFile": {"loc": "/dev/fpga0", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for base functions", + "slot": 0, + "format": "little_endian", + }, + { + "name": "MAC_FPGA", + "cpld_id": "CPLD10", + "VersionFile": {"loc": "/dev/fpga1", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for base functions", + "slot": 0, + "format": "little_endian", + }, + { + "name": "DPORT_FPGA", + "cpld_id": "CPLD11", + "VersionFile": {"loc": "/dev/fpga2", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for base functions", + "slot": 0, + "format": "little_endian", + }, + ], + "dcdc": [ + { + "name": "MAC_VDD_ANALOG1", + "dcdc_id": "DCDC1", + "Min": 731, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in1_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 809, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD12V", + "dcdc_id": "DCDC2", + "Min": 11400, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in2_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 12600, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD1.0V_FPGA", + "dcdc_id": "DCDC3", + "Min": 969, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1071, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD1.8V_FPGA", + "dcdc_id": "DCDC4", + "Min": 1710, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1890, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD1.2V_FPGA", + "dcdc_id": "DCDC5", + "Min": 1140, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in5_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1260, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD3.3V", + "dcdc_id": "DCDC6", + "Min": 3135, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in6_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3465, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_SW_VDD1.2V", + "dcdc_id": "DCDC7", + "Min": 1140, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in7_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1260, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD5V_CLK_MCU", + "dcdc_id": "DCDC8", + "Min": 4826, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in8_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 5334, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD5V_VR", + "dcdc_id": "DCDC9", + "Min": 4826, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in9_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 5334, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD3.3_CLK", + "dcdc_id": "DCDC10", + "Min": 3154, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in10_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3486, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDDO1.8V", + "dcdc_id": "DCDC11", + "Min": 1719, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in11_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1901, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDDO1.2V", + "dcdc_id": "DCDC12", + "Min": 1140, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in12_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1260, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD_CORE", + "dcdc_id": "DCDC13", + "Min": 700, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in13_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 950, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD_ANALOG", + "dcdc_id": "DCDC14", + "Min": 731, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in14_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 809, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD1.2V_MAC", + "dcdc_id": "DCDC15", + "Min": 1140, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in15_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1260, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_AVDD1.8V", + "dcdc_id": "DCDC16", + "Min": 1710, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in16_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1890, + "format": "float(float(%s)/1000)", + }, + { + "name": "BASE_VDD12V", + "dcdc_id": "DCDC17", + "Min": 11400, + "value": { + "loc": "/sys/bus/i2c/devices/105-005b/hwmon/hwmon*/in1_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 12600, + "format": "float(float(%s)/1000)", + }, + { + "name": "BASE_SW_VDD1.2V", + "dcdc_id": "DCDC18", + "Min": 1140, + "value": { + "loc": "/sys/bus/i2c/devices/105-005b/hwmon/hwmon*/in2_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1260, + "format": "float(float(%s)/1000)", + }, + { + "name": "BASE_VDD2.5V", + "dcdc_id": "DCDC19", + "Min": 2365, + "value": { + "loc": "/sys/bus/i2c/devices/105-005b/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 2615, + "format": "float(float(%s)/1000)", + }, + { + "name": "BASE_VDD3.3V", + "dcdc_id": "DCDC20", + "Min": 3116, + "value": { + "loc": "/sys/bus/i2c/devices/105-005b/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3444, + "format": "float(float(%s)/1000)", + }, + { + "name": "BASE_SSD_VDD3.3V", + "dcdc_id": "DCDC21", + "Min": 3135, + "value": { + "loc": "/sys/bus/i2c/devices/105-005b/hwmon/hwmon*/in5_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3465, + "format": "float(float(%s)/1000)", + }, + { + "name": "CPU_VCCIN", + "dcdc_id": "DCDC22", + "Min": 1600, + "value": { + "loc": "/sys/bus/i2c/devices/106-0060/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1950, + "format": "float(float(%s)/1000)", + }, + { + "name": "CPU_P1V05", + "dcdc_id": "DCDC23", + "Min": 1000, + "value": { + "loc": "/sys/bus/i2c/devices/106-0060/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1100, + "format": "float(float(%s)/1000)", + }, + { + "name": "CPU_P1V2_VDDQ", + "dcdc_id": "DCDC24", + "Min": 1160, + "value": { + "loc": "/sys/bus/i2c/devices/106-006c/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1260, + "format": "float(float(%s)/1000)", + }, + { + "name": "CPU_P2V5_VPP", + "dcdc_id": "DCDC25", + "Min": 2113, + "value": { + "loc": "/sys/bus/i2c/devices/106-006c/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 2447, + "format": "float(float(%s)/1000) * 1.124", + }, + { + "name": "CPU_P3V3_STBY", + "dcdc_id": "DCDC26", + "Min": 3135, + "value": { + "loc": "/sys/bus/i2c/devices/106-0043/hwmon/hwmon*/in1_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3465, + "format": "float(float(%s)/1000)", + }, + { + "name": "CPU_P5V_AUX_IN", + "dcdc_id": "DCDC27", + "Min": 4250, + "value": { + "loc": "/sys/bus/i2c/devices/106-0043/hwmon/hwmon*/in2_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 5500, + "format": "float(float(%s)/1000)", + }, + { + "name": "CPU_P1V7_VCCSCFUSESUS_IN", + "dcdc_id": "DCDC28", + "Min": 1615, + "value": { + "loc": "/sys/bus/i2c/devices/106-0043/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1785, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_VDD1.0V_FPGA", + "dcdc_id": "DCDC29", + "Min": 959, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in1_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1061, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_VDD1.8V_FPGA", + "dcdc_id": "DCDC30", + "Min": 1719, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in2_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1901, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_VDD1.2V_FPGA", + "dcdc_id": "DCDC31", + "Min": 1140, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1260, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_VDD3.3V", + "dcdc_id": "DCDC32", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_QSFP56_VDD3.3V_A", + "dcdc_id": "DCDC33", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in5_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_QSFP56_VDD3.3V_B", + "dcdc_id": "DCDC34", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in6_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_QSFP56_VDD3.3V_C", + "dcdc_id": "DCDC35", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in7_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_QSFP56_VDD3.3V_D", + "dcdc_id": "DCDC36", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in8_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_VDD3.3_MON", + "dcdc_id": "DCDC37", + "Min": 3135, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in9_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3465, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_VDD12V", + "dcdc_id": "DCDC38", + "Min": 11400, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in10_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 12600, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_VDD1.0V_FPGA", + "dcdc_id": "DCDC39", + "Min": 959, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in1_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1061, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_VDD1.8V_FPGA", + "dcdc_id": "DCDC40", + "Min": 1719, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in2_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1901, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_VDD1.2V_FPGA", + "dcdc_id": "DCDC41", + "Min": 1140, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1260, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_VDD3.3V", + "dcdc_id": "DCDC42", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_QSFP56_VDD3.3V_A", + "dcdc_id": "DCDC43", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in5_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_QSFP56_VDD3.3V_B", + "dcdc_id": "DCDC44", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in6_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_QSFP56_VDD3.3V_C", + "dcdc_id": "DCDC45", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in7_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_QSFP56_VDD3.3V_D", + "dcdc_id": "DCDC46", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in8_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_VDD3.3_MON", + "dcdc_id": "DCDC47", + "Min": 3135, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in9_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3465, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_VDD12V", + "dcdc_id": "DCDC48", + "Min": 11400, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in10_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 12600, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_QSFPDD_VDD3.3V_A", + "dcdc_id": "DCDC49", + "Min": 3.200, + "value": { + "loc": "/sys/rg_plat/sensor/in0/in_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3.600, + "format": "%s", + }, + { + "name": "MAC_QSFPDD_VDD3.3V_B", + "dcdc_id": "DCDC50", + "Min": 3.200, + "value": { + "loc": "/sys/rg_plat/sensor/in1/in_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3.600, + "format": "%s", + }, + { + "name": "MAC_QSFPDD_VDD3.3V_C", + "dcdc_id": "DCDC51", + "Min": 3.200, + "value": { + "loc": "/sys/rg_plat/sensor/in2/in_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3.600, + "format": "%s", + }, + { + "name": "MAC_QSFPDD_VDD3.3V_D", + "dcdc_id": "DCDC52", + "Min": 3.200, + "value": { + "loc": "/sys/rg_plat/sensor/in3/in_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3.600, + "format": "%s", + }, + { + "name": "MAC_QSFPDD_VDD3.3V_E", + "dcdc_id": "DCDC53", + "Min": 3.200, + "value": { + "loc": "/sys/rg_plat/sensor/in4/in_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3.600, + "format": "%s", + }, + { + "name": "MAC_QSFPDD_VDD3.3V_F", + "dcdc_id": "DCDC54", + "Min": 3.200, + "value": { + "loc": "/sys/rg_plat/sensor/in5/in_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3.600, + "format": "%s", + }, + { + "name": "MAC_QSFPDD_VDD3.3V_G", + "dcdc_id": "DCDC55", + "Min": 3.200, + "value": { + "loc": "/sys/rg_plat/sensor/in6/in_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3.600, + "format": "%s", + }, + { + "name": "MAC_QSFPDD_VDD3.3V_H", + "dcdc_id": "DCDC56", + "Min": 3.200, + "value": { + "loc": "/sys/rg_plat/sensor/in7/in_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3.600, + "format": "%s", + }, + ], + "cpu": [ + { + "name": "cpu", + "CpuResetCntReg": {"loc": "/dev/cpld1", "offset": 0x10, "len": 1, "way": "devfile_ascii"}, + } + ], + "sfps": { + "port_start": 1, + "port_end": 127, + } +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/hal-config/x86_64_tencent_tcs9400_r0_monitor.py b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/hal-config/x86_64_tencent_tcs9400_r0_monitor.py new file mode 100755 index 000000000000..bc13f5e26f38 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/hal-config/x86_64_tencent_tcs9400_r0_monitor.py @@ -0,0 +1,154 @@ +#!/usr/bin/python3 + +monitor = { + "openloop": { + "linear": { + "name": "linear", + "flag": 0, + "pwm_min": 0x80, + "pwm_max": 0xff, + "K": 11, + "tin_min": 38, + }, + "curve": { + "name": "curve", + "flag": 1, + "pwm_min": 0x5a, + "pwm_max": 0xff, + "a": 0.086, + "b": 0.318, + "c": 28, + "tin_min": 25, + }, + }, + + "pid": { + "CPU_TEMP": { + "name": "CPU_TEMP", + "flag": 1, + "type": "duty", + "pwm_min": 0x5a, + "pwm_max": 0xff, + "Kp": 1.5, + "Ki": 1, + "Kd": 0.3, + "target": 80, + "value": [None, None, None], + }, + "SWITCH_TEMP": { + "name": "SWITCH_TEMP", + "flag": 1, + "type": "duty", + "pwm_min": 0x5a, + "pwm_max": 0xff, + "Kp": 1.5, + "Ki": 1, + "Kd": 0.3, + "target": 90, + "value": [None, None, None], + }, + "OUTLET_TEMP": { + "name": "OUTLET_TEMP", + "flag": 1, + "type": "duty", + "pwm_min": 0x5a, + "pwm_max": 0xff, + "Kp": 2, + "Ki": 0.4, + "Kd": 0.3, + "target": 65, + "value": [None, None, None], + }, + "SFF_TEMP": { + "name": "SFF_TEMP", + "flag": 1, + "type": "duty", + "pwm_min": 0x5a, + "pwm_max": 0xff, + "Kp": 0.1, + "Ki": 0.4, + "Kd": 0, + "target": 60, + "value": [None, None, None], + }, + }, + + "temps_threshold": { + "SWITCH_TEMP": {"name": "SWITCH_TEMP", "warning": 100, "critical": 105, "invalid": -100000, "error": -99999}, + "INLET_TEMP": {"name": "INLET_TEMP", "warning": 40, "critical": 50, "fix": -3}, + "OUTLET_TEMP": {"name": "OUTLET_TEMP", "warning": 70, "critical": 75}, + "CPU_TEMP": {"name": "CPU_TEMP", "warning": 100, "critical": 102}, + "SFF_TEMP": {"name": "SFF_TEMP", "warning": 999, "critical": 1000, "ignore_threshold": 1, "invalid": -10000, "error": -9999}, + }, + + "fancontrol_para": { + "interval": 5, + "fan_air_flow_monitor": 1, + "max_pwm": 0xff, + "min_pwm": 0x5a, + "abnormal_pwm": 0xff, + "warning_pwm": 0xff, + "temp_invalid_pid_pwm": 0x5a, + "temp_error_pid_pwm": 0x5a, + "temp_fail_num": 3, + "check_temp_fail" : [ + {"temp_name" : "INLET_TEMP"}, + {"temp_name" : "SWITCH_TEMP"}, + {"temp_name" : "CPU_TEMP"}, + ], + "temp_warning_num": 3, # temp over warning 3 times continuously + "temp_critical_num": 3, # temp over critical 3 times continuously + "temp_warning_countdown": 60, # 5 min warning speed after not warning + "temp_critical_countdown": 60, # 5 min full speed after not critical + "rotor_error_count": 6, # fan rotor error 6 times continuously + "inlet_mac_diff": 999, + "check_crit_reboot_flag": 1, + "check_crit_reboot_num": 3, + "check_crit_sleep_time": 20, + "psu_absent_fullspeed_num": 0xFF, + "fan_absent_fullspeed_num": 1, + "rotor_error_fullspeed_num": 1, + }, + + "ledcontrol_para": { + "interval": 5, + "checkpsu": 1, + "checkfan": 1, + "psu_yellow_num": 1, + "fan_yellow_num": 1, + "board_sys_led" : [ + {"led_name" : "FRONT_SYS_LED"}, + ], + "board_psu_led" : [ + {"led_name" : "FRONT_PSU_LED"}, + ], + "board_fan_led" : [ + {"led_name" : "FRONT_FAN_LED"}, + ], + "psu_air_flow_monitor": 1, + "fan_air_flow_monitor": 1, + }, + + "intelligent_monitor_para": { + "interval": 60, + }, + + "dcdc_monitor_whitelist": { #not monitor when checkbit equal okval + "UPORT_QSFP56_VDD3.3V_A": {"gettype": "i2c", "bus": 60, "addr": 0x3d, "offset": 0x80, "checkbit": 0, "okval": 0}, + "UPORT_QSFP56_VDD3.3V_B": {"gettype": "i2c", "bus": 60, "addr": 0x3d, "offset": 0x80, "checkbit": 1, "okval": 0}, + "UPORT_QSFP56_VDD3.3V_C": {"gettype": "i2c", "bus": 60, "addr": 0x3d, "offset": 0x80, "checkbit": 2, "okval": 0}, + "UPORT_QSFP56_VDD3.3V_D": {"gettype": "i2c", "bus": 60, "addr": 0x3d, "offset": 0x80, "checkbit": 3, "okval": 0}, + "DPORT_QSFP56_VDD3.3V_A": {"gettype": "i2c", "bus": 111, "addr": 0x3d, "offset": 0x80, "checkbit": 0, "okval": 0}, + "DPORT_QSFP56_VDD3.3V_B": {"gettype": "i2c", "bus": 111, "addr": 0x3d, "offset": 0x80, "checkbit": 1, "okval": 0}, + "DPORT_QSFP56_VDD3.3V_C": {"gettype": "i2c", "bus": 111, "addr": 0x3d, "offset": 0x80, "checkbit": 2, "okval": 0}, + "DPORT_QSFP56_VDD3.3V_D": {"gettype": "i2c", "bus": 111, "addr": 0x3d, "offset": 0x80, "checkbit": 3, "okval": 0}, + "MAC_QSFPDD_VDD3.3V_A": {"gettype": "i2c", "bus": 77, "addr": 0x1d, "offset": 0x7c, "checkbit": 0, "okval": 0}, + "MAC_QSFPDD_VDD3.3V_B": {"gettype": "i2c", "bus": 77, "addr": 0x1d, "offset": 0x7c, "checkbit": 1, "okval": 0}, + "MAC_QSFPDD_VDD3.3V_C": {"gettype": "i2c", "bus": 77, "addr": 0x1d, "offset": 0x7c, "checkbit": 2, "okval": 0}, + "MAC_QSFPDD_VDD3.3V_D": {"gettype": "i2c", "bus": 77, "addr": 0x1d, "offset": 0x7c, "checkbit": 3, "okval": 0}, + "MAC_QSFPDD_VDD3.3V_E": {"gettype": "i2c", "bus": 77, "addr": 0x1d, "offset": 0x7c, "checkbit": 4, "okval": 0}, + "MAC_QSFPDD_VDD3.3V_F": {"gettype": "i2c", "bus": 77, "addr": 0x1d, "offset": 0x7c, "checkbit": 5, "okval": 0}, + "MAC_QSFPDD_VDD3.3V_G": {"gettype": "i2c", "bus": 77, "addr": 0x1d, "offset": 0x7c, "checkbit": 6, "okval": 0}, + "MAC_QSFPDD_VDD3.3V_H": {"gettype": "i2c", "bus": 77, "addr": 0x1d, "offset": 0x7c, "checkbit": 7, "okval": 0}, + }, +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/Makefile b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/Makefile new file mode 100755 index 000000000000..873cb472f957 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/Makefile @@ -0,0 +1,12 @@ +MAKEFILE_FILE_PATH = $(abspath $(lastword $(MAKEFILE_LIST))) +MODULES_DIR = $(abspath $(MAKEFILE_FILE_PATH)/../../../../common/modules) + +EXTRA_CFLAGS+= -I$(MODULES_DIR) + +obj-m += rg_pcie_dev_device.o +obj-m += rg_fpga_i2c_bus_device.o +obj-m += rg_fpga_pca954x_device.o +obj-m += rg_lpc_drv_device.o +obj-m += rg_i2c_dev_device.o +obj-m += rg_io_dev_device.o +obj-m += rg_wdt_device.o \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_fpga_i2c_bus_device.c b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_fpga_i2c_bus_device.c new file mode 100644 index 000000000000..f3022cec2bbb --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_fpga_i2c_bus_device.c @@ -0,0 +1,2394 @@ +#include +#include +#include +#include +#include + +#include + +static int g_rg_fpga_i2c_debug = 0; +static int g_rg_fpga_i2c_error = 0; + +module_param(g_rg_fpga_i2c_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_fpga_i2c_error, int, S_IRUGO | S_IWUSR); + +#define RG_FPGA_I2C_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_rg_fpga_i2c_debug) { \ + printk(KERN_INFO "[RG_FPGA_I2C][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RG_FPGA_I2C_DEBUG_ERROR(fmt, args...) do { \ + if (g_rg_fpga_i2c_error) { \ + printk(KERN_ERR "[RG_FPGA_I2C][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static fpga_i2c_bus_device_t fpga0_i2c_bus_device_data0 = { + .adap_nr = 2, + .i2c_timeout = 3000, + .i2c_scale = 0x300, + .i2c_filter = 0x304, + .i2c_stretch = 0x308, + .i2c_ext_9548_exits_flag = 0x30c, + .i2c_ext_9548_addr = 0x310, + .i2c_ext_9548_chan = 0x314, + .i2c_in_9548_chan = 0x318, + .i2c_slave = 0x31c, + .i2c_reg = 0x320, + .i2c_reg_len = 0x330, + .i2c_data_len = 0x334, + .i2c_ctrl = 0x338, + .i2c_status = 0x33c, + .i2c_err_vec = 0x348, + .i2c_data_buf = 0x380, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x80, + .i2c_reset_on = 0x00000001, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga0_i2c_bus_device_data1 = { + .adap_nr = 3, + .i2c_timeout = 3000, + .i2c_scale = 0x400, + .i2c_filter = 0x404, + .i2c_stretch = 0x408, + .i2c_ext_9548_exits_flag = 0x40c, + .i2c_ext_9548_addr = 0x410, + .i2c_ext_9548_chan = 0x414, + .i2c_in_9548_chan = 0x418, + .i2c_slave = 0x41c, + .i2c_reg = 0x420, + .i2c_reg_len = 0x430, + .i2c_data_len = 0x434, + .i2c_ctrl = 0x438, + .i2c_status = 0x43c, + .i2c_err_vec = 0x448, + .i2c_data_buf = 0x480, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x80, + .i2c_reset_on = 0x00000002, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga0_dom_i2c_bus_device_data0 = { + .adap_nr = 4, + .i2c_timeout = 3000, + .i2c_scale = 0x2c00, + .i2c_filter = 0x2c04, + .i2c_stretch = 0x2c08, + .i2c_ext_9548_exits_flag = 0x2c0c, + .i2c_ext_9548_addr = 0x2c10, + .i2c_ext_9548_chan = 0x2c14, + .i2c_in_9548_chan = 0x2c18, + .i2c_slave = 0x2c1c, + .i2c_reg = 0x2c20, + .i2c_reg_len = 0x2c30, + .i2c_data_len = 0x2c34, + .i2c_ctrl = 0x2c38, + .i2c_status = 0x2c3c, + .i2c_err_vec = 0x2c48, + .i2c_data_buf = 0x2c80, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000001, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; +static fpga_i2c_bus_device_t fpga0_dom_i2c_bus_device_data1 = { + .adap_nr = 5, + .i2c_timeout = 3000, + .i2c_scale = 0x2d00, + .i2c_filter = 0x2d04, + .i2c_stretch = 0x2d08, + .i2c_ext_9548_exits_flag = 0x2d0c, + .i2c_ext_9548_addr = 0x2d10, + .i2c_ext_9548_chan = 0x2d14, + .i2c_in_9548_chan = 0x2d18, + .i2c_slave = 0x2d1c, + .i2c_reg = 0x2d20, + .i2c_reg_len = 0x2d30, + .i2c_data_len = 0x2d34, + .i2c_ctrl = 0x2d38, + .i2c_status = 0x2d3c, + .i2c_err_vec = 0x2d48, + .i2c_data_buf = 0x2d80, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000002, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga0_dom_i2c_bus_device_data2 = { + .adap_nr = 6, + .i2c_timeout = 3000, + .i2c_scale = 0x2e00, + .i2c_filter = 0x2e04, + .i2c_stretch = 0x2e08, + .i2c_ext_9548_exits_flag = 0x2e0c, + .i2c_ext_9548_addr = 0x2e10, + .i2c_ext_9548_chan = 0x2e14, + .i2c_in_9548_chan = 0x2e18, + .i2c_slave = 0x2e1c, + .i2c_reg = 0x2e20, + .i2c_reg_len = 0x2e30, + .i2c_data_len = 0x2e34, + .i2c_ctrl = 0x2e38, + .i2c_status = 0x2e3c, + .i2c_err_vec = 0x2e48, + .i2c_data_buf = 0x2e80, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000004, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga0_dom_i2c_bus_device_data3 = { + .adap_nr = 7, + .i2c_timeout = 3000, + .i2c_scale = 0x2f00, + .i2c_filter = 0x2f04, + .i2c_stretch = 0x2f08, + .i2c_ext_9548_exits_flag = 0x2f0c, + .i2c_ext_9548_addr = 0x2f10, + .i2c_ext_9548_chan = 0x2f14, + .i2c_in_9548_chan = 0x2f18, + .i2c_slave = 0x2f1c, + .i2c_reg = 0x2f20, + .i2c_reg_len = 0x2f30, + .i2c_data_len = 0x2f34, + .i2c_ctrl = 0x2f38, + .i2c_status = 0x2f3c, + .i2c_err_vec = 0x2f48, + .i2c_data_buf = 0x2f80, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000008, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga0_dom_i2c_bus_device_data4 = { + .adap_nr = 8, + .i2c_timeout = 3000, + .i2c_scale = 0x3000, + .i2c_filter = 0x3004, + .i2c_stretch = 0x3008, + .i2c_ext_9548_exits_flag = 0x300c, + .i2c_ext_9548_addr = 0x3010, + .i2c_ext_9548_chan = 0x3014, + .i2c_in_9548_chan = 0x3018, + .i2c_slave = 0x301c, + .i2c_reg = 0x3020, + .i2c_reg_len = 0x3030, + .i2c_data_len = 0x3034, + .i2c_ctrl = 0x3038, + .i2c_status = 0x303c, + .i2c_err_vec = 0x3048, + .i2c_data_buf = 0x3080, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000010, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga0_dom_i2c_bus_device_data5 = { + .adap_nr = 9, + .i2c_timeout = 3000, + .i2c_scale = 0x3100, + .i2c_filter = 0x3104, + .i2c_stretch = 0x3108, + .i2c_ext_9548_exits_flag = 0x310c, + .i2c_ext_9548_addr = 0x3110, + .i2c_ext_9548_chan = 0x3114, + .i2c_in_9548_chan = 0x3118, + .i2c_slave = 0x311c, + .i2c_reg = 0x3120, + .i2c_reg_len = 0x3130, + .i2c_data_len = 0x3134, + .i2c_ctrl = 0x3138, + .i2c_status = 0x313c, + .i2c_err_vec = 0x3148, + .i2c_data_buf = 0x3180, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000020, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga0_dom_i2c_bus_device_data6 = { + .adap_nr = 10, + .i2c_timeout = 3000, + .i2c_scale = 0x3200, + .i2c_filter = 0x3204, + .i2c_stretch = 0x3208, + .i2c_ext_9548_exits_flag = 0x320c, + .i2c_ext_9548_addr = 0x3210, + .i2c_ext_9548_chan = 0x3214, + .i2c_in_9548_chan = 0x3218, + .i2c_slave = 0x321c, + .i2c_reg = 0x3220, + .i2c_reg_len = 0x3230, + .i2c_data_len = 0x3234, + .i2c_ctrl = 0x3238, + .i2c_status = 0x323c, + .i2c_err_vec = 0x3248, + .i2c_data_buf = 0x3280, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000040, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga0_dom_i2c_bus_device_data7 = { + .adap_nr = 11, + .i2c_timeout = 3000, + .i2c_scale = 0x3300, + .i2c_filter = 0x3304, + .i2c_stretch = 0x3308, + .i2c_ext_9548_exits_flag = 0x330c, + .i2c_ext_9548_addr = 0x3310, + .i2c_ext_9548_chan = 0x3314, + .i2c_in_9548_chan = 0x3318, + .i2c_slave = 0x331c, + .i2c_reg = 0x3320, + .i2c_reg_len = 0x3330, + .i2c_data_len = 0x3334, + .i2c_ctrl = 0x3338, + .i2c_status = 0x333c, + .i2c_err_vec = 0x3348, + .i2c_data_buf = 0x3380, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000080, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga0_dom_i2c_bus_device_data8 = { + .adap_nr = 12, + .i2c_timeout = 3000, + .i2c_scale = 0x3400, + .i2c_filter = 0x3404, + .i2c_stretch = 0x3408, + .i2c_ext_9548_exits_flag = 0x340c, + .i2c_ext_9548_addr = 0x3410, + .i2c_ext_9548_chan = 0x3414, + .i2c_in_9548_chan = 0x3418, + .i2c_slave = 0x341c, + .i2c_reg = 0x3420, + .i2c_reg_len = 0x3430, + .i2c_data_len = 0x3434, + .i2c_ctrl = 0x3438, + .i2c_status = 0x343c, + .i2c_err_vec = 0x3448, + .i2c_data_buf = 0x3480, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000100, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga0_dom_i2c_bus_device_data9 = { + .adap_nr = 13, + .i2c_timeout = 3000, + .i2c_scale = 0x3500, + .i2c_filter = 0x3504, + .i2c_stretch = 0x3508, + .i2c_ext_9548_exits_flag = 0x350c, + .i2c_ext_9548_addr = 0x3510, + .i2c_ext_9548_chan = 0x3514, + .i2c_in_9548_chan = 0x3518, + .i2c_slave = 0x351c, + .i2c_reg = 0x3520, + .i2c_reg_len = 0x3530, + .i2c_data_len = 0x3534, + .i2c_ctrl = 0x3538, + .i2c_status = 0x353c, + .i2c_err_vec = 0x3548, + .i2c_data_buf = 0x3580, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000200, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga0_dom_i2c_bus_device_data10 = { + .adap_nr = 14, + .i2c_timeout = 3000, + .i2c_scale = 0x3600, + .i2c_filter = 0x3604, + .i2c_stretch = 0x3608, + .i2c_ext_9548_exits_flag = 0x360c, + .i2c_ext_9548_addr = 0x3610, + .i2c_ext_9548_chan = 0x3614, + .i2c_in_9548_chan = 0x3618, + .i2c_slave = 0x361c, + .i2c_reg = 0x3620, + .i2c_reg_len = 0x3630, + .i2c_data_len = 0x3634, + .i2c_ctrl = 0x3638, + .i2c_status = 0x363c, + .i2c_err_vec = 0x3648, + .i2c_data_buf = 0x3680, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000400, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga0_dom_i2c_bus_device_data11 = { + .adap_nr = 15, + .i2c_timeout = 3000, + .i2c_scale = 0x3700, + .i2c_filter = 0x3704, + .i2c_stretch = 0x3708, + .i2c_ext_9548_exits_flag = 0x370c, + .i2c_ext_9548_addr = 0x3710, + .i2c_ext_9548_chan = 0x3714, + .i2c_in_9548_chan = 0x3718, + .i2c_slave = 0x371c, + .i2c_reg = 0x3720, + .i2c_reg_len = 0x3730, + .i2c_data_len = 0x3734, + .i2c_ctrl = 0x3738, + .i2c_status = 0x373c, + .i2c_err_vec = 0x3748, + .i2c_data_buf = 0x3780, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000800, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga0_dom_i2c_bus_device_data12 = { + .adap_nr = 16, + .i2c_timeout = 3000, + .i2c_scale = 0x3800, + .i2c_filter = 0x3804, + .i2c_stretch = 0x3808, + .i2c_ext_9548_exits_flag = 0x380c, + .i2c_ext_9548_addr = 0x3810, + .i2c_ext_9548_chan = 0x3814, + .i2c_in_9548_chan = 0x3818, + .i2c_slave = 0x381c, + .i2c_reg = 0x3820, + .i2c_reg_len = 0x3830, + .i2c_data_len = 0x3834, + .i2c_ctrl = 0x3838, + .i2c_status = 0x383c, + .i2c_err_vec = 0x3848, + .i2c_data_buf = 0x3880, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00001000, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga0_dom_i2c_bus_device_data13 = { + .adap_nr = 17, + .i2c_timeout = 3000, + .i2c_scale = 0x3900, + .i2c_filter = 0x3904, + .i2c_stretch = 0x3908, + .i2c_ext_9548_exits_flag = 0x390c, + .i2c_ext_9548_addr = 0x3910, + .i2c_ext_9548_chan = 0x3914, + .i2c_in_9548_chan = 0x3918, + .i2c_slave = 0x391c, + .i2c_reg = 0x3920, + .i2c_reg_len = 0x3930, + .i2c_data_len = 0x3934, + .i2c_ctrl = 0x3938, + .i2c_status = 0x393c, + .i2c_err_vec = 0x3948, + .i2c_data_buf = 0x3980, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00002000, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga0_dom_i2c_bus_device_data14 = { + .adap_nr = 18, + .i2c_timeout = 3000, + .i2c_scale = 0x3a00, + .i2c_filter = 0x3a04, + .i2c_stretch = 0x3a08, + .i2c_ext_9548_exits_flag = 0x3a0c, + .i2c_ext_9548_addr = 0x3a10, + .i2c_ext_9548_chan = 0x3a14, + .i2c_in_9548_chan = 0x3a18, + .i2c_slave = 0x3a1c, + .i2c_reg = 0x3a20, + .i2c_reg_len = 0x3a30, + .i2c_data_len = 0x3a34, + .i2c_ctrl = 0x3a38, + .i2c_status = 0x3a3c, + .i2c_err_vec = 0x3a48, + .i2c_data_buf = 0x3a80, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00004000, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga0_dom_i2c_bus_device_data15 = { + .adap_nr = 19, + .i2c_timeout = 3000, + .i2c_scale = 0x3b00, + .i2c_filter = 0x3b04, + .i2c_stretch = 0x3b08, + .i2c_ext_9548_exits_flag = 0x3b0c, + .i2c_ext_9548_addr = 0x3b10, + .i2c_ext_9548_chan = 0x3b14, + .i2c_in_9548_chan = 0x3b18, + .i2c_slave = 0x3b1c, + .i2c_reg = 0x3b20, + .i2c_reg_len = 0x3b30, + .i2c_data_len = 0x3b34, + .i2c_ctrl = 0x3b38, + .i2c_status = 0x3b3c, + .i2c_err_vec = 0x3b48, + .i2c_data_buf = 0x3b80, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00008000, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_i2c_bus_device_data0 = { + .adap_nr = 20, + .i2c_timeout = 3000, + .i2c_scale = 0x1000, + .i2c_filter = 0x1004, + .i2c_stretch = 0x1008, + .i2c_ext_9548_exits_flag = 0x100c, + .i2c_ext_9548_addr = 0x1010, + .i2c_ext_9548_chan = 0x1014, + .i2c_in_9548_chan = 0x1018, + .i2c_slave = 0x101c, + .i2c_reg = 0x1020, + .i2c_reg_len = 0x1030, + .i2c_data_len = 0x1034, + .i2c_ctrl = 0x1038, + .i2c_status = 0x103c, + .i2c_err_vec = 0x1048, + .i2c_data_buf = 0x1080, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x80, + .i2c_reset_on = 0x00000001, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ + .i2c_offset_reg = 0xac, + .i2c_data_buf_len_reg = 0xa4, +}; + +static fpga_i2c_bus_device_t fpga1_i2c_bus_device_data1 = { + .adap_nr = 21, + .i2c_timeout = 3000, + .i2c_scale = 0x1100, + .i2c_filter = 0x1104, + .i2c_stretch = 0x1108, + .i2c_ext_9548_exits_flag = 0x110c, + .i2c_ext_9548_addr = 0x1110, + .i2c_ext_9548_chan = 0x1114, + .i2c_in_9548_chan = 0x1118, + .i2c_slave = 0x111c, + .i2c_reg = 0x1120, + .i2c_reg_len = 0x1130, + .i2c_data_len = 0x1134, + .i2c_ctrl = 0x1138, + .i2c_status = 0x113c, + .i2c_err_vec = 0x1148, + .i2c_data_buf = 0x1180, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x84, + .i2c_reset_on = 0x00000001, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_i2c_bus_device_data2 = { + .adap_nr = 22, + .i2c_timeout = 3000, + .i2c_scale = 0x1200, + .i2c_filter = 0x1204, + .i2c_stretch = 0x1208, + .i2c_ext_9548_exits_flag = 0x120c, + .i2c_ext_9548_addr = 0x1210, + .i2c_ext_9548_chan = 0x1214, + .i2c_in_9548_chan = 0x1218, + .i2c_slave = 0x121c, + .i2c_reg = 0x1220, + .i2c_reg_len = 0x1230, + .i2c_data_len = 0x1234, + .i2c_ctrl = 0x1238, + .i2c_status = 0x123c, + .i2c_err_vec = 0x1248, + .i2c_data_buf = 0x1280, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x88, + .i2c_reset_on = 0x00000001, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_i2c_bus_device_data3 = { + .adap_nr = 23, + .i2c_timeout = 3000, + .i2c_scale = 0x1300, + .i2c_filter = 0x1304, + .i2c_stretch = 0x1308, + .i2c_ext_9548_exits_flag = 0x130c, + .i2c_ext_9548_addr = 0x1310, + .i2c_ext_9548_chan = 0x1314, + .i2c_in_9548_chan = 0x1318, + .i2c_slave = 0x131c, + .i2c_reg = 0x1320, + .i2c_reg_len = 0x1330, + .i2c_data_len = 0x1334, + .i2c_ctrl = 0x1338, + .i2c_status = 0x133c, + .i2c_err_vec = 0x1348, + .i2c_data_buf = 0x1380, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x8c, + .i2c_reset_on = 0x00000001, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_i2c_bus_device_data4 = { + .adap_nr = 24, + .i2c_timeout = 3000, + .i2c_scale = 0x1400, + .i2c_filter = 0x1404, + .i2c_stretch = 0x1408, + .i2c_ext_9548_exits_flag = 0x140c, + .i2c_ext_9548_addr = 0x1410, + .i2c_ext_9548_chan = 0x1414, + .i2c_in_9548_chan = 0x1418, + .i2c_slave = 0x141c, + .i2c_reg = 0x1420, + .i2c_reg_len = 0x1430, + .i2c_data_len = 0x1434, + .i2c_ctrl = 0x1438, + .i2c_status = 0x143c, + .i2c_err_vec = 0x1448, + .i2c_data_buf = 0x1480, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x4c, + .i2c_reset_on = 0x00000001, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_i2c_bus_device_data5 = { + .adap_nr = 25, + .i2c_timeout = 3000, + .i2c_scale = 0x1500, + .i2c_filter = 0x1504, + .i2c_stretch = 0x1508, + .i2c_ext_9548_exits_flag = 0x150c, + .i2c_ext_9548_addr = 0x1510, + .i2c_ext_9548_chan = 0x1514, + .i2c_in_9548_chan = 0x1518, + .i2c_slave = 0x151c, + .i2c_reg = 0x1520, + .i2c_reg_len = 0x1530, + .i2c_data_len = 0x1534, + .i2c_ctrl = 0x1538, + .i2c_status = 0x153c, + .i2c_err_vec = 0x1548, + .i2c_data_buf = 0x1580, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x50, + .i2c_reset_on = 0x00000001, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_dom_i2c_bus_device_data0 = { + .adap_nr = 26, + .i2c_timeout = 3000, + .i2c_scale = 0x2000, + .i2c_filter = 0x2004, + .i2c_stretch = 0x2008, + .i2c_ext_9548_exits_flag = 0x200c, + .i2c_ext_9548_addr = 0x2010, + .i2c_ext_9548_chan = 0x2014, + .i2c_in_9548_chan = 0x2018, + .i2c_slave = 0x201c, + .i2c_reg = 0x2020, + .i2c_reg_len = 0x2030, + .i2c_data_len = 0x2034, + .i2c_ctrl = 0x2038, + .i2c_status = 0x203c, + .i2c_err_vec = 0x2048, + .i2c_data_buf = 0x2080, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000001, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_dom_i2c_bus_device_data1 = { + .adap_nr = 27, + .i2c_timeout = 3000, + .i2c_scale = 0x2100, + .i2c_filter = 0x2104, + .i2c_stretch = 0x2108, + .i2c_ext_9548_exits_flag = 0x210c, + .i2c_ext_9548_addr = 0x2110, + .i2c_ext_9548_chan = 0x2114, + .i2c_in_9548_chan = 0x2118, + .i2c_slave = 0x211c, + .i2c_reg = 0x2120, + .i2c_reg_len = 0x2130, + .i2c_data_len = 0x2134, + .i2c_ctrl = 0x2138, + .i2c_status = 0x213c, + .i2c_err_vec = 0x2148, + .i2c_data_buf = 0x2180, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000002, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_dom_i2c_bus_device_data2 = { + .adap_nr = 28, + .i2c_timeout = 3000, + .i2c_scale = 0x2200, + .i2c_filter = 0x2204, + .i2c_stretch = 0x2208, + .i2c_ext_9548_exits_flag = 0x220c, + .i2c_ext_9548_addr = 0x2210, + .i2c_ext_9548_chan = 0x2214, + .i2c_in_9548_chan = 0x2218, + .i2c_slave = 0x221c, + .i2c_reg = 0x2220, + .i2c_reg_len = 0x2230, + .i2c_data_len = 0x2234, + .i2c_ctrl = 0x2238, + .i2c_status = 0x223c, + .i2c_err_vec = 0x2248, + .i2c_data_buf = 0x2280, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000004, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_dom_i2c_bus_device_data3 = { + .adap_nr = 29, + .i2c_timeout = 3000, + .i2c_scale = 0x2300, + .i2c_filter = 0x2304, + .i2c_stretch = 0x2308, + .i2c_ext_9548_exits_flag = 0x230c, + .i2c_ext_9548_addr = 0x2310, + .i2c_ext_9548_chan = 0x2314, + .i2c_in_9548_chan = 0x2318, + .i2c_slave = 0x231c, + .i2c_reg = 0x2320, + .i2c_reg_len = 0x2330, + .i2c_data_len = 0x2334, + .i2c_ctrl = 0x2338, + .i2c_status = 0x233c, + .i2c_err_vec = 0x2348, + .i2c_data_buf = 0x2380, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000008, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_dom_i2c_bus_device_data4 = { + .adap_nr = 30, + .i2c_timeout = 3000, + .i2c_scale = 0x2400, + .i2c_filter = 0x2404, + .i2c_stretch = 0x2408, + .i2c_ext_9548_exits_flag = 0x240c, + .i2c_ext_9548_addr = 0x2410, + .i2c_ext_9548_chan = 0x2414, + .i2c_in_9548_chan = 0x2418, + .i2c_slave = 0x241c, + .i2c_reg = 0x2420, + .i2c_reg_len = 0x2430, + .i2c_data_len = 0x2434, + .i2c_ctrl = 0x2438, + .i2c_status = 0x243c, + .i2c_err_vec = 0x2448, + .i2c_data_buf = 0x2480, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000010, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_dom_i2c_bus_device_data5 = { + .adap_nr = 31, + .i2c_timeout = 3000, + .i2c_scale = 0x2500, + .i2c_filter = 0x2504, + .i2c_stretch = 0x2508, + .i2c_ext_9548_exits_flag = 0x250c, + .i2c_ext_9548_addr = 0x2510, + .i2c_ext_9548_chan = 0x2514, + .i2c_in_9548_chan = 0x2518, + .i2c_slave = 0x251c, + .i2c_reg = 0x2520, + .i2c_reg_len = 0x2530, + .i2c_data_len = 0x2534, + .i2c_ctrl = 0x2538, + .i2c_status = 0x253c, + .i2c_err_vec = 0x2548, + .i2c_data_buf = 0x2580, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000020, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_dom_i2c_bus_device_data6 = { + .adap_nr = 32, + .i2c_timeout = 3000, + .i2c_scale = 0x2600, + .i2c_filter = 0x2604, + .i2c_stretch = 0x2608, + .i2c_ext_9548_exits_flag = 0x260c, + .i2c_ext_9548_addr = 0x2610, + .i2c_ext_9548_chan = 0x2614, + .i2c_in_9548_chan = 0x2618, + .i2c_slave = 0x261c, + .i2c_reg = 0x2620, + .i2c_reg_len = 0x2630, + .i2c_data_len = 0x2634, + .i2c_ctrl = 0x2638, + .i2c_status = 0x263c, + .i2c_err_vec = 0x2648, + .i2c_data_buf = 0x2680, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000040, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_dom_i2c_bus_device_data7 = { + .adap_nr = 33, + .i2c_timeout = 3000, + .i2c_scale = 0x2700, + .i2c_filter = 0x2704, + .i2c_stretch = 0x2708, + .i2c_ext_9548_exits_flag = 0x270c, + .i2c_ext_9548_addr = 0x2710, + .i2c_ext_9548_chan = 0x2714, + .i2c_in_9548_chan = 0x2718, + .i2c_slave = 0x271c, + .i2c_reg = 0x2720, + .i2c_reg_len = 0x2730, + .i2c_data_len = 0x2734, + .i2c_ctrl = 0x2738, + .i2c_status = 0x273c, + .i2c_err_vec = 0x2748, + .i2c_data_buf = 0x2780, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000080, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_dom_i2c_bus_device_data8 = { + .adap_nr = 34, + .i2c_timeout = 3000, + .i2c_scale = 0x2800, + .i2c_filter = 0x2804, + .i2c_stretch = 0x2808, + .i2c_ext_9548_exits_flag = 0x280c, + .i2c_ext_9548_addr = 0x2810, + .i2c_ext_9548_chan = 0x2814, + .i2c_in_9548_chan = 0x2818, + .i2c_slave = 0x281c, + .i2c_reg = 0x2820, + .i2c_reg_len = 0x2830, + .i2c_data_len = 0x2834, + .i2c_ctrl = 0x2838, + .i2c_status = 0x283c, + .i2c_err_vec = 0x2848, + .i2c_data_buf = 0x2880, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000100, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_dom_i2c_bus_device_data9 = { + .adap_nr = 35, + .i2c_timeout = 3000, + .i2c_scale = 0x2900, + .i2c_filter = 0x2904, + .i2c_stretch = 0x2908, + .i2c_ext_9548_exits_flag = 0x290c, + .i2c_ext_9548_addr = 0x2910, + .i2c_ext_9548_chan = 0x2914, + .i2c_in_9548_chan = 0x2918, + .i2c_slave = 0x291c, + .i2c_reg = 0x2920, + .i2c_reg_len = 0x2930, + .i2c_data_len = 0x2934, + .i2c_ctrl = 0x2938, + .i2c_status = 0x293c, + .i2c_err_vec = 0x2948, + .i2c_data_buf = 0x2980, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000200, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_dom_i2c_bus_device_data10 = { + .adap_nr = 36, + .i2c_timeout = 3000, + .i2c_scale = 0x2a00, + .i2c_filter = 0x2a04, + .i2c_stretch = 0x2a08, + .i2c_ext_9548_exits_flag = 0x2a0c, + .i2c_ext_9548_addr = 0x2a10, + .i2c_ext_9548_chan = 0x2a14, + .i2c_in_9548_chan = 0x2a18, + .i2c_slave = 0x2a1c, + .i2c_reg = 0x2a20, + .i2c_reg_len = 0x2a30, + .i2c_data_len = 0x2a34, + .i2c_ctrl = 0x2a38, + .i2c_status = 0x2a3c, + .i2c_err_vec = 0x2a48, + .i2c_data_buf = 0x2a80, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000400, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_dom_i2c_bus_device_data11 = { + .adap_nr = 37, + .i2c_timeout = 3000, + .i2c_scale = 0x2b00, + .i2c_filter = 0x2b04, + .i2c_stretch = 0x2b08, + .i2c_ext_9548_exits_flag = 0x2b0c, + .i2c_ext_9548_addr = 0x2b10, + .i2c_ext_9548_chan = 0x2b14, + .i2c_in_9548_chan = 0x2b18, + .i2c_slave = 0x2b1c, + .i2c_reg = 0x2b20, + .i2c_reg_len = 0x2b30, + .i2c_data_len = 0x2b34, + .i2c_ctrl = 0x2b38, + .i2c_status = 0x2b3c, + .i2c_err_vec = 0x2b48, + .i2c_data_buf = 0x2b80, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000800, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_dom_i2c_bus_device_data12 = { + .adap_nr = 38, + .i2c_timeout = 3000, + .i2c_scale = 0x2c00, + .i2c_filter = 0x2c04, + .i2c_stretch = 0x2c08, + .i2c_ext_9548_exits_flag = 0x2c0c, + .i2c_ext_9548_addr = 0x2c10, + .i2c_ext_9548_chan = 0x2c14, + .i2c_in_9548_chan = 0x2c18, + .i2c_slave = 0x2c1c, + .i2c_reg = 0x2c20, + .i2c_reg_len = 0x2c30, + .i2c_data_len = 0x2c34, + .i2c_ctrl = 0x2c38, + .i2c_status = 0x2c3c, + .i2c_err_vec = 0x2c48, + .i2c_data_buf = 0x2c80, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00001000, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_dom_i2c_bus_device_data13 = { + .adap_nr = 39, + .i2c_timeout = 3000, + .i2c_scale = 0x2d00, + .i2c_filter = 0x2d04, + .i2c_stretch = 0x2d08, + .i2c_ext_9548_exits_flag = 0x2d0c, + .i2c_ext_9548_addr = 0x2d10, + .i2c_ext_9548_chan = 0x2d14, + .i2c_in_9548_chan = 0x2d18, + .i2c_slave = 0x2d1c, + .i2c_reg = 0x2d20, + .i2c_reg_len = 0x2d30, + .i2c_data_len = 0x2d34, + .i2c_ctrl = 0x2d38, + .i2c_status = 0x2d3c, + .i2c_err_vec = 0x2d48, + .i2c_data_buf = 0x2d80, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00002000, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_dom_i2c_bus_device_data14 = { + .adap_nr = 40, + .i2c_timeout = 3000, + .i2c_scale = 0x2e00, + .i2c_filter = 0x2e04, + .i2c_stretch = 0x2e08, + .i2c_ext_9548_exits_flag = 0x2e0c, + .i2c_ext_9548_addr = 0x2e10, + .i2c_ext_9548_chan = 0x2e14, + .i2c_in_9548_chan = 0x2e18, + .i2c_slave = 0x2e1c, + .i2c_reg = 0x2e20, + .i2c_reg_len = 0x2e30, + .i2c_data_len = 0x2e34, + .i2c_ctrl = 0x2e38, + .i2c_status = 0x2e3c, + .i2c_err_vec = 0x2e48, + .i2c_data_buf = 0x2e80, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00004000, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_dom_i2c_bus_device_data15 = { + .adap_nr = 41, + .i2c_timeout = 3000, + .i2c_scale = 0x2f00, + .i2c_filter = 0x2f04, + .i2c_stretch = 0x2f08, + .i2c_ext_9548_exits_flag = 0x2f0c, + .i2c_ext_9548_addr = 0x2f10, + .i2c_ext_9548_chan = 0x2f14, + .i2c_in_9548_chan = 0x2f18, + .i2c_slave = 0x2f1c, + .i2c_reg = 0x2f20, + .i2c_reg_len = 0x2f30, + .i2c_data_len = 0x2f34, + .i2c_ctrl = 0x2f38, + .i2c_status = 0x2f3c, + .i2c_err_vec = 0x2f48, + .i2c_data_buf = 0x2f80, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00008000, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga2_i2c_bus_device_data0 = { + .adap_nr = 42, + .i2c_timeout = 3000, + .i2c_scale = 0x300, + .i2c_filter = 0x304, + .i2c_stretch = 0x308, + .i2c_ext_9548_exits_flag = 0x30c, + .i2c_ext_9548_addr = 0x310, + .i2c_ext_9548_chan = 0x314, + .i2c_in_9548_chan = 0x318, + .i2c_slave = 0x31c, + .i2c_reg = 0x320, + .i2c_reg_len = 0x330, + .i2c_data_len = 0x334, + .i2c_ctrl = 0x338, + .i2c_status = 0x33c, + .i2c_err_vec = 0x348, + .i2c_data_buf = 0x380, + .dev_name = "/dev/fpga2", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x80, + .i2c_reset_on = 0x00000001, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga2_i2c_bus_device_data1 = { + .adap_nr = 43, + .i2c_timeout = 3000, + .i2c_scale = 0x400, + .i2c_filter = 0x404, + .i2c_stretch = 0x408, + .i2c_ext_9548_exits_flag = 0x40c, + .i2c_ext_9548_addr = 0x410, + .i2c_ext_9548_chan = 0x414, + .i2c_in_9548_chan = 0x418, + .i2c_slave = 0x41c, + .i2c_reg = 0x420, + .i2c_reg_len = 0x430, + .i2c_data_len = 0x434, + .i2c_ctrl = 0x438, + .i2c_status = 0x43c, + .i2c_err_vec = 0x448, + .i2c_data_buf = 0x480, + .dev_name = "/dev/fpga2", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x80, + .i2c_reset_on = 0x00000002, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga2_dom_i2c_bus_device_data0 = { + .adap_nr = 44, + .i2c_timeout = 3000, + .i2c_scale = 0x2c00, + .i2c_filter = 0x2c04, + .i2c_stretch = 0x2c08, + .i2c_ext_9548_exits_flag = 0x2c0c, + .i2c_ext_9548_addr = 0x2c10, + .i2c_ext_9548_chan = 0x2c14, + .i2c_in_9548_chan = 0x2c18, + .i2c_slave = 0x2c1c, + .i2c_reg = 0x2c20, + .i2c_reg_len = 0x2c30, + .i2c_data_len = 0x2c34, + .i2c_ctrl = 0x2c38, + .i2c_status = 0x2c3c, + .i2c_err_vec = 0x2c48, + .i2c_data_buf = 0x2c80, + .dev_name = "/dev/fpga2", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000001, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga2_dom_i2c_bus_device_data1 = { + .adap_nr = 45, + .i2c_timeout = 3000, + .i2c_scale = 0x2d00, + .i2c_filter = 0x2d04, + .i2c_stretch = 0x2d08, + .i2c_ext_9548_exits_flag = 0x2d0c, + .i2c_ext_9548_addr = 0x2d10, + .i2c_ext_9548_chan = 0x2d14, + .i2c_in_9548_chan = 0x2d18, + .i2c_slave = 0x2d1c, + .i2c_reg = 0x2d20, + .i2c_reg_len = 0x2d30, + .i2c_data_len = 0x2d34, + .i2c_ctrl = 0x2d38, + .i2c_status = 0x2d3c, + .i2c_err_vec = 0x2d48, + .i2c_data_buf = 0x2d80, + .dev_name = "/dev/fpga2", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000002, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga2_dom_i2c_bus_device_data2 = { + .adap_nr = 46, + .i2c_timeout = 3000, + .i2c_scale = 0x2e00, + .i2c_filter = 0x2e04, + .i2c_stretch = 0x2e08, + .i2c_ext_9548_exits_flag = 0x2e0c, + .i2c_ext_9548_addr = 0x2e10, + .i2c_ext_9548_chan = 0x2e14, + .i2c_in_9548_chan = 0x2e18, + .i2c_slave = 0x2e1c, + .i2c_reg = 0x2e20, + .i2c_reg_len = 0x2e30, + .i2c_data_len = 0x2e34, + .i2c_ctrl = 0x2e38, + .i2c_status = 0x2e3c, + .i2c_err_vec = 0x2e48, + .i2c_data_buf = 0x2e80, + .dev_name = "/dev/fpga2", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000004, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga2_dom_i2c_bus_device_data3 = { + .adap_nr = 47, + .i2c_timeout = 3000, + .i2c_scale = 0x2f00, + .i2c_filter = 0x2f04, + .i2c_stretch = 0x2f08, + .i2c_ext_9548_exits_flag = 0x2f0c, + .i2c_ext_9548_addr = 0x2f10, + .i2c_ext_9548_chan = 0x2f14, + .i2c_in_9548_chan = 0x2f18, + .i2c_slave = 0x2f1c, + .i2c_reg = 0x2f20, + .i2c_reg_len = 0x2f30, + .i2c_data_len = 0x2f34, + .i2c_ctrl = 0x2f38, + .i2c_status = 0x2f3c, + .i2c_err_vec = 0x2f48, + .i2c_data_buf = 0x2f80, + .dev_name = "/dev/fpga2", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000008, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga2_dom_i2c_bus_device_data4 = { + .adap_nr = 48, + .i2c_timeout = 3000, + .i2c_scale = 0x3000, + .i2c_filter = 0x3004, + .i2c_stretch = 0x3008, + .i2c_ext_9548_exits_flag = 0x300c, + .i2c_ext_9548_addr = 0x3010, + .i2c_ext_9548_chan = 0x3014, + .i2c_in_9548_chan = 0x3018, + .i2c_slave = 0x301c, + .i2c_reg = 0x3020, + .i2c_reg_len = 0x3030, + .i2c_data_len = 0x3034, + .i2c_ctrl = 0x3038, + .i2c_status = 0x303c, + .i2c_err_vec = 0x3048, + .i2c_data_buf = 0x3080, + .dev_name = "/dev/fpga2", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000010, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga2_dom_i2c_bus_device_data5 = { + .adap_nr = 49, + .i2c_timeout = 3000, + .i2c_scale = 0x3100, + .i2c_filter = 0x3104, + .i2c_stretch = 0x3108, + .i2c_ext_9548_exits_flag = 0x310c, + .i2c_ext_9548_addr = 0x3110, + .i2c_ext_9548_chan = 0x3114, + .i2c_in_9548_chan = 0x3118, + .i2c_slave = 0x311c, + .i2c_reg = 0x3120, + .i2c_reg_len = 0x3130, + .i2c_data_len = 0x3134, + .i2c_ctrl = 0x3138, + .i2c_status = 0x313c, + .i2c_err_vec = 0x3148, + .i2c_data_buf = 0x3180, + .dev_name = "/dev/fpga2", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000020, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga2_dom_i2c_bus_device_data6 = { + .adap_nr = 50, + .i2c_timeout = 3000, + .i2c_scale = 0x3200, + .i2c_filter = 0x3204, + .i2c_stretch = 0x3208, + .i2c_ext_9548_exits_flag = 0x320c, + .i2c_ext_9548_addr = 0x3210, + .i2c_ext_9548_chan = 0x3214, + .i2c_in_9548_chan = 0x3218, + .i2c_slave = 0x321c, + .i2c_reg = 0x3220, + .i2c_reg_len = 0x3230, + .i2c_data_len = 0x3234, + .i2c_ctrl = 0x3238, + .i2c_status = 0x323c, + .i2c_err_vec = 0x3248, + .i2c_data_buf = 0x3280, + .dev_name = "/dev/fpga2", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000040, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga2_dom_i2c_bus_device_data7 = { + .adap_nr = 51, + .i2c_timeout = 3000, + .i2c_scale = 0x3300, + .i2c_filter = 0x3304, + .i2c_stretch = 0x3308, + .i2c_ext_9548_exits_flag = 0x330c, + .i2c_ext_9548_addr = 0x3310, + .i2c_ext_9548_chan = 0x3314, + .i2c_in_9548_chan = 0x3318, + .i2c_slave = 0x331c, + .i2c_reg = 0x3320, + .i2c_reg_len = 0x3330, + .i2c_data_len = 0x3334, + .i2c_ctrl = 0x3338, + .i2c_status = 0x333c, + .i2c_err_vec = 0x3348, + .i2c_data_buf = 0x3380, + .dev_name = "/dev/fpga2", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000080, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga2_dom_i2c_bus_device_data8 = { + .adap_nr = 52, + .i2c_timeout = 3000, + .i2c_scale = 0x3400, + .i2c_filter = 0x3404, + .i2c_stretch = 0x3408, + .i2c_ext_9548_exits_flag = 0x340c, + .i2c_ext_9548_addr = 0x3410, + .i2c_ext_9548_chan = 0x3414, + .i2c_in_9548_chan = 0x3418, + .i2c_slave = 0x341c, + .i2c_reg = 0x3420, + .i2c_reg_len = 0x3430, + .i2c_data_len = 0x3434, + .i2c_ctrl = 0x3438, + .i2c_status = 0x343c, + .i2c_err_vec = 0x3448, + .i2c_data_buf = 0x3480, + .dev_name = "/dev/fpga2", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000100, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga2_dom_i2c_bus_device_data9 = { + .adap_nr = 53, + .i2c_timeout = 3000, + .i2c_scale = 0x3500, + .i2c_filter = 0x3504, + .i2c_stretch = 0x3508, + .i2c_ext_9548_exits_flag = 0x350c, + .i2c_ext_9548_addr = 0x3510, + .i2c_ext_9548_chan = 0x3514, + .i2c_in_9548_chan = 0x3518, + .i2c_slave = 0x351c, + .i2c_reg = 0x3520, + .i2c_reg_len = 0x3530, + .i2c_data_len = 0x3534, + .i2c_ctrl = 0x3538, + .i2c_status = 0x353c, + .i2c_err_vec = 0x3548, + .i2c_data_buf = 0x3580, + .dev_name = "/dev/fpga2", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000200, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga2_dom_i2c_bus_device_data10 = { + .adap_nr = 54, + .i2c_timeout = 3000, + .i2c_scale = 0x3600, + .i2c_filter = 0x3604, + .i2c_stretch = 0x3608, + .i2c_ext_9548_exits_flag = 0x360c, + .i2c_ext_9548_addr = 0x3610, + .i2c_ext_9548_chan = 0x3614, + .i2c_in_9548_chan = 0x3618, + .i2c_slave = 0x361c, + .i2c_reg = 0x3620, + .i2c_reg_len = 0x3630, + .i2c_data_len = 0x3634, + .i2c_ctrl = 0x3638, + .i2c_status = 0x363c, + .i2c_err_vec = 0x3648, + .i2c_data_buf = 0x3680, + .dev_name = "/dev/fpga2", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000400, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga2_dom_i2c_bus_device_data11 = { + .adap_nr = 55, + .i2c_timeout = 3000, + .i2c_scale = 0x3700, + .i2c_filter = 0x3704, + .i2c_stretch = 0x3708, + .i2c_ext_9548_exits_flag = 0x370c, + .i2c_ext_9548_addr = 0x3710, + .i2c_ext_9548_chan = 0x3714, + .i2c_in_9548_chan = 0x3718, + .i2c_slave = 0x371c, + .i2c_reg = 0x3720, + .i2c_reg_len = 0x3730, + .i2c_data_len = 0x3734, + .i2c_ctrl = 0x3738, + .i2c_status = 0x373c, + .i2c_err_vec = 0x3748, + .i2c_data_buf = 0x3780, + .dev_name = "/dev/fpga2", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000800, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga2_dom_i2c_bus_device_data12 = { + .adap_nr = 56, + .i2c_timeout = 3000, + .i2c_scale = 0x3800, + .i2c_filter = 0x3804, + .i2c_stretch = 0x3808, + .i2c_ext_9548_exits_flag = 0x380c, + .i2c_ext_9548_addr = 0x3810, + .i2c_ext_9548_chan = 0x3814, + .i2c_in_9548_chan = 0x3818, + .i2c_slave = 0x381c, + .i2c_reg = 0x3820, + .i2c_reg_len = 0x3830, + .i2c_data_len = 0x3834, + .i2c_ctrl = 0x3838, + .i2c_status = 0x383c, + .i2c_err_vec = 0x3848, + .i2c_data_buf = 0x3880, + .dev_name = "/dev/fpga2", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00001000, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga2_dom_i2c_bus_device_data13 = { + .adap_nr = 57, + .i2c_timeout = 3000, + .i2c_scale = 0x3900, + .i2c_filter = 0x3904, + .i2c_stretch = 0x3908, + .i2c_ext_9548_exits_flag = 0x390c, + .i2c_ext_9548_addr = 0x3910, + .i2c_ext_9548_chan = 0x3914, + .i2c_in_9548_chan = 0x3918, + .i2c_slave = 0x391c, + .i2c_reg = 0x3920, + .i2c_reg_len = 0x3930, + .i2c_data_len = 0x3934, + .i2c_ctrl = 0x3938, + .i2c_status = 0x393c, + .i2c_err_vec = 0x3948, + .i2c_data_buf = 0x3980, + .dev_name = "/dev/fpga2", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00002000, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga2_dom_i2c_bus_device_data14 = { + .adap_nr = 58, + .i2c_timeout = 3000, + .i2c_scale = 0x3a00, + .i2c_filter = 0x3a04, + .i2c_stretch = 0x3a08, + .i2c_ext_9548_exits_flag = 0x3a0c, + .i2c_ext_9548_addr = 0x3a10, + .i2c_ext_9548_chan = 0x3a14, + .i2c_in_9548_chan = 0x3a18, + .i2c_slave = 0x3a1c, + .i2c_reg = 0x3a20, + .i2c_reg_len = 0x3a30, + .i2c_data_len = 0x3a34, + .i2c_ctrl = 0x3a38, + .i2c_status = 0x3a3c, + .i2c_err_vec = 0x3a48, + .i2c_data_buf = 0x3a80, + .dev_name = "/dev/fpga2", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00004000, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga2_dom_i2c_bus_device_data15 = { + .adap_nr = 59, + .i2c_timeout = 3000, + .i2c_scale = 0x3b00, + .i2c_filter = 0x3b04, + .i2c_stretch = 0x3b08, + .i2c_ext_9548_exits_flag = 0x3b0c, + .i2c_ext_9548_addr = 0x3b10, + .i2c_ext_9548_chan = 0x3b14, + .i2c_in_9548_chan = 0x3b18, + .i2c_slave = 0x3b1c, + .i2c_reg = 0x3b20, + .i2c_reg_len = 0x3b30, + .i2c_data_len = 0x3b34, + .i2c_ctrl = 0x3b38, + .i2c_status = 0x3b3c, + .i2c_err_vec = 0x3b48, + .i2c_data_buf = 0x3b80, + .dev_name = "/dev/fpga2", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00008000, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static void rg_fpga_i2c_bus_device_release(struct device *dev) +{ + return; +} + +static struct platform_device fpga_i2c_bus_device[] = { + { + .name = "rg-fpga-i2c", + .id = 1, + .dev = { + .platform_data = &fpga0_i2c_bus_device_data0, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 2, + .dev = { + .platform_data = &fpga0_i2c_bus_device_data1, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 3, + .dev = { + .platform_data = &fpga0_dom_i2c_bus_device_data0, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 4, + .dev = { + .platform_data = &fpga0_dom_i2c_bus_device_data1, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 5, + .dev = { + .platform_data = &fpga0_dom_i2c_bus_device_data2, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 6, + .dev = { + .platform_data = &fpga0_dom_i2c_bus_device_data3, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 7, + .dev = { + .platform_data = &fpga0_dom_i2c_bus_device_data4, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 8, + .dev = { + .platform_data = &fpga0_dom_i2c_bus_device_data5, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 9, + .dev = { + .platform_data = &fpga0_dom_i2c_bus_device_data6, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 10, + .dev = { + .platform_data = &fpga0_dom_i2c_bus_device_data7, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 11, + .dev = { + .platform_data = &fpga0_dom_i2c_bus_device_data8, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 12, + .dev = { + .platform_data = &fpga0_dom_i2c_bus_device_data9, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 13, + .dev = { + .platform_data = &fpga0_dom_i2c_bus_device_data10, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 14, + .dev = { + .platform_data = &fpga0_dom_i2c_bus_device_data11, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 15, + .dev = { + .platform_data = &fpga0_dom_i2c_bus_device_data12, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 16, + .dev = { + .platform_data = &fpga0_dom_i2c_bus_device_data13, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 17, + .dev = { + .platform_data = &fpga0_dom_i2c_bus_device_data14, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 18, + .dev = { + .platform_data = &fpga0_dom_i2c_bus_device_data15, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 19, + .dev = { + .platform_data = &fpga1_i2c_bus_device_data0, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 20, + .dev = { + .platform_data = &fpga1_i2c_bus_device_data1, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 21, + .dev = { + .platform_data = &fpga1_i2c_bus_device_data2, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 22, + .dev = { + .platform_data = &fpga1_i2c_bus_device_data3, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 23, + .dev = { + .platform_data = &fpga1_i2c_bus_device_data4, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 24, + .dev = { + .platform_data = &fpga1_i2c_bus_device_data5, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 25, + .dev = { + .platform_data = &fpga1_dom_i2c_bus_device_data0, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 26, + .dev = { + .platform_data = &fpga1_dom_i2c_bus_device_data1, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 27, + .dev = { + .platform_data = &fpga1_dom_i2c_bus_device_data2, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 28, + .dev = { + .platform_data = &fpga1_dom_i2c_bus_device_data3, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 29, + .dev = { + .platform_data = &fpga1_dom_i2c_bus_device_data4, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 30, + .dev = { + .platform_data = &fpga1_dom_i2c_bus_device_data5, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 31, + .dev = { + .platform_data = &fpga1_dom_i2c_bus_device_data6, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 32, + .dev = { + .platform_data = &fpga1_dom_i2c_bus_device_data7, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 33, + .dev = { + .platform_data = &fpga1_dom_i2c_bus_device_data8, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 34, + .dev = { + .platform_data = &fpga1_dom_i2c_bus_device_data9, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 35, + .dev = { + .platform_data = &fpga1_dom_i2c_bus_device_data10, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 36, + .dev = { + .platform_data = &fpga1_dom_i2c_bus_device_data11, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 37, + .dev = { + .platform_data = &fpga1_dom_i2c_bus_device_data12, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 38, + .dev = { + .platform_data = &fpga1_dom_i2c_bus_device_data13, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 39, + .dev = { + .platform_data = &fpga1_dom_i2c_bus_device_data14, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 40, + .dev = { + .platform_data = &fpga1_dom_i2c_bus_device_data15, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 41, + .dev = { + .platform_data = &fpga2_i2c_bus_device_data0, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 42, + .dev = { + .platform_data = &fpga2_i2c_bus_device_data1, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 43, + .dev = { + .platform_data = &fpga2_dom_i2c_bus_device_data0, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 44, + .dev = { + .platform_data = &fpga2_dom_i2c_bus_device_data1, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 45, + .dev = { + .platform_data = &fpga2_dom_i2c_bus_device_data2, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 46, + .dev = { + .platform_data = &fpga2_dom_i2c_bus_device_data3, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 47, + .dev = { + .platform_data = &fpga2_dom_i2c_bus_device_data4, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 48, + .dev = { + .platform_data = &fpga2_dom_i2c_bus_device_data5, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 49, + .dev = { + .platform_data = &fpga2_dom_i2c_bus_device_data6, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 50, + .dev = { + .platform_data = &fpga2_dom_i2c_bus_device_data7, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 51, + .dev = { + .platform_data = &fpga2_dom_i2c_bus_device_data8, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 52, + .dev = { + .platform_data = &fpga2_dom_i2c_bus_device_data9, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 53, + .dev = { + .platform_data = &fpga2_dom_i2c_bus_device_data10, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 54, + .dev = { + .platform_data = &fpga2_dom_i2c_bus_device_data11, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 55, + .dev = { + .platform_data = &fpga2_dom_i2c_bus_device_data12, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 56, + .dev = { + .platform_data = &fpga2_dom_i2c_bus_device_data13, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 57, + .dev = { + .platform_data = &fpga2_dom_i2c_bus_device_data14, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 58, + .dev = { + .platform_data = &fpga2_dom_i2c_bus_device_data15, + .release = rg_fpga_i2c_bus_device_release, + }, + }, +}; + +static int __init rg_fpga_i2c_bus_device_init(void) +{ + int i; + int ret = 0; + fpga_i2c_bus_device_t *fpga_i2c_bus_device_data; + + RG_FPGA_I2C_DEBUG_VERBOSE("enter!\n"); + for (i = 0; i < ARRAY_SIZE(fpga_i2c_bus_device); i++) { + fpga_i2c_bus_device_data = fpga_i2c_bus_device[i].dev.platform_data; + ret = platform_device_register(&fpga_i2c_bus_device[i]); + if (ret < 0) { + fpga_i2c_bus_device_data->device_flag = -1; /* device register failed, set flag -1 */ + printk(KERN_ERR "rg-fpga-i2c.%d register failed!\n", i + 1); + } else { + fpga_i2c_bus_device_data->device_flag = 0; /* device register suucess, set flag 0 */ + } + } + return 0; +} + +static void __exit rg_fpga_i2c_bus_device_exit(void) +{ + int i; + fpga_i2c_bus_device_t *fpga_i2c_bus_device_data; + + RG_FPGA_I2C_DEBUG_VERBOSE("enter!\n"); + for (i = ARRAY_SIZE(fpga_i2c_bus_device) - 1; i >= 0; i--) { + fpga_i2c_bus_device_data = fpga_i2c_bus_device[i].dev.platform_data; + if (fpga_i2c_bus_device_data->device_flag == 0) { /* device register success, need unregister */ + platform_device_unregister(&fpga_i2c_bus_device[i]); + } + } +} + +module_init(rg_fpga_i2c_bus_device_init); +module_exit(rg_fpga_i2c_bus_device_exit); +MODULE_DESCRIPTION("FPGA I2C Devices"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd@ruijie.com.cn"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_fpga_pca954x_device.c b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_fpga_pca954x_device.c new file mode 100644 index 000000000000..4fd4539da6f3 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_fpga_pca954x_device.c @@ -0,0 +1,824 @@ +#include +#include +#include +#include +#include +#include + +#include + +static int g_rg_fpga_pca954x_device_debug = 0; +static int g_rg_fpga_pca954x_device_error = 0; + +module_param(g_rg_fpga_pca954x_device_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_fpga_pca954x_device_error, int, S_IRUGO | S_IWUSR); + +#define RG_FPGA_PCA954X_DEVICE_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_rg_fpga_pca954x_device_debug) { \ + printk(KERN_INFO "[RG_FPGA_PCA954X_DEVICE][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RG_FPGA_PCA954X_DEVICE_DEBUG_ERROR(fmt, args...) do { \ + if (g_rg_fpga_pca954x_device_error) { \ + printk(KERN_ERR "[RG_FPGA_PCA954X_DEVICE][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static fpga_pca954x_device_t fpga0_i2c0_pca954x_device_data = { + .i2c_bus = 2, + .i2c_addr = 0x70, + .pca9548_base_nr = 60, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga0_i2c1_pca954x_device_data = { + .i2c_bus = 3, + .i2c_addr = 0x70, + .pca9548_base_nr = 61, /* 61~64 */ + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_i2c0_pca954x_device_data = { + .i2c_bus = 20, + .i2c_addr = 0x70, + .pca9548_base_nr = 65, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_i2c1_pca954x_device_data = { + .i2c_bus = 21, + .i2c_addr = 0x70, + .pca9548_base_nr = 66, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_i2c2_pca954x_device_data = { + .i2c_bus = 22, + .i2c_addr = 0x70, + .pca9548_base_nr = 67, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_i2c3_pca954x_device_data = { + .i2c_bus = 23, + .i2c_addr = 0x70, + .pca9548_base_nr = 68, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_i2c4_pca954x_device_data = { + .i2c_bus = 24, + .i2c_addr = 0x70, + .pca9548_base_nr = 69, /* 69~76 */ + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_i2c5_pca954x_device_data = { + .i2c_bus = 25, + .i2c_addr = 0x70, + .pca9548_base_nr = 77, /* 77~78 */ + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_i2c0_in0_pca954x_device_data = { + .i2c_bus = 65, + .i2c_addr = 0x76, + .pca9548_base_nr = 79, /* 79~86 */ + .fpga_9548_flag = 2, + .fpga_9548_reset_flag = 1, +}; + +static fpga_pca954x_device_t fpga1_i2c1_in0_pca954x_device_data = { + .i2c_bus = 66, + .i2c_addr = 0x77, + .pca9548_base_nr = 87, /* 87~94 */ + .fpga_9548_flag = 2, + .fpga_9548_reset_flag = 1, +}; + +static fpga_pca954x_device_t fpga1_i2c2_in0_pca954x_device_data = { + .i2c_bus = 67, + .i2c_addr = 0x77, + .pca9548_base_nr = 95, /* 95~102 */ + .fpga_9548_flag = 2, + .fpga_9548_reset_flag = 1, +}; + +static fpga_pca954x_device_t fpga1_i2c3_in0_pca954x_device_data = { + .i2c_bus = 68, + .i2c_addr = 0x77, + .pca9548_base_nr = 103, /* 103~110 */ + .fpga_9548_flag = 2, + .fpga_9548_reset_flag = 1, +}; + +static fpga_pca954x_device_t fpga2_i2c0_pca954x_device_data = { + .i2c_bus = 42, + .i2c_addr = 0x70, + .pca9548_base_nr = 111, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga2_i2c1_pca954x_device_data = { + .i2c_bus = 43, + .i2c_addr = 0x70, + .pca9548_base_nr = 112, /* 112~115 */ + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga0_dom_i2c0_pca954x_device_data = { + .i2c_bus = 4, + .i2c_addr = 0x70, + .pca9548_base_nr = 124, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga0_dom_i2c1_pca954x_device_data = { + .i2c_bus = 5, + .i2c_addr = 0x70, + .pca9548_base_nr = 126, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga0_dom_i2c2_pca954x_device_data = { + .i2c_bus = 6, + .i2c_addr = 0x70, + .pca9548_base_nr = 128, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga0_dom_i2c3_pca954x_device_data = { + .i2c_bus = 7, + .i2c_addr = 0x70, + .pca9548_base_nr = 130, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga0_dom_i2c4_pca954x_device_data = { + .i2c_bus = 8, + .i2c_addr = 0x70, + .pca9548_base_nr = 132, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga0_dom_i2c5_pca954x_device_data = { + .i2c_bus = 9, + .i2c_addr = 0x70, + .pca9548_base_nr = 134, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga0_dom_i2c6_pca954x_device_data = { + .i2c_bus = 10, + .i2c_addr = 0x70, + .pca9548_base_nr = 136, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga0_dom_i2c7_pca954x_device_data = { + .i2c_bus = 11, + .i2c_addr = 0x70, + .pca9548_base_nr = 138, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga0_dom_i2c8_pca954x_device_data = { + .i2c_bus = 12, + .i2c_addr = 0x70, + .pca9548_base_nr = 140, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga0_dom_i2c9_pca954x_device_data = { + .i2c_bus = 13, + .i2c_addr = 0x70, + .pca9548_base_nr = 142, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga0_dom_i2c10_pca954x_device_data = { + .i2c_bus = 14, + .i2c_addr = 0x70, + .pca9548_base_nr = 144, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga0_dom_i2c11_pca954x_device_data = { + .i2c_bus = 15, + .i2c_addr = 0x70, + .pca9548_base_nr = 146, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga0_dom_i2c12_pca954x_device_data = { + .i2c_bus = 16, + .i2c_addr = 0x70, + .pca9548_base_nr = 148, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga0_dom_i2c13_pca954x_device_data = { + .i2c_bus = 17, + .i2c_addr = 0x70, + .pca9548_base_nr = 150, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga0_dom_i2c14_pca954x_device_data = { + .i2c_bus = 18, + .i2c_addr = 0x70, + .pca9548_base_nr = 152, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga0_dom_i2c15_pca954x_device_data = { + .i2c_bus = 19, + .i2c_addr = 0x70, + .pca9548_base_nr = 154, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_dom_i2c0_pca954x_device_data = { + .i2c_bus = 26, + .i2c_addr = 0x70, + .pca9548_base_nr = 156, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_dom_i2c1_pca954x_device_data = { + .i2c_bus = 27, + .i2c_addr = 0x70, + .pca9548_base_nr = 160, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_dom_i2c2_pca954x_device_data = { + .i2c_bus = 28, + .i2c_addr = 0x70, + .pca9548_base_nr = 164, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_dom_i2c3_pca954x_device_data = { + .i2c_bus = 29, + .i2c_addr = 0x70, + .pca9548_base_nr = 168, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_dom_i2c4_pca954x_device_data = { + .i2c_bus = 30, + .i2c_addr = 0x70, + .pca9548_base_nr = 172, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_dom_i2c5_pca954x_device_data = { + .i2c_bus = 31, + .i2c_addr = 0x70, + .pca9548_base_nr = 176, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_dom_i2c6_pca954x_device_data = { + .i2c_bus = 32, + .i2c_addr = 0x70, + .pca9548_base_nr = 180, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_dom_i2c7_pca954x_device_data = { + .i2c_bus = 33, + .i2c_addr = 0x70, + .pca9548_base_nr = 184, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_dom_i2c8_pca954x_device_data = { + .i2c_bus = 34, + .i2c_addr = 0x70, + .pca9548_base_nr = 188, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_dom_i2c9_pca954x_device_data = { + .i2c_bus = 35, + .i2c_addr = 0x70, + .pca9548_base_nr = 192, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_dom_i2c10_pca954x_device_data = { + .i2c_bus = 36, + .i2c_addr = 0x70, + .pca9548_base_nr = 196, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_dom_i2c11_pca954x_device_data = { + .i2c_bus = 37, + .i2c_addr = 0x70, + .pca9548_base_nr = 200, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_dom_i2c12_pca954x_device_data = { + .i2c_bus = 38, + .i2c_addr = 0x70, + .pca9548_base_nr = 204, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_dom_i2c13_pca954x_device_data = { + .i2c_bus = 39, + .i2c_addr = 0x70, + .pca9548_base_nr = 208, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_dom_i2c14_pca954x_device_data = { + .i2c_bus = 40, + .i2c_addr = 0x70, + .pca9548_base_nr = 212, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_dom_i2c15_pca954x_device_data = { + .i2c_bus = 41, + .i2c_addr = 0x70, + .pca9548_base_nr = 216, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga2_dom_i2c0_pca954x_device_data = { + .i2c_bus = 44, + .i2c_addr = 0x70, + .pca9548_base_nr = 220, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga2_dom_i2c1_pca954x_device_data = { + .i2c_bus = 45, + .i2c_addr = 0x70, + .pca9548_base_nr = 222, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga2_dom_i2c2_pca954x_device_data = { + .i2c_bus = 46, + .i2c_addr = 0x70, + .pca9548_base_nr = 224, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga2_dom_i2c3_pca954x_device_data = { + .i2c_bus = 47, + .i2c_addr = 0x70, + .pca9548_base_nr = 226, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga2_dom_i2c4_pca954x_device_data = { + .i2c_bus = 48, + .i2c_addr = 0x70, + .pca9548_base_nr = 228, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga2_dom_i2c5_pca954x_device_data = { + .i2c_bus = 49, + .i2c_addr = 0x70, + .pca9548_base_nr = 230, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga2_dom_i2c6_pca954x_device_data = { + .i2c_bus = 50, + .i2c_addr = 0x70, + .pca9548_base_nr = 232, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga2_dom_i2c7_pca954x_device_data = { + .i2c_bus = 51, + .i2c_addr = 0x70, + .pca9548_base_nr = 234, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga2_dom_i2c8_pca954x_device_data = { + .i2c_bus = 52, + .i2c_addr = 0x70, + .pca9548_base_nr = 236, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga2_dom_i2c9_pca954x_device_data = { + .i2c_bus = 53, + .i2c_addr = 0x70, + .pca9548_base_nr = 238, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga2_dom_i2c10_pca954x_device_data = { + .i2c_bus = 54, + .i2c_addr = 0x70, + .pca9548_base_nr = 240, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga2_dom_i2c11_pca954x_device_data = { + .i2c_bus = 55, + .i2c_addr = 0x70, + .pca9548_base_nr = 242, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga2_dom_i2c12_pca954x_device_data = { + .i2c_bus = 56, + .i2c_addr = 0x70, + .pca9548_base_nr = 244, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga2_dom_i2c13_pca954x_device_data = { + .i2c_bus = 57, + .i2c_addr = 0x70, + .pca9548_base_nr = 246, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga2_dom_i2c14_pca954x_device_data = { + .i2c_bus = 58, + .i2c_addr = 0x70, + .pca9548_base_nr = 248, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga2_dom_i2c15_pca954x_device_data = { + .i2c_bus = 59, + .i2c_addr = 0x70, + .pca9548_base_nr = 250, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +struct i2c_board_info fpga_pca954x_device_info[] = { + { + .type = "rg_fpga_pca9541", + .platform_data = &fpga0_i2c0_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9545", + .platform_data = &fpga0_i2c1_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9541", + .platform_data = &fpga1_i2c0_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9541", + .platform_data = &fpga1_i2c1_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9541", + .platform_data = &fpga1_i2c2_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9541", + .platform_data = &fpga1_i2c3_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9548", + .platform_data = &fpga1_i2c4_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga1_i2c5_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9548", + .platform_data = &fpga1_i2c0_in0_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9548", + .platform_data = &fpga1_i2c1_in0_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9548", + .platform_data = &fpga1_i2c2_in0_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9548", + .platform_data = &fpga1_i2c3_in0_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9541", + .platform_data = &fpga2_i2c0_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9545", + .platform_data = &fpga2_i2c1_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga0_dom_i2c0_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga0_dom_i2c1_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga0_dom_i2c2_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga0_dom_i2c3_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga0_dom_i2c4_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga0_dom_i2c5_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga0_dom_i2c6_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga0_dom_i2c7_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga0_dom_i2c8_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga0_dom_i2c9_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga0_dom_i2c10_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga0_dom_i2c11_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga0_dom_i2c12_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga0_dom_i2c13_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga0_dom_i2c14_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga0_dom_i2c15_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9545", + .platform_data = &fpga1_dom_i2c0_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9545", + .platform_data = &fpga1_dom_i2c1_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9545", + .platform_data = &fpga1_dom_i2c2_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9545", + .platform_data = &fpga1_dom_i2c3_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9545", + .platform_data = &fpga1_dom_i2c4_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9545", + .platform_data = &fpga1_dom_i2c5_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9545", + .platform_data = &fpga1_dom_i2c6_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9545", + .platform_data = &fpga1_dom_i2c7_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9545", + .platform_data = &fpga1_dom_i2c8_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9545", + .platform_data = &fpga1_dom_i2c9_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9545", + .platform_data = &fpga1_dom_i2c10_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9545", + .platform_data = &fpga1_dom_i2c11_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9545", + .platform_data = &fpga1_dom_i2c12_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9545", + .platform_data = &fpga1_dom_i2c13_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9545", + .platform_data = &fpga1_dom_i2c14_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9545", + .platform_data = &fpga1_dom_i2c15_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga2_dom_i2c0_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga2_dom_i2c1_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga2_dom_i2c2_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga2_dom_i2c3_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga2_dom_i2c4_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga2_dom_i2c5_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga2_dom_i2c6_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga2_dom_i2c7_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga2_dom_i2c8_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga2_dom_i2c9_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga2_dom_i2c10_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga2_dom_i2c11_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga2_dom_i2c12_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga2_dom_i2c13_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga2_dom_i2c14_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga2_dom_i2c15_pca954x_device_data, + }, +}; + +static int __init rg_fpga_pca954x_device_init(void) +{ + int i; + struct i2c_adapter *adap; + struct i2c_client *client; + fpga_pca954x_device_t *fpga_pca954x_device_data; + + RG_FPGA_PCA954X_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = 0; i < ARRAY_SIZE(fpga_pca954x_device_info); i++) { + fpga_pca954x_device_data = fpga_pca954x_device_info[i].platform_data; + fpga_pca954x_device_info[i].addr = fpga_pca954x_device_data->i2c_addr; + adap = i2c_get_adapter(fpga_pca954x_device_data->i2c_bus); + if (adap == NULL) { + fpga_pca954x_device_data->client = NULL; + printk(KERN_ERR "get i2c bus %d adapter fail.\n", fpga_pca954x_device_data->i2c_bus); + continue; + } + client = i2c_new_client_device(adap, &fpga_pca954x_device_info[i]); + if (!client) { + fpga_pca954x_device_data->client = NULL; + printk(KERN_ERR "Failed to register fpga pca954x device %d at bus %d!\n", + fpga_pca954x_device_data->i2c_addr, fpga_pca954x_device_data->i2c_bus); + } else { + fpga_pca954x_device_data->client = client; + } + i2c_put_adapter(adap); + } + return 0; +} + +static void __exit rg_fpga_pca954x_device_exit(void) +{ + int i; + fpga_pca954x_device_t *fpga_pca954x_device_data; + + RG_FPGA_PCA954X_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = ARRAY_SIZE(fpga_pca954x_device_info) - 1; i >= 0; i--) { + fpga_pca954x_device_data = fpga_pca954x_device_info[i].platform_data; + if (fpga_pca954x_device_data->client) { + i2c_unregister_device(fpga_pca954x_device_data->client); + fpga_pca954x_device_data->client = NULL; + } + } +} + +module_init(rg_fpga_pca954x_device_init); +module_exit(rg_fpga_pca954x_device_exit); +MODULE_DESCRIPTION("RG FPGA PCA954X Devices"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd@ruijie.com.cn"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_i2c_dev_device.c b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_i2c_dev_device.c new file mode 100644 index 000000000000..651d5e794417 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_i2c_dev_device.c @@ -0,0 +1,185 @@ +#include +#include +#include +#include +#include +#include + +#include + +static int g_rg_i2c_dev_device_debug = 0; +static int g_rg_i2c_dev_device_error = 0; + +module_param(g_rg_i2c_dev_device_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_i2c_dev_device_error, int, S_IRUGO | S_IWUSR); + +#define RG_I2C_DEV_DEVICE_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_rg_i2c_dev_device_debug) { \ + printk(KERN_INFO "[RG_I2C_DEV_DEVICE][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RG_I2C_DEV_DEVICE_DEBUG_ERROR(fmt, args...) do { \ + if (g_rg_i2c_dev_device_error) { \ + printk(KERN_ERR "[RG_I2C_DEV_DEVICE][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static i2c_dev_device_t i2c_dev_device_data0 = { + .i2c_bus = 60, + .i2c_addr = 0x3d, + .i2c_name = "cpld2", + .data_bus_width = 1, + .addr_bus_width = 1, + .per_rd_len = 256, + .per_wr_len = 256, + .i2c_len = 256, +}; + +static i2c_dev_device_t i2c_dev_device_data1 = { + .i2c_bus = 87, + .i2c_addr = 0x0d, + .i2c_name = "cpld3", + .data_bus_width = 1, + .addr_bus_width = 1, + .per_rd_len = 256, + .per_wr_len = 256, + .i2c_len = 256, +}; + +static i2c_dev_device_t i2c_dev_device_data2 = { + .i2c_bus = 95, + .i2c_addr = 0x0d, + .i2c_name = "cpld4", + .data_bus_width = 1, + .addr_bus_width = 1, + .per_rd_len = 256, + .per_wr_len = 256, + .i2c_len = 256, +}; + +static i2c_dev_device_t i2c_dev_device_data3 = { + .i2c_bus = 77, + .i2c_addr = 0x1d, + .i2c_name = "cpld5", + .data_bus_width = 1, + .addr_bus_width = 1, + .per_rd_len = 256, + .per_wr_len = 256, + .i2c_len = 256, +}; + +static i2c_dev_device_t i2c_dev_device_data4 = { + .i2c_bus = 77, + .i2c_addr = 0x2d, + .i2c_name = "cpld6", + .data_bus_width = 1, + .addr_bus_width = 1, + .per_rd_len = 256, + .per_wr_len = 256, + .i2c_len = 256, +}; + +static i2c_dev_device_t i2c_dev_device_data5 = { + .i2c_bus = 111, + .i2c_addr = 0x3d, + .i2c_name = "cpld7", + .data_bus_width = 1, + .addr_bus_width = 1, + .per_rd_len = 256, + .per_wr_len = 256, + .i2c_len = 256, +}; + +static i2c_dev_device_t i2c_dev_device_data6 = { + .i2c_bus = 108, + .i2c_addr = 0x3b, + .i2c_name = "cpld8", + .data_bus_width = 1, + .addr_bus_width = 1, + .per_rd_len = 256, + .per_wr_len = 256, + .i2c_len = 256, +}; + +struct i2c_board_info i2c_dev_device_info[] = { + { + .type = "rg-i2c-dev", + .platform_data = &i2c_dev_device_data0, + }, + { + .type = "rg-i2c-dev", + .platform_data = &i2c_dev_device_data1, + }, + { + .type = "rg-i2c-dev", + .platform_data = &i2c_dev_device_data2, + }, + { + .type = "rg-i2c-dev", + .platform_data = &i2c_dev_device_data3, + }, + { + .type = "rg-i2c-dev", + .platform_data = &i2c_dev_device_data4, + }, + { + .type = "rg-i2c-dev", + .platform_data = &i2c_dev_device_data5, + }, + { + .type = "rg-i2c-dev", + .platform_data = &i2c_dev_device_data6, + }, +}; + +static int __init rg_i2c_dev_device_init(void) +{ + int i; + struct i2c_adapter *adap; + struct i2c_client *client; + i2c_dev_device_t *i2c_dev_device_data; + + RG_I2C_DEV_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = 0; i < ARRAY_SIZE(i2c_dev_device_info); i++) { + i2c_dev_device_data = i2c_dev_device_info[i].platform_data; + i2c_dev_device_info[i].addr = i2c_dev_device_data->i2c_addr; + adap = i2c_get_adapter(i2c_dev_device_data->i2c_bus); + if (adap == NULL) { + i2c_dev_device_data->client = NULL; + printk(KERN_ERR "get i2c bus %d adapter fail.\n", i2c_dev_device_data->i2c_bus); + continue; + } + client = i2c_new_client_device(adap, &i2c_dev_device_info[i]); + if (!client) { + i2c_dev_device_data->client = NULL; + printk(KERN_ERR "Failed to register i2c dev device %d at bus %d!\n", + i2c_dev_device_data->i2c_addr, i2c_dev_device_data->i2c_bus); + } else { + i2c_dev_device_data->client = client; + } + i2c_put_adapter(adap); + } + return 0; +} + +static void __exit rg_i2c_dev_device_exit(void) +{ + int i; + i2c_dev_device_t *i2c_dev_device_data; + + RG_I2C_DEV_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = ARRAY_SIZE(i2c_dev_device_info) - 1; i >= 0; i--) { + i2c_dev_device_data = i2c_dev_device_info[i].platform_data; + if (i2c_dev_device_data->client) { + i2c_unregister_device(i2c_dev_device_data->client); + i2c_dev_device_data->client = NULL; + } + } +} + +module_init(rg_i2c_dev_device_init); +module_exit(rg_i2c_dev_device_exit); +MODULE_DESCRIPTION("RG I2C DEV Devices"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd@ruijie.com.cn"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_io_dev_device.c b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_io_dev_device.c new file mode 100644 index 000000000000..42d887e9f2d1 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_io_dev_device.c @@ -0,0 +1,103 @@ +#include +#include +#include +#include +#include + +#include + +static int g_rg_io_dev_device_debug = 0; +static int g_rg_io_dev_device_error = 0; + +module_param(g_rg_io_dev_device_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_io_dev_device_error, int, S_IRUGO | S_IWUSR); + +#define RG_IO_DEV_DEVICE_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_rg_io_dev_device_debug) { \ + printk(KERN_INFO "[RG_IO_DEV_DEVICE][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RG_IO_DEV_DEVICE_DEBUG_ERROR(fmt, args...) do { \ + if (g_rg_io_dev_device_error) { \ + printk(KERN_ERR "[RG_IO_DEV_DEVICE][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static io_dev_device_t io_dev_device_data0 = { + .io_dev_name = "cpld0", + .io_base = 0x700, + .io_len = 0x100, + .indirect_addr = 0, +}; + +static io_dev_device_t io_dev_device_data1 = { + .io_dev_name = "cpld1", + .io_base = 0x900, + .io_len = 0x100, + .indirect_addr = 0, +}; + +static void rg_io_dev_device_release(struct device *dev) +{ + return; +} + +static struct platform_device io_dev_device[] = { + { + .name = "rg-io-dev", + .id = 1, + .dev = { + .platform_data = &io_dev_device_data0, + .release = rg_io_dev_device_release, + }, + }, + { + .name = "rg-io-dev", + .id = 2, + .dev = { + .platform_data = &io_dev_device_data1, + .release = rg_io_dev_device_release, + }, + }, +}; + +static int __init rg_io_dev_device_init(void) +{ + int i; + int ret = 0; + io_dev_device_t *io_dev_device_data; + + RG_IO_DEV_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = 0; i < ARRAY_SIZE(io_dev_device); i++) { + io_dev_device_data = io_dev_device[i].dev.platform_data; + ret = platform_device_register(&io_dev_device[i]); + if (ret < 0) { + io_dev_device_data->device_flag = -1; /* device register failed, set flag -1 */ + printk(KERN_ERR "rg-io-dev.%d register failed!\n", i + 1); + } else { + io_dev_device_data->device_flag = 0; /* device register suucess, set flag 0 */ + } + } + return 0; +} + +static void __exit rg_io_dev_device_exit(void) +{ + int i; + io_dev_device_t *io_dev_device_data; + + RG_IO_DEV_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = ARRAY_SIZE(io_dev_device) - 1; i >= 0; i--) { + io_dev_device_data = io_dev_device[i].dev.platform_data; + if (io_dev_device_data->device_flag == 0) { /* device register success, need unregister */ + platform_device_unregister(&io_dev_device[i]); + } + } +} + +module_init(rg_io_dev_device_init); +module_exit(rg_io_dev_device_exit); +MODULE_DESCRIPTION("RG IO DEV Devices"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd@ruijie.com.cn"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_lpc_drv_device.c b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_lpc_drv_device.c new file mode 100644 index 000000000000..c6a0d37c1428 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_lpc_drv_device.c @@ -0,0 +1,111 @@ +#include +#include +#include +#include +#include + +#include + +static int g_rg_lpc_drv_device_debug = 0; +static int g_rg_lpc_drv_device_error = 0; + +module_param(g_rg_lpc_drv_device_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_lpc_drv_device_error, int, S_IRUGO | S_IWUSR); + +#define RG_LPC_DRV_DEVICE_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_rg_lpc_drv_device_debug) { \ + printk(KERN_INFO "[RG_LPC_DRV_DEVICE][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RG_LPC_DRV_DEVICE_DEBUG_ERROR(fmt, args...) do { \ + if (g_rg_lpc_drv_device_error) { \ + printk(KERN_ERR "[RG_LPC_DRV_DEVICE][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static lpc_drv_device_t lpc_drv_device_data_0 = { + .lpc_io_name = "rg_lpc", + .pci_domain = 0x0000, + .pci_bus = 0x00, + .pci_slot = 0x1f, + .pci_fn = 0, + .lpc_io_base = 0x700, + .lpc_io_size = 0x100, + .lpc_gen_dec = 0x84, +}; + +static lpc_drv_device_t lpc_drv_device_data_1 = { + .lpc_io_name = "rg_lpc", + .pci_domain = 0x0000, + .pci_bus = 0x00, + .pci_slot = 0x1f, + .pci_fn = 0, + .lpc_io_base = 0x900, + .lpc_io_size = 0x100, + .lpc_gen_dec = 0x88, +}; + +static void rg_lpc_drv_device_release(struct device *dev) +{ + return; +} + +static struct platform_device lpc_drv_device[] = { + { + .name = "rg-lpc", + .id = 1, + .dev = { + .platform_data = &lpc_drv_device_data_0, + .release = rg_lpc_drv_device_release, + }, + }, + { + .name = "rg-lpc", + .id = 2, + .dev = { + .platform_data = &lpc_drv_device_data_1, + .release = rg_lpc_drv_device_release, + }, + }, +}; + +static int __init rg_lpc_drv_device_init(void) +{ + int i; + int ret = 0; + lpc_drv_device_t *lpc_drv_device_data; + + RG_LPC_DRV_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = 0; i < ARRAY_SIZE(lpc_drv_device); i++) { + lpc_drv_device_data = lpc_drv_device[i].dev.platform_data; + ret = platform_device_register(&lpc_drv_device[i]); + if (ret < 0) { + lpc_drv_device_data->device_flag = -1; /* device register failed, set flag -1 */ + printk(KERN_ERR "rg-lpc.%d register failed!\n", i + 1); + } else { + lpc_drv_device_data->device_flag = 0; /* device register suucess, set flag 0 */ + } + } + return 0; +} + +static void __exit rg_lpc_drv_device_exit(void) +{ + int i; + lpc_drv_device_t *lpc_drv_device_data; + + RG_LPC_DRV_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = ARRAY_SIZE(lpc_drv_device) - 1; i >= 0; i--) { + lpc_drv_device_data = lpc_drv_device[i].dev.platform_data; + if (lpc_drv_device_data->device_flag == 0) { /* device register success, need unregister */ + platform_device_unregister(&lpc_drv_device[i]); + } + } +} + +module_init(rg_lpc_drv_device_init); +module_exit(rg_lpc_drv_device_exit); +MODULE_DESCRIPTION("RG LPC DRV Devices"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd@ruijie.com.cn"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_pcie_dev_device.c b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_pcie_dev_device.c new file mode 100644 index 000000000000..bafa2715e38b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_pcie_dev_device.c @@ -0,0 +1,132 @@ +#include +#include +#include +#include +#include + +#include + +static int g_rg_pcie_dev_device_debug = 0; +static int g_rg_pcie_dev_device_error = 0; + +module_param(g_rg_pcie_dev_device_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_pcie_dev_device_error, int, S_IRUGO | S_IWUSR); + +#define RG_PCIE_DEV_DEVICE_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_rg_pcie_dev_device_debug) { \ + printk(KERN_INFO "[RG_PCIE_DEV_DEVICE][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RG_PCIE_DEV_DEVICE_DEBUG_ERROR(fmt, args...) do { \ + if (g_rg_pcie_dev_device_error) { \ + printk(KERN_ERR "[RG_PCIE_DEV_DEVICE][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static pci_dev_device_t pcie_dev_device_data0 = { + .pci_dev_name = "fpga0", + .pci_domain = 0x0000, + .pci_bus = 0x0a, + .pci_slot = 0x00, + .pci_fn = 0, + .pci_bar = 0, + .bus_width = 4, + .upg_ctrl_base = 0xa00, + .upg_flash_base = 0x2f0000, +}; + +static pci_dev_device_t pcie_dev_device_data1 = { + .pci_dev_name = "fpga1", + .pci_domain = 0x0000, + .pci_bus = 0x08, + .pci_slot = 0x00, + .pci_fn = 0, + .pci_bar = 0, + .bus_width = 4, + .upg_ctrl_base = 0xa00, + .upg_flash_base = 0x2f0000, +}; + +static pci_dev_device_t pcie_dev_device_data2 = { + .pci_dev_name = "fpga2", + .pci_domain = 0x0000, + .pci_bus = 0x0b, + .pci_slot = 0x00, + .pci_fn = 0, + .pci_bar = 0, + .bus_width = 4, + .upg_ctrl_base = 0xa00, + .upg_flash_base = 0x2f0000, +}; +static void rg_pcie_dev_device_release(struct device *dev) +{ + return; +} + +static struct platform_device pcie_dev_device[] = { + { + .name = "rg-pci-dev", + .id = 1, + .dev = { + .platform_data = &pcie_dev_device_data0, + .release = rg_pcie_dev_device_release, + }, + }, + { + .name = "rg-pci-dev", + .id = 2, + .dev = { + .platform_data = &pcie_dev_device_data1, + .release = rg_pcie_dev_device_release, + }, + }, + { + .name = "rg-pci-dev", + .id = 3, + .dev = { + .platform_data = &pcie_dev_device_data2, + .release = rg_pcie_dev_device_release, + }, + }, +}; + +static int __init rg_pcie_dev_device_init(void) +{ + int i; + int ret = 0; + pci_dev_device_t *pcie_dev_device_data; + + RG_PCIE_DEV_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = 0; i < ARRAY_SIZE(pcie_dev_device); i++) { + pcie_dev_device_data = pcie_dev_device[i].dev.platform_data; + ret = platform_device_register(&pcie_dev_device[i]); + if (ret < 0) { + pcie_dev_device_data->device_flag = -1; /* device register failed, set flag -1 */ + printk(KERN_ERR "rg-pci-dev.%d register failed!\n", i + 1); + } else { + pcie_dev_device_data->device_flag = 0; /* device register suucess, set flag 0 */ + } + } + return 0; +} + +static void __exit rg_pcie_dev_device_exit(void) +{ + int i; + pci_dev_device_t *pcie_dev_device_data; + + RG_PCIE_DEV_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = ARRAY_SIZE(pcie_dev_device) - 1; i >= 0; i--) { + pcie_dev_device_data = pcie_dev_device[i].dev.platform_data; + if (pcie_dev_device_data->device_flag == 0) { /* device register success, need unregister */ + platform_device_unregister(&pcie_dev_device[i]); + } + } +} + +module_init(rg_pcie_dev_device_init); +module_exit(rg_pcie_dev_device_exit); +MODULE_DESCRIPTION("RG PCIE DEV Devices"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd@ruijie.com.cn"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_wdt_device.c b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_wdt_device.c new file mode 100644 index 000000000000..4b3b1217afb0 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_wdt_device.c @@ -0,0 +1,104 @@ +#include +#include +#include +#include +#include + +#include + +static int g_rg_wdt_device_debug = 0; +static int g_rg_wdt_device_error = 0; + +module_param(g_rg_wdt_device_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_wdt_device_error, int, S_IRUGO | S_IWUSR); + +#define RG_WDT_DEVICE_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_rg_wdt_device_debug) { \ + printk(KERN_INFO "[RG_WDT_DEVICE][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RG_WDT_DEVICE_DEBUG_ERROR(fmt, args...) do { \ + if (g_rg_wdt_device_error) { \ + printk(KERN_ERR "[RG_WDT_DEVICE][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static rg_wdt_device_t rg_wdt_device_data_0 = { + .feed_wdt_type = 2, + .hw_margin = 180000, + .feed_time = 30000, + .config_dev_name = "/dev/cpld5", + .config_mode = 2, + .priv_func_mode = 4, + .enable_reg = 0x42, + .enable_val = 0x1, + .disable_val = 0x0, + .enable_mask = 0x1, + .timeout_cfg_reg = 0x43, + .hw_algo = "toggle", + .wdt_config_mode.logic_wdt = { + .feed_dev_name = "/dev/cpld5", + .feed_reg = 0x42, + .active_val = 0x1, + .logic_func_mode = 0x1, + }, + .timer_accuracy = 6000, /* 6s */ + .sysfs_index = SYSFS_NO_CFG, +}; + +static void rg_wdt_device_release(struct device *dev) +{ + return; +} + +static struct platform_device rg_wdt_device[] = { + { + .name = "rg_wdt", + .id = 0, + .dev = { + .platform_data = &rg_wdt_device_data_0, + .release = rg_wdt_device_release, + }, + }, +}; + +static int __init rg_wdt_device_init(void) +{ + int i; + int ret = 0; + rg_wdt_device_t *rg_wdt_device_data; + + RG_WDT_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = 0; i < ARRAY_SIZE(rg_wdt_device); i++) { + rg_wdt_device_data = rg_wdt_device[i].dev.platform_data; + ret = platform_device_register(&rg_wdt_device[i]); + if (ret < 0) { + rg_wdt_device_data->device_flag = -1; /* device register failed, set flag -1 */ + printk(KERN_ERR "rg-wdt.%d register failed!\n", i + 1); + } else { + rg_wdt_device_data->device_flag = 0; /* device register suucess, set flag 0 */ + } + } + return 0; +} + +static void __exit rg_wdt_device_exit(void) +{ + int i; + rg_wdt_device_t *rg_wdt_device_data; + + RG_WDT_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = ARRAY_SIZE(rg_wdt_device) - 1; i >= 0; i--) { + rg_wdt_device_data = rg_wdt_device[i].dev.platform_data; + if (rg_wdt_device_data->device_flag == 0) { /* device register success, need unregister */ + platform_device_unregister(&rg_wdt_device[i]); + } + } +} + +module_init(rg_wdt_device_init); +module_exit(rg_wdt_device_exit); +MODULE_DESCRIPTION("RG WDT Devices"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd@ruijie.com.cn"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/TCS9400-CPLD.cfg b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/TCS9400-CPLD.cfg new file mode 100755 index 000000000000..e1dbac4b94f9 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/TCS9400-CPLD.cfg @@ -0,0 +1,29 @@ +# cpld_id: 0:CPLD_A 1:CPLD_B +cpld_i2c_dev.bus_0_2=60 +cpld_i2c_dev.addr_0_2=0x3d +cpld_i2c_dev.bus_0_3=87 +cpld_i2c_dev.addr_0_3=0x0d +cpld_i2c_dev.bus_0_4=95 +cpld_i2c_dev.addr_0_4=0x0d +cpld_i2c_dev.bus_0_5=77 +cpld_i2c_dev.addr_0_5=0x1d +cpld_i2c_dev.bus_0_6=77 +cpld_i2c_dev.addr_0_6=0x2d +cpld_i2c_dev.bus_0_7=111 +cpld_i2c_dev.addr_0_7=0x3d + +# cpld_id: 0:X86_CPLD, 1:MAC_CPLDA, 2:MAC_CPLDB +cpld_lpc_dev_0_0=0x700 +cpld_lpc_dev_0_1=0x900 + +mode_cpld_0_0=lpc +mode_cpld_0_1=lpc +mode_cpld_0_2=i2c +mode_cpld_0_3=i2c +mode_cpld_0_4=i2c +mode_cpld_0_5=i2c +mode_cpld_0_6=i2c +mode_cpld_0_7=i2c + +# cpld number +dev_num_4_0=8 diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/TCS9400-FAN.cfg b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/TCS9400-FAN.cfg new file mode 100755 index 000000000000..d8134e221bc2 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/TCS9400-FAN.cfg @@ -0,0 +1,422 @@ +# fan number +dev_num_1_0=8 + +# motor number +dev_num_1_5=2 + +dev_present_status.mode_1_1=config +dev_present_status.src_1_1=cpld +dev_present_status.frmt_1_1=bit +dev_present_status.pola_1_1=negative +dev_present_status.addr_1_1=0x00030030 +dev_present_status.len_1_1=1 +dev_present_status.bit_offset_1_1=0 + +dev_present_status.mode_1_2=config +dev_present_status.src_1_2=cpld +dev_present_status.frmt_1_2=bit +dev_present_status.pola_1_2=negative +dev_present_status.addr_1_2=0x00040030 +dev_present_status.len_1_2=1 +dev_present_status.bit_offset_1_2=0 + +dev_present_status.mode_1_3=config +dev_present_status.src_1_3=cpld +dev_present_status.frmt_1_3=bit +dev_present_status.pola_1_3=negative +dev_present_status.addr_1_3=0x00030030 +dev_present_status.len_1_3=1 +dev_present_status.bit_offset_1_3=1 + +dev_present_status.mode_1_4=config +dev_present_status.src_1_4=cpld +dev_present_status.frmt_1_4=bit +dev_present_status.pola_1_4=negative +dev_present_status.addr_1_4=0x00040030 +dev_present_status.len_1_4=1 +dev_present_status.bit_offset_1_4=1 + +dev_present_status.mode_1_5=config +dev_present_status.src_1_5=cpld +dev_present_status.frmt_1_5=bit +dev_present_status.pola_1_5=negative +dev_present_status.addr_1_5=0x00030030 +dev_present_status.len_1_5=1 +dev_present_status.bit_offset_1_5=2 + +dev_present_status.mode_1_6=config +dev_present_status.src_1_6=cpld +dev_present_status.frmt_1_6=bit +dev_present_status.pola_1_6=negative +dev_present_status.addr_1_6=0x00040030 +dev_present_status.len_1_6=1 +dev_present_status.bit_offset_1_6=2 + +dev_present_status.mode_1_7=config +dev_present_status.src_1_7=cpld +dev_present_status.frmt_1_7=bit +dev_present_status.pola_1_7=negative +dev_present_status.addr_1_7=0x00030030 +dev_present_status.len_1_7=1 +dev_present_status.bit_offset_1_7=3 + +dev_present_status.mode_1_8=config +dev_present_status.src_1_8=cpld +dev_present_status.frmt_1_8=bit +dev_present_status.pola_1_8=negative +dev_present_status.addr_1_8=0x00040030 +dev_present_status.len_1_8=1 +dev_present_status.bit_offset_1_8=3 + +fan_ratio.mode_1_0=config +fan_ratio.src_1_0=cpld +fan_ratio.frmt_1_0=byte +fan_ratio.addr_1_0=0x00030014 +fan_ratio.len_1_0=1 + +fan_ratio.mode_1_1=config +fan_ratio.src_1_1=cpld +fan_ratio.frmt_1_1=byte +fan_ratio.addr_1_1=0x00030014 +fan_ratio.len_1_1=1 + +fan_ratio.mode_2_0=config +fan_ratio.src_2_0=cpld +fan_ratio.frmt_2_0=byte +fan_ratio.addr_2_0=0x00040014 +fan_ratio.len_2_0=1 + +fan_ratio.mode_2_1=config +fan_ratio.src_2_1=cpld +fan_ratio.frmt_2_1=byte +fan_ratio.addr_2_1=0x00040014 +fan_ratio.len_2_1=1 + +fan_ratio.mode_3_0=config +fan_ratio.src_3_0=cpld +fan_ratio.frmt_3_0=byte +fan_ratio.addr_3_0=0x00030015 +fan_ratio.len_3_0=1 + +fan_ratio.mode_3_1=config +fan_ratio.src_3_1=cpld +fan_ratio.frmt_3_1=byte +fan_ratio.addr_3_1=0x00030015 +fan_ratio.len_3_1=1 + +fan_ratio.mode_4_0=config +fan_ratio.src_4_0=cpld +fan_ratio.frmt_4_0=byte +fan_ratio.addr_4_0=0x00040015 +fan_ratio.len_4_0=1 + +fan_ratio.mode_4_1=config +fan_ratio.src_4_1=cpld +fan_ratio.frmt_4_1=byte +fan_ratio.addr_4_1=0x00040015 +fan_ratio.len_4_1=1 + +fan_ratio.mode_5_0=config +fan_ratio.src_5_0=cpld +fan_ratio.frmt_5_0=byte +fan_ratio.addr_5_0=0x00030016 +fan_ratio.len_5_0=1 + +fan_ratio.mode_5_1=config +fan_ratio.src_5_1=cpld +fan_ratio.frmt_5_1=byte +fan_ratio.addr_5_1=0x00030016 +fan_ratio.len_5_1=1 + +fan_ratio.mode_6_0=config +fan_ratio.src_6_0=cpld +fan_ratio.frmt_6_0=byte +fan_ratio.addr_6_0=0x00040016 +fan_ratio.len_6_0=1 + +fan_ratio.mode_6_1=config +fan_ratio.src_6_1=cpld +fan_ratio.frmt_6_1=byte +fan_ratio.addr_6_1=0x00040016 +fan_ratio.len_6_1=1 + +fan_ratio.mode_7_0=config +fan_ratio.src_7_0=cpld +fan_ratio.frmt_7_0=byte +fan_ratio.addr_7_0=0x00030017 +fan_ratio.len_7_0=1 + +fan_ratio.mode_7_1=config +fan_ratio.src_7_1=cpld +fan_ratio.frmt_7_1=byte +fan_ratio.addr_7_1=0x00030017 +fan_ratio.len_7_1=1 + +fan_ratio.mode_8_0=config +fan_ratio.src_8_0=cpld +fan_ratio.frmt_8_0=byte +fan_ratio.addr_8_0=0x00040017 +fan_ratio.len_8_0=1 + +fan_ratio.mode_8_1=config +fan_ratio.src_8_1=cpld +fan_ratio.frmt_8_1=byte +fan_ratio.addr_8_1=0x00040017 +fan_ratio.len_8_1=1 + + +fan_roll_status.mode_1_0=config +fan_roll_status.src_1_0=cpld +fan_roll_status.frmt_1_0=bit +fan_roll_status.pola_1_0=positive +fan_roll_status.addr_1_0=0x00030031 +fan_roll_status.len_1_0=1 +fan_roll_status.bit_offset_1_0=0 + +fan_roll_status.mode_1_1=config +fan_roll_status.src_1_1=cpld +fan_roll_status.frmt_1_1=bit +fan_roll_status.pola_1_1=positive +fan_roll_status.addr_1_1=0x00030034 +fan_roll_status.len_1_1=1 +fan_roll_status.bit_offset_1_1=0 + +fan_roll_status.mode_2_0=config +fan_roll_status.src_2_0=cpld +fan_roll_status.frmt_2_0=bit +fan_roll_status.pola_2_0=positive +fan_roll_status.addr_2_0=0x00040031 +fan_roll_status.len_2_0=1 +fan_roll_status.bit_offset_2_0=0 + +fan_roll_status.mode_2_1=config +fan_roll_status.src_2_1=cpld +fan_roll_status.frmt_2_1=bit +fan_roll_status.pola_2_1=positive +fan_roll_status.addr_2_1=0x00040034 +fan_roll_status.len_2_1=1 +fan_roll_status.bit_offset_2_1=0 + +fan_roll_status.mode_3_0=config +fan_roll_status.src_3_0=cpld +fan_roll_status.frmt_3_0=bit +fan_roll_status.pola_3_0=positive +fan_roll_status.addr_3_0=0x00030031 +fan_roll_status.len_3_0=1 +fan_roll_status.bit_offset_3_0=1 + +fan_roll_status.mode_3_1=config +fan_roll_status.src_3_1=cpld +fan_roll_status.frmt_3_1=bit +fan_roll_status.pola_3_1=positive +fan_roll_status.addr_3_1=0x00030034 +fan_roll_status.len_3_1=1 +fan_roll_status.bit_offset_3_1=1 + +fan_roll_status.mode_4_0=config +fan_roll_status.src_4_0=cpld +fan_roll_status.frmt_4_0=bit +fan_roll_status.pola_4_0=positive +fan_roll_status.addr_4_0=0x00040031 +fan_roll_status.len_4_0=1 +fan_roll_status.bit_offset_4_0=1 + +fan_roll_status.mode_4_1=config +fan_roll_status.src_4_1=cpld +fan_roll_status.frmt_4_1=bit +fan_roll_status.pola_4_1=positive +fan_roll_status.addr_4_1=0x00040034 +fan_roll_status.len_4_1=1 +fan_roll_status.bit_offset_4_1=1 + +fan_roll_status.mode_5_0=config +fan_roll_status.src_5_0=cpld +fan_roll_status.frmt_5_0=bit +fan_roll_status.pola_5_0=positive +fan_roll_status.addr_5_0=0x00030031 +fan_roll_status.len_5_0=1 +fan_roll_status.bit_offset_5_0=2 + +fan_roll_status.mode_5_1=config +fan_roll_status.src_5_1=cpld +fan_roll_status.frmt_5_1=bit +fan_roll_status.pola_5_1=positive +fan_roll_status.addr_5_1=0x00030034 +fan_roll_status.len_5_1=1 +fan_roll_status.bit_offset_5_1=2 + +fan_roll_status.mode_6_0=config +fan_roll_status.src_6_0=cpld +fan_roll_status.frmt_6_0=bit +fan_roll_status.pola_6_0=positive +fan_roll_status.addr_6_0=0x00040031 +fan_roll_status.len_6_0=1 +fan_roll_status.bit_offset_6_0=2 + +fan_roll_status.mode_6_1=config +fan_roll_status.src_6_1=cpld +fan_roll_status.frmt_6_1=bit +fan_roll_status.pola_6_1=positive +fan_roll_status.addr_6_1=0x00040034 +fan_roll_status.len_6_1=1 +fan_roll_status.bit_offset_6_1=2 + +fan_roll_status.mode_7_0=config +fan_roll_status.src_7_0=cpld +fan_roll_status.frmt_7_0=bit +fan_roll_status.pola_7_0=positive +fan_roll_status.addr_7_0=0x00030031 +fan_roll_status.len_7_0=1 +fan_roll_status.bit_offset_7_0=3 + +fan_roll_status.mode_7_1=config +fan_roll_status.src_7_1=cpld +fan_roll_status.frmt_7_1=bit +fan_roll_status.pola_7_1=positive +fan_roll_status.addr_7_1=0x00030034 +fan_roll_status.len_7_1=1 +fan_roll_status.bit_offset_7_1=3 + +fan_roll_status.mode_8_0=config +fan_roll_status.src_8_0=cpld +fan_roll_status.frmt_8_0=bit +fan_roll_status.pola_8_0=positive +fan_roll_status.addr_8_0=0x00040031 +fan_roll_status.len_8_0=1 +fan_roll_status.bit_offset_8_0=3 + +fan_roll_status.mode_8_1=config +fan_roll_status.src_8_1=cpld +fan_roll_status.frmt_8_1=bit +fan_roll_status.pola_8_1=positive +fan_roll_status.addr_8_1=0x00040034 +fan_roll_status.len_8_1=1 +fan_roll_status.bit_offset_8_1=3 + +fan_speed.mode_1_0=config +fan_speed.src_1_0=cpld +fan_speed.frmt_1_0=num_bytes +fan_speed.pola_1_0=negative +fan_speed.addr_1_0=0x0003001B +fan_speed.len_1_0=2 +fan_speed.bit_offset_1_0=0 + +fan_speed.mode_1_1=config +fan_speed.src_1_1=cpld +fan_speed.frmt_1_1=num_bytes +fan_speed.pola_1_1=negative +fan_speed.addr_1_1=0x00030025 +fan_speed.len_1_1=2 +fan_speed.bit_offset_1_1=0 + +fan_speed.mode_2_0=config +fan_speed.src_2_0=cpld +fan_speed.frmt_2_0=num_bytes +fan_speed.pola_2_0=negative +fan_speed.addr_2_0=0x0004001B +fan_speed.len_2_0=2 +fan_speed.bit_offset_2_0=0 + +fan_speed.mode_2_1=config +fan_speed.src_2_1=cpld +fan_speed.frmt_2_1=num_bytes +fan_speed.pola_2_1=negative +fan_speed.addr_2_1=0x00040025 +fan_speed.len_2_1=2 +fan_speed.bit_offset_2_1=0 + +fan_speed.mode_3_0=config +fan_speed.src_3_0=cpld +fan_speed.frmt_3_0=num_bytes +fan_speed.pola_3_0=negative +fan_speed.addr_3_0=0x0003001D +fan_speed.len_3_0=2 +fan_speed.bit_offset_3_0=0 + +fan_speed.mode_3_1=config +fan_speed.src_3_1=cpld +fan_speed.frmt_3_1=num_bytes +fan_speed.pola_3_1=negative +fan_speed.addr_3_1=0x00030027 +fan_speed.len_3_1=2 +fan_speed.bit_offset_3_1=0 + +fan_speed.mode_4_0=config +fan_speed.src_4_0=cpld +fan_speed.frmt_4_0=num_bytes +fan_speed.pola_4_0=negative +fan_speed.addr_4_0=0x0004001D +fan_speed.len_4_0=2 +fan_speed.bit_offset_4_0=0 + +fan_speed.mode_4_1=config +fan_speed.src_4_1=cpld +fan_speed.frmt_4_1=num_bytes +fan_speed.pola_4_1=negative +fan_speed.addr_4_1=0x00040027 +fan_speed.len_4_1=2 +fan_speed.bit_offset_4_1=0 + +fan_speed.mode_5_0=config +fan_speed.src_5_0=cpld +fan_speed.frmt_5_0=num_bytes +fan_speed.pola_5_0=negative +fan_speed.addr_5_0=0x0003001F +fan_speed.len_5_0=2 +fan_speed.bit_offset_5_0=0 + +fan_speed.mode_5_1=config +fan_speed.src_5_1=cpld +fan_speed.frmt_5_1=num_bytes +fan_speed.pola_5_1=negative +fan_speed.addr_5_1=0x00030029 +fan_speed.len_5_1=2 +fan_speed.bit_offset_5_1=0 + +fan_speed.mode_6_0=config +fan_speed.src_6_0=cpld +fan_speed.frmt_6_0=num_bytes +fan_speed.pola_6_0=negative +fan_speed.addr_6_0=0x0004001F +fan_speed.len_6_0=2 +fan_speed.bit_offset_6_0=0 + +fan_speed.mode_6_1=config +fan_speed.src_6_1=cpld +fan_speed.frmt_6_1=num_bytes +fan_speed.pola_6_1=negative +fan_speed.addr_6_1=0x00040029 +fan_speed.len_6_1=2 +fan_speed.bit_offset_6_1=0 + +fan_speed.mode_7_0=config +fan_speed.src_7_0=cpld +fan_speed.frmt_7_0=num_bytes +fan_speed.pola_7_0=negative +fan_speed.addr_7_0=0x00030021 +fan_speed.len_7_0=2 +fan_speed.bit_offset_7_0=0 + +fan_speed.mode_7_1=config +fan_speed.src_7_1=cpld +fan_speed.frmt_7_1=num_bytes +fan_speed.pola_7_1=negative +fan_speed.addr_7_1=0x0003002b +fan_speed.len_7_1=2 +fan_speed.bit_offset_7_1=0 + +fan_speed.mode_8_0=config +fan_speed.src_8_0=cpld +fan_speed.frmt_8_0=num_bytes +fan_speed.pola_8_0=negative +fan_speed.addr_8_0=0x00040021 +fan_speed.len_8_0=2 +fan_speed.bit_offset_8_0=0 + +fan_speed.mode_8_1=config +fan_speed.src_8_1=cpld +fan_speed.frmt_8_1=num_bytes +fan_speed.pola_8_1=negative +fan_speed.addr_8_1=0x0004002b +fan_speed.len_8_1=2 +fan_speed.bit_offset_8_1=0 diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/TCS9400-PSU.cfg b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/TCS9400-PSU.cfg new file mode 100755 index 000000000000..aa53cf0cfa95 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/TCS9400-PSU.cfg @@ -0,0 +1,98 @@ +# psu number +dev_num_2_0=4 + +psu_status.mode_1_0=config +psu_status.src_1_0=cpld +psu_status.frmt_1_0=bit +psu_status.pola_1_0=negative +psu_status.addr_1_0=0x00010064 +psu_status.len_1_0=1 +psu_status.bit_offset_1_0=0 + +psu_status.mode_1_1=config +psu_status.src_1_1=cpld +psu_status.frmt_1_1=bit +psu_status.pola_1_1=positive +psu_status.addr_1_1=0x00010064 +psu_status.len_1_1=1 +psu_status.bit_offset_1_1=1 + +psu_status.mode_1_2=config +psu_status.src_1_2=cpld +psu_status.frmt_1_2=bit +psu_status.pola_1_2=negative +psu_status.addr_1_2=0x00010064 +psu_status.len_1_2=1 +psu_status.bit_offset_1_2=2 + +psu_status.mode_2_0=config +psu_status.src_2_0=cpld +psu_status.frmt_2_0=bit +psu_status.pola_2_0=negative +psu_status.addr_2_0=0x00010064 +psu_status.len_2_0=1 +psu_status.bit_offset_2_0=4 + +psu_status.mode_2_1=config +psu_status.src_2_1=cpld +psu_status.frmt_2_1=bit +psu_status.pola_2_1=positive +psu_status.addr_2_1=0x00010064 +psu_status.len_2_1=1 +psu_status.bit_offset_2_1=5 + +psu_status.mode_2_2=config +psu_status.src_2_2=cpld +psu_status.frmt_2_2=bit +psu_status.pola_2_2=negative +psu_status.addr_2_2=0x00010064 +psu_status.len_2_2=1 +psu_status.bit_offset_2_2=6 + +psu_status.mode_3_0=config +psu_status.src_3_0=cpld +psu_status.frmt_3_0=bit +psu_status.pola_3_0=negative +psu_status.addr_3_0=0x00010065 +psu_status.len_3_0=1 +psu_status.bit_offset_3_0=4 + +psu_status.mode_3_1=config +psu_status.src_3_1=cpld +psu_status.frmt_3_1=bit +psu_status.pola_3_1=positive +psu_status.addr_3_1=0x00010065 +psu_status.len_3_1=1 +psu_status.bit_offset_3_1=5 + +psu_status.mode_3_2=config +psu_status.src_3_2=cpld +psu_status.frmt_3_2=bit +psu_status.pola_3_2=negative +psu_status.addr_3_2=0x00010065 +psu_status.len_3_2=1 +psu_status.bit_offset_3_2=6 + +psu_status.mode_4_0=config +psu_status.src_4_0=cpld +psu_status.frmt_4_0=bit +psu_status.pola_4_0=negative +psu_status.addr_4_0=0x00010065 +psu_status.len_4_0=1 +psu_status.bit_offset_4_0=0 + +psu_status.mode_4_1=config +psu_status.src_4_1=cpld +psu_status.frmt_4_1=bit +psu_status.pola_4_1=positive +psu_status.addr_4_1=0x00010065 +psu_status.len_4_1=1 +psu_status.bit_offset_4_1=1 + +psu_status.mode_4_2=config +psu_status.src_4_2=cpld +psu_status.frmt_4_2=bit +psu_status.pola_4_2=negative +psu_status.addr_4_2=0x00010065 +psu_status.len_4_2=1 +psu_status.bit_offset_4_2=2 \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/TCS9400-SENSOR.cfg b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/TCS9400-SENSOR.cfg new file mode 100755 index 000000000000..0b7f4dead885 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/TCS9400-SENSOR.cfg @@ -0,0 +1,188 @@ +# main board temp sensors +dev_num_0_1=0 + +# main board voltage sensors +dev_num_0_2=8 + +# in0 MAC_QSFPDD_VDD3.3V_A +hwmon_in.mode_0x0000_0x00=config +hwmon_in.int_cons_0x0000_0x00=3 +hwmon_in.src_0x0000_0x00=cpld +hwmon_in.frmt_0x0000_0x00=num_bytes +hwmon_in.addr_0x0000_0x00=0x00050030 +hwmon_in.len_0x0000_0x00=2 +hwmon_in.int_extra1_0x0000_0x00=0x00050030 +hwmon_in.int_extra2_0x0000_0x00=2000 + +hwmon_in.mode_0x0000_0x01=str_constant +hwmon_in.str_cons_0x0000_0x01=MAC_QSFPDD_VDD3.3V_A + +hwmon_in.mode_0x0000_0x02=str_constant +hwmon_in.str_cons_0x0000_0x02=cpld + +hwmon_in.mode_0x0000_0x03=str_constant +hwmon_in.str_cons_0x0000_0x03=3.600 + +hwmon_in.mode_0x0000_0x05=str_constant +hwmon_in.str_cons_0x0000_0x05=3.200 + + +# in1 MAC_QSFPDD_VDD3.3V_B +hwmon_in.mode_0x0001_0x00=config +hwmon_in.int_cons_0x0001_0x00=3 +hwmon_in.src_0x0001_0x00=cpld +hwmon_in.frmt_0x0001_0x00=num_bytes +hwmon_in.addr_0x0001_0x00=0x00050032 +hwmon_in.len_0x0001_0x00=2 +hwmon_in.int_extra1_0x0001_0x00=0x00050032 +hwmon_in.int_extra2_0x0001_0x00=2000 + +hwmon_in.mode_0x0001_0x01=str_constant +hwmon_in.str_cons_0x0001_0x01=MAC_QSFPDD_VDD3.3V_B + +hwmon_in.mode_0x0001_0x02=str_constant +hwmon_in.str_cons_0x0001_0x02=cpld + +hwmon_in.mode_0x0001_0x03=str_constant +hwmon_in.str_cons_0x0001_0x03=3.600 + +hwmon_in.mode_0x0001_0x05=str_constant +hwmon_in.str_cons_0x0001_0x05=3.200 + + +# in2 MAC_QSFPDD_VDD3.3V_C +hwmon_in.mode_0x0002_0x00=config +hwmon_in.int_cons_0x0002_0x00=3 +hwmon_in.src_0x0002_0x00=cpld +hwmon_in.frmt_0x0002_0x00=num_bytes +hwmon_in.addr_0x0002_0x00=0x00050034 +hwmon_in.len_0x0002_0x00=2 +hwmon_in.int_extra1_0x0002_0x00=0x00050034 +hwmon_in.int_extra2_0x0002_0x00=2000 + +hwmon_in.mode_0x0002_0x01=str_constant +hwmon_in.str_cons_0x0002_0x01=MAC_QSFPDD_VDD3.3V_C + +hwmon_in.mode_0x0002_0x02=str_constant +hwmon_in.str_cons_0x0002_0x02=cpld + +hwmon_in.mode_0x0002_0x03=str_constant +hwmon_in.str_cons_0x0002_0x03=3.600 + +hwmon_in.mode_0x0002_0x05=str_constant +hwmon_in.str_cons_0x0002_0x05=3.200 + + +# in3 MAC_QSFPDD_VDD3.3V_D +hwmon_in.mode_0x0003_0x00=config +hwmon_in.int_cons_0x0003_0x00=3 +hwmon_in.src_0x0003_0x00=cpld +hwmon_in.frmt_0x0003_0x00=num_bytes +hwmon_in.addr_0x0003_0x00=0x00050036 +hwmon_in.len_0x0003_0x00=2 +hwmon_in.int_extra1_0x0003_0x00=0x00050036 +hwmon_in.int_extra2_0x0003_0x00=2000 + +hwmon_in.mode_0x0003_0x01=str_constant +hwmon_in.str_cons_0x0003_0x01=MAC_QSFPDD_VDD3.3V_D + +hwmon_in.mode_0x0003_0x02=str_constant +hwmon_in.str_cons_0x0003_0x02=cpld + +hwmon_in.mode_0x0003_0x03=str_constant +hwmon_in.str_cons_0x0003_0x03=3.600 + +hwmon_in.mode_0x0003_0x05=str_constant +hwmon_in.str_cons_0x0003_0x05=3.200 + + +# in4 MAC_QSFPDD_VDD3.3V_E +hwmon_in.mode_0x0004_0x00=config +hwmon_in.int_cons_0x0004_0x00=3 +hwmon_in.src_0x0004_0x00=cpld +hwmon_in.frmt_0x0004_0x00=num_bytes +hwmon_in.addr_0x0004_0x00=0x00050038 +hwmon_in.len_0x0004_0x00=2 +hwmon_in.int_extra1_0x0004_0x00=0x00050038 +hwmon_in.int_extra2_0x0004_0x00=2000 + +hwmon_in.mode_0x0004_0x01=str_constant +hwmon_in.str_cons_0x0004_0x01=MAC_QSFPDD_VDD3.3V_E + +hwmon_in.mode_0x0004_0x02=str_constant +hwmon_in.str_cons_0x0004_0x02=cpld + +hwmon_in.mode_0x0004_0x03=str_constant +hwmon_in.str_cons_0x0004_0x03=3.600 + +hwmon_in.mode_0x0004_0x05=str_constant +hwmon_in.str_cons_0x0004_0x05=3.200 + + +# in5 MAC_QSFPDD_VDD3.3V_F +hwmon_in.mode_0x0005_0x00=config +hwmon_in.int_cons_0x0005_0x00=3 +hwmon_in.src_0x0005_0x00=cpld +hwmon_in.frmt_0x0005_0x00=num_bytes +hwmon_in.addr_0x0005_0x00=0x0005003a +hwmon_in.len_0x0005_0x00=2 +hwmon_in.int_extra1_0x0005_0x00=0x0005003a +hwmon_in.int_extra2_0x0005_0x00=2000 + +hwmon_in.mode_0x0005_0x01=str_constant +hwmon_in.str_cons_0x0005_0x01=MAC_QSFPDD_VDD3.3V_F + +hwmon_in.mode_0x0005_0x02=str_constant +hwmon_in.str_cons_0x0005_0x02=cpld + +hwmon_in.mode_0x0005_0x03=str_constant +hwmon_in.str_cons_0x0005_0x03=3.600 + +hwmon_in.mode_0x0005_0x05=str_constant +hwmon_in.str_cons_0x0005_0x05=3.200 + + +# in6 MAC_QSFPDD_VDD3.3V_G +hwmon_in.mode_0x0006_0x00=config +hwmon_in.int_cons_0x0006_0x00=3 +hwmon_in.src_0x0006_0x00=cpld +hwmon_in.frmt_0x0006_0x00=num_bytes +hwmon_in.addr_0x0006_0x00=0x0005003c +hwmon_in.len_0x0006_0x00=2 +hwmon_in.int_extra1_0x0006_0x00=0x0005003c +hwmon_in.int_extra2_0x0006_0x00=2000 + +hwmon_in.mode_0x0006_0x01=str_constant +hwmon_in.str_cons_0x0006_0x01=MAC_QSFPDD_VDD3.3V_G + +hwmon_in.mode_0x0006_0x02=str_constant +hwmon_in.str_cons_0x0006_0x02=cpld + +hwmon_in.mode_0x0006_0x03=str_constant +hwmon_in.str_cons_0x0006_0x03=3.600 + +hwmon_in.mode_0x0006_0x05=str_constant +hwmon_in.str_cons_0x0006_0x05=3.200 + + +# in7 MAC_QSFPDD_VDD3.3V_H +hwmon_in.mode_0x0007_0x00=config +hwmon_in.int_cons_0x0007_0x00=3 +hwmon_in.src_0x0007_0x00=cpld +hwmon_in.frmt_0x0007_0x00=num_bytes +hwmon_in.addr_0x0007_0x00=0x0005003e +hwmon_in.len_0x0007_0x00=2 +hwmon_in.int_extra1_0x0007_0x00=0x0005003e +hwmon_in.int_extra2_0x0007_0x00=2000 + +hwmon_in.mode_0x0007_0x01=str_constant +hwmon_in.str_cons_0x0007_0x01=MAC_QSFPDD_VDD3.3V_H + +hwmon_in.mode_0x0007_0x02=str_constant +hwmon_in.str_cons_0x0007_0x02=cpld + +hwmon_in.mode_0x0007_0x03=str_constant +hwmon_in.str_cons_0x0007_0x03=3.600 + +hwmon_in.mode_0x0007_0x05=str_constant +hwmon_in.str_cons_0x0007_0x05=3.200 \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/TCS9400-SFF.cfg b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/TCS9400-SFF.cfg new file mode 100755 index 000000000000..8bd43e161b06 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/TCS9400-SFF.cfg @@ -0,0 +1,1157 @@ +# sff number +dev_num_3_0=128 + +sff_dir_name_1 =sff1 +sff_dir_name_2 =sff2 +sff_dir_name_3 =sff3 +sff_dir_name_4 =sff4 +sff_dir_name_5 =sff5 +sff_dir_name_6 =sff6 +sff_dir_name_7 =sff7 +sff_dir_name_8 =sff8 +sff_dir_name_9 =sff9 +sff_dir_name_10 =sff10 +sff_dir_name_11 =sff11 +sff_dir_name_12 =sff12 +sff_dir_name_13 =sff13 +sff_dir_name_14 =sff14 +sff_dir_name_15 =sff15 +sff_dir_name_16 =sff16 +sff_dir_name_17 =sff17 +sff_dir_name_18 =sff18 +sff_dir_name_19 =sff19 +sff_dir_name_20 =sff20 +sff_dir_name_21 =sff21 +sff_dir_name_22 =sff22 +sff_dir_name_23 =sff23 +sff_dir_name_24 =sff24 +sff_dir_name_25 =sff25 +sff_dir_name_26 =sff26 +sff_dir_name_27 =sff27 +sff_dir_name_28 =sff28 +sff_dir_name_29 =sff29 +sff_dir_name_30 =sff30 +sff_dir_name_31 =sff31 +sff_dir_name_32 =sff32 +sff_dir_name_33 =sff33 +sff_dir_name_34 =sff34 +sff_dir_name_35 =sff35 +sff_dir_name_36 =sff36 +sff_dir_name_37 =sff37 +sff_dir_name_38 =sff38 +sff_dir_name_39 =sff39 +sff_dir_name_40 =sff40 +sff_dir_name_41 =sff41 +sff_dir_name_42 =sff42 +sff_dir_name_43 =sff43 +sff_dir_name_44 =sff44 +sff_dir_name_45 =sff45 +sff_dir_name_46 =sff46 +sff_dir_name_47 =sff47 +sff_dir_name_48 =sff48 +sff_dir_name_49 =sff49 +sff_dir_name_50 =sff50 +sff_dir_name_51 =sff51 +sff_dir_name_52 =sff52 +sff_dir_name_53 =sff53 +sff_dir_name_54 =sff54 +sff_dir_name_55 =sff55 +sff_dir_name_56 =sff56 +sff_dir_name_57 =sff57 +sff_dir_name_58 =sff58 +sff_dir_name_59 =sff59 +sff_dir_name_60 =sff60 +sff_dir_name_61 =sff61 +sff_dir_name_62 =sff62 +sff_dir_name_63 =sff63 +sff_dir_name_64 =sff64 +sff_dir_name_65 =sff65 +sff_dir_name_66 =sff66 +sff_dir_name_67 =sff67 +sff_dir_name_68 =sff68 +sff_dir_name_69 =sff69 +sff_dir_name_70 =sff70 +sff_dir_name_71 =sff71 +sff_dir_name_72 =sff72 +sff_dir_name_73 =sff73 +sff_dir_name_74 =sff74 +sff_dir_name_75 =sff75 +sff_dir_name_76 =sff76 +sff_dir_name_77 =sff77 +sff_dir_name_78 =sff78 +sff_dir_name_79 =sff79 +sff_dir_name_80 =sff80 +sff_dir_name_81 =sff81 +sff_dir_name_82 =sff82 +sff_dir_name_83 =sff83 +sff_dir_name_84 =sff84 +sff_dir_name_85 =sff85 +sff_dir_name_86 =sff86 +sff_dir_name_87 =sff87 +sff_dir_name_88 =sff88 +sff_dir_name_89 =sff89 +sff_dir_name_90 =sff90 +sff_dir_name_91 =sff91 +sff_dir_name_92 =sff92 +sff_dir_name_93 =sff93 +sff_dir_name_94 =sff94 +sff_dir_name_95 =sff95 +sff_dir_name_96 =sff96 +sff_dir_name_97 =sff97 +sff_dir_name_98 =sff98 +sff_dir_name_99 =sff99 +sff_dir_name_100 =sff100 +sff_dir_name_101 =sff101 +sff_dir_name_102 =sff102 +sff_dir_name_103 =sff103 +sff_dir_name_104 =sff104 +sff_dir_name_105 =sff105 +sff_dir_name_106 =sff106 +sff_dir_name_107 =sff107 +sff_dir_name_108 =sff108 +sff_dir_name_109 =sff109 +sff_dir_name_110 =sff110 +sff_dir_name_111 =sff111 +sff_dir_name_112 =sff112 +sff_dir_name_113 =sff113 +sff_dir_name_114 =sff114 +sff_dir_name_115 =sff115 +sff_dir_name_116 =sff116 +sff_dir_name_117 =sff117 +sff_dir_name_118 =sff118 +sff_dir_name_119 =sff119 +sff_dir_name_120 =sff120 +sff_dir_name_121 =sff121 +sff_dir_name_122 =sff122 +sff_dir_name_123 =sff123 +sff_dir_name_124 =sff124 +sff_dir_name_125 =sff125 +sff_dir_name_126 =sff126 +sff_dir_name_127 =sff127 +sff_dir_name_128 =sff128 + + +# sff present +sff_cpld_reg.mode_1_8=config +sff_cpld_reg.src_1_8=cpld +sff_cpld_reg.frmt_1_8=bit +sff_cpld_reg.pola_1_8=negative +sff_cpld_reg.addr_1_8=0x00020077 +sff_cpld_reg.len_1_8=1 +sff_cpld_reg.bit_offset_1_8=0 + +sff_cpld_reg.mode_2_8=config +sff_cpld_reg.src_2_8=cpld +sff_cpld_reg.frmt_2_8=bit +sff_cpld_reg.pola_2_8=negative +sff_cpld_reg.addr_2_8=0x00020077 +sff_cpld_reg.len_2_8=1 +sff_cpld_reg.bit_offset_2_8=1 + +sff_cpld_reg.mode_3_8=config +sff_cpld_reg.src_3_8=cpld +sff_cpld_reg.frmt_3_8=bit +sff_cpld_reg.pola_3_8=negative +sff_cpld_reg.addr_3_8=0x00020077 +sff_cpld_reg.len_3_8=1 +sff_cpld_reg.bit_offset_3_8=2 + +sff_cpld_reg.mode_4_8=config +sff_cpld_reg.src_4_8=cpld +sff_cpld_reg.frmt_4_8=bit +sff_cpld_reg.pola_4_8=negative +sff_cpld_reg.addr_4_8=0x00020077 +sff_cpld_reg.len_4_8=1 +sff_cpld_reg.bit_offset_4_8=3 + +sff_cpld_reg.mode_5_8=config +sff_cpld_reg.src_5_8=cpld +sff_cpld_reg.frmt_5_8=bit +sff_cpld_reg.pola_5_8=negative +sff_cpld_reg.addr_5_8=0x00020077 +sff_cpld_reg.len_5_8=1 +sff_cpld_reg.bit_offset_5_8=4 + +sff_cpld_reg.mode_6_8=config +sff_cpld_reg.src_6_8=cpld +sff_cpld_reg.frmt_6_8=bit +sff_cpld_reg.pola_6_8=negative +sff_cpld_reg.addr_6_8=0x00020077 +sff_cpld_reg.len_6_8=1 +sff_cpld_reg.bit_offset_6_8=5 + +sff_cpld_reg.mode_7_8=config +sff_cpld_reg.src_7_8=cpld +sff_cpld_reg.frmt_7_8=bit +sff_cpld_reg.pola_7_8=negative +sff_cpld_reg.addr_7_8=0x00020077 +sff_cpld_reg.len_7_8=1 +sff_cpld_reg.bit_offset_7_8=6 + +sff_cpld_reg.mode_8_8=config +sff_cpld_reg.src_8_8=cpld +sff_cpld_reg.frmt_8_8=bit +sff_cpld_reg.pola_8_8=negative +sff_cpld_reg.addr_8_8=0x00020077 +sff_cpld_reg.len_8_8=1 +sff_cpld_reg.bit_offset_8_8=7 + +sff_cpld_reg.mode_9_8=config +sff_cpld_reg.src_9_8=cpld +sff_cpld_reg.frmt_9_8=bit +sff_cpld_reg.pola_9_8=negative +sff_cpld_reg.addr_9_8=0x00020076 +sff_cpld_reg.len_9_8=1 +sff_cpld_reg.bit_offset_9_8=0 + +sff_cpld_reg.mode_10_8=config +sff_cpld_reg.src_10_8=cpld +sff_cpld_reg.frmt_10_8=bit +sff_cpld_reg.pola_10_8=negative +sff_cpld_reg.addr_10_8=0x00020076 +sff_cpld_reg.len_10_8=1 +sff_cpld_reg.bit_offset_10_8=1 + +sff_cpld_reg.mode_11_8=config +sff_cpld_reg.src_11_8=cpld +sff_cpld_reg.frmt_11_8=bit +sff_cpld_reg.pola_11_8=negative +sff_cpld_reg.addr_11_8=0x00020076 +sff_cpld_reg.len_11_8=1 +sff_cpld_reg.bit_offset_11_8=2 + +sff_cpld_reg.mode_12_8=config +sff_cpld_reg.src_12_8=cpld +sff_cpld_reg.frmt_12_8=bit +sff_cpld_reg.pola_12_8=negative +sff_cpld_reg.addr_12_8=0x00020076 +sff_cpld_reg.len_12_8=1 +sff_cpld_reg.bit_offset_12_8=3 + +sff_cpld_reg.mode_13_8=config +sff_cpld_reg.src_13_8=cpld +sff_cpld_reg.frmt_13_8=bit +sff_cpld_reg.pola_13_8=negative +sff_cpld_reg.addr_13_8=0x00020076 +sff_cpld_reg.len_13_8=1 +sff_cpld_reg.bit_offset_13_8=4 + +sff_cpld_reg.mode_14_8=config +sff_cpld_reg.src_14_8=cpld +sff_cpld_reg.frmt_14_8=bit +sff_cpld_reg.pola_14_8=negative +sff_cpld_reg.addr_14_8=0x00020076 +sff_cpld_reg.len_14_8=1 +sff_cpld_reg.bit_offset_14_8=5 + +sff_cpld_reg.mode_15_8=config +sff_cpld_reg.src_15_8=cpld +sff_cpld_reg.frmt_15_8=bit +sff_cpld_reg.pola_15_8=negative +sff_cpld_reg.addr_15_8=0x00020076 +sff_cpld_reg.len_15_8=1 +sff_cpld_reg.bit_offset_15_8=6 + +sff_cpld_reg.mode_16_8=config +sff_cpld_reg.src_16_8=cpld +sff_cpld_reg.frmt_16_8=bit +sff_cpld_reg.pola_16_8=negative +sff_cpld_reg.addr_16_8=0x00020076 +sff_cpld_reg.len_16_8=1 +sff_cpld_reg.bit_offset_16_8=7 + +sff_cpld_reg.mode_17_8=config +sff_cpld_reg.src_17_8=cpld +sff_cpld_reg.frmt_17_8=bit +sff_cpld_reg.pola_17_8=negative +sff_cpld_reg.addr_17_8=0x00020075 +sff_cpld_reg.len_17_8=1 +sff_cpld_reg.bit_offset_17_8=0 + +sff_cpld_reg.mode_18_8=config +sff_cpld_reg.src_18_8=cpld +sff_cpld_reg.frmt_18_8=bit +sff_cpld_reg.pola_18_8=negative +sff_cpld_reg.addr_18_8=0x00020075 +sff_cpld_reg.len_18_8=1 +sff_cpld_reg.bit_offset_18_8=1 + +sff_cpld_reg.mode_19_8=config +sff_cpld_reg.src_19_8=cpld +sff_cpld_reg.frmt_19_8=bit +sff_cpld_reg.pola_19_8=negative +sff_cpld_reg.addr_19_8=0x00020075 +sff_cpld_reg.len_19_8=1 +sff_cpld_reg.bit_offset_19_8=2 + +sff_cpld_reg.mode_20_8=config +sff_cpld_reg.src_20_8=cpld +sff_cpld_reg.frmt_20_8=bit +sff_cpld_reg.pola_20_8=negative +sff_cpld_reg.addr_20_8=0x00020075 +sff_cpld_reg.len_20_8=1 +sff_cpld_reg.bit_offset_20_8=3 + +sff_cpld_reg.mode_21_8=config +sff_cpld_reg.src_21_8=cpld +sff_cpld_reg.frmt_21_8=bit +sff_cpld_reg.pola_21_8=negative +sff_cpld_reg.addr_21_8=0x00020075 +sff_cpld_reg.len_21_8=1 +sff_cpld_reg.bit_offset_21_8=4 + +sff_cpld_reg.mode_22_8=config +sff_cpld_reg.src_22_8=cpld +sff_cpld_reg.frmt_22_8=bit +sff_cpld_reg.pola_22_8=negative +sff_cpld_reg.addr_22_8=0x00020075 +sff_cpld_reg.len_22_8=1 +sff_cpld_reg.bit_offset_22_8=5 + +sff_cpld_reg.mode_23_8=config +sff_cpld_reg.src_23_8=cpld +sff_cpld_reg.frmt_23_8=bit +sff_cpld_reg.pola_23_8=negative +sff_cpld_reg.addr_23_8=0x00020075 +sff_cpld_reg.len_23_8=1 +sff_cpld_reg.bit_offset_23_8=6 + +sff_cpld_reg.mode_24_8=config +sff_cpld_reg.src_24_8=cpld +sff_cpld_reg.frmt_24_8=bit +sff_cpld_reg.pola_24_8=negative +sff_cpld_reg.addr_24_8=0x00020075 +sff_cpld_reg.len_24_8=1 +sff_cpld_reg.bit_offset_24_8=7 + +sff_cpld_reg.mode_25_8=config +sff_cpld_reg.src_25_8=cpld +sff_cpld_reg.frmt_25_8=bit +sff_cpld_reg.pola_25_8=negative +sff_cpld_reg.addr_25_8=0x00020074 +sff_cpld_reg.len_25_8=1 +sff_cpld_reg.bit_offset_25_8=0 + +sff_cpld_reg.mode_26_8=config +sff_cpld_reg.src_26_8=cpld +sff_cpld_reg.frmt_26_8=bit +sff_cpld_reg.pola_26_8=negative +sff_cpld_reg.addr_26_8=0x00020074 +sff_cpld_reg.len_26_8=1 +sff_cpld_reg.bit_offset_26_8=1 + +sff_cpld_reg.mode_27_8=config +sff_cpld_reg.src_27_8=cpld +sff_cpld_reg.frmt_27_8=bit +sff_cpld_reg.pola_27_8=negative +sff_cpld_reg.addr_27_8=0x00020074 +sff_cpld_reg.len_27_8=1 +sff_cpld_reg.bit_offset_27_8=2 + +sff_cpld_reg.mode_28_8=config +sff_cpld_reg.src_28_8=cpld +sff_cpld_reg.frmt_28_8=bit +sff_cpld_reg.pola_28_8=negative +sff_cpld_reg.addr_28_8=0x00020074 +sff_cpld_reg.len_28_8=1 +sff_cpld_reg.bit_offset_28_8=3 + +sff_cpld_reg.mode_29_8=config +sff_cpld_reg.src_29_8=cpld +sff_cpld_reg.frmt_29_8=bit +sff_cpld_reg.pola_29_8=negative +sff_cpld_reg.addr_29_8=0x00020074 +sff_cpld_reg.len_29_8=1 +sff_cpld_reg.bit_offset_29_8=4 + +sff_cpld_reg.mode_30_8=config +sff_cpld_reg.src_30_8=cpld +sff_cpld_reg.frmt_30_8=bit +sff_cpld_reg.pola_30_8=negative +sff_cpld_reg.addr_30_8=0x00020074 +sff_cpld_reg.len_30_8=1 +sff_cpld_reg.bit_offset_30_8=5 + +sff_cpld_reg.mode_31_8=config +sff_cpld_reg.src_31_8=cpld +sff_cpld_reg.frmt_31_8=bit +sff_cpld_reg.pola_31_8=negative +sff_cpld_reg.addr_31_8=0x00020074 +sff_cpld_reg.len_31_8=1 +sff_cpld_reg.bit_offset_31_8=6 + +sff_cpld_reg.mode_32_8=config +sff_cpld_reg.src_32_8=cpld +sff_cpld_reg.frmt_32_8=bit +sff_cpld_reg.pola_32_8=negative +sff_cpld_reg.addr_32_8=0x00020074 +sff_cpld_reg.len_32_8=1 +sff_cpld_reg.bit_offset_32_8=7 + +sff_cpld_reg.mode_33_8=config +sff_cpld_reg.src_33_8=cpld +sff_cpld_reg.frmt_33_8=bit +sff_cpld_reg.pola_33_8=negative +sff_cpld_reg.addr_33_8=0x00050075 +sff_cpld_reg.len_33_8=1 +sff_cpld_reg.bit_offset_33_8=0 + +sff_cpld_reg.mode_34_8=config +sff_cpld_reg.src_34_8=cpld +sff_cpld_reg.frmt_34_8=bit +sff_cpld_reg.pola_34_8=negative +sff_cpld_reg.addr_34_8=0x00050075 +sff_cpld_reg.len_34_8=1 +sff_cpld_reg.bit_offset_34_8=1 + +sff_cpld_reg.mode_35_8=config +sff_cpld_reg.src_35_8=cpld +sff_cpld_reg.frmt_35_8=bit +sff_cpld_reg.pola_35_8=negative +sff_cpld_reg.addr_35_8=0x00050075 +sff_cpld_reg.len_35_8=1 +sff_cpld_reg.bit_offset_35_8=2 + +sff_cpld_reg.mode_36_8=config +sff_cpld_reg.src_36_8=cpld +sff_cpld_reg.frmt_36_8=bit +sff_cpld_reg.pola_36_8=negative +sff_cpld_reg.addr_36_8=0x00050075 +sff_cpld_reg.len_36_8=1 +sff_cpld_reg.bit_offset_36_8=3 + +sff_cpld_reg.mode_37_8=config +sff_cpld_reg.src_37_8=cpld +sff_cpld_reg.frmt_37_8=bit +sff_cpld_reg.pola_37_8=negative +sff_cpld_reg.addr_37_8=0x00050074 +sff_cpld_reg.len_37_8=1 +sff_cpld_reg.bit_offset_37_8=0 + +sff_cpld_reg.mode_38_8=config +sff_cpld_reg.src_38_8=cpld +sff_cpld_reg.frmt_38_8=bit +sff_cpld_reg.pola_38_8=negative +sff_cpld_reg.addr_38_8=0x00050074 +sff_cpld_reg.len_38_8=1 +sff_cpld_reg.bit_offset_38_8=1 + +sff_cpld_reg.mode_39_8=config +sff_cpld_reg.src_39_8=cpld +sff_cpld_reg.frmt_39_8=bit +sff_cpld_reg.pola_39_8=negative +sff_cpld_reg.addr_39_8=0x00050074 +sff_cpld_reg.len_39_8=1 +sff_cpld_reg.bit_offset_39_8=2 + +sff_cpld_reg.mode_40_8=config +sff_cpld_reg.src_40_8=cpld +sff_cpld_reg.frmt_40_8=bit +sff_cpld_reg.pola_40_8=negative +sff_cpld_reg.addr_40_8=0x00050074 +sff_cpld_reg.len_40_8=1 +sff_cpld_reg.bit_offset_40_8=3 + +sff_cpld_reg.mode_41_8=config +sff_cpld_reg.src_41_8=cpld +sff_cpld_reg.frmt_41_8=bit +sff_cpld_reg.pola_41_8=negative +sff_cpld_reg.addr_41_8=0x00050074 +sff_cpld_reg.len_41_8=1 +sff_cpld_reg.bit_offset_41_8=4 + +sff_cpld_reg.mode_42_8=config +sff_cpld_reg.src_42_8=cpld +sff_cpld_reg.frmt_42_8=bit +sff_cpld_reg.pola_42_8=negative +sff_cpld_reg.addr_42_8=0x00050074 +sff_cpld_reg.len_42_8=1 +sff_cpld_reg.bit_offset_42_8=5 + +sff_cpld_reg.mode_43_8=config +sff_cpld_reg.src_43_8=cpld +sff_cpld_reg.frmt_43_8=bit +sff_cpld_reg.pola_43_8=negative +sff_cpld_reg.addr_43_8=0x0006007b +sff_cpld_reg.len_43_8=1 +sff_cpld_reg.bit_offset_43_8=0 + +sff_cpld_reg.mode_44_8=config +sff_cpld_reg.src_44_8=cpld +sff_cpld_reg.frmt_44_8=bit +sff_cpld_reg.pola_44_8=negative +sff_cpld_reg.addr_44_8=0x0006007b +sff_cpld_reg.len_44_8=1 +sff_cpld_reg.bit_offset_44_8=1 + +sff_cpld_reg.mode_45_8=config +sff_cpld_reg.src_45_8=cpld +sff_cpld_reg.frmt_45_8=bit +sff_cpld_reg.pola_45_8=negative +sff_cpld_reg.addr_45_8=0x0006007b +sff_cpld_reg.len_45_8=1 +sff_cpld_reg.bit_offset_45_8=2 + +sff_cpld_reg.mode_46_8=config +sff_cpld_reg.src_46_8=cpld +sff_cpld_reg.frmt_46_8=bit +sff_cpld_reg.pola_46_8=negative +sff_cpld_reg.addr_46_8=0x0006007b +sff_cpld_reg.len_46_8=1 +sff_cpld_reg.bit_offset_46_8=3 + +sff_cpld_reg.mode_47_8=config +sff_cpld_reg.src_47_8=cpld +sff_cpld_reg.frmt_47_8=bit +sff_cpld_reg.pola_47_8=negative +sff_cpld_reg.addr_47_8=0x0006007b +sff_cpld_reg.len_47_8=1 +sff_cpld_reg.bit_offset_47_8=4 + +sff_cpld_reg.mode_48_8=config +sff_cpld_reg.src_48_8=cpld +sff_cpld_reg.frmt_48_8=bit +sff_cpld_reg.pola_48_8=negative +sff_cpld_reg.addr_48_8=0x0006007b +sff_cpld_reg.len_48_8=1 +sff_cpld_reg.bit_offset_48_8=5 + +sff_cpld_reg.mode_49_8=config +sff_cpld_reg.src_49_8=cpld +sff_cpld_reg.frmt_49_8=bit +sff_cpld_reg.pola_49_8=negative +sff_cpld_reg.addr_49_8=0x0006007a +sff_cpld_reg.len_49_8=1 +sff_cpld_reg.bit_offset_49_8=0 + +sff_cpld_reg.mode_50_8=config +sff_cpld_reg.src_50_8=cpld +sff_cpld_reg.frmt_50_8=bit +sff_cpld_reg.pola_50_8=negative +sff_cpld_reg.addr_50_8=0x0006007a +sff_cpld_reg.len_50_8=1 +sff_cpld_reg.bit_offset_50_8=1 + +sff_cpld_reg.mode_51_8=config +sff_cpld_reg.src_51_8=cpld +sff_cpld_reg.frmt_51_8=bit +sff_cpld_reg.pola_51_8=negative +sff_cpld_reg.addr_51_8=0x0006007a +sff_cpld_reg.len_51_8=1 +sff_cpld_reg.bit_offset_51_8=2 + +sff_cpld_reg.mode_52_8=config +sff_cpld_reg.src_52_8=cpld +sff_cpld_reg.frmt_52_8=bit +sff_cpld_reg.pola_52_8=negative +sff_cpld_reg.addr_52_8=0x0006007a +sff_cpld_reg.len_52_8=1 +sff_cpld_reg.bit_offset_52_8=3 + +sff_cpld_reg.mode_53_8=config +sff_cpld_reg.src_53_8=cpld +sff_cpld_reg.frmt_53_8=bit +sff_cpld_reg.pola_53_8=negative +sff_cpld_reg.addr_53_8=0x0006007a +sff_cpld_reg.len_53_8=1 +sff_cpld_reg.bit_offset_53_8=4 + +sff_cpld_reg.mode_54_8=config +sff_cpld_reg.src_54_8=cpld +sff_cpld_reg.frmt_54_8=bit +sff_cpld_reg.pola_54_8=negative +sff_cpld_reg.addr_54_8=0x0006007a +sff_cpld_reg.len_54_8=1 +sff_cpld_reg.bit_offset_54_8=5 + +sff_cpld_reg.mode_55_8=config +sff_cpld_reg.src_55_8=cpld +sff_cpld_reg.frmt_55_8=bit +sff_cpld_reg.pola_55_8=negative +sff_cpld_reg.addr_55_8=0x0006007a +sff_cpld_reg.len_55_8=1 +sff_cpld_reg.bit_offset_55_8=6 + +sff_cpld_reg.mode_56_8=config +sff_cpld_reg.src_56_8=cpld +sff_cpld_reg.frmt_56_8=bit +sff_cpld_reg.pola_56_8=negative +sff_cpld_reg.addr_56_8=0x0006007a +sff_cpld_reg.len_56_8=1 +sff_cpld_reg.bit_offset_56_8=7 + +sff_cpld_reg.mode_57_8=config +sff_cpld_reg.src_57_8=cpld +sff_cpld_reg.frmt_57_8=bit +sff_cpld_reg.pola_57_8=negative +sff_cpld_reg.addr_57_8=0x00060079 +sff_cpld_reg.len_57_8=1 +sff_cpld_reg.bit_offset_57_8=0 + +sff_cpld_reg.mode_58_8=config +sff_cpld_reg.src_58_8=cpld +sff_cpld_reg.frmt_58_8=bit +sff_cpld_reg.pola_58_8=negative +sff_cpld_reg.addr_58_8=0x00060079 +sff_cpld_reg.len_58_8=1 +sff_cpld_reg.bit_offset_58_8=1 + +sff_cpld_reg.mode_59_8=config +sff_cpld_reg.src_59_8=cpld +sff_cpld_reg.frmt_59_8=bit +sff_cpld_reg.pola_59_8=negative +sff_cpld_reg.addr_59_8=0x00060079 +sff_cpld_reg.len_59_8=1 +sff_cpld_reg.bit_offset_59_8=2 + +sff_cpld_reg.mode_60_8=config +sff_cpld_reg.src_60_8=cpld +sff_cpld_reg.frmt_60_8=bit +sff_cpld_reg.pola_60_8=negative +sff_cpld_reg.addr_60_8=0x00060079 +sff_cpld_reg.len_60_8=1 +sff_cpld_reg.bit_offset_60_8=3 + +sff_cpld_reg.mode_61_8=config +sff_cpld_reg.src_61_8=cpld +sff_cpld_reg.frmt_61_8=bit +sff_cpld_reg.pola_61_8=negative +sff_cpld_reg.addr_61_8=0x00060079 +sff_cpld_reg.len_61_8=1 +sff_cpld_reg.bit_offset_61_8=4 + +sff_cpld_reg.mode_62_8=config +sff_cpld_reg.src_62_8=cpld +sff_cpld_reg.frmt_62_8=bit +sff_cpld_reg.pola_62_8=negative +sff_cpld_reg.addr_62_8=0x00060079 +sff_cpld_reg.len_62_8=1 +sff_cpld_reg.bit_offset_62_8=5 + +sff_cpld_reg.mode_63_8=config +sff_cpld_reg.src_63_8=cpld +sff_cpld_reg.frmt_63_8=bit +sff_cpld_reg.pola_63_8=negative +sff_cpld_reg.addr_63_8=0x00060079 +sff_cpld_reg.len_63_8=1 +sff_cpld_reg.bit_offset_63_8=6 + +sff_cpld_reg.mode_64_8=config +sff_cpld_reg.src_64_8=cpld +sff_cpld_reg.frmt_64_8=bit +sff_cpld_reg.pola_64_8=negative +sff_cpld_reg.addr_64_8=0x00060079 +sff_cpld_reg.len_64_8=1 +sff_cpld_reg.bit_offset_64_8=7 + +sff_cpld_reg.mode_65_8=config +sff_cpld_reg.src_65_8=cpld +sff_cpld_reg.frmt_65_8=bit +sff_cpld_reg.pola_65_8=negative +sff_cpld_reg.addr_65_8=0x00050074 +sff_cpld_reg.len_65_8=1 +sff_cpld_reg.bit_offset_65_8=6 + +sff_cpld_reg.mode_66_8=config +sff_cpld_reg.src_66_8=cpld +sff_cpld_reg.frmt_66_8=bit +sff_cpld_reg.pola_66_8=negative +sff_cpld_reg.addr_66_8=0x00050074 +sff_cpld_reg.len_66_8=1 +sff_cpld_reg.bit_offset_66_8=7 + +sff_cpld_reg.mode_67_8=config +sff_cpld_reg.src_67_8=cpld +sff_cpld_reg.frmt_67_8=bit +sff_cpld_reg.pola_67_8=negative +sff_cpld_reg.addr_67_8=0x00050073 +sff_cpld_reg.len_67_8=1 +sff_cpld_reg.bit_offset_67_8=0 + +sff_cpld_reg.mode_68_8=config +sff_cpld_reg.src_68_8=cpld +sff_cpld_reg.frmt_68_8=bit +sff_cpld_reg.pola_68_8=negative +sff_cpld_reg.addr_68_8=0x00050073 +sff_cpld_reg.len_68_8=1 +sff_cpld_reg.bit_offset_68_8=1 + +sff_cpld_reg.mode_69_8=config +sff_cpld_reg.src_69_8=cpld +sff_cpld_reg.frmt_69_8=bit +sff_cpld_reg.pola_69_8=negative +sff_cpld_reg.addr_69_8=0x00050073 +sff_cpld_reg.len_69_8=1 +sff_cpld_reg.bit_offset_69_8=2 + +sff_cpld_reg.mode_70_8=config +sff_cpld_reg.src_70_8=cpld +sff_cpld_reg.frmt_70_8=bit +sff_cpld_reg.pola_70_8=negative +sff_cpld_reg.addr_70_8=0x00050073 +sff_cpld_reg.len_70_8=1 +sff_cpld_reg.bit_offset_70_8=3 + +sff_cpld_reg.mode_71_8=config +sff_cpld_reg.src_71_8=cpld +sff_cpld_reg.frmt_71_8=bit +sff_cpld_reg.pola_71_8=negative +sff_cpld_reg.addr_71_8=0x00050073 +sff_cpld_reg.len_71_8=1 +sff_cpld_reg.bit_offset_71_8=4 + +sff_cpld_reg.mode_72_8=config +sff_cpld_reg.src_72_8=cpld +sff_cpld_reg.frmt_72_8=bit +sff_cpld_reg.pola_72_8=negative +sff_cpld_reg.addr_72_8=0x00050073 +sff_cpld_reg.len_72_8=1 +sff_cpld_reg.bit_offset_72_8=5 + +sff_cpld_reg.mode_73_8=config +sff_cpld_reg.src_73_8=cpld +sff_cpld_reg.frmt_73_8=bit +sff_cpld_reg.pola_73_8=negative +sff_cpld_reg.addr_73_8=0x00050073 +sff_cpld_reg.len_73_8=1 +sff_cpld_reg.bit_offset_73_8=6 + +sff_cpld_reg.mode_74_8=config +sff_cpld_reg.src_74_8=cpld +sff_cpld_reg.frmt_74_8=bit +sff_cpld_reg.pola_74_8=negative +sff_cpld_reg.addr_74_8=0x00050073 +sff_cpld_reg.len_74_8=1 +sff_cpld_reg.bit_offset_74_8=7 + +sff_cpld_reg.mode_75_8=config +sff_cpld_reg.src_75_8=cpld +sff_cpld_reg.frmt_75_8=bit +sff_cpld_reg.pola_75_8=negative +sff_cpld_reg.addr_75_8=0x00060078 +sff_cpld_reg.len_75_8=1 +sff_cpld_reg.bit_offset_75_8=0 + +sff_cpld_reg.mode_76_8=config +sff_cpld_reg.src_76_8=cpld +sff_cpld_reg.frmt_76_8=bit +sff_cpld_reg.pola_76_8=negative +sff_cpld_reg.addr_76_8=0x00060078 +sff_cpld_reg.len_76_8=1 +sff_cpld_reg.bit_offset_76_8=1 + +sff_cpld_reg.mode_77_8=config +sff_cpld_reg.src_77_8=cpld +sff_cpld_reg.frmt_77_8=bit +sff_cpld_reg.pola_77_8=negative +sff_cpld_reg.addr_77_8=0x00060078 +sff_cpld_reg.len_77_8=1 +sff_cpld_reg.bit_offset_77_8=2 + +sff_cpld_reg.mode_78_8=config +sff_cpld_reg.src_78_8=cpld +sff_cpld_reg.frmt_78_8=bit +sff_cpld_reg.pola_78_8=negative +sff_cpld_reg.addr_78_8=0x00060078 +sff_cpld_reg.len_78_8=1 +sff_cpld_reg.bit_offset_78_8=3 + +sff_cpld_reg.mode_79_8=config +sff_cpld_reg.src_79_8=cpld +sff_cpld_reg.frmt_79_8=bit +sff_cpld_reg.pola_79_8=negative +sff_cpld_reg.addr_79_8=0x00060078 +sff_cpld_reg.len_79_8=1 +sff_cpld_reg.bit_offset_79_8=4 + +sff_cpld_reg.mode_80_8=config +sff_cpld_reg.src_80_8=cpld +sff_cpld_reg.frmt_80_8=bit +sff_cpld_reg.pola_80_8=negative +sff_cpld_reg.addr_80_8=0x00060078 +sff_cpld_reg.len_80_8=1 +sff_cpld_reg.bit_offset_80_8=5 + +sff_cpld_reg.mode_81_8=config +sff_cpld_reg.src_81_8=cpld +sff_cpld_reg.frmt_81_8=bit +sff_cpld_reg.pola_81_8=negative +sff_cpld_reg.addr_81_8=0x00060077 +sff_cpld_reg.len_81_8=1 +sff_cpld_reg.bit_offset_81_8=0 + +sff_cpld_reg.mode_82_8=config +sff_cpld_reg.src_82_8=cpld +sff_cpld_reg.frmt_82_8=bit +sff_cpld_reg.pola_82_8=negative +sff_cpld_reg.addr_82_8=0x00060077 +sff_cpld_reg.len_82_8=1 +sff_cpld_reg.bit_offset_82_8=1 + +sff_cpld_reg.mode_83_8=config +sff_cpld_reg.src_83_8=cpld +sff_cpld_reg.frmt_83_8=bit +sff_cpld_reg.pola_83_8=negative +sff_cpld_reg.addr_83_8=0x00060077 +sff_cpld_reg.len_83_8=1 +sff_cpld_reg.bit_offset_83_8=2 + +sff_cpld_reg.mode_84_8=config +sff_cpld_reg.src_84_8=cpld +sff_cpld_reg.frmt_84_8=bit +sff_cpld_reg.pola_84_8=negative +sff_cpld_reg.addr_84_8=0x00060077 +sff_cpld_reg.len_84_8=1 +sff_cpld_reg.bit_offset_84_8=3 + +sff_cpld_reg.mode_85_8=config +sff_cpld_reg.src_85_8=cpld +sff_cpld_reg.frmt_85_8=bit +sff_cpld_reg.pola_85_8=negative +sff_cpld_reg.addr_85_8=0x00060077 +sff_cpld_reg.len_85_8=1 +sff_cpld_reg.bit_offset_85_8=4 + +sff_cpld_reg.mode_86_8=config +sff_cpld_reg.src_86_8=cpld +sff_cpld_reg.frmt_86_8=bit +sff_cpld_reg.pola_86_8=negative +sff_cpld_reg.addr_86_8=0x00060077 +sff_cpld_reg.len_86_8=1 +sff_cpld_reg.bit_offset_86_8=5 + +sff_cpld_reg.mode_87_8=config +sff_cpld_reg.src_87_8=cpld +sff_cpld_reg.frmt_87_8=bit +sff_cpld_reg.pola_87_8=negative +sff_cpld_reg.addr_87_8=0x00060077 +sff_cpld_reg.len_87_8=1 +sff_cpld_reg.bit_offset_87_8=6 + +sff_cpld_reg.mode_88_8=config +sff_cpld_reg.src_88_8=cpld +sff_cpld_reg.frmt_88_8=bit +sff_cpld_reg.pola_88_8=negative +sff_cpld_reg.addr_88_8=0x00060077 +sff_cpld_reg.len_88_8=1 +sff_cpld_reg.bit_offset_88_8=7 + +sff_cpld_reg.mode_89_8=config +sff_cpld_reg.src_89_8=cpld +sff_cpld_reg.frmt_89_8=bit +sff_cpld_reg.pola_89_8=negative +sff_cpld_reg.addr_89_8=0x00060076 +sff_cpld_reg.len_89_8=1 +sff_cpld_reg.bit_offset_89_8=0 + +sff_cpld_reg.mode_90_8=config +sff_cpld_reg.src_90_8=cpld +sff_cpld_reg.frmt_90_8=bit +sff_cpld_reg.pola_90_8=negative +sff_cpld_reg.addr_90_8=0x00060076 +sff_cpld_reg.len_90_8=1 +sff_cpld_reg.bit_offset_90_8=1 + +sff_cpld_reg.mode_91_8=config +sff_cpld_reg.src_91_8=cpld +sff_cpld_reg.frmt_91_8=bit +sff_cpld_reg.pola_91_8=negative +sff_cpld_reg.addr_91_8=0x00060076 +sff_cpld_reg.len_91_8=1 +sff_cpld_reg.bit_offset_91_8=2 + +sff_cpld_reg.mode_92_8=config +sff_cpld_reg.src_92_8=cpld +sff_cpld_reg.frmt_92_8=bit +sff_cpld_reg.pola_92_8=negative +sff_cpld_reg.addr_92_8=0x00060076 +sff_cpld_reg.len_92_8=1 +sff_cpld_reg.bit_offset_92_8=3 + +sff_cpld_reg.mode_93_8=config +sff_cpld_reg.src_93_8=cpld +sff_cpld_reg.frmt_93_8=bit +sff_cpld_reg.pola_93_8=negative +sff_cpld_reg.addr_93_8=0x00060076 +sff_cpld_reg.len_93_8=1 +sff_cpld_reg.bit_offset_93_8=4 + +sff_cpld_reg.mode_94_8=config +sff_cpld_reg.src_94_8=cpld +sff_cpld_reg.frmt_94_8=bit +sff_cpld_reg.pola_94_8=negative +sff_cpld_reg.addr_94_8=0x00060076 +sff_cpld_reg.len_94_8=1 +sff_cpld_reg.bit_offset_94_8=5 + +sff_cpld_reg.mode_95_8=config +sff_cpld_reg.src_95_8=cpld +sff_cpld_reg.frmt_95_8=bit +sff_cpld_reg.pola_95_8=negative +sff_cpld_reg.addr_95_8=0x00060076 +sff_cpld_reg.len_95_8=1 +sff_cpld_reg.bit_offset_95_8=6 + +sff_cpld_reg.mode_96_8=config +sff_cpld_reg.src_96_8=cpld +sff_cpld_reg.frmt_96_8=bit +sff_cpld_reg.pola_96_8=negative +sff_cpld_reg.addr_96_8=0x00060076 +sff_cpld_reg.len_96_8=1 +sff_cpld_reg.bit_offset_96_8=7 + +sff_cpld_reg.mode_97_8=config +sff_cpld_reg.src_97_8=cpld +sff_cpld_reg.frmt_97_8=bit +sff_cpld_reg.pola_97_8=negative +sff_cpld_reg.addr_97_8=0x00070077 +sff_cpld_reg.len_97_8=1 +sff_cpld_reg.bit_offset_97_8=0 + +sff_cpld_reg.mode_98_8=config +sff_cpld_reg.src_98_8=cpld +sff_cpld_reg.frmt_98_8=bit +sff_cpld_reg.pola_98_8=negative +sff_cpld_reg.addr_98_8=0x00070077 +sff_cpld_reg.len_98_8=1 +sff_cpld_reg.bit_offset_98_8=1 + +sff_cpld_reg.mode_99_8=config +sff_cpld_reg.src_99_8=cpld +sff_cpld_reg.frmt_99_8=bit +sff_cpld_reg.pola_99_8=negative +sff_cpld_reg.addr_99_8=0x00070077 +sff_cpld_reg.len_99_8=1 +sff_cpld_reg.bit_offset_99_8=2 + +sff_cpld_reg.mode_100_8=config +sff_cpld_reg.src_100_8=cpld +sff_cpld_reg.frmt_100_8=bit +sff_cpld_reg.pola_100_8=negative +sff_cpld_reg.addr_100_8=0x00070077 +sff_cpld_reg.len_100_8=1 +sff_cpld_reg.bit_offset_100_8=3 + +sff_cpld_reg.mode_101_8=config +sff_cpld_reg.src_101_8=cpld +sff_cpld_reg.frmt_101_8=bit +sff_cpld_reg.pola_101_8=negative +sff_cpld_reg.addr_101_8=0x00070077 +sff_cpld_reg.len_101_8=1 +sff_cpld_reg.bit_offset_101_8=4 + +sff_cpld_reg.mode_102_8=config +sff_cpld_reg.src_102_8=cpld +sff_cpld_reg.frmt_102_8=bit +sff_cpld_reg.pola_102_8=negative +sff_cpld_reg.addr_102_8=0x00070077 +sff_cpld_reg.len_102_8=1 +sff_cpld_reg.bit_offset_102_8=5 + +sff_cpld_reg.mode_103_8=config +sff_cpld_reg.src_103_8=cpld +sff_cpld_reg.frmt_103_8=bit +sff_cpld_reg.pola_103_8=negative +sff_cpld_reg.addr_103_8=0x00070077 +sff_cpld_reg.len_103_8=1 +sff_cpld_reg.bit_offset_103_8=6 + +sff_cpld_reg.mode_104_8=config +sff_cpld_reg.src_104_8=cpld +sff_cpld_reg.frmt_104_8=bit +sff_cpld_reg.pola_104_8=negative +sff_cpld_reg.addr_104_8=0x00070077 +sff_cpld_reg.len_104_8=1 +sff_cpld_reg.bit_offset_104_8=7 + +sff_cpld_reg.mode_105_8=config +sff_cpld_reg.src_105_8=cpld +sff_cpld_reg.frmt_105_8=bit +sff_cpld_reg.pola_105_8=negative +sff_cpld_reg.addr_105_8=0x00070076 +sff_cpld_reg.len_105_8=1 +sff_cpld_reg.bit_offset_105_8=0 + +sff_cpld_reg.mode_106_8=config +sff_cpld_reg.src_106_8=cpld +sff_cpld_reg.frmt_106_8=bit +sff_cpld_reg.pola_106_8=negative +sff_cpld_reg.addr_106_8=0x00070076 +sff_cpld_reg.len_106_8=1 +sff_cpld_reg.bit_offset_106_8=1 + +sff_cpld_reg.mode_107_8=config +sff_cpld_reg.src_107_8=cpld +sff_cpld_reg.frmt_107_8=bit +sff_cpld_reg.pola_107_8=negative +sff_cpld_reg.addr_107_8=0x00070076 +sff_cpld_reg.len_107_8=1 +sff_cpld_reg.bit_offset_107_8=2 + +sff_cpld_reg.mode_108_8=config +sff_cpld_reg.src_108_8=cpld +sff_cpld_reg.frmt_108_8=bit +sff_cpld_reg.pola_108_8=negative +sff_cpld_reg.addr_108_8=0x00070076 +sff_cpld_reg.len_108_8=1 +sff_cpld_reg.bit_offset_108_8=3 + +sff_cpld_reg.mode_109_8=config +sff_cpld_reg.src_109_8=cpld +sff_cpld_reg.frmt_109_8=bit +sff_cpld_reg.pola_109_8=negative +sff_cpld_reg.addr_109_8=0x00070076 +sff_cpld_reg.len_109_8=1 +sff_cpld_reg.bit_offset_109_8=4 + +sff_cpld_reg.mode_110_8=config +sff_cpld_reg.src_110_8=cpld +sff_cpld_reg.frmt_110_8=bit +sff_cpld_reg.pola_110_8=negative +sff_cpld_reg.addr_110_8=0x00070076 +sff_cpld_reg.len_110_8=1 +sff_cpld_reg.bit_offset_110_8=5 + +sff_cpld_reg.mode_111_8=config +sff_cpld_reg.src_111_8=cpld +sff_cpld_reg.frmt_111_8=bit +sff_cpld_reg.pola_111_8=negative +sff_cpld_reg.addr_111_8=0x00070076 +sff_cpld_reg.len_111_8=1 +sff_cpld_reg.bit_offset_111_8=6 + +sff_cpld_reg.mode_112_8=config +sff_cpld_reg.src_112_8=cpld +sff_cpld_reg.frmt_112_8=bit +sff_cpld_reg.pola_112_8=negative +sff_cpld_reg.addr_112_8=0x00070076 +sff_cpld_reg.len_112_8=1 +sff_cpld_reg.bit_offset_112_8=7 + +sff_cpld_reg.mode_113_8=config +sff_cpld_reg.src_113_8=cpld +sff_cpld_reg.frmt_113_8=bit +sff_cpld_reg.pola_113_8=negative +sff_cpld_reg.addr_113_8=0x00070075 +sff_cpld_reg.len_113_8=1 +sff_cpld_reg.bit_offset_113_8=0 + +sff_cpld_reg.mode_114_8=config +sff_cpld_reg.src_114_8=cpld +sff_cpld_reg.frmt_114_8=bit +sff_cpld_reg.pola_114_8=negative +sff_cpld_reg.addr_114_8=0x00070075 +sff_cpld_reg.len_114_8=1 +sff_cpld_reg.bit_offset_114_8=1 + +sff_cpld_reg.mode_115_8=config +sff_cpld_reg.src_115_8=cpld +sff_cpld_reg.frmt_115_8=bit +sff_cpld_reg.pola_115_8=negative +sff_cpld_reg.addr_115_8=0x00070075 +sff_cpld_reg.len_115_8=1 +sff_cpld_reg.bit_offset_115_8=2 + +sff_cpld_reg.mode_116_8=config +sff_cpld_reg.src_116_8=cpld +sff_cpld_reg.frmt_116_8=bit +sff_cpld_reg.pola_116_8=negative +sff_cpld_reg.addr_116_8=0x00070075 +sff_cpld_reg.len_116_8=1 +sff_cpld_reg.bit_offset_116_8=3 + +sff_cpld_reg.mode_117_8=config +sff_cpld_reg.src_117_8=cpld +sff_cpld_reg.frmt_117_8=bit +sff_cpld_reg.pola_117_8=negative +sff_cpld_reg.addr_117_8=0x00070075 +sff_cpld_reg.len_117_8=1 +sff_cpld_reg.bit_offset_117_8=4 + +sff_cpld_reg.mode_118_8=config +sff_cpld_reg.src_118_8=cpld +sff_cpld_reg.frmt_118_8=bit +sff_cpld_reg.pola_118_8=negative +sff_cpld_reg.addr_118_8=0x00070075 +sff_cpld_reg.len_118_8=1 +sff_cpld_reg.bit_offset_118_8=5 + +sff_cpld_reg.mode_119_8=config +sff_cpld_reg.src_119_8=cpld +sff_cpld_reg.frmt_119_8=bit +sff_cpld_reg.pola_119_8=negative +sff_cpld_reg.addr_119_8=0x00070075 +sff_cpld_reg.len_119_8=1 +sff_cpld_reg.bit_offset_119_8=6 + +sff_cpld_reg.mode_120_8=config +sff_cpld_reg.src_120_8=cpld +sff_cpld_reg.frmt_120_8=bit +sff_cpld_reg.pola_120_8=negative +sff_cpld_reg.addr_120_8=0x00070075 +sff_cpld_reg.len_120_8=1 +sff_cpld_reg.bit_offset_120_8=7 + +sff_cpld_reg.mode_121_8=config +sff_cpld_reg.src_121_8=cpld +sff_cpld_reg.frmt_121_8=bit +sff_cpld_reg.pola_121_8=negative +sff_cpld_reg.addr_121_8=0x00070074 +sff_cpld_reg.len_121_8=1 +sff_cpld_reg.bit_offset_121_8=0 + +sff_cpld_reg.mode_122_8=config +sff_cpld_reg.src_122_8=cpld +sff_cpld_reg.frmt_122_8=bit +sff_cpld_reg.pola_122_8=negative +sff_cpld_reg.addr_122_8=0x00070074 +sff_cpld_reg.len_122_8=1 +sff_cpld_reg.bit_offset_122_8=1 + +sff_cpld_reg.mode_123_8=config +sff_cpld_reg.src_123_8=cpld +sff_cpld_reg.frmt_123_8=bit +sff_cpld_reg.pola_123_8=negative +sff_cpld_reg.addr_123_8=0x00070074 +sff_cpld_reg.len_123_8=1 +sff_cpld_reg.bit_offset_123_8=2 + +sff_cpld_reg.mode_124_8=config +sff_cpld_reg.src_124_8=cpld +sff_cpld_reg.frmt_124_8=bit +sff_cpld_reg.pola_124_8=negative +sff_cpld_reg.addr_124_8=0x00070074 +sff_cpld_reg.len_124_8=1 +sff_cpld_reg.bit_offset_124_8=3 + +sff_cpld_reg.mode_125_8=config +sff_cpld_reg.src_125_8=cpld +sff_cpld_reg.frmt_125_8=bit +sff_cpld_reg.pola_125_8=negative +sff_cpld_reg.addr_125_8=0x00070074 +sff_cpld_reg.len_125_8=1 +sff_cpld_reg.bit_offset_125_8=4 + +sff_cpld_reg.mode_126_8=config +sff_cpld_reg.src_126_8=cpld +sff_cpld_reg.frmt_126_8=bit +sff_cpld_reg.pola_126_8=negative +sff_cpld_reg.addr_126_8=0x00070074 +sff_cpld_reg.len_126_8=1 +sff_cpld_reg.bit_offset_126_8=5 + +sff_cpld_reg.mode_127_8=config +sff_cpld_reg.src_127_8=cpld +sff_cpld_reg.frmt_127_8=bit +sff_cpld_reg.pola_127_8=negative +sff_cpld_reg.addr_127_8=0x00070074 +sff_cpld_reg.len_127_8=1 +sff_cpld_reg.bit_offset_127_8=6 + +sff_cpld_reg.mode_128_8=config +sff_cpld_reg.src_128_8=cpld +sff_cpld_reg.frmt_128_8=bit +sff_cpld_reg.pola_128_8=negative +sff_cpld_reg.addr_128_8=0x00070074 +sff_cpld_reg.len_128_8=1 +sff_cpld_reg.bit_offset_128_8=7 \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/cfg_file_name b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/cfg_file_name new file mode 100755 index 000000000000..5f694169a546 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/cfg_file_name @@ -0,0 +1,5 @@ +TCS9400-CPLD +TCS9400-FAN +TCS9400-PSU +TCS9400-SFF +TCS9400-SENSOR \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/s3ip_config/customer_sysfs.json b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/s3ip_config/customer_sysfs.json new file mode 100755 index 000000000000..cc02b9e68b50 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/s3ip_config/customer_sysfs.json @@ -0,0 +1,70 @@ +{ + "s3ip_syfs_paths": [ + { + "path": "/sys_switch/temp_sensor", + "type" : "path", + "value" : "/sys/s3ip/temp_sensor", + "description": "temperature sensor information" + }, + { + "path": "/sys_switch/vol_sensor", + "type" : "path", + "value" : "/sys/s3ip/vol_sensor", + "description": "voltage sensor information" + }, + { + "path": "/sys_switch/curr_sensor", + "type" : "path", + "value" : "/sys/s3ip/curr_sensor", + "description": "current sensor information" + }, + { + "path": "/sys_switch/syseeprom", + "type" : "path", + "value" : "/sys/s3ip/syseeprom", + "description": "ONIE EEPROM" + }, + { + "path": "/sys_switch/fan", + "type" : "path", + "value" : "/sys/s3ip/fan", + "description": "fan information" + }, + { + "path": "/sys_switch/psu", + "type" : "path", + "value" : "/sys/s3ip/psu", + "description": "psu information" + }, + { + "path": "/sys_switch/transceiver", + "type" : "path", + "value" : "/sys/s3ip/transceiver", + "description": "transceiver information" + }, + { + "path": "/sys_switch/sysled", + "type" : "path", + "value" : "/sys/s3ip/sysled", + "description": "sysled information" + }, + { + "path": "/sys_switch/fpga", + "type" : "path", + "value" : "/sys/s3ip/fpga", + "description": "FPGA information" + }, + { + "path": "/sys_switch/cpld", + "type" : "path", + "value" : "/sys/s3ip/cpld", + "description": "CPLD information" + }, + { + "path": "/sys_switch/watchdog", + "type" : "path", + "value" : "/sys/s3ip/watchdog", + "description": "watchdog information" + } + ] +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/setup.py b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/setup.py new file mode 100755 index 000000000000..74fa60395d9a --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/setup.py @@ -0,0 +1,40 @@ +from setuptools import setup + +setup( + name='sonic-platform', + version='1.0', + description='SONiC platform API implementation on Ruijie TCS9400 Platforms', + license='Apache 2.0', + author='SONiC Team', + author_email='sonic_rd@ruijie.com.cn', + url='', + maintainer='Ruijie TCS9400', + maintainer_email='', + packages=[ + 'sonic_platform', + 'plat_hal', + 'rjutil', + 'eepromutil', + 'hal-config', + 'config', + ], + py_modules=[ + 'hal_pltfm', + 'platform_util', + 'platform_intf', + ], + 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.9', + 'Topic :: Utilities', + ], + keywords='sonic SONiC platform PLATFORM', +) + diff --git a/platform/cavium/docker-syncd-cavm/Dockerfile.j2 b/platform/cavium/docker-syncd-cavm/Dockerfile.j2 index f60fa0fe5797..5932da253208 100755 --- a/platform/cavium/docker-syncd-cavm/Dockerfile.j2 +++ b/platform/cavium/docker-syncd-cavm/Dockerfile.j2 @@ -2,8 +2,6 @@ FROM docker-config-engine-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} ARG docker_container_name -RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf - ## Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive diff --git a/platform/centec-arm64/docker-saiserver-centec/Dockerfile.j2 b/platform/centec-arm64/docker-saiserver-centec/Dockerfile.j2 index 33941235bf90..2e0e8ecca836 100644 --- a/platform/centec-arm64/docker-saiserver-centec/Dockerfile.j2 +++ b/platform/centec-arm64/docker-saiserver-centec/Dockerfile.j2 @@ -1,7 +1,6 @@ FROM docker-config-engine-buster-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} ARG docker_container_name -RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf ## Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive diff --git a/platform/centec-arm64/docker-syncd-centec/Dockerfile.j2 b/platform/centec-arm64/docker-syncd-centec/Dockerfile.j2 index 046de960cd20..175d18505d67 100755 --- a/platform/centec-arm64/docker-syncd-centec/Dockerfile.j2 +++ b/platform/centec-arm64/docker-syncd-centec/Dockerfile.j2 @@ -2,8 +2,6 @@ FROM docker-config-engine-buster-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} ARG docker_container_name -RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf - ## Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive diff --git a/platform/centec-arm64/sai.mk b/platform/centec-arm64/sai.mk index b07f334c2f02..2a8ee5c45d36 100755 --- a/platform/centec-arm64/sai.mk +++ b/platform/centec-arm64/sai.mk @@ -1,6 +1,6 @@ # Centec SAI -export CENTEC_SAI_VERSION = 1.10.1-0 +export CENTEC_SAI_VERSION = 1.11.0-1 export CENTEC_SAI = libsai_$(CENTEC_SAI_VERSION)_$(PLATFORM_ARCH).deb export CENTEC_SAI_DEV = libsai-dev_$(CENTEC_SAI_VERSION)_$(PLATFORM_ARCH).deb diff --git a/platform/centec-arm64/tsingma-bsp/src/ctc_wdt/ctc_wdt.c b/platform/centec-arm64/tsingma-bsp/src/ctc_wdt/ctc_wdt.c index 8cac376c0bbe..6a651434ea7b 100644 --- a/platform/centec-arm64/tsingma-bsp/src/ctc_wdt/ctc_wdt.c +++ b/platform/centec-arm64/tsingma-bsp/src/ctc_wdt/ctc_wdt.c @@ -345,14 +345,14 @@ static int ctc_wdt_probe(struct amba_device *adev, const struct amba_id *id) return ret; } -static int ctc_wdt_remove(struct amba_device *adev) +static void ctc_wdt_remove(struct amba_device *adev) { struct ctc_wdt *wdt = amba_get_drvdata(adev); watchdog_unregister_device(&wdt->wdd); watchdog_set_drvdata(&wdt->wdd, NULL); - return 0; + return; } static int __maybe_unused ctc_wdt_suspend(struct device *dev) diff --git a/platform/centec/docker-saiserver-centec/Dockerfile.j2 b/platform/centec/docker-saiserver-centec/Dockerfile.j2 index 33941235bf90..2e0e8ecca836 100644 --- a/platform/centec/docker-saiserver-centec/Dockerfile.j2 +++ b/platform/centec/docker-saiserver-centec/Dockerfile.j2 @@ -1,7 +1,6 @@ FROM docker-config-engine-buster-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} ARG docker_container_name -RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf ## Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive diff --git a/platform/centec/docker-syncd-centec/Dockerfile.j2 b/platform/centec/docker-syncd-centec/Dockerfile.j2 index c1d122eeb9a0..9993539887a5 100755 --- a/platform/centec/docker-syncd-centec/Dockerfile.j2 +++ b/platform/centec/docker-syncd-centec/Dockerfile.j2 @@ -2,8 +2,6 @@ FROM docker-config-engine-buster-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} ARG docker_container_name -RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf - ## Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive diff --git a/platform/centec/sdk.mk b/platform/centec/sdk.mk index 7fe7122a4bf9..ae836d2bf3db 100644 --- a/platform/centec/sdk.mk +++ b/platform/centec/sdk.mk @@ -1,8 +1,8 @@ # Centec SAI -CENTEC_SAI = libsai_1.10.1-0_amd64.deb +CENTEC_SAI = libsai_1.11.0-1_amd64.deb $(CENTEC_SAI)_URL = https://github.com/CentecNetworks/sonic-binaries/raw/master/amd64/sai/$(CENTEC_SAI) -CENTEC_SAI_DEV = libsai-dev_1.10.1-0_amd64.deb +CENTEC_SAI_DEV = libsai-dev_1.11.0-1_amd64.deb $(CENTEC_SAI_DEV)_URL = https://github.com/CentecNetworks/sonic-binaries/raw/master/amd64/sai/$(CENTEC_SAI_DEV) $(eval $(call add_conflict_package,$(CENTEC_SAI_DEV),$(LIBSAIVS_DEV))) diff --git a/platform/components/docker-gbsyncd-broncos/Dockerfile.j2 b/platform/components/docker-gbsyncd-broncos/Dockerfile.j2 index ca7670acb628..3bb3f402098e 100644 --- a/platform/components/docker-gbsyncd-broncos/Dockerfile.j2 +++ b/platform/components/docker-gbsyncd-broncos/Dockerfile.j2 @@ -1,7 +1,6 @@ FROM docker-config-engine-bullseye-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} ARG docker_container_name -RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf ## Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive diff --git a/platform/components/docker-gbsyncd-credo.mk b/platform/components/docker-gbsyncd-credo.mk index 6f5c69b506e6..d1961afe9a12 100644 --- a/platform/components/docker-gbsyncd-credo.mk +++ b/platform/components/docker-gbsyncd-credo.mk @@ -1,9 +1,9 @@ DOCKER_GBSYNCD_PLATFORM_CODE = credo -LIBSAI_CREDO = libsaicredo_0.7.5_amd64.deb -$(LIBSAI_CREDO)_URL = "https://sonicstorage.blob.core.windows.net/packages/credosai/libsaicredo_0.7.5_amd64.deb?sv=2020-10-02&st=2022-04-14T02%3A21%3A31Z&se=2100-04-15T02%3A21%3A00Z&sr=b&sp=r&sig=iDv9Fprntpw9iVBFYVjW8iygy4qcSWT8O90nAXdXR0A%3D" -LIBSAI_CREDO_OWL = libsaicredo-owl_0.7.5_amd64.deb -$(LIBSAI_CREDO_OWL)_URL = "https://sonicstorage.blob.core.windows.net/packages/credosai/libsaicredo-owl_0.7.5_amd64.deb?sv=2020-10-02&st=2022-04-14T02%3A23%3A22Z&se=2100-04-15T02%3A23%3A00Z&sr=b&sp=r&sig=58z6E2nPcLIGjqAoxRAo7du%2FzjIBZkFdoXfSzw96Kxc%3D" +LIBSAI_CREDO = libsaicredo_0.9.0_amd64.deb +$(LIBSAI_CREDO)_URL = "https://sonicstorage.blob.core.windows.net/packages/credosai/libsaicredo_0.9.0_amd64.deb?sv=2021-04-10&st=2023-03-08T02%3A10%3A11Z&se=2100-03-09T02%3A10%3A00Z&sr=b&sp=r&sig=mxOWttgAuOXVjvDI3zF5KHcrTHBgg6mv%2FOpTOxlCoVM%3D" +LIBSAI_CREDO_OWL = libsaicredo-owl_0.9.0_amd64.deb +$(LIBSAI_CREDO_OWL)_URL = "https://sonicstorage.blob.core.windows.net/packages/credosai/libsaicredo-owl_0.9.0_amd64.deb?sv=2021-04-10&st=2023-03-08T02%3A12%3A02Z&se=2100-03-09T02%3A12%3A00Z&sr=b&sp=r&sig=n4mqMVnZxC3u14EWRehfl6bqqUAi1VP1uUdHGg3%2B7H4%3D" ifneq ($($(LIBSAI_CREDO)_URL),) include $(PLATFORM_PATH)/../template/docker-gbsyncd-base.mk diff --git a/platform/components/docker-gbsyncd-credo/Dockerfile.j2 b/platform/components/docker-gbsyncd-credo/Dockerfile.j2 index 3010dc7fdad5..24fef740dc34 100644 --- a/platform/components/docker-gbsyncd-credo/Dockerfile.j2 +++ b/platform/components/docker-gbsyncd-credo/Dockerfile.j2 @@ -1,7 +1,6 @@ FROM docker-config-engine-bullseye-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} ARG docker_container_name -RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf ## Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive diff --git a/platform/innovium/docker-syncd-invm/Dockerfile.j2 b/platform/innovium/docker-syncd-invm/Dockerfile.j2 index ef0c3d57e025..0811d044b02b 100755 --- a/platform/innovium/docker-syncd-invm/Dockerfile.j2 +++ b/platform/innovium/docker-syncd-invm/Dockerfile.j2 @@ -1,7 +1,6 @@ FROM docker-config-engine-stretch-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} ARG docker_container_name -RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf ## Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive diff --git a/platform/marvell-arm64/docker-syncd-mrvl/Dockerfile.j2 b/platform/marvell-arm64/docker-syncd-mrvl/Dockerfile.j2 index 7ec04c49fc4b..d07c2523182c 100755 --- a/platform/marvell-arm64/docker-syncd-mrvl/Dockerfile.j2 +++ b/platform/marvell-arm64/docker-syncd-mrvl/Dockerfile.j2 @@ -3,8 +3,6 @@ FROM docker-config-engine-buster-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} ARG docker_container_name -RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf - ## Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive diff --git a/platform/marvell-armhf/docker-syncd-mrvl/Dockerfile.j2 b/platform/marvell-armhf/docker-syncd-mrvl/Dockerfile.j2 index b5e70888a599..84e3d5bde2fb 100755 --- a/platform/marvell-armhf/docker-syncd-mrvl/Dockerfile.j2 +++ b/platform/marvell-armhf/docker-syncd-mrvl/Dockerfile.j2 @@ -3,8 +3,6 @@ FROM docker-config-engine-bullseye-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} ARG docker_container_name -RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf - ## Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive 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 d95e7a522da8..846bd7131685 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 @@ -974,3 +974,20 @@ def get_position_in_parent(self): integer: The 1-based relative physical position in parent device """ return self.index + + def get_error_description(self): + """ + Retrives the error descriptions of the SFP module + + Returns: + String that represents the current error descriptions of vendor specific errors + In case there are multiple errors, they should be joined by '|', + like: "Bad EEPROM|Unsupported cable" + """ + + if not self.get_presence(): + error_description = self.SFP_STATUS_UNPLUGGED + else: + error_description = self.SFP_STATUS_OK + + return error_description 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 ea347d79be3a..1ad633876be6 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 @@ -2,5 +2,4 @@ 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-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 deleted file mode 100644 index a2131cdc17fb..000000000000 --- a/platform/marvell-armhf/sonic-platform-nokia/entropy.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/python -import fcntl, struct -import time -from os import path - -RNDADDENTROPY=0x40085203 - -def avail(): - if path.exists("/proc/sys/kernel/random/entropy_avail"): - with open("/proc/sys/kernel/random/entropy_avail", mode='r') as avail: - return int(avail.read()) - else: - return int(2048) - -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/nokia-7215_plt_setup.sh b/platform/marvell-armhf/sonic-platform-nokia/nokia-7215_plt_setup.sh index 0af85d730615..017c7e5153a8 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 @@ -25,7 +25,6 @@ main() fw_uboot_env_cfg echo "Nokia-IXS7215: /dev/mtd0 FW_ENV_DEFAULT" - python /etc/entropy.py & /bin/sh /etc/inband_mgmt.sh } diff --git a/platform/marvell/docker-syncd-mrvl/Dockerfile.j2 b/platform/marvell/docker-syncd-mrvl/Dockerfile.j2 index cb2f7eadb911..4de6df313834 100755 --- a/platform/marvell/docker-syncd-mrvl/Dockerfile.j2 +++ b/platform/marvell/docker-syncd-mrvl/Dockerfile.j2 @@ -3,8 +3,6 @@ FROM docker-config-engine-buster-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} ARG docker_container_name -RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf - ## Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive diff --git a/platform/mellanox/docker-saiserver-mlnx/Dockerfile.j2 b/platform/mellanox/docker-saiserver-mlnx/Dockerfile.j2 index 0f6745d580ab..40cf0634bbb7 100644 --- a/platform/mellanox/docker-saiserver-mlnx/Dockerfile.j2 +++ b/platform/mellanox/docker-saiserver-mlnx/Dockerfile.j2 @@ -18,7 +18,6 @@ FROM docker-config-engine-bullseye-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} ARG docker_container_name -RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf ## Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive diff --git a/platform/mellanox/docker-syncd-mlnx/Dockerfile.j2 b/platform/mellanox/docker-syncd-mlnx/Dockerfile.j2 index cd3f74bcfaf3..3d68ba4bc9f7 100755 --- a/platform/mellanox/docker-syncd-mlnx/Dockerfile.j2 +++ b/platform/mellanox/docker-syncd-mlnx/Dockerfile.j2 @@ -19,8 +19,6 @@ FROM docker-config-engine-bullseye-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} ARG docker_container_name -RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf - RUN mkdir -p /var/run/sx_sdk ## Make apt-get non-interactive @@ -32,6 +30,7 @@ RUN apt-get update && \ python3-pip \ python3-dev \ python-is-python3 \ + python3-jsonschema \ {%- if ENABLE_ASAN == "y" %} libasan6 \ {%- endif %} @@ -65,9 +64,16 @@ RUN apt-get clean -y && \ COPY ["supervisord.conf.j2", "/usr/share/sonic/templates/"] COPY ["files/supervisor-proc-exit-listener", "/usr/bin"] COPY ["critical_processes", "/etc/supervisor/"] +COPY ["platform_syncd_dump.sh", "/usr/bin/"] RUN mkdir -p /etc/supervisor/conf.d/ RUN sonic-cfggen -a "{\"ENABLE_ASAN\":\"{{ENABLE_ASAN}}\"}" -t /usr/share/sonic/templates/supervisord.conf.j2 > /etc/supervisor/conf.d/supervisord.conf RUN rm -f /usr/share/sonic/templates/supervisord.conf.j2 +RUN mkdir -p /usr/lib/ecmp_calc +COPY ["ecmp_calculator/ecmp_calc.py", "/usr/bin"] +COPY ["ecmp_calculator/ecmp_calc_sdk.py", "/usr/lib/ecmp_calc"] +COPY ["ecmp_calculator/packet_scheme.py", "/usr/lib/ecmp_calc"] +COPY ["lib/port_utils.py", "/usr/lib"] + ENTRYPOINT ["/usr/local/bin/supervisord"] diff --git a/platform/mellanox/docker-syncd-mlnx/ecmp_calculator/README.md b/platform/mellanox/docker-syncd-mlnx/ecmp_calculator/README.md new file mode 100644 index 000000000000..59a49edeca59 --- /dev/null +++ b/platform/mellanox/docker-syncd-mlnx/ecmp_calculator/README.md @@ -0,0 +1,150 @@ +# SONiC ECMP Calculator + +## Description +An equal cost multipath (ECMP) is formed when routing table contains multiple next hop addresses for the same destination IP address. +ECMP will load balance the outbound traffic between the IP interfaces. +The purpose of ECMP calculator is to calculate which IP interface ECMP will choose and return the physical interface packet will egress from. +Packet is defined by a JSON file given as an argument to the tool. + +## Usage notes +1. ECMP calculator performs its calculations based on the current operational state of the router. In order to calculate the egress port, it fetches routes from HW. Routes exist in HW only for next hops with a resolved ARP. +2. ECMP calculator supports only routed packets. +- IPv4/IPv6 TCP/UDP packets +- IPinIP and VXLAN encapsulated packets +3. Changes done in the packet classification (e.g. ACL, PBR) are not taken into consideration during calculation. + +## Command line interface +1. User shall enter syncd container to run ECMP calculator. +2. User shall provide the following input parameters: +- JSON file describing a packet +- Ingress port (e.g. "Ethernet0", must pe a physical interface) +- Debug option for debug purposes (optional) +- VRF name (optional) +3. Usage example: +``` +$ docker exec -it syncd bash +$ /usr/bin/ecmp_calc.py -i Ethernet0 -p ./packet.json -v Vrf_red +Egress port: Ethernet4 +``` +``` +$ docker exec -it syncd bash +$ /usr/bin/ecmp_calc.py -h +usage: ecmp_calc.py [-h] -i INTERFACE -p PACKET [-v VRF] [-d] + +ECMP calculator + +optional arguments: + -h, --help show this help message and exit + -i INTERFACE, --interface INTERFACE + Ingress interface + -p PACKET, --packet PACKET + Packet description + -v VRF, --vrf VRF VRF name + -d, --debug Flag for debug + +``` + +## Packet JSON +1. Numbers in packet JSON must be in base-ten. +2. For packets with single header, outer header shall be provided. +3. The following table defines the structure of a packet JSON file. + +| ecmp_hash | | | | | | | +|-----------|-------------|-------|-------------|-------------|--------|----------------------------------------------------------------------------------| +| | packet_info | | | | object | | +| | | outer | | | object | | +| | | | layer2 | | object | | +| | | | | smac | string | | +| | | | | dmac | string | | +| | | | | ethertype | number | 16bits, needed for IPv4 or IPv6 packet | +| | | | | outer_vid | number | 12bits | +| | | | | outer_pcp | number | 3bits | +| | | | | outer_dei | number | 1bits | +| | | | | inner_vid | number | QinQ | +| | | | | inner_pcp | number | QinQ | +| | | | | inner_dei | number | QinQ | +| | | | ipv4 | | object | | +| | | | | sip | string | | +| | | | | dip | string | | +| | | | | proto | number | 8bits | +| | | | | dscp | number | 6bits | +| | | | | ecn | number | 2bits | +| | | | | mflag | number | 1bit | +| | | | | l3_length | number | 16bits | +| | | | ipv6 | | object | should not co-exist with ipv4 field | +| | | | | sip | string | | +| | | | | dip | string | | +| | | | | mflag | number | 1bit | +| | | | | next_header | number | 8bits | +| | | | | dscp | number | 6bits | +| | | | | ecn | number | 2bits | +| | | | | l3_length | number | 16bits | +| | | | | flow_label | number | 20bits | +| | | | tcp_udp | | object | | +| | | | | sport | number | 16bits | +| | | | | dport | number | 16bits | +| | | | vxlan_nvgre | | object | | +| | | | | vni | number | 24bits | +| | | inner | | | object | overlay | +| | | | layer2 | | object | | +| | | | | smac | string | | +| | | | | dmac | string | | +| | | | | ethertype | number | 16bits | +| | | | ipv4 | | object | | +| | | | | sip | string | | +| | | | | dip | string | | +| | | | | mflag | number | 1bit | +| | | | | proto | number | 8bits | +| | | | ipv6 | | object | should not co-exist with ipv4 field | +| | | | | sip | string | | +| | | | | dip | string | | +| | | | | mflag | number | 1bit | +| | | | | next_header | number | 8bits | +| | | | | flow_label | number | 20bits | +| | | | tcp_udp | | object | | +| | | | | sport | number | 16bits | +| | | | | dport | number | 16bits | + +4. Packet JSON file example + +```json +{ + "packet_info": { + "outer": { + "ipv4": { + "sip": "10.10.10.10", + "dip": "3.3.3.3", + "proto": 17 + }, + "layer2": { + "smac": "24:8a:07:1e:82:ed", + "dmac": "1c:34:da:1c:a1:00", + "ethertype": 2048 + }, + "tcp_udp": { + "sport": 100, + "dport": 4789 + }, + "vxlan_nvgre": { + "vni": 100 + } + }, + "inner": { + "layer2": { + "smac": "11:11:11:11:11:11", + "dmac": "22:22:22:22:22:22", + "ethertype": 2048 + }, + "ipv4": { + "sip": "1.1.1.1", + "dip": "2.2.2.3", + "proto": 17, + "mflag": 0 + }, + "tcp_udp": { + "sport": 100, + "dport": 200 + } + } + } +} \ No newline at end of file diff --git a/platform/mellanox/docker-syncd-mlnx/ecmp_calculator/ecmp_calc.py b/platform/mellanox/docker-syncd-mlnx/ecmp_calculator/ecmp_calc.py new file mode 100755 index 000000000000..2fbcef86993e --- /dev/null +++ b/platform/mellanox/docker-syncd-mlnx/ecmp_calculator/ecmp_calc.py @@ -0,0 +1,517 @@ +#!/usr/bin/env python3 + +import json, jsonschema +import argparse +import ipaddress +import re +import subprocess +import pprint +import os +import sys + +usr_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +lib_path = os.path.join(usr_path, "lib") +ecmp_lib_path = os.path.join(lib_path, "ecmp_calc") +sys.path.append(lib_path) +sys.path.append(ecmp_lib_path) + +from ecmp_calc_sdk import sx_open_sdk_connection, sx_get_active_vrids, sx_router_get_ecmp_id, \ + sx_router_ecmp_nexthops_get, sx_get_router_interface, \ + sx_port_vport_base_get, sx_router_neigh_get_mac, sx_fdb_uc_mac_addr_get, \ + sx_lag_port_group_get, sx_make_ip_prefix_v4, sx_make_ip_prefix_v6, \ + sx_vlan_ports_get, sx_ip_addr_to_str, sx_close_sdk_connection, \ + PORT, VPORT, VLAN, SX_ENTRY_NOT_FOUND +from packet_scheme import PACKET_SCHEME +from port_utils import sx_get_ports_map, is_lag +from swsscommon.swsscommon import ConfigDBConnector, DBConnector, Table + +IP_VERSION_IPV4 = 1 +IP_VERSION_IPV6 = 2 +PORT_CHANNEL_IDX = 0 +VRF_NAME_IDX = 1 +IP_VERSION_MAX_MASK_LEN = {IP_VERSION_IPV4: 32, IP_VERSION_IPV6: 128} + +APPL_DB_NAME = 'APPL_DB' +INTF_TABLE = 'INTF_TABLE' +VRF_TABLE = 'VRF_TABLE' +LAG_MEMBER_TABLE = 'LAG_MEMBER_TABLE' +HASH_CALC_PATH = '/usr/bin/sx_hash_calculator' +HASH_CALC_INPUT_FILE = "/tmp/hash_calculator_input.json" +HASH_CALC_OUTPUT_FILE = "/tmp/hash_calculator_output.json" + +def exec_cmd(cmd): + """ Execute shell command """ + return subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=False).decode("utf-8") + +def is_mac_valid(mac): + return bool(re.match("^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$", mac)) + +def is_ip_valid(address, ip_version): + try: + if ip_version == IP_VERSION_IPV4: + ip = ipaddress.IPv4Address(address) + invalid_list = ['0.0.0.0','255.255.255.255'] + else: + ip = ipaddress.IPv6Address(address) + invalid_list = ['0::0'] + + if ip.is_link_local: + print ("Link local IP {} is not valid".format(ip)) + return False + + if ip in invalid_list: + print ("IP {} is not valid".format(ip)) + return False + + if ip.is_multicast: + print ("Multicast IP {} is not valid".format(ip)) + return False + + if ip.is_loopback: + print ("Loopback IP {} is not valid".format(ip)) + return False + + except ipaddress.AddressValueError: + return False + + return True + +def load_json(filename): + data = None + with open(filename) as f: + try: + data = json.load(f) + except json.JSONDecodeError as e: + raise ValueError("Failed to load JSON file '{}', error: '{}'".format(filename, e)) + return data + +def create_network_addr(ip_addr, mask_len, ip_version): + ip_addr_mask = "{}/{}".format(ip_addr, mask_len) + + if ip_version == IP_VERSION_IPV4: + network_addr = ipaddress.IPv4Network(ip_addr_mask,strict = False) + else: + network_addr = ipaddress.IPv6Network(ip_addr_mask,strict = False) + + network_addr_ip = network_addr.with_netmask.split('/')[0] + network_addr_mask = network_addr.with_netmask.split('/')[1] + + if ip_version == IP_VERSION_IPV4: + network_addr = sx_make_ip_prefix_v4(network_addr_ip, network_addr_mask) + else: + network_addr = sx_make_ip_prefix_v6(network_addr_ip, network_addr_mask) + + return network_addr + +class EcmpCalcExit(Exception): + pass + +class EcmpCalc: + def __init__(self): + self.packet = {} + self.ports_map = {} + self.ecmp_ids = {} + self.next_hops = {} + self.user_vrf = '' + self.ingress_port = "" + self.egress_ports = [] + self.debug = False + + self.config_db = ConfigDBConnector() + self.appl_db = DBConnector(APPL_DB_NAME, 0) + self.open_sdk_connection() + self.init_ports_map() + self.get_active_vrids() + + def __del__(self): + self.close_sdk_connection() + self.cleanup() + + def cleanup(self): + for filename in [HASH_CALC_INPUT_FILE, HASH_CALC_OUTPUT_FILE]: + if os.path.exists(filename): + os.remove(filename) + + def close_sdk_connection(self): + sx_close_sdk_connection(self.handle) + + def open_sdk_connection(self): + self.handle = sx_open_sdk_connection() + + def debug_print(self, *args, **kwargs): + if self.debug == True: + print(*args, **kwargs) + + def init_ports_map(self): + self.ports_map = sx_get_ports_map(self.handle, self.config_db) + + def validate_ingress_port(self, interface): + if interface not in self.ports_map.values(): + raise ValueError("Invalid interface {}".format(interface)) + self.ingress_port = interface + + def validate_args(self, interface, packet, vrf, debug): + if (debug is True): + self.debug = True + + self.validate_ingress_port(interface) + self.validate_packet_json(packet) + + if (vrf is not None): + self.user_vrf = vrf + if not self.validate_vrf(): + raise ValueError("VRF validation failed: VRF {} does not exist".format(self.user_vrf)) + + def validate_vrf(self): + vrf_table = Table(self.appl_db, VRF_TABLE) + vrf_table_keys = vrf_table.getKeys() + + if self.user_vrf in vrf_table_keys: + return True + + return False + + def get_ecmp_id(self): + ip_addr = self.dst_ip + ip_version = self.ip_version + max_mask_len = IP_VERSION_MAX_MASK_LEN[self.ip_version] + route_found = False + + for vrid in self.vrid_list: + for mask_len in range(max_mask_len, 0, -1): + network_addr = create_network_addr(ip_addr, mask_len, ip_version) + ecmp_id = sx_router_get_ecmp_id(self.handle, vrid, network_addr) + if ecmp_id != SX_ENTRY_NOT_FOUND: + route_found = True + self.debug_print("Found route for destination IP {} ECMP id {} VRID {}".format(self.dst_ip, ecmp_id, vrid)) + self.ecmp_ids[vrid] = ecmp_id + + # move to next vrid + break + + if not route_found: + raise EcmpCalcExit("No route found for given packet") + + def get_next_hops(self): + next_hops = [] + ecmp_found = False + + for vrid in self.ecmp_ids.keys(): + ecmp_id = self.ecmp_ids[vrid] + next_hops = sx_router_ecmp_nexthops_get(self.handle, ecmp_id) + + if len(next_hops) > 1: + if self.debug: + next_hops_ips = [] + for nh in next_hops: + ip = nh.next_hop_key.next_hop_key_entry.ip_next_hop.address + next_hops_ips.append(sx_ip_addr_to_str(ip)) + print("Next hops IPs {}, VRID {}".format(next_hops_ips, vrid)) + print("Found ECMP for destination IP {} ECMP id {}, now checking if port is member in VRF {}". + format(self.dst_ip, ecmp_id, 'default' if self.user_vrf=='' else self.user_vrf)) + + self.next_hops[vrid] = next_hops + ecmp_found = True + + if not ecmp_found: + raise EcmpCalcExit("No ECMP for given packet") + + def calculate_egress_port(self): + for vrid in self.vrid_list: + if vrid not in self.next_hops.keys(): + continue + + next_hops = self.next_hops[vrid] + next_hop_idx = self.get_next_hop_index(len(next_hops)) + next_hop = next_hops[next_hop_idx] + + rif = next_hop.next_hop_key.next_hop_key_entry.ip_next_hop.rif + ip = next_hop.next_hop_key.next_hop_key_entry.ip_next_hop.address + rif_params = sx_get_router_interface(self.handle, vrid, rif) + + self.debug_print("Next hop ip to which trafic will egress: {}".format(sx_ip_addr_to_str(ip))) + + # Handle router port + if PORT in rif_params: + logical = rif_params[PORT] + port_type = PORT + vlan_id = 0 + + # Handle vlan subinterface + elif VPORT in rif_params: + logical, vlan_id = sx_port_vport_base_get(self.handle, rif_params[VPORT]) + port_type = VPORT + + # Handle vlan interface + elif VLAN in rif_params: + vlan_id = rif_params[VLAN] + neigh_mac = sx_router_neigh_get_mac(self.handle, rif, ip) + if neigh_mac is not None: + mac_entry = sx_fdb_uc_mac_addr_get(self.handle, vlan_id, neigh_mac) + if mac_entry is not None: + logical = mac_entry.log_port + port_type = VLAN + + # Handle flood case + if (neigh_mac is None) or (mac_entry is None): + vlan_members = sx_vlan_ports_get(self.handle, rif_params[VLAN]) + for port in vlan_members: + if is_lag(port): + port = self.get_lag_member(port, True) + self.egress_ports.append(self.ports_map[port]) + return + + # Check if port is binded to VRF we got from the user + if is_lag(logical): + lag_logical = logical + logical = self.get_lag_member(lag_logical) + egress_port = self.ports_map[logical] + + port_channel = self.get_port_channel_name(egress_port) + if self.is_port_bind_to_user_vrf(port_type, port_channel, vlan_id): + self.egress_ports.append(egress_port) + return + else: + egress_port = self.ports_map[logical] + if self.is_port_bind_to_user_vrf(port_type, egress_port, vlan_id): + self.egress_ports.append(egress_port) + return + + def print_egress_port(self): + if len(self.egress_ports) == 0: + print("Egress port not found, check input parameters") + elif len(self.egress_ports) == 1: + print("Egress port: {}".format(self.egress_ports[0])) + else: + egress_ports = '' + for port in self.egress_ports: + egress_ports += ' ' + port + print("Egress ports:{}".format(egress_ports)) + + def is_port_bind_to_user_vrf(self, port_type, port, vlan_id = 0): + if port_type == PORT: + # INTF_TABLE:Ethernet0 + entry = '{}'.format(port) + elif port_type == VPORT: + # INTF_TABLE:Ethernet0.300 + entry = '{}.{}'.format(port, vlan_id) + elif port_type == VLAN: + # INTF_TABLE:Vlan300 + entry = 'Vlan{}'.format(vlan_id) + + vrf_table = Table(self.appl_db, INTF_TABLE) + (_, port_vrf) = vrf_table.hget(entry, 'vrf_name') + + if self.user_vrf == port_vrf.strip(): + return True + + return False + + # Get port-channel name for given port-channel member port + def get_port_channel_name(self, port): + lag_member_table = Table(self.appl_db, LAG_MEMBER_TABLE) + lag_member_table_keys = lag_member_table.getKeys() + + for key in lag_member_table_keys: + if port in key: + port_channel = key.split(':')[PORT_CHANNEL_IDX] + return port_channel + + raise KeyError("Failed to get port-channel name for interface {}".format(port)) + + def get_ingress_port_logical_idx(self): + for logical_index, sonic_port_name in self.ports_map.items(): + if sonic_port_name == self.ingress_port: + return logical_index + + raise KeyError("Failed to get logical index for interface {}".format(self.ingress_port)) + + # Get index in next hop array from which packet will egress + def get_next_hop_index(self, ecmp_size): + logical = self.get_ingress_port_logical_idx() + + ecmp_hash = { + "ingress_port": str(hex(logical)), + "packet_info":self.packet['packet_info'], + "ecmp_size": ecmp_size, + } + + self.debug_print("Calling hash calculator for ECMP") + hash_result = self.call_hash_calculator({'ecmp_hash': ecmp_hash}) + ecmp_hash_result = hash_result['ecmp_hash'] + index = ecmp_hash_result['ecmp_index'] + + self.debug_print("Next hop index to which trafic will egress: {}".format(index)) + return index + + # Get index in LAG memebrs array from which packet will egress + def get_lag_member_index(self, lag_size, flood_case = False): + logical = self.get_ingress_port_logical_idx() + + lag_hash = { + "ingress_port": str(hex(logical)), + "packet_info": self.packet['packet_info'], + "lag_size": lag_size, + } + + self.debug_print("Calling hash calculator for LAG, flood case {}".format(True if flood_case else False)) + hash_result = self.call_hash_calculator({"lag_hash": lag_hash}) + lag_hash_result = hash_result["lag_hash"] + + if flood_case: + index = lag_hash_result['lag_mc_index'] + else: + index = lag_hash_result['lag_index'] + + self.debug_print("Lag member index from which trafic will egress: {}".format(index)) + return index + + # Get LAG memebr from which packet will egress + def get_lag_member(self, logical, flood_case = False): + lag_members = sx_lag_port_group_get(self.handle, logical) + lag_members.sort() + + member_index = self.get_lag_member_index(len(lag_members), flood_case) + lag_member = lag_members[member_index] + + self.debug_print("Lag members: {}\nLag member from which trafic will egress: {}".format(lag_members, lag_member)) + return lag_member + + def call_hash_calculator(self, input_dict): + with open(HASH_CALC_INPUT_FILE, "w") as outfile: + json.dump(input_dict, outfile) + + out = exec_cmd([HASH_CALC_PATH, '-c', HASH_CALC_INPUT_FILE, '-o', HASH_CALC_OUTPUT_FILE, '-d']) + self.debug_print ("Hash calculator output:\n{}".format(out)) + + with open(HASH_CALC_OUTPUT_FILE, 'r') as openfile: + output_dict = json.loads(openfile.read()) + + return output_dict + + def get_active_vrids(self): + self.vrid_list = sx_get_active_vrids(self.handle) + + def validate_ipv4_header(self, header): + for ip in ['sip', 'dip']: + if ip in header and is_ip_valid(header[ip], IP_VERSION_IPV4) == False: + raise ValueError("Json validation failed: invalid IP {}".format(header[ip])) + + def validate_ipv6_header(self, header): + for ip in ['sip', 'dip']: + if ip in header and is_ip_valid(header[ip], IP_VERSION_IPV6) == False: + raise ValueError("Json validation failed: invalid IP {}".format(header[ip])) + + def validate_layer2_header(self, header): + for mac in ['smac', 'dmac']: + if mac in header and is_mac_valid(header[mac]) == False: + raise ValueError("Json validation failed: invalid mac {}".format(header[mac])) + + def validate_header(self, header, is_outer_header=False): + ipv4_header = False + ipv6_header = False + + # Verify IPv4 and IPv6 headers do not co-exist in header + if 'ipv4' in header: + ipv4_header = True + if 'ipv6' in header: + ipv6_header = True + + if ipv4_header and ipv6_header: + raise ValueError("Json validation failed: IPv4 and IPv6 headers can not co-exist") + + if ipv4_header: + # Verify valid IPs in header + self.validate_ipv4_header(header['ipv4']) + + if is_outer_header: + if 'dip' not in header['ipv4']: + raise ValueError("Json validation failed: destination IP is mandatory") + + self.dst_ip = header['ipv4']['dip'] + self.ip_version = IP_VERSION_IPV4 + + if 'tcp_udp' in header and 'proto' not in header['ipv4']: + raise ValueError("Json validation failed: transport protocol (proto) is mandatory when transport layer port exists") + + elif ipv6_header: + self.validate_ipv6_header(header['ipv6']) + + if is_outer_header: + if 'dip' not in header['ipv6']: + raise ValueError("Json validation failed: destination IP is mandatory") + + self.dst_ip = header['ipv6']['dip'] + self.ip_version = IP_VERSION_IPV6 + + if 'tcp_udp' in header and 'next_header' not in header['ipv6']: + raise ValueError("Json validation failed: transport protocol (next_header) is mandatory when transport layer port exists") + + # Verify valid macs in header + if header['layer2']: + self.validate_layer2_header(header['layer2']) + + def validate_outer_header(self): + outer_header = self.packet['packet_info'].get('outer') + if not outer_header: + raise ValueError("Json validation failed: outer header is mandatory") + + self.validate_header(outer_header, is_outer_header=True) + + def validate_inner_header(self): + inner_header = self.packet['packet_info'].get('inner') + if not inner_header: + return + + self.validate_header(inner_header) + + def validate_packet_json(self, packet_json): + # Verify json has valid format + self.packet = load_json(packet_json) + + # Verify json schema + try: + jsonschema.validate(self.packet, PACKET_SCHEME) + except jsonschema.exceptions.ValidationError as e: + raise ValueError("Json validation failed: {}".format(e)) + + # Verify outer header + self.validate_outer_header() + + # Verify inner header + self.validate_inner_header() + + if self.debug: + print('Packet:') + pprint.pprint(self.packet) + +def main(): + rc = 0 + try: + parser = argparse.ArgumentParser(description="Calculate egress interface for the given packet being routed over ECMP", + usage="/usr/bin/ecmp_calc.py -i -p ") + parser.add_argument("-i", "--interface", required=True, help="ingress interface") + parser.add_argument("-p", "--packet", required=True, help="json file describing a packet") + parser.add_argument("-v", "--vrf", help="VRF name") + parser.add_argument("-d", "--debug", default=False, action="store_true", help="when used, debug messages will be printed to stdout") + args = parser.parse_args() + + ecmp_calc = EcmpCalc() + ecmp_calc.validate_args(args.interface, args.packet, args.vrf, args.debug) + ecmp_calc.get_ecmp_id() + ecmp_calc.get_next_hops() + ecmp_calc.calculate_egress_port() + ecmp_calc.print_egress_port() + + except EcmpCalcExit as s: + print(s) + except ValueError as s: + print("Value error: {}".format(s)) + rc = 1 + except Exception as s: + print("Error: {}".format(s)) + rc = 2 + return rc + +if __name__ == "__main__": + sys.exit(main()) diff --git a/platform/mellanox/docker-syncd-mlnx/ecmp_calculator/ecmp_calc_sdk.py b/platform/mellanox/docker-syncd-mlnx/ecmp_calculator/ecmp_calc_sdk.py new file mode 100755 index 000000000000..564b2ffb02ba --- /dev/null +++ b/platform/mellanox/docker-syncd-mlnx/ecmp_calculator/ecmp_calc_sdk.py @@ -0,0 +1,456 @@ +#!/usr/bin/env python3 + +from python_sdk_api.sx_api import * +from port_utils import sx_check_rc, SWITCH_ID +import struct +import socket +import ctypes +import sys + +PORT='port' +VPORT='vport' +VLAN='vlan' +SX_ENTRY_NOT_FOUND = -1 +SDK_DEFAULT_LOG_LEVEL=SX_VERBOSITY_LEVEL_ERROR + +def severity_to_verbosity(severity): + value = severity + 1 + verbosity = 0 + while not (value & 1): + value = value >> 1 + verbosity = verbosity + 1 + return verbosity + +def log_cb(severity, module_name, msg): + verbosity = severity_to_verbosity(severity) + log_level = {SX_VERBOSITY_LEVEL_INFO: 'LOG_INFO', SX_VERBOSITY_LEVEL_ERROR: 'LOG_ERR', + SX_VERBOSITY_LEVEL_WARNING: 'LOG_WARN', SX_VERBOSITY_LEVEL_DEBUG: 'LOG_DEBUG', + SX_VERBOSITY_LEVEL_NOTICE: 'LOG_NOTICE'} + if verbosity in log_level.keys(): + level = log_level[verbosity] + else: + level = 'LOG' + if verbosity <= SDK_DEFAULT_LOG_LEVEL: + print('{}: {}'.format(level, ctypes.cast(msg,ctypes.c_char_p).value.decode('utf-8'))) + +def sx_open_sdk_connection(): + """ Open connection to SDK + + Args: + None + + Returns: + SDK handle + """ + sx_api = ctypes.CDLL('libsxapi.so', mode=ctypes.RTLD_GLOBAL) + log_cb_type = ctypes.CFUNCTYPE(None, ctypes.c_int, + ctypes.POINTER(ctypes.c_char), + ctypes.POINTER(ctypes.c_char)) + log_cb_fn = log_cb_type(log_cb) + handle_p = ctypes.pointer(ctypes.c_int64()) + + rc = sx_api.sx_api_open(log_cb_fn, handle_p) + sx_check_rc(rc) + + return handle_p.contents.value + +def sx_close_sdk_connection(handle): + """ Close connection to SDK + + Args: + SDK handle + """ + rc = sx_api_close(handle) + sx_check_rc(rc) + +def sx_get_active_vrids(handle): + """ Get existing virtual router IDs + + Args: + handle (sx_api_handle_t): SDK handle + + Returns: + list : List of virtual routers ids + """ + try: + vrid_list = [] + + vrid_cnt_p = new_uint32_t_p() + uint32_t_p_assign(vrid_cnt_p, 0) + vrid_key_p = new_sx_router_id_t_p() + sx_router_id_t_p_assign(vrid_key_p, 0) + vrid_key = sx_router_id_t_p_value(vrid_key_p) + + rc = sx_api_router_vrid_iter_get(handle, SX_ACCESS_CMD_GET, vrid_key, None, None, vrid_cnt_p) + sx_check_rc(rc) + + vrid_cnt = uint32_t_p_value(vrid_cnt_p) + vrid_list_p = new_sx_router_id_t_arr(vrid_cnt) + + rc = sx_api_router_vrid_iter_get(handle, SX_ACCESS_CMD_GET_FIRST, vrid_key, None, vrid_list_p, vrid_cnt_p) + sx_check_rc(rc) + + vrid_cnt = uint32_t_p_value(vrid_cnt_p) + for i in range(0, vrid_cnt): + vrid = sx_router_id_t_arr_getitem(vrid_list_p, i) + vrid_list.append(vrid) + + return vrid_list + + finally: + delete_sx_router_id_t_arr(vrid_list_p) + delete_sx_router_id_t_p(vrid_key_p) + delete_uint32_t_p(vrid_cnt_p) + +def sx_router_get_ecmp_id(handle, vrid, ip_prefix): + """ Get ECMP id for a given IP prefix + + Args: + handle (sx_api_handle_t): SDK handle + vrid (sx_router_id_t): Virtual router id + ip_prefix (sx_ip_prefix_t): Network address + + Returns: + int: ECMP id + """ + try: + ip_prefix_p = new_sx_ip_prefix_t_p() + sx_ip_prefix_t_p_assign(ip_prefix_p, ip_prefix) + entries_cnt_p = new_uint32_t_p() + uint32_t_p_assign(entries_cnt_p, 1) + entries_array = new_sx_uc_route_get_entry_t_arr(1) + + rc = sx_api_router_uc_route_get(handle, SX_ACCESS_CMD_GET, vrid, ip_prefix_p, None, entries_array, entries_cnt_p) + if rc == SX_STATUS_ENTRY_NOT_FOUND: + return SX_ENTRY_NOT_FOUND + sx_check_rc(rc) + + entry = sx_uc_route_get_entry_t_arr_getitem(entries_array, 0) + if entry.route_data.type == SX_UC_ROUTE_TYPE_NEXT_HOP: + return entry.route_data.uc_route_param.ecmp_id + + return SX_ENTRY_NOT_FOUND + + finally: + delete_sx_uc_route_get_entry_t_arr(entries_array) + delete_uint32_t_p(entries_cnt_p) + delete_sx_ip_prefix_t_p(ip_prefix_p) + +def sx_router_ecmp_nexthops_get(handle, ecmp_id): + """ Get next hops for a given ECMP id + + Args: + handle (sx_api_handle_t): SDK handle + ecmp_id (int): ECMP id + + Returns: + list: List of next hops + """ + try: + next_hops = [] + + next_hop_count_p = new_uint32_t_p() + uint32_t_p_assign(next_hop_count_p, 0) + + rc = sx_api_router_operational_ecmp_get(handle, ecmp_id, None, next_hop_count_p) + sx_check_rc(rc) + + next_hop_count = uint32_t_p_value(next_hop_count_p) + next_hop_list_p = new_sx_next_hop_t_arr(next_hop_count) + + rc = sx_api_router_operational_ecmp_get(handle, ecmp_id, next_hop_list_p, next_hop_count_p) + sx_check_rc(rc) + + next_hop_count = uint32_t_p_value(next_hop_count_p) + for i in range(next_hop_count): + next_hop = sx_next_hop_t_arr_getitem(next_hop_list_p, i) + if next_hop.next_hop_key.type == SX_NEXT_HOP_TYPE_IP: + next_hops.append(next_hop) + + return next_hops + + finally: + delete_sx_next_hop_t_arr(next_hop_list_p) + delete_uint32_t_p(next_hop_count_p) + +def sx_get_router_interface(handle, vrid, rif): + """ Get router interface information + + Args: + handle (sx_api_handle_t): SDK handle + vrid (sx_router_id_t): virtual router id + rif (sx_router_interface_t): router interface id + + Returns: + dict : Dictionary contains interface parameters + """ + try: + vrid_p = new_sx_router_id_t_p() + sx_router_id_t_p_assign(vrid_p, vrid) + + ifc_p = new_sx_router_interface_param_t_p() + ifc_attr_p = new_sx_interface_attributes_t_p() + rif_params = {} + + rc = sx_api_router_interface_get(handle, rif, vrid_p, ifc_p, ifc_attr_p) + sx_check_rc(rc) + + if ifc_p.type == SX_L2_INTERFACE_TYPE_PORT_VLAN: + rif_params[PORT] = ifc_p.ifc.port_vlan.port + + if ifc_p.type == SX_L2_INTERFACE_TYPE_VPORT: + rif_params[VPORT] = ifc_p.ifc.vport.vport + + if ifc_p.type == SX_L2_INTERFACE_TYPE_VLAN: + rif_params[VLAN] = ifc_p.ifc.vlan.vlan + + return rif_params + + finally: + delete_sx_interface_attributes_t_p(ifc_attr_p) + delete_sx_router_interface_param_t_p(ifc_p) + delete_sx_router_id_t_p(vrid_p) + +def sx_port_vport_base_get(handle, vport): + """ Get SDK logical index and vlan for given vport + + Args: + handle (sx_api_handle_t): SDK handle + vport (sx_port_id_t): SDK vport id + + Returns: + sx_port_log_id_t : SDK logical index + """ + try: + vlan_id_p = new_sx_vlan_id_t_p() + logical_port_p = new_sx_port_log_id_t_p() + + rc = sx_api_port_vport_base_get(handle, vport, vlan_id_p, logical_port_p) + sx_check_rc(rc) + + logical_port = sx_port_log_id_t_p_value(logical_port_p) + vlan_id = sx_vlan_id_t_p_value(vlan_id_p) + + return logical_port, vlan_id + + finally: + delete_sx_port_log_id_t_p(logical_port_p) + delete_sx_vlan_id_t_p(vlan_id_p) + +def sx_router_neigh_get_mac(handle, rif, addr): + """ Get neighbour mac address + + Args: + handle (sx_api_handle_t): SDK handle + rif (sx_port_id_t): SDK vport id + addr (sx_ip_addr_t): Neighbour IP address + + Returns: + str : Neighbour mac address + """ + try: + neigh_entry_cnt_p = new_uint32_t_p() + neigh_entry_list_p = new_sx_neigh_get_entry_t_arr(1) + + filter_p = new_sx_neigh_filter_t_p() + neigh_filter = sx_neigh_filter_t() + neigh_filter.filter_by_rif = SX_KEY_FILTER_FIELD_NOT_VALID + neigh_filter.rif = 0 + sx_neigh_filter_t_p_assign(filter_p, neigh_filter) + + rc = sx_api_router_neigh_get(handle, SX_ACCESS_CMD_GET, rif, addr, filter_p, neigh_entry_list_p, neigh_entry_cnt_p) + if rc == SX_STATUS_ENTRY_NOT_FOUND: + return None + sx_check_rc(rc) + + neighbor_entry = sx_neigh_get_entry_t_arr_getitem(neigh_entry_list_p, 0) + + return neighbor_entry.neigh_data.mac_addr.to_str() + + finally: + delete_sx_neigh_filter_t_p(filter_p) + delete_sx_neigh_get_entry_t_arr(neigh_entry_list_p) + delete_uint32_t_p(neigh_entry_cnt_p) + +def sx_fdb_uc_mac_addr_get(handle, vlan_id, mac_addr): + """ Get UC mac entry from FDB + + Args: + handle (sx_api_handle_t): SDK handle + vlan_id (sx_vlan_id_t): VLAN id + mac_addr (str): mac address + + Returns: + sx_fdb_uc_mac_addr_params_t : FDB mac entry + """ + try: + key = sx_fdb_uc_mac_addr_params_t() + key.fid_vid = vlan_id + key.mac_addr = ether_addr(mac_addr) + key.action = SX_FDB_ACTION_FORWARD + key_p = copy_sx_fdb_uc_mac_addr_params_t_p(key) + + key_filter = sx_fdb_uc_key_filter_t() + key_filter.filter_by_fid = SX_FDB_KEY_FILTER_FIELD_VALID + key_filter.filter_by_mac_addr = SX_FDB_KEY_FILTER_FIELD_VALID + key_filter.filter_by_log_port = SX_FDB_KEY_FILTER_FIELD_NOT_VALID + key_filter.fid = vlan_id + key_filter.mac_addr = ether_addr(mac_addr) + key_filter_p = copy_sx_fdb_uc_key_filter_t_p(key_filter) + + data_cnt_p = copy_uint32_t_p(SX_FDB_MAX_GET_ENTRIES) + mac_list_p = new_sx_fdb_uc_mac_addr_params_t_arr(SX_FDB_MAX_GET_ENTRIES) + + rc = sx_api_fdb_uc_mac_addr_get(handle, 0, SX_ACCESS_CMD_GET_FIRST, SX_FDB_UC_ALL, key_p, key_filter_p, mac_list_p, data_cnt_p) + if rc == SX_STATUS_ENTRY_NOT_FOUND: + return None + sx_check_rc(rc) + + data_cnt = uint32_t_p_value(data_cnt_p) + if data_cnt == 0: + return None + + assert data_cnt == 1, "Got unexpected macs amount, mac {} vlan {} data_cnt {}".format(mac_addr, vlan_id, data_cnt) + + mac_entry = sx_fdb_uc_mac_addr_params_t_arr_getitem(mac_list_p, 0) + assert mac_entry.dest_type == SX_FDB_UC_MAC_ADDR_DEST_TYPE_LOGICAL_PORT, "Got unexpected mac entry type {}".format(mac_entry.dest_type) + + return mac_entry + + finally: + delete_sx_fdb_uc_mac_addr_params_t_arr(mac_list_p) + delete_uint32_t_p(data_cnt_p) + delete_sx_fdb_uc_key_filter_t_p(key_filter_p) + delete_sx_fdb_uc_mac_addr_params_t_p(key_p) + +def sx_lag_port_group_get(handle, lag_id): + """ Get LAG members + + Args: + handle (sx_api_handle_t): SDK handle + lag_id (sx_port_log_id_t): LAG id + + Returns: + list : list of LAG members logical indices + """ + try: + lag_members = [] + port_count_p = new_uint32_t_p() + uint32_t_p_assign(port_count_p, 0) + port_arr = None + + rc = sx_api_lag_port_group_get(handle, 0, lag_id, port_arr, port_count_p) + sx_check_rc(rc) + + port_count = uint32_t_p_value(port_count_p) + if port_count > 0: + port_arr = new_sx_port_log_id_t_arr(port_count) + rc = sx_api_lag_port_group_get(handle, 0, lag_id, port_arr, port_count_p) + sx_check_rc(rc) + + for i in range(port_count): + lag_members.append(sx_port_log_id_t_arr_getitem(port_arr, i)) + + return lag_members + + finally: + delete_sx_port_log_id_t_arr(port_arr) + delete_uint32_t_p(port_count_p) + +def sx_vlan_ports_get(handle, vlan_id): + """ Get VLAN member ports + Args: + handle (sx_api_handle_t): SDK handle + vlan_id (sx_vid_t): VLAN id + + Returns: + list : list of VLAN members logical indexes + """ + try: + vlan_members = [] + port_cnt_p = new_uint32_t_p() + uint32_t_p_assign(port_cnt_p, 0) + + rc = sx_api_vlan_ports_get(handle, SWITCH_ID, vlan_id, None, port_cnt_p) + sx_check_rc(rc) + + port_cnt = uint32_t_p_value(port_cnt_p) + vlan_port_list_p = new_sx_vlan_ports_t_arr(port_cnt) + + rc = sx_api_vlan_ports_get(handle, SWITCH_ID, vlan_id, vlan_port_list_p, port_cnt_p) + sx_check_rc(rc) + + for i in range(0, port_cnt): + vlan_port = sx_vlan_ports_t_arr_getitem(vlan_port_list_p, i) + vlan_members.append(vlan_port.log_port) + + return vlan_members + + finally: + delete_sx_vlan_ports_t_arr(vlan_port_list_p) + delete_uint32_t_p(port_cnt_p) + +def sx_make_ip_prefix_v4(addr, mask): + """ Create IPv4 prefix + + Args: + addr (str): IPv4 address + mask (str): Network mask + + Returns: + sx_ip_prefix_t : IPv4 prefix + """ + ip_prefix = sx_ip_prefix_t() + ip_prefix.version = SX_IP_VERSION_IPV4 + ip_prefix.prefix.ipv4.addr.s_addr = struct.unpack('>I', socket.inet_pton(socket.AF_INET, addr))[0] + ip_prefix.prefix.ipv4.mask.s_addr = struct.unpack('>I', socket.inet_pton(socket.AF_INET, mask))[0] + + return ip_prefix + +def sx_make_ip_prefix_v6(addr, mask): + """ Create IPv6 prefix + + Args: + addr (str): IPv6 address + mask (str): Network mask + + Returns: + sx_ip_v6_prefix_t : IPv6 prefix + """ + addr = ipv6_str_to_bytes(str(addr)) + mask = ipv6_str_to_bytes(str(mask)) + + ip_prefix = sx_ip_prefix_t() + ip_prefix.version = SX_IP_VERSION_IPV6 + for i in range(0, 16): + uint8_t_arr_setitem(ip_prefix.prefix.ipv6.addr._in6_addr__in6_u._in6_addr___in6_u__u6_addr8, i, addr[i]) + uint8_t_arr_setitem(ip_prefix.prefix.ipv6.mask._in6_addr__in6_u._in6_addr___in6_u__u6_addr8, i, mask[i]) + + return ip_prefix + +def ipv6_str_to_bytes(address): + # Load the ipv6 string into 4 dwords + dwords = struct.unpack("!IIII", socket.inet_pton(socket.AF_INET6, address)) + # Convert dwords endian using ntohl + total_bytes = [socket.ntohl(i) for i in dwords] + # Finally, convert back to bytes + out = struct.pack(">IIII", total_bytes[0], total_bytes[1], total_bytes[2], total_bytes[3]) + return [i for i in out] + +def sx_ip_addr_to_str(ip_addr): + if ip_addr.version == SX_IP_VERSION_IPV4: + return socket.inet_ntop(socket.AF_INET, struct.pack('!I', ip_addr.addr.ipv4.s_addr)) + else: + bytes = ip_addr.addr.ipv6._in6_addr__in6_u._in6_addr___in6_u__u6_addr8 + byte_arr = [] + for i in range(0, 16): + byte_arr.append(uint8_t_arr_getitem(bytes, i)) + if sys.byteorder == "little": + dwords = struct.pack("!BBBBBBBBBBBBBBBB", byte_arr[3], byte_arr[2], byte_arr[1], byte_arr[0], byte_arr[7], + byte_arr[6], byte_arr[5], byte_arr[4], byte_arr[11], byte_arr[10], byte_arr[9], + byte_arr[8], byte_arr[15], byte_arr[14], byte_arr[13], byte_arr[12]) + else: + dwords = struct.pack("!BBBBBBBBBBBBBBBB", byte_arr[0], byte_arr[1], byte_arr[2], byte_arr[3], byte_arr[4], + byte_arr[5], byte_arr[6], byte_arr[7], byte_arr[8], byte_arr[9], byte_arr[10], + byte_arr[11], byte_arr[12], byte_arr[13], byte_arr[14], byte_arr[15]) + return socket.inet_ntop(socket.AF_INET6, dwords) diff --git a/platform/mellanox/docker-syncd-mlnx/ecmp_calculator/packet_scheme.py b/platform/mellanox/docker-syncd-mlnx/ecmp_calculator/packet_scheme.py new file mode 100755 index 000000000000..922669f42aaf --- /dev/null +++ b/platform/mellanox/docker-syncd-mlnx/ecmp_calculator/packet_scheme.py @@ -0,0 +1,140 @@ +#!/usr/bin/env python3 + +PACKET_SCHEME = { + "type" : "object", + "properties" : + { + "packet_info" : + { + "type" : "object", + "properties" : + { + "outer" : + { + "type" : "object", + "properties" : + { + "layer2" : + { + "type" : "object", + "properties" : + { + "smac": {"type": "string"}, + "dmac": {"type": "string"}, + "ethertype": {"type": "number"}, + "outer_vid": {"type": "number"}, + "outer_pcp": {"type": "number"}, + "outer_dei": {"type": "number"}, + "inner_vid": {"type": "number"}, + "inner_pcp": {"type": "number"}, + "inner_dei": {"type": "number"} + } + }, + "arp" : + { + "type" : "object", + "properties" : + { + "spa": {"type": "string"}, + "tpa": {"type": "string"} + } + }, + "ipv4" : + { + "type" : "object", + "properties" : + { + "sip": {"type": "string"}, + "dip": {"type": "string"}, + "proto": {"type": "number"} + }, + "required": ["dip"] + }, + "ipv6" : + { + "type" : "object", + "properties" : + { + "sip": {"type": "string"}, + "dip": {"type": "string"}, + "mflag": {"type": "number"}, + "next_header": {"type": "number"}, + "dscp": {"type": "number"}, + "ecn": {"type": "number"}, + "l3_length": {"type": "number"}, + "flow_label": {"type": "number"} + }, + "required": ["dip"] + }, + "tcp_udp" : + { + "type" : "object", + "properties" : + { + "sport": {"type": "number"}, + "dport": {"type": "number"} + } + }, + "vxlan_nvgre" : + { + "type" : "object", + "properties" : + { + "vni": {"type": "number"} + } + } + } + }, + "inner" : + { + "type" : "object", + "properties" : + { + "layer2" : + { + "type" : "object", + "properties" : + { + "smac": {"type": "string"}, + "dmac": {"type": "string"}, + "ethertype": {"type": "number"} + } + }, + "ipv4" : + { + "type" : "object", + "properties" : + { + "sip": {"type": "string"}, + "dip": {"type": "string"}, + "mflag": {"type": "number"}, + "proto": {"type": "number"} + } + }, + "ipv6" : + { + "type" : "object", + "properties" : + { + "sip": {"type": "string"}, + "dip": {"type": "string"}, + "mflag": {"type": "number"}, + "next_header": {"type": "number"}, + "flow_label": {"type": "number"} + } + }, + "tcp_udp" : + { + "type" : "object", + "properties" : + { + "sport": {"type": "number"}, + "dport": {"type": "number"} + } + } + } + } + } + } + } +} diff --git a/platform/mellanox/docker-syncd-mlnx/lib/port_utils.py b/platform/mellanox/docker-syncd-mlnx/lib/port_utils.py new file mode 100755 index 000000000000..f00d22d5426c --- /dev/null +++ b/platform/mellanox/docker-syncd-mlnx/lib/port_utils.py @@ -0,0 +1,183 @@ +#!/usr/bin/env python3 + +from python_sdk_api.sx_api import * +import inspect +import re + +DEVICE_ID = 1 +SWITCH_ID = 0 +PORT_TABLE = 'PORT' +FIRST_LANE_INDEX = 0 +ETHERNET_PREFIX = 'Ethernet' + +def get_ports_lanes_map(config_db): + """ Get lane number of the first lane in use by port for all existing ports. + + Args: + config_db (ConfigDBConnector): Config DB connector + + Returns: + dict: key is lane number of the first lane in use by port, value is SONiC port index (124 for Ethernet124) + """ + lanes_map = {} + config_db.connect() + + ports_table = config_db.get_table(PORT_TABLE) + if ports_table is None: + raise Exception("Can't read {} table".format(PORT_TABLE)) + + ports_table_keys = config_db.get_keys(PORT_TABLE) + for port in ports_table_keys: + port_data = ports_table.get(port) + if port_data is not None: + lanes = port_data.get('lanes') + first_lane = lanes.split(',')[FIRST_LANE_INDEX] + port_idx = re.sub(r"\D", "", port) + lanes_map[int(first_lane)] = int(port_idx) + + return lanes_map + +def get_port_max_width(handle): + """ Get max number of lanes in port according to chip type + + Args: + handle (sx_api_handle_t): SDK handle + + Returns: + int: max lanes in port + """ + # Get chip type + chip_type = sx_get_chip_type(handle) + + limits = rm_resources_t() + modes = rm_modes_t() + + rc = rm_chip_limits_get(chip_type, limits) + sx_check_rc(rc) + max_width = limits.port_map_width_max + + # SPC2 ports have 8 lanes but SONiC is using 4 + if chip_type == SX_CHIP_TYPE_SPECTRUM2: + max_width = 4 + + return max_width + +def sx_get_ports_map(handle, config_db): + """ Get ports map from SDK logical index to SONiC index + + Args: + handle (sx_api_handle_t): SDK handle + config_db (ConfigDBConnector): Config DB connector + + Returns: + dict: key is SDK logical index, value is SONiC index (4 for Ethernet4) + """ + try: + ports_map = {} + port_attributes_list = None + port_cnt_p = None + + # Get lanes map + lanes_map = get_ports_lanes_map(config_db) + + # Get max number of lanes in port + port_max_width = get_port_max_width(handle) + + # Get ports count + port_cnt_p = new_uint32_t_p() + rc = sx_api_port_device_get(handle, DEVICE_ID, SWITCH_ID, None, port_cnt_p) + sx_check_rc(rc) + + # Get ports + port_cnt = uint32_t_p_value(port_cnt_p) + port_attributes_list = new_sx_port_attributes_t_arr(port_cnt) + rc = sx_api_port_device_get(handle, DEVICE_ID, SWITCH_ID, port_attributes_list, port_cnt_p) + sx_check_rc(rc) + + for i in range(0, port_cnt): + port_attributes = sx_port_attributes_t_arr_getitem(port_attributes_list, i) + label_port = port_attributes.port_mapping.module_port + logical_port = port_attributes.log_port; + lane_bmap = port_attributes.port_mapping.lane_bmap; + + if (is_phy_port(port_attributes.log_port) == False): + continue + + # Calculate sonic index (sonic index=4 for Ethernet4) + lane_index = get_lane_index(lane_bmap, port_max_width) + assert lane_index != -1, "Failed to calculate port index" + + first_lane = label_port * port_max_width + lane_index; + sonic_index = lanes_map[first_lane] + + sonic_interface = ETHERNET_PREFIX + str(sonic_index) + ports_map[logical_port] = sonic_interface + + return ports_map + + finally: + delete_sx_port_attributes_t_arr(port_attributes_list) + delete_uint32_t_p(port_cnt_p) + +def sx_get_chip_type(handle): + """ Get system ASIC type + + Args: + handle (sx_api_handle_t): SDK handle + + Returns: + sx_chip_types_t: Chip type + """ + try: + device_info_cnt_p = new_uint32_t_p() + uint32_t_p_assign(device_info_cnt_p, 1) + device_info_cnt = uint32_t_p_value(device_info_cnt_p) + device_info_list_p = new_sx_device_info_t_arr(device_info_cnt) + + rc = sx_api_port_device_list_get(handle, device_info_list_p, device_info_cnt_p) + sx_check_rc(rc) + + device_info = sx_device_info_t_arr_getitem(device_info_list_p, SWITCH_ID) + chip_type = device_info.dev_type + if chip_type == SX_CHIP_TYPE_SPECTRUM_A1: + chip_type = SX_CHIP_TYPE_SPECTRUM + + return chip_type + + finally: + delete_sx_device_info_t_arr(device_info_list_p) + delete_uint32_t_p(device_info_cnt_p) + +def get_lane_index(lane_bmap, max_lanes): + """ Get index of first lane in use (2 for 00001100) + + Args: + lane_bmap (int): bitmap indicating module lanes in use + max_lanes (int): Max lanes in module + + Returns: + int: index of the first bit set to 1 in lane_bmap + """ + for lane_idx in range(0, max_lanes): + if (lane_bmap & 0x1 == 1): + return lane_idx + lane_bmap = lane_bmap >> 1 + +def sx_check_rc(rc): + if rc is not SX_STATUS_SUCCESS: + # Get the calling function name from the last frame + cf = inspect.currentframe().f_back + func_name = inspect.getframeinfo(cf).function + error_info = func_name + ' failed with rc = ' + str(rc) + + raise Exception(error_info) + +def get_port_type(log_port_id): + return (log_port_id & SX_PORT_TYPE_ID_MASK) >> SX_PORT_TYPE_ID_OFFS + +def is_phy_port(log_port_id): + return get_port_type(log_port_id) == SX_PORT_TYPE_NETWORK + +def is_lag(log_port_id): + return get_port_type(log_port_id) == SX_PORT_TYPE_LAG + diff --git a/platform/mellanox/docker-syncd-mlnx/platform_syncd_dump.sh b/platform/mellanox/docker-syncd-mlnx/platform_syncd_dump.sh new file mode 100755 index 000000000000..f5dc28647ff5 --- /dev/null +++ b/platform/mellanox/docker-syncd-mlnx/platform_syncd_dump.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +# +# Script for sai failure dump +# + +# Source the platform specific dump file + +sai_dump_name="sai_sdk_dump_$(date +"%m_%d_%Y_%I_%M_%p")" +sai_dump_path="${DUMPDIR}/$sai_dump_name" +mkdir -p $sai_dump_path +sai_dump_file="${sai_dump_path}/$sai_dump_name" +saisdkdump -f $sai_dump_file +cd "${DUMPDIR}" +tar -cvf "$sai_dump_name".tar $sai_dump_name +gzip "$sai_dump_name".tar +rm -rf $sai_dump_name + +# Update max failure dumps +if grep -q SAI_DUMP_STORE_AMOUNT /usr/share/sonic/hwsku/sai.profile; then + SAI_MAX_FAILURE_DUMPS=$(grep SAI_DUMP_STORE_AMOUNT /usr/share/sonic/hwsku/sai.profile | cut -d '=' -f2) +fi + diff --git a/platform/mellanox/fw.mk b/platform/mellanox/fw.mk index ebfec14fb6e2..1791df3c1b06 100644 --- a/platform/mellanox/fw.mk +++ b/platform/mellanox/fw.mk @@ -21,23 +21,28 @@ MLNX_FW_BASE_PATH = $(MLNX_SDK_BASE_PATH) # Place an URL here to FW if you want to download FW instead MLNX_FW_BASE_URL = -ifneq ($(MLNX_FW_BASE_URL), ) +SIMX_VERSION = 5.1-1065 + FW_FROM_URL = y -else -FW_FROM_URL = n + +MLNX_FW_ASSETS_RELEASE_TAG = fw-2010.4204 +MLNX_FW_ASSETS_URL = $(MLNX_ASSETS_GITHUB_URL)/releases/download/$(MLNX_FW_ASSETS_RELEASE_TAG) + +ifeq ($(MLNX_FW_BASE_URL), ) +MLNX_FW_BASE_URL = $(MLNX_FW_ASSETS_URL) endif -MLNX_SPC_FW_VERSION = 13.2010.3186 +MLNX_SPC_FW_VERSION = 13.2010.4204 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.2010.3186 +MLNX_SPC2_FW_VERSION = 29.2010.4204 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.2010.3186 +MLNX_SPC3_FW_VERSION = 30.2010.4204 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/hw-management.mk b/platform/mellanox/hw-management.mk index 0c8c8c1b548d..a12bd9b32aca 100644 --- a/platform/mellanox/hw-management.mk +++ b/platform/mellanox/hw-management.mk @@ -16,7 +16,7 @@ # # Mellanox HW Management -MLNX_HW_MANAGEMENT_VERSION = 7.0020.3006 +MLNX_HW_MANAGEMENT_VERSION = 7.0020.4104 export MLNX_HW_MANAGEMENT_VERSION 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 index 11539e606369..f7667ed6c4ea 100644 --- 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 @@ -1,8 +1,8 @@ -From 1a1011b6da491d35001df5a7204d4eecb2769767 Mon Sep 17 00:00:00 2001 +From 489764eb124e03087eb408dec27d769fa4f98459 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 +Subject: [PATCH 1/4] Make SONiC determine-reboot-cause service start after + hw-mgmt service Signed-off-by: Kebo Liu --- @@ -10,7 +10,7 @@ Signed-off-by: Kebo Liu 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 +index 8bdcaef..1c25ffb 100755 --- a/debian/hw-management.hw-management.service +++ b/debian/hw-management.hw-management.service @@ -1,6 +1,7 @@ @@ -22,5 +22,5 @@ index 39a2a54..2104b87 100755 [Service] Type=oneshot -- -1.9.1 +2.20.1 diff --git a/platform/mellanox/hw-management/0002-Disable-hw-mgmt-on-SimX-platforms.patch b/platform/mellanox/hw-management/0002-Disable-hw-mgmt-on-SimX-platforms.patch index c12474712b9b..61aab18090a2 100644 --- a/platform/mellanox/hw-management/0002-Disable-hw-mgmt-on-SimX-platforms.patch +++ b/platform/mellanox/hw-management/0002-Disable-hw-mgmt-on-SimX-platforms.patch @@ -1,59 +1,47 @@ -From 79dadd5b0d2f5e860b525c12d4d3843607b03a9f Mon Sep 17 00:00:00 2001 +From 422b64397f2f33b394d037820f0ceb4c09e3a725 Mon Sep 17 00:00:00 2001 From: Alexander Allen Date: Fri, 21 Jan 2022 16:47:19 +0000 -Subject: [PATCH] Disable hw-mgmt on SimX platforms +Subject: [PATCH 2/4] Disable hw-mgmt on SimX platforms --- - usr/usr/bin/hw-management-ready.sh | 31 ++++++++++++++++-------------- + usr/usr/bin/hw-management-ready.sh | 11 +++++++---- usr/usr/bin/hw-management.sh | 9 +++++++++ - 2 files changed, 26 insertions(+), 14 deletions(-) + 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/usr/usr/bin/hw-management-ready.sh b/usr/usr/bin/hw-management-ready.sh -index 5a9698c..364f906 100755 +index 88672a8..7558c68 100755 --- a/usr/usr/bin/hw-management-ready.sh +++ b/usr/usr/bin/hw-management-ready.sh -@@ -51,19 +51,22 @@ if [ -d /var/run/hw-management ]; then +@@ -51,17 +51,20 @@ if [ -d /var/run/hw-management ]; then rm -fr /var/run/hw-management fi -case $board_type in -VMOD0014) -- while [ ! -d /sys/devices/pci0000:00/0000:00:1f.0/NVSN2201:00/mlxreg-hotplug/hwmon ] -- do -- sleep 1 -- done -- ;; ++if [ -z "$(lspci -vvv | grep SimX)" ]; then ++ case $board_type in ++ VMOD0014) + if [ ! -d /sys/devices/pci0000:00/0000:00:1f.0/NVSN2201:00/mlxreg-hotplug/hwmon ]; then + timeout 180 bash -c 'until [ -d /sys/devices/pci0000:00/0000:00:1f.0/NVSN2201:00/mlxreg-hotplug/hwmon ]; do sleep 0.2; done' + fi + ;; -*) -- while [ ! -d /sys/devices/platform/mlxplat/mlxreg-hotplug/hwmon ] -- do -- sleep 1 -- done -- ;; ++ *) + if [ ! -d /sys/devices/platform/mlxplat/mlxreg-hotplug/hwmon ]; then + timeout 180 bash -c 'until [ -d /sys/devices/platform/mlxplat/mlxreg-hotplug/hwmon ]; do sleep 0.2; done' + fi + ;; -esac -+if [ -z "$(lspci -vvv | grep SimX)" ]; then -+ case $board_type in -+ VMOD0014) -+ while [ ! -d /sys/devices/pci0000:00/0000:00:1f.0/NVSN2201:00/mlxreg-hotplug/hwmon ] -+ do -+ sleep 1 -+ done -+ ;; -+ *) -+ while [ ! -d /sys/devices/platform/mlxplat/mlxreg-hotplug/hwmon ] -+ do -+ sleep 1 -+ done -+ ;; -+ esac ++ esac +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 ebfabb0..c0c038e 100755 +index 1ee05b5..50d922b 100755 --- a/usr/usr/bin/hw-management.sh +++ b/usr/usr/bin/hw-management.sh -@@ -1495,6 +1495,13 @@ do_chip_down() +@@ -2310,6 +2310,13 @@ do_chip_down() /usr/bin/hw-management-thermal-events.sh change hotplug_asic down %S %p } @@ -67,7 +55,7 @@ index ebfabb0..c0c038e 100755 __usage=" Usage: $(basename "$0") [Options] -@@ -1520,6 +1527,8 @@ Options: +@@ -2335,6 +2342,8 @@ Options: force-reload Performs hw-management 'stop' and the 'start. " @@ -77,5 +65,5 @@ index ebfabb0..c0c038e 100755 start) if [ -d /var/run/hw-management ]; then -- -2.17.1 +2.20.1 diff --git a/platform/mellanox/hw-management/0003-Remove-unused-non-upstream-kernel-modules-from-load.patch b/platform/mellanox/hw-management/0003-Remove-unused-non-upstream-kernel-modules-from-load.patch index 496085e9d4d8..ba83bf6764ee 100644 --- a/platform/mellanox/hw-management/0003-Remove-unused-non-upstream-kernel-modules-from-load.patch +++ b/platform/mellanox/hw-management/0003-Remove-unused-non-upstream-kernel-modules-from-load.patch @@ -1,14 +1,14 @@ -From 14b06a12802fc0e15116a64f419d002d0d21d695 Mon Sep 17 00:00:00 2001 +From 439639e939f896f9aee42a4dbd5216feb728220c Mon Sep 17 00:00:00 2001 From: Alexander Allen Date: Thu, 17 Feb 2022 04:19:50 +0000 -Subject: [PATCH] Remove unused non-upstream kernel modules from load +Subject: [PATCH 3/4] Remove unused non-upstream kernel modules from load --- usr/etc/modules-load.d/05-hw-management-modules.conf | 2 -- 1 file changed, 2 deletions(-) diff --git a/usr/etc/modules-load.d/05-hw-management-modules.conf b/usr/etc/modules-load.d/05-hw-management-modules.conf -index 39f621e..c0980bc 100644 +index cfcfaa4..dd3b5ca 100644 --- a/usr/etc/modules-load.d/05-hw-management-modules.conf +++ b/usr/etc/modules-load.d/05-hw-management-modules.conf @@ -15,8 +15,6 @@ xdpe12284 @@ -21,5 +21,5 @@ index 39f621e..c0980bc 100644 gpio-pca953x pmbus -- -2.17.1 +2.20.1 diff --git a/platform/mellanox/hw-management/0004-Make-system-health-service-starts-after-hw-managemen.patch b/platform/mellanox/hw-management/0004-Make-system-health-service-starts-after-hw-managemen.patch new file mode 100644 index 000000000000..5423cbb001c3 --- /dev/null +++ b/platform/mellanox/hw-management/0004-Make-system-health-service-starts-after-hw-managemen.patch @@ -0,0 +1,29 @@ +From 038bce6bf808ec9d082e96fec4184e060b3a85a9 Mon Sep 17 00:00:00 2001 +From: Stephen Sun +Date: Mon, 28 Nov 2022 03:55:14 +0000 +Subject: [PATCH 4/4] Make system-health service starts after hw-management to + avoid failures + +On SN2410, it can fail to read the file led_status_capability if it starts from ONIE + +Signed-off-by: Stephen Sun +--- + debian/hw-management.hw-management.service | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/debian/hw-management.hw-management.service b/debian/hw-management.hw-management.service +index 1c25ffb..0fbd877 100755 +--- a/debian/hw-management.hw-management.service ++++ b/debian/hw-management.hw-management.service +@@ -1,7 +1,7 @@ + [Unit] + Description=Chassis HW management service of Mellanox systems + Documentation=man:hw-management.service(8) +-Before=determine-reboot-cause.service ++Before=determine-reboot-cause.service system-health.service watchdog-control.service + + [Service] + Type=oneshot +-- +2.20.1 + diff --git a/platform/mellanox/hw-management/hw-mgmt b/platform/mellanox/hw-management/hw-mgmt index 137109ed15be..9c3f6b2d6ac4 160000 --- a/platform/mellanox/hw-management/hw-mgmt +++ b/platform/mellanox/hw-management/hw-mgmt @@ -1 +1 @@ -Subproject commit 137109ed15be147a99b59ceb9dfa1799688dfb71 +Subproject commit 9c3f6b2d6ac4be2eda936522f369ff8920deb4e2 diff --git a/platform/mellanox/mft.mk b/platform/mellanox/mft.mk index 047e87b09086..1c0efa6a3df3 100644 --- a/platform/mellanox/mft.mk +++ b/platform/mellanox/mft.mk @@ -16,10 +16,18 @@ # # Mellanox SAI -MFT_VERSION = 4.21.0 -MFT_REVISION = 100 +MFT_VERSION = 4.22.1 +MFT_REVISION = 15 -export MFT_VERSION MFT_REVISION +MLNX_MFT_INTERNAL_SOURCE_BASE_URL = + +ifneq ($(MLNX_MFT_INTERNAL_SOURCE_BASE_URL), ) +MFT_FROM_INTERNAL = y +else +MFT_FROM_INTERNAL = n +endif + +export MFT_VERSION MFT_REVISION MFT_FROM_INTERNAL MLNX_MFT_INTERNAL_SOURCE_BASE_URL MFT = mft_$(MFT_VERSION)-$(MFT_REVISION)_$(CONFIGURED_ARCH).deb $(MFT)_SRC_PATH = $(PLATFORM_PATH)/mft diff --git a/platform/mellanox/mft/Makefile b/platform/mellanox/mft/Makefile index 4c454028b0e0..3139e874cc08 100644 --- a/platform/mellanox/mft/Makefile +++ b/platform/mellanox/mft/Makefile @@ -27,6 +27,12 @@ endif MFT_NAME = mft-$(MFT_VERSION)-$(MFT_REVISION)-$(MFT_ARCH)-deb MFT_TGZ = $(MFT_NAME).tgz +ifeq ($(MFT_FROM_INTERNAL),y) +MFT_TGZ_URL = $(MLNX_MFT_INTERNAL_SOURCE_BASE_URL)$(MFT_TGZ) +else +MFT_TGZ_URL = http://www.mellanox.com/downloads/MFT/$(MFT_TGZ) +endif + SRC_DEB = kernel-mft-dkms_$(MFT_VERSION)-$(MFT_REVISION)_all.deb MOD_DEB = kernel-mft-dkms-modules-$(KVERSION)_$(MFT_VERSION)_$(CONFIGURED_ARCH).deb @@ -38,7 +44,7 @@ DKMS_TMP := $(shell mktemp -u -d -t dkms.XXXXXXXXXX) $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : rm -rf $(MFT_NAME) - wget -O $(MFT_TGZ) http://www.mellanox.com/downloads/MFT/$(MFT_TGZ) + wget -O $(MFT_TGZ) $(MFT_TGZ_URL) tar xzf $(MFT_TGZ) pushd $(MFT_NAME)/SDEBS diff --git a/platform/mellanox/mlnx-fw-upgrade.j2 b/platform/mellanox/mlnx-fw-upgrade.j2 index e17ec176503c..676d07cf3e49 100755 --- a/platform/mellanox/mlnx-fw-upgrade.j2 +++ b/platform/mellanox/mlnx-fw-upgrade.j2 @@ -32,12 +32,13 @@ declare -r UNKN_ASIC="unknown" declare -r UNKN_MST="unknown" declare -rA FW_FILE_MAP=( \ - [$SPC1_ASIC]="/etc/mlnx/fw-SPC.mfa" \ - [$SPC2_ASIC]="/etc/mlnx/fw-SPC2.mfa" \ - [$SPC3_ASIC]="/etc/mlnx/fw-SPC3.mfa" \ + [$SPC1_ASIC]="fw-SPC.mfa" \ + [$SPC2_ASIC]="fw-SPC2.mfa" \ + [$SPC3_ASIC]="fw-SPC3.mfa" \ ) IMAGE_UPGRADE="${NO_PARAM}" +SYSLOG_LOGGER="${NO_PARAM}" VERBOSE_LEVEL="${VERBOSE_MIN}" function PrintHelp() { @@ -46,7 +47,8 @@ function PrintHelp() { echo echo "OPTIONS:" echo " -u, --upgrade Upgrade ASIC firmware using next boot image (useful after SONiC-To-SONiC update)" - echo " -v, --verbose Verbose mode" + echo " -s, --syslog Use syslog logger (enabled when -u|--upgrade)" + echo " -v, --verbose Verbose mode (enabled when -u|--upgrade)" echo " -h, --help Print help" echo echo "Examples:" @@ -61,10 +63,14 @@ function ParseArguments() { case "$1" in -u|--upgrade) IMAGE_UPGRADE="${YES_PARAM}" + SYSLOG_LOGGER="${YES_PARAM}" ;; -v|--verbose) VERBOSE_LEVEL="${VERBOSE_MAX}" ;; + -s|--syslog) + SYSLOG_LOGGER="${YES_PARAM}" + ;; -h|--help) PrintHelp exit "${EXIT_SUCCESS}" @@ -77,6 +83,11 @@ function ParseArguments() { function LogError() { if [[ "${VERBOSE_LEVEL}" -ge "${VERBOSE_ERROR}" ]]; then echo "ERROR: $*" + logger -p "ERROR" -t "${SCRIPT_NAME}" "$*" + fi + + if [[ "${SYSLOG_LOGGER}" = "${YES_PARAM}" ]]; then + logger -p "ERROR" -t "${SCRIPT_NAME}" "$*" fi } @@ -84,18 +95,30 @@ function LogWarning() { if [[ "${VERBOSE_LEVEL}" -ge "${VERBOSE_WARNING}" ]]; then echo "WARNING: $*" fi + + if [[ "${SYSLOG_LOGGER}" = "${YES_PARAM}" ]]; then + logger -p "WARNING" -t "${SCRIPT_NAME}" "$*" + fi } function LogNotice() { if [[ "${VERBOSE_LEVEL}" -ge "${VERBOSE_NOTICE}" ]]; then echo "NOTICE: $*" fi + + if [[ "${SYSLOG_LOGGER}" = "${YES_PARAM}" ]]; then + logger -p "NOTICE" -t "${SCRIPT_NAME}" "$*" + fi } function LogInfo() { if [[ "${VERBOSE_LEVEL}" -ge "${VERBOSE_INFO}" ]]; then echo "INFO: $*" fi + + if [[ "${SYSLOG_LOGGER}" = "${YES_PARAM}" ]]; then + logger -p "INFO" -t "${SCRIPT_NAME}" "$*" + fi } function ExitFailure() { @@ -180,18 +203,35 @@ function RunCmd() { fi } +function RunFwUpdateCmd() { + local ERROR_CODE="${EXIT_SUCCESS}" + local COMMAND="${BURN_CMD} $@" + + if [[ "${VERBOSE_LEVEL}" -eq "${VERBOSE_MAX}" ]]; then + output=$(eval "${COMMAND}") + else + output=$(eval "${COMMAND}") >/dev/null 2>&1 + fi + + ERROR_CODE="$?" + if [[ "${ERROR_CODE}" != "${EXIT_SUCCESS}" ]]; then + failure_msg="${output#*Fail : }" + ExitFailure "FW Update command: ${COMMAND} failed with error: ${failure_msg}" + fi +} + function UpgradeFW() { - local -r _FS_MOUNTPOINT="$1" + local -r _FW_BIN_PATH="$1" local -r _ASIC_TYPE="$(GetAsicType)" if [[ "${_ASIC_TYPE}" = "${UNKN_ASIC}" ]]; then ExitFailure "failed to detect ASIC type" fi - if [ ! -z "${_FS_MOUNTPOINT}" ]; then - local -r _FW_FILE="${_FS_MOUNTPOINT}/${FW_FILE_MAP[$_ASIC_TYPE]}" + if [ ! -z "${_FW_BIN_PATH}" ]; then + local -r _FW_FILE="${_FW_BIN_PATH}/${FW_FILE_MAP[$_ASIC_TYPE]}" else - local -r _FW_FILE="${FW_FILE_MAP[$_ASIC_TYPE]}" + local -r _FW_FILE="/etc/mlnx/${FW_FILE_MAP[$_ASIC_TYPE]}" fi if [ ! -f "${_FW_FILE}" ]; then @@ -223,9 +263,9 @@ function UpgradeFW() { 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}" + RunFwUpdateCmd "-i ${_FW_FILE}" else - RunCmd "${BURN_CMD} -d ${_MST_DEVICE} -i ${_FW_FILE}" + RunFwUpdateCmd "-d ${_MST_DEVICE} -i ${_FW_FILE}" fi fi } @@ -234,16 +274,29 @@ function UpgradeFWFromImage() { local -r _NEXT_SONIC_IMAGE="$(sonic-installer list | grep "Next: " | cut -f2 -d' ')" local -r _CURRENT_SONIC_IMAGE="$(sonic-installer list | grep "Current: " | cut -f2 -d' ')" - local -r _FS_PATH="/host/image-${_NEXT_SONIC_IMAGE#SONiC-OS-}/fs.squashfs" - local -r _FS_MOUNTPOINT="/tmp/image-${_NEXT_SONIC_IMAGE#SONiC-OS-}-fs" - if [[ "${_CURRENT_SONIC_IMAGE}" == "${_NEXT_SONIC_IMAGE}" ]]; then ExitSuccess "firmware is up to date" + fi + + # /host/image-/platform/fw/asic is now the new location for FW binaries. + # Prefere this path and if it does not exist use squashfs as a fallback. + local -r _PLATFORM_FW_BIN_PATH="/host/image-${_NEXT_SONIC_IMAGE#SONiC-OS-}/platform/fw/asic/" + + if [[ -d "${_PLATFORM_FW_BIN_PATH}" ]]; then + LogInfo "Using FW binaries from ${_PLATFORM_FW_BIN_PATH}" + + UpgradeFW "${_PLATFORM_FW_BIN_PATH}" else + local -r _FS_PATH="/host/image-${_NEXT_SONIC_IMAGE#SONiC-OS-}/fs.squashfs" + local -r _FS_MOUNTPOINT="/tmp/image-${_NEXT_SONIC_IMAGE#SONiC-OS-}-fs" + local -r _FW_BIN_PATH="${_FS_MOUNTPOINT}/etc/mlnx/" + + LogInfo "Using FW binaries from ${_FW_BIN_PATH}" + mkdir -p "${_FS_MOUNTPOINT}" mount -t squashfs "${_FS_PATH}" "${_FS_MOUNTPOINT}" - UpgradeFW "${_FS_MOUNTPOINT}" + UpgradeFW "${_FW_BIN_PATH}" umount -rf "${_FS_MOUNTPOINT}" rm -rf "${_FS_MOUNTPOINT}" diff --git a/platform/mellanox/mlnx-platform-api.mk b/platform/mellanox/mlnx-platform-api.mk index ecd8b8532e6d..a8846e26f855 100644 --- a/platform/mellanox/mlnx-platform-api.mk +++ b/platform/mellanox/mlnx-platform-api.mk @@ -21,6 +21,7 @@ SONIC_PLATFORM_API_PY3 = mlnx_platform_api-1.0-py3-none-any.whl $(SONIC_PLATFORM_API_PY3)_SRC_PATH = $(PLATFORM_PATH)/mlnx-platform-api $(SONIC_PLATFORM_API_PY3)_PYTHON_VERSION = 3 $(SONIC_PLATFORM_API_PY3)_DEPENDS = $(SONIC_PY_COMMON_PY3) $(SONIC_PLATFORM_COMMON_PY3) $(SONIC_CONFIG_ENGINE_PY3) $(SONIC_PLATFORM_API_PY2) +$(SONIC_PLATFORM_API_PY3)_DEBS_DEPENDS = $(PYTHON3_SWSSCOMMON) SONIC_PYTHON_WHEELS += $(SONIC_PLATFORM_API_PY3) export mlnx_platform_api_py3_wheel_path="$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_PLATFORM_API_PY3))" diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/chassis.py b/platform/mellanox/mlnx-platform-api/sonic_platform/chassis.py index 96a7b9e2315a..e13b90d6c0ca 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/chassis.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/chassis.py @@ -30,6 +30,7 @@ from .utils import extract_RJ45_ports_index from . import utils from .device_data import DeviceDataManager + import re except ImportError as e: raise ImportError (str(e) + "- required module not found") @@ -61,6 +62,10 @@ REBOOT_CAUSE_FILE_LENGTH = 1 +REBOOT_TYPE_KEXEC_FILE = "/proc/cmdline" +REBOOT_TYPE_KEXEC_PATTERN_WARM = ".*SONIC_BOOT_TYPE=(warm|fastfast).*" +REBOOT_TYPE_KEXEC_PATTERN_FAST = ".*SONIC_BOOT_TYPE=(fast|fast-reboot).*" + # Global logger class instance logger = Logger() @@ -736,6 +741,18 @@ def initialize_reboot_cause(self): self.reboot_by_software = 'reset_sw_reset' self.reboot_cause_initialized = True + def _parse_warmfast_reboot_from_proc_cmdline(self): + if os.path.isfile(REBOOT_TYPE_KEXEC_FILE): + with open(REBOOT_TYPE_KEXEC_FILE) as cause_file: + cause_file_kexec = cause_file.readline() + m = re.search(REBOOT_TYPE_KEXEC_PATTERN_WARM, cause_file_kexec) + if m and m.group(1): + return 'warm-reboot' + m = re.search(REBOOT_TYPE_KEXEC_PATTERN_FAST, cause_file_kexec) + if m and m.group(1): + return 'fast-reboot' + return None + def get_reboot_cause(self): """ Retrieves the cause of the previous reboot @@ -748,6 +765,14 @@ def get_reboot_cause(self): to pass a description of the reboot cause. """ #read reboot causes files in the following order + + # To avoid the leftover hardware reboot cause confusing the reboot cause determine service + # Skip the hardware reboot cause check if warm/fast reboot cause found from cmdline + if utils.is_host(): + reboot_cause = self._parse_warmfast_reboot_from_proc_cmdline() + if reboot_cause: + return self.REBOOT_CAUSE_NON_HARDWARE, '' + if not self.reboot_cause_initialized: self.initialize_reboot_cause() diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/eeprom.py b/platform/mellanox/mlnx-platform-api/sonic_platform/eeprom.py index 17f14b04430f..f5b13f0ae4a5 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/eeprom.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/eeprom.py @@ -31,13 +31,13 @@ raise ImportError (str(e) + "- required module not found") from .device_data import DeviceDataManager -from .utils import default_return, is_host +from .utils import default_return, is_host, wait_until logger = Logger() # # this is mlnx-specific -# should this be moved to chass.py or here, which better? +# should this be moved to chassis.py or here, which better? # EEPROM_SYMLINK = "/var/run/hw-management/eeprom/vpd_info" platform_name = DeviceDataManager.get_platform_name() @@ -51,10 +51,12 @@ os.makedirs(os.path.dirname(EEPROM_SYMLINK)) subprocess.check_call(['/usr/bin/xxd', '-r', '-p', 'syseeprom.hex', EEPROM_SYMLINK], cwd=platform_path) +WAIT_EEPROM_READY_SEC = 10 + class Eeprom(eeprom_tlvinfo.TlvInfoDecoder): def __init__(self): - if not os.path.exists(EEPROM_SYMLINK): + if not wait_until(predict=os.path.exists, timeout=WAIT_EEPROM_READY_SEC, path=EEPROM_SYMLINK): logger.log_error("Nowhere to read syseeprom from! No symlink found") raise RuntimeError("No syseeprom symlink found") diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/module.py b/platform/mellanox/mlnx-platform-api/sonic_platform/module.py index 8cd6ffa9b8db..765314d7baf0 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/module.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/module.py @@ -93,7 +93,7 @@ def get_position_in_parent(self): def is_replaceable(self): return True - def get_oper_status(self): # TODO: read from DB? + def get_oper_status(self): if utils.read_int_from_file('/run/hw-management/system/lc{}_active'.format(self.slot_id)) == 1: return ModuleBase.MODULE_STATUS_ONLINE elif utils.read_int_from_file('/run/hw-management/system/lc{}_present'.format(self.slot_id)) == 1: @@ -105,7 +105,7 @@ def get_oper_status(self): # TODO: read from DB? def _check_state(self): """Check Module status change: - 1. If status sysfs file value has been changed TODO: read from DB? + 1. If status sysfs file value has been changed 2. If sequence NO has been changed which means line card has been removed and inserted again. """ seq_no = self._get_seq_no() @@ -140,7 +140,7 @@ def initialize_thermals(self): self._check_state() if self.current_state == Module.STATE_ACTIVATED and not self._thermal_list: from .thermal import initialize_linecard_thermals - self._thermal_list = initialize_linecard_thermals(self.get_name(), self.slot_id) # TODO: add presence_cb? + self._thermal_list = initialize_linecard_thermals(self.get_name(), self.slot_id) def get_num_thermals(self): """ @@ -192,7 +192,7 @@ def initialize_single_sfp(self, index): if index < sfp_count: if not self._sfp_list: self._sfp_list = [None] * sfp_count - + if not self._sfp_list[index]: self._sfp_list[index] = self._create_sfp_object(index) self.sfp_initialized_count += 1 @@ -220,7 +220,7 @@ def get_num_sfps(self): """ if self.sfp_count == 0: self.sfp_count = DeviceDataManager.get_linecard_sfp_count(self.slot_id) - return self.sfp_count + return self.sfp_count def get_all_sfps(self): """ diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/psu.py b/platform/mellanox/mlnx-platform-api/sonic_platform/psu.py index e447bbb43565..521183ca1f19 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/psu.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/psu.py @@ -84,8 +84,8 @@ def get_voltage(self): Retrieves current PSU voltage output Returns: - A float number, the output voltage in volts, - e.g. 12.1 + A float number, the output voltage in volts, + e.g. 12.1 """ return None @@ -143,7 +143,7 @@ def get_power_available_status(self): Gets the power available status Returns: - True if power is present and power on. + True if power is present and power on. False and "absence of PSU" if power is not present. False and "absence of power" if power is present but not power on. """ @@ -176,7 +176,7 @@ def get_temperature(self): Returns: A float number of current temperature in Celsius up to nearest thousandth - of one degree Celsius, e.g. 30.125 + of one degree Celsius, e.g. 30.125 """ return None @@ -195,8 +195,8 @@ def get_input_voltage(self): Retrieves current PSU voltage input Returns: - A float number, the input voltage in volts, - e.g. 12.1 + A float number, the input voltage in volts, + e.g. 12.1 """ return None @@ -216,6 +216,11 @@ class Psu(FixedPsu): PSU_VPD = "eeprom/psu{}_vpd" PSU_CURRENT_IN = "power/psu{}_curr_in" PSU_VOLT_IN = "power/psu{}_volt_in" + PORT_AMBIENT_TEMP = os.path.join(PSU_PATH, "thermal/port_amb") + FAN_AMBIENT_TEMP = os.path.join(PSU_PATH, "thermal/fan_amb") + AMBIENT_TEMP_CRITICAL_THRESHOLD = os.path.join(PSU_PATH, "config/amb_tmp_crit_limit") + AMBIENT_TEMP_WARNING_THRESHOLD = os.path.join(PSU_PATH, "config/amb_tmp_warn_limit") + PSU_POWER_SLOPE = os.path.join(PSU_PATH, "config/psu{}_power_slope") shared_led = None @@ -235,9 +240,13 @@ def __init__(self, psu_index): self.psu_power_max = self.psu_power + "_max" self.psu_presence = os.path.join(PSU_PATH, "thermal/psu{}_status".format(self.index)) + self.psu_power_max_capacity = os.path.join(PSU_PATH, "config/psu{}_power_capacity".format(self.index)) + self.psu_temp = os.path.join(PSU_PATH, 'thermal/psu{}_temp'.format(self.index)) self.psu_temp_threshold = os.path.join(PSU_PATH, 'thermal/psu{}_temp_max'.format(self.index)) + self.psu_power_slope = os.path.join(PSU_PATH, self.PSU_POWER_SLOPE.format(self.index)) + from .fan import PsuFan self._fan_list.append(PsuFan(psu_index, 1, self)) @@ -257,7 +266,7 @@ def psu_voltage(self): psu_voltage_out = os.path.join(PSU_PATH, "power/psu{}_volt".format(self.index)) if os.path.exists(psu_voltage_out): self._psu_voltage = psu_voltage_out - + return self._psu_voltage @property @@ -329,12 +338,10 @@ def get_voltage(self): Retrieves current PSU voltage output Returns: - A float number, the output voltage in volts, - e.g. 12.1 + A float number, the output voltage in volts, + e.g. 12.1 """ if self.get_powergood_status() and self.psu_voltage: - # TODO: should we put log_func=None here? If not do this, when a PSU is back to power, some PSU related - # sysfs may not ready, read_int_from_file would encounter exception and log an error. voltage = utils.read_int_from_file(self.psu_voltage, log_func=logger.log_info) return float(voltage) / 1000 return None @@ -398,7 +405,7 @@ def get_temperature(self): Returns: A float number of current temperature in Celsius up to nearest thousandth - of one degree Celsius, e.g. 30.125 + of one degree Celsius, e.g. 30.125 """ if self.get_powergood_status(): temp = utils.read_int_from_file(self.psu_temp, log_func=logger.log_info) @@ -485,8 +492,8 @@ def get_input_voltage(self): Retrieves current PSU voltage input Returns: - A float number, the input voltage in volts, - e.g. 12.1 + A float number, the input voltage in volts, + e.g. 12.1 """ if self.get_powergood_status(): voltage = utils.read_int_from_file(self.psu_voltage_in, log_func=logger.log_info) @@ -505,14 +512,64 @@ def get_input_current(self): return float(amperes) / 1000 return None + def _get_psu_power_threshold(self, temp_threshold_path): + """ + Calculate power threshold for a PSU according to the maximum power capacity and ambient temperature + amb_temp = min(port_amb, fan_amb) + If amb_temp < ambient_temp_threshold + threshold = max capacity + else + threshold = max capacity - slope*(amb_temp - ambient_temp_threshold) + """ + if self.get_powergood_status(): + if os.path.exists(self.psu_power_max_capacity): + power_max_capacity = utils.read_int_from_file(self.psu_power_max_capacity) + temp_threshold = utils.read_int_from_file(temp_threshold_path) + fan_ambient_temp = utils.read_int_from_file(Psu.FAN_AMBIENT_TEMP) + port_ambient_temp = utils.read_int_from_file(Psu.PORT_AMBIENT_TEMP) + ambient_temp = min(fan_ambient_temp, port_ambient_temp) + if ambient_temp < temp_threshold: + power_threshold = power_max_capacity + else: + slope = utils.read_int_from_file(self.psu_power_slope) + power_threshold = power_max_capacity - (ambient_temp - temp_threshold) * slope + if power_threshold <= 0: + logger.log_warning('Got negative PSU power threshold {} for {}'.format(power_threshold, self.get_name())) + power_threshold = 0 + return float(power_threshold) / 1000000 + + return None + + def get_psu_power_warning_suppress_threshold(self): + """ + Retrieve the warning suppress threshold of the power on this PSU + The value can be volatile, so the caller should call the API each time it is used. + On Mellanox platform, it is translated from the `warning threshold` + + Returns: + A float number, the warning suppress threshold of the PSU in watts. + """ + return self._get_psu_power_threshold(Psu.AMBIENT_TEMP_WARNING_THRESHOLD) + + def get_psu_power_critical_threshold(self): + """ + Retrieve the critical threshold of the power on this PSU + The value can be volatile, so the caller should call the API each time it is used. + + Returns: + A float number, the critical threshold of the PSU in watts. + """ + return self._get_psu_power_threshold(Psu.AMBIENT_TEMP_CRITICAL_THRESHOLD) + + class InvalidPsuVolWA: - """This class is created as a workaround for a known hardware issue that the PSU voltage threshold could be a + """This class is created as a workaround for a known hardware issue that the PSU voltage threshold could be a invalid value 127998. Once we read a voltage threshold value equal to 127998, we should do following: 1. Check the PSU vendor, it should be Delta 2. Generate a temp sensor configuration file which contains a few set commands. Those set commands are the WA provided by low level team. 3. Call "sensors -s -c " 4. Wait for it to take effect - + This issue is found on 3700, 3700c, 3800, 4600c """ diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py b/platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py index 2ca37fcefdfc..aa12c19bb170 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py @@ -89,7 +89,6 @@ REGISTER_NUM = 1 DEVICE_ID = 1 SWITCH_ID = 0 -SX_PORT_ATTR_ARR_SIZE = 64 PMAOS_ASE = 1 PMAOS_EE = 1 @@ -345,7 +344,7 @@ def _read_eeprom(self, offset, num_bytes, log_on_error=True): raise IOError(f'errno = {os.strerror(ctypes.get_errno())}') except (OSError, IOError) as e: if log_on_error: - logger.log_error(f'Failed to read sfp={self.sdk_index} EEPROM page={page}, page_offset={page_offset}, \ + logger.log_warning(f'Failed to read sfp={self.sdk_index} EEPROM page={page}, page_offset={page_offset}, \ size={num_bytes}, offset={offset}, error = {e}') return None @@ -529,9 +528,13 @@ def set_port_admin_status_by_log_port(cls, sdk_handle, log_port, admin_status): @classmethod def get_logical_ports(cls, sdk_handle, sdk_index, slot_id): # Get all the ports related to the sfp, if port admin status is up, put it to list - port_attributes_list = new_sx_port_attributes_t_arr(SX_PORT_ATTR_ARR_SIZE) port_cnt_p = new_uint32_t_p() - uint32_t_p_assign(port_cnt_p, SX_PORT_ATTR_ARR_SIZE) + uint32_t_p_assign(port_cnt_p, 0) + rc = sx_api_port_device_get(sdk_handle, DEVICE_ID, SWITCH_ID, None, port_cnt_p) + + assert rc == SX_STATUS_SUCCESS, "sx_api_port_device_get failed, rc = %d" % rc + port_cnt = uint32_t_p_value(port_cnt_p) + port_attributes_list = new_sx_port_attributes_t_arr(port_cnt) rc = sx_api_port_device_get(sdk_handle, DEVICE_ID , SWITCH_ID, port_attributes_list, port_cnt_p) assert rc == SX_STATUS_SUCCESS, "sx_api_port_device_get failed, rc = %d" % rc 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 eec88e1786df..c390e9a4d341 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/sfp_event.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/sfp_event.py @@ -332,11 +332,9 @@ def on_pmpe(self, fd_p): pkt = new_uint8_t_arr(pkt_size) recv_info_p = new_sx_receive_info_t_p() pmpe_t = sx_event_pmpe_t() - port_attributes_list = new_sx_port_attributes_t_arr(64) port_cnt_p = new_uint32_t_p() - uint32_t_p_assign(port_cnt_p,64) + uint32_t_p_assign(port_cnt_p, 0) label_port_list = [] - label_port = None module_state = 0 rc = sx_lib_host_ifc_recv(fd_p, pkt, pkt_size_p, recv_info_p) @@ -352,31 +350,44 @@ def on_pmpe(self, fd_p): module_state = pmpe_t.module_state error_type = pmpe_t.error_type module_id = pmpe_t.module_id - slot_id = pmpe_t.slot_id # For non-modular chassis, it should return 0 + slot_id = pmpe_t.slot_id # For non-modular chassis, it should return 0 if module_state == SDK_SFP_STATE_ERR: logger.log_error("Receive PMPE error event on module {}: status {} error type {}".format(module_id, module_state, error_type)) elif module_state == SDK_SFP_STATE_DIS: - logger.log_info("Receive PMPE disable event on module {}: status {}".format(module_id, module_state)) + logger.log_notice("Receive PMPE disable event on module {}: status {}".format(module_id, module_state)) elif module_state == SDK_SFP_STATE_IN or module_state == SDK_SFP_STATE_OUT: - logger.log_info("Receive PMPE plug in/out event on module {}: status {}".format(module_id, module_state)) + logger.log_notice("Receive PMPE plug in/out event on module {}: status {}".format(module_id, module_state)) elif module_state == SDK_SFP_STATE_UNKNOWN: unknown = True else: logger.log_error("Receive PMPE unknown event on module {}: status {}".format(module_id, module_state)) - for i in range(port_list_size): - logical_port = sx_port_log_id_t_arr_getitem(logical_port_list, i) - rc = sx_api_port_device_get(self.handle, 1 , 0, port_attributes_list, port_cnt_p) + # Call sx_api_port_device_get with port_cnt_p=0, SDK will return the logical port number + rc = sx_api_port_device_get(self.handle, 1, 0, None, port_cnt_p) + if rc != SX_STATUS_SUCCESS: + logger.log_error("Failed to get logical port number") + status = False + else: port_cnt = uint32_t_p_value(port_cnt_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: - label_port = slot_id * DeviceDataManager.get_linecard_max_port_count() + port_attributes.port_mapping.module_port - break - - if label_port is not None: - label_port_list.append(label_port) + port_attributes_list = new_sx_port_attributes_t_arr(port_cnt) + rc = sx_api_port_device_get(self.handle, 1, 0, port_attributes_list, port_cnt_p) + if rc != SX_STATUS_SUCCESS: + logger.log_error("Failed to get logical port attributes") + status = False + else: + for i in range(port_list_size): + label_port = None + logical_port = sx_port_log_id_t_arr_getitem(logical_port_list, i) + for j in range(port_cnt): + port_attributes = sx_port_attributes_t_arr_getitem(port_attributes_list,j) + if port_attributes.log_port == logical_port: + label_port = slot_id * DeviceDataManager.get_linecard_max_port_count() + port_attributes.port_mapping.module_port + break + + if label_port is not None: + label_port_list.append(label_port) + delete_sx_port_attributes_t_arr(port_attributes_list) if unknown: SFP_ports_with_unknown_event = set(label_port_list) - self.RJ45_port_set @@ -389,7 +400,9 @@ def on_pmpe(self, fd_p): delete_uint32_t_p(pkt_size_p) delete_uint8_t_arr(pkt) delete_sx_receive_info_t_p(recv_info_p) - delete_sx_port_attributes_t_arr(port_attributes_list) delete_uint32_t_p(port_cnt_p) + if not label_port_list: + logger.log_error('Dropping PMPE event due to label port not found') + return status, label_port_list, module_state, error_type diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/utils.py b/platform/mellanox/mlnx-platform-api/sonic_platform/utils.py index 2bc312cd2234..83063b5c368e 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/utils.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/utils.py @@ -19,6 +19,7 @@ import subprocess import json import sys +import time import os from sonic_py_common import device_info from sonic_py_common.logger import Logger @@ -186,17 +187,8 @@ def is_host(): Test whether current process is running on the host or an docker return True for host and False for docker """ - try: - proc = subprocess.Popen(["docker", "--version"], - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - universal_newlines=True) - stdout = proc.communicate()[0] - proc.wait() - result = stdout.rstrip('\n') - return result != '' - except OSError as e: - return False + docker_env_file = '/.dockerenv' + return os.path.exists(docker_env_file) is False def default_return(return_value, log_func=logger.log_debug): @@ -275,3 +267,21 @@ def extract_RJ45_ports_index(): return RJ45_port_index_list if bool(RJ45_port_index_list) else None + +def wait_until(predict, timeout, interval=1, *args, **kwargs): + """Wait until a condition become true + + Args: + predict (object): a callable such as function, lambda + timeout (int): wait time in seconds + interval (int, optional): interval to check the predict. Defaults to 1. + + Returns: + _type_: _description_ + """ + while timeout > 0: + if predict(*args, **kwargs): + return True + time.sleep(interval) + timeout -= interval + return False diff --git a/platform/mellanox/mlnx-platform-api/tests/test_chassis.py b/platform/mellanox/mlnx-platform-api/tests/test_chassis.py index 2aa4f78855f3..cffdd437695f 100644 --- a/platform/mellanox/mlnx-platform-api/tests/test_chassis.py +++ b/platform/mellanox/mlnx-platform-api/tests/test_chassis.py @@ -224,6 +224,35 @@ def read_int_from_file(file_path, *args, **kwargs): assert minor == value mock_file_content[file_path] = 0 + utils.is_host = mock.MagicMock(return_value=True) + chassis._parse_warmfast_reboot_from_proc_cmdline = mock.MagicMock(return_value='warm-reboot') + for key, value in chassis.reboot_major_cause_dict.items(): + file_path = os.path.join(REBOOT_CAUSE_ROOT, key) + mock_file_content[file_path] = 1 + major, minor = chassis.get_reboot_cause() + assert major == chassis.REBOOT_CAUSE_NON_HARDWARE + assert minor == '' + mock_file_content[file_path] = 0 + + for key, value in chassis.reboot_minor_cause_dict.items(): + file_path = os.path.join(REBOOT_CAUSE_ROOT, key) + mock_file_content[file_path] = 1 + major, minor = chassis.get_reboot_cause() + assert major == chassis.REBOOT_CAUSE_NON_HARDWARE + assert minor == value + mock_file_content[file_path] = 0 + + def test_parse_warmfast_reboot_from_proc_cmdline(self): + chassis = Chassis() + with mock.patch("builtins.open", mock.mock_open(read_data="SONIC_BOOT_TYPE=warm")): + assert chassis._parse_warmfast_reboot_from_proc_cmdline() == "warm-reboot" + + with mock.patch("builtins.open", mock.mock_open(read_data="SONIC_BOOT_TYPE=fast")): + assert chassis._parse_warmfast_reboot_from_proc_cmdline() == "fast-reboot" + + with mock.patch("builtins.open", mock.mock_open(read_data="SONIC_BOOT_TYPE=None")): + assert chassis._parse_warmfast_reboot_from_proc_cmdline() == None + def test_module(self): from sonic_platform.chassis import ModularChassis # Test get_num_modules, it should not create any SFP objects diff --git a/platform/mellanox/mlnx-platform-api/tests/test_eeprom.py b/platform/mellanox/mlnx-platform-api/tests/test_eeprom.py index 5f0a30dbf519..b07f9327d098 100644 --- a/platform/mellanox/mlnx-platform-api/tests/test_eeprom.py +++ b/platform/mellanox/mlnx-platform-api/tests/test_eeprom.py @@ -49,6 +49,7 @@ def test_chassis_eeprom(self, mock_eeprom_info): assert chassis.get_serial() == 'MT2019X13878' assert chassis.get_system_eeprom_info() == mock_eeprom_info.return_value + @patch('sonic_platform.eeprom.wait_until', MagicMock(return_value=False)) def test_eeprom_init(self): # Test symlink not exist, there is an exception with pytest.raises(RuntimeError): @@ -83,7 +84,7 @@ def side_effect(key, field): @patch('os.path.exists', MagicMock(return_value=True)) @patch('os.path.islink', MagicMock(return_value=True)) - def test_get_system_eeprom_info_from_hardware(self): + def test_get_system_eeprom_info_from_hardware(self): eeprom = Eeprom() eeprom.p = os.path.join(test_path, 'mock_eeprom_data') eeprom._redis_hget = MagicMock() diff --git a/platform/mellanox/mlnx-platform-api/tests/test_psu.py b/platform/mellanox/mlnx-platform-api/tests/test_psu.py index d92b8f716a6d..00c3bc8623a7 100644 --- a/platform/mellanox/mlnx-platform-api/tests/test_psu.py +++ b/platform/mellanox/mlnx-platform-api/tests/test_psu.py @@ -161,3 +161,58 @@ def get_entry_value(key): vpd_info[InvalidPsuVolWA.CAPACITY_FIELD] = InvalidPsuVolWA.EXPECT_CAPACITY assert InvalidPsuVolWA.run(psu, InvalidPsuVolWA.INVALID_VOLTAGE_VALUE, '') == 9999 mock_run_command.assert_called_with(['sensors', '-s']) + + @mock.patch('os.path.exists', mock.MagicMock(return_value=True)) + @mock.patch('sonic_platform.utils.read_int_from_file') + def test_psu_power_threshold(self, mock_read_int_from_file): + Psu.all_psus_support_power_threshold = True + psu = Psu(0) + common_info = { + psu.psu_oper_status: 1, + psu.psu_power_max_capacity: 100000000, + psu.AMBIENT_TEMP_CRITICAL_THRESHOLD: 65000, + psu.AMBIENT_TEMP_WARNING_THRESHOLD: 55000, + psu.psu_power_slope: 2000 + } + normal_data = { + psu.PORT_AMBIENT_TEMP: 55000, + psu.FAN_AMBIENT_TEMP: 50000, + 'warning_threshold': 100.0, + 'critical_threshold': 100.0 + } + warning_data = { + psu.PORT_AMBIENT_TEMP: 65000, + psu.FAN_AMBIENT_TEMP: 60000, + 'warning_threshold': 90.0, + 'critical_threshold': 100.0 + } + critical_data = { + psu.PORT_AMBIENT_TEMP: 70000, + psu.FAN_AMBIENT_TEMP: 75000, + 'warning_threshold': 70.0, + 'critical_threshold': 90.0 + } + test_data = {} + def mock_side_effect(value): + if value in common_info: + return common_info[value] + else: + return test_data[value] + + mock_read_int_from_file.side_effect = mock_side_effect + test_data = normal_data + assert psu.get_psu_power_warning_suppress_threshold() == normal_data['warning_threshold'] + assert psu.get_psu_power_critical_threshold() == normal_data['critical_threshold'] + + test_data = warning_data + assert psu.get_psu_power_warning_suppress_threshold() == warning_data['warning_threshold'] + assert psu.get_psu_power_critical_threshold() == warning_data['critical_threshold'] + + test_data = critical_data + assert psu.get_psu_power_warning_suppress_threshold() == critical_data['warning_threshold'] + assert psu.get_psu_power_critical_threshold() == critical_data['critical_threshold'] + + def test_psu_not_support_power_threshold(self): + psu = Psu(0) + assert psu.get_psu_power_warning_suppress_threshold() is None + assert psu.get_psu_power_critical_threshold() is None diff --git a/platform/mellanox/mlnx-platform-api/tests/test_utils.py b/platform/mellanox/mlnx-platform-api/tests/test_utils.py index c4c8d0c000a9..5e01fc70dc0e 100644 --- a/platform/mellanox/mlnx-platform-api/tests/test_utils.py +++ b/platform/mellanox/mlnx-platform-api/tests/test_utils.py @@ -18,6 +18,8 @@ import os import pytest import sys +import threading +import time if sys.version_info.major == 3: from unittest import mock else: @@ -125,3 +127,17 @@ def test_run_command(self): def test_extract_RJ45_ports_index(self): rj45_list = utils.extract_RJ45_ports_index() assert rj45_list is None + + def test_wait_until(self): + values = [] + assert utils.wait_until(lambda: len(values) == 0, timeout=1) + assert not utils.wait_until(lambda: len(values) > 0, timeout=1) + + def thread_func(items): + time.sleep(3) + items.append(0) + + t = threading.Thread(target=thread_func, args=(values, )) + t.start() + assert utils.wait_until(lambda: len(values) > 0, timeout=5) + t.join() diff --git a/platform/mellanox/mlnx-sai.mk b/platform/mellanox/mlnx-sai.mk index 90ca7430b0ad..cfe8099bdec5 100644 --- a/platform/mellanox/mlnx-sai.mk +++ b/platform/mellanox/mlnx-sai.mk @@ -1,6 +1,6 @@ # Mellanox SAI -MLNX_SAI_VERSION = SAIBuild2205.22.1.19 +MLNX_SAI_VERSION = SAIBuild2211.23.1.0 export MLNX_SAI_VERSION diff --git a/platform/mellanox/mlnx-sai/SAI-Implementation b/platform/mellanox/mlnx-sai/SAI-Implementation index 82274ffaef77..ea74f041dad1 160000 --- a/platform/mellanox/mlnx-sai/SAI-Implementation +++ b/platform/mellanox/mlnx-sai/SAI-Implementation @@ -1 +1 @@ -Subproject commit 82274ffaef7748120b7657362f7875fb7d6e6f5f +Subproject commit ea74f041dad129c2e8a043d8a7d6da696b6b93eb diff --git a/platform/mellanox/non-upstream-patches/README.md b/platform/mellanox/non-upstream-patches/README.md index 9138d750cbf4..a4393d818d78 100644 --- a/platform/mellanox/non-upstream-patches/README.md +++ b/platform/mellanox/non-upstream-patches/README.md @@ -1,31 +1,26 @@ ## Mellanox non-upstream linux kernel patches ## -To include non-upstream patches into the sonic-linux image during build time, this folder must contain a patch archive. - -### Structure of the patch archive - - 1. It should contain a file named series. series should provide an order in which the patches have to be applied - ``` - admin@build-server:/sonic-buildimage/src/sonic-linux-kernel$ cat linux-5.10.103/non_upstream_patches/series - mlx5-Refactor-module-EEPROM-query.patch - mlx5-Implement-get_module_eeprom_by_page.patch - mlx5-Add-support-for-DSFP-module-EEPROM-dumps.patch - ``` - 2. All the patches should be present in the same folder where series resides. - 3. Developers should make sure patches apply cleanly over the existing patches present in the src/sonic-linux-kernel . - 4. Name of the tarball should match with the one specified under EXTERNAL_KERNEL_PATCH_TAR +To include non-upstream patches into the sonic-linux image during build time, the `INCLUDE_EXTERNAL_PATCHES=y` flag has to be provided. By default, the directory pointed by EXTERNAL_KERNEL_PATCH_LOC will be used and it must follow the following structure. To use a publicly accessible tar of the non-upstream patches, also provide the `EXTERNAL_KERNEL_PATCH_URL` variable + +### Directory Structure -#### Example ``` -admin@build-server:/sonic-buildimage/platform/mellanox/non-upstream-patches$ tar -tf patches.tar.gz -./ -./mlx5-Implement-get_module_eeprom_by_page.patch -./mlx5-Add-support-for-DSFP-module-EEPROM-dumps.patch -./series -./mlx5-Refactor-module-EEPROM-query.patch +EXTERNAL_KERNEL_PATCH_LOC/ + ├──── patches/ + ├── 0001-mlx5-Refactor-module-EEPROM-query.patch.patch + ├── 0002-mlx5-Implement-get_module_eeprom_by_page.patch.patch + ├── 0005-mlx5-Add-support-for-DSFP-module-EEPROM-dumps.patch + ├── ............. + ├──── series.patch ``` -### Include the archive while building sonic linux kernel + 1. It should contain a file named series.patch. This should contain a diff that is applied on the sonic-linux-kernel/patch/series file. The diff should include all the non-upstream patches. + 2. All the patches should be present in the patches folder + 3. Developers should make sure patches apply cleanly over the existing patches present in the src/sonic-linux-kernel . + + +### Include the non upstream patches while building sonic linux kernel + +Set `INCLUDE_EXTERNAL_PATCHES=y` using `SONIC_OVERRIDE_BUILD_VARS` to include these changes before building the kernel. +- Eg: `NOJESSIE=1 NOSTRETCH=1 NOBUSTER=1 make SONIC_OVERRIDE_BUILD_VARS=' INCLUDE_EXTERNAL_PATCHES=y ' target/debs/bullseye/linux-headers-5.10.0-12-2-common_5.10.103-1_all.deb` -Set `INCLUDE_EXTERNAL_PATCH_TAR=y` using `SONIC_OVERRIDE_BUILD_VARS` to include these changes before building the kernel. -- Eg: `NOJESSIE=1 NOSTRETCH=1 NOBUSTER=1 make SONIC_OVERRIDE_BUILD_VARS=' INCLUDE_EXTERNAL_PATCH_TAR=y ' target/debs/bullseye/linux-headers-5.10.0-12-2-common_5.10.103-1_all.deb` diff --git a/platform/mellanox/non-upstream-patches/patches/0099-mlxsw-core_hwmon-Fix-variable-names-for-hwmon-attrib.patch b/platform/mellanox/non-upstream-patches/patches/0099-mlxsw-core_hwmon-Fix-variable-names-for-hwmon-attrib.patch new file mode 100644 index 000000000000..c53175073e33 --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0099-mlxsw-core_hwmon-Fix-variable-names-for-hwmon-attrib.patch @@ -0,0 +1,255 @@ +From 45dc72bca025600611d6d08e00758618ddb5d7d0 Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Fri, 3 Dec 2021 11:48:41 +0200 +Subject: [PATCH] mlxsw: core_hwmon: Fix variable names for hwmon attributes + +Replace all local variables 'mlwsw_hwmon_attr' by 'mlxsw_hwmon_attr'. +All variable prefixes should start with 'mlxsw' according to the naming +convention, so 'mlwsw' is changed to 'mlxsw'. + +Signed-off-by: Vadim Pasternak +Reviewed-by: Jiri Pirko +Signed-off-by: Ido Schimmel +--- + .../net/ethernet/mellanox/mlxsw/core_hwmon.c | 76 +++++++++---------- + 1 file changed, 38 insertions(+), 38 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c +index d41afdfbd..3788d02b5 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c +@@ -57,14 +57,14 @@ static ssize_t mlxsw_hwmon_temp_show(struct device *dev, + struct device_attribute *attr, + char *buf) + { +- struct mlxsw_hwmon_attr *mlwsw_hwmon_attr = ++ struct mlxsw_hwmon_attr *mlxsw_hwmon_attr = + container_of(attr, struct mlxsw_hwmon_attr, dev_attr); +- struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon; ++ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon; + char mtmp_pl[MLXSW_REG_MTMP_LEN]; + int temp, index; + int err; + +- index = mlxsw_hwmon_get_attr_index(mlwsw_hwmon_attr->type_index, ++ index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index, + mlxsw_hwmon->module_sensor_max); + mlxsw_reg_mtmp_pack(mtmp_pl, index, false, false); + err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl); +@@ -80,14 +80,14 @@ static ssize_t mlxsw_hwmon_temp_max_show(struct device *dev, + struct device_attribute *attr, + char *buf) + { +- struct mlxsw_hwmon_attr *mlwsw_hwmon_attr = ++ struct mlxsw_hwmon_attr *mlxsw_hwmon_attr = + container_of(attr, struct mlxsw_hwmon_attr, dev_attr); +- struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon; ++ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon; + char mtmp_pl[MLXSW_REG_MTMP_LEN]; + int temp_max, index; + int err; + +- index = mlxsw_hwmon_get_attr_index(mlwsw_hwmon_attr->type_index, ++ index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index, + mlxsw_hwmon->module_sensor_max); + mlxsw_reg_mtmp_pack(mtmp_pl, index, false, false); + err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl); +@@ -103,9 +103,9 @@ static ssize_t mlxsw_hwmon_temp_rst_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t len) + { +- struct mlxsw_hwmon_attr *mlwsw_hwmon_attr = ++ struct mlxsw_hwmon_attr *mlxsw_hwmon_attr = + container_of(attr, struct mlxsw_hwmon_attr, dev_attr); +- struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon; ++ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon; + char mtmp_pl[MLXSW_REG_MTMP_LEN] = {0}; + unsigned long val; + int index; +@@ -117,7 +117,7 @@ static ssize_t mlxsw_hwmon_temp_rst_store(struct device *dev, + if (val != 1) + return -EINVAL; + +- index = mlxsw_hwmon_get_attr_index(mlwsw_hwmon_attr->type_index, ++ index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index, + mlxsw_hwmon->module_sensor_max); + + mlxsw_reg_mtmp_sensor_index_set(mtmp_pl, index); +@@ -138,13 +138,13 @@ static ssize_t mlxsw_hwmon_fan_rpm_show(struct device *dev, + struct device_attribute *attr, + char *buf) + { +- struct mlxsw_hwmon_attr *mlwsw_hwmon_attr = ++ struct mlxsw_hwmon_attr *mlxsw_hwmon_attr = + container_of(attr, struct mlxsw_hwmon_attr, dev_attr); +- struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon; ++ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon; + char mfsm_pl[MLXSW_REG_MFSM_LEN]; + int err; + +- mlxsw_reg_mfsm_pack(mfsm_pl, mlwsw_hwmon_attr->type_index); ++ mlxsw_reg_mfsm_pack(mfsm_pl, mlxsw_hwmon_attr->type_index); + err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mfsm), mfsm_pl); + if (err) { + dev_err(mlxsw_hwmon->bus_info->dev, "Failed to query fan\n"); +@@ -157,9 +157,9 @@ static ssize_t mlxsw_hwmon_fan_fault_show(struct device *dev, + struct device_attribute *attr, + char *buf) + { +- struct mlxsw_hwmon_attr *mlwsw_hwmon_attr = ++ struct mlxsw_hwmon_attr *mlxsw_hwmon_attr = + container_of(attr, struct mlxsw_hwmon_attr, dev_attr); +- struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon; ++ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon; + char fore_pl[MLXSW_REG_FORE_LEN]; + bool fault; + int err; +@@ -169,7 +169,7 @@ static ssize_t mlxsw_hwmon_fan_fault_show(struct device *dev, + dev_err(mlxsw_hwmon->bus_info->dev, "Failed to query fan\n"); + return err; + } +- mlxsw_reg_fore_unpack(fore_pl, mlwsw_hwmon_attr->type_index, &fault); ++ mlxsw_reg_fore_unpack(fore_pl, mlxsw_hwmon_attr->type_index, &fault); + + return sprintf(buf, "%u\n", fault); + } +@@ -178,13 +178,13 @@ static ssize_t mlxsw_hwmon_pwm_show(struct device *dev, + struct device_attribute *attr, + char *buf) + { +- struct mlxsw_hwmon_attr *mlwsw_hwmon_attr = ++ struct mlxsw_hwmon_attr *mlxsw_hwmon_attr = + container_of(attr, struct mlxsw_hwmon_attr, dev_attr); +- struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon; ++ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon; + char mfsc_pl[MLXSW_REG_MFSC_LEN]; + int err; + +- mlxsw_reg_mfsc_pack(mfsc_pl, mlwsw_hwmon_attr->type_index, 0); ++ mlxsw_reg_mfsc_pack(mfsc_pl, mlxsw_hwmon_attr->type_index, 0); + err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mfsc), mfsc_pl); + if (err) { + dev_err(mlxsw_hwmon->bus_info->dev, "Failed to query PWM\n"); +@@ -198,9 +198,9 @@ static ssize_t mlxsw_hwmon_pwm_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t len) + { +- struct mlxsw_hwmon_attr *mlwsw_hwmon_attr = ++ struct mlxsw_hwmon_attr *mlxsw_hwmon_attr = + container_of(attr, struct mlxsw_hwmon_attr, dev_attr); +- struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon; ++ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon; + char mfsc_pl[MLXSW_REG_MFSC_LEN]; + unsigned long val; + int err; +@@ -211,7 +211,7 @@ static ssize_t mlxsw_hwmon_pwm_store(struct device *dev, + if (val > 255) + return -EINVAL; + +- mlxsw_reg_mfsc_pack(mfsc_pl, mlwsw_hwmon_attr->type_index, val); ++ mlxsw_reg_mfsc_pack(mfsc_pl, mlxsw_hwmon_attr->type_index, val); + err = mlxsw_reg_write(mlxsw_hwmon->core, MLXSW_REG(mfsc), mfsc_pl); + if (err) { + dev_err(mlxsw_hwmon->bus_info->dev, "Failed to write PWM\n"); +@@ -224,14 +224,14 @@ static int mlxsw_hwmon_module_temp_get(struct device *dev, + struct device_attribute *attr, + int *p_temp) + { +- struct mlxsw_hwmon_attr *mlwsw_hwmon_attr = ++ struct mlxsw_hwmon_attr *mlxsw_hwmon_attr = + container_of(attr, struct mlxsw_hwmon_attr, dev_attr); +- struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon; ++ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon; + char mtmp_pl[MLXSW_REG_MTMP_LEN]; + u8 module; + int err; + +- module = mlwsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count; ++ module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count; + mlxsw_reg_mtmp_pack(mtmp_pl, MLXSW_REG_MTMP_MODULE_INDEX_MIN + module, + false, false); + err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl); +@@ -261,15 +261,15 @@ static ssize_t mlxsw_hwmon_module_temp_fault_show(struct device *dev, + struct device_attribute *attr, + char *buf) + { +- struct mlxsw_hwmon_attr *mlwsw_hwmon_attr = ++ struct mlxsw_hwmon_attr *mlxsw_hwmon_attr = + container_of(attr, struct mlxsw_hwmon_attr, dev_attr); +- struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon; ++ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon; + char mtbr_pl[MLXSW_REG_MTBR_LEN] = {0}; + u8 module, fault; + u16 temp; + int err; + +- module = mlwsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count; ++ module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count; + mlxsw_reg_mtbr_pack(mtbr_pl, MLXSW_REG_MTBR_BASE_MODULE_INDEX + module, + 1); + err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtbr), mtbr_pl); +@@ -303,13 +303,13 @@ static int mlxsw_hwmon_module_temp_critical_get(struct device *dev, + struct device_attribute *attr, + int *p_temp) + { +- struct mlxsw_hwmon_attr *mlwsw_hwmon_attr = ++ struct mlxsw_hwmon_attr *mlxsw_hwmon_attr = + container_of(attr, struct mlxsw_hwmon_attr, dev_attr); +- struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon; ++ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon; + u8 module; + int err; + +- module = mlwsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count; ++ module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count; + err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core, module, + SFP_TEMP_HIGH_WARN, p_temp); + if (err) { +@@ -337,13 +337,13 @@ static int mlxsw_hwmon_module_temp_emergency_get(struct device *dev, + struct device_attribute *attr, + int *p_temp) + { +- struct mlxsw_hwmon_attr *mlwsw_hwmon_attr = ++ struct mlxsw_hwmon_attr *mlxsw_hwmon_attr = + container_of(attr, struct mlxsw_hwmon_attr, dev_attr); +- struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon; ++ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon; + u8 module; + int err; + +- module = mlwsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count; ++ module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count; + err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core, module, + SFP_TEMP_HIGH_ALARM, p_temp); + if (err) { +@@ -373,11 +373,11 @@ mlxsw_hwmon_module_temp_label_show(struct device *dev, + struct device_attribute *attr, + char *buf) + { +- struct mlxsw_hwmon_attr *mlwsw_hwmon_attr = ++ struct mlxsw_hwmon_attr *mlxsw_hwmon_attr = + container_of(attr, struct mlxsw_hwmon_attr, dev_attr); + + return sprintf(buf, "front panel %03u\n", +- mlwsw_hwmon_attr->type_index); ++ mlxsw_hwmon_attr->type_index); + } + + static ssize_t +@@ -385,10 +385,10 @@ mlxsw_hwmon_gbox_temp_label_show(struct device *dev, + struct device_attribute *attr, + char *buf) + { +- struct mlxsw_hwmon_attr *mlwsw_hwmon_attr = ++ struct mlxsw_hwmon_attr *mlxsw_hwmon_attr = + container_of(attr, struct mlxsw_hwmon_attr, dev_attr); +- struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon; +- int index = mlwsw_hwmon_attr->type_index - ++ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon; ++ int index = mlxsw_hwmon_attr->type_index - + mlxsw_hwmon->module_sensor_max + 1; + + return sprintf(buf, "gearbox %03u\n", index); +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0100-mlxsw-core_thermal-Rename-labels-according-to-naming.patch b/platform/mellanox/non-upstream-patches/patches/0100-mlxsw-core_thermal-Rename-labels-according-to-naming.patch new file mode 100644 index 000000000000..cf8c9365af45 --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0100-mlxsw-core_thermal-Rename-labels-according-to-naming.patch @@ -0,0 +1,162 @@ +From d2d0080ec104f01fbf0d6b4750f70f1ebe013495 Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Fri, 3 Dec 2021 11:48:42 +0200 +Subject: [PATCH] mlxsw: core_thermal: Rename labels according to naming + convention + +Rename labels for error flow handling in order to align with naming +convention used in rest of 'mlxsw' code. + +Signed-off-by: Vadim Pasternak +Reviewed-by: Jiri Pirko +Signed-off-by: Ido Schimmel +--- + .../ethernet/mellanox/mlxsw/core_thermal.c | 43 ++++++++++--------- + 1 file changed, 23 insertions(+), 20 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +index cc4cddbdb..e5997b6a0 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +@@ -401,11 +401,11 @@ static int mlxsw_thermal_module_bind(struct thermal_zone_device *tzdev, + trip->min_state, + THERMAL_WEIGHT_DEFAULT); + if (err < 0) +- goto err_bind_cooling_device; ++ goto err_thermal_zone_bind_cooling_device; + } + return 0; + +-err_bind_cooling_device: ++err_thermal_zone_bind_cooling_device: + for (j = i - 1; j >= 0; j--) + thermal_zone_unbind_cooling_device(tzdev, j, cdev); + return err; +@@ -807,7 +807,7 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core, + for (i = 0; i < thermal->tz_module_num; i++) { + err = mlxsw_thermal_module_init(dev, core, thermal, i); + if (err) +- goto err_unreg_tz_module_arr; ++ goto err_thermal_module_init; + } + + for (i = 0; i < thermal->tz_module_num; i++) { +@@ -816,12 +816,13 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core, + continue; + err = mlxsw_thermal_module_tz_init(module_tz); + if (err) +- goto err_unreg_tz_module_arr; ++ goto err_thermal_module_tz_init; + } + + return 0; + +-err_unreg_tz_module_arr: ++err_thermal_module_tz_init: ++err_thermal_module_init: + for (i = thermal->tz_module_num - 1; i >= 0; i--) + mlxsw_thermal_module_fini(&thermal->tz_module_arr[i]); + kfree(thermal->tz_module_arr); +@@ -912,12 +913,12 @@ mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core, + gearbox_tz->parent = thermal; + err = mlxsw_thermal_gearbox_tz_init(gearbox_tz); + if (err) +- goto err_unreg_tz_gearbox; ++ goto err_thermal_gearbox_tz_init; + } + + return 0; + +-err_unreg_tz_gearbox: ++err_thermal_gearbox_tz_init: + for (i--; i >= 0; i--) + mlxsw_thermal_gearbox_tz_fini(&thermal->tz_gearbox_arr[i]); + kfree(thermal->tz_gearbox_arr); +@@ -961,7 +962,7 @@ int mlxsw_thermal_init(struct mlxsw_core *core, + err = mlxsw_reg_query(thermal->core, MLXSW_REG(mfcr), mfcr_pl); + if (err) { + dev_err(dev, "Failed to probe PWMs\n"); +- goto err_free_thermal; ++ goto err_reg_query; + } + mlxsw_reg_mfcr_unpack(mfcr_pl, &freq, &tacho_active, &pwm_active); + +@@ -975,14 +976,14 @@ int mlxsw_thermal_init(struct mlxsw_core *core, + err = mlxsw_reg_query(thermal->core, MLXSW_REG(mfsl), + mfsl_pl); + if (err) +- goto err_free_thermal; ++ goto err_reg_query; + + /* set the minimal RPMs to 0 */ + mlxsw_reg_mfsl_tach_min_set(mfsl_pl, 0); + err = mlxsw_reg_write(thermal->core, MLXSW_REG(mfsl), + mfsl_pl); + if (err) +- goto err_free_thermal; ++ goto err_reg_write; + } + } + for (i = 0; i < MLXSW_MFCR_PWMS_MAX; i++) { +@@ -995,7 +996,7 @@ int mlxsw_thermal_init(struct mlxsw_core *core, + if (IS_ERR(cdev)) { + err = PTR_ERR(cdev); + dev_err(dev, "Failed to register cooling device\n"); +- goto err_unreg_cdevs; ++ goto err_thermal_cooling_device_register; + } + thermal->cdevs[i] = cdev; + } +@@ -1020,38 +1021,40 @@ int mlxsw_thermal_init(struct mlxsw_core *core, + if (IS_ERR(thermal->tzdev)) { + err = PTR_ERR(thermal->tzdev); + dev_err(dev, "Failed to register thermal zone\n"); +- goto err_unreg_cdevs; ++ goto err_thermal_zone_device_register; + } + + err = mlxsw_thermal_modules_init(dev, core, thermal); + if (err) +- goto err_unreg_tzdev; ++ goto err_thermal_modules_init; + + err = mlxsw_thermal_gearboxes_init(dev, core, thermal); + if (err) +- goto err_unreg_modules_tzdev; ++ goto err_thermal_gearboxes_init; + + err = thermal_zone_device_enable(thermal->tzdev); + if (err) +- goto err_unreg_gearboxes; ++ goto err_thermal_zone_device_enable; + + *p_thermal = thermal; + return 0; + +-err_unreg_gearboxes: ++err_thermal_zone_device_enable: + mlxsw_thermal_gearboxes_fini(thermal); +-err_unreg_modules_tzdev: ++err_thermal_gearboxes_init: + mlxsw_thermal_modules_fini(thermal); +-err_unreg_tzdev: ++err_thermal_modules_init: + if (thermal->tzdev) { + thermal_zone_device_unregister(thermal->tzdev); + thermal->tzdev = NULL; + } +-err_unreg_cdevs: ++err_thermal_zone_device_register: ++err_thermal_cooling_device_register: + for (i = 0; i < MLXSW_MFCR_PWMS_MAX; i++) + if (thermal->cdevs[i]) + thermal_cooling_device_unregister(thermal->cdevs[i]); +-err_free_thermal: ++err_reg_write: ++err_reg_query: + devm_kfree(dev, thermal); + return err; + } +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0101-mlxsw-core_thermal-Remove-obsolete-API-for-query-res.patch b/platform/mellanox/non-upstream-patches/patches/0101-mlxsw-core_thermal-Remove-obsolete-API-for-query-res.patch new file mode 100644 index 000000000000..fd76e960d472 --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0101-mlxsw-core_thermal-Remove-obsolete-API-for-query-res.patch @@ -0,0 +1,110 @@ +From 1186332d9cbf3f7cbd2ed52dfcb594ce4e2d2df8 Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Fri, 3 Dec 2021 11:48:43 +0200 +Subject: [PATCH] mlxsw: core_thermal: Remove obsolete API for query resource + +Remove obsolete API mlxsw_core_res_query_enabled(), which is only +relevant for end-of-life SwitchX-2 ASICs. Support for these ASICs was +removed in commit b0d80c013b04 ("mlxsw: Remove Mellanox SwitchX-2 ASIC +support"). + +Signed-off-by: Vadim Pasternak +Signed-off-by: Ido Schimmel +--- + drivers/net/ethernet/mellanox/mlxsw/core.c | 6 ------ + drivers/net/ethernet/mellanox/mlxsw/core.h | 2 -- + drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c | 3 --- + drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 12 ------------ + 4 files changed, 23 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c +index 7938bad70..0b1888318 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core.c +@@ -129,12 +129,6 @@ void *mlxsw_core_driver_priv(struct mlxsw_core *mlxsw_core) + } + EXPORT_SYMBOL(mlxsw_core_driver_priv); + +-bool mlxsw_core_res_query_enabled(const struct mlxsw_core *mlxsw_core) +-{ +- return mlxsw_core->driver->res_query_enabled; +-} +-EXPORT_SYMBOL(mlxsw_core_res_query_enabled); +- + bool mlxsw_core_temp_warn_enabled(const struct mlxsw_core *mlxsw_core) + { + return mlxsw_core->driver->temp_warn_enabled; +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.h b/drivers/net/ethernet/mellanox/mlxsw/core.h +index 56efb8e48..0ceb7dae9 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core.h ++++ b/drivers/net/ethernet/mellanox/mlxsw/core.h +@@ -30,8 +30,6 @@ unsigned int mlxsw_core_max_ports(const struct mlxsw_core *mlxsw_core); + + void *mlxsw_core_driver_priv(struct mlxsw_core *mlxsw_core); + +-bool mlxsw_core_res_query_enabled(const struct mlxsw_core *mlxsw_core); +- + bool mlxsw_core_temp_warn_enabled(const struct mlxsw_core *mlxsw_core); + + bool +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c +index 3788d02b5..8b170ad92 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c +@@ -655,9 +655,6 @@ static int mlxsw_hwmon_module_init(struct mlxsw_hwmon *mlxsw_hwmon) + u8 module_sensor_max; + int i, err; + +- if (!mlxsw_core_res_query_enabled(mlxsw_hwmon->core)) +- return 0; +- + mlxsw_reg_mgpir_pack(mgpir_pl); + err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mgpir), mgpir_pl); + if (err) +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +index e5997b6a0..9b0cd6f79 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +@@ -787,9 +787,6 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core, + char mgpir_pl[MLXSW_REG_MGPIR_LEN]; + int i, err; + +- if (!mlxsw_core_res_query_enabled(core)) +- return 0; +- + mlxsw_reg_mgpir_pack(mgpir_pl); + err = mlxsw_reg_query(core, MLXSW_REG(mgpir), mgpir_pl); + if (err) +@@ -834,9 +831,6 @@ mlxsw_thermal_modules_fini(struct mlxsw_thermal *thermal) + { + int i; + +- if (!mlxsw_core_res_query_enabled(thermal->core)) +- return; +- + for (i = thermal->tz_module_num - 1; i >= 0; i--) + mlxsw_thermal_module_fini(&thermal->tz_module_arr[i]); + kfree(thermal->tz_module_arr); +@@ -884,9 +878,6 @@ mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core, + int i; + int err; + +- if (!mlxsw_core_res_query_enabled(core)) +- return 0; +- + mlxsw_reg_mgpir_pack(mgpir_pl); + err = mlxsw_reg_query(core, MLXSW_REG(mgpir), mgpir_pl); + if (err) +@@ -930,9 +921,6 @@ mlxsw_thermal_gearboxes_fini(struct mlxsw_thermal *thermal) + { + int i; + +- if (!mlxsw_core_res_query_enabled(thermal->core)) +- return; +- + for (i = thermal->tz_gearbox_num - 1; i >= 0; i--) + mlxsw_thermal_gearbox_tz_fini(&thermal->tz_gearbox_arr[i]); + kfree(thermal->tz_gearbox_arr); +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0102-mlxsw-reg-Add-mgpir_-prefix-to-MGPIR-fields-comments.patch b/platform/mellanox/non-upstream-patches/patches/0102-mlxsw-reg-Add-mgpir_-prefix-to-MGPIR-fields-comments.patch new file mode 100644 index 000000000000..8dfb08c2129e --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0102-mlxsw-reg-Add-mgpir_-prefix-to-MGPIR-fields-comments.patch @@ -0,0 +1,51 @@ +From ad972c6b6591023ddc7547bbcbc5c5e1941b29c5 Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Fri, 3 Dec 2021 11:48:44 +0200 +Subject: [PATCH] mlxsw: reg: Add "mgpir_" prefix to MGPIR fields comments + +Do the same as for other registers and have "mgpir_" prefix for the +MGPIR fields. + +Signed-off-by: Jiri Pirko +Signed-off-by: Vadim Pasternak +Signed-off-by: Ido Schimmel +--- + drivers/net/ethernet/mellanox/mlxsw/reg.h | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h +index a9119451d..7f7cdb3fc 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h ++++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h +@@ -10131,24 +10131,24 @@ enum mlxsw_reg_mgpir_device_type { + MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE, + }; + +-/* device_type ++/* mgpir_device_type + * Access: RO + */ + MLXSW_ITEM32(reg, mgpir, device_type, 0x00, 24, 4); + +-/* devices_per_flash ++/* mgpir_devices_per_flash + * Number of devices of device_type per flash (can be shared by few devices). + * Access: RO + */ + MLXSW_ITEM32(reg, mgpir, devices_per_flash, 0x00, 16, 8); + +-/* num_of_devices ++/* mgpir_num_of_devices + * Number of devices of device_type. + * Access: RO + */ + MLXSW_ITEM32(reg, mgpir, num_of_devices, 0x00, 0, 8); + +-/* num_of_modules ++/* mgpir_num_of_modules + * Number of modules. + * Access: RO + */ +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0103-mlxsw-core-Remove-unnecessary-asserts.patch b/platform/mellanox/non-upstream-patches/patches/0103-mlxsw-core-Remove-unnecessary-asserts.patch new file mode 100644 index 000000000000..2c6249423bbe --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0103-mlxsw-core-Remove-unnecessary-asserts.patch @@ -0,0 +1,102 @@ +From 4392d92a40328fe18d1152fae6fada74f46fa1a3 Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Tue, 7 Dec 2021 16:07:31 +0200 +Subject: [PATCH] mlxsw: core: Remove unnecessary asserts + +Remove unnecessary asserts for module index validation. Leave only one +that is actually necessary in mlxsw_env_pmpe_listener_func() where the +module index is directly read from the firmware event. + +Signed-off-by: Vadim Pasternak +Signed-off-by: Ido Schimmel +--- + .../net/ethernet/mellanox/mlxsw/core_env.c | 24 ------------------- + 1 file changed, 24 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c +index 61f7a40c0..4cbed2e3b 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c +@@ -416,9 +416,6 @@ int mlxsw_env_reset_module(struct net_device *netdev, + !(req & (ETH_RESET_PHY << ETH_RESET_SHARED_SHIFT))) + return 0; + +- if (WARN_ON_ONCE(module >= mlxsw_env->module_count)) +- return -EINVAL; +- + mutex_lock(&mlxsw_env->module_info_lock); + + if (mlxsw_env->module_info[module].num_ports_up) { +@@ -458,9 +455,6 @@ mlxsw_env_get_module_power_mode(struct mlxsw_core *mlxsw_core, u8 module, + u32 status_bits; + int err; + +- if (WARN_ON_ONCE(module >= mlxsw_env->module_count)) +- return -EINVAL; +- + mutex_lock(&mlxsw_env->module_info_lock); + + params->policy = mlxsw_env->module_info[module].power_mode_policy; +@@ -562,9 +556,6 @@ mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 module, + bool low_power; + int err = 0; + +- if (WARN_ON_ONCE(module >= mlxsw_env->module_count)) +- return -EINVAL; +- + if (policy != ETHTOOL_MODULE_POWER_MODE_POLICY_HIGH && + policy != ETHTOOL_MODULE_POWER_MODE_POLICY_AUTO) { + NL_SET_ERR_MSG_MOD(extack, "Unsupported power mode policy"); +@@ -903,9 +894,6 @@ mlxsw_env_module_overheat_counter_get(struct mlxsw_core *mlxsw_core, u8 module, + { + struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); + +- if (WARN_ON_ONCE(module >= mlxsw_env->module_count)) +- return -EINVAL; +- + mutex_lock(&mlxsw_env->module_info_lock); + *p_counter = mlxsw_env->module_info[module].module_overheat_counter; + mutex_unlock(&mlxsw_env->module_info_lock); +@@ -918,9 +906,6 @@ void mlxsw_env_module_port_map(struct mlxsw_core *mlxsw_core, u8 module) + { + struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); + +- if (WARN_ON_ONCE(module >= mlxsw_env->module_count)) +- return; +- + mutex_lock(&mlxsw_env->module_info_lock); + mlxsw_env->module_info[module].num_ports_mapped++; + mutex_unlock(&mlxsw_env->module_info_lock); +@@ -931,9 +916,6 @@ void mlxsw_env_module_port_unmap(struct mlxsw_core *mlxsw_core, u8 module) + { + struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); + +- if (WARN_ON_ONCE(module >= mlxsw_env->module_count)) +- return; +- + mutex_lock(&mlxsw_env->module_info_lock); + mlxsw_env->module_info[module].num_ports_mapped--; + mutex_unlock(&mlxsw_env->module_info_lock); +@@ -945,9 +927,6 @@ int mlxsw_env_module_port_up(struct mlxsw_core *mlxsw_core, u8 module) + struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); + int err = 0; + +- if (WARN_ON_ONCE(module >= mlxsw_env->module_count)) +- return -EINVAL; +- + mutex_lock(&mlxsw_env->module_info_lock); + + if (mlxsw_env->module_info[module].power_mode_policy != +@@ -977,9 +956,6 @@ void mlxsw_env_module_port_down(struct mlxsw_core *mlxsw_core, u8 module) + { + struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); + +- if (WARN_ON_ONCE(module >= mlxsw_env->module_count)) +- return; +- + mutex_lock(&mlxsw_env->module_info_lock); + + mlxsw_env->module_info[module].num_ports_up--; +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0104-mlxsw-reg-Extend-MTMP-register-with-new-slot-number-.patch b/platform/mellanox/non-upstream-patches/patches/0104-mlxsw-reg-Extend-MTMP-register-with-new-slot-number-.patch new file mode 100644 index 000000000000..db900ff41bd1 --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0104-mlxsw-reg-Extend-MTMP-register-with-new-slot-number-.patch @@ -0,0 +1,146 @@ +From 5c2fb60aa437b4858f15bb8bfb02d9df43b4dd95 Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Fri, 3 Dec 2021 11:48:45 +0200 +Subject: [PATCH] mlxsw: reg: Extend MTMP register with new slot number field + +Extend MTMP (Management Temperature Register) with new field specifying +the slot index. The purpose of this field is to support access to MTMP +register for reading temperature sensors on modular systems. +For non-modular systems the 'sensor_index' uniquely identifies the cage +sensors, while 'slot_index' is always 0. For modular systems the +sensors are identified by: +- 'slot_index', specifying the slot index, where line card is located; +- 'sensor_index', specifying cage sensor within the line card. + +Signed-off-by: Vadim Pasternak +Reviewed-by: Jiri Pirko +Signed-off-by: Ido Schimmel +--- + drivers/net/ethernet/mellanox/mlxsw/core_env.c | 2 +- + drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c | 11 ++++++----- + drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 6 +++--- + drivers/net/ethernet/mellanox/mlxsw/reg.h | 11 +++++++++-- + 4 files changed, 19 insertions(+), 11 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c +index 4cbed2e3b..0b43029b2 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c +@@ -143,7 +143,7 @@ int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module, + int page; + int err; + +- mlxsw_reg_mtmp_pack(mtmp_pl, MLXSW_REG_MTMP_MODULE_INDEX_MIN + module, ++ mlxsw_reg_mtmp_pack(mtmp_pl, 0, MLXSW_REG_MTMP_MODULE_INDEX_MIN + module, + false, false); + err = mlxsw_reg_query(core, MLXSW_REG(mtmp), mtmp_pl); + if (err) +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c +index 8b170ad92..71ca3b561 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c +@@ -66,7 +66,7 @@ static ssize_t mlxsw_hwmon_temp_show(struct device *dev, + + index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index, + mlxsw_hwmon->module_sensor_max); +- mlxsw_reg_mtmp_pack(mtmp_pl, index, false, false); ++ mlxsw_reg_mtmp_pack(mtmp_pl, 0, index, false, false); + err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl); + if (err) { + dev_err(mlxsw_hwmon->bus_info->dev, "Failed to query temp sensor\n"); +@@ -89,7 +89,7 @@ static ssize_t mlxsw_hwmon_temp_max_show(struct device *dev, + + index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index, + mlxsw_hwmon->module_sensor_max); +- mlxsw_reg_mtmp_pack(mtmp_pl, index, false, false); ++ mlxsw_reg_mtmp_pack(mtmp_pl, 0, index, false, false); + err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl); + if (err) { + dev_err(mlxsw_hwmon->bus_info->dev, "Failed to query temp sensor\n"); +@@ -232,8 +232,9 @@ static int mlxsw_hwmon_module_temp_get(struct device *dev, + int err; + + module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count; +- mlxsw_reg_mtmp_pack(mtmp_pl, MLXSW_REG_MTMP_MODULE_INDEX_MIN + module, +- false, false); ++ mlxsw_reg_mtmp_pack(mtmp_pl, 0, ++ MLXSW_REG_MTMP_MODULE_INDEX_MIN + module, false, ++ false); + err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl); + if (err) { + dev_err(dev, "Failed to query module temperature\n"); +@@ -721,7 +722,7 @@ static int mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon *mlxsw_hwmon) + while (index < max_index) { + sensor_index = index % mlxsw_hwmon->module_sensor_max + + MLXSW_REG_MTMP_GBOX_INDEX_MIN; +- mlxsw_reg_mtmp_pack(mtmp_pl, sensor_index, true, true); ++ mlxsw_reg_mtmp_pack(mtmp_pl, 0, sensor_index, true, true); + err = mlxsw_reg_write(mlxsw_hwmon->core, + MLXSW_REG(mtmp), mtmp_pl); + if (err) { +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +index 9b0cd6f79..8d88633c9 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +@@ -280,7 +280,7 @@ static int mlxsw_thermal_get_temp(struct thermal_zone_device *tzdev, + int temp; + int err; + +- mlxsw_reg_mtmp_pack(mtmp_pl, 0, false, false); ++ mlxsw_reg_mtmp_pack(mtmp_pl, 0, 0, false, false); + + err = mlxsw_reg_query(thermal->core, MLXSW_REG(mtmp), mtmp_pl); + if (err) { +@@ -440,7 +440,7 @@ mlxsw_thermal_module_temp_and_thresholds_get(struct mlxsw_core *core, + int err; + + /* Read module temperature and thresholds. */ +- mlxsw_reg_mtmp_pack(mtmp_pl, sensor_index, false, false); ++ mlxsw_reg_mtmp_pack(mtmp_pl, 0, sensor_index, false, false); + err = mlxsw_reg_query(core, MLXSW_REG(mtmp), mtmp_pl); + if (err) { + /* Set temperature and thresholds to zero to avoid passing +@@ -585,7 +585,7 @@ static int mlxsw_thermal_gearbox_temp_get(struct thermal_zone_device *tzdev, + int err; + + index = MLXSW_REG_MTMP_GBOX_INDEX_MIN + tz->module; +- mlxsw_reg_mtmp_pack(mtmp_pl, index, false, false); ++ mlxsw_reg_mtmp_pack(mtmp_pl, 0, index, false, false); + + err = mlxsw_reg_query(thermal->core, MLXSW_REG(mtmp), mtmp_pl); + if (err) +diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h +index 7f7cdb3fc..52cb58c6d 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h ++++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h +@@ -8541,6 +8541,12 @@ MLXSW_ITEM32(reg, mtcap, sensor_count, 0x00, 0, 7); + + MLXSW_REG_DEFINE(mtmp, MLXSW_REG_MTMP_ID, MLXSW_REG_MTMP_LEN); + ++/* reg_mtmp_slot_index ++ * Slot index (0: Main board). ++ * Access: Index ++ */ ++MLXSW_ITEM32(reg, mtmp, slot_index, 0x00, 16, 4); ++ + #define MLXSW_REG_MTMP_MODULE_INDEX_MIN 64 + #define MLXSW_REG_MTMP_GBOX_INDEX_MIN 256 + /* reg_mtmp_sensor_index +@@ -8630,11 +8636,12 @@ MLXSW_ITEM32(reg, mtmp, temperature_threshold_lo, 0x10, 0, 16); + */ + MLXSW_ITEM_BUF(reg, mtmp, sensor_name, 0x18, MLXSW_REG_MTMP_SENSOR_NAME_SIZE); + +-static inline void mlxsw_reg_mtmp_pack(char *payload, u16 sensor_index, +- bool max_temp_enable, ++static inline void mlxsw_reg_mtmp_pack(char *payload, u8 slot_index, ++ u16 sensor_index, bool max_temp_enable, + bool max_temp_reset) + { + MLXSW_REG_ZERO(mtmp, payload); ++ mlxsw_reg_mtmp_slot_index_set(payload, slot_index); + mlxsw_reg_mtmp_sensor_index_set(payload, sensor_index); + mlxsw_reg_mtmp_mte_set(payload, max_temp_enable); + mlxsw_reg_mtmp_mtr_set(payload, max_temp_reset); +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0105-mlxsw-reg-Extend-MTBR-register-with-new-slot-number-.patch b/platform/mellanox/non-upstream-patches/patches/0105-mlxsw-reg-Extend-MTBR-register-with-new-slot-number-.patch new file mode 100644 index 000000000000..3c8cfdd7be40 --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0105-mlxsw-reg-Extend-MTBR-register-with-new-slot-number-.patch @@ -0,0 +1,87 @@ +From c9c0ae28ab85836ee15920ddafaa3ba45e0dcaeb Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Fri, 3 Dec 2021 11:48:46 +0200 +Subject: [PATCH] mlxsw: reg: Extend MTBR register with new slot number field + +Extend MTBR (Management Temperature Bulk Register) with new field +specifying the slot number. The purpose of this field is to support +access to MTBR register for reading temperature sensors on modular +system. For non-modular systems the 'sensor_index' uniquely identifies +the cage sensors. For modular systems the sensors are identified by two +indexes: +- 'slot_index', specifying the slot number, where line card is located; +- 'sensor_index', specifying cage sensor within the line card. + +Signed-off-by: Vadim Pasternak +Reviewed-by: Jiri Pirko +Signed-off-by: Ido Schimmel +--- + drivers/net/ethernet/mellanox/mlxsw/core_env.c | 4 ++-- + drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c | 4 ++-- + drivers/net/ethernet/mellanox/mlxsw/reg.h | 11 +++++++++-- + 3 files changed, 13 insertions(+), 6 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c +index 0b43029b2..7feefb38b 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c +@@ -593,8 +593,8 @@ static int mlxsw_env_module_has_temp_sensor(struct mlxsw_core *mlxsw_core, + u16 temp; + int err; + +- mlxsw_reg_mtbr_pack(mtbr_pl, MLXSW_REG_MTBR_BASE_MODULE_INDEX + module, +- 1); ++ mlxsw_reg_mtbr_pack(mtbr_pl, 0, ++ MLXSW_REG_MTBR_BASE_MODULE_INDEX + module, 1); + err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mtbr), mtbr_pl); + if (err) + return err; +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c +index 71ca3b561..f4bc711a1 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c +@@ -271,8 +271,8 @@ static ssize_t mlxsw_hwmon_module_temp_fault_show(struct device *dev, + int err; + + module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count; +- mlxsw_reg_mtbr_pack(mtbr_pl, MLXSW_REG_MTBR_BASE_MODULE_INDEX + module, +- 1); ++ mlxsw_reg_mtbr_pack(mtbr_pl, 0, ++ MLXSW_REG_MTBR_BASE_MODULE_INDEX + module, 1); + err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtbr), mtbr_pl); + if (err) { + dev_err(dev, "Failed to query module temperature sensor\n"); +diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h +index 52cb58c6d..56927c772 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h ++++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h +@@ -8707,6 +8707,12 @@ MLXSW_ITEM_BIT_ARRAY(reg, mtwe, sensor_warning, 0x0, 0x10, 1); + + MLXSW_REG_DEFINE(mtbr, MLXSW_REG_MTBR_ID, MLXSW_REG_MTBR_LEN); + ++/* reg_mtbr_slot_index ++ * Slot index (0: Main board). ++ * Access: Index ++ */ ++MLXSW_ITEM32(reg, mtbr, slot_index, 0x00, 16, 4); ++ + /* reg_mtbr_base_sensor_index + * Base sensors index to access (0 - ASIC sensor, 1-63 - ambient sensors, + * 64-127 are mapped to the SFP+/QSFP modules sequentially). +@@ -8739,10 +8745,11 @@ MLXSW_ITEM32_INDEXED(reg, mtbr, rec_max_temp, MLXSW_REG_MTBR_BASE_LEN, 16, + MLXSW_ITEM32_INDEXED(reg, mtbr, rec_temp, MLXSW_REG_MTBR_BASE_LEN, 0, 16, + MLXSW_REG_MTBR_REC_LEN, 0x00, false); + +-static inline void mlxsw_reg_mtbr_pack(char *payload, u16 base_sensor_index, +- u8 num_rec) ++static inline void mlxsw_reg_mtbr_pack(char *payload, u8 slot_index, ++ u16 base_sensor_index, u8 num_rec) + { + MLXSW_REG_ZERO(mtbr, payload); ++ mlxsw_reg_mtbr_slot_index_set(payload, slot_index); + mlxsw_reg_mtbr_base_sensor_index_set(payload, base_sensor_index); + mlxsw_reg_mtbr_num_rec_set(payload, num_rec); + } +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0106-mlxsw-reg-Extend-MCIA-register-with-new-slot-number-.patch b/platform/mellanox/non-upstream-patches/patches/0106-mlxsw-reg-Extend-MCIA-register-with-new-slot-number-.patch new file mode 100644 index 000000000000..bf6f065a9c33 --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0106-mlxsw-reg-Extend-MCIA-register-with-new-slot-number-.patch @@ -0,0 +1,108 @@ +From d494bb0c59dd1f6150f189e2878babf53b67e111 Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Fri, 3 Dec 2021 11:48:47 +0200 +Subject: [PATCH] mlxsw: reg: Extend MCIA register with new slot number field + +Extend MCIA (Management Cable Info Access Register) with new field +specifying the slot number. The purpose of this field is to support +access to MCIA register for reading cage cable information on modular +system. For non-modular systems the 'module' number uniquely identifies +the transceiver location. For modular systems the transceivers are +identified by two indexes: +- 'slot_index', specifying the slot number, where line card is located; +- 'module', specifying cage transceiver within the line card. + +Signed-off-by: Vadim Pasternak +Reviewed-by: Jiri Pirko +Signed-off-by: Ido Schimmel +--- + drivers/net/ethernet/mellanox/mlxsw/core_env.c | 13 +++++++------ + drivers/net/ethernet/mellanox/mlxsw/reg.h | 14 +++++++++++--- + 2 files changed, 18 insertions(+), 9 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c +index 7feefb38b..21eacbe0a 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c +@@ -35,8 +35,8 @@ static int mlxsw_env_validate_cable_ident(struct mlxsw_core *core, int id, + u8 ident; + int err; + +- mlxsw_reg_mcia_pack(mcia_pl, id, 0, MLXSW_REG_MCIA_PAGE0_LO_OFF, 0, 1, +- MLXSW_REG_MCIA_I2C_ADDR_LOW); ++ mlxsw_reg_mcia_pack(mcia_pl, 0, id, 0, MLXSW_REG_MCIA_PAGE0_LO_OFF, 0, ++ 1, MLXSW_REG_MCIA_I2C_ADDR_LOW); + err = mlxsw_reg_query(core, MLXSW_REG(mcia), mcia_pl); + if (err) + return err; +@@ -111,7 +111,8 @@ mlxsw_env_query_module_eeprom(struct mlxsw_core *mlxsw_core, int module, + } + } + +- mlxsw_reg_mcia_pack(mcia_pl, module, 0, page, offset, size, i2c_addr); ++ mlxsw_reg_mcia_pack(mcia_pl, 0, module, 0, page, offset, size, ++ i2c_addr); + + err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mcia), mcia_pl); + if (err) +@@ -185,12 +186,12 @@ int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module, + page = MLXSW_REG_MCIA_TH_PAGE_CMIS_NUM; + else + page = MLXSW_REG_MCIA_TH_PAGE_NUM; +- mlxsw_reg_mcia_pack(mcia_pl, module, 0, page, ++ mlxsw_reg_mcia_pack(mcia_pl, 0, module, 0, page, + MLXSW_REG_MCIA_TH_PAGE_OFF + off, + MLXSW_REG_MCIA_TH_ITEM_SIZE, + MLXSW_REG_MCIA_I2C_ADDR_LOW); + } else { +- mlxsw_reg_mcia_pack(mcia_pl, module, 0, ++ mlxsw_reg_mcia_pack(mcia_pl, 0, module, 0, + MLXSW_REG_MCIA_PAGE0_LO, + off, MLXSW_REG_MCIA_TH_ITEM_SIZE, + MLXSW_REG_MCIA_I2C_ADDR_HIGH); +@@ -371,7 +372,7 @@ mlxsw_env_get_module_eeprom_by_page(struct mlxsw_core *mlxsw_core, u8 module, + size = min_t(u8, page->length - bytes_read, + MLXSW_REG_MCIA_EEPROM_SIZE); + +- mlxsw_reg_mcia_pack(mcia_pl, module, 0, page->page, ++ mlxsw_reg_mcia_pack(mcia_pl, 0, module, 0, page->page, + device_addr + bytes_read, size, + page->i2c_address); + mlxsw_reg_mcia_bank_number_set(mcia_pl, page->bank); +diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h +index 56927c772..2714e316c 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h ++++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h +@@ -8798,6 +8798,12 @@ MLXSW_ITEM32(reg, mcia, l, 0x00, 31, 1); + */ + MLXSW_ITEM32(reg, mcia, module, 0x00, 16, 8); + ++/* reg_mcia_slot_index ++ * Slot index (0: Main board) ++ * Access: Index ++ */ ++MLXSW_ITEM32(reg, mcia, slot, 0x00, 12, 4); ++ + enum { + MLXSW_REG_MCIA_STATUS_GOOD = 0, + /* No response from module's EEPROM. */ +@@ -8897,11 +8903,13 @@ MLXSW_ITEM_BUF(reg, mcia, eeprom, 0x10, MLXSW_REG_MCIA_EEPROM_SIZE); + MLXSW_REG_MCIA_EEPROM_PAGE_LENGTH) / \ + MLXSW_REG_MCIA_EEPROM_UP_PAGE_LENGTH + 1) + +-static inline void mlxsw_reg_mcia_pack(char *payload, u8 module, u8 lock, +- u8 page_number, u16 device_addr, +- u8 size, u8 i2c_device_addr) ++static inline void mlxsw_reg_mcia_pack(char *payload, u8 slot_index, u8 module, ++ u8 lock, u8 page_number, ++ u16 device_addr, u8 size, ++ u8 i2c_device_addr) + { + MLXSW_REG_ZERO(mcia, payload); ++ mlxsw_reg_mcia_slot_set(payload, slot_index); + mlxsw_reg_mcia_module_set(payload, module); + mlxsw_reg_mcia_l_set(payload, lock); + mlxsw_reg_mcia_page_number_set(payload, page_number); +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0107-mlxsw-reg-Extend-MCION-register-with-new-slot-number.patch b/platform/mellanox/non-upstream-patches/patches/0107-mlxsw-reg-Extend-MCION-register-with-new-slot-number.patch new file mode 100644 index 000000000000..46f34b6a2fa4 --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0107-mlxsw-reg-Extend-MCION-register-with-new-slot-number.patch @@ -0,0 +1,68 @@ +From 9c4ce1a56515e927399a87b63deeacd77ada6b3b Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Fri, 3 Dec 2021 11:48:50 +0200 +Subject: [PATCH] mlxsw: reg: Extend MCION register with new slot number field + +Extend MCION (Management Cable IO and Notifications Register) with new +field specifying the slot number. The purpose of this field is to +support access to MCION register for query cage transceiver on modular +system. + +For non-modular systems the 'module' number uniquely identifies the +transceiver location. For modular systems the transceivers are +identified by two indexes: +- 'slot_index', specifying the slot number, where line card is located; +- 'module', specifying cage transceiver within the line card. + +Signed-off-by: Vadim Pasternak +Signed-off-by: Ido Schimmel +--- + drivers/net/ethernet/mellanox/mlxsw/core_env.c | 2 +- + drivers/net/ethernet/mellanox/mlxsw/reg.h | 9 ++++++++- + 2 files changed, 9 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c +index 21eacbe0a..d88033ec6 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c +@@ -460,7 +460,7 @@ mlxsw_env_get_module_power_mode(struct mlxsw_core *mlxsw_core, u8 module, + + params->policy = mlxsw_env->module_info[module].power_mode_policy; + +- mlxsw_reg_mcion_pack(mcion_pl, module); ++ mlxsw_reg_mcion_pack(mcion_pl, 0, module); + err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mcion), mcion_pl); + if (err) { + NL_SET_ERR_MSG_MOD(extack, "Failed to retrieve module's power mode"); +diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h +index 2714e316c..243d91f1d 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h ++++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h +@@ -9328,6 +9328,12 @@ MLXSW_REG_DEFINE(mcion, MLXSW_REG_MCION_ID, MLXSW_REG_MCION_LEN); + */ + MLXSW_ITEM32(reg, mcion, module, 0x00, 16, 8); + ++/* reg_mcion_slot_index ++ * Slot index. ++ * Access: Index ++ */ ++MLXSW_ITEM32(reg, mcion, slot_index, 0x00, 12, 4); ++ + enum { + MLXSW_REG_MCION_MODULE_STATUS_BITS_PRESENT_MASK = BIT(0), + MLXSW_REG_MCION_MODULE_STATUS_BITS_LOW_POWER_MASK = BIT(8), +@@ -9339,9 +9345,10 @@ enum { + */ + MLXSW_ITEM32(reg, mcion, module_status_bits, 0x04, 0, 16); + +-static inline void mlxsw_reg_mcion_pack(char *payload, u8 module) ++static inline void mlxsw_reg_mcion_pack(char *payload, u8 slot_index, u8 module) + { + MLXSW_REG_ZERO(mcion, payload); ++ mlxsw_reg_mcion_slot_index_set(payload, slot_index); + mlxsw_reg_mcion_module_set(payload, module); + } + +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0108-mlxsw-reg-Extend-PMMP-register-with-new-slot-number-.patch b/platform/mellanox/non-upstream-patches/patches/0108-mlxsw-reg-Extend-PMMP-register-with-new-slot-number-.patch new file mode 100644 index 000000000000..8eff1b9973ad --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0108-mlxsw-reg-Extend-PMMP-register-with-new-slot-number-.patch @@ -0,0 +1,67 @@ +From d707ce17ce596c2deb97b481dffb24b8c4537fa2 Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Fri, 3 Dec 2021 11:48:51 +0200 +Subject: [PATCH] mlxsw: reg: Extend PMMP register with new slot number field + +Extend PMMP (Port Module Memory Map Properties Register) with new +field specifying the slot number. The purpose of this field is to +enable overriding the cable/module memory map advertisement. + +For non-modular systems the 'module' number uniquely identifies the +transceiver location. For modular systems the transceivers are +identified by two indexes: +- 'slot_index', specifying the slot number, where line card is located; +- 'module', specifying cage transceiver within the line card. + +Signed-off-by: Vadim Pasternak +Signed-off-by: Ido Schimmel +--- + drivers/net/ethernet/mellanox/mlxsw/core_env.c | 2 +- + drivers/net/ethernet/mellanox/mlxsw/reg.h | 9 ++++++++- + 2 files changed, 9 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c +index d88033ec6..49c58197b 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c +@@ -503,7 +503,7 @@ static int mlxsw_env_module_low_power_set(struct mlxsw_core *mlxsw_core, + u16 eeprom_override_mask, eeprom_override; + char pmmp_pl[MLXSW_REG_PMMP_LEN]; + +- mlxsw_reg_pmmp_pack(pmmp_pl, module); ++ mlxsw_reg_pmmp_pack(pmmp_pl, 0, module); + mlxsw_reg_pmmp_sticky_set(pmmp_pl, true); + /* Mask all the bits except low power mode. */ + eeprom_override_mask = ~MLXSW_REG_PMMP_EEPROM_OVERRIDE_LOW_POWER_MASK; +diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h +index 243d91f1d..c19db16bf 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h ++++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h +@@ -5633,6 +5633,12 @@ MLXSW_REG_DEFINE(pmmp, MLXSW_REG_PMMP_ID, MLXSW_REG_PMMP_LEN); + */ + MLXSW_ITEM32(reg, pmmp, module, 0x00, 16, 8); + ++/* reg_pmmp_slot_index ++ * Slot index. ++ * Access: Index ++ */ ++MLXSW_ITEM32(reg, pmmp, slot_index, 0x00, 24, 4); ++ + /* reg_pmmp_sticky + * When set, will keep eeprom_override values after plug-out event. + * Access: OP +@@ -5660,9 +5666,10 @@ enum { + */ + MLXSW_ITEM32(reg, pmmp, eeprom_override, 0x04, 0, 16); + +-static inline void mlxsw_reg_pmmp_pack(char *payload, u8 module) ++static inline void mlxsw_reg_pmmp_pack(char *payload, u8 slot_index, u8 module) + { + MLXSW_REG_ZERO(pmmp, payload); ++ mlxsw_reg_pmmp_slot_index_set(payload, slot_index); + mlxsw_reg_pmmp_module_set(payload, module); + } + +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0109-mlxsw-reg-Extend-MGPIR-register-with-new-slot-fields.patch b/platform/mellanox/non-upstream-patches/patches/0109-mlxsw-reg-Extend-MGPIR-register-with-new-slot-fields.patch new file mode 100644 index 000000000000..95a723bd2649 --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0109-mlxsw-reg-Extend-MGPIR-register-with-new-slot-fields.patch @@ -0,0 +1,198 @@ +From 1373ed22ae41e92c081bb80df4b3c4c0630edbb9 Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Wed, 22 Dec 2021 06:11:50 +0000 +Subject: [PATCH] mlxsw: reg: Extend MGPIR register with new slot fields + +Extend MGPIR (Management General Peripheral Information Register) with +new fields specifying the slot number and number of the slots available +on system. The purpose of these fields is: +- to support access to MPGIR register on modular system for getting the + number of cages, equipped on the line card, inserted at specified + slot. In case slot number is set zero, MGPIR will provide the + information for the main board. For Top of the Rack (non-modular) + system it will provide the same as before. +- to provide the number of slots supported by system. This data is + relevant only in case slot number is set zero. + +Signed-off-by: Vadim Pasternak +Signed-off-by: Ido Schimmel +--- + .../net/ethernet/mellanox/mlxsw/core_env.c | 4 ++-- + .../net/ethernet/mellanox/mlxsw/core_hwmon.c | 9 +++++---- + .../ethernet/mellanox/mlxsw/core_thermal.c | 8 ++++---- + drivers/net/ethernet/mellanox/mlxsw/minimal.c | 4 ++-- + drivers/net/ethernet/mellanox/mlxsw/reg.h | 20 +++++++++++++++++-- + 5 files changed, 31 insertions(+), 14 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c +index 49c58197b..b1a1204e7 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c +@@ -985,12 +985,12 @@ int mlxsw_env_init(struct mlxsw_core *mlxsw_core, struct mlxsw_env **p_env) + u8 module_count; + int i, err; + +- mlxsw_reg_mgpir_pack(mgpir_pl); ++ mlxsw_reg_mgpir_pack(mgpir_pl, 0); + err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mgpir), mgpir_pl); + if (err) + return err; + +- mlxsw_reg_mgpir_unpack(mgpir_pl, NULL, NULL, NULL, &module_count); ++ mlxsw_reg_mgpir_unpack(mgpir_pl, NULL, NULL, NULL, &module_count, NULL); + + env = kzalloc(struct_size(env, module_info, module_count), GFP_KERNEL); + if (!env) +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c +index f4bc711a1..2bc4c4556 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c +@@ -656,13 +656,13 @@ static int mlxsw_hwmon_module_init(struct mlxsw_hwmon *mlxsw_hwmon) + u8 module_sensor_max; + int i, err; + +- mlxsw_reg_mgpir_pack(mgpir_pl); ++ mlxsw_reg_mgpir_pack(mgpir_pl, 0); + err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mgpir), mgpir_pl); + if (err) + return err; + + mlxsw_reg_mgpir_unpack(mgpir_pl, NULL, NULL, NULL, +- &module_sensor_max); ++ &module_sensor_max, NULL); + + /* Add extra attributes for module temperature. Sensor index is + * assigned to sensor_count value, while all indexed before +@@ -707,12 +707,13 @@ static int mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon *mlxsw_hwmon) + u8 gbox_num; + int err; + +- mlxsw_reg_mgpir_pack(mgpir_pl); ++ mlxsw_reg_mgpir_pack(mgpir_pl, 0); + err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mgpir), mgpir_pl); + if (err) + return err; + +- mlxsw_reg_mgpir_unpack(mgpir_pl, &gbox_num, &device_type, NULL, NULL); ++ mlxsw_reg_mgpir_unpack(mgpir_pl, &gbox_num, &device_type, NULL, NULL, ++ NULL); + if (device_type != MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE || + !gbox_num) + return 0; +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +index 8d88633c9..56e0291f1 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +@@ -787,13 +787,13 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core, + char mgpir_pl[MLXSW_REG_MGPIR_LEN]; + int i, err; + +- mlxsw_reg_mgpir_pack(mgpir_pl); ++ mlxsw_reg_mgpir_pack(mgpir_pl, 0); + err = mlxsw_reg_query(core, MLXSW_REG(mgpir), mgpir_pl); + if (err) + return err; + + mlxsw_reg_mgpir_unpack(mgpir_pl, NULL, NULL, NULL, +- &thermal->tz_module_num); ++ &thermal->tz_module_num, NULL); + + thermal->tz_module_arr = kcalloc(thermal->tz_module_num, + sizeof(*thermal->tz_module_arr), +@@ -878,13 +878,13 @@ mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core, + int i; + int err; + +- mlxsw_reg_mgpir_pack(mgpir_pl); ++ mlxsw_reg_mgpir_pack(mgpir_pl, 0); + err = mlxsw_reg_query(core, MLXSW_REG(mgpir), mgpir_pl); + if (err) + return err; + + mlxsw_reg_mgpir_unpack(mgpir_pl, &gbox_num, &device_type, NULL, +- NULL); ++ NULL, NULL); + if (device_type != MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE || + !gbox_num) + return 0; +diff --git a/drivers/net/ethernet/mellanox/mlxsw/minimal.c b/drivers/net/ethernet/mellanox/mlxsw/minimal.c +index 3d07c2dcf..b2ffcfda8 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/minimal.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/minimal.c +@@ -280,13 +280,13 @@ static int mlxsw_m_ports_create(struct mlxsw_m *mlxsw_m) + char mgpir_pl[MLXSW_REG_MGPIR_LEN]; + int i, err; + +- mlxsw_reg_mgpir_pack(mgpir_pl); ++ mlxsw_reg_mgpir_pack(mgpir_pl, 0); + err = mlxsw_reg_query(mlxsw_m->core, MLXSW_REG(mgpir), mgpir_pl); + if (err) + return err; + + mlxsw_reg_mgpir_unpack(mgpir_pl, NULL, NULL, NULL, +- &mlxsw_m->max_ports); ++ &mlxsw_m->max_ports, NULL); + if (!mlxsw_m->max_ports) + return 0; + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h +index c19db16bf..e981630fd 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h ++++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h +@@ -10167,6 +10167,12 @@ enum mlxsw_reg_mgpir_device_type { + MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE, + }; + ++/* mgpir_slot_index ++ * Slot index (0: Main board). ++ * Access: Index ++ */ ++MLXSW_ITEM32(reg, mgpir, slot_index, 0x00, 28, 4); ++ + /* mgpir_device_type + * Access: RO + */ +@@ -10184,21 +10190,29 @@ MLXSW_ITEM32(reg, mgpir, devices_per_flash, 0x00, 16, 8); + */ + MLXSW_ITEM32(reg, mgpir, num_of_devices, 0x00, 0, 8); + ++/* mgpir_num_of_slots ++ * Number of slots in the system. ++ * Access: RO ++ */ ++MLXSW_ITEM32(reg, mgpir, num_of_slots, 0x04, 8, 8); ++ + /* mgpir_num_of_modules + * Number of modules. + * Access: RO + */ + MLXSW_ITEM32(reg, mgpir, num_of_modules, 0x04, 0, 8); + +-static inline void mlxsw_reg_mgpir_pack(char *payload) ++static inline void mlxsw_reg_mgpir_pack(char *payload, u8 slot_index) + { + MLXSW_REG_ZERO(mgpir, payload); ++ mlxsw_reg_mgpir_slot_index_set(payload, slot_index); + } + + static inline void + mlxsw_reg_mgpir_unpack(char *payload, u8 *num_of_devices, + enum mlxsw_reg_mgpir_device_type *device_type, +- u8 *devices_per_flash, u8 *num_of_modules) ++ u8 *devices_per_flash, u8 *num_of_modules, ++ u8 *num_of_slots) + { + if (num_of_devices) + *num_of_devices = mlxsw_reg_mgpir_num_of_devices_get(payload); +@@ -10209,6 +10223,8 @@ mlxsw_reg_mgpir_unpack(char *payload, u8 *num_of_devices, + mlxsw_reg_mgpir_devices_per_flash_get(payload); + if (num_of_modules) + *num_of_modules = mlxsw_reg_mgpir_num_of_modules_get(payload); ++ if (num_of_slots) ++ *num_of_slots = mlxsw_reg_mgpir_num_of_slots_get(payload); + } + + /* MFDE - Monitoring FW Debug Register +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0110-mlxsw-core_env-Pass-slot-index-during-PMAOS-register.patch b/platform/mellanox/non-upstream-patches/patches/0110-mlxsw-core_env-Pass-slot-index-during-PMAOS-register.patch new file mode 100644 index 000000000000..ae90d51ca88b --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0110-mlxsw-core_env-Pass-slot-index-during-PMAOS-register.patch @@ -0,0 +1,66 @@ +From 562fe3c68c9dbcff172eeae8b4f0a84484b5e3e9 Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Fri, 3 Dec 2021 11:48:52 +0200 +Subject: [PATCH] mlxsw: core_env: Pass slot index during PMAOS register write + call + +Pass the slot index down to PMAOS pack helper alongside with the module. + +Signed-off-by: Jiri Pirko +Signed-off-by: Vadim Pasternak +Signed-off-by: Ido Schimmel +--- + drivers/net/ethernet/mellanox/mlxsw/core_env.c | 6 +++--- + drivers/net/ethernet/mellanox/mlxsw/reg.h | 3 ++- + 2 files changed, 5 insertions(+), 4 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c +index b1a1204e7..45058d4cf 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c +@@ -400,7 +400,7 @@ static int mlxsw_env_module_reset(struct mlxsw_core *mlxsw_core, u8 module) + { + char pmaos_pl[MLXSW_REG_PMAOS_LEN]; + +- mlxsw_reg_pmaos_pack(pmaos_pl, module); ++ mlxsw_reg_pmaos_pack(pmaos_pl, 0, module); + mlxsw_reg_pmaos_rst_set(pmaos_pl, true); + + return mlxsw_reg_write(mlxsw_core, MLXSW_REG(pmaos), pmaos_pl); +@@ -488,7 +488,7 @@ static int mlxsw_env_module_enable_set(struct mlxsw_core *mlxsw_core, + enum mlxsw_reg_pmaos_admin_status admin_status; + char pmaos_pl[MLXSW_REG_PMAOS_LEN]; + +- mlxsw_reg_pmaos_pack(pmaos_pl, module); ++ mlxsw_reg_pmaos_pack(pmaos_pl, 0, module); + admin_status = enable ? MLXSW_REG_PMAOS_ADMIN_STATUS_ENABLED : + MLXSW_REG_PMAOS_ADMIN_STATUS_DISABLED; + mlxsw_reg_pmaos_admin_status_set(pmaos_pl, admin_status); +@@ -878,7 +878,7 @@ mlxsw_env_module_oper_state_event_enable(struct mlxsw_core *mlxsw_core, + for (i = 0; i < module_count; i++) { + char pmaos_pl[MLXSW_REG_PMAOS_LEN]; + +- mlxsw_reg_pmaos_pack(pmaos_pl, i); ++ mlxsw_reg_pmaos_pack(pmaos_pl, 0, i); + mlxsw_reg_pmaos_e_set(pmaos_pl, + MLXSW_REG_PMAOS_E_GENERATE_EVENT); + mlxsw_reg_pmaos_ee_set(pmaos_pl, true); +diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h +index e981630fd..748a22ec4 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h ++++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h +@@ -5481,9 +5481,10 @@ enum mlxsw_reg_pmaos_e { + */ + MLXSW_ITEM32(reg, pmaos, e, 0x04, 0, 2); + +-static inline void mlxsw_reg_pmaos_pack(char *payload, u8 module) ++static inline void mlxsw_reg_pmaos_pack(char *payload, u8 slot_index, u8 module) + { + MLXSW_REG_ZERO(pmaos, payload); ++ mlxsw_reg_pmaos_slot_index_set(payload, slot_index); + mlxsw_reg_pmaos_module_set(payload, module); + } + +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0111-mlxsw-reg-Add-new-field-to-Management-General-Periph.patch b/platform/mellanox/non-upstream-patches/patches/0111-mlxsw-reg-Add-new-field-to-Management-General-Periph.patch new file mode 100644 index 000000000000..e785735732e0 --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0111-mlxsw-reg-Add-new-field-to-Management-General-Periph.patch @@ -0,0 +1,38 @@ +From fe27f006de6b428fe59acb1960373b32e59adf0b Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Fri, 3 Dec 2021 11:48:49 +0200 +Subject: [PATCH] mlxsw: reg: Add new field to Management General Peripheral + Information Register + +Add new field 'max_modules_per_slot' to provide maximum number of +modules that can be connected per slot. This field will always be zero, +if 'slot_index' in query request is set to non-zero value, otherwise +value in this field will provide maximum modules number, which can be +equipped on device inserted at any slot. + +Signed-off-by: Vadim Pasternak +Signed-off-by: Ido Schimmel +--- + drivers/net/ethernet/mellanox/mlxsw/reg.h | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h +index 748a22ec4..9de037b9a 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h ++++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h +@@ -10191,6 +10191,12 @@ MLXSW_ITEM32(reg, mgpir, devices_per_flash, 0x00, 16, 8); + */ + MLXSW_ITEM32(reg, mgpir, num_of_devices, 0x00, 0, 8); + ++/* max_modules_per_slot ++ * Maximum number of modules that can be connected per slot. ++ * Access: RO ++ */ ++MLXSW_ITEM32(reg, mgpir, max_modules_per_slot, 0x04, 16, 8); ++ + /* mgpir_num_of_slots + * Number of slots in the system. + * Access: RO +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0112-mlxsw-core-Extend-interfaces-for-cable-info-access-w.patch b/platform/mellanox/non-upstream-patches/patches/0112-mlxsw-core-Extend-interfaces-for-cable-info-access-w.patch new file mode 100644 index 000000000000..8b4290613cde --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0112-mlxsw-core-Extend-interfaces-for-cable-info-access-w.patch @@ -0,0 +1,828 @@ +From 5577988f783619b9d55f19c983ee8667f52165b7 Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Fri, 3 Dec 2021 11:48:53 +0200 +Subject: [PATCH] mlxsw: core: Extend interfaces for cable info access with + slot argument + +Extend all cable info APIs with 'slot_index' argument. + +For main board, slot will always be set to zero and these APIs will work +as before. If reading cable information is required from cages located +on line cards, slot should be set to the physical slot number, where +line card is located in modular systems. + +Signed-off-by: Vadim Pasternak +Signed-off-by: Ido Schimmel +--- + .../net/ethernet/mellanox/mlxsw/core_env.c | 172 +++++++++++------- + .../net/ethernet/mellanox/mlxsw/core_env.h | 43 +++-- + .../net/ethernet/mellanox/mlxsw/core_hwmon.c | 10 +- + .../ethernet/mellanox/mlxsw/core_thermal.c | 4 +- + drivers/net/ethernet/mellanox/mlxsw/minimal.c | 21 ++- + .../net/ethernet/mellanox/mlxsw/spectrum.c | 2 +- + .../mellanox/mlxsw/spectrum_ethtool.c | 10 +- + 7 files changed, 155 insertions(+), 107 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c +index 45058d4cf..fefb9bb02 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c +@@ -27,16 +27,18 @@ struct mlxsw_env { + struct mlxsw_env_module_info module_info[]; + }; + +-static int mlxsw_env_validate_cable_ident(struct mlxsw_core *core, int id, +- bool *qsfp, bool *cmis) ++static int ++mlxsw_env_validate_cable_ident(struct mlxsw_core *core, u8 slot_index, int id, ++ bool *qsfp, bool *cmis) + { + char mcia_pl[MLXSW_REG_MCIA_LEN]; + char *eeprom_tmp; + u8 ident; + int err; + +- mlxsw_reg_mcia_pack(mcia_pl, 0, id, 0, MLXSW_REG_MCIA_PAGE0_LO_OFF, 0, +- 1, MLXSW_REG_MCIA_I2C_ADDR_LOW); ++ mlxsw_reg_mcia_pack(mcia_pl, slot_index, id, 0, ++ MLXSW_REG_MCIA_PAGE0_LO_OFF, 0, 1, ++ MLXSW_REG_MCIA_I2C_ADDR_LOW); + err = mlxsw_reg_query(core, MLXSW_REG(mcia), mcia_pl); + if (err) + return err; +@@ -65,8 +67,8 @@ static int mlxsw_env_validate_cable_ident(struct mlxsw_core *core, int id, + } + + static int +-mlxsw_env_query_module_eeprom(struct mlxsw_core *mlxsw_core, int module, +- u16 offset, u16 size, void *data, ++mlxsw_env_query_module_eeprom(struct mlxsw_core *mlxsw_core, u8 slot_index, ++ int module, u16 offset, u16 size, void *data, + bool qsfp, unsigned int *p_read_size) + { + char mcia_pl[MLXSW_REG_MCIA_LEN]; +@@ -111,7 +113,7 @@ mlxsw_env_query_module_eeprom(struct mlxsw_core *mlxsw_core, int module, + } + } + +- mlxsw_reg_mcia_pack(mcia_pl, 0, module, 0, page, offset, size, ++ mlxsw_reg_mcia_pack(mcia_pl, slot_index, module, 0, page, offset, size, + i2c_addr); + + err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mcia), mcia_pl); +@@ -129,8 +131,9 @@ mlxsw_env_query_module_eeprom(struct mlxsw_core *mlxsw_core, int module, + return 0; + } + +-int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module, +- int off, int *temp) ++int ++mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, u8 slot_index, ++ int module, int off, int *temp) + { + unsigned int module_temp, module_crit, module_emerg; + union { +@@ -144,8 +147,9 @@ int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module, + int page; + int err; + +- mlxsw_reg_mtmp_pack(mtmp_pl, 0, MLXSW_REG_MTMP_MODULE_INDEX_MIN + module, +- false, false); ++ mlxsw_reg_mtmp_pack(mtmp_pl, slot_index, ++ MLXSW_REG_MTMP_MODULE_INDEX_MIN + module, false, ++ false); + err = mlxsw_reg_query(core, MLXSW_REG(mtmp), mtmp_pl); + if (err) + return err; +@@ -174,7 +178,8 @@ int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module, + */ + + /* Validate module identifier value. */ +- err = mlxsw_env_validate_cable_ident(core, module, &qsfp, &cmis); ++ err = mlxsw_env_validate_cable_ident(core, slot_index, module, &qsfp, ++ &cmis); + if (err) + return err; + +@@ -186,12 +191,12 @@ int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module, + page = MLXSW_REG_MCIA_TH_PAGE_CMIS_NUM; + else + page = MLXSW_REG_MCIA_TH_PAGE_NUM; +- mlxsw_reg_mcia_pack(mcia_pl, 0, module, 0, page, ++ mlxsw_reg_mcia_pack(mcia_pl, slot_index, module, 0, page, + MLXSW_REG_MCIA_TH_PAGE_OFF + off, + MLXSW_REG_MCIA_TH_ITEM_SIZE, + MLXSW_REG_MCIA_I2C_ADDR_LOW); + } else { +- mlxsw_reg_mcia_pack(mcia_pl, 0, module, 0, ++ mlxsw_reg_mcia_pack(mcia_pl, slot_index, module, 0, + MLXSW_REG_MCIA_PAGE0_LO, + off, MLXSW_REG_MCIA_TH_ITEM_SIZE, + MLXSW_REG_MCIA_I2C_ADDR_HIGH); +@@ -208,8 +213,8 @@ int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module, + return 0; + } + +-int mlxsw_env_get_module_info(struct mlxsw_core *mlxsw_core, int module, +- struct ethtool_modinfo *modinfo) ++int mlxsw_env_get_module_info(struct mlxsw_core *mlxsw_core, u8 slot_index, ++ int module, struct ethtool_modinfo *modinfo) + { + u8 module_info[MLXSW_REG_MCIA_EEPROM_MODULE_INFO_SIZE]; + u16 offset = MLXSW_REG_MCIA_EEPROM_MODULE_INFO_SIZE; +@@ -217,8 +222,9 @@ int mlxsw_env_get_module_info(struct mlxsw_core *mlxsw_core, int module, + unsigned int read_size; + int err; + +- err = mlxsw_env_query_module_eeprom(mlxsw_core, module, 0, offset, +- module_info, false, &read_size); ++ err = mlxsw_env_query_module_eeprom(mlxsw_core, slot_index, module, 0, ++ offset, module_info, false, ++ &read_size); + if (err) + return err; + +@@ -247,9 +253,10 @@ int mlxsw_env_get_module_info(struct mlxsw_core *mlxsw_core, int module, + break; + case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_SFP: + /* Verify if transceiver provides diagnostic monitoring page */ +- err = mlxsw_env_query_module_eeprom(mlxsw_core, module, +- SFP_DIAGMON, 1, &diag_mon, +- false, &read_size); ++ err = mlxsw_env_query_module_eeprom(mlxsw_core, slot_index, ++ module, SFP_DIAGMON, 1, ++ &diag_mon, false, ++ &read_size); + if (err) + return err; + +@@ -288,8 +295,9 @@ int mlxsw_env_get_module_info(struct mlxsw_core *mlxsw_core, int module, + EXPORT_SYMBOL(mlxsw_env_get_module_info); + + int mlxsw_env_get_module_eeprom(struct net_device *netdev, +- struct mlxsw_core *mlxsw_core, int module, +- struct ethtool_eeprom *ee, u8 *data) ++ struct mlxsw_core *mlxsw_core, u8 slot_index, ++ int module, struct ethtool_eeprom *ee, ++ u8 *data) + { + int offset = ee->offset; + unsigned int read_size; +@@ -302,12 +310,14 @@ int mlxsw_env_get_module_eeprom(struct net_device *netdev, + + memset(data, 0, ee->len); + /* Validate module identifier value. */ +- err = mlxsw_env_validate_cable_ident(mlxsw_core, module, &qsfp, &cmis); ++ err = mlxsw_env_validate_cable_ident(mlxsw_core, slot_index, module, ++ &qsfp, &cmis); + if (err) + return err; + + while (i < ee->len) { +- err = mlxsw_env_query_module_eeprom(mlxsw_core, module, offset, ++ err = mlxsw_env_query_module_eeprom(mlxsw_core, slot_index, ++ module, offset, + ee->len - i, data + i, + qsfp, &read_size); + if (err) { +@@ -353,7 +363,8 @@ static int mlxsw_env_mcia_status_process(const char *mcia_pl, + } + + int +-mlxsw_env_get_module_eeprom_by_page(struct mlxsw_core *mlxsw_core, u8 module, ++mlxsw_env_get_module_eeprom_by_page(struct mlxsw_core *mlxsw_core, ++ u8 slot_index, u8 module, + const struct ethtool_module_eeprom *page, + struct netlink_ext_ack *extack) + { +@@ -372,7 +383,7 @@ mlxsw_env_get_module_eeprom_by_page(struct mlxsw_core *mlxsw_core, u8 module, + size = min_t(u8, page->length - bytes_read, + MLXSW_REG_MCIA_EEPROM_SIZE); + +- mlxsw_reg_mcia_pack(mcia_pl, 0, module, 0, page->page, ++ mlxsw_reg_mcia_pack(mcia_pl, slot_index, module, 0, page->page, + device_addr + bytes_read, size, + page->i2c_address); + mlxsw_reg_mcia_bank_number_set(mcia_pl, page->bank); +@@ -396,18 +407,20 @@ mlxsw_env_get_module_eeprom_by_page(struct mlxsw_core *mlxsw_core, u8 module, + } + EXPORT_SYMBOL(mlxsw_env_get_module_eeprom_by_page); + +-static int mlxsw_env_module_reset(struct mlxsw_core *mlxsw_core, u8 module) ++static int mlxsw_env_module_reset(struct mlxsw_core *mlxsw_core, u8 slot_index, ++ u8 module) + { + char pmaos_pl[MLXSW_REG_PMAOS_LEN]; + +- mlxsw_reg_pmaos_pack(pmaos_pl, 0, module); ++ mlxsw_reg_pmaos_pack(pmaos_pl, slot_index, module); + mlxsw_reg_pmaos_rst_set(pmaos_pl, true); + + return mlxsw_reg_write(mlxsw_core, MLXSW_REG(pmaos), pmaos_pl); + } + + int mlxsw_env_reset_module(struct net_device *netdev, +- struct mlxsw_core *mlxsw_core, u8 module, u32 *flags) ++ struct mlxsw_core *mlxsw_core, u8 slot_index, ++ u8 module, u32 *flags) + { + struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); + u32 req = *flags; +@@ -432,7 +445,7 @@ int mlxsw_env_reset_module(struct net_device *netdev, + goto out; + } + +- err = mlxsw_env_module_reset(mlxsw_core, module); ++ err = mlxsw_env_module_reset(mlxsw_core, slot_index, module); + if (err) { + netdev_err(netdev, "Failed to reset module\n"); + goto out; +@@ -447,7 +460,8 @@ int mlxsw_env_reset_module(struct net_device *netdev, + EXPORT_SYMBOL(mlxsw_env_reset_module); + + int +-mlxsw_env_get_module_power_mode(struct mlxsw_core *mlxsw_core, u8 module, ++mlxsw_env_get_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index, ++ u8 module, + struct ethtool_module_power_mode_params *params, + struct netlink_ext_ack *extack) + { +@@ -460,7 +474,7 @@ mlxsw_env_get_module_power_mode(struct mlxsw_core *mlxsw_core, u8 module, + + params->policy = mlxsw_env->module_info[module].power_mode_policy; + +- mlxsw_reg_mcion_pack(mcion_pl, 0, module); ++ mlxsw_reg_mcion_pack(mcion_pl, slot_index, module); + err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mcion), mcion_pl); + if (err) { + NL_SET_ERR_MSG_MOD(extack, "Failed to retrieve module's power mode"); +@@ -483,12 +497,12 @@ mlxsw_env_get_module_power_mode(struct mlxsw_core *mlxsw_core, u8 module, + EXPORT_SYMBOL(mlxsw_env_get_module_power_mode); + + static int mlxsw_env_module_enable_set(struct mlxsw_core *mlxsw_core, +- u8 module, bool enable) ++ u8 slot_index, u8 module, bool enable) + { + enum mlxsw_reg_pmaos_admin_status admin_status; + char pmaos_pl[MLXSW_REG_PMAOS_LEN]; + +- mlxsw_reg_pmaos_pack(pmaos_pl, 0, module); ++ mlxsw_reg_pmaos_pack(pmaos_pl, slot_index, module); + admin_status = enable ? MLXSW_REG_PMAOS_ADMIN_STATUS_ENABLED : + MLXSW_REG_PMAOS_ADMIN_STATUS_DISABLED; + mlxsw_reg_pmaos_admin_status_set(pmaos_pl, admin_status); +@@ -498,12 +512,13 @@ static int mlxsw_env_module_enable_set(struct mlxsw_core *mlxsw_core, + } + + static int mlxsw_env_module_low_power_set(struct mlxsw_core *mlxsw_core, +- u8 module, bool low_power) ++ u8 slot_index, u8 module, ++ bool low_power) + { + u16 eeprom_override_mask, eeprom_override; + char pmmp_pl[MLXSW_REG_PMMP_LEN]; + +- mlxsw_reg_pmmp_pack(pmmp_pl, 0, module); ++ mlxsw_reg_pmmp_pack(pmmp_pl, slot_index, module); + mlxsw_reg_pmmp_sticky_set(pmmp_pl, true); + /* Mask all the bits except low power mode. */ + eeprom_override_mask = ~MLXSW_REG_PMMP_EEPROM_OVERRIDE_LOW_POWER_MASK; +@@ -516,24 +531,26 @@ static int mlxsw_env_module_low_power_set(struct mlxsw_core *mlxsw_core, + } + + static int __mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, +- u8 module, bool low_power, ++ u8 slot_index, u8 module, ++ bool low_power, + struct netlink_ext_ack *extack) + { + int err; + +- err = mlxsw_env_module_enable_set(mlxsw_core, module, false); ++ err = mlxsw_env_module_enable_set(mlxsw_core, slot_index, module, false); + if (err) { + NL_SET_ERR_MSG_MOD(extack, "Failed to disable module"); + return err; + } + +- err = mlxsw_env_module_low_power_set(mlxsw_core, module, low_power); ++ err = mlxsw_env_module_low_power_set(mlxsw_core, slot_index, module, ++ low_power); + if (err) { + NL_SET_ERR_MSG_MOD(extack, "Failed to set module's power mode"); + goto err_module_low_power_set; + } + +- err = mlxsw_env_module_enable_set(mlxsw_core, module, true); ++ err = mlxsw_env_module_enable_set(mlxsw_core, slot_index, module, true); + if (err) { + NL_SET_ERR_MSG_MOD(extack, "Failed to enable module"); + goto err_module_enable_set; +@@ -542,14 +559,16 @@ static int __mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, + return 0; + + err_module_enable_set: +- mlxsw_env_module_low_power_set(mlxsw_core, module, !low_power); ++ mlxsw_env_module_low_power_set(mlxsw_core, slot_index, module, ++ !low_power); + err_module_low_power_set: +- mlxsw_env_module_enable_set(mlxsw_core, module, true); ++ mlxsw_env_module_enable_set(mlxsw_core, slot_index, module, true); + return err; + } + + int +-mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 module, ++mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index, ++ u8 module, + enum ethtool_module_power_mode_policy policy, + struct netlink_ext_ack *extack) + { +@@ -573,8 +592,8 @@ mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 module, + goto out_set_policy; + + low_power = policy == ETHTOOL_MODULE_POWER_MODE_POLICY_AUTO; +- err = __mlxsw_env_set_module_power_mode(mlxsw_core, module, low_power, +- extack); ++ err = __mlxsw_env_set_module_power_mode(mlxsw_core, slot_index, module, ++ low_power, extack); + if (err) + goto out; + +@@ -587,14 +606,14 @@ mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 module, + EXPORT_SYMBOL(mlxsw_env_set_module_power_mode); + + static int mlxsw_env_module_has_temp_sensor(struct mlxsw_core *mlxsw_core, +- u8 module, ++ u8 slot_index, u8 module, + bool *p_has_temp_sensor) + { + char mtbr_pl[MLXSW_REG_MTBR_LEN]; + u16 temp; + int err; + +- mlxsw_reg_mtbr_pack(mtbr_pl, 0, ++ mlxsw_reg_mtbr_pack(mtbr_pl, slot_index, + MLXSW_REG_MTBR_BASE_MODULE_INDEX + module, 1); + err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mtbr), mtbr_pl); + if (err) +@@ -615,13 +634,15 @@ static int mlxsw_env_module_has_temp_sensor(struct mlxsw_core *mlxsw_core, + return 0; + } + +-static int mlxsw_env_temp_event_set(struct mlxsw_core *mlxsw_core, +- u16 sensor_index, bool enable) ++static int ++mlxsw_env_temp_event_set(struct mlxsw_core *mlxsw_core, u8 slot_index, ++ u16 sensor_index, bool enable) + { + char mtmp_pl[MLXSW_REG_MTMP_LEN] = {0}; + enum mlxsw_reg_mtmp_tee tee; + int err, threshold_hi; + ++ mlxsw_reg_mtmp_slot_index_set(mtmp_pl, slot_index); + mlxsw_reg_mtmp_sensor_index_set(mtmp_pl, sensor_index); + err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mtmp), mtmp_pl); + if (err) +@@ -629,6 +650,7 @@ static int mlxsw_env_temp_event_set(struct mlxsw_core *mlxsw_core, + + if (enable) { + err = mlxsw_env_module_temp_thresholds_get(mlxsw_core, ++ slot_index, + sensor_index - + MLXSW_REG_MTMP_MODULE_INDEX_MIN, + SFP_TEMP_HIGH_WARN, +@@ -656,14 +678,14 @@ static int mlxsw_env_temp_event_set(struct mlxsw_core *mlxsw_core, + } + + static int mlxsw_env_module_temp_event_enable(struct mlxsw_core *mlxsw_core, +- u8 module_count) ++ u8 slot_index, u8 module_count) + { + int i, err, sensor_index; + bool has_temp_sensor; + + for (i = 0; i < module_count; i++) { +- err = mlxsw_env_module_has_temp_sensor(mlxsw_core, i, +- &has_temp_sensor); ++ err = mlxsw_env_module_has_temp_sensor(mlxsw_core, slot_index, ++ i, &has_temp_sensor); + if (err) + return err; + +@@ -671,7 +693,8 @@ static int mlxsw_env_module_temp_event_enable(struct mlxsw_core *mlxsw_core, + continue; + + sensor_index = i + MLXSW_REG_MTMP_MODULE_INDEX_MIN; +- err = mlxsw_env_temp_event_set(mlxsw_core, sensor_index, true); ++ err = mlxsw_env_temp_event_set(mlxsw_core, slot_index, ++ sensor_index, true); + if (err) + return err; + } +@@ -778,6 +801,7 @@ static void mlxsw_env_temp_warn_event_unregister(struct mlxsw_env *mlxsw_env) + + struct mlxsw_env_module_plug_unplug_event { + struct mlxsw_env *mlxsw_env; ++ u8 slot_index; + u8 module; + struct work_struct work; + }; +@@ -798,7 +822,9 @@ static void mlxsw_env_pmpe_event_work(struct work_struct *work) + mlxsw_env->module_info[event->module].is_overheat = false; + mutex_unlock(&mlxsw_env->module_info_lock); + +- err = mlxsw_env_module_has_temp_sensor(mlxsw_env->core, event->module, ++ err = mlxsw_env_module_has_temp_sensor(mlxsw_env->core, ++ event->slot_index, ++ event->module, + &has_temp_sensor); + /* Do not disable events on modules without sensors or faulty sensors + * because FW returns errors. +@@ -810,7 +836,8 @@ static void mlxsw_env_pmpe_event_work(struct work_struct *work) + goto out; + + sensor_index = event->module + MLXSW_REG_MTMP_MODULE_INDEX_MIN; +- mlxsw_env_temp_event_set(mlxsw_env->core, sensor_index, true); ++ mlxsw_env_temp_event_set(mlxsw_env->core, event->slot_index, ++ sensor_index, true); + + out: + kfree(event); +@@ -837,6 +864,7 @@ mlxsw_env_pmpe_listener_func(const struct mlxsw_reg_info *reg, char *pmpe_pl, + return; + + event->mlxsw_env = mlxsw_env; ++ event->slot_index = 0; + event->module = module; + INIT_WORK(&event->work, mlxsw_env_pmpe_event_work); + mlxsw_core_schedule_work(&event->work); +@@ -871,14 +899,14 @@ mlxsw_env_module_plug_event_unregister(struct mlxsw_env *mlxsw_env) + + static int + mlxsw_env_module_oper_state_event_enable(struct mlxsw_core *mlxsw_core, +- u8 module_count) ++ u8 slot_index, u8 module_count) + { + int i, err; + + for (i = 0; i < module_count; i++) { + char pmaos_pl[MLXSW_REG_PMAOS_LEN]; + +- mlxsw_reg_pmaos_pack(pmaos_pl, 0, i); ++ mlxsw_reg_pmaos_pack(pmaos_pl, slot_index, i); + mlxsw_reg_pmaos_e_set(pmaos_pl, + MLXSW_REG_PMAOS_E_GENERATE_EVENT); + mlxsw_reg_pmaos_ee_set(pmaos_pl, true); +@@ -890,8 +918,8 @@ mlxsw_env_module_oper_state_event_enable(struct mlxsw_core *mlxsw_core, + } + + int +-mlxsw_env_module_overheat_counter_get(struct mlxsw_core *mlxsw_core, u8 module, +- u64 *p_counter) ++mlxsw_env_module_overheat_counter_get(struct mlxsw_core *mlxsw_core, u8 slot_index, ++ u8 module, u64 *p_counter) + { + struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); + +@@ -903,7 +931,8 @@ mlxsw_env_module_overheat_counter_get(struct mlxsw_core *mlxsw_core, u8 module, + } + EXPORT_SYMBOL(mlxsw_env_module_overheat_counter_get); + +-void mlxsw_env_module_port_map(struct mlxsw_core *mlxsw_core, u8 module) ++void mlxsw_env_module_port_map(struct mlxsw_core *mlxsw_core, u8 slot_index, ++ u8 module) + { + struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); + +@@ -913,7 +942,8 @@ void mlxsw_env_module_port_map(struct mlxsw_core *mlxsw_core, u8 module) + } + EXPORT_SYMBOL(mlxsw_env_module_port_map); + +-void mlxsw_env_module_port_unmap(struct mlxsw_core *mlxsw_core, u8 module) ++void mlxsw_env_module_port_unmap(struct mlxsw_core *mlxsw_core, u8 slot_index, ++ u8 module) + { + struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); + +@@ -923,7 +953,8 @@ void mlxsw_env_module_port_unmap(struct mlxsw_core *mlxsw_core, u8 module) + } + EXPORT_SYMBOL(mlxsw_env_module_port_unmap); + +-int mlxsw_env_module_port_up(struct mlxsw_core *mlxsw_core, u8 module) ++int mlxsw_env_module_port_up(struct mlxsw_core *mlxsw_core, u8 slot_index, ++ u8 module) + { + struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); + int err = 0; +@@ -940,8 +971,8 @@ int mlxsw_env_module_port_up(struct mlxsw_core *mlxsw_core, u8 module) + /* Transition to high power mode following first port using the module + * being put administratively up. + */ +- err = __mlxsw_env_set_module_power_mode(mlxsw_core, module, false, +- NULL); ++ err = __mlxsw_env_set_module_power_mode(mlxsw_core, slot_index, module, ++ false, NULL); + if (err) + goto out_unlock; + +@@ -953,7 +984,8 @@ int mlxsw_env_module_port_up(struct mlxsw_core *mlxsw_core, u8 module) + } + EXPORT_SYMBOL(mlxsw_env_module_port_up); + +-void mlxsw_env_module_port_down(struct mlxsw_core *mlxsw_core, u8 module) ++void mlxsw_env_module_port_down(struct mlxsw_core *mlxsw_core, u8 slot_index, ++ u8 module) + { + struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); + +@@ -971,7 +1003,8 @@ void mlxsw_env_module_port_down(struct mlxsw_core *mlxsw_core, u8 module) + /* Transition to low power mode following last port using the module + * being put administratively down. + */ +- __mlxsw_env_set_module_power_mode(mlxsw_core, module, true, NULL); ++ __mlxsw_env_set_module_power_mode(mlxsw_core, slot_index, module, true, ++ NULL); + + out_unlock: + mutex_unlock(&mlxsw_env->module_info_lock); +@@ -1016,12 +1049,13 @@ int mlxsw_env_init(struct mlxsw_core *mlxsw_core, struct mlxsw_env **p_env) + if (err) + goto err_module_plug_event_register; + +- err = mlxsw_env_module_oper_state_event_enable(mlxsw_core, ++ err = mlxsw_env_module_oper_state_event_enable(mlxsw_core, 0, + env->module_count); + if (err) + goto err_oper_state_event_enable; + +- err = mlxsw_env_module_temp_event_enable(mlxsw_core, env->module_count); ++ err = mlxsw_env_module_temp_event_enable(mlxsw_core, 0, ++ env->module_count); + if (err) + goto err_temp_event_enable; + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.h b/drivers/net/ethernet/mellanox/mlxsw/core_env.h +index da121b1a8..03d027870 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_env.h ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.h +@@ -9,46 +9,55 @@ + struct ethtool_modinfo; + struct ethtool_eeprom; + +-int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module, +- int off, int *temp); ++int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, ++ u8 slot_index, int module, int off, ++ int *temp); + +-int mlxsw_env_get_module_info(struct mlxsw_core *mlxsw_core, int module, +- struct ethtool_modinfo *modinfo); ++int mlxsw_env_get_module_info(struct mlxsw_core *mlxsw_core, u8 slot_index, ++ int module, struct ethtool_modinfo *modinfo); + + int mlxsw_env_get_module_eeprom(struct net_device *netdev, +- struct mlxsw_core *mlxsw_core, int module, +- struct ethtool_eeprom *ee, u8 *data); ++ struct mlxsw_core *mlxsw_core, u8 slot_index, ++ int module, struct ethtool_eeprom *ee, ++ u8 *data); + + int +-mlxsw_env_get_module_eeprom_by_page(struct mlxsw_core *mlxsw_core, u8 module, ++mlxsw_env_get_module_eeprom_by_page(struct mlxsw_core *mlxsw_core, ++ u8 slot_index, u8 module, + const struct ethtool_module_eeprom *page, + struct netlink_ext_ack *extack); + + int mlxsw_env_reset_module(struct net_device *netdev, +- struct mlxsw_core *mlxsw_core, u8 module, +- u32 *flags); ++ struct mlxsw_core *mlxsw_core, u8 slot_index, ++ u8 module, u32 *flags); + + int +-mlxsw_env_get_module_power_mode(struct mlxsw_core *mlxsw_core, u8 module, ++mlxsw_env_get_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index, ++ u8 module, + struct ethtool_module_power_mode_params *params, + struct netlink_ext_ack *extack); + + int +-mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 module, ++mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index, ++ u8 module, + enum ethtool_module_power_mode_policy policy, + struct netlink_ext_ack *extack); + + int +-mlxsw_env_module_overheat_counter_get(struct mlxsw_core *mlxsw_core, u8 module, +- u64 *p_counter); ++mlxsw_env_module_overheat_counter_get(struct mlxsw_core *mlxsw_core, u8 slot_index, ++ u8 module, u64 *p_counter); + +-void mlxsw_env_module_port_map(struct mlxsw_core *mlxsw_core, u8 module); ++void mlxsw_env_module_port_map(struct mlxsw_core *mlxsw_core, u8 slot_index, ++ u8 module); + +-void mlxsw_env_module_port_unmap(struct mlxsw_core *mlxsw_core, u8 module); ++void mlxsw_env_module_port_unmap(struct mlxsw_core *mlxsw_core, u8 slot_index, ++ u8 module); + +-int mlxsw_env_module_port_up(struct mlxsw_core *mlxsw_core, u8 module); ++int mlxsw_env_module_port_up(struct mlxsw_core *mlxsw_core, u8 slot_index, ++ u8 module); + +-void mlxsw_env_module_port_down(struct mlxsw_core *mlxsw_core, u8 module); ++void mlxsw_env_module_port_down(struct mlxsw_core *mlxsw_core, u8 slot_index, ++ u8 module); + + int mlxsw_env_init(struct mlxsw_core *core, struct mlxsw_env **p_env); + void mlxsw_env_fini(struct mlxsw_env *env); +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c +index 2bc4c4556..5df54a5bf 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c +@@ -311,8 +311,9 @@ static int mlxsw_hwmon_module_temp_critical_get(struct device *dev, + int err; + + module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count; +- err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core, module, +- SFP_TEMP_HIGH_WARN, p_temp); ++ err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core, 0, ++ module, SFP_TEMP_HIGH_WARN, ++ p_temp); + if (err) { + dev_err(dev, "Failed to query module temperature thresholds\n"); + return err; +@@ -345,8 +346,9 @@ static int mlxsw_hwmon_module_temp_emergency_get(struct device *dev, + int err; + + module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count; +- err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core, module, +- SFP_TEMP_HIGH_ALARM, p_temp); ++ err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core, 0, ++ module, SFP_TEMP_HIGH_ALARM, ++ p_temp); + if (err) { + dev_err(dev, "Failed to query module temperature thresholds\n"); + return err; +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +index 56e0291f1..3f9062f1c 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +@@ -159,13 +159,13 @@ mlxsw_thermal_module_trips_update(struct device *dev, struct mlxsw_core *core, + * EEPROM if we got valid thresholds from MTMP. + */ + if (!emerg_temp || !crit_temp) { +- err = mlxsw_env_module_temp_thresholds_get(core, tz->module, ++ err = mlxsw_env_module_temp_thresholds_get(core, 0, tz->module, + SFP_TEMP_HIGH_WARN, + &crit_temp); + if (err) + return err; + +- err = mlxsw_env_module_temp_thresholds_get(core, tz->module, ++ err = mlxsw_env_module_temp_thresholds_get(core, 0, tz->module, + SFP_TEMP_HIGH_ALARM, + &emerg_temp); + if (err) +diff --git a/drivers/net/ethernet/mellanox/mlxsw/minimal.c b/drivers/net/ethernet/mellanox/mlxsw/minimal.c +index b2ffcfda8..104f1ba02 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/minimal.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/minimal.c +@@ -59,7 +59,8 @@ static int mlxsw_m_port_open(struct net_device *dev) + struct mlxsw_m_port *mlxsw_m_port = netdev_priv(dev); + struct mlxsw_m *mlxsw_m = mlxsw_m_port->mlxsw_m; + +- return mlxsw_env_module_port_up(mlxsw_m->core, mlxsw_m_port->module); ++ return mlxsw_env_module_port_up(mlxsw_m->core, 0, ++ mlxsw_m_port->module); + } + + static int mlxsw_m_port_stop(struct net_device *dev) +@@ -67,7 +68,7 @@ static int mlxsw_m_port_stop(struct net_device *dev) + struct mlxsw_m_port *mlxsw_m_port = netdev_priv(dev); + struct mlxsw_m *mlxsw_m = mlxsw_m_port->mlxsw_m; + +- mlxsw_env_module_port_down(mlxsw_m->core, mlxsw_m_port->module); ++ mlxsw_env_module_port_down(mlxsw_m->core, 0, mlxsw_m_port->module); + return 0; + } + +@@ -110,7 +111,8 @@ static int mlxsw_m_get_module_info(struct net_device *netdev, + struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev); + struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core; + +- return mlxsw_env_get_module_info(core, mlxsw_m_port->module, modinfo); ++ return mlxsw_env_get_module_info(core, 0, mlxsw_m_port->module, ++ modinfo); + } + + static int +@@ -120,8 +122,8 @@ mlxsw_m_get_module_eeprom(struct net_device *netdev, struct ethtool_eeprom *ee, + struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev); + struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core; + +- return mlxsw_env_get_module_eeprom(netdev, core, mlxsw_m_port->module, +- ee, data); ++ return mlxsw_env_get_module_eeprom(netdev, core, 0, ++ mlxsw_m_port->module, ee, data); + } + + static int +@@ -132,7 +134,8 @@ mlxsw_m_get_module_eeprom_by_page(struct net_device *netdev, + struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev); + struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core; + +- return mlxsw_env_get_module_eeprom_by_page(core, mlxsw_m_port->module, ++ return mlxsw_env_get_module_eeprom_by_page(core, 0, ++ mlxsw_m_port->module, + page, extack); + } + +@@ -141,7 +144,7 @@ static int mlxsw_m_reset(struct net_device *netdev, u32 *flags) + struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev); + struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core; + +- return mlxsw_env_reset_module(netdev, core, mlxsw_m_port->module, ++ return mlxsw_env_reset_module(netdev, core, 0, mlxsw_m_port->module, + flags); + } + +@@ -153,7 +156,7 @@ mlxsw_m_get_module_power_mode(struct net_device *netdev, + struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev); + struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core; + +- return mlxsw_env_get_module_power_mode(core, mlxsw_m_port->module, ++ return mlxsw_env_get_module_power_mode(core, 0, mlxsw_m_port->module, + params, extack); + } + +@@ -165,7 +168,7 @@ mlxsw_m_set_module_power_mode(struct net_device *netdev, + struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev); + struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core; + +- return mlxsw_env_set_module_power_mode(core, mlxsw_m_port->module, ++ return mlxsw_env_set_module_power_mode(core, 0, mlxsw_m_port->module, + params->policy, extack); + } + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +index 9f068c030..5066fcc46 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +@@ -1377,7 +1377,7 @@ static int mlxsw_sp_port_overheat_init_val_set(struct mlxsw_sp_port *mlxsw_sp_po + u64 overheat_counter; + int err; + +- err = mlxsw_env_module_overheat_counter_get(mlxsw_sp->core, module, ++ err = mlxsw_env_module_overheat_counter_get(mlxsw_sp->core, 0, module, + &overheat_counter); + if (err) + return err; +diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c +index 369b9d0dc..c9298b236 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c +@@ -566,7 +566,7 @@ mlxsw_sp_port_get_transceiver_overheat_stats(struct mlxsw_sp_port *mlxsw_sp_port + u64 stats; + int err; + +- err = mlxsw_env_module_overheat_counter_get(mlxsw_core, ++ err = mlxsw_env_module_overheat_counter_get(mlxsw_core, 0, + port_mapping.module, + &stats); + if (err) +@@ -1032,7 +1032,7 @@ static int mlxsw_sp_get_module_info(struct net_device *netdev, + struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; + int err; + +- err = mlxsw_env_get_module_info(mlxsw_sp->core, ++ err = mlxsw_env_get_module_info(mlxsw_sp->core, 0, + mlxsw_sp_port->mapping.module, + modinfo); + +@@ -1046,7 +1046,7 @@ static int mlxsw_sp_get_module_eeprom(struct net_device *netdev, + struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; + int err; + +- err = mlxsw_env_get_module_eeprom(netdev, mlxsw_sp->core, ++ err = mlxsw_env_get_module_eeprom(netdev, mlxsw_sp->core, 0, + mlxsw_sp_port->mapping.module, ee, + data); + +@@ -1062,8 +1062,8 @@ mlxsw_sp_get_module_eeprom_by_page(struct net_device *dev, + struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; + u8 module = mlxsw_sp_port->mapping.module; + +- return mlxsw_env_get_module_eeprom_by_page(mlxsw_sp->core, module, page, +- extack); ++ return mlxsw_env_get_module_eeprom_by_page(mlxsw_sp->core, 0, module, ++ page, extack); + } + + static int +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0113-mlxsw-core-Extend-port-module-data-structures-for-li.patch b/platform/mellanox/non-upstream-patches/patches/0113-mlxsw-core-Extend-port-module-data-structures-for-li.patch new file mode 100644 index 000000000000..d2e9385ffa3c --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0113-mlxsw-core-Extend-port-module-data-structures-for-li.patch @@ -0,0 +1,520 @@ +From 8e7c606209b97b89b58d21a2c33c319ade1ba867 Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Tue, 14 Dec 2021 10:57:27 +0200 +Subject: [PATCH] mlxsw: core: Extend port module data structures for line + cards + +The port module core is tasked with module operations such as setting +power mode policy and reset. The per-module information is currently +stored in one large array suited for non-modular systems where only the +main board is present (i.e., slot index 0). + +As a preparation for line cards support, allocate a per line card array +according to the queried number of slots in the system. For each line +card, allocate a module array according to the queried maximum number of +modules per-slot. + +Signed-off-by: Vadim Pasternak +Signed-off-by: Ido Schimmel +--- + .../net/ethernet/mellanox/mlxsw/core_env.c | 223 ++++++++++++------ + 1 file changed, 157 insertions(+), 66 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c +index fefb9bb02..2a6630547 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c +@@ -20,13 +20,19 @@ struct mlxsw_env_module_info { + enum ethtool_module_power_mode_policy power_mode_policy; + }; + +-struct mlxsw_env { +- struct mlxsw_core *core; ++struct mlxsw_env_module_line_cards { + u8 module_count; +- struct mutex module_info_lock; /* Protects 'module_info'. */ + struct mlxsw_env_module_info module_info[]; + }; + ++struct mlxsw_env { ++ struct mlxsw_core *core; ++ u8 max_module_count; /* Maximum number of modules per-slot. */ ++ u8 num_of_slots; /* Including the main board. */ ++ struct mutex line_cards_lock; /* Protects line cards. */ ++ struct mlxsw_env_module_line_cards *line_cards[]; ++}; ++ + static int + mlxsw_env_validate_cable_ident(struct mlxsw_core *core, u8 slot_index, int id, + bool *qsfp, bool *cmis) +@@ -407,6 +413,15 @@ mlxsw_env_get_module_eeprom_by_page(struct mlxsw_core *mlxsw_core, + } + EXPORT_SYMBOL(mlxsw_env_get_module_eeprom_by_page); + ++static struct ++mlxsw_env_module_info *mlxsw_env_module_info_get(struct mlxsw_core *mlxsw_core, ++ u8 slot_index, u8 module) ++{ ++ struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); ++ ++ return &mlxsw_env->line_cards[slot_index]->module_info[module]; ++} ++ + static int mlxsw_env_module_reset(struct mlxsw_core *mlxsw_core, u8 slot_index, + u8 module) + { +@@ -423,6 +438,7 @@ int mlxsw_env_reset_module(struct net_device *netdev, + u8 module, u32 *flags) + { + struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); ++ struct mlxsw_env_module_info *module_info; + u32 req = *flags; + int err; + +@@ -430,15 +446,16 @@ int mlxsw_env_reset_module(struct net_device *netdev, + !(req & (ETH_RESET_PHY << ETH_RESET_SHARED_SHIFT))) + return 0; + +- mutex_lock(&mlxsw_env->module_info_lock); ++ mutex_lock(&mlxsw_env->line_cards_lock); + +- if (mlxsw_env->module_info[module].num_ports_up) { ++ module_info = mlxsw_env_module_info_get(mlxsw_core, slot_index, module); ++ if (module_info->num_ports_up) { + netdev_err(netdev, "Cannot reset module when ports using it are administratively up\n"); + err = -EINVAL; + goto out; + } + +- if (mlxsw_env->module_info[module].num_ports_mapped > 1 && ++ if (module_info->num_ports_mapped > 1 && + !(req & (ETH_RESET_PHY << ETH_RESET_SHARED_SHIFT))) { + netdev_err(netdev, "Cannot reset module without \"phy-shared\" flag when shared by multiple ports\n"); + err = -EINVAL; +@@ -454,7 +471,7 @@ int mlxsw_env_reset_module(struct net_device *netdev, + *flags &= ~(ETH_RESET_PHY | (ETH_RESET_PHY << ETH_RESET_SHARED_SHIFT)); + + out: +- mutex_unlock(&mlxsw_env->module_info_lock); ++ mutex_unlock(&mlxsw_env->line_cards_lock); + return err; + } + EXPORT_SYMBOL(mlxsw_env_reset_module); +@@ -466,13 +483,15 @@ mlxsw_env_get_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index, + struct netlink_ext_ack *extack) + { + struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); ++ struct mlxsw_env_module_info *module_info; + char mcion_pl[MLXSW_REG_MCION_LEN]; + u32 status_bits; + int err; + +- mutex_lock(&mlxsw_env->module_info_lock); ++ mutex_lock(&mlxsw_env->line_cards_lock); + +- params->policy = mlxsw_env->module_info[module].power_mode_policy; ++ module_info = mlxsw_env_module_info_get(mlxsw_core, slot_index, module); ++ params->policy = module_info->power_mode_policy; + + mlxsw_reg_mcion_pack(mcion_pl, slot_index, module); + err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mcion), mcion_pl); +@@ -491,7 +510,7 @@ mlxsw_env_get_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index, + params->mode = ETHTOOL_MODULE_POWER_MODE_HIGH; + + out: +- mutex_unlock(&mlxsw_env->module_info_lock); ++ mutex_unlock(&mlxsw_env->line_cards_lock); + return err; + } + EXPORT_SYMBOL(mlxsw_env_get_module_power_mode); +@@ -573,6 +592,7 @@ mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index, + struct netlink_ext_ack *extack) + { + struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); ++ struct mlxsw_env_module_info *module_info; + bool low_power; + int err = 0; + +@@ -582,13 +602,14 @@ mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index, + return -EOPNOTSUPP; + } + +- mutex_lock(&mlxsw_env->module_info_lock); ++ mutex_lock(&mlxsw_env->line_cards_lock); + +- if (mlxsw_env->module_info[module].power_mode_policy == policy) ++ module_info = mlxsw_env_module_info_get(mlxsw_core, slot_index, module); ++ if (module_info->power_mode_policy == policy) + goto out; + + /* If any ports are up, we are already in high power mode. */ +- if (mlxsw_env->module_info[module].num_ports_up) ++ if (module_info->num_ports_up) + goto out_set_policy; + + low_power = policy == ETHTOOL_MODULE_POWER_MODE_POLICY_AUTO; +@@ -598,9 +619,9 @@ mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index, + goto out; + + out_set_policy: +- mlxsw_env->module_info[module].power_mode_policy = policy; ++ module_info->power_mode_policy = policy; + out: +- mutex_unlock(&mlxsw_env->module_info_lock); ++ mutex_unlock(&mlxsw_env->line_cards_lock); + return err; + } + EXPORT_SYMBOL(mlxsw_env_set_module_power_mode); +@@ -711,6 +732,7 @@ struct mlxsw_env_module_temp_warn_event { + static void mlxsw_env_mtwe_event_work(struct work_struct *work) + { + struct mlxsw_env_module_temp_warn_event *event; ++ struct mlxsw_env_module_info *module_info; + struct mlxsw_env *mlxsw_env; + int i, sensor_warning; + bool is_overheat; +@@ -719,7 +741,7 @@ static void mlxsw_env_mtwe_event_work(struct work_struct *work) + work); + mlxsw_env = event->mlxsw_env; + +- for (i = 0; i < mlxsw_env->module_count; i++) { ++ for (i = 0; i < mlxsw_env->max_module_count; i++) { + /* 64-127 of sensor_index are mapped to the port modules + * sequentially (module 0 is mapped to sensor_index 64, + * module 1 to sensor_index 65 and so on) +@@ -727,9 +749,10 @@ static void mlxsw_env_mtwe_event_work(struct work_struct *work) + sensor_warning = + mlxsw_reg_mtwe_sensor_warning_get(event->mtwe_pl, + i + MLXSW_REG_MTMP_MODULE_INDEX_MIN); +- mutex_lock(&mlxsw_env->module_info_lock); +- is_overheat = +- mlxsw_env->module_info[i].is_overheat; ++ mutex_lock(&mlxsw_env->line_cards_lock); ++ /* MTWE only supports main board. */ ++ module_info = mlxsw_env_module_info_get(mlxsw_env->core, 0, i); ++ is_overheat = module_info->is_overheat; + + if ((is_overheat && sensor_warning) || + (!is_overheat && !sensor_warning)) { +@@ -737,21 +760,21 @@ static void mlxsw_env_mtwe_event_work(struct work_struct *work) + * warning OR current state in "no warning" and MTWE + * does not report warning. + */ +- mutex_unlock(&mlxsw_env->module_info_lock); ++ mutex_unlock(&mlxsw_env->line_cards_lock); + continue; + } else if (is_overheat && !sensor_warning) { + /* MTWE reports "no warning", turn is_overheat off. + */ +- mlxsw_env->module_info[i].is_overheat = false; +- mutex_unlock(&mlxsw_env->module_info_lock); ++ module_info->is_overheat = false; ++ mutex_unlock(&mlxsw_env->line_cards_lock); + } else { + /* Current state is "no warning" and MTWE reports + * "warning", increase the counter and turn is_overheat + * on. + */ +- mlxsw_env->module_info[i].is_overheat = true; +- mlxsw_env->module_info[i].module_overheat_counter++; +- mutex_unlock(&mlxsw_env->module_info_lock); ++ module_info->is_overheat = true; ++ module_info->module_overheat_counter++; ++ mutex_unlock(&mlxsw_env->line_cards_lock); + } + } + +@@ -809,6 +832,7 @@ struct mlxsw_env_module_plug_unplug_event { + static void mlxsw_env_pmpe_event_work(struct work_struct *work) + { + struct mlxsw_env_module_plug_unplug_event *event; ++ struct mlxsw_env_module_info *module_info; + struct mlxsw_env *mlxsw_env; + bool has_temp_sensor; + u16 sensor_index; +@@ -818,9 +842,12 @@ static void mlxsw_env_pmpe_event_work(struct work_struct *work) + work); + mlxsw_env = event->mlxsw_env; + +- mutex_lock(&mlxsw_env->module_info_lock); +- mlxsw_env->module_info[event->module].is_overheat = false; +- mutex_unlock(&mlxsw_env->module_info_lock); ++ mutex_lock(&mlxsw_env->line_cards_lock); ++ module_info = mlxsw_env_module_info_get(mlxsw_env->core, ++ event->slot_index, ++ event->module); ++ module_info->is_overheat = false; ++ mutex_unlock(&mlxsw_env->line_cards_lock); + + err = mlxsw_env_module_has_temp_sensor(mlxsw_env->core, + event->slot_index, +@@ -847,12 +874,14 @@ static void + mlxsw_env_pmpe_listener_func(const struct mlxsw_reg_info *reg, char *pmpe_pl, + void *priv) + { ++ u8 slot_index = mlxsw_reg_pmpe_slot_index_get(pmpe_pl); + struct mlxsw_env_module_plug_unplug_event *event; + enum mlxsw_reg_pmpe_module_status module_status; + u8 module = mlxsw_reg_pmpe_module_get(pmpe_pl); + struct mlxsw_env *mlxsw_env = priv; + +- if (WARN_ON_ONCE(module >= mlxsw_env->module_count)) ++ if (WARN_ON_ONCE(module >= mlxsw_env->max_module_count || ++ slot_index >= mlxsw_env->num_of_slots)) + return; + + module_status = mlxsw_reg_pmpe_module_status_get(pmpe_pl); +@@ -864,7 +893,7 @@ mlxsw_env_pmpe_listener_func(const struct mlxsw_reg_info *reg, char *pmpe_pl, + return; + + event->mlxsw_env = mlxsw_env; +- event->slot_index = 0; ++ event->slot_index = slot_index; + event->module = module; + INIT_WORK(&event->work, mlxsw_env_pmpe_event_work); + mlxsw_core_schedule_work(&event->work); +@@ -922,10 +951,12 @@ mlxsw_env_module_overheat_counter_get(struct mlxsw_core *mlxsw_core, u8 slot_ind + u8 module, u64 *p_counter) + { + struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); ++ struct mlxsw_env_module_info *module_info; + +- mutex_lock(&mlxsw_env->module_info_lock); +- *p_counter = mlxsw_env->module_info[module].module_overheat_counter; +- mutex_unlock(&mlxsw_env->module_info_lock); ++ mutex_lock(&mlxsw_env->line_cards_lock); ++ module_info = mlxsw_env_module_info_get(mlxsw_core, slot_index, module); ++ *p_counter = module_info->module_overheat_counter; ++ mutex_unlock(&mlxsw_env->line_cards_lock); + + return 0; + } +@@ -935,10 +966,12 @@ void mlxsw_env_module_port_map(struct mlxsw_core *mlxsw_core, u8 slot_index, + u8 module) + { + struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); ++ struct mlxsw_env_module_info *module_info; + +- mutex_lock(&mlxsw_env->module_info_lock); +- mlxsw_env->module_info[module].num_ports_mapped++; +- mutex_unlock(&mlxsw_env->module_info_lock); ++ mutex_lock(&mlxsw_env->line_cards_lock); ++ module_info = mlxsw_env_module_info_get(mlxsw_core, slot_index, module); ++ module_info->num_ports_mapped++; ++ mutex_unlock(&mlxsw_env->line_cards_lock); + } + EXPORT_SYMBOL(mlxsw_env_module_port_map); + +@@ -946,10 +979,12 @@ void mlxsw_env_module_port_unmap(struct mlxsw_core *mlxsw_core, u8 slot_index, + u8 module) + { + struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); ++ struct mlxsw_env_module_info *module_info; + +- mutex_lock(&mlxsw_env->module_info_lock); +- mlxsw_env->module_info[module].num_ports_mapped--; +- mutex_unlock(&mlxsw_env->module_info_lock); ++ mutex_lock(&mlxsw_env->line_cards_lock); ++ module_info = mlxsw_env_module_info_get(mlxsw_core, slot_index, module); ++ module_info->num_ports_mapped--; ++ mutex_unlock(&mlxsw_env->line_cards_lock); + } + EXPORT_SYMBOL(mlxsw_env_module_port_unmap); + +@@ -957,15 +992,17 @@ int mlxsw_env_module_port_up(struct mlxsw_core *mlxsw_core, u8 slot_index, + u8 module) + { + struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); ++ struct mlxsw_env_module_info *module_info; + int err = 0; + +- mutex_lock(&mlxsw_env->module_info_lock); ++ mutex_lock(&mlxsw_env->line_cards_lock); + +- if (mlxsw_env->module_info[module].power_mode_policy != ++ module_info = mlxsw_env_module_info_get(mlxsw_core, slot_index, module); ++ if (module_info->power_mode_policy != + ETHTOOL_MODULE_POWER_MODE_POLICY_AUTO) + goto out_inc; + +- if (mlxsw_env->module_info[module].num_ports_up != 0) ++ if (module_info->num_ports_up != 0) + goto out_inc; + + /* Transition to high power mode following first port using the module +@@ -977,9 +1014,9 @@ int mlxsw_env_module_port_up(struct mlxsw_core *mlxsw_core, u8 slot_index, + goto out_unlock; + + out_inc: +- mlxsw_env->module_info[module].num_ports_up++; ++ module_info->num_ports_up++; + out_unlock: +- mutex_unlock(&mlxsw_env->module_info_lock); ++ mutex_unlock(&mlxsw_env->line_cards_lock); + return err; + } + EXPORT_SYMBOL(mlxsw_env_module_port_up); +@@ -988,16 +1025,18 @@ void mlxsw_env_module_port_down(struct mlxsw_core *mlxsw_core, u8 slot_index, + u8 module) + { + struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); ++ struct mlxsw_env_module_info *module_info; + +- mutex_lock(&mlxsw_env->module_info_lock); ++ mutex_lock(&mlxsw_env->line_cards_lock); + +- mlxsw_env->module_info[module].num_ports_up--; ++ module_info = mlxsw_env_module_info_get(mlxsw_core, slot_index, module); ++ module_info->num_ports_up--; + +- if (mlxsw_env->module_info[module].power_mode_policy != ++ if (module_info->power_mode_policy != + ETHTOOL_MODULE_POWER_MODE_POLICY_AUTO) + goto out_unlock; + +- if (mlxsw_env->module_info[module].num_ports_up != 0) ++ if (module_info->num_ports_up != 0) + goto out_unlock; + + /* Transition to low power mode following last port using the module +@@ -1007,38 +1046,83 @@ void mlxsw_env_module_port_down(struct mlxsw_core *mlxsw_core, u8 slot_index, + NULL); + + out_unlock: +- mutex_unlock(&mlxsw_env->module_info_lock); ++ mutex_unlock(&mlxsw_env->line_cards_lock); + } + EXPORT_SYMBOL(mlxsw_env_module_port_down); + ++static int mlxsw_env_line_cards_alloc(struct mlxsw_env *env) ++{ ++ struct mlxsw_env_module_info *module_info; ++ int i, j; ++ ++ for (i = 0; i < env->num_of_slots; i++) { ++ env->line_cards[i] = kzalloc(struct_size(env->line_cards[i], ++ module_info, ++ env->max_module_count), ++ GFP_KERNEL); ++ if (!env->line_cards[i]) ++ goto kzalloc_err; ++ ++ /* Firmware defaults to high power mode policy where modules ++ * are transitioned to high power mode following plug-in. ++ */ ++ for (j = 0; j < env->max_module_count; j++) { ++ module_info = &env->line_cards[i]->module_info[j]; ++ module_info->power_mode_policy = ++ ETHTOOL_MODULE_POWER_MODE_POLICY_HIGH; ++ } ++ } ++ ++ return 0; ++ ++kzalloc_err: ++ for (i--; i >= 0; i--) ++ kfree(env->line_cards[i]); ++ return -ENOMEM; ++} ++ ++static void mlxsw_env_line_cards_free(struct mlxsw_env *env) ++{ ++ int i = env->num_of_slots; ++ ++ for (i--; i >= 0; i--) ++ kfree(env->line_cards[i]); ++} ++ + int mlxsw_env_init(struct mlxsw_core *mlxsw_core, struct mlxsw_env **p_env) + { ++ u8 module_count, num_of_slots, max_module_count; + char mgpir_pl[MLXSW_REG_MGPIR_LEN]; + struct mlxsw_env *env; +- u8 module_count; +- int i, err; ++ int err; + + mlxsw_reg_mgpir_pack(mgpir_pl, 0); + err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mgpir), mgpir_pl); + if (err) + return err; + +- mlxsw_reg_mgpir_unpack(mgpir_pl, NULL, NULL, NULL, &module_count, NULL); ++ mlxsw_reg_mgpir_unpack(mgpir_pl, NULL, NULL, NULL, &module_count, ++ &num_of_slots); ++ /* If the system is modular, get the maximum number of modules per-slot. ++ * Otherwise, get the maximum number of modules on the main board. ++ */ ++ max_module_count = num_of_slots ? ++ mlxsw_reg_mgpir_max_modules_per_slot_get(mgpir_pl) : ++ module_count; + +- env = kzalloc(struct_size(env, module_info, module_count), GFP_KERNEL); ++ env = kzalloc(struct_size(env, line_cards, num_of_slots + 1), ++ GFP_KERNEL); + if (!env) + return -ENOMEM; + +- /* Firmware defaults to high power mode policy where modules are +- * transitioned to high power mode following plug-in. +- */ +- for (i = 0; i < module_count; i++) +- env->module_info[i].power_mode_policy = +- ETHTOOL_MODULE_POWER_MODE_POLICY_HIGH; +- +- mutex_init(&env->module_info_lock); + env->core = mlxsw_core; +- env->module_count = module_count; ++ env->num_of_slots = num_of_slots + 1; ++ env->max_module_count = max_module_count; ++ err = mlxsw_env_line_cards_alloc(env); ++ if (err) ++ goto err_mlxsw_env_line_cards_alloc; ++ ++ mutex_init(&env->line_cards_lock); + *p_env = env; + + err = mlxsw_env_temp_warn_event_register(mlxsw_core); +@@ -1049,13 +1133,17 @@ int mlxsw_env_init(struct mlxsw_core *mlxsw_core, struct mlxsw_env **p_env) + if (err) + goto err_module_plug_event_register; + ++ /* Set 'module_count' only for main board. Actual count for line card ++ * is to be set after line card is activated. ++ */ ++ env->line_cards[0]->module_count = num_of_slots ? 0 : module_count; + err = mlxsw_env_module_oper_state_event_enable(mlxsw_core, 0, +- env->module_count); ++ module_count); + if (err) + goto err_oper_state_event_enable; + + err = mlxsw_env_module_temp_event_enable(mlxsw_core, 0, +- env->module_count); ++ module_count); + if (err) + goto err_temp_event_enable; + +@@ -1067,7 +1155,9 @@ int mlxsw_env_init(struct mlxsw_core *mlxsw_core, struct mlxsw_env **p_env) + err_module_plug_event_register: + mlxsw_env_temp_warn_event_unregister(env); + err_temp_warn_event_register: +- mutex_destroy(&env->module_info_lock); ++ mutex_destroy(&env->line_cards_lock); ++ mlxsw_env_line_cards_free(env); ++err_mlxsw_env_line_cards_alloc: + kfree(env); + return err; + } +@@ -1078,6 +1168,7 @@ void mlxsw_env_fini(struct mlxsw_env *env) + /* Make sure there is no more event work scheduled. */ + mlxsw_core_flush_owq(); + mlxsw_env_temp_warn_event_unregister(env); +- mutex_destroy(&env->module_info_lock); ++ mutex_destroy(&env->line_cards_lock); ++ mlxsw_env_line_cards_free(env); + kfree(env); + } +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0114-mlxsw-core-Move-port-module-events-enablement-to-a-s.patch b/platform/mellanox/non-upstream-patches/patches/0114-mlxsw-core-Move-port-module-events-enablement-to-a-s.patch new file mode 100644 index 000000000000..77ebf2610814 --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0114-mlxsw-core-Move-port-module-events-enablement-to-a-s.patch @@ -0,0 +1,92 @@ +From 9eb9b3172a238d5818d2925e2db6b0f686b31411 Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Tue, 14 Dec 2021 10:57:28 +0200 +Subject: [PATCH] mlxsw: core: Move port module events enablement to a separate + function + +Use a separate function for enablement of port module events such +plug/unplug and temperature threshold crossing. The motivation is to +reuse the function for line cards. + +Signed-off-by: Vadim Pasternak +Signed-off-by: Ido Schimmel +--- + .../net/ethernet/mellanox/mlxsw/core_env.c | 44 ++++++++++++++----- + 1 file changed, 34 insertions(+), 10 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c +index 2a6630547..94d44db1a 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c +@@ -1089,6 +1089,32 @@ static void mlxsw_env_line_cards_free(struct mlxsw_env *env) + kfree(env->line_cards[i]); + } + ++static int ++mlxsw_env_module_event_enable(struct mlxsw_env *mlxsw_env, u8 slot_index) ++{ ++ u8 module_count; ++ int err; ++ ++ module_count = mlxsw_env->line_cards[slot_index]->module_count; ++ err = mlxsw_env_module_oper_state_event_enable(mlxsw_env->core, ++ slot_index, ++ module_count); ++ if (err) ++ return err; ++ ++ err = mlxsw_env_module_temp_event_enable(mlxsw_env->core, slot_index, ++ module_count); ++ if (err) ++ return err; ++ ++ return 0; ++} ++ ++static void ++mlxsw_env_module_event_disable(struct mlxsw_env *mlxsw_env, u8 slot_index) ++{ ++} ++ + int mlxsw_env_init(struct mlxsw_core *mlxsw_core, struct mlxsw_env **p_env) + { + u8 module_count, num_of_slots, max_module_count; +@@ -1137,20 +1163,17 @@ int mlxsw_env_init(struct mlxsw_core *mlxsw_core, struct mlxsw_env **p_env) + * is to be set after line card is activated. + */ + env->line_cards[0]->module_count = num_of_slots ? 0 : module_count; +- err = mlxsw_env_module_oper_state_event_enable(mlxsw_core, 0, +- module_count); +- if (err) +- goto err_oper_state_event_enable; +- +- err = mlxsw_env_module_temp_event_enable(mlxsw_core, 0, +- module_count); ++ /* Enable events only for main board. Line card events are to be ++ * configured only after line card is activated. Before that, access to ++ * modules on line cards is not allowed. ++ */ ++ err = mlxsw_env_module_event_enable(env, 0); + if (err) +- goto err_temp_event_enable; ++ goto err_mlxsw_env_module_event_enable; + + return 0; + +-err_temp_event_enable: +-err_oper_state_event_enable: ++err_mlxsw_env_module_event_enable: + mlxsw_env_module_plug_event_unregister(env); + err_module_plug_event_register: + mlxsw_env_temp_warn_event_unregister(env); +@@ -1164,6 +1187,7 @@ int mlxsw_env_init(struct mlxsw_core *mlxsw_core, struct mlxsw_env **p_env) + + void mlxsw_env_fini(struct mlxsw_env *env) + { ++ mlxsw_env_module_event_disable(env, 0); + mlxsw_env_module_plug_event_unregister(env); + /* Make sure there is no more event work scheduled. */ + mlxsw_core_flush_owq(); +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0115-mlxsw-core_hwmon-Split-gearbox-initialization.patch b/platform/mellanox/non-upstream-patches/patches/0115-mlxsw-core_hwmon-Split-gearbox-initialization.patch new file mode 100644 index 000000000000..1365785ff9db --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0115-mlxsw-core_hwmon-Split-gearbox-initialization.patch @@ -0,0 +1,121 @@ +From 4d15dd7f69b89a370731b08cb3f13e5dd591c189 Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Tue, 14 Dec 2021 10:57:29 +0200 +Subject: [PATCH] mlxsw: core_hwmon: Split gearbox initialization + +Split gearbox initialization in two functions - the first one is to be +used for gearbox configuration validation, the second for creation of +gearbox related hwmon attributes, if any. + +Currently, mlxsw supports gearbox hwmon attributes corresponding to the +objects discovered on the main board. Same hwmon attributes could be +also discovered on line cards. While the initialization flow for main +board and for line cards is the same, the configuration flow is +different. + +The purpose of this patch is to allow reusing of initialization flow by +main board and line cards. + +Signed-off-by: Vadim Pasternak +Reviewed-by: Jiri Pirko +Signed-off-by: Ido Schimmel +--- + .../net/ethernet/mellanox/mlxsw/core_hwmon.c | 43 ++++++++++++++----- + 1 file changed, 33 insertions(+), 10 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c +index 5df54a5bf..7061c18b7 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c +@@ -700,13 +700,11 @@ static int mlxsw_hwmon_module_init(struct mlxsw_hwmon *mlxsw_hwmon) + return 0; + } + +-static int mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon *mlxsw_hwmon) ++static int ++mlxsw_hwmon_gearbox_main_init(struct mlxsw_hwmon *mlxsw_hwmon, u8 *gbox_num) + { + enum mlxsw_reg_mgpir_device_type device_type; +- int index, max_index, sensor_index; + char mgpir_pl[MLXSW_REG_MGPIR_LEN]; +- char mtmp_pl[MLXSW_REG_MTMP_LEN]; +- u8 gbox_num; + int err; + + mlxsw_reg_mgpir_pack(mgpir_pl, 0); +@@ -714,10 +712,27 @@ static int mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon *mlxsw_hwmon) + if (err) + return err; + +- mlxsw_reg_mgpir_unpack(mgpir_pl, &gbox_num, &device_type, NULL, NULL, ++ mlxsw_reg_mgpir_unpack(mgpir_pl, gbox_num, &device_type, NULL, NULL, + NULL); +- if (device_type != MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE || +- !gbox_num) ++ if (device_type != MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE) ++ *gbox_num = 0; ++ ++ return 0; ++} ++ ++static void ++mlxsw_hwmon_gearbox_main_fini(struct mlxsw_hwmon *mlxsw_hwmon) ++{ ++} ++ ++static int ++mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon *mlxsw_hwmon, u8 gbox_num) ++{ ++ int index, max_index, sensor_index; ++ char mtmp_pl[MLXSW_REG_MTMP_LEN]; ++ int err; ++ ++ if (!gbox_num) + return 0; + + index = mlxsw_hwmon->module_sensor_max; +@@ -756,6 +771,7 @@ int mlxsw_hwmon_init(struct mlxsw_core *mlxsw_core, + { + struct mlxsw_hwmon *mlxsw_hwmon; + struct device *hwmon_dev; ++ u8 gbox_num; + int err; + + mlxsw_hwmon = kzalloc(sizeof(*mlxsw_hwmon), GFP_KERNEL); +@@ -776,9 +792,13 @@ int mlxsw_hwmon_init(struct mlxsw_core *mlxsw_core, + if (err) + goto err_temp_module_init; + +- err = mlxsw_hwmon_gearbox_init(mlxsw_hwmon); ++ err = mlxsw_hwmon_gearbox_main_init(mlxsw_hwmon, &gbox_num); ++ if (err) ++ goto err_gearbox_main_init; ++ ++ err = mlxsw_hwmon_gearbox_init(mlxsw_hwmon, gbox_num); + if (err) +- goto err_temp_gearbox_init; ++ goto err_gearbox_init; + + mlxsw_hwmon->groups[0] = &mlxsw_hwmon->group; + mlxsw_hwmon->group.attrs = mlxsw_hwmon->attrs; +@@ -796,7 +816,9 @@ int mlxsw_hwmon_init(struct mlxsw_core *mlxsw_core, + return 0; + + err_hwmon_register: +-err_temp_gearbox_init: ++err_gearbox_init: ++ mlxsw_hwmon_gearbox_main_fini(mlxsw_hwmon); ++err_gearbox_main_init: + err_temp_module_init: + err_fans_init: + err_temp_init: +@@ -807,5 +829,6 @@ int mlxsw_hwmon_init(struct mlxsw_core *mlxsw_core, + void mlxsw_hwmon_fini(struct mlxsw_hwmon *mlxsw_hwmon) + { + hwmon_device_unregister(mlxsw_hwmon->hwmon_dev); ++ mlxsw_hwmon_gearbox_main_fini(mlxsw_hwmon); + kfree(mlxsw_hwmon); + } +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0116-mlxsw-core_hwmon-Extend-internal-structures-to-suppo.patch b/platform/mellanox/non-upstream-patches/patches/0116-mlxsw-core_hwmon-Extend-internal-structures-to-suppo.patch new file mode 100644 index 000000000000..2c1eafe70367 --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0116-mlxsw-core_hwmon-Extend-internal-structures-to-suppo.patch @@ -0,0 +1,541 @@ +From 9780cd7afe3455d0ee428f5009514780e858c133 Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Tue, 14 Dec 2021 10:57:30 +0200 +Subject: [PATCH] mlxsw: core_hwmon: Extend internal structures to support + multi hwmon objects + +Currently, mlxsw supports a single hwmon device and registers it with +attributes corresponding to the various objects found on the main +board such as fans and gearboxes. + +Line cards can have the same objects, but unlike the main board they +can be added and removed while the system is running. The various +hwmon objects found on these line cards should be created when the +line card becomes available and destroyed when the line card becomes +unavailable. + +The above can be achieved by representing each line card as a +different hwmon device and registering / unregistering it when the +line card becomes available / unavailable. + +Prepare for multi hwmon device support by splitting +'struct mlxsw_hwmon' into 'struct mlxsw_hwmon' and +'struct mlxsw_hwmon_dev'. The first will hold information relevant to +all hwmon devices, whereas the second will hold per-hwmon device +information. + +Signed-off-by: Vadim Pasternak +Reviewed-by: Jiri Pirko +Signed-off-by: Ido Schimmel +--- + .../net/ethernet/mellanox/mlxsw/core_hwmon.c | 192 ++++++++++-------- + 1 file changed, 112 insertions(+), 80 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c +index 7061c18b7..31b370862 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c +@@ -27,7 +27,7 @@ + + struct mlxsw_hwmon_attr { + struct device_attribute dev_attr; +- struct mlxsw_hwmon *hwmon; ++ struct mlxsw_hwmon_dev *mlxsw_hwmon_dev; + unsigned int type_index; + char name[32]; + }; +@@ -40,9 +40,8 @@ static int mlxsw_hwmon_get_attr_index(int index, int count) + return index; + } + +-struct mlxsw_hwmon { +- struct mlxsw_core *core; +- const struct mlxsw_bus_info *bus_info; ++struct mlxsw_hwmon_dev { ++ struct mlxsw_hwmon *hwmon; + struct device *hwmon_dev; + struct attribute_group group; + const struct attribute_group *groups[2]; +@@ -53,19 +52,26 @@ struct mlxsw_hwmon { + u8 module_sensor_max; + }; + ++struct mlxsw_hwmon { ++ struct mlxsw_core *core; ++ const struct mlxsw_bus_info *bus_info; ++ struct mlxsw_hwmon_dev *main; ++}; ++ + static ssize_t mlxsw_hwmon_temp_show(struct device *dev, + struct device_attribute *attr, + char *buf) + { + struct mlxsw_hwmon_attr *mlxsw_hwmon_attr = + container_of(attr, struct mlxsw_hwmon_attr, dev_attr); +- struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon; ++ struct mlxsw_hwmon_dev *mlxsw_hwmon_dev = mlxsw_hwmon_attr->mlxsw_hwmon_dev; ++ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon; + char mtmp_pl[MLXSW_REG_MTMP_LEN]; + int temp, index; + int err; + + index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index, +- mlxsw_hwmon->module_sensor_max); ++ mlxsw_hwmon_dev->module_sensor_max); + mlxsw_reg_mtmp_pack(mtmp_pl, 0, index, false, false); + err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl); + if (err) { +@@ -82,13 +88,14 @@ static ssize_t mlxsw_hwmon_temp_max_show(struct device *dev, + { + struct mlxsw_hwmon_attr *mlxsw_hwmon_attr = + container_of(attr, struct mlxsw_hwmon_attr, dev_attr); +- struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon; ++ struct mlxsw_hwmon_dev *mlxsw_hwmon_dev = mlxsw_hwmon_attr->mlxsw_hwmon_dev; ++ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon; + char mtmp_pl[MLXSW_REG_MTMP_LEN]; + int temp_max, index; + int err; + + index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index, +- mlxsw_hwmon->module_sensor_max); ++ mlxsw_hwmon_dev->module_sensor_max); + mlxsw_reg_mtmp_pack(mtmp_pl, 0, index, false, false); + err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl); + if (err) { +@@ -105,8 +112,9 @@ static ssize_t mlxsw_hwmon_temp_rst_store(struct device *dev, + { + struct mlxsw_hwmon_attr *mlxsw_hwmon_attr = + container_of(attr, struct mlxsw_hwmon_attr, dev_attr); +- struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon; +- char mtmp_pl[MLXSW_REG_MTMP_LEN] = {0}; ++ struct mlxsw_hwmon_dev *mlxsw_hwmon_dev = mlxsw_hwmon_attr->mlxsw_hwmon_dev; ++ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon; ++ char mtmp_pl[MLXSW_REG_MTMP_LEN]; + unsigned long val; + int index; + int err; +@@ -118,7 +126,7 @@ static ssize_t mlxsw_hwmon_temp_rst_store(struct device *dev, + return -EINVAL; + + index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index, +- mlxsw_hwmon->module_sensor_max); ++ mlxsw_hwmon_dev->module_sensor_max); + + mlxsw_reg_mtmp_sensor_index_set(mtmp_pl, index); + err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl); +@@ -140,7 +148,8 @@ static ssize_t mlxsw_hwmon_fan_rpm_show(struct device *dev, + { + struct mlxsw_hwmon_attr *mlxsw_hwmon_attr = + container_of(attr, struct mlxsw_hwmon_attr, dev_attr); +- struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon; ++ struct mlxsw_hwmon_dev *mlxsw_hwmon_dev = mlxsw_hwmon_attr->mlxsw_hwmon_dev; ++ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon; + char mfsm_pl[MLXSW_REG_MFSM_LEN]; + int err; + +@@ -159,7 +168,8 @@ static ssize_t mlxsw_hwmon_fan_fault_show(struct device *dev, + { + struct mlxsw_hwmon_attr *mlxsw_hwmon_attr = + container_of(attr, struct mlxsw_hwmon_attr, dev_attr); +- struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon; ++ struct mlxsw_hwmon_dev *mlxsw_hwmon_dev = mlxsw_hwmon_attr->mlxsw_hwmon_dev; ++ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon; + char fore_pl[MLXSW_REG_FORE_LEN]; + bool fault; + int err; +@@ -180,7 +190,8 @@ static ssize_t mlxsw_hwmon_pwm_show(struct device *dev, + { + struct mlxsw_hwmon_attr *mlxsw_hwmon_attr = + container_of(attr, struct mlxsw_hwmon_attr, dev_attr); +- struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon; ++ struct mlxsw_hwmon_dev *mlxsw_hwmon_dev = mlxsw_hwmon_attr->mlxsw_hwmon_dev; ++ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon; + char mfsc_pl[MLXSW_REG_MFSC_LEN]; + int err; + +@@ -200,7 +211,8 @@ static ssize_t mlxsw_hwmon_pwm_store(struct device *dev, + { + struct mlxsw_hwmon_attr *mlxsw_hwmon_attr = + container_of(attr, struct mlxsw_hwmon_attr, dev_attr); +- struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon; ++ struct mlxsw_hwmon_dev *mlxsw_hwmon_dev = mlxsw_hwmon_attr->mlxsw_hwmon_dev; ++ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon; + char mfsc_pl[MLXSW_REG_MFSC_LEN]; + unsigned long val; + int err; +@@ -226,12 +238,13 @@ static int mlxsw_hwmon_module_temp_get(struct device *dev, + { + struct mlxsw_hwmon_attr *mlxsw_hwmon_attr = + container_of(attr, struct mlxsw_hwmon_attr, dev_attr); +- struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon; ++ struct mlxsw_hwmon_dev *mlxsw_hwmon_dev = mlxsw_hwmon_attr->mlxsw_hwmon_dev; ++ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon; + char mtmp_pl[MLXSW_REG_MTMP_LEN]; + u8 module; + int err; + +- module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count; ++ module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon_dev->sensor_count; + mlxsw_reg_mtmp_pack(mtmp_pl, 0, + MLXSW_REG_MTMP_MODULE_INDEX_MIN + module, false, + false); +@@ -264,15 +277,16 @@ static ssize_t mlxsw_hwmon_module_temp_fault_show(struct device *dev, + { + struct mlxsw_hwmon_attr *mlxsw_hwmon_attr = + container_of(attr, struct mlxsw_hwmon_attr, dev_attr); +- struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon; ++ struct mlxsw_hwmon_dev *mlxsw_hwmon_dev = mlxsw_hwmon_attr->mlxsw_hwmon_dev; ++ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon; + char mtbr_pl[MLXSW_REG_MTBR_LEN] = {0}; + u8 module, fault; + u16 temp; + int err; + +- module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count; +- mlxsw_reg_mtbr_pack(mtbr_pl, 0, +- MLXSW_REG_MTBR_BASE_MODULE_INDEX + module, 1); ++ module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon_dev->sensor_count; ++ mlxsw_reg_mtbr_pack(mtbr_pl, 0, MLXSW_REG_MTBR_BASE_MODULE_INDEX + module, ++ 1); + err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtbr), mtbr_pl); + if (err) { + dev_err(dev, "Failed to query module temperature sensor\n"); +@@ -306,11 +320,12 @@ static int mlxsw_hwmon_module_temp_critical_get(struct device *dev, + { + struct mlxsw_hwmon_attr *mlxsw_hwmon_attr = + container_of(attr, struct mlxsw_hwmon_attr, dev_attr); +- struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon; ++ struct mlxsw_hwmon_dev *mlxsw_hwmon_dev = mlxsw_hwmon_attr->mlxsw_hwmon_dev; ++ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon; + u8 module; + int err; + +- module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count; ++ module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon_dev->sensor_count; + err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core, 0, + module, SFP_TEMP_HIGH_WARN, + p_temp); +@@ -341,11 +356,12 @@ static int mlxsw_hwmon_module_temp_emergency_get(struct device *dev, + { + struct mlxsw_hwmon_attr *mlxsw_hwmon_attr = + container_of(attr, struct mlxsw_hwmon_attr, dev_attr); +- struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon; ++ struct mlxsw_hwmon_dev *mlxsw_hwmon_dev = mlxsw_hwmon_attr->mlxsw_hwmon_dev; ++ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon; + u8 module; + int err; + +- module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count; ++ module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon_dev->sensor_count; + err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core, 0, + module, SFP_TEMP_HIGH_ALARM, + p_temp); +@@ -390,9 +406,9 @@ mlxsw_hwmon_gbox_temp_label_show(struct device *dev, + { + struct mlxsw_hwmon_attr *mlxsw_hwmon_attr = + container_of(attr, struct mlxsw_hwmon_attr, dev_attr); +- struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon; ++ struct mlxsw_hwmon_dev *mlxsw_hwmon_dev = mlxsw_hwmon_attr->mlxsw_hwmon_dev; + int index = mlxsw_hwmon_attr->type_index - +- mlxsw_hwmon->module_sensor_max + 1; ++ mlxsw_hwmon_dev->module_sensor_max + 1; + + return sprintf(buf, "gearbox %03u\n", index); + } +@@ -461,14 +477,15 @@ enum mlxsw_hwmon_attr_type { + MLXSW_HWMON_ATTR_TYPE_TEMP_EMERGENCY_ALARM, + }; + +-static void mlxsw_hwmon_attr_add(struct mlxsw_hwmon *mlxsw_hwmon, ++static void mlxsw_hwmon_attr_add(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev, + enum mlxsw_hwmon_attr_type attr_type, +- unsigned int type_index, unsigned int num) { ++ unsigned int type_index, unsigned int num) ++{ + struct mlxsw_hwmon_attr *mlxsw_hwmon_attr; + unsigned int attr_index; + +- attr_index = mlxsw_hwmon->attrs_count; +- mlxsw_hwmon_attr = &mlxsw_hwmon->hwmon_attrs[attr_index]; ++ attr_index = mlxsw_hwmon_dev->attrs_count; ++ mlxsw_hwmon_attr = &mlxsw_hwmon_dev->hwmon_attrs[attr_index]; + + switch (attr_type) { + case MLXSW_HWMON_ATTR_TYPE_TEMP: +@@ -568,16 +585,17 @@ static void mlxsw_hwmon_attr_add(struct mlxsw_hwmon *mlxsw_hwmon, + } + + mlxsw_hwmon_attr->type_index = type_index; +- mlxsw_hwmon_attr->hwmon = mlxsw_hwmon; ++ mlxsw_hwmon_attr->mlxsw_hwmon_dev = mlxsw_hwmon_dev; + mlxsw_hwmon_attr->dev_attr.attr.name = mlxsw_hwmon_attr->name; + sysfs_attr_init(&mlxsw_hwmon_attr->dev_attr.attr); + +- mlxsw_hwmon->attrs[attr_index] = &mlxsw_hwmon_attr->dev_attr.attr; +- mlxsw_hwmon->attrs_count++; ++ mlxsw_hwmon_dev->attrs[attr_index] = &mlxsw_hwmon_attr->dev_attr.attr; ++ mlxsw_hwmon_dev->attrs_count++; + } + +-static int mlxsw_hwmon_temp_init(struct mlxsw_hwmon *mlxsw_hwmon) ++static int mlxsw_hwmon_temp_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev) + { ++ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon; + char mtcap_pl[MLXSW_REG_MTCAP_LEN] = {0}; + int i; + int err; +@@ -587,8 +605,8 @@ static int mlxsw_hwmon_temp_init(struct mlxsw_hwmon *mlxsw_hwmon) + dev_err(mlxsw_hwmon->bus_info->dev, "Failed to get number of temp sensors\n"); + return err; + } +- mlxsw_hwmon->sensor_count = mlxsw_reg_mtcap_sensor_count_get(mtcap_pl); +- for (i = 0; i < mlxsw_hwmon->sensor_count; i++) { ++ mlxsw_hwmon_dev->sensor_count = mlxsw_reg_mtcap_sensor_count_get(mtcap_pl); ++ for (i = 0; i < mlxsw_hwmon_dev->sensor_count; i++) { + char mtmp_pl[MLXSW_REG_MTMP_LEN] = {0}; + + mlxsw_reg_mtmp_sensor_index_set(mtmp_pl, i); +@@ -605,18 +623,19 @@ static int mlxsw_hwmon_temp_init(struct mlxsw_hwmon *mlxsw_hwmon) + i); + return err; + } +- mlxsw_hwmon_attr_add(mlxsw_hwmon, ++ mlxsw_hwmon_attr_add(mlxsw_hwmon_dev, + MLXSW_HWMON_ATTR_TYPE_TEMP, i, i); +- mlxsw_hwmon_attr_add(mlxsw_hwmon, ++ mlxsw_hwmon_attr_add(mlxsw_hwmon_dev, + MLXSW_HWMON_ATTR_TYPE_TEMP_MAX, i, i); +- mlxsw_hwmon_attr_add(mlxsw_hwmon, ++ mlxsw_hwmon_attr_add(mlxsw_hwmon_dev, + MLXSW_HWMON_ATTR_TYPE_TEMP_RST, i, i); + } + return 0; + } + +-static int mlxsw_hwmon_fans_init(struct mlxsw_hwmon *mlxsw_hwmon) ++static int mlxsw_hwmon_fans_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev) + { ++ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon; + char mfcr_pl[MLXSW_REG_MFCR_LEN] = {0}; + enum mlxsw_reg_mfcr_pwm_frequency freq; + unsigned int type_index; +@@ -634,10 +653,10 @@ static int mlxsw_hwmon_fans_init(struct mlxsw_hwmon *mlxsw_hwmon) + num = 0; + for (type_index = 0; type_index < MLXSW_MFCR_TACHOS_MAX; type_index++) { + if (tacho_active & BIT(type_index)) { +- mlxsw_hwmon_attr_add(mlxsw_hwmon, ++ mlxsw_hwmon_attr_add(mlxsw_hwmon_dev, + MLXSW_HWMON_ATTR_TYPE_FAN_RPM, + type_index, num); +- mlxsw_hwmon_attr_add(mlxsw_hwmon, ++ mlxsw_hwmon_attr_add(mlxsw_hwmon_dev, + MLXSW_HWMON_ATTR_TYPE_FAN_FAULT, + type_index, num++); + } +@@ -645,15 +664,16 @@ static int mlxsw_hwmon_fans_init(struct mlxsw_hwmon *mlxsw_hwmon) + num = 0; + for (type_index = 0; type_index < MLXSW_MFCR_PWMS_MAX; type_index++) { + if (pwm_active & BIT(type_index)) +- mlxsw_hwmon_attr_add(mlxsw_hwmon, ++ mlxsw_hwmon_attr_add(mlxsw_hwmon_dev, + MLXSW_HWMON_ATTR_TYPE_PWM, + type_index, num++); + } + return 0; + } + +-static int mlxsw_hwmon_module_init(struct mlxsw_hwmon *mlxsw_hwmon) ++static int mlxsw_hwmon_module_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev) + { ++ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon; + char mgpir_pl[MLXSW_REG_MGPIR_LEN]; + u8 module_sensor_max; + int i, err; +@@ -671,28 +691,28 @@ static int mlxsw_hwmon_module_init(struct mlxsw_hwmon *mlxsw_hwmon) + * sensor_count are already utilized by the sensors connected through + * mtmp register by mlxsw_hwmon_temp_init(). + */ +- mlxsw_hwmon->module_sensor_max = mlxsw_hwmon->sensor_count + +- module_sensor_max; +- for (i = mlxsw_hwmon->sensor_count; +- i < mlxsw_hwmon->module_sensor_max; i++) { +- mlxsw_hwmon_attr_add(mlxsw_hwmon, ++ mlxsw_hwmon_dev->module_sensor_max = mlxsw_hwmon_dev->sensor_count + ++ module_sensor_max; ++ for (i = mlxsw_hwmon_dev->sensor_count; ++ i < mlxsw_hwmon_dev->module_sensor_max; i++) { ++ mlxsw_hwmon_attr_add(mlxsw_hwmon_dev, + MLXSW_HWMON_ATTR_TYPE_TEMP_MODULE, i, i); +- mlxsw_hwmon_attr_add(mlxsw_hwmon, ++ mlxsw_hwmon_attr_add(mlxsw_hwmon_dev, + MLXSW_HWMON_ATTR_TYPE_TEMP_MODULE_FAULT, + i, i); +- mlxsw_hwmon_attr_add(mlxsw_hwmon, ++ mlxsw_hwmon_attr_add(mlxsw_hwmon_dev, + MLXSW_HWMON_ATTR_TYPE_TEMP_MODULE_CRIT, i, + i); +- mlxsw_hwmon_attr_add(mlxsw_hwmon, ++ mlxsw_hwmon_attr_add(mlxsw_hwmon_dev, + MLXSW_HWMON_ATTR_TYPE_TEMP_MODULE_EMERG, + i, i); +- mlxsw_hwmon_attr_add(mlxsw_hwmon, ++ mlxsw_hwmon_attr_add(mlxsw_hwmon_dev, + MLXSW_HWMON_ATTR_TYPE_TEMP_MODULE_LABEL, + i, i); +- mlxsw_hwmon_attr_add(mlxsw_hwmon, ++ mlxsw_hwmon_attr_add(mlxsw_hwmon_dev, + MLXSW_HWMON_ATTR_TYPE_TEMP_CRIT_ALARM, + i, i); +- mlxsw_hwmon_attr_add(mlxsw_hwmon, ++ mlxsw_hwmon_attr_add(mlxsw_hwmon_dev, + MLXSW_HWMON_ATTR_TYPE_TEMP_EMERGENCY_ALARM, + i, i); + } +@@ -701,8 +721,10 @@ static int mlxsw_hwmon_module_init(struct mlxsw_hwmon *mlxsw_hwmon) + } + + static int +-mlxsw_hwmon_gearbox_main_init(struct mlxsw_hwmon *mlxsw_hwmon, u8 *gbox_num) ++mlxsw_hwmon_gearbox_main_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev, ++ u8 *gbox_num) + { ++ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon; + enum mlxsw_reg_mgpir_device_type device_type; + char mgpir_pl[MLXSW_REG_MGPIR_LEN]; + int err; +@@ -721,13 +743,14 @@ mlxsw_hwmon_gearbox_main_init(struct mlxsw_hwmon *mlxsw_hwmon, u8 *gbox_num) + } + + static void +-mlxsw_hwmon_gearbox_main_fini(struct mlxsw_hwmon *mlxsw_hwmon) ++mlxsw_hwmon_gearbox_main_fini(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev) + { + } + + static int +-mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon *mlxsw_hwmon, u8 gbox_num) ++mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev, u8 gbox_num) + { ++ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon; + int index, max_index, sensor_index; + char mtmp_pl[MLXSW_REG_MTMP_LEN]; + int err; +@@ -735,10 +758,10 @@ mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon *mlxsw_hwmon, u8 gbox_num) + if (!gbox_num) + return 0; + +- index = mlxsw_hwmon->module_sensor_max; +- max_index = mlxsw_hwmon->module_sensor_max + gbox_num; ++ index = mlxsw_hwmon_dev->module_sensor_max; ++ max_index = mlxsw_hwmon_dev->module_sensor_max + gbox_num; + while (index < max_index) { +- sensor_index = index % mlxsw_hwmon->module_sensor_max + ++ sensor_index = index % mlxsw_hwmon_dev->module_sensor_max + + MLXSW_REG_MTMP_GBOX_INDEX_MIN; + mlxsw_reg_mtmp_pack(mtmp_pl, 0, sensor_index, true, true); + err = mlxsw_reg_write(mlxsw_hwmon->core, +@@ -748,15 +771,15 @@ mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon *mlxsw_hwmon, u8 gbox_num) + sensor_index); + return err; + } +- mlxsw_hwmon_attr_add(mlxsw_hwmon, MLXSW_HWMON_ATTR_TYPE_TEMP, +- index, index); +- mlxsw_hwmon_attr_add(mlxsw_hwmon, ++ mlxsw_hwmon_attr_add(mlxsw_hwmon_dev, ++ MLXSW_HWMON_ATTR_TYPE_TEMP, index, index); ++ mlxsw_hwmon_attr_add(mlxsw_hwmon_dev, + MLXSW_HWMON_ATTR_TYPE_TEMP_MAX, index, + index); +- mlxsw_hwmon_attr_add(mlxsw_hwmon, ++ mlxsw_hwmon_attr_add(mlxsw_hwmon_dev, + MLXSW_HWMON_ATTR_TYPE_TEMP_RST, index, + index); +- mlxsw_hwmon_attr_add(mlxsw_hwmon, ++ mlxsw_hwmon_attr_add(mlxsw_hwmon_dev, + MLXSW_HWMON_ATTR_TYPE_TEMP_GBOX_LABEL, + index, index); + index++; +@@ -777,58 +800,67 @@ int mlxsw_hwmon_init(struct mlxsw_core *mlxsw_core, + mlxsw_hwmon = kzalloc(sizeof(*mlxsw_hwmon), GFP_KERNEL); + if (!mlxsw_hwmon) + return -ENOMEM; ++ mlxsw_hwmon->main = kzalloc(sizeof(*mlxsw_hwmon->main), GFP_KERNEL); ++ if (!mlxsw_hwmon->main) { ++ err = -ENOMEM; ++ goto err_hwmon_main_init; ++ } + mlxsw_hwmon->core = mlxsw_core; + mlxsw_hwmon->bus_info = mlxsw_bus_info; ++ mlxsw_hwmon->main->hwmon = mlxsw_hwmon; + +- err = mlxsw_hwmon_temp_init(mlxsw_hwmon); ++ err = mlxsw_hwmon_temp_init(mlxsw_hwmon->main); + if (err) + goto err_temp_init; + +- err = mlxsw_hwmon_fans_init(mlxsw_hwmon); ++ err = mlxsw_hwmon_fans_init(mlxsw_hwmon->main); + if (err) + goto err_fans_init; + +- err = mlxsw_hwmon_module_init(mlxsw_hwmon); ++ err = mlxsw_hwmon_module_init(mlxsw_hwmon->main); + if (err) + goto err_temp_module_init; + +- err = mlxsw_hwmon_gearbox_main_init(mlxsw_hwmon, &gbox_num); ++ err = mlxsw_hwmon_gearbox_main_init(mlxsw_hwmon->main, &gbox_num); + if (err) + goto err_gearbox_main_init; + +- err = mlxsw_hwmon_gearbox_init(mlxsw_hwmon, gbox_num); ++ err = mlxsw_hwmon_gearbox_init(mlxsw_hwmon->main, gbox_num); + if (err) + goto err_gearbox_init; + +- mlxsw_hwmon->groups[0] = &mlxsw_hwmon->group; +- mlxsw_hwmon->group.attrs = mlxsw_hwmon->attrs; ++ mlxsw_hwmon->main->groups[0] = &mlxsw_hwmon->main->group; ++ mlxsw_hwmon->main->group.attrs = mlxsw_hwmon->main->attrs; + + hwmon_dev = hwmon_device_register_with_groups(mlxsw_bus_info->dev, +- "mlxsw", mlxsw_hwmon, +- mlxsw_hwmon->groups); ++ "mlxsw", mlxsw_hwmon->main, ++ mlxsw_hwmon->main->groups); + if (IS_ERR(hwmon_dev)) { + err = PTR_ERR(hwmon_dev); + goto err_hwmon_register; + } + +- mlxsw_hwmon->hwmon_dev = hwmon_dev; ++ mlxsw_hwmon->main->hwmon_dev = hwmon_dev; + *p_hwmon = mlxsw_hwmon; + return 0; + + err_hwmon_register: + err_gearbox_init: +- mlxsw_hwmon_gearbox_main_fini(mlxsw_hwmon); ++ mlxsw_hwmon_gearbox_main_fini(mlxsw_hwmon->main); + err_gearbox_main_init: + err_temp_module_init: + err_fans_init: + err_temp_init: ++ kfree(mlxsw_hwmon->main); ++err_hwmon_main_init: + kfree(mlxsw_hwmon); + return err; + } + + void mlxsw_hwmon_fini(struct mlxsw_hwmon *mlxsw_hwmon) + { +- hwmon_device_unregister(mlxsw_hwmon->hwmon_dev); +- mlxsw_hwmon_gearbox_main_fini(mlxsw_hwmon); ++ hwmon_device_unregister(mlxsw_hwmon->main->hwmon_dev); ++ mlxsw_hwmon_gearbox_main_fini(mlxsw_hwmon->main); ++ kfree(mlxsw_hwmon->main); + kfree(mlxsw_hwmon); + } +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0117-mlxsw-core_hwmon-Introduce-slot-parameter-in-hwmon-i.patch b/platform/mellanox/non-upstream-patches/patches/0117-mlxsw-core_hwmon-Introduce-slot-parameter-in-hwmon-i.patch new file mode 100644 index 000000000000..43208f6d2c3a --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0117-mlxsw-core_hwmon-Introduce-slot-parameter-in-hwmon-i.patch @@ -0,0 +1,129 @@ +From aa8cdb2df37cbfb7bb37f90879d385428e32ae23 Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Tue, 14 Dec 2021 10:57:31 +0200 +Subject: [PATCH] mlxsw: core_hwmon: Introduce slot parameter in hwmon + interfaces + +Add 'slot' parameter to 'mlxsw_hwmon_dev' structure. Use this parameter +in mlxsw_reg_mtmp_pack(), mlxsw_reg_mtbr_pack() and +Use mlxsw_reg_mtmp_slot_index_set() routines. +For main board it'll always be zero, for line cards it'll be set to +the physical slot number in modular systems. + +Signed-off-by: Vadim Pasternak +Reviewed-by: Jiri Pirko +Signed-off-by: Ido Schimmel +--- + .../net/ethernet/mellanox/mlxsw/core_hwmon.c | 26 +++++++++++++------ + 1 file changed, 18 insertions(+), 8 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c +index 31b370862..0d7edabf1 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c +@@ -50,6 +50,7 @@ struct mlxsw_hwmon_dev { + unsigned int attrs_count; + u8 sensor_count; + u8 module_sensor_max; ++ u8 slot_index; + }; + + struct mlxsw_hwmon { +@@ -72,7 +73,8 @@ static ssize_t mlxsw_hwmon_temp_show(struct device *dev, + + index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index, + mlxsw_hwmon_dev->module_sensor_max); +- mlxsw_reg_mtmp_pack(mtmp_pl, 0, index, false, false); ++ mlxsw_reg_mtmp_pack(mtmp_pl, mlxsw_hwmon_dev->slot_index, index, false, ++ false); + err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl); + if (err) { + dev_err(mlxsw_hwmon->bus_info->dev, "Failed to query temp sensor\n"); +@@ -96,7 +98,8 @@ static ssize_t mlxsw_hwmon_temp_max_show(struct device *dev, + + index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index, + mlxsw_hwmon_dev->module_sensor_max); +- mlxsw_reg_mtmp_pack(mtmp_pl, 0, index, false, false); ++ mlxsw_reg_mtmp_pack(mtmp_pl, mlxsw_hwmon_dev->slot_index, index, false, ++ false); + err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl); + if (err) { + dev_err(mlxsw_hwmon->bus_info->dev, "Failed to query temp sensor\n"); +@@ -128,6 +131,7 @@ static ssize_t mlxsw_hwmon_temp_rst_store(struct device *dev, + index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index, + mlxsw_hwmon_dev->module_sensor_max); + ++ mlxsw_reg_mtmp_slot_index_set(mtmp_pl, mlxsw_hwmon_dev->slot_index); + mlxsw_reg_mtmp_sensor_index_set(mtmp_pl, index); + err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl); + if (err) +@@ -245,7 +249,7 @@ static int mlxsw_hwmon_module_temp_get(struct device *dev, + int err; + + module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon_dev->sensor_count; +- mlxsw_reg_mtmp_pack(mtmp_pl, 0, ++ mlxsw_reg_mtmp_pack(mtmp_pl, mlxsw_hwmon_dev->slot_index, + MLXSW_REG_MTMP_MODULE_INDEX_MIN + module, false, + false); + err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl); +@@ -285,8 +289,8 @@ static ssize_t mlxsw_hwmon_module_temp_fault_show(struct device *dev, + int err; + + module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon_dev->sensor_count; +- mlxsw_reg_mtbr_pack(mtbr_pl, 0, MLXSW_REG_MTBR_BASE_MODULE_INDEX + module, +- 1); ++ mlxsw_reg_mtbr_pack(mtbr_pl, mlxsw_hwmon_dev->slot_index, ++ MLXSW_REG_MTBR_BASE_MODULE_INDEX + module, 1); + err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtbr), mtbr_pl); + if (err) { + dev_err(dev, "Failed to query module temperature sensor\n"); +@@ -326,7 +330,8 @@ static int mlxsw_hwmon_module_temp_critical_get(struct device *dev, + int err; + + module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon_dev->sensor_count; +- err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core, 0, ++ err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core, ++ mlxsw_hwmon_dev->slot_index, + module, SFP_TEMP_HIGH_WARN, + p_temp); + if (err) { +@@ -362,7 +367,8 @@ static int mlxsw_hwmon_module_temp_emergency_get(struct device *dev, + int err; + + module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon_dev->sensor_count; +- err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core, 0, ++ err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core, ++ mlxsw_hwmon_dev->slot_index, + module, SFP_TEMP_HIGH_ALARM, + p_temp); + if (err) { +@@ -609,6 +615,8 @@ static int mlxsw_hwmon_temp_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev) + for (i = 0; i < mlxsw_hwmon_dev->sensor_count; i++) { + char mtmp_pl[MLXSW_REG_MTMP_LEN] = {0}; + ++ mlxsw_reg_mtmp_slot_index_set(mtmp_pl, ++ mlxsw_hwmon_dev->slot_index); + mlxsw_reg_mtmp_sensor_index_set(mtmp_pl, i); + err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), + mtmp_pl); +@@ -763,7 +771,8 @@ mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev, u8 gbox_num) + while (index < max_index) { + sensor_index = index % mlxsw_hwmon_dev->module_sensor_max + + MLXSW_REG_MTMP_GBOX_INDEX_MIN; +- mlxsw_reg_mtmp_pack(mtmp_pl, 0, sensor_index, true, true); ++ mlxsw_reg_mtmp_pack(mtmp_pl, mlxsw_hwmon_dev->slot_index, ++ sensor_index, true, true); + err = mlxsw_reg_write(mlxsw_hwmon->core, + MLXSW_REG(mtmp), mtmp_pl); + if (err) { +@@ -808,6 +817,7 @@ int mlxsw_hwmon_init(struct mlxsw_core *mlxsw_core, + mlxsw_hwmon->core = mlxsw_core; + mlxsw_hwmon->bus_info = mlxsw_bus_info; + mlxsw_hwmon->main->hwmon = mlxsw_hwmon; ++ mlxsw_hwmon->main->slot_index = 0; + + err = mlxsw_hwmon_temp_init(mlxsw_hwmon->main); + if (err) +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0118-mlxsw-core_hwmon-Extend-hwmon-device-with-gearbox-ma.patch b/platform/mellanox/non-upstream-patches/patches/0118-mlxsw-core_hwmon-Extend-hwmon-device-with-gearbox-ma.patch new file mode 100644 index 000000000000..f88c8721bcbd --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0118-mlxsw-core_hwmon-Extend-hwmon-device-with-gearbox-ma.patch @@ -0,0 +1,136 @@ +From 94d3b63c64fc202bfe525cc3b500c23e92d38fbf Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Tue, 14 Dec 2021 10:57:32 +0200 +Subject: [PATCH] mlxsw: core_hwmon: Extend hwmon device with gearbox mapping + field + +Add gearbox mapping field to 'mlxsw_hwmon_dev' structure. It should +provide the mapping for gearbox sensor indexes, given gearbox number. +For main board mapping is supposed to be always sequential, while for +line cards on modular system it could be non-sequential. + +Signed-off-by: Vadim Pasternak +Reviewed-by: Jiri Pirko +Signed-off-by: Ido Schimmel +--- + .../net/ethernet/mellanox/mlxsw/core_hwmon.c | 40 ++++++++++++++----- + 1 file changed, 31 insertions(+), 9 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c +index 0d7edabf1..6af23f472 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c +@@ -32,10 +32,11 @@ struct mlxsw_hwmon_attr { + char name[32]; + }; + +-static int mlxsw_hwmon_get_attr_index(int index, int count) ++static int ++mlxsw_hwmon_get_attr_index(int index, int count, u16 *gearbox_sensor_map) + { + if (index >= count) +- return index % count + MLXSW_REG_MTMP_GBOX_INDEX_MIN; ++ return gearbox_sensor_map[index % count]; + + return index; + } +@@ -50,6 +51,7 @@ struct mlxsw_hwmon_dev { + unsigned int attrs_count; + u8 sensor_count; + u8 module_sensor_max; ++ u16 *gearbox_sensor_map; + u8 slot_index; + }; + +@@ -72,7 +74,8 @@ static ssize_t mlxsw_hwmon_temp_show(struct device *dev, + int err; + + index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index, +- mlxsw_hwmon_dev->module_sensor_max); ++ mlxsw_hwmon_dev->module_sensor_max, ++ mlxsw_hwmon_dev->gearbox_sensor_map); + mlxsw_reg_mtmp_pack(mtmp_pl, mlxsw_hwmon_dev->slot_index, index, false, + false); + err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl); +@@ -97,7 +100,8 @@ static ssize_t mlxsw_hwmon_temp_max_show(struct device *dev, + int err; + + index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index, +- mlxsw_hwmon_dev->module_sensor_max); ++ mlxsw_hwmon_dev->module_sensor_max, ++ mlxsw_hwmon_dev->gearbox_sensor_map); + mlxsw_reg_mtmp_pack(mtmp_pl, mlxsw_hwmon_dev->slot_index, index, false, + false); + err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl); +@@ -129,7 +133,8 @@ static ssize_t mlxsw_hwmon_temp_rst_store(struct device *dev, + return -EINVAL; + + index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index, +- mlxsw_hwmon_dev->module_sensor_max); ++ mlxsw_hwmon_dev->module_sensor_max, ++ mlxsw_hwmon_dev->gearbox_sensor_map); + + mlxsw_reg_mtmp_slot_index_set(mtmp_pl, mlxsw_hwmon_dev->slot_index); + mlxsw_reg_mtmp_sensor_index_set(mtmp_pl, index); +@@ -735,7 +740,7 @@ mlxsw_hwmon_gearbox_main_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev, + struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon; + enum mlxsw_reg_mgpir_device_type device_type; + char mgpir_pl[MLXSW_REG_MGPIR_LEN]; +- int err; ++ int i, err; + + mlxsw_reg_mgpir_pack(mgpir_pl, 0); + err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mgpir), mgpir_pl); +@@ -747,12 +752,30 @@ mlxsw_hwmon_gearbox_main_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev, + if (device_type != MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE) + *gbox_num = 0; + ++ /* Skip gearbox sensor mapping array allocation, if no gearboxes are ++ * available. ++ */ ++ if (!*gbox_num) ++ return 0; ++ ++ mlxsw_hwmon_dev->gearbox_sensor_map = kmalloc_array(*gbox_num, ++ sizeof(u16), ++ GFP_KERNEL); ++ if (!mlxsw_hwmon_dev->gearbox_sensor_map) ++ return -ENOMEM; ++ ++ /* Fill out gearbox sensor mapping array. */ ++ for (i = 0; i < *gbox_num; i++) ++ mlxsw_hwmon_dev->gearbox_sensor_map[i] = ++ MLXSW_REG_MTMP_GBOX_INDEX_MIN + i; ++ + return 0; + } + + static void + mlxsw_hwmon_gearbox_main_fini(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev) + { ++ kfree(mlxsw_hwmon_dev->gearbox_sensor_map); + } + + static int +@@ -761,7 +784,7 @@ mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev, u8 gbox_num) + struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon; + int index, max_index, sensor_index; + char mtmp_pl[MLXSW_REG_MTMP_LEN]; +- int err; ++ int i = 0, err; + + if (!gbox_num) + return 0; +@@ -769,8 +792,7 @@ mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev, u8 gbox_num) + index = mlxsw_hwmon_dev->module_sensor_max; + max_index = mlxsw_hwmon_dev->module_sensor_max + gbox_num; + while (index < max_index) { +- sensor_index = index % mlxsw_hwmon_dev->module_sensor_max + +- MLXSW_REG_MTMP_GBOX_INDEX_MIN; ++ sensor_index = mlxsw_hwmon_dev->gearbox_sensor_map[i++]; + mlxsw_reg_mtmp_pack(mtmp_pl, mlxsw_hwmon_dev->slot_index, + sensor_index, true, true); + err = mlxsw_reg_write(mlxsw_hwmon->core, +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0119-mlxsw-core_thermal-Extend-internal-structures-to-sup.patch b/platform/mellanox/non-upstream-patches/patches/0119-mlxsw-core_thermal-Extend-internal-structures-to-sup.patch new file mode 100644 index 000000000000..cf6199aa186f --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0119-mlxsw-core_thermal-Extend-internal-structures-to-sup.patch @@ -0,0 +1,367 @@ +From ab0f9b9dd1f7326242eee0b0a643d6d34e557ae3 Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Tue, 14 Dec 2021 10:57:33 +0200 +Subject: [PATCH] mlxsw: core_thermal: Extend internal structures to support + multi thermal areas + +Introduce intermediate level for thermal zones areas. +Currently all thermal zones are associated with thermal objects located +within the main board. Such objects are created during driver +initialization and removed during driver de-initialization. + +For line cards in modular system the thermal zones are to be associated +with the specific line card. They should be created whenever new line +card is available (inserted, validated, powered and enabled) and +removed, when line card is getting unavailable. +The thermal objects found on the line card #n are accessed by setting +slot index to #n, while for access to objects found on the main board +slot index should be set to default value zero. + +Each thermal area contains the set of thermal zones associated with +particular slot index. +Thus introduction of thermal zone areas allows to use the same APIs for +the main board and line cards, by adding slot index argument. + +Signed-off-by: Vadim Pasternak +Signed-off-by: Ido Schimmel +--- + .../ethernet/mellanox/mlxsw/core_thermal.c | 134 +++++++++++------- + 1 file changed, 83 insertions(+), 51 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +index 3f9062f1c..77a484a55 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +@@ -91,6 +91,15 @@ struct mlxsw_thermal_module { + struct thermal_zone_device *tzdev; + struct mlxsw_thermal_trip trips[MLXSW_THERMAL_NUM_TRIPS]; + int module; /* Module or gearbox number */ ++ u8 slot_index; ++}; ++ ++struct mlxsw_thermal_area { ++ struct mlxsw_thermal_module *tz_module_arr; ++ u8 tz_module_num; ++ struct mlxsw_thermal_module *tz_gearbox_arr; ++ u8 tz_gearbox_num; ++ u8 slot_index; + }; + + struct mlxsw_thermal { +@@ -101,10 +110,7 @@ struct mlxsw_thermal { + struct thermal_cooling_device *cdevs[MLXSW_MFCR_PWMS_MAX]; + u8 cooling_levels[MLXSW_THERMAL_MAX_STATE + 1]; + struct mlxsw_thermal_trip trips[MLXSW_THERMAL_NUM_TRIPS]; +- struct mlxsw_thermal_module *tz_module_arr; +- u8 tz_module_num; +- struct mlxsw_thermal_module *tz_gearbox_arr; +- u8 tz_gearbox_num; ++ struct mlxsw_thermal_area *main; + unsigned int tz_highest_score; + struct thermal_zone_device *tz_highest_dev; + }; +@@ -159,13 +165,15 @@ mlxsw_thermal_module_trips_update(struct device *dev, struct mlxsw_core *core, + * EEPROM if we got valid thresholds from MTMP. + */ + if (!emerg_temp || !crit_temp) { +- err = mlxsw_env_module_temp_thresholds_get(core, 0, tz->module, ++ err = mlxsw_env_module_temp_thresholds_get(core, tz->slot_index, ++ tz->module, + SFP_TEMP_HIGH_WARN, + &crit_temp); + if (err) + return err; + +- err = mlxsw_env_module_temp_thresholds_get(core, 0, tz->module, ++ err = mlxsw_env_module_temp_thresholds_get(core, tz->slot_index, ++ tz->module, + SFP_TEMP_HIGH_ALARM, + &emerg_temp); + if (err) +@@ -432,15 +440,16 @@ static int mlxsw_thermal_module_unbind(struct thermal_zone_device *tzdev, + + static void + mlxsw_thermal_module_temp_and_thresholds_get(struct mlxsw_core *core, +- u16 sensor_index, int *p_temp, +- int *p_crit_temp, ++ u8 slot_index, u16 sensor_index, ++ int *p_temp, int *p_crit_temp, + int *p_emerg_temp) + { + char mtmp_pl[MLXSW_REG_MTMP_LEN]; + int err; + + /* Read module temperature and thresholds. */ +- mlxsw_reg_mtmp_pack(mtmp_pl, 0, sensor_index, false, false); ++ mlxsw_reg_mtmp_pack(mtmp_pl, slot_index, sensor_index, ++ false, false); + err = mlxsw_reg_query(core, MLXSW_REG(mtmp), mtmp_pl); + if (err) { + /* Set temperature and thresholds to zero to avoid passing +@@ -471,6 +480,7 @@ static int mlxsw_thermal_module_temp_get(struct thermal_zone_device *tzdev, + + /* Read module temperature and thresholds. */ + mlxsw_thermal_module_temp_and_thresholds_get(thermal->core, ++ tz->slot_index, + sensor_index, &temp, + &crit_temp, &emerg_temp); + *p_temp = temp; +@@ -585,7 +595,7 @@ static int mlxsw_thermal_gearbox_temp_get(struct thermal_zone_device *tzdev, + int err; + + index = MLXSW_REG_MTMP_GBOX_INDEX_MIN + tz->module; +- mlxsw_reg_mtmp_pack(mtmp_pl, 0, index, false, false); ++ mlxsw_reg_mtmp_pack(mtmp_pl, tz->slot_index, index, false, false); + + err = mlxsw_reg_query(thermal->core, MLXSW_REG(mtmp), mtmp_pl); + if (err) +@@ -745,25 +755,28 @@ static void mlxsw_thermal_module_tz_fini(struct thermal_zone_device *tzdev) + + static int + mlxsw_thermal_module_init(struct device *dev, struct mlxsw_core *core, +- struct mlxsw_thermal *thermal, u8 module) ++ struct mlxsw_thermal *thermal, ++ struct mlxsw_thermal_area *area, u8 module) + { + struct mlxsw_thermal_module *module_tz; + int dummy_temp, crit_temp, emerg_temp; + u16 sensor_index; + + sensor_index = MLXSW_REG_MTMP_MODULE_INDEX_MIN + module; +- module_tz = &thermal->tz_module_arr[module]; ++ module_tz = &area->tz_module_arr[module]; + /* Skip if parent is already set (case of port split). */ + if (module_tz->parent) + return 0; + module_tz->module = module; ++ module_tz->slot_index = area->slot_index; + module_tz->parent = thermal; + memcpy(module_tz->trips, default_thermal_trips, + sizeof(thermal->trips)); + /* Initialize all trip point. */ + mlxsw_thermal_module_trips_reset(module_tz); + /* Read module temperature and thresholds. */ +- mlxsw_thermal_module_temp_and_thresholds_get(core, sensor_index, &dummy_temp, ++ mlxsw_thermal_module_temp_and_thresholds_get(core, area->slot_index, ++ sensor_index, &dummy_temp, + &crit_temp, &emerg_temp); + /* Update trip point according to the module data. */ + return mlxsw_thermal_module_trips_update(dev, core, module_tz, +@@ -781,34 +794,39 @@ static void mlxsw_thermal_module_fini(struct mlxsw_thermal_module *module_tz) + + static int + mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core, +- struct mlxsw_thermal *thermal) ++ struct mlxsw_thermal *thermal, ++ struct mlxsw_thermal_area *area) + { + struct mlxsw_thermal_module *module_tz; + char mgpir_pl[MLXSW_REG_MGPIR_LEN]; + int i, err; + +- mlxsw_reg_mgpir_pack(mgpir_pl, 0); ++ mlxsw_reg_mgpir_pack(mgpir_pl, area->slot_index); + err = mlxsw_reg_query(core, MLXSW_REG(mgpir), mgpir_pl); + if (err) + return err; + + mlxsw_reg_mgpir_unpack(mgpir_pl, NULL, NULL, NULL, +- &thermal->tz_module_num, NULL); ++ &area->tz_module_num, NULL); + +- thermal->tz_module_arr = kcalloc(thermal->tz_module_num, +- sizeof(*thermal->tz_module_arr), +- GFP_KERNEL); +- if (!thermal->tz_module_arr) ++ /* For modular system module counter could be zero. */ ++ if (!area->tz_module_num) ++ return 0; ++ ++ area->tz_module_arr = kcalloc(area->tz_module_num, ++ sizeof(*area->tz_module_arr), ++ GFP_KERNEL); ++ if (!area->tz_module_arr) + return -ENOMEM; + +- for (i = 0; i < thermal->tz_module_num; i++) { +- err = mlxsw_thermal_module_init(dev, core, thermal, i); ++ for (i = 0; i < area->tz_module_num; i++) { ++ err = mlxsw_thermal_module_init(dev, core, thermal, area, i); + if (err) + goto err_thermal_module_init; + } + +- for (i = 0; i < thermal->tz_module_num; i++) { +- module_tz = &thermal->tz_module_arr[i]; ++ for (i = 0; i < area->tz_module_num; i++) { ++ module_tz = &area->tz_module_arr[i]; + if (!module_tz->parent) + continue; + err = mlxsw_thermal_module_tz_init(module_tz); +@@ -820,20 +838,21 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core, + + err_thermal_module_tz_init: + err_thermal_module_init: +- for (i = thermal->tz_module_num - 1; i >= 0; i--) +- mlxsw_thermal_module_fini(&thermal->tz_module_arr[i]); +- kfree(thermal->tz_module_arr); ++ for (i = area->tz_module_num - 1; i >= 0; i--) ++ mlxsw_thermal_module_fini(&area->tz_module_arr[i]); ++ kfree(area->tz_module_arr); + return err; + } + + static void +-mlxsw_thermal_modules_fini(struct mlxsw_thermal *thermal) ++mlxsw_thermal_modules_fini(struct mlxsw_thermal *thermal, ++ struct mlxsw_thermal_area *area) + { + int i; + +- for (i = thermal->tz_module_num - 1; i >= 0; i--) +- mlxsw_thermal_module_fini(&thermal->tz_module_arr[i]); +- kfree(thermal->tz_module_arr); ++ for (i = area->tz_module_num - 1; i >= 0; i--) ++ mlxsw_thermal_module_fini(&area->tz_module_arr[i]); ++ kfree(area->tz_module_arr); + } + + static int +@@ -869,7 +888,8 @@ mlxsw_thermal_gearbox_tz_fini(struct mlxsw_thermal_module *gearbox_tz) + + static int + mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core, +- struct mlxsw_thermal *thermal) ++ struct mlxsw_thermal *thermal, ++ struct mlxsw_thermal_area *area) + { + enum mlxsw_reg_mgpir_device_type device_type; + struct mlxsw_thermal_module *gearbox_tz; +@@ -889,19 +909,20 @@ mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core, + !gbox_num) + return 0; + +- thermal->tz_gearbox_num = gbox_num; +- thermal->tz_gearbox_arr = kcalloc(thermal->tz_gearbox_num, +- sizeof(*thermal->tz_gearbox_arr), +- GFP_KERNEL); +- if (!thermal->tz_gearbox_arr) ++ area->tz_gearbox_num = gbox_num; ++ area->tz_gearbox_arr = kcalloc(area->tz_gearbox_num, ++ sizeof(*area->tz_gearbox_arr), ++ GFP_KERNEL); ++ if (!area->tz_gearbox_arr) + return -ENOMEM; + +- for (i = 0; i < thermal->tz_gearbox_num; i++) { +- gearbox_tz = &thermal->tz_gearbox_arr[i]; ++ for (i = 0; i < area->tz_gearbox_num; i++) { ++ gearbox_tz = &area->tz_gearbox_arr[i]; + memcpy(gearbox_tz->trips, default_thermal_trips, + sizeof(thermal->trips)); + gearbox_tz->module = i; + gearbox_tz->parent = thermal; ++ gearbox_tz->slot_index = area->slot_index; + err = mlxsw_thermal_gearbox_tz_init(gearbox_tz); + if (err) + goto err_thermal_gearbox_tz_init; +@@ -911,19 +932,20 @@ mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core, + + err_thermal_gearbox_tz_init: + for (i--; i >= 0; i--) +- mlxsw_thermal_gearbox_tz_fini(&thermal->tz_gearbox_arr[i]); +- kfree(thermal->tz_gearbox_arr); ++ mlxsw_thermal_gearbox_tz_fini(&area->tz_gearbox_arr[i]); ++ kfree(area->tz_gearbox_arr); + return err; + } + + static void +-mlxsw_thermal_gearboxes_fini(struct mlxsw_thermal *thermal) ++mlxsw_thermal_gearboxes_fini(struct mlxsw_thermal *thermal, ++ struct mlxsw_thermal_area *area) + { + int i; + +- for (i = thermal->tz_gearbox_num - 1; i >= 0; i--) +- mlxsw_thermal_gearbox_tz_fini(&thermal->tz_gearbox_arr[i]); +- kfree(thermal->tz_gearbox_arr); ++ for (i = area->tz_gearbox_num - 1; i >= 0; i--) ++ mlxsw_thermal_gearbox_tz_fini(&area->tz_gearbox_arr[i]); ++ kfree(area->tz_gearbox_arr); + } + + int mlxsw_thermal_init(struct mlxsw_core *core, +@@ -943,9 +965,16 @@ int mlxsw_thermal_init(struct mlxsw_core *core, + if (!thermal) + return -ENOMEM; + ++ thermal->main = devm_kzalloc(dev, sizeof(*thermal->main), GFP_KERNEL); ++ if (!thermal->main) { ++ err = -ENOMEM; ++ goto err_devm_kzalloc; ++ } ++ + thermal->core = core; + thermal->bus_info = bus_info; + memcpy(thermal->trips, default_thermal_trips, sizeof(thermal->trips)); ++ thermal->main->slot_index = 0; + + err = mlxsw_reg_query(thermal->core, MLXSW_REG(mfcr), mfcr_pl); + if (err) { +@@ -1012,11 +1041,11 @@ int mlxsw_thermal_init(struct mlxsw_core *core, + goto err_thermal_zone_device_register; + } + +- err = mlxsw_thermal_modules_init(dev, core, thermal); ++ err = mlxsw_thermal_modules_init(dev, core, thermal, thermal->main); + if (err) + goto err_thermal_modules_init; + +- err = mlxsw_thermal_gearboxes_init(dev, core, thermal); ++ err = mlxsw_thermal_gearboxes_init(dev, core, thermal, thermal->main); + if (err) + goto err_thermal_gearboxes_init; + +@@ -1028,9 +1057,9 @@ int mlxsw_thermal_init(struct mlxsw_core *core, + return 0; + + err_thermal_zone_device_enable: +- mlxsw_thermal_gearboxes_fini(thermal); ++ mlxsw_thermal_gearboxes_fini(thermal, thermal->main); + err_thermal_gearboxes_init: +- mlxsw_thermal_modules_fini(thermal); ++ mlxsw_thermal_modules_fini(thermal, thermal->main); + err_thermal_modules_init: + if (thermal->tzdev) { + thermal_zone_device_unregister(thermal->tzdev); +@@ -1043,6 +1072,8 @@ int mlxsw_thermal_init(struct mlxsw_core *core, + thermal_cooling_device_unregister(thermal->cdevs[i]); + err_reg_write: + err_reg_query: ++ devm_kfree(dev, thermal->main); ++err_devm_kzalloc: + devm_kfree(dev, thermal); + return err; + } +@@ -1051,8 +1082,8 @@ void mlxsw_thermal_fini(struct mlxsw_thermal *thermal) + { + int i; + +- mlxsw_thermal_gearboxes_fini(thermal); +- mlxsw_thermal_modules_fini(thermal); ++ mlxsw_thermal_gearboxes_fini(thermal, thermal->main); ++ mlxsw_thermal_modules_fini(thermal, thermal->main); + if (thermal->tzdev) { + thermal_zone_device_unregister(thermal->tzdev); + thermal->tzdev = NULL; +@@ -1065,5 +1096,6 @@ void mlxsw_thermal_fini(struct mlxsw_thermal *thermal) + } + } + ++ devm_kfree(thermal->bus_info->dev, thermal->main); + devm_kfree(thermal->bus_info->dev, thermal); + } +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0120-mlxsw-core_thermal-Split-gearbox-initialization.patch b/platform/mellanox/non-upstream-patches/patches/0120-mlxsw-core_thermal-Split-gearbox-initialization.patch new file mode 100644 index 000000000000..299d03e4c5d6 --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0120-mlxsw-core_thermal-Split-gearbox-initialization.patch @@ -0,0 +1,137 @@ +From 219381cde0a7294834aff7e3f30584182b26a2b6 Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Tue, 14 Dec 2021 10:57:34 +0200 +Subject: [PATCH] mlxsw: core_thermal: Split gearbox initialization + +Split gearbox initialization in two routines - the first one is to be +used for gearbox configuration validation, the second for creation of +gearbox related thermal zones if any. + +Currently, mlxsw supports gearbox thermal zones corresponding to the +main board. For system equipped with the line cards assembled with the +gearboxes, thermal zones will be associated with the gearboxes found on +those line cards. + +While the initialization flow for main board and for line cards is the +same, the configuration flow is different. + +The purpose of this patch is to allow reusing of initialization flow by +main board and line cards. + +Signed-off-by: Vadim Pasternak +Reviewed-by: Jiri Pirko +Signed-off-by: Ido Schimmel +--- + .../ethernet/mellanox/mlxsw/core_thermal.c | 43 +++++++++++++++---- + 1 file changed, 34 insertions(+), 9 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +index 77a484a55..a8ecd8fea 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +@@ -887,15 +887,12 @@ mlxsw_thermal_gearbox_tz_fini(struct mlxsw_thermal_module *gearbox_tz) + } + + static int +-mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core, +- struct mlxsw_thermal *thermal, +- struct mlxsw_thermal_area *area) ++mlxsw_thermal_gearboxes_main_init(struct device *dev, struct mlxsw_core *core, ++ struct mlxsw_thermal_area *area) + { + enum mlxsw_reg_mgpir_device_type device_type; +- struct mlxsw_thermal_module *gearbox_tz; + char mgpir_pl[MLXSW_REG_MGPIR_LEN]; + u8 gbox_num; +- int i; + int err; + + mlxsw_reg_mgpir_pack(mgpir_pl, 0); +@@ -905,8 +902,11 @@ mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core, + + mlxsw_reg_mgpir_unpack(mgpir_pl, &gbox_num, &device_type, NULL, + NULL, NULL); +- if (device_type != MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE || +- !gbox_num) ++ if (device_type != MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE) ++ gbox_num = 0; ++ ++ /* Skip gearbox sensor array allocation, if no gearboxes are available. */ ++ if (!gbox_num) + return 0; + + area->tz_gearbox_num = gbox_num; +@@ -916,6 +916,26 @@ mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core, + if (!area->tz_gearbox_arr) + return -ENOMEM; + ++ return 0; ++} ++ ++static void ++mlxsw_thermal_gearboxes_main_fini(struct mlxsw_thermal_area *area) ++{ ++ kfree(area->tz_gearbox_arr); ++} ++ ++static int ++mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core, ++ struct mlxsw_thermal *thermal, ++ struct mlxsw_thermal_area *area) ++{ ++ struct mlxsw_thermal_module *gearbox_tz; ++ int i, err; ++ ++ if (!area->tz_gearbox_num) ++ return 0; ++ + for (i = 0; i < area->tz_gearbox_num; i++) { + gearbox_tz = &area->tz_gearbox_arr[i]; + memcpy(gearbox_tz->trips, default_thermal_trips, +@@ -933,7 +953,6 @@ mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core, + err_thermal_gearbox_tz_init: + for (i--; i >= 0; i--) + mlxsw_thermal_gearbox_tz_fini(&area->tz_gearbox_arr[i]); +- kfree(area->tz_gearbox_arr); + return err; + } + +@@ -945,7 +964,6 @@ mlxsw_thermal_gearboxes_fini(struct mlxsw_thermal *thermal, + + for (i = area->tz_gearbox_num - 1; i >= 0; i--) + mlxsw_thermal_gearbox_tz_fini(&area->tz_gearbox_arr[i]); +- kfree(area->tz_gearbox_arr); + } + + int mlxsw_thermal_init(struct mlxsw_core *core, +@@ -1045,6 +1063,10 @@ int mlxsw_thermal_init(struct mlxsw_core *core, + if (err) + goto err_thermal_modules_init; + ++ err = mlxsw_thermal_gearboxes_main_init(dev, core, thermal->main); ++ if (err) ++ goto err_thermal_gearboxes_main_init; ++ + err = mlxsw_thermal_gearboxes_init(dev, core, thermal, thermal->main); + if (err) + goto err_thermal_gearboxes_init; +@@ -1059,6 +1081,8 @@ int mlxsw_thermal_init(struct mlxsw_core *core, + err_thermal_zone_device_enable: + mlxsw_thermal_gearboxes_fini(thermal, thermal->main); + err_thermal_gearboxes_init: ++ mlxsw_thermal_gearboxes_main_fini(thermal->main); ++err_thermal_gearboxes_main_init: + mlxsw_thermal_modules_fini(thermal, thermal->main); + err_thermal_modules_init: + if (thermal->tzdev) { +@@ -1083,6 +1107,7 @@ void mlxsw_thermal_fini(struct mlxsw_thermal *thermal) + int i; + + mlxsw_thermal_gearboxes_fini(thermal, thermal->main); ++ mlxsw_thermal_gearboxes_main_fini(thermal->main); + mlxsw_thermal_modules_fini(thermal, thermal->main); + if (thermal->tzdev) { + thermal_zone_device_unregister(thermal->tzdev); +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0121-mlxsw-core_thermal-Extend-thermal-area-with-gearbox-.patch b/platform/mellanox/non-upstream-patches/patches/0121-mlxsw-core_thermal-Extend-thermal-area-with-gearbox-.patch new file mode 100644 index 000000000000..7157375e9ca5 --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0121-mlxsw-core_thermal-Extend-thermal-area-with-gearbox-.patch @@ -0,0 +1,127 @@ +From 9c8482e7c487a0a19f0d6d5df06c70aa529d3023 Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Tue, 14 Dec 2021 10:57:35 +0200 +Subject: [PATCH] mlxsw: core_thermal: Extend thermal area with gearbox mapping + field + +Add gearbox mapping field 'gearbox_sensor_map' to +'mlxsw_thermal_module' structure. It should provide the mapping for +gearbox sensor indexes, given gearbox number. For main board mapping is +supposed to be always sequential, while for line cards on modular +system it could be non-sequential. + +Signed-off-by: Vadim Pasternak +Reviewed-by: Jiri Pirko +Signed-off-by: Ido Schimmel +--- + .../ethernet/mellanox/mlxsw/core_thermal.c | 33 ++++++++++++++----- + 1 file changed, 25 insertions(+), 8 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +index a8ecd8fea..2efedd35b 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +@@ -85,9 +85,11 @@ static const struct mlxsw_thermal_trip default_thermal_trips[] = { + #define MLXSW_THERMAL_TRIP_MASK (BIT(MLXSW_THERMAL_NUM_TRIPS) - 1) + + struct mlxsw_thermal; ++struct mlxsw_thermal_area; + + struct mlxsw_thermal_module { + struct mlxsw_thermal *parent; ++ struct mlxsw_thermal_area *area; + struct thermal_zone_device *tzdev; + struct mlxsw_thermal_trip trips[MLXSW_THERMAL_NUM_TRIPS]; + int module; /* Module or gearbox number */ +@@ -100,6 +102,7 @@ struct mlxsw_thermal_area { + struct mlxsw_thermal_module *tz_gearbox_arr; + u8 tz_gearbox_num; + u8 slot_index; ++ u16 *gearbox_sensor_map; + }; + + struct mlxsw_thermal { +@@ -594,7 +597,7 @@ static int mlxsw_thermal_gearbox_temp_get(struct thermal_zone_device *tzdev, + int temp; + int err; + +- index = MLXSW_REG_MTMP_GBOX_INDEX_MIN + tz->module; ++ index = tz->area->gearbox_sensor_map[tz->module]; + mlxsw_reg_mtmp_pack(mtmp_pl, tz->slot_index, index, false, false); + + err = mlxsw_reg_query(thermal->core, MLXSW_REG(mtmp), mtmp_pl); +@@ -768,6 +771,7 @@ mlxsw_thermal_module_init(struct device *dev, struct mlxsw_core *core, + if (module_tz->parent) + return 0; + module_tz->module = module; ++ module_tz->area = area; + module_tz->slot_index = area->slot_index; + module_tz->parent = thermal; + memcpy(module_tz->trips, default_thermal_trips, +@@ -892,36 +896,48 @@ mlxsw_thermal_gearboxes_main_init(struct device *dev, struct mlxsw_core *core, + { + enum mlxsw_reg_mgpir_device_type device_type; + char mgpir_pl[MLXSW_REG_MGPIR_LEN]; +- u8 gbox_num; +- int err; ++ int i = 0, err; + + mlxsw_reg_mgpir_pack(mgpir_pl, 0); + err = mlxsw_reg_query(core, MLXSW_REG(mgpir), mgpir_pl); + if (err) + return err; + +- mlxsw_reg_mgpir_unpack(mgpir_pl, &gbox_num, &device_type, NULL, +- NULL, NULL); ++ mlxsw_reg_mgpir_unpack(mgpir_pl, &area->tz_gearbox_num, &device_type, ++ NULL, NULL, NULL); + if (device_type != MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE) +- gbox_num = 0; ++ area->tz_gearbox_num = 0; + + /* Skip gearbox sensor array allocation, if no gearboxes are available. */ +- if (!gbox_num) ++ if (!area->tz_gearbox_num) + return 0; + +- area->tz_gearbox_num = gbox_num; + area->tz_gearbox_arr = kcalloc(area->tz_gearbox_num, + sizeof(*area->tz_gearbox_arr), + GFP_KERNEL); + if (!area->tz_gearbox_arr) + return -ENOMEM; + ++ area->gearbox_sensor_map = kmalloc_array(area->tz_gearbox_num, ++ sizeof(u16), GFP_KERNEL); ++ if (!area->gearbox_sensor_map) ++ goto mlxsw_thermal_gearbox_sensor_map; ++ ++ /* Fill out gearbox sensor mapping array. */ ++ for (i = 0; i < area->tz_gearbox_num; i++) ++ area->gearbox_sensor_map[i] = MLXSW_REG_MTMP_GBOX_INDEX_MIN + i; ++ + return 0; ++ ++mlxsw_thermal_gearbox_sensor_map: ++ kfree(area->tz_gearbox_arr); ++ return err; + } + + static void + mlxsw_thermal_gearboxes_main_fini(struct mlxsw_thermal_area *area) + { ++ kfree(area->gearbox_sensor_map); + kfree(area->tz_gearbox_arr); + } + +@@ -942,6 +958,7 @@ mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core, + sizeof(thermal->trips)); + gearbox_tz->module = i; + gearbox_tz->parent = thermal; ++ gearbox_tz->area = area; + gearbox_tz->slot_index = area->slot_index; + err = mlxsw_thermal_gearbox_tz_init(gearbox_tz); + if (err) +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0122-mlxsw-core_thermal-Add-line-card-id-prefix-to-line-c.patch b/platform/mellanox/non-upstream-patches/patches/0122-mlxsw-core_thermal-Add-line-card-id-prefix-to-line-c.patch new file mode 100644 index 000000000000..d6aa7a49ca8d --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0122-mlxsw-core_thermal-Add-line-card-id-prefix-to-line-c.patch @@ -0,0 +1,59 @@ +From 3f3548804a89b7fbe15fa92ea8686f08b990b083 Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Tue, 14 Dec 2021 10:57:36 +0200 +Subject: [PATCH] mlxsw: core_thermal: Add line card id prefix to line card + thermal zone name + +Add prefix "lc#n" to thermal zones associated with the thermal objects +found on line cards. + +For example thermal zone for module #9 located at line card #7 will +have type: +mlxsw-lc7-module9. +And thermal zone for gearbox #3 located at line card #5 will have type: +mlxsw-lc5-gearbox3. + +Signed-off-by: Vadim Pasternak +Reviewed-by: Jiri Pirko +Signed-off-by: Ido Schimmel +--- + .../net/ethernet/mellanox/mlxsw/core_thermal.c | 16 ++++++++++++---- + 1 file changed, 12 insertions(+), 4 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +index 2efedd35b..421555d3f 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +@@ -730,8 +730,12 @@ mlxsw_thermal_module_tz_init(struct mlxsw_thermal_module *module_tz) + char tz_name[MLXSW_THERMAL_ZONE_MAX_NAME]; + int err; + +- snprintf(tz_name, sizeof(tz_name), "mlxsw-module%d", +- module_tz->module + 1); ++ if (module_tz->slot_index) ++ snprintf(tz_name, sizeof(tz_name), "mlxsw-lc%d-module%d", ++ module_tz->slot_index, module_tz->module + 1); ++ else ++ snprintf(tz_name, sizeof(tz_name), "mlxsw-module%d", ++ module_tz->module + 1); + module_tz->tzdev = thermal_zone_device_register(tz_name, + MLXSW_THERMAL_NUM_TRIPS, + MLXSW_THERMAL_TRIP_MASK, +@@ -865,8 +869,12 @@ mlxsw_thermal_gearbox_tz_init(struct mlxsw_thermal_module *gearbox_tz) + char tz_name[MLXSW_THERMAL_ZONE_MAX_NAME]; + int ret; + +- snprintf(tz_name, sizeof(tz_name), "mlxsw-gearbox%d", +- gearbox_tz->module + 1); ++ if (gearbox_tz->slot_index) ++ snprintf(tz_name, sizeof(tz_name), "mlxsw-lc%d-gearbox%d", ++ gearbox_tz->slot_index, gearbox_tz->module + 1); ++ else ++ snprintf(tz_name, sizeof(tz_name), "mlxsw-gearbox%d", ++ gearbox_tz->module + 1); + gearbox_tz->tzdev = thermal_zone_device_register(tz_name, + MLXSW_THERMAL_NUM_TRIPS, + MLXSW_THERMAL_TRIP_MASK, +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0123-mlxsw-core_thermal-Use-exact-name-of-cooling-devices.patch b/platform/mellanox/non-upstream-patches/patches/0123-mlxsw-core_thermal-Use-exact-name-of-cooling-devices.patch new file mode 100644 index 000000000000..423827598825 --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0123-mlxsw-core_thermal-Use-exact-name-of-cooling-devices.patch @@ -0,0 +1,35 @@ +From 34251eb77f3f50ac2d574876f33c65d8d2c70e9c Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Tue, 14 Dec 2021 10:57:37 +0200 +Subject: [PATCH] mlxsw: core_thermal: Use exact name of cooling devices for + binding + +Modular system supports additional cooling devices "mlxreg_fan1", +"mlxreg_fan2", etcetera. Thermal zones in "mlxsw" driver should be +bound to the same device as before called "mlxreg_fan". Used exact +match for cooling device name to avoid binding to new additional +cooling devices. + +Signed-off-by: Vadim Pasternak +Signed-off-by: Ido Schimmel +--- + drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +index 421555d3f..a20a91285 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +@@ -141,8 +141,7 @@ static int mlxsw_get_cooling_device_idx(struct mlxsw_thermal *thermal, + + /* Allow mlxsw thermal zone binding to an external cooling device */ + for (i = 0; i < ARRAY_SIZE(mlxsw_thermal_external_allowed_cdev); i++) { +- if (strnstr(cdev->type, mlxsw_thermal_external_allowed_cdev[i], +- strlen(cdev->type))) ++ if (!strcmp(cdev->type, mlxsw_thermal_external_allowed_cdev[i])) + return 0; + } + +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0124-mlxsw-core_thermal-Use-common-define-for-thermal-zon.patch b/platform/mellanox/non-upstream-patches/patches/0124-mlxsw-core_thermal-Use-common-define-for-thermal-zon.patch new file mode 100644 index 000000000000..711f4d62dc4e --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0124-mlxsw-core_thermal-Use-common-define-for-thermal-zon.patch @@ -0,0 +1,48 @@ +From 56370efd25ad5b77b87645d779dd577674c12864 Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Tue, 14 Dec 2021 10:57:38 +0200 +Subject: [PATCH] mlxsw: core_thermal: Use common define for thermal zone name + length + +Replace internal define 'MLXSW_THERMAL_ZONE_MAX_NAME' by common +'THERMAL_NAME_LENGTH'. + +Signed-off-by: Vadim Pasternak +Signed-off-by: Ido Schimmel +--- + drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +index a20a91285..e860cade5 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +@@ -21,7 +21,6 @@ + #define MLXSW_THERMAL_ASIC_TEMP_HOT 105000 /* 105C */ + #define MLXSW_THERMAL_HYSTERESIS_TEMP 5000 /* 5C */ + #define MLXSW_THERMAL_MODULE_TEMP_SHIFT (MLXSW_THERMAL_HYSTERESIS_TEMP * 2) +-#define MLXSW_THERMAL_ZONE_MAX_NAME 16 + #define MLXSW_THERMAL_TEMP_SCORE_MAX GENMASK(31, 0) + #define MLXSW_THERMAL_MAX_STATE 10 + #define MLXSW_THERMAL_MAX_DUTY 255 +@@ -726,7 +725,7 @@ static const struct thermal_cooling_device_ops mlxsw_cooling_ops = { + static int + mlxsw_thermal_module_tz_init(struct mlxsw_thermal_module *module_tz) + { +- char tz_name[MLXSW_THERMAL_ZONE_MAX_NAME]; ++ char tz_name[THERMAL_NAME_LENGTH]; + int err; + + if (module_tz->slot_index) +@@ -865,7 +864,7 @@ mlxsw_thermal_modules_fini(struct mlxsw_thermal *thermal, + static int + mlxsw_thermal_gearbox_tz_init(struct mlxsw_thermal_module *gearbox_tz) + { +- char tz_name[MLXSW_THERMAL_ZONE_MAX_NAME]; ++ char tz_name[THERMAL_NAME_LENGTH]; + int ret; + + if (gearbox_tz->slot_index) +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0125-devlink-add-support-to-create-line-card-and-expose-t.patch b/platform/mellanox/non-upstream-patches/patches/0125-devlink-add-support-to-create-line-card-and-expose-t.patch new file mode 100644 index 000000000000..849645848a0d --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0125-devlink-add-support-to-create-line-card-and-expose-t.patch @@ -0,0 +1,531 @@ +From 242d6e2b00a25ec4184a63cec76c9f7f7c235594 Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Wed, 22 Dec 2021 08:57:27 +0000 +Subject: [PATCH] devlink: add support to create line card and expose to user + +Extend the devlink API so the driver is going to be able to create and +destroy linecard instances. There can be multiple line cards per devlink +device. Expose this new type of object over devlink netlink API to the +userspace, with notifications. + +Signed-off-by: Jiri Pirko +--- + include/net/devlink.h | 15 ++ + include/uapi/linux/devlink.h | 22 +++ + net/core/devlink.c | 303 ++++++++++++++++++++++++++++++++++- + 3 files changed, 339 insertions(+), 1 deletion(-) + +diff --git a/include/net/devlink.h b/include/net/devlink.h +index b01bb9bca..e8f046590 100644 +--- a/include/net/devlink.h ++++ b/include/net/devlink.h +@@ -31,6 +31,7 @@ struct devlink_dev_stats { + struct devlink_ops; + + struct devlink { ++ u32 index; + struct list_head list; + struct list_head port_list; + struct list_head sb_list; +@@ -44,6 +45,8 @@ struct devlink { + struct list_head trap_list; + struct list_head trap_group_list; + struct list_head trap_policer_list; ++ struct list_head linecard_list; ++ struct mutex linecards_lock; /* protects linecard_list */ + const struct devlink_ops *ops; + struct xarray snapshot_ids; + struct devlink_dev_stats stats; +@@ -55,6 +58,8 @@ struct devlink { + u8 reload_failed:1, + reload_enabled:1, + registered:1; ++ refcount_t refcount; ++ struct completion comp; + char priv[0] __aligned(NETDEV_ALIGN); + }; + +@@ -137,6 +142,13 @@ struct devlink_port { + struct mutex reporters_lock; /* Protects reporter_list */ + }; + ++struct devlink_linecard { ++ struct list_head list; ++ struct devlink *devlink; ++ unsigned int index; ++ refcount_t refcount; ++}; ++ + struct devlink_sb_pool_info { + enum devlink_sb_pool_type pool_type; + u32 size; +@@ -1401,6 +1413,9 @@ void devlink_port_attrs_pci_pf_set(struct devlink_port *devlink_port, u32 contro + u16 pf, bool external); + void devlink_port_attrs_pci_vf_set(struct devlink_port *devlink_port, u32 controller, + u16 pf, u16 vf, bool external); ++struct devlink_linecard *devlink_linecard_create(struct devlink *devlink, ++ unsigned int linecard_index); ++void devlink_linecard_destroy(struct devlink_linecard *linecard); + int devlink_sb_register(struct devlink *devlink, unsigned int sb_index, + u32 size, u16 ingress_pools_count, + u16 egress_pools_count, u16 ingress_tc_count, +diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h +index cf89c318f..ff07ad596 100644 +--- a/include/uapi/linux/devlink.h ++++ b/include/uapi/linux/devlink.h +@@ -126,6 +126,16 @@ enum devlink_command { + + DEVLINK_CMD_HEALTH_REPORTER_TEST, + ++ DEVLINK_CMD_RATE_GET, /* can dump */ ++ DEVLINK_CMD_RATE_SET, ++ DEVLINK_CMD_RATE_NEW, ++ DEVLINK_CMD_RATE_DEL, ++ ++ DEVLINK_CMD_LINECARD_GET, /* can dump */ ++ DEVLINK_CMD_LINECARD_SET, ++ DEVLINK_CMD_LINECARD_NEW, ++ DEVLINK_CMD_LINECARD_DEL, ++ + /* add new commands above here */ + __DEVLINK_CMD_MAX, + DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX - 1 +@@ -529,6 +539,18 @@ enum devlink_attr { + DEVLINK_ATTR_RELOAD_ACTION_INFO, /* nested */ + DEVLINK_ATTR_RELOAD_ACTION_STATS, /* nested */ + ++ DEVLINK_ATTR_PORT_PCI_SF_NUMBER, /* u32 */ ++ ++ DEVLINK_ATTR_RATE_TYPE, /* u16 */ ++ DEVLINK_ATTR_RATE_TX_SHARE, /* u64 */ ++ DEVLINK_ATTR_RATE_TX_MAX, /* u64 */ ++ DEVLINK_ATTR_RATE_NODE_NAME, /* string */ ++ DEVLINK_ATTR_RATE_PARENT_NODE_NAME, /* string */ ++ ++ DEVLINK_ATTR_REGION_MAX_SNAPSHOTS, /* u32 */ ++ ++ DEVLINK_ATTR_LINECARD_INDEX, /* u32 */ ++ + /* add new attributes above here, update the policy in devlink.c */ + + __DEVLINK_ATTR_MAX, +diff --git a/net/core/devlink.c b/net/core/devlink.c +index 72047750d..645fe0612 100644 +--- a/net/core/devlink.c ++++ b/net/core/devlink.c +@@ -91,6 +91,25 @@ static const struct nla_policy devlink_function_nl_policy[DEVLINK_PORT_FUNCTION_ + + static LIST_HEAD(devlink_list); + ++static DEFINE_XARRAY_FLAGS(devlinks, XA_FLAGS_ALLOC); ++#define DEVLINK_REGISTERED XA_MARK_1 ++ ++/* devlink instances are open to the access from the user space after ++ * devlink_register() call. Such logical barrier allows us to have certain ++ * expectations related to locking. ++ * ++ * Before *_register() - we are in initialization stage and no parallel ++ * access possible to the devlink instance. All drivers perform that phase ++ * by implicitly holding device_lock. ++ * ++ * After *_register() - users and driver can access devlink instance at ++ * the same time. ++ */ ++#define ASSERT_DEVLINK_REGISTERED(d) \ ++ WARN_ON_ONCE(!xa_get_mark(&devlinks, (d)->index, DEVLINK_REGISTERED)) ++#define ASSERT_DEVLINK_NOT_REGISTERED(d) \ ++ WARN_ON_ONCE(xa_get_mark(&devlinks, (d)->index, DEVLINK_REGISTERED)) ++ + /* devlink_mutex + * + * An overall lock guarding every operation coming from userspace. +@@ -105,6 +124,19 @@ struct net *devlink_net(const struct devlink *devlink) + } + EXPORT_SYMBOL_GPL(devlink_net); + ++void devlink_put(struct devlink *devlink) ++{ ++ if (refcount_dec_and_test(&devlink->refcount)) ++ complete(&devlink->comp); ++} ++ ++struct devlink *__must_check devlink_try_get(struct devlink *devlink) ++{ ++ if (refcount_inc_not_zero(&devlink->refcount)) ++ return devlink; ++ return NULL; ++} ++ + static void __devlink_net_set(struct devlink *devlink, struct net *net) + { + write_pnet(&devlink->_net, net); +@@ -187,6 +219,56 @@ static struct devlink_port *devlink_port_get_from_info(struct devlink *devlink, + return devlink_port_get_from_attrs(devlink, info->attrs); + } + ++static struct devlink_linecard * ++devlink_linecard_get_by_index(struct devlink *devlink, ++ unsigned int linecard_index) ++{ ++ struct devlink_linecard *devlink_linecard; ++ ++ list_for_each_entry(devlink_linecard, &devlink->linecard_list, list) { ++ if (devlink_linecard->index == linecard_index) ++ return devlink_linecard; ++ } ++ return NULL; ++} ++ ++static bool devlink_linecard_index_exists(struct devlink *devlink, ++ unsigned int linecard_index) ++{ ++ return devlink_linecard_get_by_index(devlink, linecard_index); ++} ++ ++static struct devlink_linecard * ++devlink_linecard_get_from_attrs(struct devlink *devlink, struct nlattr **attrs) ++{ ++ if (attrs[DEVLINK_ATTR_LINECARD_INDEX]) { ++ u32 linecard_index = nla_get_u32(attrs[DEVLINK_ATTR_LINECARD_INDEX]); ++ struct devlink_linecard *linecard; ++ ++ mutex_lock(&devlink->linecards_lock); ++ linecard = devlink_linecard_get_by_index(devlink, linecard_index); ++ if (linecard) ++ refcount_inc(&linecard->refcount); ++ mutex_unlock(&devlink->linecards_lock); ++ if (!linecard) ++ return ERR_PTR(-ENODEV); ++ return linecard; ++ } ++ return ERR_PTR(-EINVAL); ++} ++ ++static struct devlink_linecard * ++devlink_linecard_get_from_info(struct devlink *devlink, struct genl_info *info) ++{ ++ return devlink_linecard_get_from_attrs(devlink, info->attrs); ++} ++ ++static void devlink_linecard_put(struct devlink_linecard *linecard) ++{ ++ if (refcount_dec_and_test(&linecard->refcount)) ++ kfree(linecard); ++} ++ + struct devlink_sb { + struct list_head list; + unsigned int index; +@@ -405,16 +487,20 @@ devlink_region_snapshot_get_by_id(struct devlink_region *region, u32 id) + + #define DEVLINK_NL_FLAG_NEED_PORT BIT(0) + #define DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT BIT(1) ++#define DEVLINK_NL_FLAG_NEED_RATE BIT(2) ++#define DEVLINK_NL_FLAG_NEED_RATE_NODE BIT(3) ++#define DEVLINK_NL_FLAG_NEED_LINECARD BIT(4) + + /* The per devlink instance lock is taken by default in the pre-doit + * operation, yet several commands do not require this. The global + * devlink lock is taken and protects from disruption by user-calls. + */ +-#define DEVLINK_NL_FLAG_NO_LOCK BIT(2) ++#define DEVLINK_NL_FLAG_NO_LOCK BIT(5) + + static int devlink_nl_pre_doit(const struct genl_ops *ops, + struct sk_buff *skb, struct genl_info *info) + { ++ struct devlink_linecard *linecard; + struct devlink_port *devlink_port; + struct devlink *devlink; + int err; +@@ -439,6 +525,13 @@ static int devlink_nl_pre_doit(const struct genl_ops *ops, + devlink_port = devlink_port_get_from_info(devlink, info); + if (!IS_ERR(devlink_port)) + info->user_ptr[1] = devlink_port; ++ } else if (ops->internal_flags & DEVLINK_NL_FLAG_NEED_LINECARD) { ++ linecard = devlink_linecard_get_from_info(devlink, info); ++ if (IS_ERR(linecard)) { ++ err = PTR_ERR(linecard); ++ goto unlock; ++ } ++ info->user_ptr[1] = linecard; + } + return 0; + +@@ -452,9 +545,14 @@ static int devlink_nl_pre_doit(const struct genl_ops *ops, + static void devlink_nl_post_doit(const struct genl_ops *ops, + struct sk_buff *skb, struct genl_info *info) + { ++ struct devlink_linecard *linecard; + struct devlink *devlink; + + devlink = info->user_ptr[0]; ++ if (ops->internal_flags & DEVLINK_NL_FLAG_NEED_LINECARD) { ++ linecard = info->user_ptr[1]; ++ devlink_linecard_put(linecard); ++ } + if (~ops->internal_flags & DEVLINK_NL_FLAG_NO_LOCK) + mutex_unlock(&devlink->lock); + mutex_unlock(&devlink_mutex); +@@ -1135,6 +1233,132 @@ static int devlink_nl_cmd_port_unsplit_doit(struct sk_buff *skb, + return devlink_port_unsplit(devlink, port_index, info->extack); + } + ++static int devlink_nl_linecard_fill(struct sk_buff *msg, ++ struct devlink *devlink, ++ struct devlink_linecard *linecard, ++ enum devlink_command cmd, u32 portid, ++ u32 seq, int flags, ++ struct netlink_ext_ack *extack) ++{ ++ void *hdr; ++ ++ hdr = genlmsg_put(msg, portid, seq, &devlink_nl_family, flags, cmd); ++ if (!hdr) ++ return -EMSGSIZE; ++ ++ if (devlink_nl_put_handle(msg, devlink)) ++ goto nla_put_failure; ++ if (nla_put_u32(msg, DEVLINK_ATTR_LINECARD_INDEX, linecard->index)) ++ goto nla_put_failure; ++ ++ genlmsg_end(msg, hdr); ++ return 0; ++ ++nla_put_failure: ++ genlmsg_cancel(msg, hdr); ++ return -EMSGSIZE; ++} ++ ++static void devlink_linecard_notify(struct devlink_linecard *linecard, ++ enum devlink_command cmd) ++{ ++ struct devlink *devlink = linecard->devlink; ++ struct sk_buff *msg; ++ int err; ++ ++ WARN_ON(cmd != DEVLINK_CMD_LINECARD_NEW && ++ cmd != DEVLINK_CMD_LINECARD_DEL); ++ ++ if (!xa_get_mark(&devlinks, devlink->index, DEVLINK_REGISTERED)) ++ return; ++ ++ msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); ++ if (!msg) ++ return; ++ ++ err = devlink_nl_linecard_fill(msg, devlink, linecard, cmd, 0, 0, 0, ++ NULL); ++ if (err) { ++ nlmsg_free(msg); ++ return; ++ } ++ ++ genlmsg_multicast_netns(&devlink_nl_family, devlink_net(devlink), ++ msg, 0, DEVLINK_MCGRP_CONFIG, GFP_KERNEL); ++} ++ ++static int devlink_nl_cmd_linecard_get_doit(struct sk_buff *skb, ++ struct genl_info *info) ++{ ++ struct devlink_linecard *linecard = info->user_ptr[1]; ++ struct devlink *devlink = linecard->devlink; ++ struct sk_buff *msg; ++ int err; ++ ++ msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); ++ if (!msg) ++ return -ENOMEM; ++ ++ err = devlink_nl_linecard_fill(msg, devlink, linecard, ++ DEVLINK_CMD_LINECARD_NEW, ++ info->snd_portid, info->snd_seq, 0, ++ info->extack); ++ if (err) { ++ nlmsg_free(msg); ++ return err; ++ } ++ ++ return genlmsg_reply(msg, info); ++} ++ ++static int devlink_nl_cmd_linecard_get_dumpit(struct sk_buff *msg, ++ struct netlink_callback *cb) ++{ ++ struct devlink_linecard *linecard; ++ struct devlink *devlink; ++ int start = cb->args[0]; ++ unsigned long index; ++ int idx = 0; ++ int err; ++ ++ mutex_lock(&devlink_mutex); ++ xa_for_each_marked(&devlinks, index, devlink, DEVLINK_REGISTERED) { ++ if (!devlink_try_get(devlink)) ++ continue; ++ ++ if (!net_eq(devlink_net(devlink), sock_net(msg->sk))) ++ goto retry; ++ ++ mutex_lock(&devlink->linecards_lock); ++ list_for_each_entry(linecard, &devlink->linecard_list, list) { ++ if (idx < start) { ++ idx++; ++ continue; ++ } ++ err = devlink_nl_linecard_fill(msg, devlink, linecard, ++ DEVLINK_CMD_LINECARD_NEW, ++ NETLINK_CB(cb->skb).portid, ++ cb->nlh->nlmsg_seq, ++ NLM_F_MULTI, ++ cb->extack); ++ if (err) { ++ mutex_unlock(&devlink->linecards_lock); ++ devlink_put(devlink); ++ goto out; ++ } ++ idx++; ++ } ++ mutex_unlock(&devlink->linecards_lock); ++retry: ++ devlink_put(devlink); ++ } ++out: ++ mutex_unlock(&devlink_mutex); ++ ++ cb->args[0] = idx; ++ return msg->len; ++} ++ + static int devlink_nl_sb_fill(struct sk_buff *msg, struct devlink *devlink, + struct devlink_sb *devlink_sb, + enum devlink_command cmd, u32 portid, +@@ -7594,6 +7818,19 @@ static const struct nla_policy devlink_nl_policy[DEVLINK_ATTR_MAX + 1] = { + [DEVLINK_ATTR_RELOAD_ACTION] = NLA_POLICY_RANGE(NLA_U8, DEVLINK_RELOAD_ACTION_DRIVER_REINIT, + DEVLINK_RELOAD_ACTION_MAX), + [DEVLINK_ATTR_RELOAD_LIMITS] = NLA_POLICY_BITFIELD32(DEVLINK_RELOAD_LIMITS_VALID_MASK), ++//<<<<<<< HEAD ++//======= ++ [DEVLINK_ATTR_PORT_FLAVOUR] = { .type = NLA_U16 }, ++ [DEVLINK_ATTR_PORT_PCI_PF_NUMBER] = { .type = NLA_U16 }, ++ [DEVLINK_ATTR_PORT_PCI_SF_NUMBER] = { .type = NLA_U32 }, ++ [DEVLINK_ATTR_PORT_CONTROLLER_NUMBER] = { .type = NLA_U32 }, ++ [DEVLINK_ATTR_RATE_TYPE] = { .type = NLA_U16 }, ++ [DEVLINK_ATTR_RATE_TX_SHARE] = { .type = NLA_U64 }, ++ [DEVLINK_ATTR_RATE_TX_MAX] = { .type = NLA_U64 }, ++ [DEVLINK_ATTR_RATE_NODE_NAME] = { .type = NLA_NUL_STRING }, ++ [DEVLINK_ATTR_RATE_PARENT_NODE_NAME] = { .type = NLA_NUL_STRING }, ++ [DEVLINK_ATTR_LINECARD_INDEX] = { .type = NLA_U32 }, ++//>>>>>>> 1180815a3831... devlink: add support to create line card and expose to user + }; + + static const struct genl_small_ops devlink_nl_ops[] = { +@@ -7633,6 +7870,14 @@ static const struct genl_small_ops devlink_nl_ops[] = { + .flags = GENL_ADMIN_PERM, + .internal_flags = DEVLINK_NL_FLAG_NO_LOCK, + }, ++ { ++ .cmd = DEVLINK_CMD_LINECARD_GET, ++ .doit = devlink_nl_cmd_linecard_get_doit, ++ .dumpit = devlink_nl_cmd_linecard_get_dumpit, ++ .internal_flags = DEVLINK_NL_FLAG_NEED_LINECARD | ++ DEVLINK_NL_FLAG_NO_LOCK, ++ /* can be retrieved by unprivileged users */ ++ }, + { + .cmd = DEVLINK_CMD_SB_GET, + .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, +@@ -7980,6 +8225,7 @@ struct devlink *devlink_alloc(const struct devlink_ops *ops, size_t priv_size) + xa_init_flags(&devlink->snapshot_ids, XA_FLAGS_ALLOC); + __devlink_net_set(devlink, &init_net); + INIT_LIST_HEAD(&devlink->port_list); ++ INIT_LIST_HEAD(&devlink->linecard_list); + INIT_LIST_HEAD(&devlink->sb_list); + INIT_LIST_HEAD_RCU(&devlink->dpipe_table_list); + INIT_LIST_HEAD(&devlink->resource_list); +@@ -7991,6 +8237,8 @@ struct devlink *devlink_alloc(const struct devlink_ops *ops, size_t priv_size) + INIT_LIST_HEAD(&devlink->trap_policer_list); + mutex_init(&devlink->lock); + mutex_init(&devlink->reporters_lock); ++ mutex_init(&devlink->linecards_lock); ++ + return devlink; + } + EXPORT_SYMBOL_GPL(devlink_alloc); +@@ -8071,6 +8319,7 @@ EXPORT_SYMBOL_GPL(devlink_reload_disable); + */ + void devlink_free(struct devlink *devlink) + { ++ mutex_destroy(&devlink->linecards_lock); + mutex_destroy(&devlink->reporters_lock); + mutex_destroy(&devlink->lock); + WARN_ON(!list_empty(&devlink->trap_policer_list)); +@@ -8082,6 +8331,7 @@ void devlink_free(struct devlink *devlink) + WARN_ON(!list_empty(&devlink->resource_list)); + WARN_ON(!list_empty(&devlink->dpipe_table_list)); + WARN_ON(!list_empty(&devlink->sb_list)); ++ WARN_ON(!list_empty(&devlink->linecard_list)); + WARN_ON(!list_empty(&devlink->port_list)); + + xa_destroy(&devlink->snapshot_ids); +@@ -8427,6 +8677,57 @@ static int __devlink_port_phys_port_name_get(struct devlink_port *devlink_port, + return 0; + } + ++/** ++ * devlink_linecard_create - Create devlink linecard ++ * ++ * @devlink: devlink ++ * @linecard_index: driver-specific numerical identifier of the linecard ++ * ++ * Create devlink linecard instance with provided linecard index. ++ * Caller can use any indexing, even hw-related one. ++ */ ++struct devlink_linecard *devlink_linecard_create(struct devlink *devlink, ++ unsigned int linecard_index) ++{ ++ struct devlink_linecard *linecard; ++ ++ mutex_lock(&devlink->linecards_lock); ++ if (devlink_linecard_index_exists(devlink, linecard_index)) { ++ mutex_unlock(&devlink->linecards_lock); ++ return ERR_PTR(-EEXIST); ++ } ++ ++ linecard = kzalloc(sizeof(*linecard), GFP_KERNEL); ++ if (!linecard) ++ return ERR_PTR(-ENOMEM); ++ ++ linecard->devlink = devlink; ++ linecard->index = linecard_index; ++ list_add_tail(&linecard->list, &devlink->linecard_list); ++ refcount_set(&linecard->refcount, 1); ++ devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW); ++ mutex_unlock(&devlink->linecards_lock); ++ return linecard; ++} ++EXPORT_SYMBOL_GPL(devlink_linecard_create); ++ ++/** ++ * devlink_linecard_destroy - Destroy devlink linecard ++ * ++ * @linecard: devlink linecard ++ */ ++void devlink_linecard_destroy(struct devlink_linecard *linecard) ++{ ++ struct devlink *devlink = linecard->devlink; ++ ++ devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_DEL); ++ mutex_lock(&devlink->linecards_lock); ++ list_del(&linecard->list); ++ mutex_unlock(&devlink->linecards_lock); ++ devlink_linecard_put(linecard); ++} ++EXPORT_SYMBOL_GPL(devlink_linecard_destroy); ++ + int devlink_sb_register(struct devlink *devlink, unsigned int sb_index, + u32 size, u16 ingress_pools_count, + u16 egress_pools_count, u16 ingress_tc_count, +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0126-devlink-implement-line-card-provisioning.patch b/platform/mellanox/non-upstream-patches/patches/0126-devlink-implement-line-card-provisioning.patch new file mode 100644 index 000000000000..e5ea9d5d231e --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0126-devlink-implement-line-card-provisioning.patch @@ -0,0 +1,554 @@ +From b0a30f401ca5d69f3cd78a0bf6dd1471f7aea0be Mon Sep 17 00:00:00 2001 +From: Jiri Pirko +Date: Thu, 31 Dec 2020 17:35:08 +0100 +Subject: [PATCH] devlink: implement line card provisioning + +In order to be able to configure all needed stuff on a port/netdevice +of a line card without the line card being present, introduce line card +provisioning. Basically by setting a type, provisioning process will +start and driver is supposed to create a placeholder for instances +(ports/netdevices) for a line card type. + +Allow the user to query the supported line card types over line card +get command. Then implement two netlink command SET to allow user to +set/unset the card type. + +On the driver API side, add provision/unprovision ops and supported +types array to be advertised. Upon provision op call, the driver should +take care of creating the instances for the particular line card type. +Introduce provision_set/clear() functions to be called by the driver +once the provisioning/unprovisioning is done on its side. These helpers +are not to be called directly due to the async nature of provisioning. + +Signed-off-by: Jiri Pirko +--- + include/net/devlink.h | 41 ++++- + include/uapi/linux/devlink.h | 15 ++ + net/core/devlink.c | 311 ++++++++++++++++++++++++++++++++--- + 3 files changed, 346 insertions(+), 21 deletions(-) + +diff --git a/include/net/devlink.h b/include/net/devlink.h +index e8f046590..44b60085e 100644 +--- a/include/net/devlink.h ++++ b/include/net/devlink.h +@@ -142,11 +142,43 @@ struct devlink_port { + struct mutex reporters_lock; /* Protects reporter_list */ + }; + ++struct devlink_linecard_ops; ++struct devlink_linecard_type; ++ + struct devlink_linecard { + struct list_head list; + struct devlink *devlink; + unsigned int index; + refcount_t refcount; ++ const struct devlink_linecard_ops *ops; ++ void *priv; ++ enum devlink_linecard_state state; ++ struct mutex state_lock; /* Protects state */ ++ const char *type; ++ struct devlink_linecard_type *types; ++ unsigned int types_count; ++}; ++ ++/** ++ * struct devlink_linecard_ops - Linecard operations ++ * @provision: callback to provision the linecard slot with certain ++ * type of linecard ++ * @unprovision: callback to unprovision the linecard slot ++ * @types_init: callback to initialize types list ++ * @types_fini: callback to finalize types list ++ * @types_get: callback to get next type in list ++ */ ++struct devlink_linecard_ops { ++ int (*provision)(struct devlink_linecard *linecard, void *priv, ++ const char *type, const void *type_priv, ++ struct netlink_ext_ack *extack); ++ int (*unprovision)(struct devlink_linecard *linecard, void *priv, ++ struct netlink_ext_ack *extack); ++ unsigned int (*types_count)(struct devlink_linecard *linecard, ++ void *priv); ++ void (*types_get)(struct devlink_linecard *linecard, ++ void *priv, unsigned int index, const char **type, ++ const void **type_priv); + }; + + struct devlink_sb_pool_info { +@@ -1413,9 +1445,14 @@ void devlink_port_attrs_pci_pf_set(struct devlink_port *devlink_port, u32 contro + u16 pf, bool external); + void devlink_port_attrs_pci_vf_set(struct devlink_port *devlink_port, u32 controller, + u16 pf, u16 vf, bool external); +-struct devlink_linecard *devlink_linecard_create(struct devlink *devlink, +- unsigned int linecard_index); ++struct devlink_linecard * ++devlink_linecard_create(struct devlink *devlink, unsigned int linecard_index, ++ const struct devlink_linecard_ops *ops, void *priv); + void devlink_linecard_destroy(struct devlink_linecard *linecard); ++void devlink_linecard_provision_set(struct devlink_linecard *linecard, ++ const char *type); ++void devlink_linecard_provision_clear(struct devlink_linecard *linecard); ++void devlink_linecard_provision_fail(struct devlink_linecard *linecard); + int devlink_sb_register(struct devlink *devlink, unsigned int sb_index, + u32 size, u16 ingress_pools_count, + u16 egress_pools_count, u16 ingress_tc_count, +diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h +index ff07ad596..d88336645 100644 +--- a/include/uapi/linux/devlink.h ++++ b/include/uapi/linux/devlink.h +@@ -334,6 +334,18 @@ enum devlink_reload_limit { + + #define DEVLINK_RELOAD_LIMITS_VALID_MASK (_BITUL(__DEVLINK_RELOAD_LIMIT_MAX) - 1) + ++enum devlink_linecard_state { ++ DEVLINK_LINECARD_STATE_UNSPEC, ++ DEVLINK_LINECARD_STATE_UNPROVISIONED, ++ DEVLINK_LINECARD_STATE_UNPROVISIONING, ++ DEVLINK_LINECARD_STATE_PROVISIONING, ++ DEVLINK_LINECARD_STATE_PROVISIONING_FAILED, ++ DEVLINK_LINECARD_STATE_PROVISIONED, ++ ++ __DEVLINK_LINECARD_STATE_MAX, ++ DEVLINK_LINECARD_STATE_MAX = __DEVLINK_LINECARD_STATE_MAX - 1 ++}; ++ + enum devlink_attr { + /* don't change the order or add anything between, this is ABI! */ + DEVLINK_ATTR_UNSPEC, +@@ -550,6 +562,9 @@ enum devlink_attr { + DEVLINK_ATTR_REGION_MAX_SNAPSHOTS, /* u32 */ + + DEVLINK_ATTR_LINECARD_INDEX, /* u32 */ ++ DEVLINK_ATTR_LINECARD_STATE, /* u8 */ ++ DEVLINK_ATTR_LINECARD_TYPE, /* string */ ++ DEVLINK_ATTR_LINECARD_SUPPORTED_TYPES, /* nested */ + + /* add new attributes above here, update the policy in devlink.c */ + +diff --git a/net/core/devlink.c b/net/core/devlink.c +index 645fe0612..943973ffc 100644 +--- a/net/core/devlink.c ++++ b/net/core/devlink.c +@@ -265,8 +265,10 @@ devlink_linecard_get_from_info(struct devlink *devlink, struct genl_info *info) + + static void devlink_linecard_put(struct devlink_linecard *linecard) + { +- if (refcount_dec_and_test(&linecard->refcount)) ++ if (refcount_dec_and_test(&linecard->refcount)) { ++ mutex_destroy(&linecard->state_lock); + kfree(linecard); ++ } + } + + struct devlink_sb { +@@ -1233,6 +1235,12 @@ static int devlink_nl_cmd_port_unsplit_doit(struct sk_buff *skb, + return devlink_port_unsplit(devlink, port_index, info->extack); + } + ++struct devlink_linecard_type { ++ struct list_head list; ++ const char *type; ++ const void *priv; ++}; ++ + static int devlink_nl_linecard_fill(struct sk_buff *msg, + struct devlink *devlink, + struct devlink_linecard *linecard, +@@ -1240,7 +1248,10 @@ static int devlink_nl_linecard_fill(struct sk_buff *msg, + u32 seq, int flags, + struct netlink_ext_ack *extack) + { ++ struct devlink_linecard_type *linecard_type; ++ struct nlattr *attr; + void *hdr; ++ int i; + + hdr = genlmsg_put(msg, portid, seq, &devlink_nl_family, flags, cmd); + if (!hdr) +@@ -1250,6 +1261,25 @@ static int devlink_nl_linecard_fill(struct sk_buff *msg, + goto nla_put_failure; + if (nla_put_u32(msg, DEVLINK_ATTR_LINECARD_INDEX, linecard->index)) + goto nla_put_failure; ++ if (nla_put_u8(msg, DEVLINK_ATTR_LINECARD_STATE, linecard->state)) ++ goto nla_put_failure; ++ if (linecard->state >= DEVLINK_LINECARD_STATE_PROVISIONED && ++ nla_put_string(msg, DEVLINK_ATTR_LINECARD_TYPE, linecard->type)) ++ goto nla_put_failure; ++ ++ if (linecard->types_count) { ++ attr = nla_nest_start(msg, ++ DEVLINK_ATTR_LINECARD_SUPPORTED_TYPES); ++ if (!attr) ++ goto nla_put_failure; ++ for (i = 0; i < linecard->types_count; i++) { ++ linecard_type = &linecard->types[i]; ++ if (nla_put_string(msg, DEVLINK_ATTR_LINECARD_TYPE, ++ linecard_type->type)) ++ goto nla_put_failure; ++ } ++ nla_nest_end(msg, attr); ++ } + + genlmsg_end(msg, hdr); + return 0; +@@ -1335,12 +1365,14 @@ static int devlink_nl_cmd_linecard_get_dumpit(struct sk_buff *msg, + idx++; + continue; + } ++ mutex_lock(&linecard->state_lock); + err = devlink_nl_linecard_fill(msg, devlink, linecard, + DEVLINK_CMD_LINECARD_NEW, + NETLINK_CB(cb->skb).portid, + cb->nlh->nlmsg_seq, + NLM_F_MULTI, + cb->extack); ++ mutex_unlock(&linecard->state_lock); + if (err) { + mutex_unlock(&devlink->linecards_lock); + devlink_put(devlink); +@@ -1359,6 +1391,153 @@ static int devlink_nl_cmd_linecard_get_dumpit(struct sk_buff *msg, + return msg->len; + } + ++static struct devlink_linecard_type * ++devlink_linecard_type_lookup(struct devlink_linecard *linecard, ++ const char *type) ++{ ++ struct devlink_linecard_type *linecard_type; ++ int i; ++ ++ for (i = 0; i < linecard->types_count; i++) { ++ linecard_type = &linecard->types[i]; ++ if (!strcmp(type, linecard_type->type)) ++ return linecard_type; ++ } ++ return NULL; ++} ++ ++static int devlink_linecard_type_set(struct devlink_linecard *linecard, ++ const char *type, ++ struct netlink_ext_ack *extack) ++{ ++ struct devlink_linecard_type *linecard_type; ++ int err; ++ ++ mutex_lock(&linecard->state_lock); ++ if (linecard->state == DEVLINK_LINECARD_STATE_PROVISIONING) { ++ NL_SET_ERR_MSG_MOD(extack, "Linecard is currently being provisioned"); ++ err = -EBUSY; ++ goto out; ++ } ++ if (linecard->state == DEVLINK_LINECARD_STATE_UNPROVISIONING) { ++ NL_SET_ERR_MSG_MOD(extack, "Linecard is currently being unprovisioned"); ++ err = -EBUSY; ++ goto out; ++ } ++ if (linecard->state != DEVLINK_LINECARD_STATE_UNPROVISIONED && ++ linecard->state != DEVLINK_LINECARD_STATE_PROVISIONING_FAILED) { ++ NL_SET_ERR_MSG_MOD(extack, "Linecard already provisioned"); ++ err = -EBUSY; ++ goto out; ++ } ++ ++ linecard_type = devlink_linecard_type_lookup(linecard, type); ++ if (!linecard_type) { ++ NL_SET_ERR_MSG_MOD(extack, "Unsupported provision type provided"); ++ err = -EINVAL; ++ goto out; ++ } ++ ++ linecard->state = DEVLINK_LINECARD_STATE_PROVISIONING; ++ linecard->type = linecard_type->type; ++ devlink_linecard_notify(linecard, ++ DEVLINK_CMD_LINECARD_NEW); ++ mutex_unlock(&linecard->state_lock); ++ err = linecard->ops->provision(linecard, linecard->priv, ++ linecard_type->type, linecard_type->priv, ++ extack); ++ if (err) { ++ /* Provisioning failed. Assume the linecard is unprovisioned ++ * for future operations. ++ */ ++ mutex_lock(&linecard->state_lock); ++ linecard->state = DEVLINK_LINECARD_STATE_UNPROVISIONED; ++ devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW); ++ mutex_unlock(&linecard->state_lock); ++ } ++ return err; ++ ++out: ++ mutex_unlock(&linecard->state_lock); ++ return err; ++} ++ ++static int devlink_linecard_type_unset(struct devlink_linecard *linecard, ++ struct netlink_ext_ack *extack) ++{ ++ int err; ++ ++ mutex_lock(&linecard->state_lock); ++ if (linecard->state == DEVLINK_LINECARD_STATE_PROVISIONING) { ++ NL_SET_ERR_MSG_MOD(extack, "Linecard is currently being provisioned"); ++ err = -EBUSY; ++ goto out; ++ } ++ if (linecard->state == DEVLINK_LINECARD_STATE_UNPROVISIONING) { ++ NL_SET_ERR_MSG_MOD(extack, "Linecard is currently being unprovisioned"); ++ err = -EBUSY; ++ goto out; ++ } ++ if (linecard->state == DEVLINK_LINECARD_STATE_PROVISIONING_FAILED) { ++ linecard->state = DEVLINK_LINECARD_STATE_UNPROVISIONED; ++ linecard->type = NULL; ++ devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW); ++ err = 0; ++ goto out; ++ } ++ ++ if (linecard->state == DEVLINK_LINECARD_STATE_UNPROVISIONED || ++ linecard->state == DEVLINK_LINECARD_STATE_UNSPEC) { ++ NL_SET_ERR_MSG_MOD(extack, "Linecard is not provisioned"); ++ err = -EOPNOTSUPP; ++ goto out; ++ } ++ linecard->state = DEVLINK_LINECARD_STATE_UNPROVISIONING; ++ devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW); ++ mutex_unlock(&linecard->state_lock); ++ err = linecard->ops->unprovision(linecard, linecard->priv, ++ extack); ++ if (err) { ++ /* Unprovisioning failed. Assume the linecard is unprovisioned ++ * for future operations. ++ */ ++ mutex_lock(&linecard->state_lock); ++ linecard->state = DEVLINK_LINECARD_STATE_UNPROVISIONED; ++ devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW); ++ mutex_unlock(&linecard->state_lock); ++ } ++ return err; ++ ++out: ++ mutex_unlock(&linecard->state_lock); ++ return err; ++} ++ ++static int devlink_nl_cmd_linecard_set_doit(struct sk_buff *skb, ++ struct genl_info *info) ++{ ++ struct devlink_linecard *linecard = info->user_ptr[1]; ++ struct netlink_ext_ack *extack = info->extack; ++ int err; ++ ++ if (info->attrs[DEVLINK_ATTR_LINECARD_TYPE]) { ++ const char *type; ++ ++ type = nla_data(info->attrs[DEVLINK_ATTR_LINECARD_TYPE]); ++ if (strcmp(type, "")) { ++ err = devlink_linecard_type_set(linecard, type, extack); ++ if (err) ++ return err; ++ } else { ++ err = devlink_linecard_type_unset(linecard, extack); ++ if (err) ++ return err; ++ } ++ } ++ ++ return 0; ++} ++ + static int devlink_nl_sb_fill(struct sk_buff *msg, struct devlink *devlink, + struct devlink_sb *devlink_sb, + enum devlink_command cmd, u32 portid, +@@ -7818,19 +7997,8 @@ static const struct nla_policy devlink_nl_policy[DEVLINK_ATTR_MAX + 1] = { + [DEVLINK_ATTR_RELOAD_ACTION] = NLA_POLICY_RANGE(NLA_U8, DEVLINK_RELOAD_ACTION_DRIVER_REINIT, + DEVLINK_RELOAD_ACTION_MAX), + [DEVLINK_ATTR_RELOAD_LIMITS] = NLA_POLICY_BITFIELD32(DEVLINK_RELOAD_LIMITS_VALID_MASK), +-//<<<<<<< HEAD +-//======= +- [DEVLINK_ATTR_PORT_FLAVOUR] = { .type = NLA_U16 }, +- [DEVLINK_ATTR_PORT_PCI_PF_NUMBER] = { .type = NLA_U16 }, +- [DEVLINK_ATTR_PORT_PCI_SF_NUMBER] = { .type = NLA_U32 }, +- [DEVLINK_ATTR_PORT_CONTROLLER_NUMBER] = { .type = NLA_U32 }, +- [DEVLINK_ATTR_RATE_TYPE] = { .type = NLA_U16 }, +- [DEVLINK_ATTR_RATE_TX_SHARE] = { .type = NLA_U64 }, +- [DEVLINK_ATTR_RATE_TX_MAX] = { .type = NLA_U64 }, +- [DEVLINK_ATTR_RATE_NODE_NAME] = { .type = NLA_NUL_STRING }, +- [DEVLINK_ATTR_RATE_PARENT_NODE_NAME] = { .type = NLA_NUL_STRING }, + [DEVLINK_ATTR_LINECARD_INDEX] = { .type = NLA_U32 }, +-//>>>>>>> 1180815a3831... devlink: add support to create line card and expose to user ++ [DEVLINK_ATTR_LINECARD_TYPE] = { .type = NLA_NUL_STRING }, + }; + + static const struct genl_small_ops devlink_nl_ops[] = { +@@ -7878,6 +8046,13 @@ static const struct genl_small_ops devlink_nl_ops[] = { + DEVLINK_NL_FLAG_NO_LOCK, + /* can be retrieved by unprivileged users */ + }, ++ { ++ .cmd = DEVLINK_CMD_LINECARD_SET, ++ .doit = devlink_nl_cmd_linecard_set_doit, ++ .flags = GENL_ADMIN_PERM, ++ .internal_flags = DEVLINK_NL_FLAG_NEED_LINECARD | ++ DEVLINK_NL_FLAG_NO_LOCK, ++ }, + { + .cmd = DEVLINK_CMD_SB_GET, + .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, +@@ -8677,35 +8852,85 @@ static int __devlink_port_phys_port_name_get(struct devlink_port *devlink_port, + return 0; + } + ++static int devlink_linecard_types_init(struct devlink_linecard *linecard) ++{ ++ struct devlink_linecard_type *linecard_type; ++ unsigned int count; ++ int i; ++ ++ count = linecard->ops->types_count(linecard, linecard->priv); ++ linecard->types = kmalloc_array(count, sizeof(*linecard_type), ++ GFP_KERNEL); ++ if (!linecard->types) ++ return -ENOMEM; ++ linecard->types_count = count; ++ ++ for (i = 0; i < count; i++) { ++ linecard_type = &linecard->types[i]; ++ linecard->ops->types_get(linecard, linecard->priv, i, ++ &linecard_type->type, ++ &linecard_type->priv); ++ } ++ return 0; ++} ++ ++static void devlink_linecard_types_fini(struct devlink_linecard *linecard) ++{ ++ kfree(linecard->types); ++} ++ + /** + * devlink_linecard_create - Create devlink linecard + * + * @devlink: devlink + * @linecard_index: driver-specific numerical identifier of the linecard ++ * @ops: linecards ops ++ * @priv: user priv pointer + * + * Create devlink linecard instance with provided linecard index. + * Caller can use any indexing, even hw-related one. + */ +-struct devlink_linecard *devlink_linecard_create(struct devlink *devlink, +- unsigned int linecard_index) ++struct devlink_linecard * ++devlink_linecard_create(struct devlink *devlink, unsigned int linecard_index, ++ const struct devlink_linecard_ops *ops, void *priv) + { + struct devlink_linecard *linecard; ++ int err; ++ ++ if (WARN_ON(!ops || !ops->provision || !ops->unprovision || ++ !ops->types_count || !ops->types_get)) ++ return ERR_PTR(-EINVAL); + + mutex_lock(&devlink->linecards_lock); + if (devlink_linecard_index_exists(devlink, linecard_index)) { +- mutex_unlock(&devlink->linecards_lock); +- return ERR_PTR(-EEXIST); ++ linecard = ERR_PTR(-EEXIST); ++ goto unlock; + } + + linecard = kzalloc(sizeof(*linecard), GFP_KERNEL); +- if (!linecard) +- return ERR_PTR(-ENOMEM); ++ if (!linecard) { ++ linecard = ERR_PTR(-ENOMEM); ++ goto unlock; ++ } + + linecard->devlink = devlink; + linecard->index = linecard_index; ++ linecard->ops = ops; ++ linecard->priv = priv; ++ linecard->state = DEVLINK_LINECARD_STATE_UNPROVISIONED; ++ mutex_init(&linecard->state_lock); ++ ++ err = devlink_linecard_types_init(linecard); ++ if (err) { ++ kfree(linecard); ++ linecard = ERR_PTR(err); ++ goto unlock; ++ } ++ + list_add_tail(&linecard->list, &devlink->linecard_list); + refcount_set(&linecard->refcount, 1); + devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW); ++unlock: + mutex_unlock(&devlink->linecards_lock); + return linecard; + } +@@ -8721,6 +8946,7 @@ void devlink_linecard_destroy(struct devlink_linecard *linecard) + struct devlink *devlink = linecard->devlink; + + devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_DEL); ++ devlink_linecard_types_fini(linecard); + mutex_lock(&devlink->linecards_lock); + list_del(&linecard->list); + mutex_unlock(&devlink->linecards_lock); +@@ -8728,6 +8954,53 @@ void devlink_linecard_destroy(struct devlink_linecard *linecard) + } + EXPORT_SYMBOL_GPL(devlink_linecard_destroy); + ++/** ++ * devlink_linecard_provision_set - Set provisioning on linecard ++ * ++ * @linecard: devlink linecard ++ * @type: linecard type ++ */ ++void devlink_linecard_provision_set(struct devlink_linecard *linecard, ++ const char *type) ++{ ++ mutex_lock(&linecard->state_lock); ++ WARN_ON(linecard->type && linecard->type != type); ++ linecard->state = DEVLINK_LINECARD_STATE_PROVISIONED; ++ linecard->type = type; ++ devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW); ++ mutex_unlock(&linecard->state_lock); ++} ++EXPORT_SYMBOL_GPL(devlink_linecard_provision_set); ++ ++/** ++ * devlink_linecard_provision_clear - Clear provisioning on linecard ++ * ++ * @linecard: devlink linecard ++ */ ++void devlink_linecard_provision_clear(struct devlink_linecard *linecard) ++{ ++ mutex_lock(&linecard->state_lock); ++ linecard->state = DEVLINK_LINECARD_STATE_UNPROVISIONED; ++ linecard->type = NULL; ++ devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW); ++ mutex_unlock(&linecard->state_lock); ++} ++EXPORT_SYMBOL_GPL(devlink_linecard_provision_clear); ++ ++/** ++ * devlink_linecard_provision_fail - Fail provisioning on linecard ++ * ++ * @linecard: devlink linecard ++ */ ++void devlink_linecard_provision_fail(struct devlink_linecard *linecard) ++{ ++ mutex_lock(&linecard->state_lock); ++ linecard->state = DEVLINK_LINECARD_STATE_PROVISIONING_FAILED; ++ devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW); ++ mutex_unlock(&linecard->state_lock); ++} ++EXPORT_SYMBOL_GPL(devlink_linecard_provision_fail); ++ + int devlink_sb_register(struct devlink *devlink, unsigned int sb_index, + u32 size, u16 ingress_pools_count, + u16 egress_pools_count, u16 ingress_tc_count, +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0127-devlink-implement-line-card-active-state.patch b/platform/mellanox/non-upstream-patches/patches/0127-devlink-implement-line-card-active-state.patch new file mode 100644 index 000000000000..857f84b45b7d --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0127-devlink-implement-line-card-active-state.patch @@ -0,0 +1,98 @@ +From 999c148a0a19a6a6c96dbc5b6615285d80c28de9 Mon Sep 17 00:00:00 2001 +From: Jiri Pirko +Date: Wed, 6 Jan 2021 16:03:43 +0100 +Subject: [PATCH] devlink: implement line card active state + +Allow driver to mark a linecard as active. Expose this state to the +userspace over devlink netlink interface with proper notifications. + +Signed-off-by: Jiri Pirko +--- + include/net/devlink.h | 3 +++ + include/uapi/linux/devlink.h | 1 + + net/core/devlink.c | 36 ++++++++++++++++++++++++++++++++++++ + 3 files changed, 40 insertions(+) + +diff --git a/include/net/devlink.h b/include/net/devlink.h +index 44b60085e..d9b2b559c 100644 +--- a/include/net/devlink.h ++++ b/include/net/devlink.h +@@ -157,6 +157,7 @@ struct devlink_linecard { + const char *type; + struct devlink_linecard_type *types; + unsigned int types_count; ++ bool active; + }; + + /** +@@ -1453,6 +1454,8 @@ void devlink_linecard_provision_set(struct devlink_linecard *linecard, + const char *type); + void devlink_linecard_provision_clear(struct devlink_linecard *linecard); + void devlink_linecard_provision_fail(struct devlink_linecard *linecard); ++void devlink_linecard_activate(struct devlink_linecard *linecard); ++void devlink_linecard_deactivate(struct devlink_linecard *linecard); + int devlink_sb_register(struct devlink *devlink, unsigned int sb_index, + u32 size, u16 ingress_pools_count, + u16 egress_pools_count, u16 ingress_tc_count, +diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h +index d88336645..5ace55666 100644 +--- a/include/uapi/linux/devlink.h ++++ b/include/uapi/linux/devlink.h +@@ -341,6 +341,7 @@ enum devlink_linecard_state { + DEVLINK_LINECARD_STATE_PROVISIONING, + DEVLINK_LINECARD_STATE_PROVISIONING_FAILED, + DEVLINK_LINECARD_STATE_PROVISIONED, ++ DEVLINK_LINECARD_STATE_ACTIVE, + + __DEVLINK_LINECARD_STATE_MAX, + DEVLINK_LINECARD_STATE_MAX = __DEVLINK_LINECARD_STATE_MAX - 1 +diff --git a/net/core/devlink.c b/net/core/devlink.c +index 943973ffc..724633810 100644 +--- a/net/core/devlink.c ++++ b/net/core/devlink.c +@@ -9001,6 +9001,42 @@ void devlink_linecard_provision_fail(struct devlink_linecard *linecard) + } + EXPORT_SYMBOL_GPL(devlink_linecard_provision_fail); + ++/** ++ * devlink_linecard_activate - Set linecard active ++ * ++ * @devlink_linecard: devlink linecard ++ */ ++void devlink_linecard_activate(struct devlink_linecard *linecard) ++{ ++ mutex_lock(&linecard->state_lock); ++ WARN_ON(linecard->state != DEVLINK_LINECARD_STATE_PROVISIONED); ++ linecard->state = DEVLINK_LINECARD_STATE_ACTIVE; ++ devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW); ++ mutex_unlock(&linecard->state_lock); ++} ++EXPORT_SYMBOL_GPL(devlink_linecard_activate); ++ ++/** ++ * devlink_linecard_deactivate - Set linecard inactive ++ * ++ * @devlink_linecard: devlink linecard ++ */ ++void devlink_linecard_deactivate(struct devlink_linecard *linecard) ++{ ++ bool should_notify = false; ++ ++ mutex_lock(&linecard->state_lock); ++ if (linecard->state != DEVLINK_LINECARD_STATE_UNPROVISIONING) { ++ WARN_ON(linecard->state != DEVLINK_LINECARD_STATE_ACTIVE); ++ linecard->state = DEVLINK_LINECARD_STATE_PROVISIONED; ++ should_notify = true; ++ } ++ if (should_notify) ++ devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW); ++ mutex_unlock(&linecard->state_lock); ++} ++EXPORT_SYMBOL_GPL(devlink_linecard_deactivate); ++ + int devlink_sb_register(struct devlink *devlink, unsigned int sb_index, + u32 size, u16 ingress_pools_count, + u16 egress_pools_count, u16 ingress_tc_count, +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0128-devlink-add-port-to-line-card-relationship-set.patch b/platform/mellanox/non-upstream-patches/patches/0128-devlink-add-port-to-line-card-relationship-set.patch new file mode 100644 index 000000000000..eeae6ea472d2 --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0128-devlink-add-port-to-line-card-relationship-set.patch @@ -0,0 +1,101 @@ +From ce052dd9aec77733b55fe1285a9be5c4cbcc87b3 Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Wed, 22 Dec 2021 14:10:14 +0000 +Subject: [PATCH] devlink: add port to line card relationship set + +In order to properly inform user about relationship between port and +line card, introduce a driver API to set line card for a port. Use this +information to extend port devlink netlink message by line card index +and also include the line card index into phys_port_name and by that +into a netdevice name. + +Signed-off-by: Jiri Pirko +--- + include/net/devlink.h | 4 ++++ + net/core/devlink.c | 34 ++++++++++++++++++++++++++++------ + 2 files changed, 32 insertions(+), 6 deletions(-) + +diff --git a/include/net/devlink.h b/include/net/devlink.h +index d9b2b559c..3d4ceb290 100644 +--- a/include/net/devlink.h ++++ b/include/net/devlink.h +@@ -140,6 +140,8 @@ struct devlink_port { + struct delayed_work type_warn_dw; + struct list_head reporter_list; + struct mutex reporters_lock; /* Protects reporter_list */ ++ ++ struct devlink_linecard *linecard; + }; + + struct devlink_linecard_ops; +@@ -1446,6 +1448,8 @@ void devlink_port_attrs_pci_pf_set(struct devlink_port *devlink_port, u32 contro + u16 pf, bool external); + void devlink_port_attrs_pci_vf_set(struct devlink_port *devlink_port, u32 controller, + u16 pf, u16 vf, bool external); ++void devlink_port_linecard_set(struct devlink_port *devlink_port, ++ struct devlink_linecard *linecard); + struct devlink_linecard * + devlink_linecard_create(struct devlink *devlink, unsigned int linecard_index, + const struct devlink_linecard_ops *ops, void *priv); +diff --git a/net/core/devlink.c b/net/core/devlink.c +index 724633810..b43e93ccc 100644 +--- a/net/core/devlink.c ++++ b/net/core/devlink.c +@@ -905,6 +905,10 @@ static int devlink_nl_port_fill(struct sk_buff *msg, struct devlink *devlink, + goto nla_put_failure; + if (devlink_nl_port_function_attrs_put(msg, devlink_port, extack)) + goto nla_put_failure; ++ if (devlink_port->linecard && ++ nla_put_u32(msg, DEVLINK_ATTR_LINECARD_INDEX, ++ devlink_port->linecard->index)) ++ goto nla_put_failure; + + genlmsg_end(msg, hdr); + return 0; +@@ -8795,6 +8799,21 @@ void devlink_port_attrs_pci_vf_set(struct devlink_port *devlink_port, u32 contro + } + EXPORT_SYMBOL_GPL(devlink_port_attrs_pci_vf_set); + ++/** ++ * devlink_port_linecard_set - Link port with a linecard ++ * ++ * @devlink_port: devlink port ++ * @devlink_linecard: devlink linecard ++ */ ++void devlink_port_linecard_set(struct devlink_port *devlink_port, ++ struct devlink_linecard *linecard) ++{ ++ if (WARN_ON(devlink_port->devlink)) ++ return; ++ devlink_port->linecard = linecard; ++} ++EXPORT_SYMBOL_GPL(devlink_port_linecard_set); ++ + static int __devlink_port_phys_port_name_get(struct devlink_port *devlink_port, + char *name, size_t len) + { +@@ -8806,12 +8825,15 @@ static int __devlink_port_phys_port_name_get(struct devlink_port *devlink_port, + + switch (attrs->flavour) { + case DEVLINK_PORT_FLAVOUR_PHYSICAL: +- if (!attrs->split) +- n = snprintf(name, len, "p%u", attrs->phys.port_number); +- else +- n = snprintf(name, len, "p%us%u", +- attrs->phys.port_number, +- attrs->phys.split_subport_number); ++ if (devlink_port->linecard) ++ n = snprintf(name, len, "l%u", ++ devlink_port->linecard->index); ++ if (n < len) ++ n += snprintf(name + n, len - n, "p%u", ++ attrs->phys.port_number); ++ if (n < len && attrs->split) ++ n += snprintf(name + n, len - n, "s%u", ++ attrs->phys.split_subport_number); + break; + case DEVLINK_PORT_FLAVOUR_CPU: + case DEVLINK_PORT_FLAVOUR_DSA: +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0129-devlink-introduce-linecard-info-get-message.patch b/platform/mellanox/non-upstream-patches/patches/0129-devlink-introduce-linecard-info-get-message.patch new file mode 100644 index 000000000000..9efc8b2aa038 --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0129-devlink-introduce-linecard-info-get-message.patch @@ -0,0 +1,245 @@ +From fdc91e1289c5e491e93f7d7a872d2d656d1d0e7f Mon Sep 17 00:00:00 2001 +From: Jiri Pirko +Date: Fri, 19 Feb 2021 09:36:15 +0100 +Subject: [PATCH] devlink: introduce linecard info get message + +Allow the driver to provide per line card info get op to fill-up info, +similar to the "devlink dev info". + +Signed-off-by: Jiri Pirko +--- + include/net/devlink.h | 7 +- + include/uapi/linux/devlink.h | 3 + + net/core/devlink.c | 135 +++++++++++++++++++++++++++++++++-- + 3 files changed, 140 insertions(+), 5 deletions(-) + +diff --git a/include/net/devlink.h b/include/net/devlink.h +index 3d4ceb290..059bed6ae 100644 +--- a/include/net/devlink.h ++++ b/include/net/devlink.h +@@ -162,6 +162,8 @@ struct devlink_linecard { + bool active; + }; + ++struct devlink_info_req; ++ + /** + * struct devlink_linecard_ops - Linecard operations + * @provision: callback to provision the linecard slot with certain +@@ -170,6 +172,7 @@ struct devlink_linecard { + * @types_init: callback to initialize types list + * @types_fini: callback to finalize types list + * @types_get: callback to get next type in list ++ * @info_get: callback to get linecard info + */ + struct devlink_linecard_ops { + int (*provision)(struct devlink_linecard *linecard, void *priv, +@@ -182,6 +185,9 @@ struct devlink_linecard_ops { + void (*types_get)(struct devlink_linecard *linecard, + void *priv, unsigned int index, const char **type, + const void **type_priv); ++ int (*info_get)(struct devlink_linecard *linecard, void *priv, ++ struct devlink_info_req *req, ++ struct netlink_ext_ack *extack); + }; + + struct devlink_sb_pool_info { +@@ -630,7 +636,6 @@ struct devlink_flash_update_params { + #define DEVLINK_SUPPORT_FLASH_UPDATE_OVERWRITE_MASK BIT(1) + + struct devlink_region; +-struct devlink_info_req; + + /** + * struct devlink_region_ops - Region operations +diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h +index 5ace55666..2c9f7d584 100644 +--- a/include/uapi/linux/devlink.h ++++ b/include/uapi/linux/devlink.h +@@ -136,6 +136,8 @@ enum devlink_command { + DEVLINK_CMD_LINECARD_NEW, + DEVLINK_CMD_LINECARD_DEL, + ++ DEVLINK_CMD_LINECARD_INFO_GET, /* can dump */ ++ + /* add new commands above here */ + __DEVLINK_CMD_MAX, + DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX - 1 +@@ -566,6 +568,7 @@ enum devlink_attr { + DEVLINK_ATTR_LINECARD_STATE, /* u8 */ + DEVLINK_ATTR_LINECARD_TYPE, /* string */ + DEVLINK_ATTR_LINECARD_SUPPORTED_TYPES, /* nested */ ++ DEVLINK_ATTR_LINECARD_INFO, /* nested */ + + /* add new attributes above here, update the policy in devlink.c */ + +diff --git a/net/core/devlink.c b/net/core/devlink.c +index b43e93ccc..04f8038f8 100644 +--- a/net/core/devlink.c ++++ b/net/core/devlink.c +@@ -1245,6 +1245,10 @@ struct devlink_linecard_type { + const void *priv; + }; + ++struct devlink_info_req { ++ struct sk_buff *msg; ++}; ++ + static int devlink_nl_linecard_fill(struct sk_buff *msg, + struct devlink *devlink, + struct devlink_linecard *linecard, +@@ -1542,6 +1546,125 @@ static int devlink_nl_cmd_linecard_set_doit(struct sk_buff *skb, + return 0; + } + ++static int ++devlink_nl_linecard_info_fill(struct sk_buff *msg, struct devlink *devlink, ++ struct devlink_linecard *linecard, ++ enum devlink_command cmd, u32 portid, ++ u32 seq, int flags, struct netlink_ext_ack *extack) ++{ ++ struct devlink_info_req req; ++ struct nlattr *attr; ++ void *hdr; ++ int err; ++ ++ hdr = genlmsg_put(msg, portid, seq, &devlink_nl_family, flags, cmd); ++ if (!hdr) ++ return -EMSGSIZE; ++ ++ err = -EMSGSIZE; ++ if (devlink_nl_put_handle(msg, devlink)) ++ goto nla_put_failure; ++ if (nla_put_u32(msg, DEVLINK_ATTR_LINECARD_INDEX, linecard->index)) ++ goto nla_put_failure; ++ ++ attr = nla_nest_start(msg, DEVLINK_ATTR_LINECARD_INFO); ++ if (!attr) ++ goto nla_put_failure; ++ req.msg = msg; ++ err = linecard->ops->info_get(linecard, linecard->priv, &req, extack); ++ if (err) ++ goto nla_put_failure; ++ nla_nest_end(msg, attr); ++ ++ genlmsg_end(msg, hdr); ++ return 0; ++ ++nla_put_failure: ++ genlmsg_cancel(msg, hdr); ++ return err; ++} ++ ++static int devlink_nl_cmd_linecard_info_get_doit(struct sk_buff *skb, ++ struct genl_info *info) ++{ ++ struct devlink_linecard *linecard = info->user_ptr[1]; ++ struct devlink *devlink = linecard->devlink; ++ struct sk_buff *msg; ++ int err; ++ ++ if (!linecard->ops->info_get) ++ return -EOPNOTSUPP; ++ ++ msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); ++ if (!msg) ++ return -ENOMEM; ++ ++ err = devlink_nl_linecard_info_fill(msg, devlink, linecard, ++ DEVLINK_CMD_LINECARD_INFO_GET, ++ info->snd_portid, info->snd_seq, 0, ++ info->extack); ++ if (err) { ++ nlmsg_free(msg); ++ return err; ++ } ++ ++ return genlmsg_reply(msg, info); ++} ++ ++static int devlink_nl_cmd_linecard_info_get_dumpit(struct sk_buff *msg, ++ struct netlink_callback *cb) ++{ ++ struct devlink_linecard *linecard; ++ struct devlink *devlink; ++ int start = cb->args[0]; ++ unsigned long index; ++ int idx = 0; ++ int err = 0; ++ ++ mutex_lock(&devlink_mutex); ++ xa_for_each_marked(&devlinks, index, devlink, DEVLINK_REGISTERED) { ++ if (!devlink_try_get(devlink)) ++ continue; ++ ++ if (!net_eq(devlink_net(devlink), sock_net(msg->sk))) ++ goto retry; ++ ++ mutex_lock(&devlink->linecards_lock); ++ list_for_each_entry(linecard, &devlink->linecard_list, list) { ++ if (idx < start || !linecard->ops->info_get) { ++ idx++; ++ continue; ++ } ++ mutex_lock(&linecard->state_lock); ++ err = devlink_nl_linecard_info_fill(msg, devlink, linecard, ++ DEVLINK_CMD_LINECARD_INFO_GET, ++ NETLINK_CB(cb->skb).portid, ++ cb->nlh->nlmsg_seq, ++ NLM_F_MULTI, ++ cb->extack); ++ mutex_unlock(&linecard->state_lock); ++ if (err) { ++ mutex_unlock(&devlink->linecards_lock); ++ devlink_put(devlink); ++ goto out; ++ } ++ idx++; ++ } ++ mutex_unlock(&devlink->linecards_lock); ++retry: ++ devlink_put(devlink); ++ } ++out: ++ mutex_unlock(&devlink_mutex); ++ ++ if (err != -EMSGSIZE) ++ return err; ++ ++ cb->args[0] = idx; ++ return msg->len; ++} ++ ++ + static int devlink_nl_sb_fill(struct sk_buff *msg, struct devlink *devlink, + struct devlink_sb *devlink_sb, + enum devlink_command cmd, u32 portid, +@@ -5455,10 +5578,6 @@ static int devlink_nl_cmd_region_read_dumpit(struct sk_buff *skb, + return err; + } + +-struct devlink_info_req { +- struct sk_buff *msg; +-}; +- + int devlink_info_driver_name_put(struct devlink_info_req *req, const char *name) + { + return nla_put_string(req->msg, DEVLINK_ATTR_INFO_DRIVER_NAME, name); +@@ -8057,6 +8176,14 @@ static const struct genl_small_ops devlink_nl_ops[] = { + .internal_flags = DEVLINK_NL_FLAG_NEED_LINECARD | + DEVLINK_NL_FLAG_NO_LOCK, + }, ++ { ++ .cmd = DEVLINK_CMD_LINECARD_INFO_GET, ++ .doit = devlink_nl_cmd_linecard_info_get_doit, ++ .dumpit = devlink_nl_cmd_linecard_info_get_dumpit, ++ .internal_flags = DEVLINK_NL_FLAG_NEED_LINECARD | ++ DEVLINK_NL_FLAG_NO_LOCK, ++ /* can be retrieved by unprivileged users */ ++ }, + { + .cmd = DEVLINK_CMD_SB_GET, + .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0130-devlink-introduce-linecard-info-get-message.patch b/platform/mellanox/non-upstream-patches/patches/0130-devlink-introduce-linecard-info-get-message.patch new file mode 100644 index 000000000000..f6ea2b2f4946 --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0130-devlink-introduce-linecard-info-get-message.patch @@ -0,0 +1,315 @@ +From 7a39de95203f7dc033bdc81703989d627f2ca0de Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Wed, 22 Dec 2021 15:11:36 +0000 +Subject: [PATCH] devlink: introduce linecard info get message + +Allow the driver to provide per line card info get op to fill-up info, +similar to the "devlink dev info". + +devlink: introduce line card devices support + +Line card can contain a device. For example, this can be a gearbox with +flash. This flash could be updated. Provide the driver possibility to +attach such devices to a line card and expose those to user. Leverage +the existing devlink flash update mechanism and allow driver to pass a +custom "component name" string identifying the line card device to +flash. + +Signed-off-by: Jiri Pirko +--- + include/net/devlink.h | 12 +++ + include/uapi/linux/devlink.h | 4 + + net/core/devlink.c | 166 +++++++++++++++++++++++++++++++++++ + 3 files changed, 182 insertions(+) + +diff --git a/include/net/devlink.h b/include/net/devlink.h +index 059bed6ae..06b61c1d7 100644 +--- a/include/net/devlink.h ++++ b/include/net/devlink.h +@@ -160,9 +160,11 @@ struct devlink_linecard { + struct devlink_linecard_type *types; + unsigned int types_count; + bool active; ++ struct list_head device_list; + }; + + struct devlink_info_req; ++struct devlink_linecard_device; + + /** + * struct devlink_linecard_ops - Linecard operations +@@ -188,6 +190,9 @@ struct devlink_linecard_ops { + int (*info_get)(struct devlink_linecard *linecard, void *priv, + struct devlink_info_req *req, + struct netlink_ext_ack *extack); ++ int (*device_info_get)(struct devlink_linecard_device *device, ++ void *priv, struct devlink_info_req *req, ++ struct netlink_ext_ack *extack); + }; + + struct devlink_sb_pool_info { +@@ -1459,6 +1464,13 @@ struct devlink_linecard * + devlink_linecard_create(struct devlink *devlink, unsigned int linecard_index, + const struct devlink_linecard_ops *ops, void *priv); + void devlink_linecard_destroy(struct devlink_linecard *linecard); ++struct devlink_linecard_device * ++devlink_linecard_device_create(struct devlink_linecard *linecard, ++ unsigned int device_index, ++ const char *flash_component, void *priv); ++void ++devlink_linecard_device_destroy(struct devlink_linecard *linecard, ++ struct devlink_linecard_device *linecard_device); + void devlink_linecard_provision_set(struct devlink_linecard *linecard, + const char *type); + void devlink_linecard_provision_clear(struct devlink_linecard *linecard); +diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h +index 2c9f7d584..bac94c3c1 100644 +--- a/include/uapi/linux/devlink.h ++++ b/include/uapi/linux/devlink.h +@@ -569,6 +569,10 @@ enum devlink_attr { + DEVLINK_ATTR_LINECARD_TYPE, /* string */ + DEVLINK_ATTR_LINECARD_SUPPORTED_TYPES, /* nested */ + DEVLINK_ATTR_LINECARD_INFO, /* nested */ ++ DEVLINK_ATTR_LINECARD_DEVICE_LIST, /* nested */ ++ DEVLINK_ATTR_LINECARD_DEVICE, /* nested */ ++ DEVLINK_ATTR_LINECARD_DEVICE_INDEX, /* u32 */ ++ DEVLINK_ATTR_LINECARD_DEVICE_INFO, /* nested */ + + /* add new attributes above here, update the policy in devlink.c */ + +diff --git a/net/core/devlink.c b/net/core/devlink.c +index 04f8038f8..ca014f40a 100644 +--- a/net/core/devlink.c ++++ b/net/core/devlink.c +@@ -1249,6 +1249,59 @@ struct devlink_info_req { + struct sk_buff *msg; + }; + ++struct devlink_linecard_device { ++ struct list_head list; ++ unsigned int index; ++ const char *flash_component; ++ void *priv; ++}; ++ ++static int ++devlink_nl_linecard_device_fill(struct sk_buff *msg, ++ struct devlink_linecard *linecard, ++ struct devlink_linecard_device *linecard_device) ++{ ++ struct nlattr *attr; ++ ++ attr = nla_nest_start(msg, DEVLINK_ATTR_LINECARD_DEVICE); ++ if (!attr) ++ return -EMSGSIZE; ++ if (nla_put_u32(msg, DEVLINK_ATTR_LINECARD_DEVICE_INDEX, ++ linecard_device->index)) ++ return -EMSGSIZE; ++ if (linecard_device->flash_component && ++ nla_put_string(msg, DEVLINK_ATTR_FLASH_UPDATE_COMPONENT, ++ linecard_device->flash_component)) ++ return -EMSGSIZE; ++ nla_nest_end(msg, attr); ++ ++ return 0; ++} ++ ++static int devlink_nl_linecard_devices_fill(struct sk_buff *msg, ++ struct devlink_linecard *linecard) ++{ ++ struct devlink_linecard_device *linecard_device; ++ struct nlattr *attr; ++ int err; ++ ++ if (list_empty(&linecard->device_list)) ++ return 0; ++ ++ attr = nla_nest_start(msg, DEVLINK_ATTR_LINECARD_DEVICE_LIST); ++ if (!attr) ++ return -EMSGSIZE; ++ list_for_each_entry(linecard_device, &linecard->device_list, list) { ++ err = devlink_nl_linecard_device_fill(msg, linecard, ++ linecard_device); ++ if (err) ++ return err; ++ } ++ nla_nest_end(msg, attr); ++ ++ return 0; ++} ++ + static int devlink_nl_linecard_fill(struct sk_buff *msg, + struct devlink *devlink, + struct devlink_linecard *linecard, +@@ -1259,6 +1312,7 @@ static int devlink_nl_linecard_fill(struct sk_buff *msg, + struct devlink_linecard_type *linecard_type; + struct nlattr *attr; + void *hdr; ++ int err; + int i; + + hdr = genlmsg_put(msg, portid, seq, &devlink_nl_family, flags, cmd); +@@ -1289,6 +1343,10 @@ static int devlink_nl_linecard_fill(struct sk_buff *msg, + nla_nest_end(msg, attr); + } + ++ err = devlink_nl_linecard_devices_fill(msg, linecard); ++ if (err) ++ goto nla_put_failure; ++ + genlmsg_end(msg, hdr); + return 0; + +@@ -1546,6 +1604,66 @@ static int devlink_nl_cmd_linecard_set_doit(struct sk_buff *skb, + return 0; + } + ++static int ++devlink_nl_linecard_device_info_fill(struct sk_buff *msg, ++ struct devlink_linecard *linecard, ++ struct devlink_linecard_device *linecard_device, ++ struct netlink_ext_ack *extack) ++{ ++ struct nlattr *attr, *attr2; ++ ++ attr = nla_nest_start(msg, DEVLINK_ATTR_LINECARD_DEVICE); ++ if (!attr) ++ return -EMSGSIZE; ++ if (nla_put_u32(msg, DEVLINK_ATTR_LINECARD_DEVICE_INDEX, ++ linecard_device->index)) ++ return -EMSGSIZE; ++ if (linecard->ops->device_info_get) { ++ struct devlink_info_req req; ++ int err; ++ ++ attr2 = nla_nest_start(msg, DEVLINK_ATTR_LINECARD_DEVICE_INFO); ++ if (!attr2) ++ return -EMSGSIZE; ++ req.msg = msg; ++ err = linecard->ops->device_info_get(linecard_device, ++ linecard_device->priv, ++ &req, extack); ++ if (err) ++ return -EMSGSIZE; ++ nla_nest_end(msg, attr2); ++ } ++ nla_nest_end(msg, attr); ++ ++ return 0; ++} ++ ++static int devlink_nl_linecard_devices_info_fill(struct sk_buff *msg, ++ struct devlink_linecard *linecard, ++ struct netlink_ext_ack *extack) ++{ ++ struct devlink_linecard_device *linecard_device; ++ struct nlattr *attr; ++ int err; ++ ++ if (list_empty(&linecard->device_list)) ++ return 0; ++ ++ attr = nla_nest_start(msg, DEVLINK_ATTR_LINECARD_DEVICE_LIST); ++ if (!attr) ++ return -EMSGSIZE; ++ list_for_each_entry(linecard_device, &linecard->device_list, list) { ++ err = devlink_nl_linecard_device_info_fill(msg, linecard, ++ linecard_device, ++ extack); ++ if (err) ++ return err; ++ } ++ nla_nest_end(msg, attr); ++ ++ return 0; ++} ++ + static int + devlink_nl_linecard_info_fill(struct sk_buff *msg, struct devlink *devlink, + struct devlink_linecard *linecard, +@@ -1576,6 +1694,10 @@ devlink_nl_linecard_info_fill(struct sk_buff *msg, struct devlink *devlink, + goto nla_put_failure; + nla_nest_end(msg, attr); + ++ err = devlink_nl_linecard_devices_info_fill(msg, linecard, extack); ++ if (err) ++ goto nla_put_failure; ++ + genlmsg_end(msg, hdr); + return 0; + +@@ -9068,6 +9190,7 @@ devlink_linecard_create(struct devlink *devlink, unsigned int linecard_index, + linecard->priv = priv; + linecard->state = DEVLINK_LINECARD_STATE_UNPROVISIONED; + mutex_init(&linecard->state_lock); ++ INIT_LIST_HEAD(&linecard->device_list); + + err = devlink_linecard_types_init(linecard); + if (err) { +@@ -9096,6 +9219,7 @@ void devlink_linecard_destroy(struct devlink_linecard *linecard) + + devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_DEL); + devlink_linecard_types_fini(linecard); ++ WARN_ON(!list_empty(&linecard->device_list)); + mutex_lock(&devlink->linecards_lock); + list_del(&linecard->list); + mutex_unlock(&devlink->linecards_lock); +@@ -9103,6 +9227,47 @@ void devlink_linecard_destroy(struct devlink_linecard *linecard) + } + EXPORT_SYMBOL_GPL(devlink_linecard_destroy); + ++/** ++ * devlink_linecard_device_create - Create a device on linecard ++ * ++ * @devlink_linecard: devlink linecard ++ * @device_index: index of the linecard device ++ * @flash_component: name of flash update component, ++ * NULL if unable to flash ++ */ ++struct devlink_linecard_device * ++devlink_linecard_device_create(struct devlink_linecard *linecard, ++ unsigned int device_index, ++ const char *flash_component, void *priv) ++{ ++ struct devlink_linecard_device *linecard_device; ++ ++ linecard_device = kzalloc(sizeof(*linecard_device), GFP_KERNEL); ++ if (!linecard_device) ++ return ERR_PTR(-ENOMEM); ++ linecard_device->index = device_index; ++ linecard_device->flash_component = flash_component; ++ linecard_device->priv = priv; ++ mutex_lock(&linecard->devlink->lock); ++ list_add_tail(&linecard_device->list, &linecard->device_list); ++ devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW); ++ mutex_unlock(&linecard->devlink->lock); ++ return linecard_device; ++} ++EXPORT_SYMBOL_GPL(devlink_linecard_device_create); ++ ++void ++devlink_linecard_device_destroy(struct devlink_linecard *linecard, ++ struct devlink_linecard_device *linecard_device) ++{ ++ mutex_lock(&linecard->devlink->lock); ++ devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW); ++ list_del(&linecard_device->list); ++ mutex_unlock(&linecard->devlink->lock); ++ kfree(linecard_device); ++} ++EXPORT_SYMBOL_GPL(devlink_linecard_device_destroy); ++ + /** + * devlink_linecard_provision_set - Set provisioning on linecard + * +@@ -9129,6 +9294,7 @@ EXPORT_SYMBOL_GPL(devlink_linecard_provision_set); + void devlink_linecard_provision_clear(struct devlink_linecard *linecard) + { + mutex_lock(&linecard->state_lock); ++ WARN_ON(!list_empty(&linecard->device_list)); + linecard->state = DEVLINK_LINECARD_STATE_UNPROVISIONED; + linecard->type = NULL; + devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW); +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0131-mlxsw-reg-Add-Ports-Mapping-event-Configuration-Regi.patch b/platform/mellanox/non-upstream-patches/patches/0131-mlxsw-reg-Add-Ports-Mapping-event-Configuration-Regi.patch new file mode 100644 index 000000000000..446d2c8d8aed --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0131-mlxsw-reg-Add-Ports-Mapping-event-Configuration-Regi.patch @@ -0,0 +1,98 @@ +From ec8e91d320c8cccb8ad59663d2d59810ea5aecb9 Mon Sep 17 00:00:00 2001 +From: Jiri Pirko +Date: Fri, 29 Jan 2021 08:45:09 +0100 +Subject: [PATCH] mlxsw: reg: Add Ports Mapping event Configuration Register + +The PMECR register use to enable/disable event trigger in case of +local port mapping change. + +Signed-off-by: Jiri Pirko +--- + drivers/net/ethernet/mellanox/mlxsw/reg.h | 64 +++++++++++++++++++++++ + 1 file changed, 64 insertions(+) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h +index 9de037b9a..42169957c 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h ++++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h +@@ -5524,6 +5524,69 @@ static inline void mlxsw_reg_pplr_pack(char *payload, u8 local_port, + MLXSW_REG_PPLR_LB_TYPE_BIT_PHY_LOCAL : 0); + } + ++/* PMECR - Ports Mapping event Configuration Register ++ * -------------------------------------------------- ++ * The PMECR register use to enable/disable event trigger in case of ++ * local port mapping change. ++ */ ++#define MLXSW_REG_PMECR_ID 0x501B ++#define MLXSW_REG_PMECR_LEN 0x20 ++ ++MLXSW_REG_DEFINE(pmecr, MLXSW_REG_PMECR_ID, MLXSW_REG_PMECR_LEN); ++ ++/* reg_pmecr_local_port ++ * Local port number. ++ * Access: Index ++ */ ++MLXSW_ITEM32(reg, pmecr, local_port, 0x00, 16, 8); ++ ++/* reg_pmecr_ee ++ * Event update enable. If this bit is set, event generation will be updated ++ * based on the e field. Only relevant on Set operations. ++ * Access: WO ++ */ ++MLXSW_ITEM32(reg, pmecr, ee, 0x04, 30, 1); ++ ++/* reg_pmecr_eswi ++ * Software ignore enable bit. If this bit is set, the value if swi is used. ++ * If this bit is clear, the value of swi is ignored. ++ * Only relevant on Set operations. ++ * Access: WO ++ */ ++MLXSW_ITEM32(reg, pmecr, eswi, 0x04, 24, 1); ++ ++/* reg_pmecr_swi ++ * Software ignore. If this bit is set, the device shouldn't generate events ++ * in case of PMLP SET operation but only upon self local port mapping change ++ * (if applicable according to e configuration). This is supplementary ++ * configuration on top of e value. ++ * Access: RW ++ */ ++MLXSW_ITEM32(reg, pmecr, swi, 0x04, 8, 1); ++ ++enum mlxsw_reg_pmecr_e { ++ MLXSW_REG_PMECR_E_DO_NOT_GENERATE_EVENT, ++ MLXSW_REG_PMECR_E_GENERATE_EVENT, ++ MLXSW_REG_PMECR_E_GENERATE_SINGLE_EVENT, ++}; ++ ++/* reg_pmecr_e ++ * Event generation on local port mapping change. ++ * Access: RW ++ */ ++MLXSW_ITEM32(reg, pmecr, e, 0x04, 0, 2); ++ ++static inline void mlxsw_reg_pmecr_pack(char *payload, u8 local_port, ++ enum mlxsw_reg_pmecr_e e) ++{ ++ MLXSW_REG_ZERO(pmecr, payload); ++ mlxsw_reg_pmecr_local_port_set(payload, local_port); ++ mlxsw_reg_pmecr_e_set(payload, e); ++ mlxsw_reg_pmecr_ee_set(payload, true); ++ mlxsw_reg_pmecr_swi_set(payload, true); ++ mlxsw_reg_pmecr_eswi_set(payload, true); ++} ++ + /* PMPE - Port Module Plug/Unplug Event Register + * --------------------------------------------- + * This register reports any operational status change of a module. +@@ -11376,6 +11439,7 @@ static const struct mlxsw_reg_info *mlxsw_reg_infos[] = { + MLXSW_REG(pspa), + MLXSW_REG(pmaos), + MLXSW_REG(pplr), ++ MLXSW_REG(pmecr), + MLXSW_REG(pmpe), + MLXSW_REG(pddr), + MLXSW_REG(pmtm), +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0132-mlxsw-reg-Add-Management-DownStream-Device-Query-Reg.patch b/platform/mellanox/non-upstream-patches/patches/0132-mlxsw-reg-Add-Management-DownStream-Device-Query-Reg.patch new file mode 100644 index 000000000000..b0d35e83878b --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0132-mlxsw-reg-Add-Management-DownStream-Device-Query-Reg.patch @@ -0,0 +1,267 @@ +From e46f9bfa89b8b9caced49a74db695e86e963b35d Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Mon, 3 Jan 2022 10:20:49 +0000 +Subject: [PATCH] mlxsw: reg: Add Management DownStream Device Query Register + +The MDDQ register allows to query the DownStream device properties. + +Signed-off-by: Jiri Pirko +--- + drivers/net/ethernet/mellanox/mlxsw/reg.h | 234 ++++++++++++++++++++++ + 1 file changed, 234 insertions(+) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h +index 42169957c..d5301bd6f 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h ++++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h +@@ -10297,6 +10297,239 @@ mlxsw_reg_mgpir_unpack(char *payload, u8 *num_of_devices, + *num_of_slots = mlxsw_reg_mgpir_num_of_slots_get(payload); + } + ++/* MDDQ - Management DownStream Device Query Register ++ * -------------------------------------------------- ++ * This register allows to query the DownStream device properties. The desired ++ * information is chosen upon the query_type field and is delivered by 32B ++ * of data blocks. ++ */ ++#define MLXSW_REG_MDDQ_ID 0x9161 ++#define MLXSW_REG_MDDQ_LEN 0x30 ++ ++MLXSW_REG_DEFINE(mddq, MLXSW_REG_MDDQ_ID, MLXSW_REG_MDDQ_LEN); ++ ++/* reg_mddq_sie ++ * Slot info event enable. ++ * When set to '1', each change in the slot_info.provisioned / sr_valid / ++ * active / ready will generate an event. ++ * Access: RW ++ */ ++MLXSW_ITEM32(reg, mddq, sie, 0x00, 31, 1); ++ ++enum mlxsw_reg_mddq_query_type { ++ MLXSW_REG_MDDQ_QUERY_TYPE_SLOT_INFO = 1, ++ MLXSW_REG_MDDQ_QUERY_TYPE_DEVICE_INFO, /* If there are no devices ++ * on the slot, data_valid ++ * will be '0'. ++ */ ++ MLXSW_REG_MDDQ_QUERY_TYPE_SLOT_NAME, ++}; ++ ++/* reg_mddq_query_type ++ * Access: Index ++ */ ++MLXSW_ITEM32(reg, mddq, query_type, 0x00, 16, 8); ++ ++/* reg_mddq_slot_index ++ * Slot index. 0 is reserved. ++ * Access: Index ++ */ ++MLXSW_ITEM32(reg, mddq, slot_index, 0x00, 0, 4); ++ ++/* reg_mddq_response_msg_seq ++ * Response message sequential number. For a specific request, the response ++ * message sequential number is the following one. In addition, the last ++ * message should be 0. ++ * Access: RO ++ */ ++MLXSW_ITEM32(reg, mddq, response_msg_seq, 0x04, 16, 8); ++ ++/* reg_mddq_request_msg_seq ++ * Request message sequential number. ++ * The first message number should be 0. ++ * Access: Index ++ */ ++MLXSW_ITEM32(reg, mddq, request_msg_seq, 0x04, 0, 8); ++ ++/* reg_mddq_data_valid ++ * If set, the data in the data field is valid and contain the information ++ * for the queried index. ++ * Access: RO ++ */ ++MLXSW_ITEM32(reg, mddq, data_valid, 0x08, 31, 1); ++ ++/* reg_mddq_provisioned ++ * If set, the INI file is applied and the card is provisioned. ++ * Access: RO ++ */ ++MLXSW_ITEM32(reg, mddq, provisioned, 0x10, 31, 1); ++ ++/* reg_mddq_sr_valid ++ * If set, Shift Register is valid (after being provisioned). ++ * Access: RO ++ */ ++MLXSW_ITEM32(reg, mddq, sr_valid, 0x10, 30, 1); ++ ++enum mlxsw_reg_mddq_ready { ++ MLXSW_REG_MDDQ_READY_NOT_READY, ++ MLXSW_REG_MDDQ_READY_READY, ++ MLXSW_REG_MDDQ_READY_ERROR, ++}; ++ ++/* reg_mddq_lc_ready ++ * If set, the LC is powered on, matching the INI version and a new FW ++ * version can be burnt (if necessary). ++ * Access: RO ++ */ ++MLXSW_ITEM32(reg, mddq, lc_ready, 0x10, 28, 2); ++ ++/* reg_mddq_active ++ * If set, the FW has completed the MDDC.device_enable command. ++ * Access: RO ++ */ ++MLXSW_ITEM32(reg, mddq, active, 0x10, 27, 1); ++ ++/* reg_mddq_hw_revision ++ * Major user-configured version number of the current INI file. ++ * Valid only when active or ready are '1'. ++ * Access: RO ++ */ ++MLXSW_ITEM32(reg, mddq, hw_revision, 0x14, 16, 16); ++ ++/* reg_mddq_ini_file_version ++ * User-configured version number of the current INI file. ++ * Valid only when active or lc_ready are '1'. ++ * Access: RO ++ */ ++MLXSW_ITEM32(reg, mddq, ini_file_version, 0x14, 0, 16); ++ ++enum mlxsw_reg_mddq_card_type { ++ MLXSW_REG_MDDQ_CARD_TYPE_BUFFALO_4X400G, ++ MLXSW_REG_MDDQ_CARD_TYPE_BUFFALO_8X200G, ++ MLXSW_REG_MDDQ_CARD_TYPE_BUFFALO_16X100G, ++}; ++ ++/* reg_mddq_card_type ++ * Access: RO ++ */ ++MLXSW_ITEM32(reg, mddq, card_type, 0x18, 0, 8); ++ ++static inline void ++__mlxsw_reg_mddq_pack(char *payload, u8 slot_index, ++ enum mlxsw_reg_mddq_query_type query_type) ++{ ++ MLXSW_REG_ZERO(mddq, payload); ++ mlxsw_reg_mddq_slot_index_set(payload, slot_index); ++ mlxsw_reg_mddq_query_type_set(payload, query_type); ++} ++ ++static inline void ++mlxsw_reg_mddq_slot_info_pack(char *payload, u8 slot_index, bool sie) ++{ ++ __mlxsw_reg_mddq_pack(payload, slot_index, ++ MLXSW_REG_MDDQ_QUERY_TYPE_SLOT_INFO); ++ mlxsw_reg_mddq_sie_set(payload, sie); ++} ++ ++static inline void ++mlxsw_reg_mddq_slot_info_unpack(const char *payload, u8 *p_slot_index, ++ bool *p_provisioned, bool *p_sr_valid, ++ enum mlxsw_reg_mddq_ready *p_lc_ready, ++ bool *p_active, u16 *p_hw_revision, ++ u16 *p_ini_file_version, ++ enum mlxsw_reg_mddq_card_type *p_card_type) ++{ ++ *p_slot_index = mlxsw_reg_mddq_slot_index_get(payload); ++ *p_provisioned = mlxsw_reg_mddq_provisioned_get(payload); ++ *p_sr_valid = mlxsw_reg_mddq_sr_valid_get(payload); ++ *p_lc_ready = mlxsw_reg_mddq_lc_ready_get(payload); ++ *p_active = mlxsw_reg_mddq_active_get(payload); ++ *p_hw_revision = mlxsw_reg_mddq_hw_revision_get(payload); ++ *p_ini_file_version = mlxsw_reg_mddq_ini_file_version_get(payload); ++ *p_card_type = mlxsw_reg_mddq_card_type_get(payload); ++} ++ ++/* reg_mddq_flash_owner ++ * If set, the device is the flash owner. Otherwise, a shared flash ++ * is used by this device (another device is the flash owner). ++ * Access: RO ++ */ ++MLXSW_ITEM32(reg, mddq, flash_owner, 0x10, 30, 1); ++ ++/* reg_mddq_device_index ++ * Device index. The first device should number 0. ++ * Access: RO ++ */ ++MLXSW_ITEM32(reg, mddq, device_index, 0x10, 0, 8); ++ ++/* reg_mddq_fw_major ++ * Major FW version number. ++ * Access: RO ++ */ ++MLXSW_ITEM32(reg, mddq, fw_major, 0x14, 16, 16); ++ ++/* reg_mddq_fw_minor ++ * Minor FW version number. ++ * Access: RO ++ */ ++MLXSW_ITEM32(reg, mddq, fw_minor, 0x18, 16, 16); ++ ++/* reg_mddq_fw_sub_minor ++ * Sub-minor FW version number. ++ * Access: RO ++ */ ++MLXSW_ITEM32(reg, mddq, fw_sub_minor, 0x18, 0, 16); ++ ++static inline void ++mlxsw_reg_mddq_device_info_pack(char *payload, u8 slot_index, ++ u8 request_msg_seq) ++{ ++ __mlxsw_reg_mddq_pack(payload, slot_index, ++ MLXSW_REG_MDDQ_QUERY_TYPE_DEVICE_INFO); ++ mlxsw_reg_mddq_request_msg_seq_set(payload, request_msg_seq); ++} ++ ++static inline void ++mlxsw_reg_mddq_device_info_unpack(const char *payload, u8 *p_response_msg_seq, ++ bool *p_data_valid, bool *p_flash_owner, ++ u8 *p_device_index, u16 *p_fw_major, ++ u16 *p_fw_minor, u16 *p_fw_sub_minor) ++{ ++ *p_response_msg_seq = mlxsw_reg_mddq_response_msg_seq_get(payload); ++ *p_data_valid = mlxsw_reg_mddq_data_valid_get(payload); ++ if (p_flash_owner) ++ *p_flash_owner = mlxsw_reg_mddq_flash_owner_get(payload); ++ *p_device_index = mlxsw_reg_mddq_device_index_get(payload); ++ if (p_fw_major) ++ *p_fw_major = mlxsw_reg_mddq_fw_major_get(payload); ++ if (p_fw_minor) ++ *p_fw_minor = mlxsw_reg_mddq_fw_minor_get(payload); ++ if (p_fw_sub_minor) ++ *p_fw_sub_minor = mlxsw_reg_mddq_fw_sub_minor_get(payload); ++} ++ ++#define MLXSW_REG_MDDQ_SLOT_ACII_NAME_LEN 20 ++ ++/* reg_mddq_slot_ascii_name ++ * Slot's ASCII name. ++ * Access: RO ++ */ ++MLXSW_ITEM_BUF(reg, mddq, slot_ascii_name, 0x10, ++ MLXSW_REG_MDDQ_SLOT_ACII_NAME_LEN); ++ ++static inline void ++mlxsw_reg_mddq_slot_name_pack(char *payload, u8 slot_index) ++{ ++ __mlxsw_reg_mddq_pack(payload, slot_index, ++ MLXSW_REG_MDDQ_QUERY_TYPE_SLOT_NAME); ++} ++ ++static inline void ++mlxsw_reg_mddq_slot_name_unpack(const char *payload, char *slot_ascii_name) ++{ ++ mlxsw_reg_mddq_slot_ascii_name_memcpy_from(payload, slot_ascii_name); ++} ++ + /* MFDE - Monitoring FW Debug Register + * ----------------------------------- + */ +@@ -11496,6 +11729,7 @@ static const struct mlxsw_reg_info *mlxsw_reg_infos[] = { + MLXSW_REG(mtptpt), + MLXSW_REG(mfgd), + MLXSW_REG(mgpir), ++ MLXSW_REG(mddq), + MLXSW_REG(mfde), + MLXSW_REG(tngcr), + MLXSW_REG(tnumt), +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0133-mlxsw-reg-Add-Management-DownStream-Device-Control-R.patch b/platform/mellanox/non-upstream-patches/patches/0133-mlxsw-reg-Add-Management-DownStream-Device-Control-R.patch new file mode 100644 index 000000000000..bd3c3680e0d8 --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0133-mlxsw-reg-Add-Management-DownStream-Device-Control-R.patch @@ -0,0 +1,70 @@ +From ab25c37ca20274cbf51ab603aa44f682cf5b51b5 Mon Sep 17 00:00:00 2001 +From: Jiri Pirko +Date: Tue, 19 Jan 2021 12:16:58 +0100 +Subject: [PATCH] mlxsw: reg: Add Management DownStream Device Control Register + +The MDDC register allows control downstream devices and line cards. + +Signed-off-by: Jiri Pirko +--- + drivers/net/ethernet/mellanox/mlxsw/reg.h | 37 +++++++++++++++++++++++ + 1 file changed, 37 insertions(+) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h +index d5301bd6f..9cbdf407f 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h ++++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h +@@ -10530,6 +10530,42 @@ mlxsw_reg_mddq_slot_name_unpack(const char *payload, char *slot_ascii_name) + mlxsw_reg_mddq_slot_ascii_name_memcpy_from(payload, slot_ascii_name); + } + ++/* MDDC - Management DownStream Device Control Register ++ * ---------------------------------------------------- ++ * This register allows control downstream devices and line cards. ++ */ ++#define MLXSW_REG_MDDC_ID 0x9163 ++#define MLXSW_REG_MDDC_LEN 0x30 ++ ++MLXSW_REG_DEFINE(mddc, MLXSW_REG_MDDC_ID, MLXSW_REG_MDDC_LEN); ++ ++/* reg_mddc_slot_index ++ * Slot index. 0 is reserved. ++ * Access: Index ++ */ ++MLXSW_ITEM32(reg, mddc, slot_index, 0x00, 0, 4); ++ ++/* reg_mddc_rst ++ * Reset request. ++ * Access: RW ++ */ ++MLXSW_ITEM32(reg, mddc, rst, 0x04, 29, 1); ++ ++/* reg_mddc_device_enable ++ * When set, FW is the manager and allowed to program the Downstream Device. ++ * Access: RW ++ */ ++MLXSW_ITEM32(reg, mddc, device_enable, 0x04, 28, 1); ++ ++static inline void mlxsw_reg_mddc_pack(char *payload, u8 slot_index, bool rst, ++ bool device_enable) ++{ ++ MLXSW_REG_ZERO(mddc, payload); ++ mlxsw_reg_mddc_slot_index_set(payload, slot_index); ++ mlxsw_reg_mddc_rst_set(payload, rst); ++ mlxsw_reg_mddc_device_enable_set(payload, device_enable); ++} ++ + /* MFDE - Monitoring FW Debug Register + * ----------------------------------- + */ +@@ -11730,6 +11766,7 @@ static const struct mlxsw_reg_info *mlxsw_reg_infos[] = { + MLXSW_REG(mfgd), + MLXSW_REG(mgpir), + MLXSW_REG(mddq), ++ MLXSW_REG(mddc), + MLXSW_REG(mfde), + MLXSW_REG(tngcr), + MLXSW_REG(tnumt), +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0134-mlxsw-reg-Add-Management-Binary-Code-Transfer-Regist.patch b/platform/mellanox/non-upstream-patches/patches/0134-mlxsw-reg-Add-Management-Binary-Code-Transfer-Regist.patch new file mode 100644 index 000000000000..b8569f2ac2c7 --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0134-mlxsw-reg-Add-Management-Binary-Code-Transfer-Regist.patch @@ -0,0 +1,154 @@ +From 618665ccbf600c2838fb2e181246aef0fa90bac2 Mon Sep 17 00:00:00 2001 +From: Jiri Pirko +Date: Thu, 10 Dec 2020 18:27:38 +0100 +Subject: [PATCH] mlxsw: reg: Add Management Binary Code Transfer Register + +The MBCT register allows to transfer binary codes from the Host to +the management FW by transferring it by chunks of maximum 1KB. + +Signed-off-by: Jiri Pirko +--- + drivers/net/ethernet/mellanox/mlxsw/reg.h | 120 ++++++++++++++++++++++ + 1 file changed, 120 insertions(+) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h +index 9cbdf407f..89b21910f 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h ++++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h +@@ -10297,6 +10297,125 @@ mlxsw_reg_mgpir_unpack(char *payload, u8 *num_of_devices, + *num_of_slots = mlxsw_reg_mgpir_num_of_slots_get(payload); + } + ++/* MBCT - Management Binary Code Transfer Register ++ * ----------------------------------------------- ++ * This register allows to transfer binary codes from the Host to ++ * the management FW by transferring it by chunks of maximum 1KB. ++ */ ++#define MLXSW_REG_MBCT_ID 0x9120 ++#define MLXSW_REG_MBCT_LEN 0x420 ++ ++MLXSW_REG_DEFINE(mbct, MLXSW_REG_MBCT_ID, MLXSW_REG_MBCT_LEN); ++ ++/* reg_mbct_slot_index ++ * Slot index. 0 is reserved. ++ * Access: Index ++ */ ++MLXSW_ITEM32(reg, mbct, slot_index, 0x00, 0, 4); ++ ++/* reg_mbct_data_size ++ * Actual data field size in bytes for the current data transfer. ++ * Access: WO ++ */ ++MLXSW_ITEM32(reg, mbct, data_size, 0x04, 0, 11); ++ ++enum mlxsw_reg_mbct_op { ++ MLXSW_REG_MBCT_OP_ERASE_INI_IMAGE = 1, ++ MLXSW_REG_MBCT_OP_DATA_TRANSFER, /* Download */ ++ MLXSW_REG_MBCT_OP_ACTIVATE, ++ MLXSW_REG_MBCT_OP_CLEAR_ERRORS = 6, ++ MLXSW_REG_MBCT_OP_QUERY_STATUS, ++}; ++ ++/* reg_mbct_op ++ * Access: OP ++ */ ++MLXSW_ITEM32(reg, mbct, op, 0x08, 28, 4); ++ ++/* reg_mbct_last ++ * Indicates that the current data field is the last chunk of the INI. ++ * Access: WO ++ */ ++MLXSW_ITEM32(reg, mbct, last, 0x08, 26, 1); ++ ++/* reg_mbct_oee ++ * Opcode Event Enable. When set an event will be sent once the opcode ++ * was executed and the fsm_state has changed. ++ * Access: WO ++ */ ++MLXSW_ITEM32(reg, mbct, oee, 0x08, 25, 1); ++ ++enum mlxsw_reg_mbct_status { ++ /* Partial data transfer completed successfully and ready for next ++ * data transfer. ++ */ ++ MLXSW_REG_MBCT_STATUS_PART_DATA = 2, ++ MLXSW_REG_MBCT_STATUS_LAST_DATA, ++ MLXSW_REG_MBCT_STATUS_ERASE_COMPLETE, ++ /* Error - trying to erase INI while it being used. */ ++ MLXSW_REG_MBCT_STATUS_ERROR_INI_IN_USE, ++ /* Last data transfer completed, applying magic pattern. */ ++ MLXSW_REG_MBCT_STATUS_ERASE_FAILED = 7, ++ MLXSW_REG_MBCT_STATUS_INI_ERROR, ++ MLXSW_REG_MBCT_STATUS_ACTIVATION_FAILED, ++ MLXSW_REG_MBCT_STATUS_ILLEGAL_OPERATION = 11, ++}; ++ ++/* reg_mbct_status ++ * Status. ++ * Access: RO ++ */ ++MLXSW_ITEM32(reg, mbct, status, 0x0C, 24, 5); ++ ++enum mlxsw_reg_mbct_fsm_state { ++ MLXSW_REG_MBCT_FSM_STATE_INI_IN_USE = 5, ++ MLXSW_REG_MBCT_FSM_STATE_ERROR = 6, ++}; ++ ++/* reg_mbct_fsm_state ++ * FSM state. ++ * Access: RO ++ */ ++MLXSW_ITEM32(reg, mbct, fsm_state, 0x0C, 16, 4); ++ ++#define MLXSW_REG_MBCT_DATA_LEN 1024 ++ ++/* reg_mbct_data ++ * Up to 1KB of data. ++ * Access: WO ++ */ ++MLXSW_ITEM_BUF(reg, mbct, data, 0x20, MLXSW_REG_MBCT_DATA_LEN); ++ ++static inline void mlxsw_reg_mbct_pack(char *payload, u8 slot_index, ++ enum mlxsw_reg_mbct_op op, ++ u16 data_size, bool last, bool oee, ++ const char *data) ++{ ++ MLXSW_REG_ZERO(mbct, payload); ++ mlxsw_reg_mbct_slot_index_set(payload, slot_index); ++ mlxsw_reg_mbct_op_set(payload, op); ++ mlxsw_reg_mbct_oee_set(payload, oee); ++ if (op == MLXSW_REG_MBCT_OP_DATA_TRANSFER) { ++ if (WARN_ON(data_size > MLXSW_REG_MBCT_DATA_LEN)) ++ return; ++ mlxsw_reg_mbct_data_size_set(payload, data_size); ++ mlxsw_reg_mbct_last_set(payload, last); ++ mlxsw_reg_mbct_data_memcpy_to(payload, data); ++ } ++} ++ ++static inline void ++mlxsw_reg_mbct_unpack(const char *payload, u8 *p_slot_index, ++ enum mlxsw_reg_mbct_status *p_status, ++ enum mlxsw_reg_mbct_fsm_state *p_fsm_state) ++{ ++ if (p_slot_index) ++ *p_slot_index = mlxsw_reg_mbct_slot_index_get(payload); ++ *p_status = mlxsw_reg_mbct_status_get(payload); ++ if (p_fsm_state) ++ *p_fsm_state = mlxsw_reg_mbct_fsm_state_get(payload); ++} ++ + /* MDDQ - Management DownStream Device Query Register + * -------------------------------------------------- + * This register allows to query the DownStream device properties. The desired +@@ -11765,6 +11884,7 @@ static const struct mlxsw_reg_info *mlxsw_reg_infos[] = { + MLXSW_REG(mtptpt), + MLXSW_REG(mfgd), + MLXSW_REG(mgpir), ++ MLXSW_REG(mbct), + MLXSW_REG(mddq), + MLXSW_REG(mddc), + MLXSW_REG(mfde), +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0135-mlxsw-core_linecards-Add-line-card-objects-and-imple.patch b/platform/mellanox/non-upstream-patches/patches/0135-mlxsw-core_linecards-Add-line-card-objects-and-imple.patch new file mode 100644 index 000000000000..79a82fec6981 --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0135-mlxsw-core_linecards-Add-line-card-objects-and-imple.patch @@ -0,0 +1,1062 @@ +From 3c23c52a44d6f87f7caaf09babb6196e523d1e7c Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Wed, 22 Dec 2021 16:06:54 +0000 +Subject: [PATCH] mlxsw: core_linecards: Add line card objects and implement + provisioning + +Introduce objects for line cards and an infrastructure around that. +Use devlink_linecard_create/destroy() to register the line card with +devlink core. Implement provisioning ops with a list of supported +line cards. + +Signed-off-by: Jiri Pirko +--- + drivers/net/ethernet/mellanox/mlxsw/Makefile | 3 +- + drivers/net/ethernet/mellanox/mlxsw/core.c | 22 + + drivers/net/ethernet/mellanox/mlxsw/core.h | 46 ++ + .../ethernet/mellanox/mlxsw/core_linecards.c | 775 ++++++++++++++++++ + .../net/ethernet/mellanox/mlxsw/spectrum.c | 68 ++ + drivers/net/ethernet/mellanox/mlxsw/trap.h | 6 + + 6 files changed, 919 insertions(+), 1 deletion(-) + create mode 100644 drivers/net/ethernet/mellanox/mlxsw/core_linecards.c + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/Makefile b/drivers/net/ethernet/mellanox/mlxsw/Makefile +index 892724380..ca7260a14 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/Makefile ++++ b/drivers/net/ethernet/mellanox/mlxsw/Makefile +@@ -1,7 +1,8 @@ + # SPDX-License-Identifier: GPL-2.0 + obj-$(CONFIG_MLXSW_CORE) += mlxsw_core.o + mlxsw_core-objs := core.o core_acl_flex_keys.o \ +- core_acl_flex_actions.o core_env.o ++ core_acl_flex_actions.o core_env.o \ ++ core_linecards.o + mlxsw_core-$(CONFIG_MLXSW_CORE_HWMON) += core_hwmon.o + mlxsw_core-$(CONFIG_MLXSW_CORE_THERMAL) += core_thermal.o + obj-$(CONFIG_MLXSW_PCI) += mlxsw_pci.o +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c +index 0b1888318..246db548f 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core.c +@@ -82,6 +82,7 @@ struct mlxsw_core { + struct mlxsw_res res; + struct mlxsw_hwmon *hwmon; + struct mlxsw_thermal *thermal; ++ struct mlxsw_linecards *linecards; + struct mlxsw_core_port *ports; + unsigned int max_ports; + bool fw_flash_in_progress; +@@ -93,6 +94,11 @@ struct mlxsw_core { + /* driver_priv has to be always the last item */ + }; + ++struct mlxsw_linecards *mlxsw_core_linecards(struct mlxsw_core *mlxsw_core) ++{ ++ return mlxsw_core->linecards; ++} ++ + #define MLXSW_PORT_MAX_PORTS_DEFAULT 0x40 + + static int mlxsw_ports_init(struct mlxsw_core *mlxsw_core) +@@ -1918,6 +1924,11 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info, + if (err) + goto err_emad_init; + ++ err = mlxsw_linecards_init(mlxsw_core, mlxsw_bus_info, ++ &mlxsw_core->linecards); ++ if (err) ++ goto err_linecards_init; ++ + if (!reload) { + err = devlink_register(devlink, mlxsw_bus_info->dev); + if (err) +@@ -1963,8 +1974,15 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info, + if (!reload) + devlink_reload_enable(devlink); + ++ err = mlxsw_linecards_post_init(mlxsw_core, mlxsw_core->linecards); ++ if (err) ++ goto err_linecards_post_init; ++ + return 0; + ++err_linecards_post_init: ++ if (mlxsw_core->driver->fini) ++ mlxsw_core->driver->fini(mlxsw_core); + err_driver_init: + mlxsw_env_fini(mlxsw_core->env); + err_env_init: +@@ -1981,6 +1999,8 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info, + if (!reload) + devlink_unregister(devlink); + err_devlink_register: ++ mlxsw_linecards_fini(mlxsw_core, mlxsw_core->linecards); ++err_linecards_init: + mlxsw_emad_fini(mlxsw_core); + err_emad_init: + kfree(mlxsw_core->lag.mapping); +@@ -2042,6 +2062,7 @@ void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core, + } + + devlink_params_unpublish(devlink); ++ mlxsw_linecards_pre_fini(mlxsw_core, mlxsw_core->linecards); + if (mlxsw_core->driver->fini) + mlxsw_core->driver->fini(mlxsw_core); + mlxsw_env_fini(mlxsw_core->env); +@@ -2052,6 +2073,7 @@ void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core, + mlxsw_core_params_unregister(mlxsw_core); + if (!reload) + devlink_unregister(devlink); ++ mlxsw_linecards_fini(mlxsw_core, mlxsw_core->linecards); + mlxsw_emad_fini(mlxsw_core); + kfree(mlxsw_core->lag.mapping); + mlxsw_ports_fini(mlxsw_core); +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.h b/drivers/net/ethernet/mellanox/mlxsw/core.h +index 0ceb7dae9..d3c5d8289 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core.h ++++ b/drivers/net/ethernet/mellanox/mlxsw/core.h +@@ -30,6 +30,8 @@ unsigned int mlxsw_core_max_ports(const struct mlxsw_core *mlxsw_core); + + void *mlxsw_core_driver_priv(struct mlxsw_core *mlxsw_core); + ++struct mlxsw_linecards *mlxsw_core_linecards(struct mlxsw_core *mlxsw_core); ++ + bool mlxsw_core_temp_warn_enabled(const struct mlxsw_core *mlxsw_core); + + bool +@@ -509,4 +511,48 @@ static inline struct mlxsw_skb_cb *mlxsw_skb_cb(struct sk_buff *skb) + return (struct mlxsw_skb_cb *) skb->cb; + } + ++struct mlxsw_linecards; ++ ++struct mlxsw_linecard { ++ u8 slot_index; ++ struct mlxsw_linecards *linecards; ++ struct devlink_linecard *devlink_linecard; ++ struct mutex lock; /* Locks accesses to the linecard structure */ ++ char read_name[MLXSW_REG_MDDQ_SLOT_ACII_NAME_LEN]; ++ char mbct_pl[MLXSW_REG_MBCT_LEN]; /* too big for stack */ ++ bool provisioned; ++}; ++ ++struct mlxsw_linecard_types_info; ++ ++struct mlxsw_linecards { ++ struct list_head event_ops_list; ++ struct workqueue_struct *wq; ++ struct mlxsw_core *mlxsw_core; ++ const struct mlxsw_bus_info *bus_info; ++ u8 count; ++ struct mlxsw_linecard_types_info *types_info; ++ struct mlxsw_linecard linecards[0]; ++}; ++ ++static inline struct mlxsw_linecard * ++mlxsw_linecard_get(struct mlxsw_linecards *linecards, u8 slot_index) ++{ ++ return &linecards->linecards[slot_index - 1]; ++} ++ ++int mlxsw_linecards_init(struct mlxsw_core *mlxsw_core, ++ const struct mlxsw_bus_info *bus_info, ++ struct mlxsw_linecards **p_linecards); ++int mlxsw_linecards_post_init(struct mlxsw_core *mlxsw_core, ++ struct mlxsw_linecards *linecards); ++void mlxsw_linecards_pre_fini(struct mlxsw_core *mlxsw_core, ++ struct mlxsw_linecards *linecards); ++void mlxsw_linecards_fini(struct mlxsw_core *mlxsw_core, ++ struct mlxsw_linecards *linecards); ++int mlxsw_linecard_status_process(struct mlxsw_core *mlxsw_core, ++ const char *mddq_pl); ++int mlxsw_linecard_bct_process(struct mlxsw_core *mlxsw_core, ++ const char *mbct_pl); ++ + #endif +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c b/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c +new file mode 100644 +index 000000000..a324ce243 +--- /dev/null ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c +@@ -0,0 +1,775 @@ ++// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 ++/* Copyright (c) 2021 NVIDIA Corporation and Mellanox Technologies. All rights reserved */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "core.h" ++#include "../mlxfw/mlxfw.h" ++ ++struct mlxsw_linecard_ini_file { ++ __le16 size; ++ union { ++ u8 data[0]; ++ struct { ++ u8 __dontcare[7]; ++ u8 type; ++ u8 name[20]; ++ } format; ++ }; ++}; ++ ++struct mlxsw_linecard_types_info { ++ struct mlxsw_linecard_ini_file **ini_files; ++ unsigned int count; ++ size_t data_size; ++ char *data; ++}; ++ ++static const char * ++mlxsw_linecard_types_lookup(struct mlxsw_linecards *linecards, ++ enum mlxsw_reg_mddq_card_type card_type) ++{ ++ struct mlxsw_linecard_types_info *types_info; ++ struct mlxsw_linecard_ini_file *ini_file; ++ int i; ++ ++ types_info = linecards->types_info; ++ for (i = 0; i < types_info->count; i++) { ++ ini_file = linecards->types_info->ini_files[i]; ++ if (ini_file->format.type == card_type) ++ return ini_file->format.name; ++ } ++ return NULL; ++} ++ ++static const char *mlxsw_linecard_type_name(struct mlxsw_linecard *linecard) ++{ ++ struct mlxsw_core *mlxsw_core = linecard->linecards->mlxsw_core; ++ char mddq_pl[MLXSW_REG_MDDQ_LEN]; ++ int err; ++ ++ mlxsw_reg_mddq_slot_name_pack(mddq_pl, linecard->slot_index); ++ err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mddq), mddq_pl); ++ if (err) ++ return NULL; ++ mlxsw_reg_mddq_slot_name_unpack(mddq_pl, linecard->read_name); ++ return linecard->read_name; ++} ++ ++static void mlxsw_linecard_provision_fail(struct mlxsw_linecard *linecard) ++{ ++ linecard->provisioned = false; ++ devlink_linecard_provision_fail(linecard->devlink_linecard); ++} ++ ++static int ++mlxsw_linecard_provision_set(struct mlxsw_linecards *linecards, ++ struct mlxsw_linecard *linecard, ++ enum mlxsw_reg_mddq_card_type card_type) ++{ ++ const char *type = mlxsw_linecard_types_lookup(linecards, card_type); ++ ++ if (!type) ++ type = mlxsw_linecard_type_name(linecard); ++ if (!type) { ++ mlxsw_linecard_provision_fail(linecard); ++ return -EINVAL; ++ } ++ linecard->provisioned = true; ++ devlink_linecard_provision_set(linecard->devlink_linecard, type); ++ return 0; ++} ++ ++static void mlxsw_linecard_provision_clear(struct mlxsw_linecard *linecard) ++{ ++ linecard->provisioned = false; ++ devlink_linecard_provision_clear(linecard->devlink_linecard); ++} ++ ++static int __mlxsw_linecard_status_process(struct mlxsw_core *mlxsw_core, ++ struct mlxsw_linecards *linecards, ++ struct mlxsw_linecard *linecard, ++ const char *mddq_pl) ++{ ++ enum mlxsw_reg_mddq_card_type card_type; ++ enum mlxsw_reg_mddq_ready ready; ++ bool provisioned; ++ u16 ini_version; ++ u16 hw_revision; ++ bool sr_valid; ++ u8 slot_index; ++ int err = 0; ++ bool active; ++ ++ mlxsw_reg_mddq_slot_info_unpack(mddq_pl, &slot_index, &provisioned, ++ &sr_valid, &ready, &active, ++ &hw_revision, &ini_version, ++ &card_type); ++ ++ if (linecard) { ++ if (slot_index != linecard->slot_index) ++ return -EINVAL; ++ } else { ++ if (slot_index > linecards->count) ++ return -EINVAL; ++ linecard = mlxsw_linecard_get(linecards, slot_index); ++ } ++ ++ mutex_lock(&linecard->lock); ++ ++ if (provisioned && linecard->provisioned != provisioned) { ++ err = mlxsw_linecard_provision_set(linecards, linecard, ++ card_type); ++ if (err) ++ goto out; ++ } ++ ++ if (!provisioned && linecard->provisioned != provisioned) ++ mlxsw_linecard_provision_clear(linecard); ++ ++out: ++ mutex_unlock(&linecard->lock); ++ return err; ++} ++ ++int mlxsw_linecard_status_process(struct mlxsw_core *mlxsw_core, ++ const char *mddq_pl) ++{ ++ struct mlxsw_linecards *linecards = mlxsw_core_linecards(mlxsw_core); ++ ++ return __mlxsw_linecard_status_process(mlxsw_core, linecards, NULL, ++ mddq_pl); ++} ++EXPORT_SYMBOL(mlxsw_linecard_status_process); ++ ++static int mlxsw_linecard_status_get_and_process(struct mlxsw_core *mlxsw_core, ++ struct mlxsw_linecards *linecards, ++ struct mlxsw_linecard *linecard) ++{ ++ char mddq_pl[MLXSW_REG_MDDQ_LEN]; ++ int err; ++ ++ mlxsw_reg_mddq_slot_info_pack(mddq_pl, linecard->slot_index, false); ++ err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mddq), mddq_pl); ++ if (err) ++ return err; ++ ++ return __mlxsw_linecard_status_process(mlxsw_core, linecards, linecard, ++ mddq_pl); ++} ++ ++static int __mlxsw_linecard_fix_fsm_state(struct mlxsw_linecard *linecard) ++{ ++ dev_info(linecard->linecards->bus_info->dev, "linecard %u: Clearing FSM state error", ++ linecard->slot_index); ++ mlxsw_reg_mbct_pack(linecard->mbct_pl, linecard->slot_index, ++ MLXSW_REG_MBCT_OP_CLEAR_ERRORS, 0, ++ false, false, NULL); ++ return mlxsw_reg_write(linecard->linecards->mlxsw_core, ++ MLXSW_REG(mbct), linecard->mbct_pl); ++} ++ ++static int mlxsw_linecard_fix_fsm_state(struct mlxsw_linecard *linecard, ++ enum mlxsw_reg_mbct_fsm_state fsm_state) ++{ ++ if (fsm_state != MLXSW_REG_MBCT_FSM_STATE_ERROR) ++ return 0; ++ return __mlxsw_linecard_fix_fsm_state(linecard); ++} ++ ++static int mlxsw_linecard_query_status(struct mlxsw_linecard *linecard, ++ enum mlxsw_reg_mbct_status *status, ++ enum mlxsw_reg_mbct_fsm_state *fsm_state, ++ struct netlink_ext_ack *extack) ++{ ++ bool second_try = false; ++ int err; ++ ++another_try: ++ mlxsw_reg_mbct_pack(linecard->mbct_pl, linecard->slot_index, ++ MLXSW_REG_MBCT_OP_QUERY_STATUS, 0, ++ false, false, NULL); ++ err = mlxsw_reg_query(linecard->linecards->mlxsw_core, MLXSW_REG(mbct), ++ linecard->mbct_pl); ++ if (err) { ++ NL_SET_ERR_MSG_MOD(extack, "Failed to query linecard INI status"); ++ return err; ++ } ++ mlxsw_reg_mbct_unpack(linecard->mbct_pl, NULL, status, fsm_state); ++ if (!second_try && ++ (*status == MLXSW_REG_MBCT_STATUS_ILLEGAL_OPERATION || ++ *fsm_state == MLXSW_REG_MBCT_FSM_STATE_ERROR)) { ++ err = __mlxsw_linecard_fix_fsm_state(linecard); ++ if (!err) { ++ second_try = true; ++ goto another_try; ++ } ++ } ++ return err; ++} ++ ++static int ++mlxsw_linecard_provision_data(struct mlxsw_core *mlxsw_core, ++ struct mlxsw_linecards *linecards, ++ struct mlxsw_linecard *linecard, ++ const struct mlxsw_linecard_ini_file *ini_file, ++ struct netlink_ext_ack *extack) ++{ ++ enum mlxsw_reg_mbct_fsm_state fsm_state; ++ enum mlxsw_reg_mbct_status status; ++ size_t size_left; ++ const u8 *data; ++ int err; ++ ++ size_left = le16_to_cpu(ini_file->size); ++ data = ini_file->data; ++ while (size_left) { ++ size_t data_size = MLXSW_REG_MBCT_DATA_LEN; ++ bool is_last = false; ++ ++ if (size_left <= MLXSW_REG_MBCT_DATA_LEN) { ++ data_size = size_left; ++ is_last = true; ++ } ++ ++ mlxsw_reg_mbct_pack(linecard->mbct_pl, linecard->slot_index, ++ MLXSW_REG_MBCT_OP_DATA_TRANSFER, data_size, ++ is_last, false, data); ++ err = mlxsw_reg_write(mlxsw_core, MLXSW_REG(mbct), ++ linecard->mbct_pl); ++ if (err) { ++ NL_SET_ERR_MSG_MOD(extack, "Failed to transfer linecard INI data"); ++ return err; ++ } ++ mlxsw_reg_mbct_unpack(linecard->mbct_pl, NULL, ++ &status, &fsm_state); ++ if ((!is_last && status != MLXSW_REG_MBCT_STATUS_PART_DATA) || ++ (is_last && status != MLXSW_REG_MBCT_STATUS_LAST_DATA)) { ++ NL_SET_ERR_MSG_MOD(extack, "Failed to transfer linecard INI data"); ++ mlxsw_linecard_fix_fsm_state(linecard, fsm_state); ++ return -EINVAL; ++ } ++ size_left -= data_size; ++ data += data_size; ++ } ++ ++ return 0; ++} ++ ++int mlxsw_linecard_bct_process(struct mlxsw_core *mlxsw_core, ++ const char *mbct_pl) ++{ ++ struct mlxsw_linecards *linecards = mlxsw_core_linecards(mlxsw_core); ++ enum mlxsw_reg_mbct_fsm_state fsm_state; ++ enum mlxsw_reg_mbct_status status; ++ struct mlxsw_linecard *linecard; ++ u8 slot_index; ++ int err; ++ ++ mlxsw_reg_mbct_unpack(mbct_pl, &slot_index, &status, &fsm_state); ++ if (slot_index > linecards->count) ++ return -EINVAL; ++ linecard = mlxsw_linecard_get(linecards, slot_index); ++ if (status == MLXSW_REG_MBCT_STATUS_ACTIVATION_FAILED) { ++ dev_err(linecards->bus_info->dev, "linecard %u: Failed to activate INI", ++ linecard->slot_index); ++ err = -EINVAL; ++ goto fix_fsm_err_out; ++ } ++ return 0; ++ ++fix_fsm_err_out: ++ mlxsw_linecard_fix_fsm_state(linecard, fsm_state); ++ mlxsw_linecard_provision_fail(linecard); ++ return err; ++} ++EXPORT_SYMBOL(mlxsw_linecard_bct_process); ++ ++static int mlxsw_linecard_provision(struct devlink_linecard *devlink_linecard, ++ void *priv, const char *type, ++ const void *type_priv, ++ struct netlink_ext_ack *extack) ++{ ++ const struct mlxsw_linecard_ini_file *ini_file = type_priv; ++ enum mlxsw_reg_mbct_fsm_state fsm_state; ++ struct mlxsw_linecard *linecard = priv; ++ struct mlxsw_linecards *linecards; ++ enum mlxsw_reg_mbct_status status; ++ struct mlxsw_core *mlxsw_core; ++ int err; ++ ++ mutex_lock(&linecard->lock); ++ ++ linecards = linecard->linecards; ++ mlxsw_core = linecards->mlxsw_core; ++ mlxsw_reg_mbct_pack(linecard->mbct_pl, linecard->slot_index, ++ MLXSW_REG_MBCT_OP_ERASE_INI_IMAGE, 0, ++ false, false, NULL); ++ err = mlxsw_reg_write(mlxsw_core, MLXSW_REG(mbct), linecard->mbct_pl); ++ if (err) { ++ NL_SET_ERR_MSG_MOD(extack, "Failed to erase linecard INI"); ++ goto err_out; ++ } ++ mlxsw_reg_mbct_unpack(linecard->mbct_pl, NULL, &status, &fsm_state); ++ if (status == MLXSW_REG_MBCT_STATUS_ERASE_FAILED) { ++ NL_SET_ERR_MSG_MOD(extack, "Failed to erase linecard INI"); ++ err = -EINVAL; ++ goto fix_fsm_err_out; ++ } ++ ++ err = mlxsw_linecard_provision_data(mlxsw_core, linecards, ++ linecard, ini_file, extack); ++ if (err) ++ goto err_out; ++ ++ mlxsw_reg_mbct_pack(linecard->mbct_pl, linecard->slot_index, ++ MLXSW_REG_MBCT_OP_ACTIVATE, 0, ++ false, true, NULL); ++ err = mlxsw_reg_write(mlxsw_core, MLXSW_REG(mbct), linecard->mbct_pl); ++ if (err) { ++ NL_SET_ERR_MSG_MOD(extack, "Failed to activate linecard INI"); ++ goto err_out; ++ } ++ mlxsw_reg_mbct_unpack(linecard->mbct_pl, NULL, &status, &fsm_state); ++ if (status == MLXSW_REG_MBCT_STATUS_ACTIVATION_FAILED) { ++ NL_SET_ERR_MSG_MOD(extack, "Failed to activate linecard INI"); ++ goto fix_fsm_err_out; ++ } ++ ++ goto out; ++ ++fix_fsm_err_out: ++ mlxsw_linecard_fix_fsm_state(linecard, fsm_state); ++err_out: ++ mlxsw_linecard_provision_fail(linecard); ++out: ++ mutex_unlock(&linecard->lock); ++ return err; ++} ++ ++#define MLXSW_LINECARD_INI_WAIT_RETRIES 10 ++#define MLXSW_LINECARD_INI_WAIT_MS 500 ++ ++static int mlxsw_linecard_unprovision(struct devlink_linecard *devlink_linecard, ++ void *priv, ++ struct netlink_ext_ack *extack) ++{ ++ enum mlxsw_reg_mbct_fsm_state fsm_state; ++ struct mlxsw_linecard *linecard = priv; ++ struct mlxsw_linecards *linecards; ++ enum mlxsw_reg_mbct_status status; ++ unsigned int ini_wait_retries = 0; ++ struct mlxsw_core *mlxsw_core; ++ int err; ++ ++ mutex_lock(&linecard->lock); ++ ++ linecards = linecard->linecards; ++ mlxsw_core = linecard->linecards->mlxsw_core; ++ ++query_ini_status: ++ err = mlxsw_linecard_query_status(linecard, &status, ++ &fsm_state, extack); ++ if (err) ++ goto err_out; ++ ++ switch (fsm_state) { ++ case MLXSW_REG_MBCT_FSM_STATE_INI_IN_USE: ++ if (ini_wait_retries++ > MLXSW_LINECARD_INI_WAIT_RETRIES) { ++ NL_SET_ERR_MSG_MOD(extack, "Failed to wait for linecard INI to be not used"); ++ goto err_out; ++ } ++ mdelay(MLXSW_LINECARD_INI_WAIT_MS); ++ goto query_ini_status; ++ default: ++ break; ++ } ++ ++ mlxsw_reg_mbct_pack(linecard->mbct_pl, linecard->slot_index, ++ MLXSW_REG_MBCT_OP_ERASE_INI_IMAGE, 0, ++ false, false, NULL); ++ err = mlxsw_reg_write(mlxsw_core, MLXSW_REG(mbct), ++ linecard->mbct_pl); ++ if (err) { ++ NL_SET_ERR_MSG_MOD(extack, "Failed to erase linecard INI"); ++ goto err_out; ++ } ++ mlxsw_reg_mbct_unpack(linecard->mbct_pl, NULL, &status, &fsm_state); ++ switch (status) { ++ case MLXSW_REG_MBCT_STATUS_ERASE_COMPLETE: ++ break; ++ default: ++ /* Should not happen */ ++ fallthrough; ++ case MLXSW_REG_MBCT_STATUS_ERASE_FAILED: ++ NL_SET_ERR_MSG_MOD(extack, "Failed to erase linecard INI"); ++ goto fix_fsm_err_out; ++ case MLXSW_REG_MBCT_STATUS_ERROR_INI_IN_USE: ++ NL_SET_ERR_MSG_MOD(extack, "Failed to erase linecard INI while being used"); ++ goto fix_fsm_err_out; ++ } ++ goto out; ++ ++fix_fsm_err_out: ++ mlxsw_linecard_fix_fsm_state(linecard, fsm_state); ++err_out: ++ mlxsw_linecard_provision_fail(linecard); ++out: ++ mutex_unlock(&linecard->lock); ++ return err; ++} ++ ++static unsigned int ++mlxsw_linecard_types_count(struct devlink_linecard *devlink_linecard, ++ void *priv) ++{ ++ struct mlxsw_linecard *linecard = priv; ++ ++ return linecard->linecards->types_info->count; ++} ++ ++static void mlxsw_linecard_types_get(struct devlink_linecard *devlink_linecard, ++ void *priv, unsigned int index, ++ const char **type, const void **type_priv) ++{ ++ struct mlxsw_linecard_types_info *types_info; ++ struct mlxsw_linecard_ini_file *ini_file; ++ struct mlxsw_linecard *linecard = priv; ++ ++ types_info = linecard->linecards->types_info; ++ ini_file = types_info->ini_files[index]; ++ *type = ini_file->format.name; ++ *type_priv = ini_file; ++} ++ ++static const struct devlink_linecard_ops mlxsw_linecard_ops = { ++ .provision = mlxsw_linecard_provision, ++ .unprovision = mlxsw_linecard_unprovision, ++ .types_count = mlxsw_linecard_types_count, ++ .types_get = mlxsw_linecard_types_get, ++}; ++ ++static int mlxsw_linecard_init(struct mlxsw_core *mlxsw_core, ++ struct mlxsw_linecards *linecards, ++ u8 slot_index) ++{ ++ struct devlink_linecard *devlink_linecard; ++ struct mlxsw_linecard *linecard; ++ int err; ++ ++ linecard = mlxsw_linecard_get(linecards, slot_index); ++ linecard->slot_index = slot_index; ++ linecard->linecards = linecards; ++ mutex_init(&linecard->lock); ++ ++ devlink_linecard = devlink_linecard_create(priv_to_devlink(mlxsw_core), ++ slot_index, &mlxsw_linecard_ops, ++ linecard); ++ if (IS_ERR(devlink_linecard)) ++ return PTR_ERR(devlink_linecard); ++ linecard->devlink_linecard = devlink_linecard; ++ ++ err = mlxsw_linecard_status_get_and_process(mlxsw_core, linecards, ++ linecard); ++ if (err) ++ goto err_status_get_and_process; ++ ++ return 0; ++ ++err_status_get_and_process: ++ devlink_linecard_destroy(linecard->devlink_linecard); ++ return err; ++} ++ ++static int mlxsw_linecard_event_delivery_set(struct mlxsw_core *mlxsw_core, ++ struct mlxsw_linecard *linecard, ++ bool enable) ++{ ++ char mddq_pl[MLXSW_REG_MDDQ_LEN]; ++ ++ mlxsw_reg_mddq_slot_info_pack(mddq_pl, linecard->slot_index, enable); ++ return mlxsw_reg_write(mlxsw_core, MLXSW_REG(mddq), mddq_pl); ++} ++ ++static int mlxsw_linecard_post_init(struct mlxsw_core *mlxsw_core, ++ struct mlxsw_linecards *linecards, ++ u8 slot_index) ++{ ++ struct mlxsw_linecard *linecard; ++ int err; ++ ++ linecard = mlxsw_linecard_get(linecards, slot_index); ++ linecard->slot_index = slot_index; ++ ++ err = mlxsw_linecard_event_delivery_set(mlxsw_core, linecard, true); ++ if (err) ++ return err; ++ ++ err = mlxsw_linecard_status_get_and_process(mlxsw_core, linecards, ++ linecard); ++ if (err) ++ goto err_status_get_and_process; ++ ++ return 0; ++ ++err_status_get_and_process: ++ mlxsw_linecard_event_delivery_set(mlxsw_core, linecard, false); ++ return err; ++} ++ ++static void mlxsw_linecard_pre_fini(struct mlxsw_core *mlxsw_core, ++ struct mlxsw_linecards *linecards, ++ u8 slot_index) ++{ ++ struct mlxsw_linecard *linecard; ++ ++ linecard = mlxsw_linecard_get(linecards, slot_index); ++ mlxsw_linecard_event_delivery_set(mlxsw_core, linecard, false); ++} ++ ++static void mlxsw_linecard_fini(struct mlxsw_core *mlxsw_core, ++ struct mlxsw_linecards *linecards, ++ u8 slot_index) ++{ ++ struct mlxsw_linecard *linecard; ++ ++ linecard = mlxsw_linecard_get(linecards, slot_index); ++ devlink_linecard_destroy(linecard->devlink_linecard); ++ mutex_destroy(&linecard->lock); ++} ++ ++#define MLXSW_LINECARDS_INI_BUNDLE_MINOR 2008 ++#define MLXSW_LINECARDS_INI_BUNDLE_MINOR_SUBMINOR 9999 ++#define MLXSW_LINECARDS_INI_BUNDLE_FILE \ ++ "mellanox/lc_ini_bundle_" \ ++ __stringify(MLXSW_LINECARDS_INI_BUNDLE_MINOR) "_" \ ++ __stringify(MLXSW_LINECARDS_INI_BUNDLE_MINOR_SUBMINOR) ".bin" ++#define MLXSW_LINECARDS_INI_BUNDLE_MAGIC "NVLCINI+" ++ ++static int mlxsw_linecard_types_init(struct mlxsw_core *mlxsw_core, ++ struct mlxsw_linecards *linecards) ++{ ++ struct mlxsw_linecard_types_info *types_info; ++ struct mlxsw_linecard_ini_file *ini_file; ++ const struct firmware *firmware; ++ unsigned int count; ++ u16 ini_file_size; ++ size_t magic_size; ++ const u8 *data; ++ size_t size; ++ int err; ++ ++ types_info = kzalloc(sizeof(*types_info), GFP_KERNEL); ++ if (!types_info) ++ return -ENOMEM; ++ linecards->types_info = types_info; ++ return 0; /* Skip for non-upstream flow. */ ++ err = request_firmware_direct(&firmware, ++ MLXSW_LINECARDS_INI_BUNDLE_FILE, ++ linecards->bus_info->dev); ++ if (err) { ++ dev_warn(linecards->bus_info->dev, "Could not request linecards INI file \"" MLXSW_LINECARDS_INI_BUNDLE_FILE "\", provisioning will not be possible\n"); ++ return 0; ++ } ++ ++ types_info->data_size = firmware->size; ++ types_info->data = kmemdup(firmware->data, firmware->size, GFP_KERNEL); ++ release_firmware(firmware); ++ if (!types_info->data) { ++ err = -ENOMEM; ++ goto free_types_info; ++ } ++ ++ data = types_info->data; ++ size = types_info->data_size; ++ magic_size = strlen(MLXSW_LINECARDS_INI_BUNDLE_MAGIC); ++ ++ if (size < magic_size || ++ memcmp(data, MLXSW_LINECARDS_INI_BUNDLE_MAGIC, magic_size)) ++ goto incorrect_inis_file_format; ++ data += magic_size; ++ size -= magic_size; ++ count = 0; ++ ++ while (size > 0) { ++ if (size < sizeof(*ini_file)) ++ goto incorrect_inis_file_format; ++ ini_file = (struct mlxsw_linecard_ini_file *) data; ++ ini_file_size = le16_to_cpu(ini_file->size); ++ if (ini_file_size > size || ini_file_size % 4) ++ goto incorrect_inis_file_format; ++ data += ini_file_size + sizeof(__le16); ++ size -= ini_file_size + sizeof(__le16); ++ count++; ++ } ++ if (size) ++ goto incorrect_inis_file_format; ++ ++ types_info->ini_files = kmalloc_array(count, sizeof(ini_file), ++ GFP_KERNEL); ++ if (!types_info->ini_files) { ++ err = -ENOMEM; ++ goto free_types_info; ++ } ++ ++ data = types_info->data + magic_size; ++ size = types_info->data_size - magic_size; ++ count = 0; ++ ++ while (size) { ++ int i; ++ ++ ini_file = (struct mlxsw_linecard_ini_file *) data; ++ ini_file_size = le16_to_cpu(ini_file->size); ++ for (i = 0; i < ini_file_size / 4; i++) { ++ u32 *val = &((u32 *) ini_file->data)[i]; ++ ++ *val = swab32(*val); ++ } ++ types_info->ini_files[count] = ini_file; ++ data += ini_file_size + sizeof(__le16); ++ size -= ini_file_size + sizeof(__le16); ++ count++; ++ } ++ ++ types_info->count = count; ++ return 0; ++ ++incorrect_inis_file_format: ++ dev_warn(linecards->bus_info->dev, "Incorrect linecards INIs file format, provisioning will not be possible\n"); ++ return 0; ++ ++free_types_info: ++ kfree(types_info); ++ return err; ++} ++ ++static void mlxsw_linecard_types_fini(struct mlxsw_linecards *linecards) ++{ ++ struct mlxsw_linecard_types_info *types_info = linecards->types_info; ++ ++ kfree(types_info->ini_files); ++ kfree(types_info->data); ++ kfree(types_info); ++} ++ ++int mlxsw_linecards_init(struct mlxsw_core *mlxsw_core, ++ const struct mlxsw_bus_info *bus_info, ++ struct mlxsw_linecards **p_linecards) ++{ ++ char mgpir_pl[MLXSW_REG_MGPIR_LEN]; ++ struct mlxsw_linecards *linecards; ++ u8 slot_count; ++ int err; ++ int i; ++ ++ mlxsw_reg_mgpir_pack(mgpir_pl, 0); ++ err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mgpir), mgpir_pl); ++ if (err) ++ return err; ++ ++ mlxsw_reg_mgpir_unpack(mgpir_pl, NULL, NULL, NULL, ++ NULL, &slot_count); ++ if (!slot_count) { ++ *p_linecards = NULL; ++ return 0; ++ } ++ ++ linecards = kzalloc(struct_size(linecards, linecards, slot_count), ++ GFP_KERNEL); ++ if (!linecards) ++ return -ENOMEM; ++ linecards->count = slot_count; ++ linecards->mlxsw_core = mlxsw_core; ++ linecards->bus_info = bus_info; ++ ++ linecards->wq = alloc_workqueue("mlxsw_linecards", 0, 0); ++ if (!linecards->wq) { ++ err = ENOMEM; ++ goto err_wq_alloc; ++ } ++ ++ err = mlxsw_linecard_types_init(mlxsw_core, linecards); ++ if (err) ++ goto err_types_init; ++ ++ for (i = 0; i < linecards->count; i++) { ++ err = mlxsw_linecard_init(mlxsw_core, linecards, i + 1); ++ if (err) ++ goto err_linecard_init; ++ } ++ ++ *p_linecards = linecards; ++ ++ return 0; ++ ++err_linecard_init: ++ for (i--; i >= 0; i--) ++ mlxsw_linecard_fini(mlxsw_core, linecards, i + 1); ++err_types_init: ++ destroy_workqueue(linecards->wq); ++err_wq_alloc: ++ kfree(linecards); ++ ++ return err; ++} ++ ++int mlxsw_linecards_post_init(struct mlxsw_core *mlxsw_core, ++ struct mlxsw_linecards *linecards) ++{ ++ int err; ++ int i; ++ ++ if (!linecards) ++ return 0; ++ ++ for (i = 0; i < linecards->count; i++) { ++ err = mlxsw_linecard_post_init(mlxsw_core, linecards, i + 1); ++ if (err) ++ goto err_linecard_post_init; ++ } ++ return 0; ++ ++err_linecard_post_init: ++ for (i--; i >= 0; i--) ++ mlxsw_linecard_pre_fini(mlxsw_core, linecards, i + 1); ++ ++ return err; ++} ++ ++void mlxsw_linecards_pre_fini(struct mlxsw_core *mlxsw_core, ++ struct mlxsw_linecards *linecards) ++{ ++ int i; ++ ++ if (!linecards) ++ return; ++ for (i = 0; i < linecards->count; i++) ++ mlxsw_linecard_pre_fini(mlxsw_core, linecards, i + 1); ++ /* Make sure all scheduled events are processed */ ++ mlxsw_core_flush_owq(); ++} ++ ++void mlxsw_linecards_fini(struct mlxsw_core *mlxsw_core, ++ struct mlxsw_linecards *linecards) ++{ ++ int i; ++ ++ if (!linecards) ++ return; ++ for (i = 0; i < linecards->count; i++) ++ mlxsw_linecard_fini(mlxsw_core, linecards, i + 1); ++ mlxsw_linecard_types_fini(linecards); ++ destroy_workqueue(linecards->wq); ++ kfree(linecards); ++} ++ ++MODULE_FIRMWARE(MLXSW_LINECARDS_INI_BUNDLE_FILE); +diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +index 5066fcc46..d7a230828 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +@@ -2076,6 +2076,72 @@ static void mlxsw_sp_pude_event_func(const struct mlxsw_reg_info *reg, + } + } + ++struct mlxsw_sp_linecard_status_event { ++ struct mlxsw_core *mlxsw_core; ++ char mddq_pl[MLXSW_REG_MDDQ_LEN]; ++ struct work_struct work; ++}; ++ ++static void mlxsw_sp_linecard_status_event_work(struct work_struct *work) ++{ ++ struct mlxsw_sp_linecard_status_event *event; ++ struct mlxsw_core *mlxsw_core; ++ ++ event = container_of(work, struct mlxsw_sp_linecard_status_event, work); ++ mlxsw_core = event->mlxsw_core; ++ mlxsw_linecard_status_process(mlxsw_core, event->mddq_pl); ++ kfree(event); ++} ++ ++static void ++mlxsw_sp_linecard_status_listener_func(const struct mlxsw_reg_info *reg, ++ char *mddq_pl, void *priv) ++{ ++ struct mlxsw_sp_linecard_status_event *event; ++ struct mlxsw_sp *mlxsw_sp = priv; ++ ++ event = kmalloc(sizeof(*event), GFP_ATOMIC); ++ if (!event) ++ return; ++ event->mlxsw_core = mlxsw_sp->core; ++ memcpy(event->mddq_pl, mddq_pl, sizeof(event->mddq_pl)); ++ INIT_WORK(&event->work, mlxsw_sp_linecard_status_event_work); ++ mlxsw_core_schedule_work(&event->work); ++} ++ ++struct mlxsw_sp_linecard_bct_event { ++ struct mlxsw_core *mlxsw_core; ++ char mbct_pl[MLXSW_REG_MBCT_LEN]; ++ struct work_struct work; ++}; ++ ++static void mlxsw_sp_linecard_bct_event_work(struct work_struct *work) ++{ ++ struct mlxsw_sp_linecard_bct_event *event; ++ struct mlxsw_core *mlxsw_core; ++ ++ event = container_of(work, struct mlxsw_sp_linecard_bct_event, work); ++ mlxsw_core = event->mlxsw_core; ++ mlxsw_linecard_bct_process(mlxsw_core, event->mbct_pl); ++ kfree(event); ++} ++ ++static void ++mlxsw_sp_linecard_bct_listener_func(const struct mlxsw_reg_info *reg, ++ char *mbct_pl, void *priv) ++{ ++ struct mlxsw_sp_linecard_bct_event *event; ++ struct mlxsw_sp *mlxsw_sp = priv; ++ ++ event = kmalloc(sizeof(*event), GFP_ATOMIC); ++ if (!event) ++ return; ++ event->mlxsw_core = mlxsw_sp->core; ++ memcpy(event->mbct_pl, mbct_pl, sizeof(event->mbct_pl)); ++ INIT_WORK(&event->work, mlxsw_sp_linecard_bct_event_work); ++ mlxsw_core_schedule_work(&event->work); ++} ++ + static void mlxsw_sp1_ptp_fifo_event_func(struct mlxsw_sp *mlxsw_sp, + char *mtpptr_pl, bool ingress) + { +@@ -2206,6 +2272,8 @@ void mlxsw_sp_sample_receive(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb, + static const struct mlxsw_listener mlxsw_sp_listener[] = { + /* Events */ + MLXSW_SP_EVENTL(mlxsw_sp_pude_event_func, PUDE), ++ MLXSW_SP_EVENTL(mlxsw_sp_linecard_status_listener_func, DSDSC), ++ MLXSW_SP_EVENTL(mlxsw_sp_linecard_bct_listener_func, BCTOE), + /* L2 traps */ + MLXSW_SP_RXL_NO_MARK(FID_MISS, TRAP_TO_CPU, FID_MISS, false), + /* L3 traps */ +diff --git a/drivers/net/ethernet/mellanox/mlxsw/trap.h b/drivers/net/ethernet/mellanox/mlxsw/trap.h +index 57f9e2460..f3e522de2 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/trap.h ++++ b/drivers/net/ethernet/mellanox/mlxsw/trap.h +@@ -132,6 +132,12 @@ enum mlxsw_event_trap_id { + MLXSW_TRAP_ID_PTP_ING_FIFO = 0x2D, + /* PTP Egress FIFO has a new entry */ + MLXSW_TRAP_ID_PTP_EGR_FIFO = 0x2E, ++ /* Downstream Device Status Change */ ++ MLXSW_TRAP_ID_DSDSC = 0x321, ++ /* Binary Code Transfer Operation Executed Event */ ++ MLXSW_TRAP_ID_BCTOE = 0x322, ++ /* Port mapping change */ ++ MLXSW_TRAP_ID_PMLPE = 0x32E, + }; + + #endif /* _MLXSW_TRAP_H */ +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0136-mlxsw-core_linecards-Implement-line-card-activation-.patch b/platform/mellanox/non-upstream-patches/patches/0136-mlxsw-core_linecards-Implement-line-card-activation-.patch new file mode 100644 index 000000000000..b889ad938776 --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0136-mlxsw-core_linecards-Implement-line-card-activation-.patch @@ -0,0 +1,205 @@ +From f2ecea65348e527345e9e7a59766162eb2297a53 Mon Sep 17 00:00:00 2001 +From: Jiri Pirko +Date: Fri, 22 Jan 2021 14:45:06 +0100 +Subject: [PATCH] mlxsw: core_linecards: Implement line card activation process + +Allow to process events generated upon line card getting "ready" and +"active". + +Signed-off-by: Jiri Pirko +--- + drivers/net/ethernet/mellanox/mlxsw/core.h | 3 + + .../ethernet/mellanox/mlxsw/core_linecards.c | 85 +++++++++++++++++-- + 2 files changed, 80 insertions(+), 8 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.h b/drivers/net/ethernet/mellanox/mlxsw/core.h +index d3c5d8289..ecd91bb8c 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core.h ++++ b/drivers/net/ethernet/mellanox/mlxsw/core.h +@@ -521,6 +521,9 @@ struct mlxsw_linecard { + char read_name[MLXSW_REG_MDDQ_SLOT_ACII_NAME_LEN]; + char mbct_pl[MLXSW_REG_MBCT_LEN]; /* too big for stack */ + bool provisioned; ++ bool ready; ++ bool active; ++ bool unprovision_done; + }; + + struct mlxsw_linecard_types_info; +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c b/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c +index a324ce243..134437f49 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c +@@ -67,6 +67,8 @@ static const char *mlxsw_linecard_type_name(struct mlxsw_linecard *linecard) + static void mlxsw_linecard_provision_fail(struct mlxsw_linecard *linecard) + { + linecard->provisioned = false; ++ linecard->ready = false; ++ linecard->active = false; + devlink_linecard_provision_fail(linecard->devlink_linecard); + } + +@@ -94,10 +96,51 @@ static void mlxsw_linecard_provision_clear(struct mlxsw_linecard *linecard) + devlink_linecard_provision_clear(linecard->devlink_linecard); + } + ++static int mlxsw_linecard_ready_set(struct mlxsw_core *mlxsw_core, ++ struct mlxsw_linecard *linecard) ++{ ++ char mddc_pl[MLXSW_REG_MDDC_LEN]; ++ int err; ++ ++ mlxsw_reg_mddc_pack(mddc_pl, linecard->slot_index, false, true); ++ err = mlxsw_reg_write(mlxsw_core, MLXSW_REG(mddc), mddc_pl); ++ if (err) ++ return err; ++ linecard->ready = true; ++ return 0; ++} ++ ++static int mlxsw_linecard_ready_clear(struct mlxsw_core *mlxsw_core, ++ struct mlxsw_linecard *linecard) ++{ ++ char mddc_pl[MLXSW_REG_MDDC_LEN]; ++ int err; ++ ++ mlxsw_reg_mddc_pack(mddc_pl, linecard->slot_index, false, false); ++ err = mlxsw_reg_write(mlxsw_core, MLXSW_REG(mddc), mddc_pl); ++ if (err) ++ return err; ++ linecard->ready = false; ++ return 0; ++} ++ ++static void mlxsw_linecard_active_set(struct mlxsw_linecard *linecard) ++{ ++ linecard->active = true; ++ devlink_linecard_activate(linecard->devlink_linecard); ++} ++ ++static void mlxsw_linecard_active_clear(struct mlxsw_linecard *linecard) ++{ ++ linecard->active = false; ++ devlink_linecard_deactivate(linecard->devlink_linecard); ++} ++ + static int __mlxsw_linecard_status_process(struct mlxsw_core *mlxsw_core, + struct mlxsw_linecards *linecards, + struct mlxsw_linecard *linecard, +- const char *mddq_pl) ++ const char *mddq_pl, ++ bool process_provision_only) + { + enum mlxsw_reg_mddq_card_type card_type; + enum mlxsw_reg_mddq_ready ready; +@@ -132,6 +175,27 @@ static int __mlxsw_linecard_status_process(struct mlxsw_core *mlxsw_core, + goto out; + } + ++ if (!process_provision_only && !linecard->unprovision_done && ++ ready == MLXSW_REG_MDDQ_READY_READY && !linecard->ready) { ++ err = mlxsw_linecard_ready_set(mlxsw_core, linecard); ++ if (err) ++ goto out; ++ } ++ ++ if (!process_provision_only && !linecard->unprovision_done && active && ++ linecard->active != active && linecard->ready) ++ mlxsw_linecard_active_set(linecard); ++ ++ if (!process_provision_only && !active && linecard->active != active) ++ mlxsw_linecard_active_clear(linecard); ++ ++ if (!process_provision_only && ready != MLXSW_REG_MDDQ_READY_READY && ++ linecard->ready) { ++ err = mlxsw_linecard_ready_clear(mlxsw_core, linecard); ++ if (err) ++ goto out; ++ } ++ + if (!provisioned && linecard->provisioned != provisioned) + mlxsw_linecard_provision_clear(linecard); + +@@ -146,13 +210,14 @@ int mlxsw_linecard_status_process(struct mlxsw_core *mlxsw_core, + struct mlxsw_linecards *linecards = mlxsw_core_linecards(mlxsw_core); + + return __mlxsw_linecard_status_process(mlxsw_core, linecards, NULL, +- mddq_pl); ++ mddq_pl, false); + } + EXPORT_SYMBOL(mlxsw_linecard_status_process); + + static int mlxsw_linecard_status_get_and_process(struct mlxsw_core *mlxsw_core, + struct mlxsw_linecards *linecards, +- struct mlxsw_linecard *linecard) ++ struct mlxsw_linecard *linecard, ++ bool process_provision_only) + { + char mddq_pl[MLXSW_REG_MDDQ_LEN]; + int err; +@@ -163,7 +228,7 @@ static int mlxsw_linecard_status_get_and_process(struct mlxsw_core *mlxsw_core, + return err; + + return __mlxsw_linecard_status_process(mlxsw_core, linecards, linecard, +- mddq_pl); ++ mddq_pl, process_provision_only); + } + + static int __mlxsw_linecard_fix_fsm_state(struct mlxsw_linecard *linecard) +@@ -308,6 +373,7 @@ static int mlxsw_linecard_provision(struct devlink_linecard *devlink_linecard, + + mutex_lock(&linecard->lock); + ++ linecard->unprovision_done = false; + linecards = linecard->linecards; + mlxsw_core = linecards->mlxsw_core; + mlxsw_reg_mbct_pack(linecard->mbct_pl, linecard->slot_index, +@@ -416,6 +482,7 @@ static int mlxsw_linecard_unprovision(struct devlink_linecard *devlink_linecard, + NL_SET_ERR_MSG_MOD(extack, "Failed to erase linecard INI while being used"); + goto fix_fsm_err_out; + } ++ linecard->unprovision_done = true; + goto out; + + fix_fsm_err_out: +@@ -478,7 +545,7 @@ static int mlxsw_linecard_init(struct mlxsw_core *mlxsw_core, + linecard->devlink_linecard = devlink_linecard; + + err = mlxsw_linecard_status_get_and_process(mlxsw_core, linecards, +- linecard); ++ linecard, true); + if (err) + goto err_status_get_and_process; + +@@ -514,7 +581,7 @@ static int mlxsw_linecard_post_init(struct mlxsw_core *mlxsw_core, + return err; + + err = mlxsw_linecard_status_get_and_process(mlxsw_core, linecards, +- linecard); ++ linecard, false); + if (err) + goto err_status_get_and_process; + +@@ -533,6 +600,10 @@ static void mlxsw_linecard_pre_fini(struct mlxsw_core *mlxsw_core, + + linecard = mlxsw_linecard_get(linecards, slot_index); + mlxsw_linecard_event_delivery_set(mlxsw_core, linecard, false); ++ /* Make sure all scheduled events are processed */ ++ mlxsw_core_flush_owq(); ++ if (linecard->active) ++ mlxsw_linecard_active_clear(linecard); + } + + static void mlxsw_linecard_fini(struct mlxsw_core *mlxsw_core, +@@ -754,8 +825,6 @@ void mlxsw_linecards_pre_fini(struct mlxsw_core *mlxsw_core, + return; + for (i = 0; i < linecards->count; i++) + mlxsw_linecard_pre_fini(mlxsw_core, linecards, i + 1); +- /* Make sure all scheduled events are processed */ +- mlxsw_core_flush_owq(); + } + + void mlxsw_linecards_fini(struct mlxsw_core *mlxsw_core, +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0137-mlxsw-core-Extend-driver-ops-by-remove-selected-port.patch b/platform/mellanox/non-upstream-patches/patches/0137-mlxsw-core-Extend-driver-ops-by-remove-selected-port.patch new file mode 100644 index 000000000000..d8abff2cb1c2 --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0137-mlxsw-core-Extend-driver-ops-by-remove-selected-port.patch @@ -0,0 +1,98 @@ +From 063ca0577ceb2355884555d96a24a740a2c03bdb Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Wed, 22 Dec 2021 16:26:43 +0000 +Subject: [PATCH] mlxsw: core: Extend driver ops by remove selected ports op + +In case of line card implementation, the core has to have a way to +remove relevant ports manually. Extend the Spectrum driver ops by an op +that implements port removal of selected ports upon request. + +Signed-off-by: Jiri Pirko +--- + drivers/net/ethernet/mellanox/mlxsw/core.c | 9 +++++++++ + drivers/net/ethernet/mellanox/mlxsw/core.h | 8 ++++++++ + drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 15 +++++++++++++++ + 3 files changed, 32 insertions(+) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c +index 246db548f..2b4f9844b 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core.c +@@ -2870,6 +2870,15 @@ mlxsw_core_port_devlink_port_get(struct mlxsw_core *mlxsw_core, + } + EXPORT_SYMBOL(mlxsw_core_port_devlink_port_get); + ++void mlxsw_core_ports_remove_selected(struct mlxsw_core *mlxsw_core, ++ bool (*selector)(void *priv, u16 local_port), ++ void *priv) ++{ ++ if (WARN_ON(!mlxsw_core->driver->ports_remove_selected)) ++ return; ++ mlxsw_core->driver->ports_remove_selected(mlxsw_core, selector, priv); ++} ++ + struct mlxsw_env *mlxsw_core_env(const struct mlxsw_core *mlxsw_core) + { + return mlxsw_core->env; +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.h b/drivers/net/ethernet/mellanox/mlxsw/core.h +index ecd91bb8c..70f97ef74 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core.h ++++ b/drivers/net/ethernet/mellanox/mlxsw/core.h +@@ -223,6 +223,10 @@ enum devlink_port_type mlxsw_core_port_type_get(struct mlxsw_core *mlxsw_core, + struct devlink_port * + mlxsw_core_port_devlink_port_get(struct mlxsw_core *mlxsw_core, + u8 local_port); ++void mlxsw_core_ports_remove_selected(struct mlxsw_core *mlxsw_core, ++ bool (*selector)(void *priv, ++ u16 local_port), ++ void *priv); + struct mlxsw_env *mlxsw_core_env(const struct mlxsw_core *mlxsw_core); + int mlxsw_core_module_max_width(struct mlxsw_core *mlxsw_core, u8 module); + +@@ -296,6 +300,10 @@ struct mlxsw_driver { + unsigned int count, struct netlink_ext_ack *extack); + int (*port_unsplit)(struct mlxsw_core *mlxsw_core, u8 local_port, + struct netlink_ext_ack *extack); ++ void (*ports_remove_selected)(struct mlxsw_core *mlxsw_core, ++ bool (*selector)(void *priv, ++ u16 local_port), ++ void *priv); + int (*sb_pool_get)(struct mlxsw_core *mlxsw_core, + unsigned int sb_index, u16 pool_index, + struct devlink_sb_pool_info *pool_info); +diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +index d7a230828..75b418fbe 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +@@ -1736,6 +1736,20 @@ static void mlxsw_sp_ports_remove(struct mlxsw_sp *mlxsw_sp) + mlxsw_sp->ports = NULL; + } + ++static void ++mlxsw_sp_ports_remove_selected(struct mlxsw_core *mlxsw_core, ++ bool (*selector)(void *priv, u16 local_port), ++ void *priv) ++{ ++ struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core); ++ unsigned int max_ports = mlxsw_core_max_ports(mlxsw_core); ++ int i; ++ ++ for (i = 1; i < max_ports; i++) ++ if (mlxsw_sp_port_created(mlxsw_sp, i) && selector(priv, i)) ++ mlxsw_sp_port_remove(mlxsw_sp, i); ++} ++ + static int mlxsw_sp_ports_create(struct mlxsw_sp *mlxsw_sp) + { + unsigned int max_ports = mlxsw_core_max_ports(mlxsw_sp->core); +@@ -3370,6 +3384,7 @@ static struct mlxsw_driver mlxsw_sp3_driver = { + .basic_trap_groups_set = mlxsw_sp_basic_trap_groups_set, + .port_split = mlxsw_sp_port_split, + .port_unsplit = mlxsw_sp_port_unsplit, ++ .ports_remove_selected = mlxsw_sp_ports_remove_selected, + .sb_pool_get = mlxsw_sp_sb_pool_get, + .sb_pool_set = mlxsw_sp_sb_pool_set, + .sb_port_pool_get = mlxsw_sp_sb_port_pool_get, +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0138-mlxsw-spectrum-Add-port-to-linecard-mapping.patch b/platform/mellanox/non-upstream-patches/patches/0138-mlxsw-spectrum-Add-port-to-linecard-mapping.patch new file mode 100644 index 000000000000..0e886cc29040 --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0138-mlxsw-spectrum-Add-port-to-linecard-mapping.patch @@ -0,0 +1,152 @@ +From fd68af1d7a7c58c3f7db6ec95aba528137ec4c2d Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Mon, 3 Jan 2022 11:22:42 +0000 +Subject: [PATCH] mlxsw: spectrum: Add port to linecard mapping + +For each port get slot_index using PMLP register. For ports residing +on a linecard, identify it with the linecard by setting mapping +using devlink_port_linecard_set() helper. Use linecard slot index for +PMTDB register queries. + +Signed-off-by: Jiri Pirko +--- + drivers/net/ethernet/mellanox/mlxsw/core.c | 18 ++++++++++++++---- + drivers/net/ethernet/mellanox/mlxsw/core.h | 3 ++- + drivers/net/ethernet/mellanox/mlxsw/minimal.c | 2 +- + drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 2 +- + drivers/net/ethernet/mellanox/mlxsw/switchib.c | 2 +- + drivers/net/ethernet/mellanox/mlxsw/switchx2.c | 2 +- + 6 files changed, 20 insertions(+), 9 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c +index 2b4f9844b..68ef007ac 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core.c +@@ -48,6 +48,7 @@ struct mlxsw_core_port { + struct devlink_port devlink_port; + void *port_driver_priv; + u8 local_port; ++ struct mlxsw_linecard *linecard; + }; + + void *mlxsw_core_port_driver_priv(struct mlxsw_core_port *mlxsw_core_port) +@@ -2723,7 +2724,7 @@ EXPORT_SYMBOL(mlxsw_core_res_get); + + static int __mlxsw_core_port_init(struct mlxsw_core *mlxsw_core, u8 local_port, + enum devlink_port_flavour flavour, +- u32 port_number, bool split, ++ u8 slot_index, u32 port_number, bool split, + u32 split_port_subnumber, + bool splittable, u32 lanes, + const unsigned char *switch_id, +@@ -2746,6 +2747,15 @@ static int __mlxsw_core_port_init(struct mlxsw_core *mlxsw_core, u8 local_port, + attrs.switch_id.id_len = switch_id_len; + mlxsw_core_port->local_port = local_port; + devlink_port_attrs_set(devlink_port, &attrs); ++ if (slot_index) { ++ struct mlxsw_linecard *linecard; ++ ++ linecard = mlxsw_linecard_get(mlxsw_core->linecards, ++ slot_index); ++ mlxsw_core_port->linecard = linecard; ++ devlink_port_linecard_set(devlink_port, ++ linecard->devlink_linecard); ++ } + err = devlink_port_register(devlink, devlink_port, local_port); + if (err) + memset(mlxsw_core_port, 0, sizeof(*mlxsw_core_port)); +@@ -2763,14 +2773,14 @@ static void __mlxsw_core_port_fini(struct mlxsw_core *mlxsw_core, u8 local_port) + } + + int mlxsw_core_port_init(struct mlxsw_core *mlxsw_core, u8 local_port, +- u32 port_number, bool split, ++ u8 slot_index, u32 port_number, bool split, + u32 split_port_subnumber, + bool splittable, u32 lanes, + const unsigned char *switch_id, + unsigned char switch_id_len) + { + return __mlxsw_core_port_init(mlxsw_core, local_port, +- DEVLINK_PORT_FLAVOUR_PHYSICAL, ++ DEVLINK_PORT_FLAVOUR_PHYSICAL, slot_index, + port_number, split, split_port_subnumber, + splittable, lanes, + switch_id, switch_id_len); +@@ -2794,7 +2804,7 @@ int mlxsw_core_cpu_port_init(struct mlxsw_core *mlxsw_core, + + err = __mlxsw_core_port_init(mlxsw_core, MLXSW_PORT_CPU_PORT, + DEVLINK_PORT_FLAVOUR_CPU, +- 0, false, 0, false, 0, ++ 0, 0, false, 0, false, 0, + switch_id, switch_id_len); + if (err) + return err; +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.h b/drivers/net/ethernet/mellanox/mlxsw/core.h +index 70f97ef74..8e738ddb3 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core.h ++++ b/drivers/net/ethernet/mellanox/mlxsw/core.h +@@ -202,7 +202,8 @@ void mlxsw_core_lag_mapping_clear(struct mlxsw_core *mlxsw_core, + + void *mlxsw_core_port_driver_priv(struct mlxsw_core_port *mlxsw_core_port); + int mlxsw_core_port_init(struct mlxsw_core *mlxsw_core, u8 local_port, +- u32 port_number, bool split, u32 split_port_subnumber, ++ u8 slot_index, u32 port_number, bool split, ++ u32 split_port_subnumber, + bool splittable, u32 lanes, + const unsigned char *switch_id, + unsigned char switch_id_len); +diff --git a/drivers/net/ethernet/mellanox/mlxsw/minimal.c b/drivers/net/ethernet/mellanox/mlxsw/minimal.c +index 104f1ba02..30925f573 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/minimal.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/minimal.c +@@ -210,7 +210,7 @@ mlxsw_m_port_create(struct mlxsw_m *mlxsw_m, u8 local_port, u8 module) + struct net_device *dev; + int err; + +- err = mlxsw_core_port_init(mlxsw_m->core, local_port, ++ err = mlxsw_core_port_init(mlxsw_m->core, local_port, 0, + module + 1, false, 0, false, + 0, mlxsw_m->base_mac, + sizeof(mlxsw_m->base_mac)); +diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +index 75b418fbe..31eec40a3 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +@@ -1399,7 +1399,7 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port, + int err; + + splittable = lanes > 1 && !split; +- err = mlxsw_core_port_init(mlxsw_sp->core, local_port, ++ err = mlxsw_core_port_init(mlxsw_sp->core, local_port, 0, + port_mapping->module + 1, split, + port_mapping->lane / lanes, + splittable, lanes, +diff --git a/drivers/net/ethernet/mellanox/mlxsw/switchib.c b/drivers/net/ethernet/mellanox/mlxsw/switchib.c +index 1e561132e..090b9a103 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/switchib.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/switchib.c +@@ -280,7 +280,7 @@ static int mlxsw_sib_port_create(struct mlxsw_sib *mlxsw_sib, u8 local_port, + { + int err; + +- err = mlxsw_core_port_init(mlxsw_sib->core, local_port, ++ err = mlxsw_core_port_init(mlxsw_sib->core, local_port, 0, + module + 1, false, 0, false, 0, + mlxsw_sib->hw_id, sizeof(mlxsw_sib->hw_id)); + if (err) { +diff --git a/drivers/net/ethernet/mellanox/mlxsw/switchx2.c b/drivers/net/ethernet/mellanox/mlxsw/switchx2.c +index 131b2a53d..bf8a54776 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/switchx2.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/switchx2.c +@@ -1085,7 +1085,7 @@ static int mlxsw_sx_port_eth_create(struct mlxsw_sx *mlxsw_sx, u8 local_port, + { + int err; + +- err = mlxsw_core_port_init(mlxsw_sx->core, local_port, ++ err = mlxsw_core_port_init(mlxsw_sx->core, local_port, 0, + module + 1, false, 0, false, 0, + mlxsw_sx->hw_id, sizeof(mlxsw_sx->hw_id)); + if (err) { +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0139-mlxsw-reg-Introduce-Management-Temperature-Extended-.patch b/platform/mellanox/non-upstream-patches/patches/0139-mlxsw-reg-Introduce-Management-Temperature-Extended-.patch new file mode 100644 index 000000000000..1a532d88fa61 --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0139-mlxsw-reg-Introduce-Management-Temperature-Extended-.patch @@ -0,0 +1,105 @@ +From a719653b2a7f0943e757c04dab73df324e469436 Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Wed, 12 May 2021 22:57:37 +0300 +Subject: [PATCH] mlxsw: reg: Introduce Management Temperature Extended + Capabilities Register + +Introduce new register MTECR (Management Temperature Extended +Capabilities Register). This register exposes the capabilities of the +device and system temperature sensing. It provides information for +all possible temperature sensors that are on the system. + +Signed-off-by: Vadim Pasternak +Signed-off-by: Jiri Pirko +--- + drivers/net/ethernet/mellanox/mlxsw/reg.h | 67 +++++++++++++++++++++++ + 1 file changed, 67 insertions(+) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h +index 89b21910f..c1ce0b42e 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h ++++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h +@@ -10297,6 +10297,72 @@ mlxsw_reg_mgpir_unpack(char *payload, u8 *num_of_devices, + *num_of_slots = mlxsw_reg_mgpir_num_of_slots_get(payload); + } + ++/* MTECR - Management Temperature Extended Capabilities Register ++ * ------------------------------------------------------------- ++ * MTECR register exposes the capabilities of the device and system ++ * temperature sensing. ++ */ ++#define MLXSW_REG_MTECR_ID 0x9109 ++#define MLXSW_REG_MTECR_LEN 0x60 ++#define MLXSW_REG_MTECR_SENSOR_MAP_LEN 0x58 ++ ++MLXSW_REG_DEFINE(mtecr, MLXSW_REG_MTECR_ID, MLXSW_REG_MTECR_LEN); ++ ++/* reg_mtecr_last_sensor. ++ * Last sensor index that is available in the system to read from. ++ * Access: RO ++ */ ++MLXSW_ITEM32(reg, mtecr, last_sensor, 0x00, 16, 12); ++ ++/* reg_mtecr_sensor_count. ++ * Number of sensors supported by the device. ++ * This includes the ASIC, ambient sensors, Gearboxes etc. ++ * QSFP module sensors are not included. ++ * Access: RO ++ */ ++MLXSW_ITEM32(reg, mtecr, sensor_count, 0x00, 0, 12); ++ ++/* reg_mtecr_slot_index. ++ * Slot index (0: Main board). ++ * Access: Index ++ */ ++MLXSW_ITEM32(reg, mtecr, slot_index, 0x04, 28, 4); ++ ++/* reg_mtecr_internal_sensor_count. ++ * Number of sensors supported by the device that are in the ASIC. ++ * Access: RO ++ */ ++MLXSW_ITEM32(reg, mtecr, internal_sensor_count, 0x04, 0, 7); ++ ++/* reg_mtecr_sensor_map. ++ * Mapping of system sensors supported by the device. Each bit represents a ++ * sensor. This field is size variable based on the last_sensor field and in ++ * granularity of 32 bits. ++ * 0: Not connected or not supported ++ * 1: Supports temperature measurements ++ * ++ */ ++MLXSW_ITEM_BIT_ARRAY(reg, mtecr, sensor_map, 0x08, MLXSW_REG_MTECR_SENSOR_MAP_LEN, 1); ++ ++static inline void mlxsw_reg_mtecr_pack(char *payload, u8 slot_index) ++{ ++ MLXSW_REG_ZERO(mtecr, payload); ++ mlxsw_reg_mtecr_slot_index_set(payload, slot_index); ++} ++ ++static inline void mlxsw_reg_mtecr_unpack(char *payload, u16 *sensor_count, ++ u16 *last_sensor, ++ u8 *internal_sensor_count) ++{ ++ if (sensor_count) ++ *sensor_count = mlxsw_reg_mtecr_sensor_count_get(payload); ++ if (last_sensor) ++ *last_sensor = mlxsw_reg_mtecr_last_sensor_get(payload); ++ if (internal_sensor_count) ++ *internal_sensor_count = ++ mlxsw_reg_mtecr_internal_sensor_count_get(payload); ++} ++ + /* MBCT - Management Binary Code Transfer Register + * ----------------------------------------------- + * This register allows to transfer binary codes from the Host to +@@ -11884,6 +11950,7 @@ static const struct mlxsw_reg_info *mlxsw_reg_infos[] = { + MLXSW_REG(mtptpt), + MLXSW_REG(mfgd), + MLXSW_REG(mgpir), ++ MLXSW_REG(mtecr), + MLXSW_REG(mbct), + MLXSW_REG(mddq), + MLXSW_REG(mddc), +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0140-mlxsw-core-Add-APIs-for-thermal-sensor-mapping.patch b/platform/mellanox/non-upstream-patches/patches/0140-mlxsw-core-Add-APIs-for-thermal-sensor-mapping.patch new file mode 100644 index 000000000000..d48940325e53 --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0140-mlxsw-core-Add-APIs-for-thermal-sensor-mapping.patch @@ -0,0 +1,113 @@ +From 1ea36b4966e21d9d599da7e4e3195364841d9318 Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Mon, 13 Dec 2021 12:29:10 +0000 +Subject: [PATCH] mlxsw: core: Add APIs for thermal sensor mapping + +Add APIs mlxsw_env_sensor_map_init() and mlxsw_env_sensor_map_fini((). +The purpose of the first one is to allocate and create thermal sensors +mapping for temperature sensors, presented within the main board or +line card. It obtains mapping information from the Management +Temperature Extended Capabilities Register, by specifying the relevant +device by the number of a slot at which this device is located. Slot +zero is used for the main board. The second API just free allocated +memory. +The motivation is to create dynamic mapping for gearbox thermal sensors +access. + +Signed-off-by: Vadim Pasternak +--- + .../net/ethernet/mellanox/mlxsw/core_env.c | 47 +++++++++++++++++++ + .../net/ethernet/mellanox/mlxsw/core_env.h | 12 +++++ + 2 files changed, 59 insertions(+) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c +index 94d44db1a..c27cd424b 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c +@@ -626,6 +626,53 @@ mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index, + } + EXPORT_SYMBOL(mlxsw_env_set_module_power_mode); + ++int mlxsw_env_sensor_map_create(struct mlxsw_core *core, ++ const struct mlxsw_bus_info *bus_info, ++ u8 slot_index, ++ struct mlxsw_env_gearbox_sensors_map *map) ++{ ++ char mtecr_pl[MLXSW_REG_MTECR_LEN]; ++ u16 last_sensor, offset; ++ int i, bit, err; ++ ++ mlxsw_reg_mtecr_pack(mtecr_pl, slot_index); ++ err = mlxsw_reg_query(core, MLXSW_REG(mtecr), mtecr_pl); ++ if (err) ++ return err; ++ ++ mlxsw_reg_mtecr_unpack(mtecr_pl, &map->sensor_count, &last_sensor, NULL); ++ if (!map->sensor_count) { ++ map->sensor_bit_map = NULL; ++ return 0; ++ } ++ ++ /* Fill out sensor mapping array. */ ++ map->sensor_bit_map = kcalloc(map->sensor_count, sizeof(u16), GFP_KERNEL); ++ if (!map->sensor_bit_map) ++ return -ENOMEM; ++ ++ /* Sensors bitmap is size variable based on the last_sensor field and ++ * in granularity of 32 bits. Calculate an offset in payload buffer to ++ * start from. ++ */ ++ offset = MLXSW_REG_MTECR_SENSOR_MAP_LEN * 8 - last_sensor - 1; ++ offset -= offset % 32; ++ for (bit = 0, i = 0; bit <= last_sensor && i < map->sensor_count; bit++) { ++ if (mlxsw_reg_mtecr_sensor_map_get(mtecr_pl, bit + offset)) ++ map->sensor_bit_map[i++] = bit; ++ } ++ ++ return 0; ++} ++EXPORT_SYMBOL(mlxsw_env_sensor_map_create); ++ ++void mlxsw_env_sensor_map_destroy(const struct mlxsw_bus_info *bus_info, ++ u16 *sensor_bit_map) ++{ ++ kfree(sensor_bit_map); ++} ++EXPORT_SYMBOL(mlxsw_env_sensor_map_destroy); ++ + static int mlxsw_env_module_has_temp_sensor(struct mlxsw_core *mlxsw_core, + u8 slot_index, u8 module, + bool *p_has_temp_sensor) +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.h b/drivers/net/ethernet/mellanox/mlxsw/core_env.h +index 03d027870..336c9ee57 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_env.h ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.h +@@ -9,6 +9,11 @@ + struct ethtool_modinfo; + struct ethtool_eeprom; + ++struct mlxsw_env_gearbox_sensors_map { ++ u16 sensor_count; ++ u16 *sensor_bit_map; ++}; ++ + int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, + u8 slot_index, int module, int off, + int *temp); +@@ -21,6 +26,13 @@ int mlxsw_env_get_module_eeprom(struct net_device *netdev, + int module, struct ethtool_eeprom *ee, + u8 *data); + ++int mlxsw_env_sensor_map_create(struct mlxsw_core *core, ++ const struct mlxsw_bus_info *bus_info, ++ u8 slot_index, ++ struct mlxsw_env_gearbox_sensors_map *map); ++void mlxsw_env_sensor_map_destroy(const struct mlxsw_bus_info *bus_info, ++ u16 *sensor_bit_map); ++ + int + mlxsw_env_get_module_eeprom_by_page(struct mlxsw_core *mlxsw_core, + u8 slot_index, u8 module, +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0141-mlxsw-reg-Add-Management-DownStream-Device-Tunneling.patch b/platform/mellanox/non-upstream-patches/patches/0141-mlxsw-reg-Add-Management-DownStream-Device-Tunneling.patch new file mode 100644 index 000000000000..2c1bd96646ea --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0141-mlxsw-reg-Add-Management-DownStream-Device-Tunneling.patch @@ -0,0 +1,126 @@ +From 46563dcd511270f67a9e771497ccfc73907aa4d3 Mon Sep 17 00:00:00 2001 +From: Jiri Pirko +Date: Thu, 25 Feb 2021 10:17:53 +0100 +Subject: [PATCH] mlxsw: reg: Add Management DownStream Device Tunneling + Register + +The MDDT register allows deliver query and request messages +(PRM registers, commands) to a DownStream device. + +Signed-off-by: Jiri Pirko +--- + drivers/net/ethernet/mellanox/mlxsw/reg.h | 91 +++++++++++++++++++++++ + 1 file changed, 91 insertions(+) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h +index c1ce0b42e..f8c828e05 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h ++++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h +@@ -10482,6 +10482,96 @@ mlxsw_reg_mbct_unpack(const char *payload, u8 *p_slot_index, + *p_fsm_state = mlxsw_reg_mbct_fsm_state_get(payload); + } + ++/* MDDT - Management DownStream Device Tunneling Register ++ * ------------------------------------------------------ ++ * This register allows deliver query and request messages (PRM registers, ++ * commands) to a DownStream device. ++ */ ++#define MLXSW_REG_MDDT_ID 0x9160 ++#define MLXSW_REG_MDDT_LEN 0x110 ++ ++MLXSW_REG_DEFINE(mddt, MLXSW_REG_MDDT_ID, MLXSW_REG_MDDT_LEN); ++ ++/* reg_mddt_slot_index ++ * Slot index. ++ * Access: Index ++ */ ++ ++MLXSW_ITEM32(reg, mddt, slot_index, 0x00, 8, 4); ++ ++/* reg_mddt_device_index ++ * Device index. ++ * Access: Index ++ */ ++MLXSW_ITEM32(reg, mddt, device_index, 0x00, 0, 8); ++ ++/* reg_mddt_read_size ++ * Read size in D-Words. ++ * Access: OP ++ */ ++MLXSW_ITEM32(reg, mddt, read_size, 0x04, 24, 8); ++ ++/* reg_mddt_write_size ++ * Write size in D-Words. ++ * Access: OP ++ */ ++MLXSW_ITEM32(reg, mddt, write_size, 0x04, 16, 8); ++ ++enum mlxsw_reg_mddt_status { ++ MLXSW_REG_MDDT_STATUS_OK, ++}; ++ ++/* reg_mddt_status ++ * Return code of the Downstream Device to the register that was sent. ++ * Access: RO ++ */ ++MLXSW_ITEM32(reg, mddt, status, 0x0C, 24, 8); ++ ++enum mlxsw_reg_mddt_method { ++ MLXSW_REG_MDDT_METHOD_QUERY, ++ MLXSW_REG_MDDT_METHOD_WRITE, ++}; ++ ++/* reg_mddt_method ++ * Access: OP ++ */ ++MLXSW_ITEM32(reg, mddt, method, 0x0C, 22, 2); ++ ++/* reg_mddt_register_id ++ * Access: Index ++ */ ++MLXSW_ITEM32(reg, mddt, register_id, 0x0C, 0, 16); ++ ++#define MLXSW_REG_MDDT_PAYLOAD_OFFSET 0x0C ++#define MLXSW_REG_MDDT_PRM_REGISTER_HEADER_LEN 4 ++ ++static inline char *mlxsw_reg_mddt_inner_payload(char *payload) ++{ ++ return payload + MLXSW_REG_MDDT_PAYLOAD_OFFSET + ++ MLXSW_REG_MDDT_PRM_REGISTER_HEADER_LEN; ++} ++ ++static inline void mlxsw_reg_mddt_pack(char *payload, u8 slot_index, ++ u8 device_index, ++ enum mlxsw_reg_mddt_method method, ++ const struct mlxsw_reg_info *reg, ++ char **inner_payload) ++{ ++ int len = reg->len + MLXSW_REG_MDDT_PRM_REGISTER_HEADER_LEN; ++ ++ if (WARN_ON(len + MLXSW_REG_MDDT_PAYLOAD_OFFSET > MLXSW_REG_MDDT_LEN)) ++ len = MLXSW_REG_MDDT_LEN - MLXSW_REG_MDDT_PAYLOAD_OFFSET; ++ ++ MLXSW_REG_ZERO(mddt, payload); ++ mlxsw_reg_mddt_slot_index_set(payload, slot_index); ++ mlxsw_reg_mddt_device_index_set(payload, device_index); ++ mlxsw_reg_mddt_method_set(payload, method); ++ mlxsw_reg_mddt_register_id_set(payload, reg->id); ++ mlxsw_reg_mddt_read_size_set(payload, len / 4); ++ mlxsw_reg_mddt_write_size_set(payload, len / 4); ++ *inner_payload = mlxsw_reg_mddt_inner_payload(payload); ++} ++ + /* MDDQ - Management DownStream Device Query Register + * -------------------------------------------------- + * This register allows to query the DownStream device properties. The desired +@@ -11952,6 +12042,7 @@ static const struct mlxsw_reg_info *mlxsw_reg_infos[] = { + MLXSW_REG(mgpir), + MLXSW_REG(mtecr), + MLXSW_REG(mbct), ++ MLXSW_REG(mddt), + MLXSW_REG(mddq), + MLXSW_REG(mddc), + MLXSW_REG(mfde), +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0142-mlxsw-core_linecards-Probe-devices-for-provisioned-l.patch b/platform/mellanox/non-upstream-patches/patches/0142-mlxsw-core_linecards-Probe-devices-for-provisioned-l.patch new file mode 100644 index 000000000000..1126d7013e46 --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0142-mlxsw-core_linecards-Probe-devices-for-provisioned-l.patch @@ -0,0 +1,224 @@ +From 70bc337251ccbfe095a89457ded233c3ad5b9bbc Mon Sep 17 00:00:00 2001 +From: Jiri Pirko +Date: Fri, 26 Feb 2021 13:15:09 +0100 +Subject: [PATCH] mlxsw: core_linecards: Probe devices for provisioned line + card and attach them + +In case the line card is provisioned, go over all possible existing +devices (gearboxes) on it and attach them, so devlink core is aware of +them. In case the device can be flashed, register mlxsw flash component. + +Signed-off-by: Jiri Pirko +--- + drivers/net/ethernet/mellanox/mlxsw/core.h | 3 + + .../ethernet/mellanox/mlxsw/core_linecards.c | 113 ++++++++++++++++-- + 2 files changed, 108 insertions(+), 8 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.h b/drivers/net/ethernet/mellanox/mlxsw/core.h +index 8e738ddb3..593470d14 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core.h ++++ b/drivers/net/ethernet/mellanox/mlxsw/core.h +@@ -533,6 +533,9 @@ struct mlxsw_linecard { + bool ready; + bool active; + bool unprovision_done; ++ u16 hw_revision; ++ u16 ini_version; ++ struct list_head device_list; + }; + + struct mlxsw_linecard_types_info; +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c b/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c +index 134437f49..720ad6d82 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c +@@ -64,27 +64,120 @@ static const char *mlxsw_linecard_type_name(struct mlxsw_linecard *linecard) + return linecard->read_name; + } + +-static void mlxsw_linecard_provision_fail(struct mlxsw_linecard *linecard) ++struct mlxsw_linecard_device { ++ struct list_head list; ++ u8 index; ++ struct mlxsw_linecard *linecard; ++ struct devlink_linecard_device *devlink_device; ++}; ++ ++static int mlxsw_linecard_device_attach(struct mlxsw_core *mlxsw_core, ++ struct mlxsw_linecard *linecard, ++ u8 device_index, bool flash_owner) ++{ ++ struct mlxsw_linecard_device *device; ++ int err; ++ ++ device = kzalloc(sizeof(*device), GFP_KERNEL); ++ if (!device) ++ return -ENOMEM; ++ device->index = device_index; ++ device->linecard = linecard; ++ ++ device->devlink_device = devlink_linecard_device_create(linecard->devlink_linecard, ++ device_index, ++ NULL, NULL); ++ if (IS_ERR(device->devlink_device)) { ++ err = PTR_ERR(device->devlink_device); ++ goto err_devlink_linecard_device_attach; ++ } ++ ++ list_add_tail(&device->list, &linecard->device_list); ++ return 0; ++ ++err_devlink_linecard_device_attach: ++ kfree(device); ++ return err; ++} ++ ++static void mlxsw_linecard_device_detach(struct mlxsw_core *mlxsw_core, ++ struct mlxsw_linecard *linecard, ++ struct mlxsw_linecard_device *device) ++{ ++ list_del(&device->list); ++ devlink_linecard_device_destroy(linecard->devlink_linecard, ++ device->devlink_device); ++ kfree(device); ++} ++ ++static int mlxsw_linecard_devices_attach(struct mlxsw_core *mlxsw_core, ++ struct mlxsw_linecard *linecard) ++{ ++ char mddq_pl[MLXSW_REG_MDDQ_LEN]; ++ bool flash_owner; ++ bool data_valid; ++ u8 device_index; ++ u8 msg_seq = 0; ++ int err; ++ ++ do { ++ mlxsw_reg_mddq_device_info_pack(mddq_pl, linecard->slot_index, ++ msg_seq); ++ err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mddq), mddq_pl); ++ if (err) ++ return err; ++ mlxsw_reg_mddq_device_info_unpack(mddq_pl, &msg_seq, ++ &data_valid, &flash_owner, ++ &device_index, NULL, ++ NULL, NULL); ++ if (!data_valid) ++ break; ++ err = mlxsw_linecard_device_attach(mlxsw_core, linecard, ++ device_index, flash_owner); ++ if (err) ++ return err; ++ } while (msg_seq); ++ ++ return 0; ++} ++ ++static void mlxsw_linecard_devices_detach(struct mlxsw_core *mlxsw_core, ++ struct mlxsw_linecard *linecard) ++{ ++ struct mlxsw_linecard_device *device, *tmp; ++ ++ list_for_each_entry_safe(device, tmp, &linecard->device_list, list) ++ mlxsw_linecard_device_detach(mlxsw_core, linecard, device); ++} ++ ++static void mlxsw_linecard_provision_fail(struct mlxsw_core *mlxsw_core, ++ struct mlxsw_linecard *linecard) + { + linecard->provisioned = false; + linecard->ready = false; + linecard->active = false; ++ mlxsw_linecard_devices_detach(mlxsw_core, linecard); + devlink_linecard_provision_fail(linecard->devlink_linecard); + } + + static int +-mlxsw_linecard_provision_set(struct mlxsw_linecards *linecards, ++mlxsw_linecard_provision_set(struct mlxsw_core *mlxsw_core, ++ struct mlxsw_linecards *linecards, + struct mlxsw_linecard *linecard, + enum mlxsw_reg_mddq_card_type card_type) + { + const char *type = mlxsw_linecard_types_lookup(linecards, card_type); ++ int err; + + if (!type) + type = mlxsw_linecard_type_name(linecard); + if (!type) { +- mlxsw_linecard_provision_fail(linecard); ++ mlxsw_linecard_provision_fail(mlxsw_core, linecard); + return -EINVAL; + } ++ err = mlxsw_linecard_devices_attach(mlxsw_core, linecard); ++ if (err) ++ return err; + linecard->provisioned = true; + devlink_linecard_provision_set(linecard->devlink_linecard, type); + return 0; +@@ -93,6 +186,8 @@ mlxsw_linecard_provision_set(struct mlxsw_linecards *linecards, + static void mlxsw_linecard_provision_clear(struct mlxsw_linecard *linecard) + { + linecard->provisioned = false; ++ mlxsw_linecard_devices_detach(linecard->linecards->mlxsw_core, ++ linecard); + devlink_linecard_provision_clear(linecard->devlink_linecard); + } + +@@ -169,8 +264,8 @@ static int __mlxsw_linecard_status_process(struct mlxsw_core *mlxsw_core, + mutex_lock(&linecard->lock); + + if (provisioned && linecard->provisioned != provisioned) { +- err = mlxsw_linecard_provision_set(linecards, linecard, +- card_type); ++ err = mlxsw_linecard_provision_set(mlxsw_core, linecards, ++ linecard, card_type); + if (err) + goto out; + } +@@ -353,7 +448,7 @@ int mlxsw_linecard_bct_process(struct mlxsw_core *mlxsw_core, + + fix_fsm_err_out: + mlxsw_linecard_fix_fsm_state(linecard, fsm_state); +- mlxsw_linecard_provision_fail(linecard); ++ mlxsw_linecard_provision_fail(mlxsw_core, linecard); + return err; + } + EXPORT_SYMBOL(mlxsw_linecard_bct_process); +@@ -415,7 +510,7 @@ static int mlxsw_linecard_provision(struct devlink_linecard *devlink_linecard, + fix_fsm_err_out: + mlxsw_linecard_fix_fsm_state(linecard, fsm_state); + err_out: +- mlxsw_linecard_provision_fail(linecard); ++ mlxsw_linecard_provision_fail(mlxsw_core, linecard); + out: + mutex_unlock(&linecard->lock); + return err; +@@ -488,7 +583,7 @@ static int mlxsw_linecard_unprovision(struct devlink_linecard *devlink_linecard, + fix_fsm_err_out: + mlxsw_linecard_fix_fsm_state(linecard, fsm_state); + err_out: +- mlxsw_linecard_provision_fail(linecard); ++ mlxsw_linecard_provision_fail(mlxsw_core, linecard); + out: + mutex_unlock(&linecard->lock); + return err; +@@ -536,6 +631,7 @@ static int mlxsw_linecard_init(struct mlxsw_core *mlxsw_core, + linecard->slot_index = slot_index; + linecard->linecards = linecards; + mutex_init(&linecard->lock); ++ INIT_LIST_HEAD(&linecard->device_list); + + devlink_linecard = devlink_linecard_create(priv_to_devlink(mlxsw_core), + slot_index, &mlxsw_linecard_ops, +@@ -613,6 +709,7 @@ static void mlxsw_linecard_fini(struct mlxsw_core *mlxsw_core, + struct mlxsw_linecard *linecard; + + linecard = mlxsw_linecard_get(linecards, slot_index); ++ mlxsw_linecard_devices_detach(mlxsw_core, linecard); + devlink_linecard_destroy(linecard->devlink_linecard); + mutex_destroy(&linecard->lock); + } +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0143-mlxsw-core_linecards-Expose-device-FW-version-over-d.patch b/platform/mellanox/non-upstream-patches/patches/0143-mlxsw-core_linecards-Expose-device-FW-version-over-d.patch new file mode 100644 index 000000000000..f4dc89aec2f9 --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0143-mlxsw-core_linecards-Expose-device-FW-version-over-d.patch @@ -0,0 +1,177 @@ +From 8279b3c273fac860394fb922c70c336993e6f087 Mon Sep 17 00:00:00 2001 +From: Jiri Pirko +Date: Thu, 10 Jun 2021 15:32:00 +0200 +Subject: [PATCH] mlxsw: core_linecards: Expose device FW version over device + info + +Extend MDDQ to obtain FW version of line card device and implement +device_info_get() op to fill up the info with that. + +Signed-off-by: Jiri Pirko +--- + .../ethernet/mellanox/mlxsw/core_linecards.c | 104 +++++++++++++++++- + 1 file changed, 100 insertions(+), 4 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c b/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c +index 720ad6d82..cb872f918 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c +@@ -64,13 +64,31 @@ static const char *mlxsw_linecard_type_name(struct mlxsw_linecard *linecard) + return linecard->read_name; + } + ++struct mlxsw_linecard_device_info { ++ u16 fw_major; ++ u16 fw_minor; ++ u16 fw_sub_minor; ++}; ++ + struct mlxsw_linecard_device { + struct list_head list; + u8 index; + struct mlxsw_linecard *linecard; + struct devlink_linecard_device *devlink_device; ++ struct mlxsw_linecard_device_info info; + }; + ++static struct mlxsw_linecard_device * ++mlxsw_linecard_device_lookup(struct mlxsw_linecard *linecard, u8 index) ++{ ++ struct mlxsw_linecard_device *device; ++ ++ list_for_each_entry(device, &linecard->device_list, list) ++ if (device->index == index) ++ return device; ++ return NULL; ++} ++ + static int mlxsw_linecard_device_attach(struct mlxsw_core *mlxsw_core, + struct mlxsw_linecard *linecard, + u8 device_index, bool flash_owner) +@@ -86,7 +104,7 @@ static int mlxsw_linecard_device_attach(struct mlxsw_core *mlxsw_core, + + device->devlink_device = devlink_linecard_device_create(linecard->devlink_linecard, + device_index, +- NULL, NULL); ++ NULL, device); + if (IS_ERR(device->devlink_device)) { + err = PTR_ERR(device->devlink_device); + goto err_devlink_linecard_device_attach; +@@ -150,6 +168,71 @@ static void mlxsw_linecard_devices_detach(struct mlxsw_core *mlxsw_core, + mlxsw_linecard_device_detach(mlxsw_core, linecard, device); + } + ++static void mlxsw_linecard_device_update(struct mlxsw_core *mlxsw_core, ++ struct mlxsw_linecard *linecard, ++ u8 device_index, ++ struct mlxsw_linecard_device_info *info) ++{ ++ struct mlxsw_linecard_device *device; ++ ++ device = mlxsw_linecard_device_lookup(linecard, device_index); ++ if (!device) ++ return; ++ device->info = *info; ++} ++ ++static int mlxsw_linecard_devices_update(struct mlxsw_core *mlxsw_core, ++ struct mlxsw_linecard *linecard) ++{ ++ struct mlxsw_linecard_device_info info; ++ char mddq_pl[MLXSW_REG_MDDQ_LEN]; ++ bool data_valid; ++ u8 device_index; ++ u8 msg_seq = 0; ++ int err; ++ ++ do { ++ mlxsw_reg_mddq_device_info_pack(mddq_pl, linecard->slot_index, ++ msg_seq); ++ err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mddq), mddq_pl); ++ if (err) ++ return err; ++ mlxsw_reg_mddq_device_info_unpack(mddq_pl, &msg_seq, ++ &data_valid, NULL, ++ &device_index, ++ &info.fw_major, ++ &info.fw_minor, ++ &info.fw_sub_minor); ++ if (!data_valid) ++ break; ++ mlxsw_linecard_device_update(mlxsw_core, linecard, ++ device_index, &info); ++ } while (msg_seq); ++ ++ return 0; ++} ++ ++static int ++mlxsw_linecard_device_info_get(struct devlink_linecard_device *devlink_linecard_device, ++ void *priv, struct devlink_info_req *req, ++ struct netlink_ext_ack *extack) ++{ ++ struct mlxsw_linecard_device *device = priv; ++ struct mlxsw_linecard_device_info *info; ++ char buf[32]; ++ ++ if (!device->linecard->active) ++ return 0; ++ ++ info = &device->info; ++ ++ sprintf(buf, "%u.%u.%u", info->fw_major, info->fw_minor, ++ info->fw_sub_minor); ++ return devlink_info_version_running_put(req, ++ DEVLINK_INFO_VERSION_GENERIC_FW, ++ buf); ++} ++ + static void mlxsw_linecard_provision_fail(struct mlxsw_core *mlxsw_core, + struct mlxsw_linecard *linecard) + { +@@ -219,10 +302,18 @@ static int mlxsw_linecard_ready_clear(struct mlxsw_core *mlxsw_core, + return 0; + } + +-static void mlxsw_linecard_active_set(struct mlxsw_linecard *linecard) ++static int mlxsw_linecard_active_set(struct mlxsw_core *mlxsw_core, ++ struct mlxsw_linecard *linecard, ++ u16 hw_revision, u16 ini_version) + { ++ int err; ++ ++ err = mlxsw_linecard_devices_update(mlxsw_core, linecard); ++ if (err) ++ return err; + linecard->active = true; + devlink_linecard_activate(linecard->devlink_linecard); ++ return 0; + } + + static void mlxsw_linecard_active_clear(struct mlxsw_linecard *linecard) +@@ -278,8 +369,12 @@ static int __mlxsw_linecard_status_process(struct mlxsw_core *mlxsw_core, + } + + if (!process_provision_only && !linecard->unprovision_done && active && +- linecard->active != active && linecard->ready) +- mlxsw_linecard_active_set(linecard); ++ linecard->active != active && linecard->ready) { ++ err = mlxsw_linecard_active_set(mlxsw_core, linecard, ++ hw_revision, ini_version); ++ if (err) ++ goto out; ++ } + + if (!process_provision_only && !active && linecard->active != active) + mlxsw_linecard_active_clear(linecard); +@@ -617,6 +712,7 @@ static const struct devlink_linecard_ops mlxsw_linecard_ops = { + .unprovision = mlxsw_linecard_unprovision, + .types_count = mlxsw_linecard_types_count, + .types_get = mlxsw_linecard_types_get, ++ .device_info_get = mlxsw_linecard_device_info_get, + }; + + static int mlxsw_linecard_init(struct mlxsw_core *mlxsw_core, +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0144-mlxsw-core-Introduce-flash-update-components.patch b/platform/mellanox/non-upstream-patches/patches/0144-mlxsw-core-Introduce-flash-update-components.patch new file mode 100644 index 000000000000..642cd79ca4f5 --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0144-mlxsw-core-Introduce-flash-update-components.patch @@ -0,0 +1,243 @@ +From a1421cadee435540d09a5526525f692821a271cd Mon Sep 17 00:00:00 2001 +From: Jiri Pirko +Date: Fri, 26 Feb 2021 18:40:28 +0100 +Subject: [PATCH] mlxsw: core: Introduce flash update components + +Introduce an infrastructure allowing to have multiple components for +flashing purposes that can be registered from inside the driver. Convert +the existing "no component" flash update to use the new infra. + +Signed-off-by: Jiri Pirko +--- + drivers/net/ethernet/mellanox/mlxsw/core.c | 117 +++++++++++++++++++-- + drivers/net/ethernet/mellanox/mlxsw/core.h | 12 +++ + include/net/devlink.h | 3 + + 3 files changed, 125 insertions(+), 7 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c +index 68ef007ac..f55071982 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core.c +@@ -91,6 +91,10 @@ struct mlxsw_core { + struct devlink_health_reporter *fw_fatal; + } health; + struct mlxsw_env *env; ++ struct list_head flash_component_list; ++ struct mutex flash_update_lock; /* Protects component list and component ++ * callbacks. ++ */ + unsigned long driver_priv[]; + /* driver_priv has to be always the last item */ + }; +@@ -1113,21 +1117,101 @@ static int mlxsw_core_fw_rev_validate(struct mlxsw_core *mlxsw_core, + return 0; + } + ++static int mlxsw_core_fw_flash_cb(struct mlxsw_core *mlxsw_core, ++ const struct firmware *firmware, ++ struct netlink_ext_ack *extack, void *priv) ++{ ++ return mlxsw_core_fw_flash(mlxsw_core, firmware, extack); ++} ++ ++struct mlxsw_core_flash_component { ++ struct list_head list; ++ const char *name; ++ mlxsw_core_flash_update_cb cb; ++ void *priv; ++}; ++ ++static struct mlxsw_core_flash_component * ++mlxsw_core_flash_component_lookup(struct mlxsw_core *mlxsw_core, ++ const char *name) ++{ ++ struct mlxsw_core_flash_component *component; ++ ++ list_for_each_entry(component, &mlxsw_core->flash_component_list, ++ list) { ++ if ((name && component->name && ++ !strcmp(name, component->name)) || ++ (!name && !component->name)) ++ return component; ++ } ++ return NULL; ++} ++ + static int mlxsw_core_fw_flash_update(struct mlxsw_core *mlxsw_core, + struct devlink_flash_update_params *params, + struct netlink_ext_ack *extack) + { +- const struct firmware *firmware; ++ struct mlxsw_core_flash_component *component; + int err; + +- err = request_firmware_direct(&firmware, params->file_name, mlxsw_core->bus_info->dev); +- if (err) +- return err; +- err = mlxsw_core_fw_flash(mlxsw_core, firmware, extack); +- release_firmware(firmware); ++ mutex_lock(&mlxsw_core->flash_update_lock); ++ component = mlxsw_core_flash_component_lookup(mlxsw_core, ++ params->component); ++ if (!component) { ++ NL_SET_ERR_MSG_MOD(extack, "Component does not exist"); ++ err = -ENOENT; ++ goto unlock; ++ } ++ err = component->cb(mlxsw_core, params->fw, extack, component->priv); ++unlock: ++ mutex_unlock(&mlxsw_core->flash_update_lock); ++ return err; ++} + ++int mlxsw_core_flash_component_register(struct mlxsw_core *mlxsw_core, ++ const char *name, ++ mlxsw_core_flash_update_cb cb, ++ void *priv) ++{ ++ struct mlxsw_core_flash_component *component; ++ int err = 0; ++ ++ mutex_lock(&mlxsw_core->flash_update_lock); ++ component = mlxsw_core_flash_component_lookup(mlxsw_core, name); ++ if (WARN_ON(component)) { ++ err = -EEXIST; ++ goto unlock; ++ } ++ component = kzalloc(sizeof(*component), GFP_KERNEL); ++ if (!component) { ++ err = -ENOMEM; ++ goto unlock; ++ } ++ component->name = name; ++ component->cb = cb; ++ component->priv = priv; ++ list_add_tail(&component->list, &mlxsw_core->flash_component_list); ++unlock: ++ mutex_unlock(&mlxsw_core->flash_update_lock); + return err; + } ++EXPORT_SYMBOL(mlxsw_core_flash_component_register); ++ ++void mlxsw_core_flash_component_unregister(struct mlxsw_core *mlxsw_core, ++ const char *name) ++{ ++ struct mlxsw_core_flash_component *component; ++ ++ mutex_lock(&mlxsw_core->flash_update_lock); ++ component = mlxsw_core_flash_component_lookup(mlxsw_core, name); ++ if (WARN_ON(!component)) ++ goto unlock; ++ list_del(&component->list); ++unlock: ++ mutex_unlock(&mlxsw_core->flash_update_lock); ++ kfree(component); ++} ++EXPORT_SYMBOL(mlxsw_core_flash_component_unregister); + + static int mlxsw_core_devlink_param_fw_load_policy_validate(struct devlink *devlink, u32 id, + union devlink_param_value val, +@@ -1572,6 +1656,7 @@ mlxsw_devlink_trap_policer_counter_get(struct devlink *devlink, + } + + static const struct devlink_ops mlxsw_devlink_ops = { ++ .supported_flash_update_params = DEVLINK_SUPPORT_FLASH_UPDATE_COMPONENT, + .reload_actions = BIT(DEVLINK_RELOAD_ACTION_DRIVER_REINIT) | + BIT(DEVLINK_RELOAD_ACTION_FW_ACTIVATE), + .reload_down = mlxsw_devlink_core_bus_device_reload_down, +@@ -1894,6 +1979,16 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info, + mlxsw_core->bus_priv = bus_priv; + mlxsw_core->bus_info = mlxsw_bus_info; + ++ if (!reload) { ++ INIT_LIST_HEAD(&mlxsw_core->flash_component_list); ++ mutex_init(&mlxsw_core->flash_update_lock); ++ err = mlxsw_core_flash_component_register(mlxsw_core, NULL, ++ mlxsw_core_fw_flash_cb, ++ NULL); ++ if (err) ++ goto err_flash_component_register; ++ } ++ + res = mlxsw_driver->res_query_enabled ? &mlxsw_core->res : NULL; + err = mlxsw_bus->init(bus_priv, mlxsw_core, mlxsw_driver->profile, res); + if (err) +@@ -2013,6 +2108,11 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info, + err_register_resources: + mlxsw_bus->fini(bus_priv); + err_bus_init: ++ if (!reload) { ++ mlxsw_core_flash_component_unregister(mlxsw_core, NULL); ++ mutex_destroy(&mlxsw_core->flash_update_lock); ++ } ++err_flash_component_register: + if (!reload) + devlink_free(devlink); + err_devlink_alloc: +@@ -2081,8 +2181,11 @@ void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core, + if (!reload) + devlink_resources_unregister(devlink, NULL); + mlxsw_core->bus->fini(mlxsw_core->bus_priv); +- if (!reload) ++ if (!reload) { ++ mlxsw_core_flash_component_unregister(mlxsw_core, NULL); ++ mutex_destroy(&mlxsw_core->flash_update_lock); + devlink_free(devlink); ++ } + + return; + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.h b/drivers/net/ethernet/mellanox/mlxsw/core.h +index 593470d14..30f00da0a 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core.h ++++ b/drivers/net/ethernet/mellanox/mlxsw/core.h +@@ -41,6 +41,18 @@ mlxsw_core_fw_rev_minor_subminor_validate(const struct mlxsw_fw_rev *rev, + int mlxsw_core_driver_register(struct mlxsw_driver *mlxsw_driver); + void mlxsw_core_driver_unregister(struct mlxsw_driver *mlxsw_driver); + ++typedef int (*mlxsw_core_flash_update_cb)(struct mlxsw_core *mlxsw_core, ++ const struct firmware *firmware, ++ struct netlink_ext_ack *extack, ++ void *priv); ++ ++int mlxsw_core_flash_component_register(struct mlxsw_core *mlxsw_core, ++ const char *name, ++ mlxsw_core_flash_update_cb cb, ++ void *priv); ++void mlxsw_core_flash_component_unregister(struct mlxsw_core *mlxsw_core, ++ const char *name); ++ + int mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info, + const struct mlxsw_bus *mlxsw_bus, + void *bus_priv, bool reload, +diff --git a/include/net/devlink.h b/include/net/devlink.h +index 06b61c1d7..fafbec26d 100644 +--- a/include/net/devlink.h ++++ b/include/net/devlink.h +@@ -19,6 +19,7 @@ + #include + #include + #include ++#include + + #define DEVLINK_RELOAD_STATS_ARRAY_SIZE \ + (__DEVLINK_RELOAD_LIMIT_MAX * __DEVLINK_RELOAD_ACTION_MAX) +@@ -624,6 +625,7 @@ enum devlink_param_generic_id { + + /** + * struct devlink_flash_update_params - Flash Update parameters ++ * @fw: pointer to the firmware data to update from + * @file_name: the name of the flash firmware file to update from + * @component: the flash component to update + * +@@ -632,6 +634,7 @@ enum devlink_param_generic_id { + * their devlink_ops structure. + */ + struct devlink_flash_update_params { ++ const struct firmware *fw; + const char *file_name; + const char *component; + u32 overwrite_mask; +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0145-mlxfw-Get-the-PSID-value-using-op-instead-of-passing.patch b/platform/mellanox/non-upstream-patches/patches/0145-mlxfw-Get-the-PSID-value-using-op-instead-of-passing.patch new file mode 100644 index 000000000000..1fc1f2c96dc2 --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0145-mlxfw-Get-the-PSID-value-using-op-instead-of-passing.patch @@ -0,0 +1,200 @@ +From ecf655b1e2329f2376f014c2cad0f81ec2ac5deb Mon Sep 17 00:00:00 2001 +From: Jiri Pirko +Date: Fri, 4 Jun 2021 10:25:35 +0200 +Subject: [PATCH] mlxfw: Get the PSID value using op instead of passing it in + struct + +In preparation for line card device flashing, where the PSID is going to +be obtained dynamically using MGIR register for each individual line +card device. So convert the PSID value get to an extra op. + +Signed-off-by: Jiri Pirko +--- + drivers/net/ethernet/mellanox/mlx5/core/fw.c | 18 +++++++++++++-- + drivers/net/ethernet/mellanox/mlxfw/mlxfw.h | 4 ++-- + .../net/ethernet/mellanox/mlxfw/mlxfw_fsm.c | 23 ++++++++++++++----- + drivers/net/ethernet/mellanox/mlxsw/core.c | 19 +++++++++++++-- + 4 files changed, 52 insertions(+), 12 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fw.c b/drivers/net/ethernet/mellanox/mlx5/core/fw.c +index 02558ac2a..06edfd5b1 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/fw.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/fw.c +@@ -494,6 +494,20 @@ struct mlx5_mlxfw_dev { + struct mlx5_core_dev *mlx5_core_dev; + }; + ++static const char *mlx5_psid_get(struct mlxfw_dev *mlxfw_dev, u16 *psid_size) ++{ ++ struct mlx5_mlxfw_dev *mlx5_mlxfw_dev = ++ container_of(mlxfw_dev, struct mlx5_mlxfw_dev, mlxfw_dev); ++ struct mlx5_core_dev *dev = mlx5_mlxfw_dev->mlx5_core_dev; ++ ++ *psid_size = MLX5_BOARD_ID_LEN; ++ return dev->board_id; ++} ++ ++static void mlx5_psid_put(const char *psid) ++{ ++} ++ + static int mlx5_component_query(struct mlxfw_dev *mlxfw_dev, + u16 component_index, u32 *p_max_size, + u8 *p_align_bits, u16 *p_max_write_size) +@@ -651,6 +665,8 @@ static int mlx5_fsm_reactivate(struct mlxfw_dev *mlxfw_dev, u8 *status) + } + + static const struct mlxfw_dev_ops mlx5_mlxfw_dev_ops = { ++ .psid_get = mlx5_psid_get, ++ .psid_put = mlx5_psid_put, + .component_query = mlx5_component_query, + .fsm_lock = mlx5_fsm_lock, + .fsm_component_update = mlx5_fsm_component_update, +@@ -670,8 +686,6 @@ int mlx5_firmware_flash(struct mlx5_core_dev *dev, + struct mlx5_mlxfw_dev mlx5_mlxfw_dev = { + .mlxfw_dev = { + .ops = &mlx5_mlxfw_dev_ops, +- .psid = dev->board_id, +- .psid_size = strlen(dev->board_id), + .devlink = priv_to_devlink(dev), + }, + .mlx5_core_dev = dev +diff --git a/drivers/net/ethernet/mellanox/mlxfw/mlxfw.h b/drivers/net/ethernet/mellanox/mlxfw/mlxfw.h +index 7654841a0..b83651246 100644 +--- a/drivers/net/ethernet/mellanox/mlxfw/mlxfw.h ++++ b/drivers/net/ethernet/mellanox/mlxfw/mlxfw.h +@@ -11,8 +11,6 @@ + + struct mlxfw_dev { + const struct mlxfw_dev_ops *ops; +- const char *psid; +- u16 psid_size; + struct devlink *devlink; + }; + +@@ -70,6 +68,8 @@ enum mlxfw_fsm_reactivate_status { + }; + + struct mlxfw_dev_ops { ++ const char * (*psid_get)(struct mlxfw_dev *mlxfw_dev, u16 *psid_size); ++ void (*psid_put)(const char *psid); + int (*component_query)(struct mlxfw_dev *mlxfw_dev, u16 component_index, + u32 *p_max_size, u8 *p_align_bits, + u16 *p_max_write_size); +diff --git a/drivers/net/ethernet/mellanox/mlxfw/mlxfw_fsm.c b/drivers/net/ethernet/mellanox/mlxfw/mlxfw_fsm.c +index bcd166911..329ddf1b3 100644 +--- a/drivers/net/ethernet/mellanox/mlxfw/mlxfw_fsm.c ++++ b/drivers/net/ethernet/mellanox/mlxfw/mlxfw_fsm.c +@@ -303,7 +303,8 @@ static int mlxfw_flash_component(struct mlxfw_dev *mlxfw_dev, + return err; + } + +-static int mlxfw_flash_components(struct mlxfw_dev *mlxfw_dev, u32 fwhandle, ++static int mlxfw_flash_components(struct mlxfw_dev *mlxfw_dev, const char *psid, ++ u16 psid_size, u32 fwhandle, + struct mlxfw_mfa2_file *mfa2_file, + bool reactivate_supp, + struct netlink_ext_ack *extack) +@@ -312,8 +313,7 @@ static int mlxfw_flash_components(struct mlxfw_dev *mlxfw_dev, u32 fwhandle, + int err; + int i; + +- err = mlxfw_mfa2_file_component_count(mfa2_file, mlxfw_dev->psid, +- mlxfw_dev->psid_size, ++ err = mlxfw_mfa2_file_component_count(mfa2_file, psid, psid_size, + &component_count); + if (err) { + MLXFW_ERR_MSG(mlxfw_dev, extack, +@@ -324,8 +324,8 @@ static int mlxfw_flash_components(struct mlxfw_dev *mlxfw_dev, u32 fwhandle, + for (i = 0; i < component_count; i++) { + struct mlxfw_mfa2_component *comp; + +- comp = mlxfw_mfa2_file_component_get(mfa2_file, mlxfw_dev->psid, +- mlxfw_dev->psid_size, i); ++ comp = mlxfw_mfa2_file_component_get(mfa2_file, psid, ++ psid_size, i); + if (IS_ERR(comp)) { + err = PTR_ERR(comp); + MLXFW_ERR_MSG(mlxfw_dev, extack, +@@ -350,6 +350,8 @@ int mlxfw_firmware_flash(struct mlxfw_dev *mlxfw_dev, + { + struct mlxfw_mfa2_file *mfa2_file; + bool reactivate_supp = true; ++ const char *psid; ++ u16 psid_size; + u32 fwhandle; + int err; + +@@ -392,8 +394,16 @@ int mlxfw_firmware_flash(struct mlxfw_dev *mlxfw_dev, + if (err) + goto err_state_wait_reactivate_to_locked; + +- err = mlxfw_flash_components(mlxfw_dev, fwhandle, mfa2_file, ++ psid = mlxfw_dev->ops->psid_get(mlxfw_dev, &psid_size); ++ if (IS_ERR(psid)) { ++ err = PTR_ERR(psid); ++ goto err_psid_get; ++ } ++ ++ err = mlxfw_flash_components(mlxfw_dev, psid, psid_size, ++ fwhandle, mfa2_file, + reactivate_supp, extack); ++ mlxfw_dev->ops->psid_put(psid); + if (err) + goto err_flash_components; + +@@ -423,6 +433,7 @@ int mlxfw_firmware_flash(struct mlxfw_dev *mlxfw_dev, + err_state_wait_activate_to_locked: + err_fsm_activate: + err_flash_components: ++err_psid_get: + err_state_wait_reactivate_to_locked: + err_fsm_reactivate: + err_state_wait_idle_to_locked: +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c +index f55071982..8c1280781 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core.c +@@ -890,6 +890,21 @@ struct mlxsw_core_fw_info { + struct mlxsw_core *mlxsw_core; + }; + ++static const char *mlxsw_core_fw_psid_get(struct mlxfw_dev *mlxfw_dev, ++ u16 *psid_size) ++{ ++ struct mlxsw_core_fw_info *mlxsw_core_fw_info = ++ container_of(mlxfw_dev, struct mlxsw_core_fw_info, mlxfw_dev); ++ struct mlxsw_core *mlxsw_core = mlxsw_core_fw_info->mlxsw_core; ++ ++ *psid_size = strlen(mlxsw_core->bus_info->psid); ++ return mlxsw_core->bus_info->psid; ++} ++ ++static void mlxsw_core_fw_psid_put(const char *psid) ++{ ++} ++ + static int mlxsw_core_fw_component_query(struct mlxfw_dev *mlxfw_dev, + u16 component_index, u32 *p_max_size, + u8 *p_align_bits, u16 *p_max_write_size) +@@ -1028,6 +1043,8 @@ static void mlxsw_core_fw_fsm_release(struct mlxfw_dev *mlxfw_dev, u32 fwhandle) + } + + static const struct mlxfw_dev_ops mlxsw_core_fw_mlxsw_dev_ops = { ++ .psid_get = mlxsw_core_fw_psid_get, ++ .psid_put = mlxsw_core_fw_psid_put, + .component_query = mlxsw_core_fw_component_query, + .fsm_lock = mlxsw_core_fw_fsm_lock, + .fsm_component_update = mlxsw_core_fw_fsm_component_update, +@@ -1045,8 +1062,6 @@ static int mlxsw_core_fw_flash(struct mlxsw_core *mlxsw_core, const struct firmw + struct mlxsw_core_fw_info mlxsw_core_fw_info = { + .mlxfw_dev = { + .ops = &mlxsw_core_fw_mlxsw_dev_ops, +- .psid = mlxsw_core->bus_info->psid, +- .psid_size = strlen(mlxsw_core->bus_info->psid), + .devlink = priv_to_devlink(mlxsw_core), + }, + .mlxsw_core = mlxsw_core +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0146-mlxsw-core_linecards-Implement-line-card-device-flas.patch b/platform/mellanox/non-upstream-patches/patches/0146-mlxsw-core_linecards-Implement-line-card-device-flas.patch new file mode 100644 index 000000000000..c55126871721 --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0146-mlxsw-core_linecards-Implement-line-card-device-flas.patch @@ -0,0 +1,400 @@ +From b721c11b90bb0ef2fcd0bfccd6334948153edea2 Mon Sep 17 00:00:00 2001 +From: Jiri Pirko +Date: Fri, 5 Mar 2021 09:33:21 +0100 +Subject: [PATCH] mlxsw: core_linecards: Implement line card device flashing + +Generate flash component name and register it internally within mlxsw +for flashing. Also, propagate the component name to devlink core which +exposes the information about device being flashable and the component +name to use to the user. Implement flashing using MDDT register and +mlxfw. + +Signed-off-by: Jiri Pirko +--- + .../ethernet/mellanox/mlxsw/core_linecards.c | 335 +++++++++++++++++- + 1 file changed, 334 insertions(+), 1 deletion(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c b/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c +index cb872f918..9f9ee582f 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c +@@ -73,6 +73,7 @@ struct mlxsw_linecard_device_info { + struct mlxsw_linecard_device { + struct list_head list; + u8 index; ++ char component_name[16]; + struct mlxsw_linecard *linecard; + struct devlink_linecard_device *devlink_device; + struct mlxsw_linecard_device_info info; +@@ -89,11 +90,322 @@ mlxsw_linecard_device_lookup(struct mlxsw_linecard *linecard, u8 index) + return NULL; + } + ++struct mlxsw_linecard_device_fw_info { ++ struct mlxfw_dev mlxfw_dev; ++ struct mlxsw_core *mlxsw_core; ++ struct mlxsw_linecard_device *device; ++}; ++ ++static const char * ++mlxsw_linecard_device_fw_psid_get(struct mlxfw_dev *mlxfw_dev, u16 *psid_size) ++{ ++ struct mlxsw_linecard_device_fw_info *info = ++ container_of(mlxfw_dev, struct mlxsw_linecard_device_fw_info, ++ mlxfw_dev); ++ struct mlxsw_linecard_device *device = info->device; ++ struct mlxsw_core *mlxsw_core = info->mlxsw_core; ++ char mddt_pl[MLXSW_REG_MDDT_LEN]; ++ char *mgir_pl; ++ char *psid; ++ int err; ++ ++ mlxsw_reg_mddt_pack(mddt_pl, device->linecard->slot_index, ++ device->index, ++ MLXSW_REG_MDDT_METHOD_QUERY, ++ MLXSW_REG(mgir), &mgir_pl); ++ ++ mlxsw_reg_mgir_pack(mgir_pl); ++ err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mddt), mddt_pl); ++ if (err) ++ return ERR_PTR(err); ++ psid = kzalloc(MLXSW_REG_MGIR_FW_INFO_PSID_SIZE, GFP_KERNEL); ++ if (!psid) ++ return ERR_PTR(-ENOMEM); ++ ++ mlxsw_reg_mgir_fw_info_psid_memcpy_from(mgir_pl, psid); ++ *psid_size = strlen(psid); ++ return psid; ++} ++ ++static void mlxsw_linecard_device_fw_psid_put(const char *psid) ++{ ++ kfree(psid); ++} ++ ++static int mlxsw_linecard_device_fw_component_query(struct mlxfw_dev *mlxfw_dev, ++ u16 component_index, ++ u32 *p_max_size, ++ u8 *p_align_bits, ++ u16 *p_max_write_size) ++{ ++ struct mlxsw_linecard_device_fw_info *info = ++ container_of(mlxfw_dev, struct mlxsw_linecard_device_fw_info, ++ mlxfw_dev); ++ struct mlxsw_linecard_device *device = info->device; ++ struct mlxsw_core *mlxsw_core = info->mlxsw_core; ++ char mddt_pl[MLXSW_REG_MDDT_LEN]; ++ char *mcqi_pl; ++ int err; ++ ++ mlxsw_reg_mddt_pack(mddt_pl, device->linecard->slot_index, ++ device->index, ++ MLXSW_REG_MDDT_METHOD_QUERY, ++ MLXSW_REG(mcqi), &mcqi_pl); ++ ++ mlxsw_reg_mcqi_pack(mcqi_pl, component_index); ++ err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mddt), mddt_pl); ++ if (err) ++ return err; ++ mlxsw_reg_mcqi_unpack(mcqi_pl, p_max_size, p_align_bits, ++ p_max_write_size); ++ ++ *p_align_bits = max_t(u8, *p_align_bits, 2); ++ *p_max_write_size = min_t(u16, *p_max_write_size, ++ MLXSW_REG_MCDA_MAX_DATA_LEN); ++ return 0; ++} ++ ++static int mlxsw_linecard_device_fw_fsm_lock(struct mlxfw_dev *mlxfw_dev, ++ u32 *fwhandle) ++{ ++ struct mlxsw_linecard_device_fw_info *info = ++ container_of(mlxfw_dev, struct mlxsw_linecard_device_fw_info, ++ mlxfw_dev); ++ struct mlxsw_linecard_device *device = info->device; ++ struct mlxsw_core *mlxsw_core = info->mlxsw_core; ++ char mddt_pl[MLXSW_REG_MDDT_LEN]; ++ u8 control_state; ++ char *mcc_pl; ++ int err; ++ ++ mlxsw_reg_mddt_pack(mddt_pl, device->linecard->slot_index, ++ device->index, ++ MLXSW_REG_MDDT_METHOD_QUERY, ++ MLXSW_REG(mcc), &mcc_pl); ++ mlxsw_reg_mcc_pack(mcc_pl, 0, 0, 0, 0); ++ err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mddt), mddt_pl); ++ if (err) ++ return err; ++ ++ mlxsw_reg_mcc_unpack(mcc_pl, fwhandle, NULL, &control_state); ++ if (control_state != MLXFW_FSM_STATE_IDLE) ++ return -EBUSY; ++ ++ mlxsw_reg_mddt_pack(mddt_pl, device->linecard->slot_index, ++ device->index, ++ MLXSW_REG_MDDT_METHOD_QUERY, ++ MLXSW_REG(mcc), &mcc_pl); ++ mlxsw_reg_mcc_pack(mcc_pl, MLXSW_REG_MCC_INSTRUCTION_LOCK_UPDATE_HANDLE, ++ 0, *fwhandle, 0); ++ return mlxsw_reg_write(mlxsw_core, MLXSW_REG(mddt), mddt_pl); ++} ++ ++static int ++mlxsw_linecard_device_fw_fsm_component_update(struct mlxfw_dev *mlxfw_dev, ++ u32 fwhandle, ++ u16 component_index, ++ u32 component_size) ++{ ++ struct mlxsw_linecard_device_fw_info *info = ++ container_of(mlxfw_dev, struct mlxsw_linecard_device_fw_info, ++ mlxfw_dev); ++ struct mlxsw_linecard_device *device = info->device; ++ struct mlxsw_core *mlxsw_core = info->mlxsw_core; ++ char mddt_pl[MLXSW_REG_MDDT_LEN]; ++ char *mcc_pl; ++ ++ mlxsw_reg_mddt_pack(mddt_pl, device->linecard->slot_index, ++ device->index, ++ MLXSW_REG_MDDT_METHOD_WRITE, ++ MLXSW_REG(mcc), &mcc_pl); ++ mlxsw_reg_mcc_pack(mcc_pl, MLXSW_REG_MCC_INSTRUCTION_UPDATE_COMPONENT, ++ component_index, fwhandle, component_size); ++ return mlxsw_reg_write(mlxsw_core, MLXSW_REG(mddt), mddt_pl); ++} ++ ++static int ++mlxsw_linecard_device_fw_fsm_block_download(struct mlxfw_dev *mlxfw_dev, ++ u32 fwhandle, u8 *data, ++ u16 size, u32 offset) ++{ ++ struct mlxsw_linecard_device_fw_info *info = ++ container_of(mlxfw_dev, struct mlxsw_linecard_device_fw_info, ++ mlxfw_dev); ++ struct mlxsw_linecard_device *device = info->device; ++ struct mlxsw_core *mlxsw_core = info->mlxsw_core; ++ char mddt_pl[MLXSW_REG_MDDT_LEN]; ++ char *mcda_pl; ++ ++ mlxsw_reg_mddt_pack(mddt_pl, device->linecard->slot_index, ++ device->index, ++ MLXSW_REG_MDDT_METHOD_WRITE, ++ MLXSW_REG(mcda), &mcda_pl); ++ mlxsw_reg_mcda_pack(mcda_pl, fwhandle, offset, size, data); ++ return mlxsw_reg_write(mlxsw_core, MLXSW_REG(mddt), mddt_pl); ++} ++ ++static int ++mlxsw_linecard_device_fw_fsm_component_verify(struct mlxfw_dev *mlxfw_dev, ++ u32 fwhandle, u16 component_index) ++{ ++ struct mlxsw_linecard_device_fw_info *info = ++ container_of(mlxfw_dev, struct mlxsw_linecard_device_fw_info, ++ mlxfw_dev); ++ struct mlxsw_linecard_device *device = info->device; ++ struct mlxsw_core *mlxsw_core = info->mlxsw_core; ++ char mddt_pl[MLXSW_REG_MDDT_LEN]; ++ char *mcc_pl; ++ ++ mlxsw_reg_mddt_pack(mddt_pl, device->linecard->slot_index, ++ device->index, ++ MLXSW_REG_MDDT_METHOD_WRITE, ++ MLXSW_REG(mcc), &mcc_pl); ++ mlxsw_reg_mcc_pack(mcc_pl, MLXSW_REG_MCC_INSTRUCTION_VERIFY_COMPONENT, ++ component_index, fwhandle, 0); ++ return mlxsw_reg_write(mlxsw_core, MLXSW_REG(mddt), mddt_pl); ++} ++ ++static int mlxsw_linecard_device_fw_fsm_activate(struct mlxfw_dev *mlxfw_dev, ++ u32 fwhandle) ++{ ++ struct mlxsw_linecard_device_fw_info *info = ++ container_of(mlxfw_dev, struct mlxsw_linecard_device_fw_info, ++ mlxfw_dev); ++ struct mlxsw_linecard_device *device = info->device; ++ struct mlxsw_core *mlxsw_core = info->mlxsw_core; ++ char mddt_pl[MLXSW_REG_MDDT_LEN]; ++ char *mcc_pl; ++ ++ mlxsw_reg_mddt_pack(mddt_pl, device->linecard->slot_index, ++ device->index, ++ MLXSW_REG_MDDT_METHOD_WRITE, ++ MLXSW_REG(mcc), &mcc_pl); ++ mlxsw_reg_mcc_pack(mcc_pl, MLXSW_REG_MCC_INSTRUCTION_ACTIVATE, ++ 0, fwhandle, 0); ++ return mlxsw_reg_write(mlxsw_core, MLXSW_REG(mddt), mddt_pl); ++} ++ ++static int ++mlxsw_linecard_device_fw_fsm_query_state(struct mlxfw_dev *mlxfw_dev, ++ u32 fwhandle, ++ enum mlxfw_fsm_state *fsm_state, ++ enum mlxfw_fsm_state_err *fsm_state_err) ++{ ++ struct mlxsw_linecard_device_fw_info *info = ++ container_of(mlxfw_dev, struct mlxsw_linecard_device_fw_info, ++ mlxfw_dev); ++ struct mlxsw_linecard_device *device = info->device; ++ struct mlxsw_core *mlxsw_core = info->mlxsw_core; ++ char mddt_pl[MLXSW_REG_MDDT_LEN]; ++ u8 control_state; ++ u8 error_code; ++ char *mcc_pl; ++ int err; ++ ++ mlxsw_reg_mddt_pack(mddt_pl, device->linecard->slot_index, ++ device->index, ++ MLXSW_REG_MDDT_METHOD_QUERY, ++ MLXSW_REG(mcc), &mcc_pl); ++ mlxsw_reg_mcc_pack(mcc_pl, 0, 0, fwhandle, 0); ++ err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mddt), mddt_pl); ++ if (err) ++ return err; ++ ++ mlxsw_reg_mcc_unpack(mcc_pl, NULL, &error_code, &control_state); ++ *fsm_state = control_state; ++ *fsm_state_err = min_t(enum mlxfw_fsm_state_err, error_code, ++ MLXFW_FSM_STATE_ERR_MAX); ++ return 0; ++} ++ ++static void mlxsw_linecard_device_fw_fsm_cancel(struct mlxfw_dev *mlxfw_dev, ++ u32 fwhandle) ++{ ++ struct mlxsw_linecard_device_fw_info *info = ++ container_of(mlxfw_dev, struct mlxsw_linecard_device_fw_info, ++ mlxfw_dev); ++ struct mlxsw_linecard_device *device = info->device; ++ struct mlxsw_core *mlxsw_core = info->mlxsw_core; ++ char mddt_pl[MLXSW_REG_MDDT_LEN]; ++ char *mcc_pl; ++ ++ mlxsw_reg_mddt_pack(mddt_pl, device->linecard->slot_index, ++ device->index, ++ MLXSW_REG_MDDT_METHOD_WRITE, ++ MLXSW_REG(mcc), &mcc_pl); ++ mlxsw_reg_mcc_pack(mcc_pl, MLXSW_REG_MCC_INSTRUCTION_CANCEL, ++ 0, fwhandle, 0); ++ mlxsw_reg_write(mlxsw_core, MLXSW_REG(mddt), mddt_pl); ++} ++ ++static void mlxsw_linecard_device_fw_fsm_release(struct mlxfw_dev *mlxfw_dev, ++ u32 fwhandle) ++{ ++ struct mlxsw_linecard_device_fw_info *info = ++ container_of(mlxfw_dev, struct mlxsw_linecard_device_fw_info, ++ mlxfw_dev); ++ struct mlxsw_linecard_device *device = info->device; ++ struct mlxsw_core *mlxsw_core = info->mlxsw_core; ++ char mddt_pl[MLXSW_REG_MDDT_LEN]; ++ char *mcc_pl; ++ ++ mlxsw_reg_mddt_pack(mddt_pl, device->linecard->slot_index, ++ device->index, ++ MLXSW_REG_MDDT_METHOD_WRITE, ++ MLXSW_REG(mcc), &mcc_pl); ++ mlxsw_reg_mcc_pack(mcc_pl, ++ MLXSW_REG_MCC_INSTRUCTION_RELEASE_UPDATE_HANDLE, ++ 0, fwhandle, 0); ++ mlxsw_reg_write(mlxsw_core, MLXSW_REG(mddt), mddt_pl); ++} ++ ++static const struct mlxfw_dev_ops mlxsw_linecard_device_dev_ops = { ++ .psid_get = mlxsw_linecard_device_fw_psid_get, ++ .psid_put = mlxsw_linecard_device_fw_psid_put, ++ .component_query = mlxsw_linecard_device_fw_component_query, ++ .fsm_lock = mlxsw_linecard_device_fw_fsm_lock, ++ .fsm_component_update = mlxsw_linecard_device_fw_fsm_component_update, ++ .fsm_block_download = mlxsw_linecard_device_fw_fsm_block_download, ++ .fsm_component_verify = mlxsw_linecard_device_fw_fsm_component_verify, ++ .fsm_activate = mlxsw_linecard_device_fw_fsm_activate, ++ .fsm_query_state = mlxsw_linecard_device_fw_fsm_query_state, ++ .fsm_cancel = mlxsw_linecard_device_fw_fsm_cancel, ++ .fsm_release = mlxsw_linecard_device_fw_fsm_release, ++}; ++ ++static int mlxsw_linecard_device_fw_flash(struct mlxsw_core *mlxsw_core, ++ const struct firmware *firmware, ++ struct mlxsw_linecard_device *device, ++ struct netlink_ext_ack *extack) ++{ ++ struct mlxsw_linecard_device_fw_info info = { ++ .mlxfw_dev = { ++ .ops = &mlxsw_linecard_device_dev_ops, ++ .devlink = priv_to_devlink(mlxsw_core), ++ }, ++ .mlxsw_core = mlxsw_core, ++ .device = device, ++ }; ++ ++ return mlxfw_firmware_flash(&info.mlxfw_dev, firmware, extack); ++} ++ ++static int mlxsw_linecard_device_flash_cb(struct mlxsw_core *mlxsw_core, ++ const struct firmware *firmware, ++ struct netlink_ext_ack *extack, void *priv) ++{ ++ struct mlxsw_linecard_device *device = priv; ++ ++ return mlxsw_linecard_device_fw_flash(mlxsw_core, firmware, ++ device, extack); ++} ++ + static int mlxsw_linecard_device_attach(struct mlxsw_core *mlxsw_core, + struct mlxsw_linecard *linecard, + u8 device_index, bool flash_owner) + { + struct mlxsw_linecard_device *device; ++ char *component_name = NULL; + int err; + + device = kzalloc(sizeof(*device), GFP_KERNEL); +@@ -102,9 +414,23 @@ static int mlxsw_linecard_device_attach(struct mlxsw_core *mlxsw_core, + device->index = device_index; + device->linecard = linecard; + ++ if (flash_owner) { ++ snprintf(device->component_name, ++ sizeof(device->component_name), "lc%u_dev%u", ++ linecard->slot_index, device->index); ++ component_name = device->component_name; ++ err = mlxsw_core_flash_component_register(mlxsw_core, ++ component_name, ++ mlxsw_linecard_device_flash_cb, ++ device); ++ if (err) ++ goto err_flash_component_register; ++ } ++ + device->devlink_device = devlink_linecard_device_create(linecard->devlink_linecard, + device_index, +- NULL, device); ++ component_name, ++ device); + if (IS_ERR(device->devlink_device)) { + err = PTR_ERR(device->devlink_device); + goto err_devlink_linecard_device_attach; +@@ -114,6 +440,10 @@ static int mlxsw_linecard_device_attach(struct mlxsw_core *mlxsw_core, + return 0; + + err_devlink_linecard_device_attach: ++ if (flash_owner) ++ mlxsw_core_flash_component_unregister(mlxsw_core, ++ device->component_name); ++err_flash_component_register: + kfree(device); + return err; + } +@@ -125,6 +455,9 @@ static void mlxsw_linecard_device_detach(struct mlxsw_core *mlxsw_core, + list_del(&device->list); + devlink_linecard_device_destroy(linecard->devlink_linecard, + device->devlink_device); ++ if (strlen(device->component_name)) ++ mlxsw_core_flash_component_unregister(mlxsw_core, ++ device->component_name); + kfree(device); + } + +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0147-mlxsw-core_linecards-Introduce-ops-for-linecards-sta.patch b/platform/mellanox/non-upstream-patches/patches/0147-mlxsw-core_linecards-Introduce-ops-for-linecards-sta.patch new file mode 100644 index 000000000000..e7b719158e93 --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0147-mlxsw-core_linecards-Introduce-ops-for-linecards-sta.patch @@ -0,0 +1,277 @@ +From 19bae5f5978a43a22258843cc999b592d0e4b414 Mon Sep 17 00:00:00 2001 +From: Jiri Pirko +Date: Fri, 22 Jan 2021 15:01:06 +0100 +Subject: [PATCH] mlxsw: core_linecards: Introduce ops for linecards status + change tracking + +Introduce an infrastructure allowing the core to register set of ops +which are called whenever line card gets provisione/unprovisioned +and active/inactive. + +Signed-off-by: Jiri Pirko +--- + drivers/net/ethernet/mellanox/mlxsw/core.h | 22 +++ + .../ethernet/mellanox/mlxsw/core_linecards.c | 134 +++++++++++++++++- + 2 files changed, 150 insertions(+), 6 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.h b/drivers/net/ethernet/mellanox/mlxsw/core.h +index 30f00da0a..10ea541bb 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core.h ++++ b/drivers/net/ethernet/mellanox/mlxsw/core.h +@@ -582,4 +582,26 @@ int mlxsw_linecard_status_process(struct mlxsw_core *mlxsw_core, + int mlxsw_linecard_bct_process(struct mlxsw_core *mlxsw_core, + const char *mbct_pl); + ++struct mlxsw_linecards_event_ops { ++ int (*got_provisioned)(struct mlxsw_core *mlxsw_core, u8 slot_index, ++ const struct mlxsw_linecard *linecard, ++ void *priv); ++ void (*got_unprovisioned)(struct mlxsw_core *mlxsw_core, u8 slot_index, ++ const struct mlxsw_linecard *linecard, ++ void *priv); ++ void (*got_active)(struct mlxsw_core *mlxsw_core, u8 slot_index, ++ const struct mlxsw_linecard *linecard, ++ void *priv); ++ void (*got_inactive)(struct mlxsw_core *mlxsw_core, u8 slot_index, ++ const struct mlxsw_linecard *linecard, ++ void *priv); ++}; ++ ++int mlxsw_linecards_event_ops_register(struct mlxsw_core *mlxsw_core, ++ struct mlxsw_linecards_event_ops *ops, ++ void *priv); ++void mlxsw_linecards_event_ops_unregister(struct mlxsw_core *mlxsw_core, ++ struct mlxsw_linecards_event_ops *ops, ++ void *priv); ++ + #endif +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c b/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c +index 9f9ee582f..3a2fdd22d 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c +@@ -576,6 +576,59 @@ static void mlxsw_linecard_provision_fail(struct mlxsw_core *mlxsw_core, + devlink_linecard_provision_fail(linecard->devlink_linecard); + } + ++struct mlxsw_linecards_event_ops_item { ++ struct list_head list; ++ struct mlxsw_linecards_event_ops *event_ops; ++ void *priv; ++}; ++ ++static int ++mlxsw_linecard_provision_cbs_call(struct mlxsw_core *mlxsw_core, ++ struct mlxsw_linecards *linecards, ++ struct mlxsw_linecard *linecard) ++{ ++ struct mlxsw_linecards_event_ops_item *item; ++ int err; ++ ++ list_for_each_entry(item, &linecards->event_ops_list, list) { ++ if (!item->event_ops->got_provisioned) ++ continue; ++ err = item->event_ops->got_provisioned(mlxsw_core, ++ linecard->slot_index, ++ linecard, item->priv); ++ if (err) ++ goto rollback; ++ } ++ return 0; ++ ++rollback: ++ list_for_each_entry_continue_reverse(item, &linecards->event_ops_list, ++ list) { ++ if (!item->event_ops->got_unprovisioned) ++ continue; ++ item->event_ops->got_unprovisioned(mlxsw_core, ++ linecard->slot_index, ++ linecard, item->priv); ++ } ++ return err; ++} ++ ++static void ++mlxsw_linecard_unprovision_cbs_call(struct mlxsw_core *mlxsw_core, ++ struct mlxsw_linecards *linecards, ++ struct mlxsw_linecard *linecard) ++{ ++ struct mlxsw_linecards_event_ops_item *item; ++ ++ list_for_each_entry(item, &linecards->event_ops_list, list) { ++ if (!item->event_ops->got_unprovisioned) ++ continue; ++ item->event_ops->got_unprovisioned(mlxsw_core, ++ linecard->slot_index, ++ linecard, item->priv); ++ } ++} ++ + static int + mlxsw_linecard_provision_set(struct mlxsw_core *mlxsw_core, + struct mlxsw_linecards *linecards, +@@ -594,14 +647,27 @@ mlxsw_linecard_provision_set(struct mlxsw_core *mlxsw_core, + err = mlxsw_linecard_devices_attach(mlxsw_core, linecard); + if (err) + return err; ++ err = mlxsw_linecard_provision_cbs_call(mlxsw_core, linecards, ++ linecard); ++ if (err) ++ goto err_cbs_call; + linecard->provisioned = true; + devlink_linecard_provision_set(linecard->devlink_linecard, type); + return 0; ++ ++err_cbs_call: ++ mlxsw_linecard_devices_detach(linecard->linecards->mlxsw_core, ++ linecard); ++ return err; + } + +-static void mlxsw_linecard_provision_clear(struct mlxsw_linecard *linecard) ++static void mlxsw_linecard_provision_clear(struct mlxsw_core *mlxsw_core, ++ struct mlxsw_linecards *linecards, ++ struct mlxsw_linecard *linecard) + { + linecard->provisioned = false; ++ mlxsw_linecard_unprovision_cbs_call(mlxsw_core, linecards, ++ linecard); + mlxsw_linecard_devices_detach(linecard->linecards->mlxsw_core, + linecard); + devlink_linecard_provision_clear(linecard->devlink_linecard); +@@ -636,22 +702,43 @@ static int mlxsw_linecard_ready_clear(struct mlxsw_core *mlxsw_core, + } + + static int mlxsw_linecard_active_set(struct mlxsw_core *mlxsw_core, ++ struct mlxsw_linecards *linecards, + struct mlxsw_linecard *linecard, + u16 hw_revision, u16 ini_version) + { ++ struct mlxsw_linecards_event_ops_item *item; + int err; + + err = mlxsw_linecard_devices_update(mlxsw_core, linecard); + if (err) + return err; ++ + linecard->active = true; ++ linecard->hw_revision = hw_revision; ++ linecard->ini_version = ini_version; ++ list_for_each_entry(item, &linecards->event_ops_list, list) { ++ if (!item->event_ops->got_active) ++ continue; ++ item->event_ops->got_active(mlxsw_core, linecard->slot_index, ++ linecard, item->priv); ++ } + devlink_linecard_activate(linecard->devlink_linecard); + return 0; + } + +-static void mlxsw_linecard_active_clear(struct mlxsw_linecard *linecard) ++static void mlxsw_linecard_active_clear(struct mlxsw_core *mlxsw_core, ++ struct mlxsw_linecards *linecards, ++ struct mlxsw_linecard *linecard) + { ++ struct mlxsw_linecards_event_ops_item *item; ++ + linecard->active = false; ++ list_for_each_entry(item, &linecards->event_ops_list, list) { ++ if (!item->event_ops->got_inactive) ++ continue; ++ item->event_ops->got_inactive(mlxsw_core, linecard->slot_index, ++ linecard, item->priv); ++ } + devlink_linecard_deactivate(linecard->devlink_linecard); + } + +@@ -703,14 +790,14 @@ static int __mlxsw_linecard_status_process(struct mlxsw_core *mlxsw_core, + + if (!process_provision_only && !linecard->unprovision_done && active && + linecard->active != active && linecard->ready) { +- err = mlxsw_linecard_active_set(mlxsw_core, linecard, ++ err = mlxsw_linecard_active_set(mlxsw_core, linecards, linecard, + hw_revision, ini_version); + if (err) + goto out; + } + + if (!process_provision_only && !active && linecard->active != active) +- mlxsw_linecard_active_clear(linecard); ++ mlxsw_linecard_active_clear(mlxsw_core, linecards, linecard); + + if (!process_provision_only && ready != MLXSW_REG_MDDQ_READY_READY && + linecard->ready) { +@@ -720,7 +807,7 @@ static int __mlxsw_linecard_status_process(struct mlxsw_core *mlxsw_core, + } + + if (!provisioned && linecard->provisioned != provisioned) +- mlxsw_linecard_provision_clear(linecard); ++ mlxsw_linecard_provision_clear(mlxsw_core, linecards, linecard); + + out: + mutex_unlock(&linecard->lock); +@@ -1128,7 +1215,7 @@ static void mlxsw_linecard_pre_fini(struct mlxsw_core *mlxsw_core, + /* Make sure all scheduled events are processed */ + mlxsw_core_flush_owq(); + if (linecard->active) +- mlxsw_linecard_active_clear(linecard); ++ mlxsw_linecard_active_clear(mlxsw_core, linecards, linecard); + } + + static void mlxsw_linecard_fini(struct mlxsw_core *mlxsw_core, +@@ -1287,6 +1374,7 @@ int mlxsw_linecards_init(struct mlxsw_core *mlxsw_core, + linecards->count = slot_count; + linecards->mlxsw_core = mlxsw_core; + linecards->bus_info = bus_info; ++ INIT_LIST_HEAD(&linecards->event_ops_list); + + linecards->wq = alloc_workqueue("mlxsw_linecards", 0, 0); + if (!linecards->wq) { +@@ -1360,6 +1448,7 @@ void mlxsw_linecards_fini(struct mlxsw_core *mlxsw_core, + + if (!linecards) + return; ++ WARN_ON(!list_empty(&linecards->event_ops_list)); + for (i = 0; i < linecards->count; i++) + mlxsw_linecard_fini(mlxsw_core, linecards, i + 1); + mlxsw_linecard_types_fini(linecards); +@@ -1367,4 +1456,37 @@ void mlxsw_linecards_fini(struct mlxsw_core *mlxsw_core, + kfree(linecards); + } + ++int mlxsw_linecards_event_ops_register(struct mlxsw_core *mlxsw_core, ++ struct mlxsw_linecards_event_ops *ops, ++ void *priv) ++{ ++ struct mlxsw_linecards *linecards = mlxsw_core_linecards(mlxsw_core); ++ struct mlxsw_linecards_event_ops_item *item; ++ ++ item = kzalloc(sizeof(*item), GFP_KERNEL); ++ if (!item) ++ return -ENOMEM; ++ item->event_ops = ops; ++ item->priv = priv; ++ list_add_tail(&item->list, &linecards->event_ops_list); ++ return 0; ++} ++EXPORT_SYMBOL(mlxsw_linecards_event_ops_register); ++ ++void mlxsw_linecards_event_ops_unregister(struct mlxsw_core *mlxsw_core, ++ struct mlxsw_linecards_event_ops *ops, ++ void *priv) ++{ ++ struct mlxsw_linecards *linecards = mlxsw_core_linecards(mlxsw_core); ++ struct mlxsw_linecards_event_ops_item *item, *tmp; ++ ++ list_for_each_entry_safe(item, tmp, &linecards->event_ops_list, list) { ++ if (item->event_ops == ops && item->priv == priv) { ++ list_del(&item->list); ++ kfree(item); ++ } ++ } ++} ++EXPORT_SYMBOL(mlxsw_linecards_event_ops_unregister); ++ + MODULE_FIRMWARE(MLXSW_LINECARDS_INI_BUNDLE_FILE); +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0148-mlxsw-core-Add-interfaces-for-line-card-initializati.patch b/platform/mellanox/non-upstream-patches/patches/0148-mlxsw-core-Add-interfaces-for-line-card-initializati.patch new file mode 100644 index 000000000000..f9e7a010e6fc --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0148-mlxsw-core-Add-interfaces-for-line-card-initializati.patch @@ -0,0 +1,133 @@ +From 8d6f7da411b62b4450db1ebb8b687dbc5a386300 Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Mon, 13 Dec 2021 12:54:36 +0000 +Subject: [PATCH] mlxsw: core: Add interfaces for line card initialization and + de-initialization + +Add callback functions for line card cables info initialization and +de-initialization. + +The line card initialization / de-initialization APIs are to be called +when line card is set to active / inactive state by got_active() / +got_inactive() callbacks from line card state machine. +Access to cable info and real number of modules is available only after +line card is activated. + +Signed-off-by: Vadim Pasternak +--- + .../net/ethernet/mellanox/mlxsw/core_env.c | 78 +++++++++++++++++++ + 1 file changed, 78 insertions(+) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c +index c27cd424b..f9c770eec 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c +@@ -1162,6 +1162,77 @@ mlxsw_env_module_event_disable(struct mlxsw_env *mlxsw_env, u8 slot_index) + { + } + ++static void ++mlxsw_env_got_active(struct mlxsw_core *mlxsw_core, u8 slot_index, ++ const struct mlxsw_linecard *linecard, void *priv) ++{ ++ struct mlxsw_env *mlxsw_env = priv; ++ char mgpir_pl[MLXSW_REG_MGPIR_LEN]; ++ int err; ++ ++ mlxsw_reg_mgpir_pack(mgpir_pl, slot_index); ++ err = mlxsw_reg_query(mlxsw_env->core, MLXSW_REG(mgpir), mgpir_pl); ++ if (err) ++ return; ++ ++ mlxsw_reg_mgpir_unpack(mgpir_pl, NULL, NULL, NULL, ++ &mlxsw_env->line_cards[slot_index]->module_count, ++ NULL); ++ mlxsw_env_module_event_enable(mlxsw_env, slot_index); ++} ++ ++static void ++mlxsw_env_got_inactive(struct mlxsw_core *mlxsw_core, u8 slot_index, ++ const struct mlxsw_linecard *linecard, void *priv) ++{ ++ struct mlxsw_env *mlxsw_env = priv; ++ ++ mlxsw_env_module_event_disable(mlxsw_env, slot_index); ++} ++ ++static struct mlxsw_linecards_event_ops mlxsw_env_event_ops = { ++ .got_active = mlxsw_env_got_active, ++ .got_inactive = mlxsw_env_got_inactive, ++}; ++ ++static int mlxsw_env_linecards_register(struct mlxsw_env *mlxsw_env) ++{ ++ struct mlxsw_linecards *linecards = mlxsw_core_linecards(mlxsw_env->core); ++ int err; ++ ++ if (!linecards || !linecards->count) ++ return 0; ++ ++ err = mlxsw_linecards_event_ops_register(mlxsw_env->core, ++ &mlxsw_env_event_ops, ++ mlxsw_env); ++ if (err) ++ goto err_linecards_event_ops_register; ++ ++ return 0; ++ ++err_linecards_event_ops_register: ++ return err; ++} ++ ++static void mlxsw_env_linecards_unregister(struct mlxsw_env *mlxsw_env) ++{ ++ struct mlxsw_linecards *linecards = mlxsw_core_linecards(mlxsw_env->core); ++ int i; ++ ++ if (!linecards || !linecards->count) ++ return; ++ ++ for (i = 1; i <= linecards->count; i++) { ++ if (mlxsw_env->line_cards[i]->module_count) ++ mlxsw_env_got_inactive(mlxsw_env->core, i, NULL, ++ mlxsw_env); ++ } ++ ++ mlxsw_linecards_event_ops_unregister(mlxsw_env->core, ++ &mlxsw_env_event_ops, mlxsw_env); ++} ++ + int mlxsw_env_init(struct mlxsw_core *mlxsw_core, struct mlxsw_env **p_env) + { + u8 module_count, num_of_slots, max_module_count; +@@ -1198,6 +1269,10 @@ int mlxsw_env_init(struct mlxsw_core *mlxsw_core, struct mlxsw_env **p_env) + mutex_init(&env->line_cards_lock); + *p_env = env; + ++ err = mlxsw_env_linecards_register(env); ++ if (err) ++ goto err_linecards_register; ++ + err = mlxsw_env_temp_warn_event_register(mlxsw_core); + if (err) + goto err_temp_warn_event_register; +@@ -1225,6 +1300,8 @@ int mlxsw_env_init(struct mlxsw_core *mlxsw_core, struct mlxsw_env **p_env) + err_module_plug_event_register: + mlxsw_env_temp_warn_event_unregister(env); + err_temp_warn_event_register: ++ mlxsw_env_linecards_unregister(env); ++err_linecards_register: + mutex_destroy(&env->line_cards_lock); + mlxsw_env_line_cards_free(env); + err_mlxsw_env_line_cards_alloc: +@@ -1239,6 +1316,7 @@ void mlxsw_env_fini(struct mlxsw_env *env) + /* Make sure there is no more event work scheduled. */ + mlxsw_core_flush_owq(); + mlxsw_env_temp_warn_event_unregister(env); ++ mlxsw_env_linecards_unregister(env); + mutex_destroy(&env->line_cards_lock); + mlxsw_env_line_cards_free(env); + kfree(env); +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0149-mlxsw-core_thermal-Add-interfaces-for-line-card-init.patch b/platform/mellanox/non-upstream-patches/patches/0149-mlxsw-core_thermal-Add-interfaces-for-line-card-init.patch new file mode 100644 index 000000000000..c64cbb6cbd44 --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0149-mlxsw-core_thermal-Add-interfaces-for-line-card-init.patch @@ -0,0 +1,213 @@ +From 62b2da593b9ee1042b0d65c7b84e9f463497ecd8 Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Wed, 12 May 2021 22:57:39 +0300 +Subject: [PATCH] mlxsw: core_thermal: Add interfaces for line card + initialization and de-initialization + +Add callback functions for line card thermal area initialization and +de-initialization. Each line card is associated with the relevant +thermal area, which may contain thermal zones for cages and gearboxes +found on this line card. + +The line card thermal initialization / de-initialization APIs are to be +called when line card is set to active / inactive state by +got_active() / got_inactive() callbacks from line card state machine. + +For example thermal zone for module #9 located at line card #7 will +have type: +mlxsw-lc7-module9. +And thermal zone for gearbox #2 located at line card #5 will have type: +mlxsw-lc5-gearbox2. + +For now the slot index is always 0 and field 'name' of the structure +'mlxsw_hwmon_dev' is empty. For line card this field is supposed to +be initialized to 'lc#n', when line card in slot #n is enabled. + +Add validation of modules number found on main board in function +mlxsw_thermal_modules_init(). On modular system this counter might be +zero. + +Signed-off-by: Vadim Pasternak +Signed-off-by: Jiri Pirko +--- + .../ethernet/mellanox/mlxsw/core_thermal.c | 129 ++++++++++++++++++ + 1 file changed, 129 insertions(+) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +index e860cade5..88a2f63c8 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +@@ -96,6 +96,7 @@ struct mlxsw_thermal_module { + }; + + struct mlxsw_thermal_area { ++ struct mlxsw_thermal *parent; + struct mlxsw_thermal_module *tz_module_arr; + u8 tz_module_num; + struct mlxsw_thermal_module *tz_gearbox_arr; +@@ -113,6 +114,7 @@ struct mlxsw_thermal { + u8 cooling_levels[MLXSW_THERMAL_MAX_STATE + 1]; + struct mlxsw_thermal_trip trips[MLXSW_THERMAL_NUM_TRIPS]; + struct mlxsw_thermal_area *main; ++ struct mlxsw_thermal_area **linecards; + unsigned int tz_highest_score; + struct thermal_zone_device *tz_highest_dev; + }; +@@ -989,6 +991,126 @@ mlxsw_thermal_gearboxes_fini(struct mlxsw_thermal *thermal, + mlxsw_thermal_gearbox_tz_fini(&area->tz_gearbox_arr[i]); + } + ++static void ++mlxsw_thermal_got_active(struct mlxsw_core *mlxsw_core, u8 slot_index, ++ const struct mlxsw_linecard *linecard, void *priv) ++{ ++ struct mlxsw_env_gearbox_sensors_map map; ++ struct mlxsw_thermal *thermal = priv; ++ struct mlxsw_thermal_area *lc; ++ int err; ++ ++ lc = kzalloc(sizeof(*lc), GFP_KERNEL); ++ if (!lc) ++ return; ++ ++ lc->slot_index = slot_index; ++ lc->parent = thermal; ++ thermal->linecards[slot_index - 1] = lc; ++ err = mlxsw_thermal_modules_init(thermal->bus_info->dev, thermal->core, ++ thermal, lc); ++ if (err) ++ goto err_thermal_linecard_modules_init; ++ ++ err = mlxsw_env_sensor_map_create(thermal->core, thermal->bus_info, ++ linecard->slot_index, &map); ++ if (err) ++ goto err_thermal_linecard_env_sensor_map_create; ++ ++ lc->gearbox_sensor_map = map.sensor_bit_map; ++ lc->tz_gearbox_num = map.sensor_count; ++ lc->tz_gearbox_arr = kcalloc(lc->tz_gearbox_num, sizeof(*lc->tz_gearbox_arr), ++ GFP_KERNEL); ++ if (!lc->tz_gearbox_arr) { ++ err = -ENOMEM; ++ goto err_tz_gearbox_arr_alloc; ++ } ++ ++ err = mlxsw_thermal_gearboxes_init(thermal->bus_info->dev, thermal->core, ++ thermal, lc); ++ if (err) ++ goto err_thermal_linecard_gearboxes_init; ++ ++ return; ++ ++err_thermal_linecard_gearboxes_init: ++ kfree(lc->tz_gearbox_arr); ++err_tz_gearbox_arr_alloc: ++ mlxsw_env_sensor_map_destroy(thermal->bus_info, ++ lc->gearbox_sensor_map); ++err_thermal_linecard_env_sensor_map_create: ++ mlxsw_thermal_modules_fini(thermal, lc); ++err_thermal_linecard_modules_init: ++ kfree(lc); ++ thermal->linecards[slot_index - 1] = NULL; ++} ++ ++static void mlxsw_thermal_got_inactive(struct mlxsw_core *mlxsw_core, u8 slot_index, ++ const struct mlxsw_linecard *linecard, void *priv) ++{ ++ struct mlxsw_thermal *thermal = priv; ++ struct mlxsw_thermal_area *lc = thermal->linecards[slot_index - 1]; ++ ++ mlxsw_thermal_gearboxes_fini(thermal, lc); ++ kfree(lc->tz_gearbox_arr); ++ mlxsw_env_sensor_map_destroy(thermal->bus_info, ++ lc->gearbox_sensor_map); ++ mlxsw_thermal_modules_fini(thermal, lc); ++ kfree(lc); ++ thermal->linecards[slot_index - 1] = NULL; ++} ++ ++static struct mlxsw_linecards_event_ops mlxsw_thermal_event_ops = { ++ .got_active = mlxsw_thermal_got_active, ++ .got_inactive = mlxsw_thermal_got_inactive, ++}; ++ ++static int mlxsw_thermal_linecards_register(struct mlxsw_core *mlxsw_core, ++ struct mlxsw_thermal *thermal) ++{ ++ struct mlxsw_linecards *linecards = mlxsw_core_linecards(mlxsw_core); ++ int err; ++ ++ if (!linecards || !linecards->count) ++ return 0; ++ ++ thermal->linecards = kcalloc(linecards->count, sizeof(*thermal->linecards), ++ GFP_KERNEL); ++ if (!thermal->linecards) ++ return -ENOMEM; ++ ++ err = mlxsw_linecards_event_ops_register(mlxsw_core, ++ &mlxsw_thermal_event_ops, ++ thermal); ++ if (err) ++ goto err_linecards_event_ops_register; ++ ++ return 0; ++ ++err_linecards_event_ops_register: ++ kfree(thermal->linecards); ++ return err; ++} ++ ++static void mlxsw_thermal_linecards_unregister(struct mlxsw_thermal *thermal) ++{ ++ struct mlxsw_linecards *linecards = mlxsw_core_linecards(thermal->core); ++ int i; ++ ++ if (!linecards || !linecards->count) ++ return; ++ ++ for (i = 1; i <= linecards->count; i++) { ++ if (thermal->linecards[i - 1]) ++ mlxsw_thermal_got_inactive(thermal->core, i, NULL, ++ thermal); ++ } ++ ++ mlxsw_linecards_event_ops_unregister(thermal->core, ++ &mlxsw_thermal_event_ops, thermal); ++ kfree(thermal->linecards); ++} ++ + int mlxsw_thermal_init(struct mlxsw_core *core, + const struct mlxsw_bus_info *bus_info, + struct mlxsw_thermal **p_thermal) +@@ -1094,6 +1216,10 @@ int mlxsw_thermal_init(struct mlxsw_core *core, + if (err) + goto err_thermal_gearboxes_init; + ++ err = mlxsw_thermal_linecards_register(core, thermal); ++ if (err) ++ goto err_linecards_register; ++ + err = thermal_zone_device_enable(thermal->tzdev); + if (err) + goto err_thermal_zone_device_enable; +@@ -1102,6 +1228,8 @@ int mlxsw_thermal_init(struct mlxsw_core *core, + return 0; + + err_thermal_zone_device_enable: ++ mlxsw_thermal_linecards_unregister(thermal); ++err_linecards_register: + mlxsw_thermal_gearboxes_fini(thermal, thermal->main); + err_thermal_gearboxes_init: + mlxsw_thermal_gearboxes_main_fini(thermal->main); +@@ -1129,6 +1257,7 @@ void mlxsw_thermal_fini(struct mlxsw_thermal *thermal) + { + int i; + ++ mlxsw_thermal_linecards_unregister(thermal); + mlxsw_thermal_gearboxes_fini(thermal, thermal->main); + mlxsw_thermal_gearboxes_main_fini(thermal->main); + mlxsw_thermal_modules_fini(thermal, thermal->main); +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0150-mlxsw-core_hwmon-Add-interfaces-for-line-card-initia.patch b/platform/mellanox/non-upstream-patches/patches/0150-mlxsw-core_hwmon-Add-interfaces-for-line-card-initia.patch new file mode 100644 index 000000000000..9b9e5133860f --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0150-mlxsw-core_hwmon-Add-interfaces-for-line-card-initia.patch @@ -0,0 +1,235 @@ +From 97f2a14ec9543588b37be8fc54aad9ed13cceec9 Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Wed, 12 May 2021 22:57:42 +0300 +Subject: [PATCH] mlxsw: core_hwmon: Add interfaces for line card + initialization and de-initialization + +Add callback functions for line card 'hwmon' initialization and +de-initialization. Each line card is associated with the relevant +'hwmon' device, which may contain thermal attributes for the cages +and gearboxes found on this line card. + +The line card 'hwmon' initialization / de-initialization APIs are to be +called when line card is set to active / inactive state by +got_active() / got_inactive() callbacks from line card state machine. + +For example cage temperature for module #9 located at line card #7 will +be exposed by utility 'sensors' like: +linecard#07 +front panel 009: +32.0C (crit = +70.0C, emerg = +80.0C) +And temperature for gearbox #3 located at line card #5 will be exposed +like: +linecard#05 +gearbox 003: +41.0C (highest = +41.0C) + +Signed-off-by: Vadim Pasternak +Signed-off-by: Jiri Pirko +--- + .../net/ethernet/mellanox/mlxsw/core_hwmon.c | 137 +++++++++++++++++- + 1 file changed, 134 insertions(+), 3 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c +index 6af23f472..a27146cca 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c +@@ -19,6 +19,7 @@ + #define MLXSW_HWMON_ATTR_PER_SENSOR 3 + #define MLXSW_HWMON_ATTR_PER_MODULE 7 + #define MLXSW_HWMON_ATTR_PER_GEARBOX 4 ++#define MLXSW_HWMON_DEV_NAME_LEN_MAX 16 + + #define MLXSW_HWMON_ATTR_COUNT (MLXSW_HWMON_SENSORS_MAX_COUNT * MLXSW_HWMON_ATTR_PER_SENSOR + \ + MLXSW_HWMON_MODULES_MAX_COUNT * MLXSW_HWMON_ATTR_PER_MODULE + \ +@@ -42,6 +43,7 @@ mlxsw_hwmon_get_attr_index(int index, int count, u16 *gearbox_sensor_map) + } + + struct mlxsw_hwmon_dev { ++ char name[MLXSW_HWMON_DEV_NAME_LEN_MAX]; + struct mlxsw_hwmon *hwmon; + struct device *hwmon_dev; + struct attribute_group group; +@@ -59,6 +61,7 @@ struct mlxsw_hwmon { + struct mlxsw_core *core; + const struct mlxsw_bus_info *bus_info; + struct mlxsw_hwmon_dev *main; ++ struct mlxsw_hwmon_dev **linecards; + }; + + static ssize_t mlxsw_hwmon_temp_show(struct device *dev, +@@ -405,9 +408,14 @@ mlxsw_hwmon_module_temp_label_show(struct device *dev, + { + struct mlxsw_hwmon_attr *mlxsw_hwmon_attr = + container_of(attr, struct mlxsw_hwmon_attr, dev_attr); ++ struct mlxsw_hwmon_dev *mlxsw_hwmon_dev; ++ int index = mlxsw_hwmon_attr->type_index; ++ ++ mlxsw_hwmon_dev = mlxsw_hwmon_attr->mlxsw_hwmon_dev; ++ if (strlen(mlxsw_hwmon_dev->name)) ++ index += 1; + +- return sprintf(buf, "front panel %03u\n", +- mlxsw_hwmon_attr->type_index); ++ return sprintf(buf, "front panel %03u\n", index); + } + + static ssize_t +@@ -691,7 +699,7 @@ static int mlxsw_hwmon_module_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev) + u8 module_sensor_max; + int i, err; + +- mlxsw_reg_mgpir_pack(mgpir_pl, 0); ++ mlxsw_reg_mgpir_pack(mgpir_pl, mlxsw_hwmon_dev->slot_index); + err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mgpir), mgpir_pl); + if (err) + return err; +@@ -819,6 +827,122 @@ mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev, u8 gbox_num) + return 0; + } + ++static void ++mlxsw_hwmon_got_active(struct mlxsw_core *mlxsw_core, u8 slot_index, ++ const struct mlxsw_linecard *linecard, void *priv) ++{ ++ struct mlxsw_hwmon *hwmon = priv; ++ struct device *dev = hwmon->bus_info->dev; ++ struct mlxsw_env_gearbox_sensors_map map; ++ struct mlxsw_hwmon_dev *lc; ++ int err; ++ ++ lc = kzalloc(sizeof(*lc), GFP_KERNEL); ++ if (!lc) ++ return; ++ lc->slot_index = slot_index; ++ lc->hwmon = hwmon; ++ err = mlxsw_hwmon_module_init(lc); ++ if (err) ++ goto err_hwmon_linecard_module_init; ++ ++ err = mlxsw_env_sensor_map_create(hwmon->core, ++ hwmon->bus_info, slot_index, ++ &map); ++ if (err) ++ goto err_hwmon_linecard_env_sensor_map_create; ++ ++ lc->gearbox_sensor_map = map.sensor_bit_map; ++ err = mlxsw_hwmon_gearbox_init(lc, map.sensor_count); ++ if (err) ++ goto err_hwmon_linecard_gearbox_init; ++ ++ lc->groups[0] = &lc->group; ++ lc->group.attrs = lc->attrs; ++ sprintf(lc->name, "%s#%02u", "linecard", slot_index); ++ lc->hwmon_dev = hwmon_device_register_with_groups(dev, (const char *) lc->name, ++ lc, lc->groups); ++ if (IS_ERR(lc->hwmon_dev)) { ++ err = PTR_ERR(lc->hwmon_dev); ++ goto err_hwmon_linecard_register; ++ } ++ hwmon->linecards[slot_index - 1] = lc; ++ ++ return; ++ ++err_hwmon_linecard_register: ++err_hwmon_linecard_gearbox_init: ++ mlxsw_env_sensor_map_destroy(hwmon->bus_info, ++ lc->gearbox_sensor_map); ++err_hwmon_linecard_env_sensor_map_create: ++err_hwmon_linecard_module_init: ++ kfree(lc); ++} ++ ++static void ++mlxsw_hwmon_got_inactive(struct mlxsw_core *mlxsw_core, u8 slot_index, ++ const struct mlxsw_linecard *linecard, void *priv) ++{ ++ struct mlxsw_hwmon *hwmon = priv; ++ struct mlxsw_hwmon_dev *lc = hwmon->linecards[slot_index - 1]; ++ ++ if (lc->hwmon_dev) ++ hwmon_device_unregister(lc->hwmon_dev); ++ mlxsw_env_sensor_map_destroy(hwmon->bus_info, ++ lc->gearbox_sensor_map); ++ kfree(lc); ++ hwmon->linecards[slot_index - 1] = NULL; ++} ++ ++static struct mlxsw_linecards_event_ops mlxsw_hwmon_event_ops = { ++ .got_active = mlxsw_hwmon_got_active, ++ .got_inactive = mlxsw_hwmon_got_inactive, ++}; ++ ++static int mlxsw_hwmon_linecards_register(struct mlxsw_hwmon *hwmon) ++{ ++ struct mlxsw_linecards *linecards = mlxsw_core_linecards(hwmon->core); ++ int err; ++ ++ if (!linecards || !linecards->count) ++ return 0; ++ ++ hwmon->linecards = kcalloc(linecards->count, sizeof(*hwmon->linecards), ++ GFP_KERNEL); ++ if (!hwmon->linecards) ++ return -ENOMEM; ++ ++ err = mlxsw_linecards_event_ops_register(hwmon->core, ++ &mlxsw_hwmon_event_ops, ++ hwmon); ++ if (err) ++ goto err_linecards_event_ops_register; ++ ++ return 0; ++ ++err_linecards_event_ops_register: ++ kfree(hwmon->linecards); ++ return err; ++} ++ ++static void mlxsw_hwmon_linecards_unregister(struct mlxsw_hwmon *hwmon) ++{ ++ struct mlxsw_linecards *linecards = mlxsw_core_linecards(hwmon->core); ++ int i; ++ ++ if (!linecards || !linecards->count) ++ return; ++ ++ for (i = 1; i <= linecards->count; i++) { ++ if (hwmon->linecards[i - 1]) ++ mlxsw_hwmon_got_inactive(hwmon->core, i, NULL, hwmon); ++ } ++ ++ mlxsw_linecards_event_ops_unregister(hwmon->core, ++ &mlxsw_hwmon_event_ops, hwmon); ++ kfree(hwmon->linecards); ++} ++ + int mlxsw_hwmon_init(struct mlxsw_core *mlxsw_core, + const struct mlxsw_bus_info *mlxsw_bus_info, + struct mlxsw_hwmon **p_hwmon) +@@ -872,10 +996,16 @@ int mlxsw_hwmon_init(struct mlxsw_core *mlxsw_core, + goto err_hwmon_register; + } + ++ err = mlxsw_hwmon_linecards_register(mlxsw_hwmon); ++ if (err) ++ goto err_linecards_register; ++ + mlxsw_hwmon->main->hwmon_dev = hwmon_dev; + *p_hwmon = mlxsw_hwmon; + return 0; + ++err_linecards_register: ++ hwmon_device_unregister(mlxsw_hwmon->main->hwmon_dev); + err_hwmon_register: + err_gearbox_init: + mlxsw_hwmon_gearbox_main_fini(mlxsw_hwmon->main); +@@ -891,6 +1021,7 @@ int mlxsw_hwmon_init(struct mlxsw_core *mlxsw_core, + + void mlxsw_hwmon_fini(struct mlxsw_hwmon *mlxsw_hwmon) + { ++ mlxsw_hwmon_linecards_unregister(mlxsw_hwmon); + hwmon_device_unregister(mlxsw_hwmon->main->hwmon_dev); + mlxsw_hwmon_gearbox_main_fini(mlxsw_hwmon->main); + kfree(mlxsw_hwmon->main); +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0151-mlxsw-minimal-Prepare-driver-for-modular-system-supp.patch b/platform/mellanox/non-upstream-patches/patches/0151-mlxsw-minimal-Prepare-driver-for-modular-system-supp.patch new file mode 100644 index 000000000000..dc18597031be --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0151-mlxsw-minimal-Prepare-driver-for-modular-system-supp.patch @@ -0,0 +1,495 @@ +From 37eabf5ec0121c1a5092f48360b3d1208a22e655 Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Thu, 30 Dec 2021 16:02:59 +0000 +Subject: [PATCH] mlxsw: minimal: Prepare driver for modular system support + +As a preparation for line cards support: +- Allocate per line card array according to the queried number of slots + in the system. For each line card, allocate a port mapping array + according to the queried maximum number of ports available in system. + Port mapping array includes port object handle, local port number and + module number. +- Extend port creation APIs with 'slot_index' argument. +- Extend port structure with slot index and module offset for this slot + index. + +For main board, slot will always be set to zero and these APIs will work +as before. For the ports located on line cards, slot should be set to the +physical slot number, where line card is located in modular systems. + +Signed-off-by: Vadim Pasternak +--- + drivers/net/ethernet/mellanox/mlxsw/minimal.c | 293 +++++++++++++++--- + 1 file changed, 242 insertions(+), 51 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/minimal.c b/drivers/net/ethernet/mellanox/mlxsw/minimal.c +index 30925f573..59c5053dc 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/minimal.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/minimal.c +@@ -24,22 +24,40 @@ static const struct mlxsw_fw_rev mlxsw_m_fw_rev = { + .subminor = MLXSW_M_FWREV_SUBMINOR, + }; + ++struct mlxsw_m_line_card; + struct mlxsw_m_port; + + struct mlxsw_m { +- struct mlxsw_m_port **ports; +- int *module_to_port; + struct mlxsw_core *core; + const struct mlxsw_bus_info *bus_info; + u8 base_mac[ETH_ALEN]; + u8 max_ports; ++ u8 max_module_count; /* Maximum number of modules per-slot. */ ++ u8 num_of_slots; /* Including the main board. */ ++ struct mlxsw_m_line_card **line_cards; ++}; ++ ++struct mlxsw_m_port_mapping { ++ struct mlxsw_m_port *port; ++ int module_to_port; ++ u8 module; ++}; ++ ++struct mlxsw_m_line_card { ++ struct mlxsw_m *mlxsw_m; ++ u8 max_ports; ++ u8 module_offset; ++ bool active; ++ struct mlxsw_m_port_mapping port_mapping[]; + }; + + struct mlxsw_m_port { + struct net_device *dev; + struct mlxsw_m *mlxsw_m; +- u8 local_port; ++ u16 local_port; + u8 module; ++ u8 slot_index; ++ u8 module_offset; + }; + + static int mlxsw_m_base_mac_get(struct mlxsw_m *mlxsw_m) +@@ -111,8 +129,8 @@ static int mlxsw_m_get_module_info(struct net_device *netdev, + struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev); + struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core; + +- return mlxsw_env_get_module_info(core, 0, mlxsw_m_port->module, +- modinfo); ++ return mlxsw_env_get_module_info(core, mlxsw_m_port->slot_index, ++ mlxsw_m_port->module, modinfo); + } + + static int +@@ -122,7 +140,8 @@ mlxsw_m_get_module_eeprom(struct net_device *netdev, struct ethtool_eeprom *ee, + struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev); + struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core; + +- return mlxsw_env_get_module_eeprom(netdev, core, 0, ++ return mlxsw_env_get_module_eeprom(netdev, core, ++ mlxsw_m_port->slot_index, + mlxsw_m_port->module, ee, data); + } + +@@ -134,7 +153,8 @@ mlxsw_m_get_module_eeprom_by_page(struct net_device *netdev, + struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev); + struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core; + +- return mlxsw_env_get_module_eeprom_by_page(core, 0, ++ return mlxsw_env_get_module_eeprom_by_page(core, ++ mlxsw_m_port->slot_index, + mlxsw_m_port->module, + page, extack); + } +@@ -144,7 +164,8 @@ static int mlxsw_m_reset(struct net_device *netdev, u32 *flags) + struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev); + struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core; + +- return mlxsw_env_reset_module(netdev, core, 0, mlxsw_m_port->module, ++ return mlxsw_env_reset_module(netdev, core, mlxsw_m_port->slot_index, ++ mlxsw_m_port->module, + flags); + } + +@@ -156,7 +177,8 @@ mlxsw_m_get_module_power_mode(struct net_device *netdev, + struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev); + struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core; + +- return mlxsw_env_get_module_power_mode(core, 0, mlxsw_m_port->module, ++ return mlxsw_env_get_module_power_mode(core, mlxsw_m_port->slot_index, ++ mlxsw_m_port->module, + params, extack); + } + +@@ -168,7 +190,8 @@ mlxsw_m_set_module_power_mode(struct net_device *netdev, + struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev); + struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core; + +- return mlxsw_env_set_module_power_mode(core, 0, mlxsw_m_port->module, ++ return mlxsw_env_set_module_power_mode(core, mlxsw_m_port->slot_index, ++ mlxsw_m_port->module, + params->policy, extack); + } + +@@ -199,19 +222,31 @@ mlxsw_m_port_dev_addr_get(struct mlxsw_m_port *mlxsw_m_port) + * to be such it does not overflow when adding local_port + * value. + */ +- dev->dev_addr[ETH_ALEN - 1] = mlxsw_m_port->module + 1; ++ dev->dev_addr[ETH_ALEN - 1] = mlxsw_m_port->module + 1 + ++ mlxsw_m_port->module_offset; + return 0; + } + ++static struct ++mlxsw_m_port_mapping *mlxsw_m_port_mapping_get(struct mlxsw_m *mlxsw_m, ++ u8 slot_index, u8 local_port) ++{ ++ return &mlxsw_m->line_cards[slot_index]->port_mapping[local_port]; ++} ++ + static int +-mlxsw_m_port_create(struct mlxsw_m *mlxsw_m, u8 local_port, u8 module) ++mlxsw_m_port_create(struct mlxsw_m *mlxsw_m, u8 slot_index, u16 local_port, ++ u8 module) + { ++ struct mlxsw_m_port_mapping *port_mapping; + struct mlxsw_m_port *mlxsw_m_port; + struct net_device *dev; ++ u8 module_offset; + int err; + +- err = mlxsw_core_port_init(mlxsw_m->core, local_port, 0, +- module + 1, false, 0, false, ++ module_offset = mlxsw_m->line_cards[slot_index]->module_offset; ++ err = mlxsw_core_port_init(mlxsw_m->core, local_port, slot_index, ++ module + 1 + module_offset, false, 0, false, + 0, mlxsw_m->base_mac, + sizeof(mlxsw_m->base_mac)); + if (err) { +@@ -233,6 +268,13 @@ mlxsw_m_port_create(struct mlxsw_m *mlxsw_m, u8 local_port, u8 module) + mlxsw_m_port->mlxsw_m = mlxsw_m; + mlxsw_m_port->local_port = local_port; + mlxsw_m_port->module = module; ++ mlxsw_m_port->slot_index = slot_index; ++ /* Add module offset for line card. Offset for main board iz zero. ++ * For line card in slot #n offset is calculated as (#n - 1) ++ * multiplied by maximum modules number, which could be found on a line ++ * card. ++ */ ++ mlxsw_m_port->module_offset = module_offset; + + dev->netdev_ops = &mlxsw_m_port_netdev_ops; + dev->ethtool_ops = &mlxsw_m_port_ethtool_ops; +@@ -245,7 +287,9 @@ mlxsw_m_port_create(struct mlxsw_m *mlxsw_m, u8 local_port, u8 module) + } + + netif_carrier_off(dev); +- mlxsw_m->ports[local_port] = mlxsw_m_port; ++ port_mapping = mlxsw_m_port_mapping_get(mlxsw_m, slot_index, ++ local_port); ++ port_mapping->port = mlxsw_m_port; + err = register_netdev(dev); + if (err) { + dev_err(mlxsw_m->bus_info->dev, "Port %d: Failed to register netdev\n", +@@ -259,7 +303,7 @@ mlxsw_m_port_create(struct mlxsw_m *mlxsw_m, u8 local_port, u8 module) + return 0; + + err_register_netdev: +- mlxsw_m->ports[local_port] = NULL; ++ port_mapping->port = NULL; + err_dev_addr_get: + free_netdev(dev); + err_alloc_etherdev: +@@ -267,72 +311,130 @@ mlxsw_m_port_create(struct mlxsw_m *mlxsw_m, u8 local_port, u8 module) + return err; + } + +-static void mlxsw_m_port_remove(struct mlxsw_m *mlxsw_m, u8 local_port) ++static void mlxsw_m_port_remove(struct mlxsw_m *mlxsw_m, u8 slot_index, ++ u16 local_port) + { +- struct mlxsw_m_port *mlxsw_m_port = mlxsw_m->ports[local_port]; ++ struct mlxsw_m_port_mapping *port_mapping; ++ struct mlxsw_m_port *mlxsw_m_port; + ++ port_mapping = mlxsw_m_port_mapping_get(mlxsw_m, slot_index, ++ local_port); ++ mlxsw_m_port = port_mapping->port; + mlxsw_core_port_clear(mlxsw_m->core, local_port, mlxsw_m); + unregister_netdev(mlxsw_m_port->dev); /* This calls ndo_stop */ +- mlxsw_m->ports[local_port] = NULL; ++ port_mapping->port = NULL; + free_netdev(mlxsw_m_port->dev); + mlxsw_core_port_fini(mlxsw_m->core, local_port); + } + +-static int mlxsw_m_ports_create(struct mlxsw_m *mlxsw_m) ++static int mlxsw_m_port_module_map(struct mlxsw_m *mlxsw_m, u8 slot_index, ++ u16 local_port, u8 module) ++{ ++ struct mlxsw_m_port_mapping *port_mapping; ++ ++ port_mapping = mlxsw_m_port_mapping_get(mlxsw_m, slot_index, ++ local_port); ++ ++ if (WARN_ON_ONCE(port_mapping->module_to_port >= mlxsw_m->max_ports)) ++ return -EINVAL; ++ mlxsw_env_module_port_map(mlxsw_m->core, slot_index, module); ++ port_mapping->module_to_port = local_port; ++ port_mapping->module = module; ++ ++ return 0; ++} ++ ++static void ++mlxsw_m_port_module_unmap(struct mlxsw_m *mlxsw_m, u8 slot_index, ++ struct mlxsw_m_port_mapping *port_mapping) + { ++ port_mapping->module_to_port = -1; ++ mlxsw_env_module_port_unmap(mlxsw_m->core, slot_index, ++ port_mapping->module); ++} ++ ++static int mlxsw_m_ports_create(struct mlxsw_m *mlxsw_m, u8 slot_index) ++{ ++ struct mlxsw_m_port_mapping *port_mapping; ++ struct mlxsw_m_line_card *line_card; + char mgpir_pl[MLXSW_REG_MGPIR_LEN]; + int i, err; + +- mlxsw_reg_mgpir_pack(mgpir_pl, 0); ++ mlxsw_reg_mgpir_pack(mgpir_pl, slot_index); + err = mlxsw_reg_query(mlxsw_m->core, MLXSW_REG(mgpir), mgpir_pl); + if (err) + return err; + ++ line_card = mlxsw_m->line_cards[slot_index]; + mlxsw_reg_mgpir_unpack(mgpir_pl, NULL, NULL, NULL, +- &mlxsw_m->max_ports, NULL); +- if (!mlxsw_m->max_ports) ++ &line_card->max_ports, NULL); ++ if (!line_card->max_ports) + return 0; + +- mlxsw_m->ports = kcalloc(mlxsw_m->max_ports, sizeof(*mlxsw_m->ports), +- GFP_KERNEL); +- if (!mlxsw_m->ports) +- return -ENOMEM; ++ line_card->max_ports += 1; ++ line_card->module_offset = slot_index ? (slot_index - 1) * ++ mlxsw_m->max_module_count : 0; + +- mlxsw_m->module_to_port = kmalloc_array(mlxsw_m->max_ports, sizeof(int), +- GFP_KERNEL); +- if (!mlxsw_m->module_to_port) { +- err = -ENOMEM; +- goto err_module_to_port_alloc; ++ /* Fill out module to local port mapping array */ ++ for (i = 1; i < mlxsw_m->line_cards[slot_index]->max_ports; i++) { ++ err = mlxsw_m_port_module_map(mlxsw_m, slot_index, i + ++ line_card->module_offset, i - 1); ++ if (err) ++ goto err_module_to_port_map; + } + +- /* Create port objects for each entry. */ ++ /* Create port objects for each valid entry */ + for (i = 0; i < mlxsw_m->max_ports; i++) { +- mlxsw_m->module_to_port[i] = i; +- err = mlxsw_m_port_create(mlxsw_m, mlxsw_m->module_to_port[i], i); +- if (err) +- goto err_module_to_port_create; ++ port_mapping = mlxsw_m_port_mapping_get(mlxsw_m, slot_index, ++ i); ++ if (port_mapping->module_to_port > 0) { ++ err = mlxsw_m_port_create(mlxsw_m, slot_index, ++ port_mapping->module_to_port, ++ port_mapping->module); ++ if (err) ++ goto err_module_to_port_create; ++ } + } + + return 0; + + err_module_to_port_create: +- for (i--; i >= 0; i--) +- mlxsw_m_port_remove(mlxsw_m, mlxsw_m->module_to_port[i]); +- kfree(mlxsw_m->module_to_port); +-err_module_to_port_alloc: +- kfree(mlxsw_m->ports); ++ for (i--; i >= 0; i--) { ++ port_mapping = mlxsw_m_port_mapping_get(mlxsw_m, slot_index, ++ i); ++ if (port_mapping->module_to_port > 0) ++ mlxsw_m_port_remove(mlxsw_m, slot_index, ++ port_mapping->module_to_port); ++ } ++ i = mlxsw_m->max_ports; ++err_module_to_port_map: ++ for (i--; i > 0; i--) { ++ port_mapping = mlxsw_m_port_mapping_get(mlxsw_m, slot_index, ++ i); ++ if (port_mapping->module_to_port > 0) ++ mlxsw_m_port_module_unmap(mlxsw_m, slot_index, ++ port_mapping); ++ } + return err; + } + +-static void mlxsw_m_ports_remove(struct mlxsw_m *mlxsw_m) ++static void mlxsw_m_ports_remove(struct mlxsw_m *mlxsw_m, u8 slot_index) + { ++ struct mlxsw_m_port_mapping *port_mapping; ++ u8 module; + int i; + +- for (i = 0; i < mlxsw_m->max_ports; i++) +- mlxsw_m_port_remove(mlxsw_m, mlxsw_m->module_to_port[i]); +- +- kfree(mlxsw_m->module_to_port); +- kfree(mlxsw_m->ports); ++ for (i = 0; i < mlxsw_m->max_ports; i++) { ++ port_mapping = mlxsw_m_port_mapping_get(mlxsw_m, slot_index, ++ i); ++ if (port_mapping->module_to_port > 0) { ++ module = port_mapping->port->module; ++ mlxsw_m_port_remove(mlxsw_m, slot_index, ++ port_mapping->module_to_port); ++ mlxsw_m_port_module_unmap(mlxsw_m, slot_index, ++ port_mapping); ++ } ++ } + } + + static int mlxsw_m_fw_rev_validate(struct mlxsw_m *mlxsw_m) +@@ -353,6 +455,78 @@ static int mlxsw_m_fw_rev_validate(struct mlxsw_m *mlxsw_m) + return -EINVAL; + } + ++static int mlxsw_m_get_peripheral_info(struct mlxsw_m *mlxsw_m) ++{ ++ char mgpir_pl[MLXSW_REG_MGPIR_LEN]; ++ u8 module_count; ++ int err; ++ ++ mlxsw_reg_mgpir_pack(mgpir_pl, 0); ++ err = mlxsw_reg_query(mlxsw_m->core, MLXSW_REG(mgpir), mgpir_pl); ++ if (err) ++ return err; ++ ++ mlxsw_reg_mgpir_unpack(mgpir_pl, NULL, NULL, NULL, &module_count, ++ &mlxsw_m->num_of_slots); ++ /* If the system is modular, get the maximum number of modules per-slot. ++ * Otherwise, get the maximum number of modules on the main board. ++ */ ++ mlxsw_m->max_module_count = mlxsw_m->num_of_slots ? ++ mlxsw_reg_mgpir_max_modules_per_slot_get(mgpir_pl) : ++ module_count; ++ /* Add slot for main board. */ ++ mlxsw_m->num_of_slots += 1; ++ ++ return 0; ++} ++ ++static int mlxsw_env_line_cards_alloc(struct mlxsw_m *mlxsw_m) ++{ ++ unsigned int max_ports = mlxsw_core_max_ports(mlxsw_m->core); ++ struct mlxsw_m_port_mapping *port_mapping; ++ int i, j; ++ ++ mlxsw_m->line_cards = kcalloc(mlxsw_m->num_of_slots, ++ sizeof(*mlxsw_m->line_cards), ++ GFP_KERNEL); ++ if (!mlxsw_m->line_cards) ++ goto err_kcalloc; ++ ++ for (i = 0; i < mlxsw_m->num_of_slots; i++) { ++ mlxsw_m->line_cards[i] = kzalloc(struct_size(mlxsw_m->line_cards[i], ++ port_mapping, max_ports), ++ GFP_KERNEL); ++ if (!mlxsw_m->line_cards[i]) ++ goto kzalloc_err; ++ ++ /* Invalidate the entries of module to local port mapping array */ ++ for (j = 0; j < mlxsw_m->max_ports; j++) { ++ port_mapping = mlxsw_m_port_mapping_get(mlxsw_m, i, j); ++ port_mapping->module_to_port = -1; ++ } ++ } ++ ++ mlxsw_m->max_ports = max_ports; ++ ++ return 0; ++ ++kzalloc_err: ++ for (i--; i >= 0; i--) ++ kfree(mlxsw_m->line_cards[i]); ++err_kcalloc: ++ kfree(mlxsw_m->line_cards); ++ return -ENOMEM; ++} ++ ++static void mlxsw_m_line_cards_free(struct mlxsw_m *mlxsw_m) ++{ ++ int i = mlxsw_m->num_of_slots; ++ ++ for (i--; i >= 0; i--) ++ kfree(mlxsw_m->line_cards[i]); ++ kfree(mlxsw_m->line_cards); ++} ++ + static int mlxsw_m_init(struct mlxsw_core *mlxsw_core, + const struct mlxsw_bus_info *mlxsw_bus_info, + struct netlink_ext_ack *extack) +@@ -367,26 +541,43 @@ static int mlxsw_m_init(struct mlxsw_core *mlxsw_core, + if (err) + return err; + ++ err = mlxsw_m_get_peripheral_info(mlxsw_m); ++ if (err) { ++ dev_err(mlxsw_m->bus_info->dev, "Failed to get peripheral info\n"); ++ return err; ++ } ++ + err = mlxsw_m_base_mac_get(mlxsw_m); + if (err) { + dev_err(mlxsw_m->bus_info->dev, "Failed to get base mac\n"); + return err; + } + +- err = mlxsw_m_ports_create(mlxsw_m); ++ err = mlxsw_env_line_cards_alloc(mlxsw_m); + if (err) { +- dev_err(mlxsw_m->bus_info->dev, "Failed to create ports\n"); ++ dev_err(mlxsw_m->bus_info->dev, "Failed to allocate memory\n"); + return err; + } + ++ err = mlxsw_m_ports_create(mlxsw_m, 0); ++ if (err) { ++ dev_err(mlxsw_m->bus_info->dev, "Failed to create ports\n"); ++ goto err_mlxsw_m_ports_create; ++ } ++ + return 0; ++ ++err_mlxsw_m_ports_create: ++ mlxsw_m_line_cards_free(mlxsw_m); ++ return err; + } + + static void mlxsw_m_fini(struct mlxsw_core *mlxsw_core) + { + struct mlxsw_m *mlxsw_m = mlxsw_core_driver_priv(mlxsw_core); + +- mlxsw_m_ports_remove(mlxsw_m); ++ mlxsw_m_ports_remove(mlxsw_m, 0); ++ mlxsw_m_line_cards_free(mlxsw_m); + } + + static const struct mlxsw_config_profile mlxsw_m_config_profile; +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0152-mlxsw-core-Extend-bus-init-function-with-event-handl.patch b/platform/mellanox/non-upstream-patches/patches/0152-mlxsw-core-Extend-bus-init-function-with-event-handl.patch new file mode 100644 index 000000000000..99c1af62b794 --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0152-mlxsw-core-Extend-bus-init-function-with-event-handl.patch @@ -0,0 +1,90 @@ +From bf88a40c8d0379e1ce8a6cc0a2bf4f935f90307c Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Wed, 15 Dec 2021 08:59:14 +0000 +Subject: [PATCH] mlxsw: core: Extend bus init function with event handler + argument + +The purpose of new argument - is to introduce system event handler for +treating line card activation / deactivation signals on modular system. + +Signed-off-by: Vadim Pasternak +--- + drivers/net/ethernet/mellanox/mlxsw/core.c | 3 ++- + drivers/net/ethernet/mellanox/mlxsw/core.h | 4 +++- + drivers/net/ethernet/mellanox/mlxsw/i2c.c | 3 ++- + drivers/net/ethernet/mellanox/mlxsw/pci.c | 9 ++++++--- + 4 files changed, 13 insertions(+), 6 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c +index 8c1280781..a9bb43837 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core.c +@@ -2005,7 +2005,8 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info, + } + + res = mlxsw_driver->res_query_enabled ? &mlxsw_core->res : NULL; +- err = mlxsw_bus->init(bus_priv, mlxsw_core, mlxsw_driver->profile, res); ++ err = mlxsw_bus->init(bus_priv, mlxsw_core, mlxsw_driver->profile, res, ++ mlxsw_driver->sys_event_handler); + if (err) + goto err_bus_init; + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.h b/drivers/net/ethernet/mellanox/mlxsw/core.h +index 10ea541bb..b09f9013d 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core.h ++++ b/drivers/net/ethernet/mellanox/mlxsw/core.h +@@ -390,6 +390,7 @@ struct mlxsw_driver { + */ + void (*ptp_transmitted)(struct mlxsw_core *mlxsw_core, + struct sk_buff *skb, u8 local_port); ++ void (*sys_event_handler)(struct mlxsw_core *mlxsw_core); + + u8 txhdr_len; + const struct mlxsw_config_profile *profile; +@@ -432,7 +433,8 @@ struct mlxsw_bus { + const char *kind; + int (*init)(void *bus_priv, struct mlxsw_core *mlxsw_core, + const struct mlxsw_config_profile *profile, +- struct mlxsw_res *res); ++ struct mlxsw_res *res, ++ void (*sys_event_handler)(struct mlxsw_core *mlxsw_core)); + void (*fini)(void *bus_priv); + bool (*skb_transmit_busy)(void *bus_priv, + const struct mlxsw_tx_info *tx_info); +diff --git a/drivers/net/ethernet/mellanox/mlxsw/i2c.c b/drivers/net/ethernet/mellanox/mlxsw/i2c.c +index b8a5c0cbb..b75416561 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/i2c.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/i2c.c +@@ -530,7 +530,8 @@ static int mlxsw_i2c_skb_transmit(void *bus_priv, struct sk_buff *skb, + static int + mlxsw_i2c_init(void *bus_priv, struct mlxsw_core *mlxsw_core, + const struct mlxsw_config_profile *profile, +- struct mlxsw_res *res) ++ struct mlxsw_res *res, ++ void (*sys_event_handler)(struct mlxsw_core *mlxsw_core)) + { + struct mlxsw_i2c *mlxsw_i2c = bus_priv; + char *mbox; +diff --git a/drivers/net/ethernet/mellanox/mlxsw/pci.c b/drivers/net/ethernet/mellanox/mlxsw/pci.c +index dbb16ce25..e8e91130c 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/pci.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/pci.c +@@ -1411,9 +1411,12 @@ static void mlxsw_pci_free_irq_vectors(struct mlxsw_pci *mlxsw_pci) + pci_free_irq_vectors(mlxsw_pci->pdev); + } + +-static int mlxsw_pci_init(void *bus_priv, struct mlxsw_core *mlxsw_core, +- const struct mlxsw_config_profile *profile, +- struct mlxsw_res *res) ++static int ++mlxsw_pci_init(void *bus_priv, struct mlxsw_core *mlxsw_core, ++ const struct mlxsw_config_profile *profile, ++ struct mlxsw_res *res, ++ void (*sys_event_handler)(struct mlxsw_core *mlxsw_core)) ++ + { + struct mlxsw_pci *mlxsw_pci = bus_priv; + struct pci_dev *pdev = mlxsw_pci->pdev; +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0153-mlxsw-i2c-Add-support-for-system-events-handling.patch b/platform/mellanox/non-upstream-patches/patches/0153-mlxsw-i2c-Add-support-for-system-events-handling.patch new file mode 100644 index 000000000000..43bda72b4d1e --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0153-mlxsw-i2c-Add-support-for-system-events-handling.patch @@ -0,0 +1,198 @@ +From c5235b3c4a8ab2b758140d75a7422117e917478c Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Sun, 19 Dec 2021 09:12:58 +0000 +Subject: [PATCH] mlxsw: i2c: Add support for system events handling + +Extend i2c bus driver with interrupt handler to support system specific +hotplug events, related to line card state change. +Provide system IRQ line for interrupt handler. Line Id could be +provided through the platform data if available, or could be set to the +default value. +Handler is supposed to be set by "mlxsw" driver through bus driver init() +call. + +Signed-off-by: Vadim Pasternak +--- + drivers/net/ethernet/mellanox/mlxsw/i2c.c | 110 ++++++++++++++++++++++ + 1 file changed, 110 insertions(+) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/i2c.c b/drivers/net/ethernet/mellanox/mlxsw/i2c.c +index b75416561..e5883b4e8 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/i2c.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/i2c.c +@@ -9,6 +9,7 @@ + #include + #include + #include ++#include + #include + + #include "cmd.h" +@@ -51,6 +52,12 @@ + #define MLXSW_I2C_TIMEOUT_MSECS 5000 + #define MLXSW_I2C_MAX_DATA_SIZE 256 + ++#define MLXSW_I2C_WORK_ARMED 1 ++#define MLXSW_I2C_WORK_CLOSED GENMASK(31, 0) ++#define MLXSW_I2C_WORK_DELAY (usecs_to_jiffies(100)) ++#define MLXSW_I2C_DEFAULT_IRQ 17 ++#define MLXSW_I2C_VIRT_SLAVE 0x37 ++ + /** + * struct mlxsw_i2c - device private data: + * @cmd: command attributes; +@@ -64,6 +71,12 @@ + * @bus_info: bus info block; + * @block_size: maximum block size allowed to pass to under layer; + * @status: status to indicate chip reset or in-service update; ++ * @pdata: device platform data; ++ * @dwork_irq: interrupts delayed work queue; ++ * @lock - lock for interrupts sync; ++ * @sys_event_handler: system events handler callback; ++ * @irq: IRQ line number; ++ * @irq_unhandled_count: number of unhandled interrupts; + */ + struct mlxsw_i2c { + struct { +@@ -78,6 +91,12 @@ struct mlxsw_i2c { + struct mlxsw_bus_info bus_info; + u16 block_size; + u8 status; ++ struct mlxreg_core_hotplug_platform_data *pdata; ++ struct delayed_work dwork_irq; ++ spinlock_t lock; /* sync with interrupt */ ++ void (*sys_event_handler)(struct mlxsw_core *mlxsw_core); ++ int irq; ++ atomic_t irq_unhandled_count; + }; + + #define MLXSW_I2C_READ_MSG(_client, _addr_buf, _buf, _len) { \ +@@ -538,6 +557,7 @@ mlxsw_i2c_init(void *bus_priv, struct mlxsw_core *mlxsw_core, + int err; + + mlxsw_i2c->core = mlxsw_core; ++ mlxsw_i2c->sys_event_handler = sys_event_handler; + + mbox = mlxsw_cmd_mbox_alloc(); + if (!mbox) +@@ -568,6 +588,87 @@ static void mlxsw_i2c_fini(void *bus_priv) + mlxsw_i2c->core = NULL; + } + ++static void mlxsw_i2c_work_handler(struct work_struct *work) ++{ ++ struct mlxsw_i2c *mlxsw_i2c; ++ unsigned long flags; ++ ++ mlxsw_i2c = container_of(work, struct mlxsw_i2c, dwork_irq.work); ++ ++ if (atomic_read(&mlxsw_i2c->irq_unhandled_count)) { ++ if (atomic_dec_and_test(&mlxsw_i2c->irq_unhandled_count)) ++ return; ++ } ++ ++ mlxsw_i2c->sys_event_handler(mlxsw_i2c->core); ++ ++ spin_lock_irqsave(&mlxsw_i2c->lock, flags); ++ ++ /* It is possible, that some signals have been inserted, while ++ * interrupts has been masked. In this case such signals could be missed. ++ * In order to handle these signals delayed work is canceled and work task ++ * re-scheduled for immediate execution. It allows to handle missed ++ * signals, if any. In other case work handler just validates that no new ++ * signals have been received during masking. ++ */ ++ cancel_delayed_work(&mlxsw_i2c->dwork_irq); ++ schedule_delayed_work(&mlxsw_i2c->dwork_irq, MLXSW_I2C_WORK_DELAY); ++ ++ spin_unlock_irqrestore(&mlxsw_i2c->lock, flags); ++ ++ if (!atomic_read(&mlxsw_i2c->irq_unhandled_count)) ++ atomic_set(&mlxsw_i2c->irq_unhandled_count, MLXSW_I2C_WORK_ARMED); ++} ++ ++static irqreturn_t mlxsw_i2c_irq_handler(int irq, void *dev) ++{ ++ struct mlxsw_i2c *mlxsw_i2c = (struct mlxsw_i2c *)dev; ++ ++ /* Schedule work task for immediate execution.*/ ++ schedule_delayed_work(&mlxsw_i2c->dwork_irq, 0); ++ ++ return IRQ_NONE; ++} ++ ++static int mlxsw_i2c_event_handler_register(struct mlxsw_i2c *mlxsw_i2c) ++{ ++ int err; ++ ++ /* Initialize interrupt handler if system hotplug driver is reachable ++ * and platform data is available. ++ */ ++ if (!IS_REACHABLE(CONFIG_MLXREG_HOTPLUG)) ++ return 0; ++ ++ if (mlxsw_i2c->pdata && mlxsw_i2c->pdata->irq) ++ mlxsw_i2c->irq = mlxsw_i2c->pdata->irq; ++ ++ if (!mlxsw_i2c->irq) ++ return 0; ++ ++ err = request_irq(mlxsw_i2c->irq, mlxsw_i2c_irq_handler, ++ IRQF_TRIGGER_FALLING | IRQF_SHARED, "mlxsw-i2c", ++ mlxsw_i2c); ++ if (err) { ++ dev_err(mlxsw_i2c->bus_info.dev, "Failed to request irq: %d\n", ++ err); ++ return err; ++ } ++ ++ spin_lock_init(&mlxsw_i2c->lock); ++ INIT_DELAYED_WORK(&mlxsw_i2c->dwork_irq, mlxsw_i2c_work_handler); ++ ++ return 0; ++} ++ ++static void mlxsw_i2c_event_handler_unregister(struct mlxsw_i2c *mlxsw_i2c) ++{ ++ if (!IS_REACHABLE(CONFIG_MLXREG_HOTPLUG) || !mlxsw_i2c->irq) ++ return; ++ cancel_delayed_work_sync(&mlxsw_i2c->dwork_irq); ++ free_irq(mlxsw_i2c->irq, mlxsw_i2c); ++} ++ + static const struct mlxsw_bus mlxsw_i2c_bus = { + .kind = "i2c", + .init = mlxsw_i2c_init, +@@ -662,6 +763,7 @@ static int mlxsw_i2c_probe(struct i2c_client *client, + mlxsw_i2c->bus_info.dev = &client->dev; + mlxsw_i2c->bus_info.low_frequency = true; + mlxsw_i2c->dev = &client->dev; ++ mlxsw_i2c->pdata = client->dev.platform_data; + + err = mlxsw_core_bus_device_register(&mlxsw_i2c->bus_info, + &mlxsw_i2c_bus, mlxsw_i2c, false, +@@ -671,6 +773,12 @@ static int mlxsw_i2c_probe(struct i2c_client *client, + return err; + } + ++ if (client->addr == MLXSW_I2C_VIRT_SLAVE) ++ mlxsw_i2c->irq = MLXSW_I2C_DEFAULT_IRQ; ++ err = mlxsw_i2c_event_handler_register(mlxsw_i2c); ++ if (err) ++ return err; ++ + return 0; + + errout: +@@ -684,6 +792,8 @@ static int mlxsw_i2c_remove(struct i2c_client *client) + { + struct mlxsw_i2c *mlxsw_i2c = i2c_get_clientdata(client); + ++ atomic_set(&mlxsw_i2c->irq_unhandled_count, MLXSW_I2C_WORK_CLOSED); ++ mlxsw_i2c_event_handler_unregister(mlxsw_i2c); + mlxsw_core_bus_device_unregister(mlxsw_i2c->core, false); + mutex_destroy(&mlxsw_i2c->cmd.lock); + +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0154-mlxsw-core-Export-line-card-API.patch b/platform/mellanox/non-upstream-patches/patches/0154-mlxsw-core-Export-line-card-API.patch new file mode 100644 index 000000000000..6500a0db878c --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0154-mlxsw-core-Export-line-card-API.patch @@ -0,0 +1,27 @@ +From 8099c3baf5f819fdf187b67cc3ed0ce25360cf88 Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Sun, 19 Dec 2021 09:31:32 +0000 +Subject: [PATCH] mlxsw: core: Export line card API + +Export API mlxsw_core_linecards() for being used by 'minimal' driver. + +Signed-off-by: Vadim Pasternak +--- + drivers/net/ethernet/mellanox/mlxsw/core.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c +index a9bb43837..a26c6d880 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core.c +@@ -103,6 +103,7 @@ struct mlxsw_linecards *mlxsw_core_linecards(struct mlxsw_core *mlxsw_core) + { + return mlxsw_core->linecards; + } ++EXPORT_SYMBOL(mlxsw_core_linecards); + + #define MLXSW_PORT_MAX_PORTS_DEFAULT 0x40 + +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0155-mlxsw-minimal-Add-system-event-handler.patch b/platform/mellanox/non-upstream-patches/patches/0155-mlxsw-minimal-Add-system-event-handler.patch new file mode 100644 index 000000000000..7bce0a016dfb --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0155-mlxsw-minimal-Add-system-event-handler.patch @@ -0,0 +1,61 @@ +From b526413a86afcd1d6bd3f4e05f25631c8103f617 Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Sun, 19 Dec 2021 09:25:35 +0000 +Subject: [PATCH] mlxsw: minimal: Add system event handler + +Add system event handler for treating line card specific signals on +modular system. These signals indicate line card state changes, like +line card activation or de-activation. +When such signals are received, driver should create or destroy "hwmon" +"thermal" and module info objects, associated with line card in a slot, +for which signal has been received. + +Signed-off-by: Vadim Pasternak +--- + drivers/net/ethernet/mellanox/mlxsw/minimal.c | 23 +++++++++++++++++++ + 1 file changed, 23 insertions(+) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/minimal.c b/drivers/net/ethernet/mellanox/mlxsw/minimal.c +index 59c5053dc..27afb28e4 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/minimal.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/minimal.c +@@ -527,6 +527,28 @@ static void mlxsw_m_line_cards_free(struct mlxsw_m *mlxsw_m) + kfree(mlxsw_m->line_cards); + } + ++static void mlxsw_m_sys_event_handler(struct mlxsw_core *mlxsw_core) ++{ ++ struct mlxsw_linecards *linecards = mlxsw_core_linecards(mlxsw_core); ++ struct mlxsw_m *mlxsw_m = mlxsw_core_driver_priv(mlxsw_core); ++ char mddq_pl[MLXSW_REG_MDDQ_LEN]; ++ int i, err; ++ ++ if (!linecards) ++ return; ++ ++ /* Handle line cards, for which active status has been changed. */ ++ for (i = 1; i <= linecards->count; i++) { ++ mlxsw_reg_mddq_slot_info_pack(mddq_pl, i, false); ++ err = mlxsw_reg_query(mlxsw_m->core, MLXSW_REG(mddq), mddq_pl); ++ if (err) ++ dev_err(mlxsw_m->bus_info->dev, "Fail to query MDDQ register for slot %d\n", ++ i); ++ ++ mlxsw_linecard_status_process(mlxsw_m->core, mddq_pl); ++ } ++} ++ + static int mlxsw_m_init(struct mlxsw_core *mlxsw_core, + const struct mlxsw_bus_info *mlxsw_bus_info, + struct netlink_ext_ack *extack) +@@ -587,6 +609,7 @@ static struct mlxsw_driver mlxsw_m_driver = { + .priv_size = sizeof(struct mlxsw_m), + .init = mlxsw_m_init, + .fini = mlxsw_m_fini, ++ .sys_event_handler = mlxsw_m_sys_event_handler, + .profile = &mlxsw_m_config_profile, + .res_query_enabled = true, + }; +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0156-mlxsw-minimal-Add-interfaces-for-line-card-initializ.patch b/platform/mellanox/non-upstream-patches/patches/0156-mlxsw-minimal-Add-interfaces-for-line-card-initializ.patch new file mode 100644 index 000000000000..6b1049f6d1c1 --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0156-mlxsw-minimal-Add-interfaces-for-line-card-initializ.patch @@ -0,0 +1,119 @@ +From 20b2dd627f42e79a8fce30d29d4cea64f6636521 Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Sun, 19 Dec 2021 09:40:34 +0000 +Subject: [PATCH] mlxsw: minimal: Add interfaces for line card initialization + and de-initialization + +Add callback functions for line card 'netdevice' objects initialization +and de-initialization. Each line card is associated with the set of +'netdevices', which are created/destroyed dynamically, when line card +is getting to active / inactive states. + +Add APIs for line card registration and de-registration during init and +de-init. + +Signed-off-by: Vadim Pasternak +--- + drivers/net/ethernet/mellanox/mlxsw/minimal.c | 70 +++++++++++++++++++ + 1 file changed, 70 insertions(+) + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/minimal.c b/drivers/net/ethernet/mellanox/mlxsw/minimal.c +index 27afb28e4..0b605c6aa 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/minimal.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/minimal.c +@@ -549,6 +549,69 @@ static void mlxsw_m_sys_event_handler(struct mlxsw_core *mlxsw_core) + } + } + ++static void ++mlxsw_m_got_active(struct mlxsw_core *mlxsw_core, u8 slot_index, ++ const struct mlxsw_linecard *linecard, void *priv) ++{ ++ struct mlxsw_m *mlxsw_m = priv; ++ int err; ++ ++ err = mlxsw_m_ports_create(mlxsw_m, slot_index); ++ if (err) { ++ dev_err(mlxsw_m->bus_info->dev, "Failed to set line card at slot %d\n", ++ slot_index); ++ goto mlxsw_m_ports_create_fail; ++ } ++ mlxsw_m->line_cards[slot_index]->active = true; ++ ++mlxsw_m_ports_create_fail: ++ return; ++} ++ ++static void ++mlxsw_m_got_inactive(struct mlxsw_core *mlxsw_core, u8 slot_index, ++ const struct mlxsw_linecard *linecard, void *priv) ++{ ++ struct mlxsw_m *mlxsw_m = priv; ++ ++ mlxsw_m_ports_remove(mlxsw_m, slot_index); ++ mlxsw_m->line_cards[slot_index]->active = false; ++} ++ ++static struct mlxsw_linecards_event_ops mlxsw_m_event_ops = { ++ .got_active = mlxsw_m_got_active, ++ .got_inactive = mlxsw_m_got_inactive, ++}; ++ ++static int mlxsw_m_linecards_register(struct mlxsw_m *mlxsw_m) ++{ ++ struct mlxsw_linecards *linecards = mlxsw_core_linecards(mlxsw_m->core); ++ ++ if (!linecards || !linecards->count) ++ return 0; ++ ++ return mlxsw_linecards_event_ops_register(mlxsw_m->core, ++ &mlxsw_m_event_ops, ++ mlxsw_m); ++} ++ ++static void mlxsw_m_linecards_unregister(struct mlxsw_m *mlxsw_m) ++{ ++ struct mlxsw_linecards *linecards = mlxsw_core_linecards(mlxsw_m->core); ++ int i; ++ ++ if (!linecards || !linecards->count) ++ return; ++ ++ for (i = 1; i <= linecards->count; i++) { ++ if (mlxsw_m->line_cards[i]->active) ++ mlxsw_m_got_inactive(mlxsw_m->core, i, NULL, mlxsw_m); ++ } ++ ++ mlxsw_linecards_event_ops_unregister(mlxsw_m->core, ++ &mlxsw_m_event_ops, mlxsw_m); ++} ++ + static int mlxsw_m_init(struct mlxsw_core *mlxsw_core, + const struct mlxsw_bus_info *mlxsw_bus_info, + struct netlink_ext_ack *extack) +@@ -587,8 +650,14 @@ static int mlxsw_m_init(struct mlxsw_core *mlxsw_core, + goto err_mlxsw_m_ports_create; + } + ++ err = mlxsw_m_linecards_register(mlxsw_m); ++ if (err) ++ goto err_linecards_register; ++ + return 0; + ++err_linecards_register: ++ mlxsw_m_ports_remove(mlxsw_m, 0); + err_mlxsw_m_ports_create: + mlxsw_m_line_cards_free(mlxsw_m); + return err; +@@ -598,6 +667,7 @@ static void mlxsw_m_fini(struct mlxsw_core *mlxsw_core) + { + struct mlxsw_m *mlxsw_m = mlxsw_core_driver_priv(mlxsw_core); + ++ mlxsw_m_linecards_unregister(mlxsw_m); + mlxsw_m_ports_remove(mlxsw_m, 0); + mlxsw_m_line_cards_free(mlxsw_m); + } +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0163-platform-mellanox-Introduce-support-for-rack-manager.patch b/platform/mellanox/non-upstream-patches/patches/0163-platform-mellanox-Introduce-support-for-rack-manager.patch new file mode 100644 index 000000000000..aa9f7fceb42a --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0163-platform-mellanox-Introduce-support-for-rack-manager.patch @@ -0,0 +1,420 @@ +From bb18ddc163092447e40f8aba96140280e2201409 Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Mon, 14 Feb 2022 13:24:44 +0200 +Subject: [PATCH] platform: mellanox: Introduce support for rack manager switch + +The rack switch is designed to provide high bandwidth, low latency +connectivity using optical fiber as the primary interconnect. + +System supports 32 OSFP ports, non-blocking switching capacity of +25.6Tbps. +System equipped with: +- 2 replaceable power supplies (AC) with 1+1 redundancy model. +- 7 replaceable fan drawers with 6+1 redundancy model. +- 2 External Root of Trust or EROT (Glacier) devices for securing + ASICs firmware. + +Signed-off-by: Vadim Pasternak +--- + drivers/platform/x86/mlx-platform.c | 259 ++++++++++++++++++++++++++++ + 1 file changed, 259 insertions(+) + +diff --git a/drivers/platform/x86/mlx-platform.c b/drivers/platform/x86/mlx-platform.c +index d0bb2becf..f1d0cc1aa 100644 +--- a/drivers/platform/x86/mlx-platform.c ++++ b/drivers/platform/x86/mlx-platform.c +@@ -90,6 +90,12 @@ + #define MLXPLAT_CPLD_LPC_REG_FAN_OFFSET 0x88 + #define MLXPLAT_CPLD_LPC_REG_FAN_EVENT_OFFSET 0x89 + #define MLXPLAT_CPLD_LPC_REG_FAN_MASK_OFFSET 0x8a ++#define MLXPLAT_CPLD_LPC_REG_EROT_OFFSET 0x91 ++#define MLXPLAT_CPLD_LPC_REG_EROT_EVENT_OFFSET 0x92 ++#define MLXPLAT_CPLD_LPC_REG_EROT_MASK_OFFSET 0x93 ++#define MLXPLAT_CPLD_LPC_REG_EROTE_OFFSET 0x94 ++#define MLXPLAT_CPLD_LPC_REG_EROTE_EVENT_OFFSET 0x95 ++#define MLXPLAT_CPLD_LPC_REG_EROTE_MASK_OFFSET 0x96 + #define MLXPLAT_CPLD_LPC_REG_LC_VR_OFFSET 0x9a + #define MLXPLAT_CPLD_LPC_REG_LC_VR_EVENT_OFFSET 0x9b + #define MLXPLAT_CPLD_LPC_REG_LC_VR_MASK_OFFSET 0x9c +@@ -109,6 +115,8 @@ + #define MLXPLAT_CPLD_LPC_REG_LC_SD_EVENT_OFFSET 0xaa + #define MLXPLAT_CPLD_LPC_REG_LC_SD_MASK_OFFSET 0xab + #define MLXPLAT_CPLD_LPC_REG_LC_PWR_ON 0xb2 ++#define MLXPLAT_CPLD_LPC_REG_GP4_RO_OFFSET 0xc2 ++#define MLXPLAT_CPLD_LPC_REG_SPI_CHNL_SELECT 0xc3 + #define MLXPLAT_CPLD_LPC_REG_WD_CLEAR_OFFSET 0xc7 + #define MLXPLAT_CPLD_LPC_REG_WD_CLEAR_WP_OFFSET 0xc8 + #define MLXPLAT_CPLD_LPC_REG_WD1_TMR_OFFSET 0xc9 +@@ -214,6 +222,7 @@ + #define MLXPLAT_CPLD_LED_HI_NIBBLE_MASK GENMASK(3, 0) + #define MLXPLAT_CPLD_VOLTREG_UPD_MASK GENMASK(5, 4) + #define MLXPLAT_CPLD_GWP_MASK GENMASK(0, 0) ++#define MLXPLAT_CPLD_EROT_MASK GENMASK(1, 0) + #define MLXPLAT_CPLD_I2C_CAP_BIT 0x04 + #define MLXPLAT_CPLD_I2C_CAP_MASK GENMASK(5, MLXPLAT_CPLD_I2C_CAP_BIT) + +@@ -243,6 +252,7 @@ + #define MLXPLAT_CPLD_CH2_ETH_MODULAR 3 + #define MLXPLAT_CPLD_CH3_ETH_MODULAR 43 + #define MLXPLAT_CPLD_CH4_ETH_MODULAR 51 ++#define MLXPLAT_CPLD_CH2_RACK_SWITCH 18 + + /* Number of LPC attached MUX platform devices */ + #define MLXPLAT_CPLD_LPC_MUX_DEVS 4 +@@ -280,6 +290,9 @@ + /* Minimum power required for turning on Ethernet modular system (WATT) */ + #define MLXPLAT_CPLD_ETH_MODULAR_PWR_MIN 50 + ++/* Default value for PWM control register for rack switch system */ ++#define MLXPLAT_REGMAP_NVSWITCH_PWM_DEFAULT 0xf4 ++ + /* mlxplat_priv - platform private data + * @pdev_i2c - i2c controller platform device + * @pdev_mux - array of mux platform devices +@@ -460,6 +473,36 @@ static struct i2c_mux_reg_platform_data mlxplat_modular_mux_data[] = { + }, + }; + ++/* Platform channels for rack swicth system family */ ++static const int mlxplat_rack_switch_channels[] = { ++ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, ++}; ++ ++/* Platform rack switch mux data */ ++static struct i2c_mux_reg_platform_data mlxplat_rack_switch_mux_data[] = { ++ { ++ .parent = 1, ++ .base_nr = MLXPLAT_CPLD_CH1, ++ .write_only = 1, ++ .reg = (void __iomem *)MLXPLAT_CPLD_LPC_REG1, ++ .reg_size = 1, ++ .idle_in_use = 1, ++ .values = mlxplat_rack_switch_channels, ++ .n_values = ARRAY_SIZE(mlxplat_rack_switch_channels), ++ }, ++ { ++ .parent = 1, ++ .base_nr = MLXPLAT_CPLD_CH2_RACK_SWITCH, ++ .write_only = 1, ++ .reg = (void __iomem *)MLXPLAT_CPLD_LPC_REG2, ++ .reg_size = 1, ++ .idle_in_use = 1, ++ .values = mlxplat_msn21xx_channels, ++ .n_values = ARRAY_SIZE(mlxplat_msn21xx_channels), ++ }, ++ ++}; ++ + /* Platform hotplug devices */ + static struct i2c_board_info mlxplat_mlxcpld_pwr[] = { + { +@@ -2064,6 +2107,97 @@ struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_chassis_blade_data = { + .mask_low = MLXPLAT_CPLD_LOW_AGGR_MASK_LOW, + }; + ++/* Platform hotplug for switch systems family data */ ++static struct mlxreg_core_data mlxplat_mlxcpld_erot_ap_items_data[] = { ++ { ++ .label = "erot1_ap", ++ .reg = MLXPLAT_CPLD_LPC_REG_EROT_OFFSET, ++ .mask = BIT(0), ++ .hpdev.nr = MLXPLAT_CPLD_NR_NONE, ++ }, ++ { ++ .label = "erot2_ap", ++ .reg = MLXPLAT_CPLD_LPC_REG_EROT_OFFSET, ++ .mask = BIT(1), ++ .hpdev.nr = MLXPLAT_CPLD_NR_NONE, ++ }, ++}; ++ ++static struct mlxreg_core_data mlxplat_mlxcpld_erot_error_items_data[] = { ++ { ++ .label = "erot1_error", ++ .reg = MLXPLAT_CPLD_LPC_REG_EROTE_OFFSET, ++ .mask = BIT(0), ++ .hpdev.nr = MLXPLAT_CPLD_NR_NONE, ++ }, ++ { ++ .label = "erot2_error", ++ .reg = MLXPLAT_CPLD_LPC_REG_EROTE_OFFSET, ++ .mask = BIT(1), ++ .hpdev.nr = MLXPLAT_CPLD_NR_NONE, ++ }, ++}; ++ ++static struct mlxreg_core_item mlxplat_mlxcpld_rack_switch_items[] = { ++ { ++ .data = mlxplat_mlxcpld_ext_psu_items_data, ++ .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, ++ .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET, ++ .mask = MLXPLAT_CPLD_PSU_EXT_MASK, ++ .capability = MLXPLAT_CPLD_LPC_REG_PSU_I2C_CAP_OFFSET, ++ .count = ARRAY_SIZE(mlxplat_mlxcpld_ext_psu_items_data), ++ .inversed = 1, ++ .health = false, ++ }, ++ { ++ .data = mlxplat_mlxcpld_ext_pwr_items_data, ++ .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, ++ .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET, ++ .mask = MLXPLAT_CPLD_PWR_EXT_MASK, ++ .capability = MLXPLAT_CPLD_LPC_REG_PSU_I2C_CAP_OFFSET, ++ .count = ARRAY_SIZE(mlxplat_mlxcpld_ext_pwr_items_data), ++ .inversed = 0, ++ .health = false, ++ }, ++ { ++ .data = mlxplat_mlxcpld_default_ng_fan_items_data, ++ .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, ++ .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, ++ .mask = MLXPLAT_CPLD_FAN_NG_MASK, ++ .count = ARRAY_SIZE(mlxplat_mlxcpld_default_ng_fan_items_data), ++ .inversed = 1, ++ .health = false, ++ }, ++ { ++ .data = mlxplat_mlxcpld_erot_ap_items_data, ++ .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, ++ .reg = MLXPLAT_CPLD_LPC_REG_EROT_OFFSET, ++ .mask = MLXPLAT_CPLD_EROT_MASK, ++ .count = ARRAY_SIZE(mlxplat_mlxcpld_erot_ap_items_data), ++ .inversed = 1, ++ .health = false, ++ }, ++ { ++ .data = mlxplat_mlxcpld_erot_error_items_data, ++ .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, ++ .reg = MLXPLAT_CPLD_LPC_REG_EROTE_OFFSET, ++ .mask = MLXPLAT_CPLD_EROT_MASK, ++ .count = ARRAY_SIZE(mlxplat_mlxcpld_erot_error_items_data), ++ .inversed = 1, ++ .health = false, ++ }, ++}; ++ ++static ++struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_rack_switch_data = { ++ .items = mlxplat_mlxcpld_rack_switch_items, ++ .counter = ARRAY_SIZE(mlxplat_mlxcpld_rack_switch_items), ++ .cell = MLXPLAT_CPLD_LPC_REG_AGGR_OFFSET, ++ .mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF | MLXPLAT_CPLD_AGGR_MASK_COMEX, ++ .cell_low = MLXPLAT_CPLD_LPC_REG_AGGRLO_OFFSET, ++ .mask_low = MLXPLAT_CPLD_LOW_AGGR_MASK_LOW, ++}; ++ + /* Platform led default data */ + static struct mlxreg_core_data mlxplat_mlxcpld_default_led_data[] = { + { +@@ -2947,6 +3081,42 @@ static struct mlxreg_core_data mlxplat_mlxcpld_default_ng_regs_io_data[] = { + .mask = GENMASK(7, 0) & ~BIT(2), + .mode = 0444, + }, ++ { ++ .label = "erot1_reset", ++ .reg = MLXPLAT_CPLD_LPC_REG_RESET_GP2_OFFSET, ++ .mask = GENMASK(7, 0) & ~BIT(6), ++ .mode = 0644, ++ }, ++ { ++ .label = "erot2_reset", ++ .reg = MLXPLAT_CPLD_LPC_REG_RESET_GP2_OFFSET, ++ .mask = GENMASK(7, 0) & ~BIT(7), ++ .mode = 0644, ++ }, ++ { ++ .label = "erot1_recovery", ++ .reg = MLXPLAT_CPLD_LPC_REG_PWM_CONTROL_OFFSET, ++ .mask = GENMASK(7, 0) & ~BIT(6), ++ .mode = 0644, ++ }, ++ { ++ .label = "erot2_recovery", ++ .reg = MLXPLAT_CPLD_LPC_REG_PWM_CONTROL_OFFSET, ++ .mask = GENMASK(7, 0) & ~BIT(7), ++ .mode = 0644, ++ }, ++ { ++ .label = "erot1_wp", ++ .reg = MLXPLAT_CPLD_LPC_REG_PWM_CONTROL_OFFSET, ++ .mask = GENMASK(7, 0) & ~BIT(4), ++ .mode = 0644, ++ }, ++ { ++ .label = "erot2_wp", ++ .reg = MLXPLAT_CPLD_LPC_REG_PWM_CONTROL_OFFSET, ++ .mask = GENMASK(7, 0) & ~BIT(5), ++ .mode = 0644, ++ }, + { + .label = "reset_long_pb", + .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, +@@ -3142,6 +3312,25 @@ static struct mlxreg_core_data mlxplat_mlxcpld_default_ng_regs_io_data[] = { + .mask = GENMASK(7, 0) & ~BIT(4), + .mode = 0644, + }, ++ { ++ .label = "erot1_ap_reset", ++ .reg = MLXPLAT_CPLD_LPC_REG_GP4_RO_OFFSET, ++ .mask = GENMASK(7, 0) & ~BIT(0), ++ .mode = 0444, ++ }, ++ { ++ .label = "erot2_ap_reset", ++ .reg = MLXPLAT_CPLD_LPC_REG_GP4_RO_OFFSET, ++ .mask = GENMASK(7, 0) & ~BIT(1), ++ .mode = 0444, ++ }, ++ { ++ .label = "spi_chnl_select", ++ .reg = MLXPLAT_CPLD_LPC_REG_SPI_CHNL_SELECT, ++ .mask = GENMASK(7, 0), ++ .bit = 1, ++ .mode = 0644, ++ }, + { + .label = "config1", + .reg = MLXPLAT_CPLD_LPC_REG_CONFIG1_OFFSET, +@@ -4257,6 +4446,10 @@ static bool mlxplat_mlxcpld_writeable_reg(struct device *dev, unsigned int reg) + case MLXPLAT_CPLD_LPC_REG_PWR_MASK_OFFSET: + case MLXPLAT_CPLD_LPC_REG_FAN_EVENT_OFFSET: + case MLXPLAT_CPLD_LPC_REG_FAN_MASK_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_EROT_EVENT_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_EROT_MASK_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_EROTE_EVENT_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_EROTE_MASK_OFFSET: + case MLXPLAT_CPLD_LPC_REG_AGGRLC_MASK_OFFSET: + case MLXPLAT_CPLD_LPC_REG_LC_IN_EVENT_OFFSET: + case MLXPLAT_CPLD_LPC_REG_LC_IN_MASK_OFFSET: +@@ -4274,6 +4467,8 @@ static bool mlxplat_mlxcpld_writeable_reg(struct device *dev, unsigned int reg) + case MLXPLAT_CPLD_LPC_REG_LC_SD_EVENT_OFFSET: + case MLXPLAT_CPLD_LPC_REG_LC_SD_MASK_OFFSET: + case MLXPLAT_CPLD_LPC_REG_LC_PWR_ON: ++ case MLXPLAT_CPLD_LPC_REG_GP4_RO_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_SPI_CHNL_SELECT: + case MLXPLAT_CPLD_LPC_REG_WD_CLEAR_OFFSET: + case MLXPLAT_CPLD_LPC_REG_WD_CLEAR_WP_OFFSET: + case MLXPLAT_CPLD_LPC_REG_WD1_TMR_OFFSET: +@@ -4358,6 +4553,12 @@ static bool mlxplat_mlxcpld_readable_reg(struct device *dev, unsigned int reg) + case MLXPLAT_CPLD_LPC_REG_FAN_OFFSET: + case MLXPLAT_CPLD_LPC_REG_FAN_EVENT_OFFSET: + case MLXPLAT_CPLD_LPC_REG_FAN_MASK_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_EROT_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_EROT_EVENT_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_EROT_MASK_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_EROTE_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_EROTE_EVENT_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_EROTE_MASK_OFFSET: + case MLXPLAT_CPLD_LPC_REG_AGGRLC_OFFSET: + case MLXPLAT_CPLD_LPC_REG_AGGRLC_MASK_OFFSET: + case MLXPLAT_CPLD_LPC_REG_LC_IN_OFFSET: +@@ -4382,6 +4583,7 @@ static bool mlxplat_mlxcpld_readable_reg(struct device *dev, unsigned int reg) + case MLXPLAT_CPLD_LPC_REG_LC_SD_EVENT_OFFSET: + case MLXPLAT_CPLD_LPC_REG_LC_SD_MASK_OFFSET: + case MLXPLAT_CPLD_LPC_REG_LC_PWR_ON: ++ case MLXPLAT_CPLD_LPC_REG_SPI_CHNL_SELECT: + case MLXPLAT_CPLD_LPC_REG_WD_CLEAR_OFFSET: + case MLXPLAT_CPLD_LPC_REG_WD_CLEAR_WP_OFFSET: + case MLXPLAT_CPLD_LPC_REG_WD1_TMR_OFFSET: +@@ -4492,6 +4694,12 @@ static bool mlxplat_mlxcpld_volatile_reg(struct device *dev, unsigned int reg) + case MLXPLAT_CPLD_LPC_REG_FAN_OFFSET: + case MLXPLAT_CPLD_LPC_REG_FAN_EVENT_OFFSET: + case MLXPLAT_CPLD_LPC_REG_FAN_MASK_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_EROT_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_EROT_EVENT_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_EROT_MASK_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_EROTE_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_EROTE_EVENT_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_EROTE_MASK_OFFSET: + case MLXPLAT_CPLD_LPC_REG_AGGRLC_OFFSET: + case MLXPLAT_CPLD_LPC_REG_AGGRLC_MASK_OFFSET: + case MLXPLAT_CPLD_LPC_REG_LC_IN_OFFSET: +@@ -4516,6 +4724,8 @@ static bool mlxplat_mlxcpld_volatile_reg(struct device *dev, unsigned int reg) + case MLXPLAT_CPLD_LPC_REG_LC_SD_EVENT_OFFSET: + case MLXPLAT_CPLD_LPC_REG_LC_SD_MASK_OFFSET: + case MLXPLAT_CPLD_LPC_REG_LC_PWR_ON: ++ case MLXPLAT_CPLD_LPC_REG_GP4_RO_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_SPI_CHNL_SELECT: + case MLXPLAT_CPLD_LPC_REG_WD2_TMR_OFFSET: + case MLXPLAT_CPLD_LPC_REG_WD2_TLEFT_OFFSET: + case MLXPLAT_CPLD_LPC_REG_WD3_TMR_OFFSET: +@@ -4583,6 +4793,13 @@ static const struct reg_default mlxplat_mlxcpld_regmap_ng400[] = { + { MLXPLAT_CPLD_LPC_REG_WD3_ACT_OFFSET, 0x00 }, + }; + ++static const struct reg_default mlxplat_mlxcpld_regmap_rack_switch[] = { ++ { MLXPLAT_CPLD_LPC_REG_PWM_CONTROL_OFFSET, MLXPLAT_REGMAP_NVSWITCH_PWM_DEFAULT }, ++ { MLXPLAT_CPLD_LPC_REG_WD1_ACT_OFFSET, 0x00 }, ++ { MLXPLAT_CPLD_LPC_REG_WD2_ACT_OFFSET, 0x00 }, ++ { MLXPLAT_CPLD_LPC_REG_WD3_ACT_OFFSET, 0x00 }, ++}; ++ + static const struct reg_default mlxplat_mlxcpld_regmap_eth_modular[] = { + { MLXPLAT_CPLD_LPC_REG_GP2_OFFSET, 0x61 }, + { MLXPLAT_CPLD_LPC_REG_PWM_CONTROL_OFFSET, 0x00 }, +@@ -4676,6 +4893,20 @@ static const struct regmap_config mlxplat_mlxcpld_regmap_config_ng400 = { + .reg_write = mlxplat_mlxcpld_reg_write, + }; + ++static const struct regmap_config mlxplat_mlxcpld_regmap_config_rack_switch = { ++ .reg_bits = 8, ++ .val_bits = 8, ++ .max_register = 255, ++ .cache_type = REGCACHE_FLAT, ++ .writeable_reg = mlxplat_mlxcpld_writeable_reg, ++ .readable_reg = mlxplat_mlxcpld_readable_reg, ++ .volatile_reg = mlxplat_mlxcpld_volatile_reg, ++ .reg_defaults = mlxplat_mlxcpld_regmap_rack_switch, ++ .num_reg_defaults = ARRAY_SIZE(mlxplat_mlxcpld_regmap_rack_switch), ++ .reg_read = mlxplat_mlxcpld_reg_read, ++ .reg_write = mlxplat_mlxcpld_reg_write, ++}; ++ + static const struct regmap_config mlxplat_mlxcpld_regmap_config_eth_modular = { + .reg_bits = 8, + .val_bits = 8, +@@ -4957,6 +5188,27 @@ static int __init mlxplat_dmi_modular_matched(const struct dmi_system_id *dmi) + return 1; + } + ++static int __init mlxplat_dmi_rack_switch_matched(const struct dmi_system_id *dmi) ++{ ++ int i; ++ ++ mlxplat_max_adap_num = MLXPLAT_CPLD_MAX_PHYS_ADAPTER_NUM; ++ mlxplat_mux_num = ARRAY_SIZE(mlxplat_rack_switch_mux_data); ++ mlxplat_mux_data = mlxplat_rack_switch_mux_data; ++ mlxplat_hotplug = &mlxplat_mlxcpld_rack_switch_data; ++ mlxplat_hotplug->deferred_nr = ++ mlxplat_msn21xx_channels[MLXPLAT_CPLD_GRP_CHNL_NUM - 1]; ++ mlxplat_led = &mlxplat_default_ng_led_data; ++ mlxplat_regs_io = &mlxplat_default_ng_regs_io_data; ++ mlxplat_fan = &mlxplat_default_fan_data; ++ for (i = 0; i < ARRAY_SIZE(mlxplat_mlxcpld_wd_set_type2); i++) ++ mlxplat_wd_data[i] = &mlxplat_mlxcpld_wd_set_type2[i]; ++ mlxplat_i2c = &mlxplat_mlxcpld_i2c_ng_data; ++ mlxplat_regmap_config = &mlxplat_mlxcpld_regmap_config_rack_switch; ++ ++ return 1; ++} ++ + static const struct dmi_system_id mlxplat_dmi_table[] __initconst = { + { + .callback = mlxplat_dmi_default_wc_matched, +@@ -5007,6 +5259,13 @@ static const struct dmi_system_id mlxplat_dmi_table[] __initconst = { + DMI_MATCH(DMI_BOARD_NAME, "VMOD0009"), + }, + }, ++ { ++ .callback = mlxplat_dmi_rack_switch_matched, ++ .matches = { ++ DMI_MATCH(DMI_BOARD_NAME, "VMOD0010"), ++ DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "HI142"), ++ }, ++ }, + { + .callback = mlxplat_dmi_ng400_matched, + .matches = { +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0176-platform-mellanox-fix-reset_pwr_converter_fail-attri.patch b/platform/mellanox/non-upstream-patches/patches/0176-platform-mellanox-fix-reset_pwr_converter_fail-attri.patch new file mode 100644 index 000000000000..17d55632e848 --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0176-platform-mellanox-fix-reset_pwr_converter_fail-attri.patch @@ -0,0 +1,30 @@ +From d3b1142ce6c3fbb02c39fc8d2e9f24ecbf466973 Mon Sep 17 00:00:00 2001 +From: Michael Shych +Date: Sun, 4 Sep 2022 10:41:45 +0300 +Subject: [PATCH] platform: mellanox: fix reset_pwr_converter_fail attribute. + +Change incorrect reset_voltmon_upgrade_fail atitribute name to +reset_pwr_converter_fail. + +Signed-off-by: Michael Shych +Reviewed-by: Vadim Pasternak +--- + drivers/platform/x86/mlx-platform.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/platform/x86/mlx-platform.c b/drivers/platform/x86/mlx-platform.c +index f1d0cc1aa..31c5cc10f 100644 +--- a/drivers/platform/x86/mlx-platform.c ++++ b/drivers/platform/x86/mlx-platform.c +@@ -3904,7 +3904,7 @@ static struct mlxreg_core_data mlxplat_mlxcpld_chassis_blade_regs_io_data[] = { + .mode = 0444, + }, + { +- .label = "reset_voltmon_upgrade_fail", ++ .label = "reset_pwr_converter_fail", + .reg = MLXPLAT_CPLD_LPC_REG_RST_CAUSE2_OFFSET, + .mask = GENMASK(7, 0) & ~BIT(0), + .mode = 0444, +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0177-Documentation-ABI-fix-description-of-fix-reset_pwr_c.patch b/platform/mellanox/non-upstream-patches/patches/0177-Documentation-ABI-fix-description-of-fix-reset_pwr_c.patch new file mode 100644 index 000000000000..7fd978b051c4 --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0177-Documentation-ABI-fix-description-of-fix-reset_pwr_c.patch @@ -0,0 +1,38 @@ +From 85ac7ddf15f380460b9e17f0e2c99aa8e476ef3f Mon Sep 17 00:00:00 2001 +From: Michael Shych +Date: Sun, 4 Sep 2022 10:46:01 +0300 +Subject: [PATCH] Documentation/ABI: fix description of fix + reset_pwr_converter_fail attribute. + +Change description of incorrect reset_voltmon_upgrade_fail atitribute +name to reset_pwr_converter_fail. + +Signed-off-by: Michael Shych +Reviewed-by: Vadim Pasternak +--- + Documentation/ABI/stable/sysfs-driver-mlxreg-io | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/Documentation/ABI/stable/sysfs-driver-mlxreg-io b/Documentation/ABI/stable/sysfs-driver-mlxreg-io +index 0913a8daf..ac503e84e 100644 +--- a/Documentation/ABI/stable/sysfs-driver-mlxreg-io ++++ b/Documentation/ABI/stable/sysfs-driver-mlxreg-io +@@ -103,13 +103,13 @@ Description: These files show the system reset cause, as following: power + What: /sys/devices/platform/mlxplat/mlxreg-io/hwmon/hwmon*/reset_comex_pwr_fail + What: /sys/devices/platform/mlxplat/mlxreg-io/hwmon/hwmon*/reset_from_comex + What: /sys/devices/platform/mlxplat/mlxreg-io/hwmon/hwmon*/reset_system +-What: /sys/devices/platform/mlxplat/mlxreg-io/hwmon/hwmon*/reset_voltmon_upgrade_fail ++What: /sys/devices/platform/mlxplat/mlxreg-io/hwmon/hwmon*/reset_pwr_converter_fail + Date: November 2018 + KernelVersion: 5.0 + Contact: Vadim Pasternak + Description: These files show the system reset cause, as following: ComEx + power fail, reset from ComEx, system platform reset, reset +- due to voltage monitor devices upgrade failure, ++ due to power converter devices failure, + Value 1 in file means this is reset cause, 0 - otherwise. + Only one bit could be 1 at the same time, representing only + the last reset cause. +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/patches/0178-platform-mellanox-Introduce-support-for-next-generat.patch b/platform/mellanox/non-upstream-patches/patches/0178-platform-mellanox-Introduce-support-for-next-generat.patch new file mode 100644 index 000000000000..922bc84b746d --- /dev/null +++ b/platform/mellanox/non-upstream-patches/patches/0178-platform-mellanox-Introduce-support-for-next-generat.patch @@ -0,0 +1,295 @@ +From 4c485e6f50001f0ea691b0ce5c0d90a118e8d360 Mon Sep 17 00:00:00 2001 +From: Michael Shych +Date: Sun, 4 Sep 2022 14:03:58 +0300 +Subject: [PATCH] platform: mellanox: Introduce support for next-generation + 800GB/s ethernet switch. + +Introduce support for Nvidia next-generation 800GB/s ethernet switch - SN5600. +SN5600 is 51.2 Tbps Ethernet switch based on Nvidia Spectrum-4 ASIC. +It can provide up to 64x800Gb/s (ETH) full bidirectional bandwidth per port +using PAM-4 modulations. The system supports 64 Belly to Belly 2x4 OSFP cages. +The switch was designed to fit standard 2U racks. + +Features: +- 64 OSFP ports support 800GbE - 10GbE speed. +- Additional 25GbE - 1GbE service port on the front panel. +- Air-cooled with 3 + 1 redundant fan units. +- 1 + 1 redundant 3000W or 3600W PSUs. +- System management board is based on Intel Coffee-lake CPU E-2276 + with secure-boot support. + +Signed-off-by: Michael Shych +Reviewed-by: Vadim Pasternak +--- + drivers/platform/x86/mlx-platform.c | 178 ++++++++++++++++++++++++++++ + 1 file changed, 178 insertions(+) + +diff --git a/drivers/platform/x86/mlx-platform.c b/drivers/platform/x86/mlx-platform.c +index 31c5cc10f..7e9f2a5ab 100644 +--- a/drivers/platform/x86/mlx-platform.c ++++ b/drivers/platform/x86/mlx-platform.c +@@ -253,6 +253,7 @@ + #define MLXPLAT_CPLD_CH3_ETH_MODULAR 43 + #define MLXPLAT_CPLD_CH4_ETH_MODULAR 51 + #define MLXPLAT_CPLD_CH2_RACK_SWITCH 18 ++#define MLXPLAT_CPLD_CH2_NG800 34 + + /* Number of LPC attached MUX platform devices */ + #define MLXPLAT_CPLD_LPC_MUX_DEVS 4 +@@ -503,6 +504,37 @@ static struct i2c_mux_reg_platform_data mlxplat_rack_switch_mux_data[] = { + + }; + ++/* Platform channels for ng800 system family */ ++static const int mlxplat_ng800_channels[] = { ++ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, ++ 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32 ++}; ++ ++/* Platform ng800 mux data */ ++static struct i2c_mux_reg_platform_data mlxplat_ng800_mux_data[] = { ++ { ++ .parent = 1, ++ .base_nr = MLXPLAT_CPLD_CH1, ++ .write_only = 1, ++ .reg = (void __iomem *)MLXPLAT_CPLD_LPC_REG1, ++ .reg_size = 1, ++ .idle_in_use = 1, ++ .values = mlxplat_ng800_channels, ++ .n_values = ARRAY_SIZE(mlxplat_ng800_channels), ++ }, ++ { ++ .parent = 1, ++ .base_nr = MLXPLAT_CPLD_CH2_NG800, ++ .write_only = 1, ++ .reg = (void __iomem *)MLXPLAT_CPLD_LPC_REG2, ++ .reg_size = 1, ++ .idle_in_use = 1, ++ .values = mlxplat_msn21xx_channels, ++ .n_values = ARRAY_SIZE(mlxplat_msn21xx_channels), ++ }, ++ ++}; ++ + /* Platform hotplug devices */ + static struct i2c_board_info mlxplat_mlxcpld_pwr[] = { + { +@@ -522,6 +554,15 @@ static struct i2c_board_info mlxplat_mlxcpld_ext_pwr[] = { + }, + }; + ++static struct i2c_board_info mlxplat_mlxcpld_pwr_ng800[] = { ++ { ++ I2C_BOARD_INFO("dps460", 0x59), ++ }, ++ { ++ I2C_BOARD_INFO("dps460", 0x5a), ++ }, ++}; ++ + static struct i2c_board_info mlxplat_mlxcpld_fan[] = { + { + I2C_BOARD_INFO("24c32", 0x50), +@@ -601,6 +642,23 @@ static struct mlxreg_core_data mlxplat_mlxcpld_default_pwr_wc_items_data[] = { + }, + }; + ++static struct mlxreg_core_data mlxplat_mlxcpld_default_pwr_ng800_items_data[] = { ++ { ++ .label = "pwr1", ++ .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET, ++ .mask = BIT(0), ++ .hpdev.brdinfo = &mlxplat_mlxcpld_pwr_ng800[0], ++ .hpdev.nr = MLXPLAT_CPLD_PSU_MSNXXXX_NR, ++ }, ++ { ++ .label = "pwr2", ++ .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET, ++ .mask = BIT(1), ++ .hpdev.brdinfo = &mlxplat_mlxcpld_pwr_ng800[1], ++ .hpdev.nr = MLXPLAT_CPLD_PSU_MSNXXXX_NR, ++ }, ++}; ++ + static struct mlxreg_core_data mlxplat_mlxcpld_default_fan_items_data[] = { + { + .label = "fan1", +@@ -1224,6 +1282,47 @@ static struct mlxreg_core_item mlxplat_mlxcpld_ext_items[] = { + } + }; + ++static struct mlxreg_core_item mlxplat_mlxcpld_ng800_items[] = { ++ { ++ .data = mlxplat_mlxcpld_default_ng_psu_items_data, ++ .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, ++ .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET, ++ .mask = MLXPLAT_CPLD_PSU_EXT_MASK, ++ .capability = MLXPLAT_CPLD_LPC_REG_PSU_I2C_CAP_OFFSET, ++ .count = ARRAY_SIZE(mlxplat_mlxcpld_default_ng_psu_items_data), ++ .inversed = 1, ++ .health = false, ++ }, ++ { ++ .data = mlxplat_mlxcpld_default_pwr_ng800_items_data, ++ .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, ++ .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET, ++ .mask = MLXPLAT_CPLD_PWR_EXT_MASK, ++ .capability = MLXPLAT_CPLD_LPC_REG_PSU_I2C_CAP_OFFSET, ++ .count = ARRAY_SIZE(mlxplat_mlxcpld_default_pwr_ng800_items_data), ++ .inversed = 0, ++ .health = false, ++ }, ++ { ++ .data = mlxplat_mlxcpld_default_ng_fan_items_data, ++ .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, ++ .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, ++ .mask = MLXPLAT_CPLD_FAN_NG_MASK, ++ .count = ARRAY_SIZE(mlxplat_mlxcpld_default_ng_fan_items_data), ++ .inversed = 1, ++ .health = false, ++ }, ++ { ++ .data = mlxplat_mlxcpld_default_asic_items_data, ++ .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, ++ .reg = MLXPLAT_CPLD_LPC_REG_ASIC_HEALTH_OFFSET, ++ .mask = MLXPLAT_CPLD_ASIC_MASK, ++ .count = ARRAY_SIZE(mlxplat_mlxcpld_default_asic_items_data), ++ .inversed = 0, ++ .health = true, ++ }, ++}; ++ + static + struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_ext_data = { + .items = mlxplat_mlxcpld_ext_items, +@@ -1234,6 +1333,16 @@ struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_ext_data = { + .mask_low = MLXPLAT_CPLD_LOW_AGGR_MASK_LOW | MLXPLAT_CPLD_LOW_AGGR_MASK_ASIC2, + }; + ++static ++struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_ng800_data = { ++ .items = mlxplat_mlxcpld_ng800_items, ++ .counter = ARRAY_SIZE(mlxplat_mlxcpld_ng800_items), ++ .cell = MLXPLAT_CPLD_LPC_REG_AGGR_OFFSET, ++ .mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF | MLXPLAT_CPLD_AGGR_MASK_COMEX, ++ .cell_low = MLXPLAT_CPLD_LPC_REG_AGGRLO_OFFSET, ++ .mask_low = MLXPLAT_CPLD_LOW_AGGR_MASK_LOW | MLXPLAT_CPLD_LOW_AGGR_MASK_ASIC2, ++}; ++ + static struct mlxreg_core_data mlxplat_mlxcpld_modular_pwr_items_data[] = { + { + .label = "pwr1", +@@ -3093,6 +3202,12 @@ static struct mlxreg_core_data mlxplat_mlxcpld_default_ng_regs_io_data[] = { + .mask = GENMASK(7, 0) & ~BIT(7), + .mode = 0644, + }, ++ { ++ .label = "clk_brd_prog_en", ++ .reg = MLXPLAT_CPLD_LPC_REG_PWM_CONTROL_OFFSET, ++ .mask = GENMASK(7, 0) & ~BIT(1), ++ .mode = 0644, ++ }, + { + .label = "erot1_recovery", + .reg = MLXPLAT_CPLD_LPC_REG_PWM_CONTROL_OFFSET, +@@ -3219,6 +3334,12 @@ static struct mlxreg_core_data mlxplat_mlxcpld_default_ng_regs_io_data[] = { + .mask = GENMASK(7, 0) & ~BIT(6), + .mode = 0444, + }, ++ { ++ .label = "reset_ac_ok_fail", ++ .reg = MLXPLAT_CPLD_LPC_REG_RST_CAUSE2_OFFSET, ++ .mask = GENMASK(7, 0) & ~BIT(7), ++ .mode = 0444, ++ }, + { + .label = "psu1_on", + .reg = MLXPLAT_CPLD_LPC_REG_GP1_OFFSET, +@@ -3324,6 +3445,30 @@ static struct mlxreg_core_data mlxplat_mlxcpld_default_ng_regs_io_data[] = { + .mask = GENMASK(7, 0) & ~BIT(1), + .mode = 0444, + }, ++ { ++ .label = "clk_brd1_boot_fail", ++ .reg = MLXPLAT_CPLD_LPC_REG_GP4_RO_OFFSET, ++ .mask = GENMASK(7, 0) & ~BIT(4), ++ .mode = 0444, ++ }, ++ { ++ .label = "clk_brd2_boot_fail", ++ .reg = MLXPLAT_CPLD_LPC_REG_GP4_RO_OFFSET, ++ .mask = GENMASK(7, 0) & ~BIT(5), ++ .mode = 0444, ++ }, ++ { ++ .label = "clk_brd_fail", ++ .reg = MLXPLAT_CPLD_LPC_REG_GP4_RO_OFFSET, ++ .mask = GENMASK(7, 0) & ~BIT(6), ++ .mode = 0444, ++ }, ++ { ++ .label = "asic_pg_fail", ++ .reg = MLXPLAT_CPLD_LPC_REG_GP4_RO_OFFSET, ++ .mask = GENMASK(7, 0) & ~BIT(7), ++ .mode = 0444, ++ }, + { + .label = "spi_chnl_select", + .reg = MLXPLAT_CPLD_LPC_REG_SPI_CHNL_SELECT, +@@ -3621,6 +3766,12 @@ static struct mlxreg_core_data mlxplat_mlxcpld_modular_regs_io_data[] = { + .bit = 5, + .mode = 0444, + }, ++ { ++ .label = "pwr_converter_prog_en", ++ .reg = MLXPLAT_CPLD_LPC_REG_GP0_OFFSET, ++ .mask = GENMASK(7, 0) & ~BIT(0), ++ .mode = 0644, ++ }, + { + .label = "vpd_wp", + .reg = MLXPLAT_CPLD_LPC_REG_GP0_OFFSET, +@@ -5209,6 +5360,27 @@ static int __init mlxplat_dmi_rack_switch_matched(const struct dmi_system_id *dm + return 1; + } + ++static int __init mlxplat_dmi_ng800_matched(const struct dmi_system_id *dmi) ++{ ++ int i; ++ ++ mlxplat_max_adap_num = MLXPLAT_CPLD_MAX_PHYS_ADAPTER_NUM; ++ mlxplat_mux_num = ARRAY_SIZE(mlxplat_ng800_mux_data); ++ mlxplat_mux_data = mlxplat_ng800_mux_data; ++ mlxplat_hotplug = &mlxplat_mlxcpld_ng800_data; ++ mlxplat_hotplug->deferred_nr = ++ mlxplat_msn21xx_channels[MLXPLAT_CPLD_GRP_CHNL_NUM - 1]; ++ mlxplat_led = &mlxplat_default_ng_led_data; ++ mlxplat_regs_io = &mlxplat_default_ng_regs_io_data; ++ mlxplat_fan = &mlxplat_default_fan_data; ++ for (i = 0; i < ARRAY_SIZE(mlxplat_mlxcpld_wd_set_type2); i++) ++ mlxplat_wd_data[i] = &mlxplat_mlxcpld_wd_set_type2[i]; ++ mlxplat_i2c = &mlxplat_mlxcpld_i2c_ng_data; ++ mlxplat_regmap_config = &mlxplat_mlxcpld_regmap_config_ng400; ++ ++ return 1; ++} ++ + static const struct dmi_system_id mlxplat_dmi_table[] __initconst = { + { + .callback = mlxplat_dmi_default_wc_matched, +@@ -5278,6 +5450,12 @@ static const struct dmi_system_id mlxplat_dmi_table[] __initconst = { + DMI_MATCH(DMI_BOARD_NAME, "VMOD0011"), + }, + }, ++ { ++ .callback = mlxplat_dmi_ng800_matched, ++ .matches = { ++ DMI_MATCH(DMI_BOARD_NAME, "VMOD0013"), ++ }, ++ }, + { + .callback = mlxplat_dmi_chassis_blade_matched, + .matches = { +-- +2.30.2 + diff --git a/platform/mellanox/non-upstream-patches/series.patch b/platform/mellanox/non-upstream-patches/series.patch new file mode 100644 index 000000000000..80cb652afb5a --- /dev/null +++ b/platform/mellanox/non-upstream-patches/series.patch @@ -0,0 +1,86 @@ +diff --git a/patch/series b/patch/series +index e86f858..61144ff 100755 +--- a/patch/series ++++ b/patch/series +@@ -155,12 +155,71 @@ kernel-compat-always-include-linux-compat.h-from-net-compat.patch + 0097-hwmon-mlxreg-fan-Support-distinctive-names-per-.patch + 0999-Revert-mlxsw-thermal-Fix-out-of-bounds-memory-a.patch + 0098-mlxsw-i2c-Prevent-transaction-execution-for.patch ++0099-mlxsw-core_hwmon-Fix-variable-names-for-hwmon-attrib.patch ++0100-mlxsw-core_thermal-Rename-labels-according-to-naming.patch ++0101-mlxsw-core_thermal-Remove-obsolete-API-for-query-res.patch ++0102-mlxsw-reg-Add-mgpir_-prefix-to-MGPIR-fields-comments.patch ++0103-mlxsw-core-Remove-unnecessary-asserts.patch ++0104-mlxsw-reg-Extend-MTMP-register-with-new-slot-number-.patch ++0105-mlxsw-reg-Extend-MTBR-register-with-new-slot-number-.patch ++0106-mlxsw-reg-Extend-MCIA-register-with-new-slot-number-.patch ++0107-mlxsw-reg-Extend-MCION-register-with-new-slot-number.patch ++0108-mlxsw-reg-Extend-PMMP-register-with-new-slot-number-.patch ++0109-mlxsw-reg-Extend-MGPIR-register-with-new-slot-fields.patch ++0110-mlxsw-core_env-Pass-slot-index-during-PMAOS-register.patch ++0111-mlxsw-reg-Add-new-field-to-Management-General-Periph.patch ++0112-mlxsw-core-Extend-interfaces-for-cable-info-access-w.patch ++0113-mlxsw-core-Extend-port-module-data-structures-for-li.patch ++0114-mlxsw-core-Move-port-module-events-enablement-to-a-s.patch ++0115-mlxsw-core_hwmon-Split-gearbox-initialization.patch ++0116-mlxsw-core_hwmon-Extend-internal-structures-to-suppo.patch ++0117-mlxsw-core_hwmon-Introduce-slot-parameter-in-hwmon-i.patch ++0118-mlxsw-core_hwmon-Extend-hwmon-device-with-gearbox-ma.patch ++0119-mlxsw-core_thermal-Extend-internal-structures-to-sup.patch ++0120-mlxsw-core_thermal-Split-gearbox-initialization.patch ++0121-mlxsw-core_thermal-Extend-thermal-area-with-gearbox-.patch ++0122-mlxsw-core_thermal-Add-line-card-id-prefix-to-line-c.patch ++0123-mlxsw-core_thermal-Use-exact-name-of-cooling-devices.patch ++0124-mlxsw-core_thermal-Use-common-define-for-thermal-zon.patch ++0125-devlink-add-support-to-create-line-card-and-expose-t.patch ++0126-devlink-implement-line-card-provisioning.patch ++0127-devlink-implement-line-card-active-state.patch ++0128-devlink-add-port-to-line-card-relationship-set.patch ++0129-devlink-introduce-linecard-info-get-message.patch ++0130-devlink-introduce-linecard-info-get-message.patch ++0131-mlxsw-reg-Add-Ports-Mapping-event-Configuration-Regi.patch ++0132-mlxsw-reg-Add-Management-DownStream-Device-Query-Reg.patch ++0133-mlxsw-reg-Add-Management-DownStream-Device-Control-R.patch ++0134-mlxsw-reg-Add-Management-Binary-Code-Transfer-Regist.patch ++0135-mlxsw-core_linecards-Add-line-card-objects-and-imple.patch ++0136-mlxsw-core_linecards-Implement-line-card-activation-.patch ++0137-mlxsw-core-Extend-driver-ops-by-remove-selected-port.patch ++0138-mlxsw-spectrum-Add-port-to-linecard-mapping.patch ++0139-mlxsw-reg-Introduce-Management-Temperature-Extended-.patch ++0140-mlxsw-core-Add-APIs-for-thermal-sensor-mapping.patch ++0141-mlxsw-reg-Add-Management-DownStream-Device-Tunneling.patch ++0142-mlxsw-core_linecards-Probe-devices-for-provisioned-l.patch ++0143-mlxsw-core_linecards-Expose-device-FW-version-over-d.patch ++0144-mlxsw-core-Introduce-flash-update-components.patch ++0145-mlxfw-Get-the-PSID-value-using-op-instead-of-passing.patch ++0146-mlxsw-core_linecards-Implement-line-card-device-flas.patch ++0147-mlxsw-core_linecards-Introduce-ops-for-linecards-sta.patch ++0148-mlxsw-core-Add-interfaces-for-line-card-initializati.patch ++0149-mlxsw-core_thermal-Add-interfaces-for-line-card-init.patch ++0150-mlxsw-core_hwmon-Add-interfaces-for-line-card-initia.patch ++0151-mlxsw-minimal-Prepare-driver-for-modular-system-supp.patch ++0152-mlxsw-core-Extend-bus-init-function-with-event-handl.patch ++0153-mlxsw-i2c-Add-support-for-system-events-handling.patch ++0154-mlxsw-core-Export-line-card-API.patch ++0155-mlxsw-minimal-Add-system-event-handler.patch ++0156-mlxsw-minimal-Add-interfaces-for-line-card-initializ.patch + 0157-platform-x86-mlx-platform-Make-activation-of-some-dr.patch + 0158-platform-x86-mlx-platform-Add-cosmetic-changes-for-a.patch + 0159-mlx-platform-Add-support-for-systems-equipped-with-t.patch + 0160-platform-mellanox-Introduce-support-for-COMe-NVSwitc.patch + 0161-platform-x86-mlx-platform-Add-support-for-new-system.patch + 0162-platform-mellanox-Add-COME-board-revision-register.patch ++0163-platform-mellanox-Introduce-support-for-rack-manager.patch + 0164-hwmon-jc42-Add-support-for-Seiko-Instruments-S-34TS0.patch + 0165-platform-mellanox-mlxreg-io-Add-locking-for-io-opera.patch + 0167-leds-mlxreg-Send-udev-change-event.patch +@@ -168,6 +227,9 @@ kernel-compat-always-include-linux-compat.h-from-net-compat.patch + 0171-platform-mellanox-mlxreg-lc-Fix-cleanup-on-failure-a.patch + 0173-core-Add-support-for-OSFP-transceiver-modules.patch + 0175-hwmon-pmbus-Add-support-for-Infineon-Digital-Multi-p.patch ++0176-platform-mellanox-fix-reset_pwr_converter_fail-attri.patch ++0177-Documentation-ABI-fix-description-of-fix-reset_pwr_c.patch ++0178-platform-mellanox-Introduce-support-for-next-generat.patch + 0180-hwmon-pmbus-Fix-sensors-readouts-for-MPS-Multi-phase.patch + ###-> mellanox_hw_mgmt-end + diff --git a/platform/mellanox/rules.mk b/platform/mellanox/rules.mk index 43aa1829953e..721118ea1699 100644 --- a/platform/mellanox/rules.mk +++ b/platform/mellanox/rules.mk @@ -51,7 +51,7 @@ $(DOCKER_PLATFORM_MONITOR)_DEPENDS += $(APPLIBS) $(SX_COMPLIB) $(SXD_LIBS) $(SX_ # Force the target bootloader for mellanox platforms to grub regardless of arch TARGET_BOOTLOADER = grub -# location for the platform specific external kernel patches tarball -override EXTERNAL_KERNEL_PATCH_TAR := $(BUILD_WORKDIR)/$(PLATFORM_PATH)/non-upstream-patches/patches.tar.gz +# location for the platform specific external kernel patches +override EXTERNAL_KERNEL_PATCH_LOC := $(BUILD_WORKDIR)/$(PLATFORM_PATH)/non-upstream-patches/ export SONIC_BUFFER_MODEL=dynamic diff --git a/platform/mellanox/sdk-src/sx-hash-calc/Makefile b/platform/mellanox/sdk-src/sx-hash-calc/Makefile new file mode 100644 index 000000000000..927d4bc892a7 --- /dev/null +++ b/platform/mellanox/sdk-src/sx-hash-calc/Makefile @@ -0,0 +1,27 @@ +.ONESHELL: +SHELL = /bin/bash + +MAIN_TARGET = sx-hash-calc_1.mlnx.$(MLNX_SDK_DEB_VERSION)_amd64.deb +DERIVED_TARGETS = sx-hash-calc-dbgsym_1.mlnx.$(MLNX_SDK_DEB_VERSION)_amd64.deb +PACKAGE_NAME = sx_hash_calc + +$(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : + # get sources + rm -rf $(PACKAGE_NAME)-$(MLNX_SDK_VERSION)-$(MLNX_SDK_ISSU_VERSION) + + wget -c $(MLNX_SDK_SOURCE_BASE_URL)/$(PACKAGE_NAME)-$(MLNX_SDK_VERSION)-$(MLNX_SDK_ISSU_VERSION).tar.gz -O - | tar -xz + + # build + pushd $(PACKAGE_NAME)-$(MLNX_SDK_VERSION)-$(MLNX_SDK_ISSU_VERSION) + + if [ -f autogen.sh ]; then + ./autogen.sh + fi + + debuild -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) + + popd + + mv $(DERIVED_TARGETS) $* $(DEST)/ + +$(addprefix $(DEST)/, $(DERIVED_TARGETS)): $(DEST)/% : $(DEST)/$(MAIN_TARGET) diff --git a/platform/mellanox/sdk-src/sx-kernel/Makefile b/platform/mellanox/sdk-src/sx-kernel/Makefile index 26ccbd02516a..12256fd4b725 100644 --- a/platform/mellanox/sdk-src/sx-kernel/Makefile +++ b/platform/mellanox/sdk-src/sx-kernel/Makefile @@ -5,6 +5,8 @@ MAIN_TARGET = sx-kernel_1.mlnx.$(MLNX_SDK_DEB_VERSION)_$(CONFIGURED_ARCH).deb DERIVED_TARGETS = sx-kernel-dev_1.mlnx.$(MLNX_SDK_DEB_VERSION)_$(CONFIGURED_ARCH).deb PACKAGE_NAME = sx_kernel +MLNX_SX_KERNEL_GITHUB_URL_BASE = https://github.com/Mellanox/Spectrum-SDK-Drivers/archive/refs/heads + $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # get sources @@ -13,9 +15,15 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : wget -c $(MLNX_SDK_SOURCE_BASE_URL)/$(PACKAGE_NAME)-$(MLNX_SDK_VERSION)-$(MLNX_SDK_ISSU_VERSION).tar.gz -O - | tar -xz pushd sx_kernel-$(MLNX_SDK_VERSION)-$(MLNX_SDK_ISSU_VERSION) else - pushd Switch-SDK-drivers - git reset --hard - git clean -xfd + rm -rf Spectrum-SDK-Drivers-$(MLNX_SDK_VERSION) + wget -c $(MLNX_SX_KERNEL_GITHUB_URL_BASE)/$(MLNX_SDK_VERSION).zip + unzip $(MLNX_SDK_VERSION).zip + rm -rf $(MLNX_SDK_VERSION).zip + + pushd Spectrum-SDK-Drivers-$(MLNX_SDK_VERSION) + ln -s ./sx_scripts/Makefile ./Makefile + ln -s ./sx_scripts/makefile ./makefile + ln -s ./sx_scripts/configure ./configure fi # build diff --git a/platform/mellanox/sdk-src/sx-kernel/Switch-SDK-drivers b/platform/mellanox/sdk-src/sx-kernel/Switch-SDK-drivers deleted file mode 160000 index 17a3b3089c9c..000000000000 --- a/platform/mellanox/sdk-src/sx-kernel/Switch-SDK-drivers +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 17a3b3089c9cbca4a62fc7d2fe0894186b801625 diff --git a/platform/mellanox/sdk.dep b/platform/mellanox/sdk.dep index 08c9f2e7c980..bf4d203eb66d 100644 --- a/platform/mellanox/sdk.dep +++ b/platform/mellanox/sdk.dep @@ -216,6 +216,23 @@ $(WJH_LIBS_DBGSYM)_DEP_FLAGS := $(MLNX_SDK_COMMON_FLAGS_LIST) $(WJH_LIBS_DBGSYM)_DEP_FILES := $(DEP_FILES) endif +# SX_HASH_CALC + +SPATH := $($(SX_HASH_CALC)_SRC_PATH) +DEP_FILES := $(SONIC_COMMON_FILES_LIST) $(PLATFORM_PATH)/sdk.mk $(PLATFORM_PATH)/sdk.dep +DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) +DEP_FILES += $(shell git ls-files -- $(SPATH)) + +$(SX_HASH_CALC)_CACHE_MODE := GIT_CONTENT_SHA +$(SX_HASH_CALC)_DEP_FLAGS := $(MLNX_SDK_COMMON_FLAGS_LIST) +$(SX_HASH_CALC)_DEP_FILES := $(DEP_FILES) + +ifeq ($(SDK_FROM_SRC),y) +$(SX_HASH_CALC_DBGSYM)_CACHE_MODE := GIT_CONTENT_SHA +$(SX_HASH_CALC_DBGSYM)_DEP_FLAGS := $(MLNX_SDK_COMMON_FLAGS_LIST) +$(SX_HASH_CALC_DBGSYM)_DEP_FILES := $(DEP_FILES) +endif + # SX_KERNEL SPATH := $($(SX_KERNEL)_SRC_PATH) diff --git a/platform/mellanox/sdk.mk b/platform/mellanox/sdk.mk index 5c3a42ab02e5..3eec580f1698 100644 --- a/platform/mellanox/sdk.mk +++ b/platform/mellanox/sdk.mk @@ -14,11 +14,12 @@ # See the License for the specific language governing permissions and # limitations under the License. # -MLNX_SDK_BASE_PATH = $(PLATFORM_PATH)/sdk-src/sx-kernel/Switch-SDK-drivers/bin/ -MLNX_SDK_PKG_BASE_PATH = $(MLNX_SDK_BASE_PATH)/$(BLDENV)/$(CONFIGURED_ARCH)/ -MLNX_SDK_VERSION = 4.5.3186 +MLNX_SDK_VERSION = 4.5.4206 MLNX_SDK_ISSU_VERSION = 101 +MLNX_ASSETS_GITHUB_URL = https://github.com/Mellanox/Spectrum-SDK-Drivers-SONiC-Bins +MLNX_SDK_ASSETS_RELEASE_TAG = sdk-$(MLNX_SDK_VERSION)-$(BLDENV)-$(CONFIGURED_ARCH) +MLNX_SDK_ASSETS_URL = $(MLNX_ASSETS_GITHUB_URL)/releases/download/$(MLNX_SDK_ASSETS_RELEASE_TAG) MLNX_SDK_DEB_VERSION = $(subst -,.,$(subst _,.,$(MLNX_SDK_VERSION))) # Place here URL where SDK sources exist @@ -30,19 +31,21 @@ else SDK_FROM_SRC = n endif -export MLNX_SDK_SOURCE_BASE_URL MLNX_SDK_VERSION MLNX_SDK_ISSU_VERSION MLNX_SDK_DEB_VERSION +export MLNX_SDK_SOURCE_BASE_URL MLNX_SDK_VERSION MLNX_SDK_ISSU_VERSION MLNX_SDK_DEB_VERSION MLNX_ASSETS_GITHUB_URL MLNX_SDK_RDEBS += $(APPLIBS) $(IPROUTE2_MLNX) $(SX_COMPLIB) $(SX_EXAMPLES) \ - $(SX_GEN_UTILS) $(SX_SCEW) $(SXD_LIBS) $(WJH_LIBS) $(SX_ACL_HELPER) + $(SX_GEN_UTILS) $(SX_SCEW) $(SXD_LIBS) $(WJH_LIBS) $(SX_ACL_HELPER) \ + $(SX_HASH_CALC) MLNX_SDK_DEBS += $(APPLIBS_DEV) $(IPROUTE2_MLNX_DEV) $(SX_COMPLIB_DEV) \ $(SX_COMPLIB_DEV_STATIC) $(SX_EXAMPLES_DEV) $(SX_GEN_UTILS_DEV) \ $(SX_SCEW_DEV) $(SX_SCEW_DEV_STATIC) $(SXD_LIBS_DEV)\ - $(SXD_LIBS_DEV_STATIC) $(WJH_LIBS_DEV) $(SX_ACL_HELPER_DEV) + $(SXD_LIBS_DEV_STATIC) $(WJH_LIBS_DEV) $(SX_ACL_HELPER_DEV) $(SX_HASH_CALC) MLNX_SDK_DBG_DEBS += $(APPLIBS_DBGSYM) $(IPROUTE2_MLNX_DBGSYM) $(SX_COMPLIB_DBGSYM) \ $(SX_EXAMPLES_DBGSYM) $(SX_GEN_UTILS_DBGSYM) $(SX_SCEW_DBGSYM) \ - $(SXD_LIBS_DBGSYM) $(WJH_LIBS_DBGSYM) $(SX_ACL_HELPER_DBGSYM) + $(SXD_LIBS_DBGSYM) $(WJH_LIBS_DBGSYM) $(SX_ACL_HELPER_DBGSYM) \ + $(SX_HASH_CALC_DBGSYM) APPLIBS = applibs_1.mlnx.$(MLNX_SDK_DEB_VERSION)_$(CONFIGURED_ARCH).deb $(APPLIBS)_SRC_PATH = $(PLATFORM_PATH)/sdk-src/applibs @@ -146,27 +149,34 @@ ifeq ($(SDK_FROM_SRC),y) $(eval $(call add_derived_package,$(WJH_LIBS),$(WJH_LIBS_DBGSYM))) endif +SX_HASH_CALC = sx-hash-calc_1.mlnx.$(MLNX_SDK_DEB_VERSION)_amd64.deb +$(SX_HASH_CALC)_SRC_PATH = $(PLATFORM_PATH)/sdk-src/sx-hash-calc +$(SX_HASH_CALC)_DEPENDS += $(SX_COMPLIB_DEV) $(SXD_LIBS_DEV) $(APPLIBS_DEV) $(SX_GEN_UTILS_DEV) +$(SX_HASH_CALC)_RDEPENDS += $(SX_COMPLIB) $(SXD_LIBS) $(APPLIBS) +SX_HASH_CALC_DBGSYM = sx-hash-calc-dbgsym_1.mlnx.$(MLNX_SDK_DEB_VERSION)_amd64.deb +ifeq ($(SDK_FROM_SRC),y) +$(eval $(call add_derived_package,$(SX_HASH_CALC),$(SX_HASH_CALC_DBGSYM))) +endif + SX_KERNEL = sx-kernel_1.mlnx.$(MLNX_SDK_DEB_VERSION)_$(CONFIGURED_ARCH).deb $(SX_KERNEL)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON) $(SX_KERNEL)_SRC_PATH = $(PLATFORM_PATH)/sdk-src/sx-kernel SX_KERNEL_DEV = sx-kernel-dev_1.mlnx.$(MLNX_SDK_DEB_VERSION)_$(CONFIGURED_ARCH).deb $(eval $(call add_derived_package,$(SX_KERNEL),$(SX_KERNEL_DEV))) -define make_path - $(1)_PATH = $(MLNX_SDK_PKG_BASE_PATH) +define make_url + $(1)_URL = $(MLNX_SDK_ASSETS_URL)/$(1) endef -$(eval $(foreach deb,$(MLNX_SDK_DEBS),$(call make_path,$(deb)))) -$(eval $(foreach deb,$(MLNX_SDK_RDEBS),$(call make_path,$(deb)))) -$(eval $(foreach deb,$(PYTHON_SDK_API) $(SX_KERNEL) $(SX_KERNEL_DEV),$(call make_path,$(deb)))) +$(eval $(foreach deb,$(MLNX_SDK_DEBS) $(MLNX_SDK_RDEBS) $(PYTHON_SDK_API),$(call make_url,$(deb)))) SONIC_MAKE_DEBS += $(SX_KERNEL) ifeq ($(SDK_FROM_SRC), y) SONIC_MAKE_DEBS += $(MLNX_SDK_RDEBS) $(PYTHON_SDK_API) else -SONIC_COPY_DEBS += $(MLNX_SDK_RDEBS) $(PYTHON_SDK_API) +SONIC_ONLINE_DEBS += $(MLNX_SDK_RDEBS) $(PYTHON_SDK_API) endif mlnx-sdk-packages: $(addprefix $(DEBS_PATH)/, $(MLNX_SDK_RDEBS) $(PYTHON_SDK_API) $(SX_KERNEL)) diff --git a/platform/nephos/docker-syncd-nephos/Dockerfile.j2 b/platform/nephos/docker-syncd-nephos/Dockerfile.j2 index 5077db796628..d26abf76a051 100755 --- a/platform/nephos/docker-syncd-nephos/Dockerfile.j2 +++ b/platform/nephos/docker-syncd-nephos/Dockerfile.j2 @@ -2,8 +2,6 @@ FROM docker-config-engine-stretch-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} ARG docker_container_name -RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf - ## Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive diff --git a/platform/p4/docker-sonic-p4/Dockerfile.j2 b/platform/p4/docker-sonic-p4/Dockerfile.j2 index e77781223dc1..80503b910e84 100644 --- a/platform/p4/docker-sonic-p4/Dockerfile.j2 +++ b/platform/p4/docker-sonic-p4/Dockerfile.j2 @@ -1,7 +1,6 @@ FROM docker-config-engine-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} ARG docker_container_name -RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf ## Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive diff --git a/platform/s3ip-sysfs/Makefile b/platform/s3ip-sysfs/Makefile new file mode 100644 index 000000000000..fa562ba235d5 --- /dev/null +++ b/platform/s3ip-sysfs/Makefile @@ -0,0 +1,46 @@ +PWD = $(shell pwd) +SYSFS_OUT_PUT := $(PWD)/build +sysfs_out_put_dir := $(SYSFS_OUT_PUT)/S3IP_sysfs/ +export sysfs_out_put_dir +KERNEL_SRC=/lib/modules/$(shell uname -r) +export KERNEL_SRC + +SYSFS_DRIVER_DIR = $(PWD)/s3ip_sysfs_frame +SWITCH_DRIVER_DIR = $(PWD)/demo_driver + +KBUILD_EXTRA_SYMBOLS += $(SYSFS_DRIVER_DIR)/Module.symvers +KBUILD_EXTRA_SYMBOLS += $(SWITCH_DRIVER_DIR)/Module.symvers +export KBUILD_EXTRA_SYMBOLS + +all : + $(MAKE) -C $(SYSFS_DRIVER_DIR) + $(MAKE) -C $(SWITCH_DRIVER_DIR) + +clean : + -rm -rf $(SYSFS_OUT_PUT) + $(MAKE) -C $(SYSFS_DRIVER_DIR) clean + $(MAKE) -C $(SWITCH_DRIVER_DIR) clean + + + +install: + install -d $(DESTDIR)/lib/modules/s3ip/ + install -D $(sysfs_out_put_dir)/*.ko \ + $(DESTDIR)/lib/modules/s3ip/ + install -D scripts/s3ip_load.py \ + $(DESTDIR)/$(prefix)/bin/s3ip_load.py + install -D scripts/s3ip_sysfs_conf.json \ + $(DESTDIR)/etc/s3ip/s3ip_sysfs_conf.json + install -D scripts/s3ip_sysfs_tool.sh \ + $(DESTDIR)/$(prefix)/bin/s3ip_sysfs_tool.sh + install -D scripts/s3ip-sysfs.service \ + $(DESTDIR)/etc/systemd/system/s3ip-sysfs.service + + +uninstall: + -rm -f $(DESTDIR)$(prefix)/bin/s3ip_load.py + -rm -f $(DESTDIR)/lib/modules/s3ip/ + -rm -f $(DESTDIR)/etc/s3ip + -rm -f $(DESTDIR)/$(prefix)/bin/s3ip_sysfs_tool.sh + -rm -f $(DESTDIR)/etc/systemd/system/s3ip-sysfs.service + diff --git a/platform/s3ip-sysfs/build.sh b/platform/s3ip-sysfs/build.sh new file mode 100755 index 000000000000..d72369ea50a1 --- /dev/null +++ b/platform/s3ip-sysfs/build.sh @@ -0,0 +1,3 @@ +#! /bin/bash + +dpkg-buildpackage -rfakeroot -b -us -uc diff --git a/platform/s3ip-sysfs/debian/.debhelper/generated/s3ip-sysfs/installed-by-dh_installdocs b/platform/s3ip-sysfs/debian/.debhelper/generated/s3ip-sysfs/installed-by-dh_installdocs new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/platform/s3ip-sysfs/debian/README.Debian b/platform/s3ip-sysfs/debian/README.Debian new file mode 100755 index 000000000000..0a2ca471ac20 --- /dev/null +++ b/platform/s3ip-sysfs/debian/README.Debian @@ -0,0 +1,8 @@ +s3ip-sysfs for Debian + +Please edit this to provide information specific to +this libkbc Debian package. + + (Automatically generated by debmake Version 4.2.9) + + -- ubuntu Mon, 07 Sep 2020 20:06:06 +0800 diff --git a/platform/s3ip-sysfs/debian/changelog b/platform/s3ip-sysfs/debian/changelog new file mode 100755 index 000000000000..6f6762dd2262 --- /dev/null +++ b/platform/s3ip-sysfs/debian/changelog @@ -0,0 +1,6 @@ +s3ip-sysfs (1.0.0) unstable; urgency=medium + + * Initial release. + + -- shangfei tian Wed, 09 Sep 2021 12:00:00 -0800 + diff --git a/platform/s3ip-sysfs/debian/compat b/platform/s3ip-sysfs/debian/compat new file mode 100755 index 000000000000..ec635144f600 --- /dev/null +++ b/platform/s3ip-sysfs/debian/compat @@ -0,0 +1 @@ +9 diff --git a/platform/s3ip-sysfs/debian/control b/platform/s3ip-sysfs/debian/control new file mode 100755 index 000000000000..9b1d90ed1cfd --- /dev/null +++ b/platform/s3ip-sysfs/debian/control @@ -0,0 +1,14 @@ +Source: s3ip-sysfs +Maintainer: timsftian +Section: libs +Priority: optional +Build-Depends: dh-exec (>=0.3),debhelper (>= 8.0.0), autotools-dev +Standards-Version: 3.9.3 +Homepage: https://tencent.com + +Package: s3ip-sysfs +Architecture: any +Section: libdevel +Depends: ${misc:Depends} +Description: This package contains development files for s3ip sysfs + diff --git a/platform/s3ip-sysfs/debian/copyright b/platform/s3ip-sysfs/debian/copyright new file mode 100755 index 000000000000..0cf1e83c5a65 --- /dev/null +++ b/platform/s3ip-sysfs/debian/copyright @@ -0,0 +1,13 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: s3ip-sysfs +Source: +# +# Please double check copyright with the licensecheck(1) command. + +Files: Makefile +Copyright: __NO_COPYRIGHT_NOR_LICENSE__ +License: __NO_COPYRIGHT_NOR_LICENSE__ + +#---------------------------------------------------------------------------- +# Files marked as NO_LICENSE_TEXT_FOUND may be covered by the following +# license/copyright files. diff --git a/platform/s3ip-sysfs/debian/files b/platform/s3ip-sysfs/debian/files new file mode 100644 index 000000000000..b1b2585c4365 --- /dev/null +++ b/platform/s3ip-sysfs/debian/files @@ -0,0 +1,2 @@ +s3ip-sysfs_1.0.0_amd64.buildinfo libs optional +s3ip-sysfs_1.0.0_amd64.deb libdevel optional diff --git a/platform/s3ip-sysfs/debian/rules b/platform/s3ip-sysfs/debian/rules new file mode 100755 index 000000000000..86f77f3211c7 --- /dev/null +++ b/platform/s3ip-sysfs/debian/rules @@ -0,0 +1,17 @@ +#!/usr/bin/make -f +# You must remove unused comment lines for the released package. +#export DH_VERBOSE = 1 + +#export DEB_BUILD_MAINT_OPTIONS = hardening=+all +#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic +#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed + +%: + dh $@ + +override_dh_auto_install: + dh_auto_install -- prefix=/usr + +override_dh_shlibdeps: + +override_dh_installmodules: diff --git a/platform/s3ip-sysfs/debian/s3ip-sysfs.postinst b/platform/s3ip-sysfs/debian/s3ip-sysfs.postinst new file mode 100644 index 000000000000..a57c5a76865c --- /dev/null +++ b/platform/s3ip-sysfs/debian/s3ip-sysfs.postinst @@ -0,0 +1,3 @@ +systemctl daemon-reload +systemctl start s3ip-sysfs +systemctl enable s3ip-sysfs diff --git a/platform/s3ip-sysfs/debian/s3ip-sysfs.prerm b/platform/s3ip-sysfs/debian/s3ip-sysfs.prerm new file mode 100644 index 000000000000..3e6b2b5180ea --- /dev/null +++ b/platform/s3ip-sysfs/debian/s3ip-sysfs.prerm @@ -0,0 +1,2 @@ +systemctl stop s3ip-sysfs +systemctl disable s3ip-sysfs diff --git a/platform/s3ip-sysfs/debian/s3ip-sysfs.substvars b/platform/s3ip-sysfs/debian/s3ip-sysfs.substvars new file mode 100644 index 000000000000..978fc8b5a0eb --- /dev/null +++ b/platform/s3ip-sysfs/debian/s3ip-sysfs.substvars @@ -0,0 +1,2 @@ +misc:Depends= +misc:Pre-Depends= diff --git a/platform/s3ip-sysfs/debian/watch b/platform/s3ip-sysfs/debian/watch new file mode 100755 index 000000000000..33435127f6c8 --- /dev/null +++ b/platform/s3ip-sysfs/debian/watch @@ -0,0 +1,2 @@ +# You must remove unused comment lines for the released package. +#version=3 diff --git a/platform/s3ip-sysfs/demo_driver/Makefile b/platform/s3ip-sysfs/demo_driver/Makefile new file mode 100644 index 000000000000..2d565cef50c5 --- /dev/null +++ b/platform/s3ip-sysfs/demo_driver/Makefile @@ -0,0 +1,33 @@ +PWD = $(shell pwd) + +MAKEFILE_FILE_PATH = $(abspath $(lastword $(MAKEFILE_LIST))) +DEV_SYSFS_HEADER_DIR = $(abspath $(MAKEFILE_FILE_PATH)/../../s3ip_sysfs_frame/include) +SWITCH_DVR_HEADER_DIR = $(abspath $(MAKEFILE_FILE_PATH)/../../s3ip_sysfs_frame/include) +EXTRA_CFLAGS:= -I$(M)/include +EXTRA_CFLAGS+= -I$(DEV_SYSFS_HEADER_DIR) +EXTRA_CFLAGS+= -I$(SWITCH_DVR_HEADER_DIR) +EXTRA_CFLAGS+= -Wall + +obj-m := syseeprom_device_driver.o +obj-m += fan_device_driver.o +obj-m += cpld_device_driver.o +obj-m += sysled_device_driver.o +obj-m += slot_device_driver.o +obj-m += psu_device_driver.o +obj-m += transceiver_device_driver.o +obj-m += temp_sensor_device_driver.o +obj-m += vol_sensor_device_driver.o +obj-m += curr_sensor_device_driver.o +obj-m += fpga_device_driver.o +obj-m += watchdog_device_driver.o + + +all: + $(MAKE) -C $(KERNEL_SRC)/build M=$(PWD) modules + @if [ ! -d $(sysfs_out_put_dir) ]; then mkdir -p $(sysfs_out_put_dir) ;fi + cp -p $(PWD)/*.ko $(sysfs_out_put_dir) +clean: + rm -f $(PWD)/*.o $(PWD)/*.ko $(PWD)/*.mod.c $(PWD)/.*.cmd + rm -f $(PWD)/Module.markers $(PWD)/Module.symvers $(PWD)/modules.order + rm -rf $(PWD)/.tmp_versions + rm -rf $(PWD)/.cache.mk \ No newline at end of file diff --git a/platform/s3ip-sysfs/demo_driver/cpld_device_driver.c b/platform/s3ip-sysfs/demo_driver/cpld_device_driver.c new file mode 100644 index 000000000000..db28c13e1e67 --- /dev/null +++ b/platform/s3ip-sysfs/demo_driver/cpld_device_driver.c @@ -0,0 +1,168 @@ +/* + * cpld_device_driver.c + * + * This module realize /sys/s3ip/cpld attributes read and write functions + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "device_driver_common.h" +#include "cpld_sysfs.h" + +#define CPLD_INFO(fmt, args...) LOG_INFO("cpld: ", fmt, ##args) +#define CPLD_ERR(fmt, args...) LOG_ERR("cpld: ", fmt, ##args) +#define CPLD_DBG(fmt, args...) LOG_DBG("cpld: ", fmt, ##args) + +static int g_loglevel = 0; + +/******************************************CPLD***********************************************/ +static int demo_get_main_board_cpld_number(void) +{ + /* add vendor codes here */ + return 1; +} + +/* + * demo_get_main_board_cpld_alias - Used to identify the location of cpld, + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_main_board_cpld_alias(unsigned int cpld_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_main_board_cpld_type - Used to get cpld model name + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_main_board_cpld_type(unsigned int cpld_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_main_board_cpld_firmware_version - Used to get cpld firmware version, + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_main_board_cpld_firmware_version(unsigned int cpld_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_main_board_cpld_board_version - Used to get cpld board version, + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_main_board_cpld_board_version(unsigned int cpld_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_main_board_cpld_test_reg - Used to test cpld register read + * filled the value to buf, value is hexadecimal, start with 0x + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_main_board_cpld_test_reg(unsigned int cpld_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_set_main_board_cpld_test_reg - Used to test cpld register write + * @cpld_index: start with 1 + * @value: value write to cpld + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int demo_set_main_board_cpld_test_reg(unsigned int cpld_index, unsigned int value) +{ + /* add vendor codes here */ + return -ENOSYS; +} +/***************************************end of CPLD*******************************************/ + +static struct s3ip_sysfs_cpld_drivers_s drivers = { + /* + * set ODM CPLD drivers to /sys/s3ip/cpld, + * if not support the function, set corresponding hook to NULL. + */ + .get_main_board_cpld_number = demo_get_main_board_cpld_number, + .get_main_board_cpld_alias = demo_get_main_board_cpld_alias, + .get_main_board_cpld_type = demo_get_main_board_cpld_type, + .get_main_board_cpld_firmware_version = demo_get_main_board_cpld_firmware_version, + .get_main_board_cpld_board_version = demo_get_main_board_cpld_board_version, + .get_main_board_cpld_test_reg = demo_get_main_board_cpld_test_reg, + .set_main_board_cpld_test_reg = demo_set_main_board_cpld_test_reg, +}; + +static int __init cpld_device_driver_init(void) +{ + int ret; + + CPLD_INFO("cpld_init...\n"); + + ret = s3ip_sysfs_cpld_drivers_register(&drivers); + if (ret < 0) { + CPLD_ERR("cpld drivers register err, ret %d.\n", ret); + return ret; + } + + CPLD_INFO("cpld_init success.\n"); + return 0; +} + +static void __exit cpld_device_driver_exit(void) +{ + s3ip_sysfs_cpld_drivers_unregister(); + CPLD_INFO("cpld_exit success.\n"); + return; +} + +module_init(cpld_device_driver_init); +module_exit(cpld_device_driver_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4, all=0xf).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_DESCRIPTION("cpld device driver"); diff --git a/platform/s3ip-sysfs/demo_driver/curr_sensor_device_driver.c b/platform/s3ip-sysfs/demo_driver/curr_sensor_device_driver.c new file mode 100644 index 000000000000..f5f7ffa53ef6 --- /dev/null +++ b/platform/s3ip-sysfs/demo_driver/curr_sensor_device_driver.c @@ -0,0 +1,188 @@ +/* + * curr_sensor_device_driver.c + * + * This module realize /sys/s3ip/curr_sensor attributes read and write functions + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "device_driver_common.h" +#include "curr_sensor_sysfs.h" + +#define CURR_SENSOR_INFO(fmt, args...) LOG_INFO("curr_sensor: ", fmt, ##args) +#define CURR_SENSOR_ERR(fmt, args...) LOG_ERR("curr_sensor: ", fmt, ##args) +#define CURR_SENSOR_DBG(fmt, args...) LOG_DBG("curr_sensor: ", fmt, ##args) + +static int g_loglevel = 0; + +/*************************************main board current***************************************/ +static int demo_get_main_board_curr_number(void) +{ + /* add vendor codes here */ + return 1; +} + +/* + * demo_get_main_board_curr_alias - Used to identify the location of the current sensor, + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_main_board_curr_alias(unsigned int curr_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_main_board_curr_type - Used to get the model of current sensor, + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_main_board_curr_type(unsigned int curr_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_main_board_curr_max - Used to get the maximum threshold of current sensor + * filled the value to buf, and the value keep three decimal places + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_main_board_curr_max(unsigned int curr_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_set_main_board_curr_max - Used to set the maximum threshold of current sensor + * get value from buf and set it to maximum threshold of current sensor + * @curr_index: start with 1 + * @buf: the buf store the data to be set + * @count: length of buf + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int demo_set_main_board_curr_max(unsigned int curr_index, const char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_main_board_curr_min - Used to get the minimum threshold of current sensor + * filled the value to buf, and the value keep three decimal places + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_main_board_curr_min(unsigned int curr_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_set_main_board_curr_min - Used to set the minimum threshold of current sensor + * get value from buf and set it to minimum threshold of current sensor + * @curr_index: start with 1 + * @buf: the buf store the data to be set, eg '50.000' + * @count: length of buf + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int demo_set_main_board_curr_min(unsigned int curr_index, const char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_main_board_curr_value - Used to get the input value of current sensor + * filled the value to buf, and the value keep three decimal places + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_main_board_curr_value(unsigned int curr_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} +/*********************************end of main board current************************************/ + +static struct s3ip_sysfs_curr_sensor_drivers_s drivers = { + /* + * set ODM current sensor drivers to /sys/s3ip/curr_sensor, + * if not support the function, set corresponding hook to NULL. + */ + .get_main_board_curr_number = demo_get_main_board_curr_number, + .get_main_board_curr_alias = demo_get_main_board_curr_alias, + .get_main_board_curr_type = demo_get_main_board_curr_type, + .get_main_board_curr_max = demo_get_main_board_curr_max, + .set_main_board_curr_max = demo_set_main_board_curr_max, + .get_main_board_curr_min = demo_get_main_board_curr_min, + .set_main_board_curr_min = demo_set_main_board_curr_min, + .get_main_board_curr_value = demo_get_main_board_curr_value, +}; + +static int __init curr_sensor_dev_drv_init(void) +{ + int ret; + + CURR_SENSOR_INFO("curr_sensor_init...\n"); + + ret = s3ip_sysfs_curr_sensor_drivers_register(&drivers); + if (ret < 0) { + CURR_SENSOR_ERR("curr sensor drivers register err, ret %d.\n", ret); + return ret; + } + + CURR_SENSOR_INFO("curr_sensor_init success.\n"); + return 0; +} + +static void __exit curr_sensor_dev_drv_exit(void) +{ + s3ip_sysfs_curr_sensor_drivers_unregister(); + CURR_SENSOR_INFO("curr_sensor_exit success.\n"); + return; +} + +module_init(curr_sensor_dev_drv_init); +module_exit(curr_sensor_dev_drv_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4, all=0xf).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_DESCRIPTION("current sensors device driver"); diff --git a/platform/s3ip-sysfs/demo_driver/fan_device_driver.c b/platform/s3ip-sysfs/demo_driver/fan_device_driver.c new file mode 100755 index 000000000000..17aa26a77f04 --- /dev/null +++ b/platform/s3ip-sysfs/demo_driver/fan_device_driver.c @@ -0,0 +1,372 @@ +/* + * fan_device_driver.c + * + * This module realize /sys/s3ip/fan attributes read and write functions + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "device_driver_common.h" +#include "fan_sysfs.h" + +#define FAN_INFO(fmt, args...) LOG_INFO("fan: ", fmt, ##args) +#define FAN_ERR(fmt, args...) LOG_ERR("fan: ", fmt, ##args) +#define FAN_DBG(fmt, args...) LOG_DBG("fan: ", fmt, ##args) + +static int g_loglevel = 0; + +/********************************************fan**********************************************/ +static int demo_get_fan_number(void) +{ + /* add vendor codes here */ + return 1; +} + +static int demo_get_fan_motor_number(unsigned int fan_index) +{ + /* add vendor codes here */ + return 1; +} + +/* + * demo_get_fan_model_name - Used to get fan model name, + * @fan_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_fan_model_name(unsigned int fan_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_fan_serial_number - Used to get fan serial number, + * @fan_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_fan_serial_number(unsigned int fan_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_fan_part_number - Used to get fan part number, + * @fan_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_fan_part_number(unsigned int fan_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_fan_hardware_version - Used to get fan hardware version, + * @fan_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_fan_hardware_version(unsigned int fan_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_fan_status - Used to get fan status, + * filled the value to buf, fan status define as below: + * 0: ABSENT + * 1: OK + * 2: NOT OK + * + * @fan_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_fan_status(unsigned int fan_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_fan_led_status - Used to get fan led status + * filled the value to buf, led status value define as below: + * 0: dark + * 1: green + * 2: yellow + * 3: red + * 4:blue + * 5: green light flashing + * 6: yellow light flashing + * 7: red light flashing + * 8:blue light flashing + * + * @fan_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_fan_led_status(unsigned int fan_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_set_fan_led_status - Used to set fan led status + * @fan_index: start with 1 + * @status: led status, led status value define as below: + * 0: dark + * 1: green + * 2: yellow + * 3: red + * 4:blue + * 5: green light flashing + * 6: yellow light flashing + * 7: red light flashing + * 8:blue light flashing + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int demo_set_fan_led_status(unsigned int fan_index, int status) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_fan_direction - Used to get fan air flow direction, + * filled the value to buf, air flow direction define as below: + * 0: F2B + * 1: B2F + * + * @fan_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_fan_direction(unsigned int fan_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_fan_motor_speed - Used to get fan motor speed + * filled the value to buf + * @fan_index: start with 1 + * @motor_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_fan_motor_speed(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_fan_motor_speed_tolerance - Used to get fan motor speed tolerance + * filled the value to buf + * @fan_index: start with 1 + * @motor_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_fan_motor_speed_tolerance(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_fan_motor_speed_target - Used to get fan motor speed target + * filled the value to buf + * @fan_index: start with 1 + * @motor_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_fan_motor_speed_target(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_fan_motor_speed_max - Used to get the maximum threshold of fan motor + * filled the value to buf + * @fan_index: start with 1 + * @motor_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_fan_motor_speed_max(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_fan_motor_speed_min - Used to get the minimum threshold of fan motor + * filled the value to buf + * @fan_index: start with 1 + * @motor_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_fan_motor_speed_min(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_fan_motor_ratio - Used to get the ratio of fan motor + * filled the value to buf + * @fan_index: start with 1 + * @motor_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_fan_ratio(unsigned int fan_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_set_fan_motor_ratio - Used to set the ratio of fan motor + * @fan_index: start with 1 + * @motor_index: start with 1 + * @ratio: motor speed ratio, from 0 to 100 + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int demo_set_fan_ratio(unsigned int fan_index, int ratio) +{ + /* add vendor codes here */ + return -ENOSYS; +} +/****************************************end of fan*******************************************/ + +static struct s3ip_sysfs_fan_drivers_s drivers = { + /* + * set ODM fan drivers to /sys/s3ip/fan, + * if not support the function, set corresponding hook to NULL. + */ + .get_fan_number = demo_get_fan_number, + .get_fan_motor_number = demo_get_fan_motor_number, + .get_fan_model_name = demo_get_fan_model_name, + .get_fan_serial_number = demo_get_fan_serial_number, + .get_fan_part_number = demo_get_fan_part_number, + .get_fan_hardware_version = demo_get_fan_hardware_version, + .get_fan_status = demo_get_fan_status, + .get_fan_led_status = demo_get_fan_led_status, + .set_fan_led_status = demo_set_fan_led_status, + .get_fan_direction = demo_get_fan_direction, + .get_fan_motor_speed = demo_get_fan_motor_speed, + .get_fan_motor_speed_tolerance = demo_get_fan_motor_speed_tolerance, + .get_fan_motor_speed_target = demo_get_fan_motor_speed_target, + .get_fan_motor_speed_max = demo_get_fan_motor_speed_max, + .get_fan_motor_speed_min = demo_get_fan_motor_speed_min, + .get_fan_ratio = demo_get_fan_ratio, + .set_fan_ratio = demo_set_fan_ratio, +}; + +static int __init fan_dev_drv_init(void) +{ + int ret; + + FAN_INFO("fan_init...\n"); + + ret = s3ip_sysfs_fan_drivers_register(&drivers); + if (ret < 0) { + FAN_ERR("fan drivers register err, ret %d.\n", ret); + return ret; + } + + FAN_INFO("fan_init success.\n"); + return 0; +} + +static void __exit fan_dev_drv_exit(void) +{ + s3ip_sysfs_fan_drivers_unregister(); + FAN_INFO("fan_exit success.\n"); + return; +} + +module_init(fan_dev_drv_init); +module_exit(fan_dev_drv_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4, all=0xf).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_DESCRIPTION("fan device driver"); diff --git a/platform/s3ip-sysfs/demo_driver/fpga_device_driver.c b/platform/s3ip-sysfs/demo_driver/fpga_device_driver.c new file mode 100644 index 000000000000..819822af486d --- /dev/null +++ b/platform/s3ip-sysfs/demo_driver/fpga_device_driver.c @@ -0,0 +1,167 @@ +/* + * fpga_device_driver.c + * + * This module realize /sys/s3ip/fpga attributes read and write functions + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "device_driver_common.h" +#include "fpga_sysfs.h" + +#define FPGA_INFO(fmt, args...) LOG_INFO("fpga: ", fmt, ##args) +#define FPGA_ERR(fmt, args...) LOG_ERR("fpga: ", fmt, ##args) +#define FPGA_DBG(fmt, args...) LOG_DBG("fpga: ", fmt, ##args) + +static int g_loglevel = 0; + +/******************************************FPGA***********************************************/ +static int demo_get_main_board_fpga_number(void) +{ + /* add vendor codes here */ + return 1; +} + +/* + * demo_get_main_board_fpga_alias - Used to identify the location of fpga, + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_main_board_fpga_alias(unsigned int fpga_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_main_board_fpga_type - Used to get fpga model name + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_main_board_fpga_type(unsigned int fpga_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_main_board_fpga_firmware_version - Used to get fpga firmware version, + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_main_board_fpga_firmware_version(unsigned int fpga_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_main_board_fpga_board_version - Used to get fpga board version, + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_main_board_fpga_board_version(unsigned int fpga_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_main_board_fpga_test_reg - Used to test fpga register read + * filled the value to buf, value is hexadecimal, start with 0x + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_main_board_fpga_test_reg(unsigned int fpga_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_set_main_board_fpga_test_reg - Used to test fpga register write + * @fpga_index: start with 1 + * @value: value write to fpga + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int demo_set_main_board_fpga_test_reg(unsigned int fpga_index, unsigned int value) +{ + /* add vendor codes here */ + return -ENOSYS; +} +/***************************************end of FPGA*******************************************/ + +static struct s3ip_sysfs_fpga_drivers_s drivers = { + /* + * set ODM FPGA drivers to /sys/s3ip/fpga, + * if not support the function, set corresponding hook to NULL. + */ + .get_main_board_fpga_number = demo_get_main_board_fpga_number, + .get_main_board_fpga_alias = demo_get_main_board_fpga_alias, + .get_main_board_fpga_type = demo_get_main_board_fpga_type, + .get_main_board_fpga_firmware_version = demo_get_main_board_fpga_firmware_version, + .get_main_board_fpga_board_version = demo_get_main_board_fpga_board_version, + .get_main_board_fpga_test_reg = demo_get_main_board_fpga_test_reg, + .set_main_board_fpga_test_reg = demo_set_main_board_fpga_test_reg, +}; + +static int __init fpga_dev_drv_init(void) +{ + int ret; + + FPGA_INFO("fpga_init...\n"); + + ret = s3ip_sysfs_fpga_drivers_register(&drivers); + if (ret < 0) { + FPGA_ERR("fpga drivers register err, ret %d.\n", ret); + return ret; + } + FPGA_INFO("fpga_init success.\n"); + return 0; +} + +static void __exit fpga_dev_drv_exit(void) +{ + s3ip_sysfs_fpga_drivers_unregister(); + FPGA_INFO("fpga_exit success.\n"); + return; +} + +module_init(fpga_dev_drv_init); +module_exit(fpga_dev_drv_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4, all=0xf).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_DESCRIPTION("fpga device driver"); diff --git a/platform/s3ip-sysfs/demo_driver/include/device_driver_common.h b/platform/s3ip-sysfs/demo_driver/include/device_driver_common.h new file mode 100644 index 000000000000..6386d88fafe9 --- /dev/null +++ b/platform/s3ip-sysfs/demo_driver/include/device_driver_common.h @@ -0,0 +1,49 @@ +#ifndef _DEVICE_DRIVER_COMMON_H_ +#define _DEVICE_DRIVER_COMMON_H_ + +#include +#include +#include +#include +#include +#include +#include +#include + +enum LOG_LEVEL{ + INFO = 0x1, + ERR = 0x2, + DBG = 0x4, + ALL = 0xf +}; + +#define LOG_INFO(_prefix, fmt, args...) do { \ + if (g_loglevel & INFO) { \ + printk( KERN_INFO _prefix "%s "fmt, __FUNCTION__, ##args); \ + } \ +} while (0) + +#define LOG_ERR(_prefix, fmt, args...) do { \ + if (g_loglevel & ERR) { \ + printk( KERN_ERR _prefix "%s "fmt, __FUNCTION__, ##args); \ + } \ +} while (0) + +#define LOG_DBG(_prefix, fmt, args...) do { \ + if (g_loglevel & DBG) { \ + printk( KERN_DEBUG _prefix "%s "fmt, __FUNCTION__, ##args); \ + } \ +} while (0) + +#define check_pfun(p) do { \ + if (p == NULL) { \ + if (g_loglevel & ERR) { \ + printk( KERN_ERR "%s, %s is NULL.\n", __FUNCTION__, #p); \ + } \ + return -ENOSYS; \ + } \ +} while(0) + +#define check_p(p) check_pfun(p) + +#endif /* _DEVICE_DRIVER_COMMON_H_ */ diff --git a/platform/s3ip-sysfs/demo_driver/psu_device_driver.c b/platform/s3ip-sysfs/demo_driver/psu_device_driver.c new file mode 100644 index 000000000000..2f424b5498c1 --- /dev/null +++ b/platform/s3ip-sysfs/demo_driver/psu_device_driver.c @@ -0,0 +1,587 @@ +/* + * psu_device_driver.c + * + * This module realize /sys/s3ip/psu attributes read and write functions + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "device_driver_common.h" +#include "psu_sysfs.h" + +#define PSU_INFO(fmt, args...) LOG_INFO("psu: ", fmt, ##args) +#define PSU_ERR(fmt, args...) LOG_ERR("psu: ", fmt, ##args) +#define PSU_DBG(fmt, args...) LOG_DBG("psu: ", fmt, ##args) + +static int g_loglevel = 0; + +/********************************************psu**********************************************/ +static int demo_get_psu_number(void) +{ + /* add vendor codes here */ + return 1; +} + +static int demo_get_psu_temp_number(unsigned int psu_index) +{ + /* add vendor codes here */ + return 1; +} + +/* + * demo_get_psu_model_name - Used to get psu model name, + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_psu_model_name(unsigned int psu_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_psu_serial_number - Used to get psu serial number, + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_psu_serial_number(unsigned int psu_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_psu_part_number - Used to get psu part number, + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_psu_part_number(unsigned int psu_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_psu_hardware_version - Used to get psu hardware version, + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_psu_hardware_version(unsigned int psu_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_psu_type - Used to get the input type of psu + * filled the value to buf, input type value define as below: + * 0: DC + * 1: AC + * + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_psu_type(unsigned int psu_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_psu_in_curr - Used to get the input current of psu + * filled the value to buf, and the value keep three decimal places + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_psu_in_curr(unsigned int psu_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_psu_in_vol - Used to get the input voltage of psu + * filled the value to buf, and the value keep three decimal places + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_psu_in_vol(unsigned int psu_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_psu_in_power - Used to get the input power of psu + * filled the value to buf, and the value keep three decimal places + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_psu_in_power(unsigned int psu_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_psu_out_curr - Used to get the output current of psu + * filled the value to buf, and the value keep three decimal places + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_psu_out_curr(unsigned int psu_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_psu_out_vol - Used to get the output voltage of psu + * filled the value to buf, and the value keep three decimal places + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_psu_out_vol(unsigned int psu_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_psu_out_power - Used to get the output power of psu + * filled the value to buf, and the value keep three decimal places + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_psu_out_power(unsigned int psu_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_psu_out_max_power - Used to get the output max power of psu + * filled the value to buf, and the value keep three decimal places + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_psu_out_max_power(unsigned int psu_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_psu_present_status - Used to get psu present status + * filled the value to buf, psu present status define as below: + * 0: ABSENT + * 1: PRESENT + * + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_psu_present_status(unsigned int psu_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_psu_in_status - Used to get psu input status + * filled the value to buf, psu input status define as below: + * 0: NOT OK + * 1: OK + * + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_psu_in_status(unsigned int psu_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_psu_out_status - Used to get psu output status + * filled the value to buf, psu output status define as below: + * 0: NOT OK + * 1: OK + * + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_psu_out_status(unsigned int psu_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_psu_fan_speed - Used to get psu fan speed + * filled the value to buf + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_psu_fan_speed(unsigned int psu_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_psu_fan_ratio - Used to get the ratio of psu fan + * filled the value to buf + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_psu_fan_ratio(unsigned int psu_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_set_psu_fan_ratio - Used to set the ratio of psu fan + * @psu_index: start with 1 + * @ratio: from 0 to 100 + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int demo_set_psu_fan_ratio(unsigned int psu_index, int ratio) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_psu_fan_direction - Used to get psu air flow direction, + * filled the value to buf, air flow direction define as below: + * 0: F2B + * 1: B2F + * + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_psu_fan_direction(unsigned int psu_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_psu_led_status - Used to get psu led status + * filled the value to buf, led status value define as below: + * 0: dark + * 1: green + * 2: yellow + * 3: red + * 4:blue + * 5: green light flashing + * 6: yellow light flashing + * 7: red light flashing + * 8:blue light flashing + * + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_psu_led_status(unsigned int psu_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_psu_temp_alias - Used to identify the location of the temperature sensor of psu, + * @psu_index: start with 1 + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_psu_temp_alias(unsigned int psu_index, unsigned int temp_index, + char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_psu_temp_type - Used to get the model of temperature sensor of psu, + * @psu_index: start with 1 + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_psu_temp_type(unsigned int psu_index, unsigned int temp_index, + char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_psu_temp_max - Used to get the maximum threshold of temperature sensor of psu, + * filled the value to buf, and the value keep three decimal places + * @psu_index: start with 1 + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_psu_temp_max(unsigned int psu_index, unsigned int temp_index, + char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_set_psu_temp_max - Used to set the maximum threshold of temperature sensor of psu, + * get value from buf and set it to maximum threshold of psu temperature sensor + * @psu_index: start with 1 + * @temp_index: start with 1 + * @buf: the buf store the data to be set, eg '80.000' + * @count: length of buf + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int demo_set_psu_temp_max(unsigned int psu_index, unsigned int temp_index, + const char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_psu_temp_min - Used to get the minimum threshold of temperature sensor of psu, + * filled the value to buf, and the value keep three decimal places + * @psu_index: start with 1 + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_psu_temp_min(unsigned int psu_index, unsigned int temp_index, + char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_set_psu_temp_min - Used to set the minimum threshold of temperature sensor of psu, + * get value from buf and set it to minimum threshold of psu temperature sensor + * @psu_index: start with 1 + * @temp_index: start with 1 + * @buf: the buf store the data to be set, eg '50.000' + * @count: length of buf + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int demo_set_psu_temp_min(unsigned int psu_index, unsigned int temp_index, + const char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_psu_temp_value - Used to get the input value of temperature sensor of psu + * filled the value to buf, and the value keep three decimal places + * @psu_index: start with 1 + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_psu_temp_value(unsigned int psu_index, unsigned int temp_index, + char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} +/****************************************end of psu*******************************************/ + +static struct s3ip_sysfs_psu_drivers_s drivers = { + /* + * set ODM psu drivers to /sys/s3ip/psu, + * if not support the function, set corresponding hook to NULL. + */ + .get_psu_number = demo_get_psu_number, + .get_psu_temp_number = demo_get_psu_temp_number, + .get_psu_model_name = demo_get_psu_model_name, + .get_psu_serial_number = demo_get_psu_serial_number, + .get_psu_part_number = demo_get_psu_part_number, + .get_psu_hardware_version = demo_get_psu_hardware_version, + .get_psu_type = demo_get_psu_type, + .get_psu_in_curr = demo_get_psu_in_curr, + .get_psu_in_vol = demo_get_psu_in_vol, + .get_psu_in_power = demo_get_psu_in_power, + .get_psu_out_curr = demo_get_psu_out_curr, + .get_psu_out_vol = demo_get_psu_out_vol, + .get_psu_out_power = demo_get_psu_out_power, + .get_psu_out_max_power = demo_get_psu_out_max_power, + .get_psu_present_status = demo_get_psu_present_status, + .get_psu_in_status = demo_get_psu_in_status, + .get_psu_out_status = demo_get_psu_out_status, + .get_psu_fan_speed = demo_get_psu_fan_speed, + .get_psu_fan_ratio = demo_get_psu_fan_ratio, + .set_psu_fan_ratio = demo_set_psu_fan_ratio, + .get_psu_fan_direction = demo_get_psu_fan_direction, + .get_psu_led_status = demo_get_psu_led_status, + .get_psu_temp_alias = demo_get_psu_temp_alias, + .get_psu_temp_type = demo_get_psu_temp_type, + .get_psu_temp_max = demo_get_psu_temp_max, + .set_psu_temp_max = demo_set_psu_temp_max, + .get_psu_temp_min = demo_get_psu_temp_min, + .set_psu_temp_min = demo_set_psu_temp_min, + .get_psu_temp_value = demo_get_psu_temp_value, +}; + +static int __init psu_dev_drv_init(void) +{ + int ret; + + PSU_INFO("psu_init...\n"); + + ret = s3ip_sysfs_psu_drivers_register(&drivers); + if (ret < 0) { + PSU_ERR("psu drivers register err, ret %d.\n", ret); + return ret; + } + PSU_INFO("psu_init success.\n"); + return 0; +} + +static void __exit psu_dev_drv_exit(void) +{ + s3ip_sysfs_psu_drivers_unregister(); + PSU_INFO("psu_exit ok.\n"); + + return; +} + +module_init(psu_dev_drv_init); +module_exit(psu_dev_drv_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4, all=0xf).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_DESCRIPTION("psu device driver"); diff --git a/platform/s3ip-sysfs/demo_driver/slot_device_driver.c b/platform/s3ip-sysfs/demo_driver/slot_device_driver.c new file mode 100644 index 000000000000..dd924eb30012 --- /dev/null +++ b/platform/s3ip-sysfs/demo_driver/slot_device_driver.c @@ -0,0 +1,918 @@ +/* + * slot_device_driver.c + * + * This module realize /sys/s3ip/slot attributes read and write functions + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "device_driver_common.h" +#include "slot_sysfs.h" + +#define SLOT_INFO(fmt, args...) LOG_INFO("slot: ", fmt, ##args) +#define SLOT_ERR(fmt, args...) LOG_ERR("slot: ", fmt, ##args) +#define SLOT_DBG(fmt, args...) LOG_DBG("slot: ", fmt, ##args) + +static int g_loglevel = 0; + +/******************************************slot***********************************************/ +static int demo_get_slot_number(void) +{ + /* add vendor codes here */ + return 1; +} + +static int demo_get_slot_temp_number(unsigned int slot_index) +{ + /* add vendor codes here */ + return 1; +} + +static int demo_get_slot_vol_number(unsigned int slot_index) +{ + /* add vendor codes here */ + return 1; +} + +static int demo_get_slot_curr_number(unsigned int slot_index) +{ + /* add vendor codes here */ + return 1; +} + +static int demo_get_slot_fpga_number(unsigned int slot_index) +{ + /* add vendor codes here */ + return 1; +} + +static int demo_get_slot_cpld_number(unsigned int slot_index) +{ + /* add vendor codes here */ + return 1; +} + +/* + * demo_get_slot_model_name - Used to get slot model name, + * @slot_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_slot_model_name(unsigned int slot_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_slot_serial_number - Used to get slot serial number, + * @slot_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_slot_serial_number(unsigned int slot_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_slot_part_number - Used to get slot part number, + * @slot_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_slot_part_number(unsigned int slot_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_slot_hardware_version - Used to get slot hardware version, + * @slot_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_slot_hardware_version(unsigned int slot_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_slot_status - Used to get slot status, + * filled the value to buf, slot status define as below: + * 0: ABSENT + * 1: OK + * 2: NOT OK + * + * @slot_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_slot_status(unsigned int slot_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_slot_led_status - Used to get slot led status + * filled the value to buf, led status value define as below: + * 0: dark + * 1: green + * 2: yellow + * 3: red + * 4:blue + * 5: green light flashing + * 6: yellow light flashing + * 7: red light flashing + * 8:blue light flashing + * + * @slot_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_slot_led_status(unsigned int slot_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_set_slot_led_status - Used to set slot led status + * @slot_index: start with 1 + * @status: led status, led status value define as below: + * 0: dark + * 1: green + * 2: yellow + * 3: red + * 4:blue + * 5: green light flashing + * 6: yellow light flashing + * 7: red light flashing + * 8:blue light flashing + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int demo_set_slot_led_status(unsigned int slot_index, int status) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_slot_temp_alias - Used to identify the location of the temperature sensor of slot, + * @slot_index: start with 1 + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_slot_temp_alias(unsigned int slot_index, unsigned int temp_index, + char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_slot_temp_type - Used to get the model of temperature sensor of slot, + * @slot_index: start with 1 + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_slot_temp_type(unsigned int slot_index, unsigned int temp_index, + char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; + +} + +/* + * demo_get_slot_temp_max - Used to get the maximum threshold of temperature sensor of slot, + * filled the value to buf, and the value keep three decimal places + * @slot_index: start with 1 + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_slot_temp_max(unsigned int slot_index, unsigned int temp_index, + char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_set_slot_temp_max - Used to set the maximum threshold of temperature sensor of slot, + * get value from buf and set it to maximum threshold of slot temperature sensor + * @slot_index: start with 1 + * @temp_index: start with 1 + * @buf: the buf store the data to be set, eg '80.000' + * @count: length of buf + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int demo_set_slot_temp_max(unsigned int slot_index, unsigned int temp_index, + const char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_slot_temp_min - Used to get the minimum threshold of temperature sensor of slot, + * filled the value to buf, and the value keep three decimal places + * @slot_index: start with 1 + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_slot_temp_min(unsigned int slot_index, unsigned int temp_index, + char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_set_slot_temp_min - Used to set the minimum threshold of temperature sensor of slot, + * get value from buf and set it to minimum threshold of slot temperature sensor + * @slot_index: start with 1 + * @temp_index: start with 1 + * @buf: the buf store the data to be set, eg '50.000' + * @count: length of buf + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int demo_set_slot_temp_min(unsigned int slot_index, unsigned int temp_index, + const char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_slot_temp_value - Used to get the input value of temperature sensor of slot, + * filled the value to buf, and the value keep three decimal places + * @slot_index: start with 1 + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_slot_temp_value(unsigned int slot_index, unsigned int temp_index, + char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_slot_vol_alias - Used to identify the location of the voltage sensor of slot, + * @slot_index: start with 1 + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_slot_vol_alias(unsigned int slot_index, unsigned int vol_index, + char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_slot_vol_type - Used to get the model of voltage sensor of slot, + * such as udc90160, tps53622 and so on + * @slot_index: start with 1 + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_slot_vol_type(unsigned int slot_index, unsigned int vol_index, + char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; + +} + +/* + * demo_get_slot_vol_max - Used to get the maximum threshold of voltage sensor of slot, + * filled the value to buf, and the value keep three decimal places + * @slot_index: start with 1 + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_slot_vol_max(unsigned int slot_index, unsigned int vol_index, + char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_set_slot_vol_max - Used to set the maximum threshold of volatge sensor of slot, + * get value from buf and set it to maximum threshold of volatge sensor + * @slot_index: start with 1 + * @vol_index: start with 1 + * @buf: the buf store the data to be set, eg '3.567' + * @count: length of buf + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int demo_set_slot_vol_max(unsigned int slot_index, unsigned int vol_index, + const char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_slot_vol_min - Used to get the minimum threshold of voltage sensor of slot, + * filled the value to buf, and the value keep three decimal places + * @slot_index: start with 1 + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_slot_vol_min(unsigned int slot_index, unsigned int vol_index, + char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_set_slot_vol_min - Used to set the minimum threshold of voltage sensor of slot, + * get value from buf and set it to minimum threshold of voltage sensor + * @slot_index: start with 1 + * @temp_index: start with 1 + * @buf: the buf store the data to be set, eg '3.123' + * @count: length of buf + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int demo_set_slot_vol_min(unsigned int slot_index, unsigned int vol_index, + const char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_slot_vol_range - Used to get the output error value of voltage sensor of slot, + * filled the value to buf + * @slot_index: start with 1 + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_slot_vol_range(unsigned int slot_index, unsigned int vol_index, + char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_slot_vol_nominal_value - Used to get the nominal value of voltage sensor of slot, + * filled the value to buf + * @slot_index: start with 1 + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_slot_vol_nominal_value(unsigned int slot_index, + unsigned int vol_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_slot_vol_value - Used to get the input value of voltage sensor of slot, + * filled the value to buf, and the value keep three decimal places + * @slot_index: start with 1 + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_slot_vol_value(unsigned int slot_index, unsigned int vol_index, + char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_slot_curr_alias - Used to identify the location of the current sensor of slot, + * @slot_index: start with 1 + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_slot_curr_alias(unsigned int slot_index, unsigned int curr_index, + char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_slot_curr_type - Used to get the model of current sensor of slot, + * @slot_index: start with 1 + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_slot_curr_type(unsigned int slot_index, unsigned int curr_index, + char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_slot_curr_max - Used to get the maximum threshold of current sensor of slot, + * filled the value to buf, and the value keep three decimal places + * @slot_index: start with 1 + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_slot_curr_max(unsigned int slot_index, unsigned int curr_index, + char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_set_slot_curr_max - Used to set the maximum threshold of current sensor of slot, + * get value from buf and set it to maximum threshold of current sensor + * @slot_index: start with 1 + * @curr_index: start with 1 + * @buf: the buf store the data to be set + * @count: length of buf + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int demo_set_slot_curr_max(unsigned int slot_index, unsigned int curr_index, + const char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_slot_curr_min - Used to get the minimum threshold of current sensor of slot, + * filled the value to buf, and the value keep three decimal places + * @slot_index: start with 1 + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_slot_curr_min(unsigned int slot_index, unsigned int curr_index, + char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_set_slot_curr_min - Used to set the minimum threshold of current sensor of slot, + * get value from buf and set it to minimum threshold of current sensor + * @slot_index: start with 1 + * @curr_index: start with 1 + * @buf: the buf store the data to be set, eg '50.000' + * @count: length of buf + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int demo_set_slot_curr_min(unsigned int slot_index, unsigned int curr_index, + const char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_slot_curr_value - Used to get the input value of current sensor of slot, + * filled the value to buf, and the value keep three decimal places + * @slot_index: start with 1 + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_slot_curr_value(unsigned int slot_index, unsigned int curr_index, + char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_slot_fpga_alias - Used to identify the location of slot fpga, + * @slot_index: start with 1 + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_slot_fpga_alias(unsigned int slot_index, unsigned int fpga_index, + char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_slot_fpga_type - Used to get slot fpga model name + * @slot_index: start with 1 + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_slot_fpga_type(unsigned int slot_index, unsigned int fpga_index, + char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_slot_fpga_firmware_version - Used to get slot fpga firmware version, + * @slot_index: start with 1 + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_slot_fpga_firmware_version(unsigned int slot_index, unsigned int fpga_index, + char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_slot_fpga_board_version - Used to get slot fpga board version, + * @slot_index: start with 1 + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_slot_fpga_board_version(unsigned int slot_index, unsigned int fpga_index, + char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_slot_fpga_test_reg - Used to test slot fpga register read + * filled the value to buf, value is hexadecimal, start with 0x + * @slot_index: start with 1 + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_slot_fpga_test_reg(unsigned int slot_index, unsigned int fpga_index, + char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_set_slot_fpga_test_reg - Used to test slot fpga register write + * @slot_index: start with 1 + * @fpga_index: start with 1 + * @value: value write to slot fpga + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int demo_set_slot_fpga_test_reg(unsigned int slot_index, unsigned int fpga_index, + unsigned int value) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_slot_cpld_alias - Used to identify the location of slot cpld, + * @slot_index: start with 1 + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_slot_cpld_alias(unsigned int slot_index, unsigned int cpld_index, + char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_slot_cpld_type - Used to get slot cpld model name + * @slot_index: start with 1 + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_slot_cpld_type(unsigned int slot_index, unsigned int cpld_index, + char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_slot_cpld_firmware_version - Used to get slot cpld firmware version, + * @slot_index: start with 1 + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_slot_cpld_firmware_version(unsigned int slot_index, unsigned int cpld_index, + char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_slot_cpld_board_version - Used to get slot cpld board version, + * @slot_index: start with 1 + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_slot_cpld_board_version(unsigned int slot_index, unsigned int cpld_index, + char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_slot_cpld_test_reg - Used to test slot cpld register read + * filled the value to buf, value is hexadecimal, start with 0x + * @slot_index: start with 1 + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_slot_cpld_test_reg(unsigned int slot_index, unsigned int cpld_index, + char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_set_slot_cpld_test_reg - Used to test slot cpld register write + * @slot_index: start with 1 + * @cpld_index: start with 1 + * @value: value write to slot cpld + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int demo_set_slot_cpld_test_reg(unsigned int slot_index, unsigned int cpld_index, + unsigned int value) +{ + /* add vendor codes here */ + return -ENOSYS; +} +/***************************************end of slot*******************************************/ + +static struct s3ip_sysfs_slot_drivers_s drivers = { + /* + * set ODM slot drivers to /sys/s3ip/slot, + * if not support the function, set corresponding hook to NULL. + */ + .get_slot_number = demo_get_slot_number, + .get_slot_temp_number = demo_get_slot_temp_number, + .get_slot_vol_number = demo_get_slot_vol_number, + .get_slot_curr_number = demo_get_slot_curr_number, + .get_slot_cpld_number = demo_get_slot_cpld_number, + .get_slot_fpga_number = demo_get_slot_fpga_number, + .get_slot_model_name = demo_get_slot_model_name, + .get_slot_serial_number = demo_get_slot_serial_number, + .get_slot_part_number = demo_get_slot_part_number, + .get_slot_hardware_version = demo_get_slot_hardware_version, + .get_slot_status = demo_get_slot_status, + .get_slot_led_status = demo_get_slot_led_status, + .set_slot_led_status = demo_set_slot_led_status, + .get_slot_temp_alias = demo_get_slot_temp_alias, + .get_slot_temp_type = demo_get_slot_temp_type, + .get_slot_temp_max = demo_get_slot_temp_max, + .set_slot_temp_max = demo_set_slot_temp_max, + .get_slot_temp_min = demo_get_slot_temp_min, + .set_slot_temp_min = demo_set_slot_temp_min, + .get_slot_temp_value = demo_get_slot_temp_value, + .get_slot_vol_alias = demo_get_slot_vol_alias, + .get_slot_vol_type = demo_get_slot_vol_type, + .get_slot_vol_max = demo_get_slot_vol_max, + .set_slot_vol_max = demo_set_slot_vol_max, + .get_slot_vol_min = demo_get_slot_vol_min, + .set_slot_vol_min = demo_set_slot_vol_min, + .get_slot_vol_range = demo_get_slot_vol_range, + .get_slot_vol_nominal_value = demo_get_slot_vol_nominal_value, + .get_slot_vol_value = demo_get_slot_vol_value, + .get_slot_curr_alias = demo_get_slot_curr_alias, + .get_slot_curr_type = demo_get_slot_curr_type, + .get_slot_curr_max = demo_get_slot_curr_max, + .set_slot_curr_max = demo_set_slot_curr_max, + .get_slot_curr_min = demo_get_slot_curr_min, + .set_slot_curr_min = demo_set_slot_curr_min, + .get_slot_curr_value = demo_get_slot_curr_value, + .get_slot_fpga_alias = demo_get_slot_fpga_alias, + .get_slot_fpga_alias = demo_get_slot_fpga_alias, + .get_slot_fpga_type = demo_get_slot_fpga_type, + .get_slot_fpga_firmware_version = demo_get_slot_fpga_firmware_version, + .get_slot_fpga_board_version = demo_get_slot_fpga_board_version, + .get_slot_fpga_test_reg = demo_get_slot_fpga_test_reg, + .set_slot_fpga_test_reg = demo_set_slot_fpga_test_reg, + .get_slot_cpld_alias = demo_get_slot_cpld_alias, + .get_slot_cpld_type = demo_get_slot_cpld_type, + .get_slot_cpld_firmware_version = demo_get_slot_cpld_firmware_version, + .get_slot_cpld_board_version = demo_get_slot_cpld_board_version, + .get_slot_cpld_test_reg = demo_get_slot_cpld_test_reg, + .set_slot_cpld_test_reg = demo_set_slot_cpld_test_reg, +}; + +static int __init slot_dev_drv_init(void) +{ + int ret; + + SLOT_INFO("slot_init...\n"); + + ret = s3ip_sysfs_slot_drivers_register(&drivers); + if (ret < 0) { + SLOT_ERR("slot drivers register err, ret %d.\n", ret); + return ret; + } + SLOT_INFO("slot_init success.\n"); + return 0; +} + +static void __exit slot_dev_drv_exit(void) +{ + s3ip_sysfs_slot_drivers_unregister(); + SLOT_INFO("slot_exit success.\n"); + return; +} + +module_init(slot_dev_drv_init); +module_exit(slot_dev_drv_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4, all=0xf).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_DESCRIPTION("slot device driver"); diff --git a/platform/s3ip-sysfs/demo_driver/syseeprom_device_driver.c b/platform/s3ip-sysfs/demo_driver/syseeprom_device_driver.c new file mode 100644 index 000000000000..0ee7c6459a30 --- /dev/null +++ b/platform/s3ip-sysfs/demo_driver/syseeprom_device_driver.c @@ -0,0 +1,106 @@ +/* + * syseeprom_device_driver.c + * + * This module realize /sys/s3ip/syseeprom attributes read and write functions + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "device_driver_common.h" +#include "syseeprom_sysfs.h" + +#define SYSE2_INFO(fmt, args...) LOG_INFO("syseeprom: ", fmt, ##args) +#define SYSE2_ERR(fmt, args...) LOG_ERR("syseeprom: ", fmt, ##args) +#define SYSE2_DBG(fmt, args...) LOG_DBG("syseeprom: ", fmt, ##args) + +static int g_loglevel = 0; + +/*****************************************syseeprom*******************************************/ +/* + * demo_get_syseeprom_size - Used to get syseeprom size + * + * This function returns the size of syseeprom by your switch, + * otherwise it returns a negative value on failed. + */ +static int demo_get_syseeprom_size(void) +{ + /* add vendor codes here */ + return 256; +} + +/* + * demo_read_syseeprom_data - Used to read syseeprom data, + * @buf: Data read buffer + * @offset: offset address to read syseeprom data + * @count: length of buf + * + * This function returns the length of the filled buffer, + * returns 0 means EOF, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_read_syseeprom_data(char *buf, loff_t offset, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_write_syseeprom_data - Used to write syseeprom data + * @buf: Data write buffer + * @offset: offset address to write syseeprom data + * @count: length of buf + * + * This function returns the written length of syseeprom, + * returns 0 means EOF, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_write_syseeprom_data(char *buf, loff_t offset, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} +/*************************************end of syseeprom****************************************/ + +static struct s3ip_sysfs_syseeprom_drivers_s drivers = { + /* + * set ODM syseeprom drivers to /sys/s3ip/syseeprom, + * if not support the function, set corresponding hook to NULL. + */ + .get_syseeprom_size = demo_get_syseeprom_size, + .read_syseeprom_data = demo_read_syseeprom_data, + .write_syseeprom_data = demo_write_syseeprom_data, +}; + +static int __init syseeprom_dev_drv_init(void) +{ + int ret; + + SYSE2_INFO("syseeprom_dev_drv_init...\n"); + + ret = s3ip_sysfs_syseeprom_drivers_register(&drivers); + if (ret < 0) { + SYSE2_ERR("syseeprom drivers register err, ret %d.\n", ret); + return ret; + } + SYSE2_INFO("syseeprom_dev_drv_init success.\n"); + return 0; +} + +static void __exit syseeprom_dev_drv_exit(void) +{ + s3ip_sysfs_syseeprom_drivers_unregister(); + SYSE2_INFO("syseeprom_exit success.\n"); + return; +} + +module_init(syseeprom_dev_drv_init); +module_exit(syseeprom_dev_drv_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4, all=0xf).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_DESCRIPTION("syseeprom device driver"); diff --git a/platform/s3ip-sysfs/demo_driver/sysled_device_driver.c b/platform/s3ip-sysfs/demo_driver/sysled_device_driver.c new file mode 100644 index 000000000000..69ae1628f50d --- /dev/null +++ b/platform/s3ip-sysfs/demo_driver/sysled_device_driver.c @@ -0,0 +1,175 @@ +/* + * sysled_device_driver.c + * + * This module realize /sys/s3ip/sysled attributes read and write functions + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "device_driver_common.h" +#include "sysled_sysfs.h" + +#define SYSLED_INFO(fmt, args...) LOG_INFO("sysled: ", fmt, ##args) +#define SYSLED_ERR(fmt, args...) LOG_ERR("sysled: ", fmt, ##args) +#define SYSLED_DBG(fmt, args...) LOG_DBG("sysled: ", fmt, ##args) + +static int g_loglevel = 0; + +/*****************************************sysled**********************************************/ +/* + * demo_get_sys_led_status - Used to get sys led status + * filled the value to buf, led status value define as below: + * 0: dark + * 1: green + * 2: yellow + * 3: red + * 4:blue + * 5: green light flashing + * 6: yellow light flashing + * 7: red light flashing + * 8:blue light flashing + * + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_sys_led_status(char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_set_sys_led_status - Used to set sys led status + * @status: led status, led status value define as below: + * 0: dark + * 1: green + * 2: yellow + * 3: red + * 4:blue + * 5: green light flashing + * 6: yellow light flashing + * 7: red light flashing + * 8:blue light flashing + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int demo_set_sys_led_status(int status) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* Similar to demo_get_sys_led_status */ +static ssize_t demo_get_bmc_led_status(char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* Similar to demo_set_sys_led_status */ +static int demo_set_bmc_led_status(int status) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* Similar to demo_get_sys_led_status */ +static ssize_t demo_get_sys_fan_led_status(char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* Similar to demo_set_sys_led_status */ +static int demo_set_sys_fan_led_status(int status) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* Similar to demo_get_sys_led_status */ +static ssize_t demo_get_sys_psu_led_status(char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* Similar to demo_set_sys_led_status */ +static int demo_set_sys_psu_led_status(int status) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* Similar to demo_get_sys_led_status */ +static ssize_t demo_get_id_led_status(char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* Similar to demo_set_sys_led_status */ +static int demo_set_id_led_status(int status) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/**************************************end of sysled******************************************/ + +static struct s3ip_sysfs_sysled_drivers_s drivers = { + /* + * set ODM sysled drivers to /sys/s3ip/sysled, + * if not support the function, set corresponding hook to NULL. + */ + .get_sys_led_status = demo_get_sys_led_status, + .set_sys_led_status = demo_set_sys_led_status, + .get_bmc_led_status = demo_get_bmc_led_status, + .set_bmc_led_status = demo_set_bmc_led_status, + .get_sys_fan_led_status = demo_get_sys_fan_led_status, + .set_sys_fan_led_status = demo_set_sys_fan_led_status, + .get_sys_psu_led_status = demo_get_sys_psu_led_status, + .set_sys_psu_led_status = demo_set_sys_psu_led_status, + .get_id_led_status = demo_get_id_led_status, + .set_id_led_status = demo_set_id_led_status, +}; + +static int __init sysled_init(void) +{ + int ret; + + SYSLED_INFO("sysled_init...\n"); + + ret = s3ip_sysfs_sysled_drivers_register(&drivers); + if (ret < 0) { + SYSLED_ERR("sysled drivers register err, ret %d.\n", ret); + return ret; + } + + SYSLED_INFO("sysled create success.\n"); + return 0; +} + +static void __exit sysled_exit(void) +{ + s3ip_sysfs_sysled_drivers_unregister(); + SYSLED_INFO("sysled_exit ok.\n"); + return; +} + +module_init(sysled_init); +module_exit(sysled_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4, all=0xf).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_DESCRIPTION("sysled device driver"); diff --git a/platform/s3ip-sysfs/demo_driver/temp_sensor_device_driver.c b/platform/s3ip-sysfs/demo_driver/temp_sensor_device_driver.c new file mode 100644 index 000000000000..e49887f2ee59 --- /dev/null +++ b/platform/s3ip-sysfs/demo_driver/temp_sensor_device_driver.c @@ -0,0 +1,196 @@ +/* + * temp_sensor_device_driver.c + * + * This module realize /sys/s3ip/temp_sensor attributes read and write functions + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "device_driver_common.h" +#include "temp_sensor_sysfs.h" + +#define TEMP_SENSOR_INFO(fmt, args...) LOG_INFO("temp_sensor: ", fmt, ##args) +#define TEMP_SENSOR_ERR(fmt, args...) LOG_ERR("temp_sensor: ", fmt, ##args) +#define TEMP_SENSOR_DBG(fmt, args...) LOG_DBG("temp_sensor: ", fmt, ##args) + +static int g_loglevel = 0; + +/***************************************main board temp*****************************************/ +/* + * demo_get_main_board_temp_number - Used to get main board temperature sensors number, + * + * This function returns main board temperature sensors by your switch, + * If there is no main board temperature sensors, returns 0, + * otherwise it returns a negative value on failed. + */ +static int demo_get_main_board_temp_number(void) +{ + /* add vendor codes here */ + return 1; +} + +/* + * demo_get_main_board_temp_alias - Used to identify the location of the temperature sensor, + * such as air_inlet, air_outlet and so on. + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_main_board_temp_alias(unsigned int temp_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_main_board_temp_type - Used to get the model of temperature sensor, + * such as lm75, tmp411 and so on + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_main_board_temp_type(unsigned int temp_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_main_board_temp_max - Used to get the maximum threshold of temperature sensor + * filled the value to buf, and the value keep three decimal places + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_main_board_temp_max(unsigned int temp_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_set_main_board_temp_max - Used to set the maximum threshold of temperature sensor + * get value from buf and set it to maximum threshold of temperature sensor + * @temp_index: start with 1 + * @buf: the buf store the data to be set, eg '80.000' + * @count: length of buf + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int demo_set_main_board_temp_max(unsigned int temp_index, const char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_main_board_temp_min - Used to get the minimum threshold of temperature sensor + * filled the value to buf, and the value keep three decimal places + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_main_board_temp_min(unsigned int temp_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_set_main_board_temp_min - Used to set the minimum threshold of temperature sensor + * get value from buf and set it to minimum threshold of temperature sensor + * @temp_index: start with 1 + * @buf: the buf store the data to be set, eg '50.000' + * @count: length of buf + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int demo_set_main_board_temp_min(unsigned int temp_index, const char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_main_board_temp_value - Used to get the input value of temperature sensor + * filled the value to buf, and the value keep three decimal places + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_main_board_temp_value(unsigned int temp_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} +/***********************************end of main board temp*************************************/ + +static struct s3ip_sysfs_temp_sensor_drivers_s drivers = { + /* + * set ODM temperature sensor drivers to /sys/s3ip/temp_sensor, + * if not support the function, set corresponding hook to NULL. + */ + .get_main_board_temp_number = demo_get_main_board_temp_number, + .get_main_board_temp_alias = demo_get_main_board_temp_alias, + .get_main_board_temp_type = demo_get_main_board_temp_type, + .get_main_board_temp_max = demo_get_main_board_temp_max, + .set_main_board_temp_max = demo_set_main_board_temp_max, + .get_main_board_temp_min = demo_get_main_board_temp_min, + .set_main_board_temp_min = demo_set_main_board_temp_min, + .get_main_board_temp_value = demo_get_main_board_temp_value, +}; + +static int __init temp_sensor_dev_drv_init(void) +{ + int ret; + + TEMP_SENSOR_INFO("temp_sensor_init...\n"); + + ret = s3ip_sysfs_temp_sensor_drivers_register(&drivers); + if (ret < 0) { + TEMP_SENSOR_ERR("temp sensor drivers register err, ret %d.\n", ret); + return ret; + } + TEMP_SENSOR_INFO("temp_sensor_init success.\n"); + return 0; +} + +static void __exit temp_sensor_dev_drv_exit(void) +{ + s3ip_sysfs_temp_sensor_drivers_unregister(); + TEMP_SENSOR_INFO("temp_sensor_exit success.\n"); + return; +} + +module_init(temp_sensor_dev_drv_init); +module_exit(temp_sensor_dev_drv_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4, all=0xf).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_DESCRIPTION("temperature sensors device driver"); diff --git a/platform/s3ip-sysfs/demo_driver/transceiver_device_driver.c b/platform/s3ip-sysfs/demo_driver/transceiver_device_driver.c new file mode 100644 index 000000000000..b89e1d7aa5b3 --- /dev/null +++ b/platform/s3ip-sysfs/demo_driver/transceiver_device_driver.c @@ -0,0 +1,335 @@ +/* + * transceiver_device_driver.c + * + * This module realize /sys/s3ip/transceiver attributes read and write functions + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "device_driver_common.h" +#include "transceiver_sysfs.h" + +#define SFF_INFO(fmt, args...) LOG_INFO("sff: ", fmt, ##args) +#define SFF_ERR(fmt, args...) LOG_ERR("sff: ", fmt, ##args) +#define SFF_DBG(fmt, args...) LOG_DBG("sff: ", fmt, ##args) + +static int g_loglevel = 0; + +/****************************************transceiver******************************************/ +static int demo_get_eth_number(void) +{ + /* add vendor codes here */ + return 1; +} + +/* + * demo_get_transceiver_power_on_status - Used to get the whole machine port power on status, + * filled the value to buf, 0: power off, 1: power on + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_transceiver_power_on_status(char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_set_transceiver_power_on_status - Used to set the whole machine port power on status, + * @status: power on status, 0: power off, 1: power on + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int demo_set_transceiver_power_on_status(int status) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_eth_power_on_status - Used to get single port power on status, + * filled the value to buf, 0: power off, 1: power on + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_eth_power_on_status(unsigned int eth_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_set_eth_power_on_status - Used to set single port power on status, + * @eth_index: start with 1 + * @status: power on status, 0: power off, 1: power on + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int demo_set_eth_power_on_status(unsigned int eth_index, int status) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_eth_tx_fault_status - Used to get port tx_fault status, + * filled the value to buf, 0: normal, 1: abnormal + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_eth_tx_fault_status(unsigned int eth_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_eth_tx_disable_status - Used to get port tx_disable status, + * filled the value to buf, 0: tx_enable, 1: tx_disable + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_eth_tx_disable_status(unsigned int eth_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_set_eth_tx_disable_status - Used to set port tx_disable status, + * @eth_index: start with 1 + * @status: tx_disable status, 0: tx_enable, 1: tx_disable + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int demo_set_eth_tx_disable_status(unsigned int eth_index, int status) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_eth_present_status - Used to get port present status, + * filled the value to buf, 1: present, 0: absent + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_eth_present_status(unsigned int eth_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_eth_rx_los_status - Used to get port rx_los status, + * filled the value to buf, 0: normal, 1: abnormal + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_eth_rx_los_status(unsigned int eth_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_eth_reset_status - Used to get port reset status, + * filled the value to buf, 0: unreset, 1: reset + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_eth_reset_status(unsigned int eth_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_set_eth_reset_status - Used to set port reset status, + * @eth_index: start with 1 + * @status: reset status, 0: unreset, 1: reset + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int demo_set_eth_reset_status(unsigned int eth_index, int status) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_eth_low_power_mode_status - Used to get port low power mode status, + * filled the value to buf, 0: high power mode, 1: low power mode + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_eth_low_power_mode_status(unsigned int eth_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_eth_interrupt_status - Used to get port interruption status, + * filled the value to buf, 0: no interruption, 1: interruption + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_eth_interrupt_status(unsigned int eth_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_eth_eeprom_size - Used to get port eeprom size + * + * This function returns the size of port eeprom, + * otherwise it returns a negative value on failed. + */ +static int demo_get_eth_eeprom_size(unsigned int eth_index) +{ + /* add vendor codes here */ + return 0x8180; +} + +/* + * demo_read_eth_eeprom_data - Used to read port eeprom data, + * @buf: Data read buffer + * @offset: offset address to read port eeprom data + * @count: length of buf + * + * This function returns the length of the filled buffer, + * returns 0 means EOF, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_read_eth_eeprom_data(unsigned int eth_index, char *buf, loff_t offset, + size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_write_eth_eeprom_data - Used to write port eeprom data + * @buf: Data write buffer + * @offset: offset address to write port eeprom data + * @count: length of buf + * + * This function returns the written length of port eeprom, + * returns 0 means EOF, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_write_eth_eeprom_data(unsigned int eth_index, char *buf, loff_t offset, + size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} +/************************************end of transceiver***************************************/ + +static struct s3ip_sysfs_transceiver_drivers_s drivers = { + /* + * set ODM transceiver drivers to /sys/s3ip/transceiver, + * if not support the function, set corresponding hook to NULL. + */ + .get_eth_number = demo_get_eth_number, + .get_transceiver_power_on_status = demo_get_transceiver_power_on_status, + .set_transceiver_power_on_status = demo_set_transceiver_power_on_status, + .get_eth_power_on_status = demo_get_eth_power_on_status, + .set_eth_power_on_status = demo_set_eth_power_on_status, + .get_eth_tx_fault_status = demo_get_eth_tx_fault_status, + .get_eth_tx_disable_status = demo_get_eth_tx_disable_status, + .set_eth_tx_disable_status = demo_set_eth_tx_disable_status, + .get_eth_present_status = demo_get_eth_present_status, + .get_eth_rx_los_status = demo_get_eth_rx_los_status, + .get_eth_reset_status = demo_get_eth_reset_status, + .set_eth_reset_status = demo_set_eth_reset_status, + .get_eth_low_power_mode_status = demo_get_eth_low_power_mode_status, + .get_eth_interrupt_status = demo_get_eth_interrupt_status, + .get_eth_eeprom_size = demo_get_eth_eeprom_size, + .read_eth_eeprom_data = demo_read_eth_eeprom_data, + .write_eth_eeprom_data = demo_write_eth_eeprom_data, +}; + +static int __init sff_dev_drv_init(void) +{ + int ret; + + SFF_INFO("sff_init...\n"); + + ret = s3ip_sysfs_sff_drivers_register(&drivers); + if (ret < 0) { + SFF_ERR("transceiver drivers register err, ret %d.\n", ret); + return ret; + } + SFF_INFO("sff_init success.\n"); + return 0; +} + +static void __exit sff_dev_drv_exit(void) +{ + s3ip_sysfs_sff_drivers_unregister(); + SFF_INFO("sff_exit success.\n"); + return; +} + +module_init(sff_dev_drv_init); +module_exit(sff_dev_drv_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4, all=0xf).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_DESCRIPTION("transceiver device driver"); diff --git a/platform/s3ip-sysfs/demo_driver/vol_sensor_device_driver.c b/platform/s3ip-sysfs/demo_driver/vol_sensor_device_driver.c new file mode 100644 index 000000000000..1c2b2fa7af59 --- /dev/null +++ b/platform/s3ip-sysfs/demo_driver/vol_sensor_device_driver.c @@ -0,0 +1,224 @@ +/* + * vol_sensor_device_driver.c + * + * This module realize /sys/s3ip/vol_sensor attributes read and write functions + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "device_driver_common.h" +#include "vol_sensor_sysfs.h" + +#define VOL_SENSOR_INFO(fmt, args...) LOG_INFO("vol_sensor: ", fmt, ##args) +#define VOL_SENSOR_ERR(fmt, args...) LOG_ERR("vol_sensor: ", fmt, ##args) +#define VOL_SENSOR_DBG(fmt, args...) LOG_DBG("vol_sensor: ", fmt, ##args) + +static int g_loglevel = 0; + +/*************************************main board voltage***************************************/ +static int demo_get_main_board_vol_number(void) +{ + /* add vendor codes here */ + return 1; +} + +/* + * demo_get_main_board_vol_alias - Used to identify the location of the voltage sensor, + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_main_board_vol_alias(unsigned int vol_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_main_board_vol_type - Used to get the model of voltage sensor, + * such as udc90160, tps53622 and so on + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_main_board_vol_type(unsigned int vol_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_main_board_vol_max - Used to get the maximum threshold of voltage sensor + * filled the value to buf, and the value keep three decimal places + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_main_board_vol_max(unsigned int vol_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_set_main_board_vol_max - Used to set the maximum threshold of volatge sensor + * get value from buf and set it to maximum threshold of volatge sensor + * @vol_index: start with 1 + * @buf: the buf store the data to be set, eg '3.567' + * @count: length of buf + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int demo_set_main_board_vol_max(unsigned int vol_index, const char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_main_board_vol_min - Used to get the minimum threshold of voltage sensor + * filled the value to buf, and the value keep three decimal places + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_main_board_vol_min(unsigned int vol_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_set_main_board_vol_min - Used to set the minimum threshold of voltage sensor + * get value from buf and set it to minimum threshold of voltage sensor + * @temp_index: start with 1 + * @buf: the buf store the data to be set, eg '3.123' + * @count: length of buf + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int demo_set_main_board_vol_min(unsigned int vol_index, const char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_main_board_vol_range - Used to get the output error value of voltage sensor + * filled the value to buf + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_main_board_vol_range(unsigned int vol_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_main_board_vol_nominal_value - Used to get the nominal value of voltage sensor + * filled the value to buf + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_main_board_vol_nominal_value(unsigned int vol_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_main_board_vol_value - Used to get the input value of voltage sensor + * filled the value to buf, and the value keep three decimal places + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_main_board_vol_value(unsigned int vol_index, char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} +/*********************************end of main board voltage************************************/ + +static struct s3ip_sysfs_vol_sensor_drivers_s drivers = { + /* + * set ODM voltage sensor drivers to /sys/s3ip/vol_sensor, + * if not support the function, set corresponding hook to NULL. + */ + .get_main_board_vol_number = demo_get_main_board_vol_number, + .get_main_board_vol_alias = demo_get_main_board_vol_alias, + .get_main_board_vol_type = demo_get_main_board_vol_type, + .get_main_board_vol_max = demo_get_main_board_vol_max, + .set_main_board_vol_max = demo_set_main_board_vol_max, + .get_main_board_vol_min = demo_get_main_board_vol_min, + .set_main_board_vol_min = demo_set_main_board_vol_min, + .get_main_board_vol_range = demo_get_main_board_vol_range, + .get_main_board_vol_nominal_value = demo_get_main_board_vol_nominal_value, + .get_main_board_vol_value = demo_get_main_board_vol_value, +}; + +static int __init vol_sensor_dev_drv_init(void) +{ + int ret; + + VOL_SENSOR_INFO("vol_sensor_init...\n"); + + ret = s3ip_sysfs_vol_sensor_drivers_register(&drivers); + if (ret < 0) { + VOL_SENSOR_ERR("vol sensor drivers register err, ret %d.\n", ret); + return ret; + } + VOL_SENSOR_INFO("vol_sensor_init success.\n"); + return 0; +} + +static void __exit vol_sensor_dev_drv_exit(void) +{ + s3ip_sysfs_vol_sensor_drivers_unregister(); + VOL_SENSOR_INFO("vol_sensor_exit success.\n"); + return; +} + +module_init(vol_sensor_dev_drv_init); +module_exit(vol_sensor_dev_drv_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4, all=0xf).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_DESCRIPTION("voltage sensors device driver"); diff --git a/platform/s3ip-sysfs/demo_driver/watchdog_device_driver.c b/platform/s3ip-sysfs/demo_driver/watchdog_device_driver.c new file mode 100755 index 000000000000..2cb5852a9908 --- /dev/null +++ b/platform/s3ip-sysfs/demo_driver/watchdog_device_driver.c @@ -0,0 +1,166 @@ +/* + * watchdog_device_driver.c + * + * This module realize /sys/s3ip/watchdog attributes read and write functions + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "device_driver_common.h" +#include "watchdog_sysfs.h" + +#define WDT_INFO(fmt, args...) LOG_INFO("watchdog: ", fmt, ##args) +#define WDT_ERR(fmt, args...) LOG_ERR("watchdog: ", fmt, ##args) +#define WDT_DBG(fmt, args...) LOG_DBG("watchdog: ", fmt, ##args) + +static int g_loglevel = 0; + +/****************************************watchdog*********************************************/ +/* + * demo_get_watchdog_identify - Used to get watchdog identify, such as iTCO_wdt + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_watchdog_identify(char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_watchdog_timeleft - Used to get watchdog timeleft, + * filled the value to buf + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_watchdog_timeleft(char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_watchdog_timeout - Used to get watchdog timeout, + * filled the value to buf + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_watchdog_timeout(char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_set_watchdog_timeout - Used to set watchdog timeout, + * @value: timeout value + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int demo_set_watchdog_timeout(int value) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_watchdog_enable_status - Used to get watchdog enable status, + * filled the value to buf, 0: disable, 1: enable + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t demo_get_watchdog_enable_status(char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_set_watchdog_enable_status - Used to set watchdog enable status, + * @value: enable status value, 0: disable, 1: enable + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int demo_set_watchdog_enable_status(int value) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * demo_get_watchdog_state - Used to get watchdog state, + * filled the value to buf, 0: inactive, 1: active + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static int demo_set_watchdog_reset(int value) +{ + /* add vendor codes here */ + return -ENOSYS; +} +/*************************************end of watchdog*****************************************/ + +static struct s3ip_sysfs_watchdog_drivers_s drivers = { + /* + * set ODM watchdog sensor drivers to /sys/s3ip/watchdog, + * if not support the function, set corresponding hook to NULL. + */ + .get_watchdog_identify = demo_get_watchdog_identify, + .get_watchdog_timeleft = demo_get_watchdog_timeleft, + .get_watchdog_timeout = demo_get_watchdog_timeout, + .set_watchdog_timeout = demo_set_watchdog_timeout, + .get_watchdog_enable_status = demo_get_watchdog_enable_status, + .set_watchdog_enable_status = demo_set_watchdog_enable_status, + .set_watchdog_reset = demo_set_watchdog_reset, +}; + +static int __init watchdog_dev_drv_init(void) +{ + int ret; + + WDT_INFO("watchdog_init...\n"); + + ret = s3ip_sysfs_watchdog_drivers_register(&drivers); + if (ret < 0) { + WDT_ERR("watchdog drivers register err, ret %d.\n", ret); + return ret; + } + WDT_INFO("watchdog create success.\n"); + return 0; +} + +static void __exit watchdog_dev_drv_exit(void) +{ + s3ip_sysfs_watchdog_drivers_unregister(); + WDT_INFO("watchdog_exit success.\n"); + return; +} + +module_init(watchdog_dev_drv_init); +module_exit(watchdog_dev_drv_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4, all=0xf).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_DESCRIPTION("watchdog device driver"); diff --git a/platform/s3ip-sysfs/s3ip_sysfs_frame/Makefile b/platform/s3ip-sysfs/s3ip_sysfs_frame/Makefile new file mode 100755 index 000000000000..38ed6083335a --- /dev/null +++ b/platform/s3ip-sysfs/s3ip_sysfs_frame/Makefile @@ -0,0 +1,27 @@ +PWD = $(shell pwd) + +EXTRA_CFLAGS:= -I$(M)/include +EXTRA_CFLAGS+= -Wall + +s3ip_sysfs-objs := switch.o cpld_sysfs.o \ +curr_sensor_sysfs.o \ +fan_sysfs.o \ +fpga_sysfs.o \ +psu_sysfs.o \ +slot_sysfs.o \ +sysled_sysfs.o \ +temp_sensor_sysfs.o \ +transceiver_sysfs.o \ +vol_sensor_sysfs.o \ +watchdog_sysfs.o \ + +obj-m := s3ip_sysfs.o + +all: + $(MAKE) -C $(KERNEL_SRC)/build M=$(PWD) modules + @if [ ! -d $(sysfs_out_put_dir) ]; then mkdir -p $(sysfs_out_put_dir) ;fi + cp -p $(PWD)/*.ko $(sysfs_out_put_dir) +clean: + rm -f $(PWD)/*.o $(PWD)/*.ko $(PWD)/*.mod.c $(PWD)/.*.cmd + rm -f $(PWD)/Module.markers $(PWD)/Module.symvers $(PWD)/modules.order + rm -rf $(PWD)/.tmp_versions \ No newline at end of file diff --git a/platform/s3ip-sysfs/s3ip_sysfs_frame/cpld_sysfs.c b/platform/s3ip-sysfs/s3ip_sysfs_frame/cpld_sysfs.c new file mode 100644 index 000000000000..9e3efaca497a --- /dev/null +++ b/platform/s3ip-sysfs/s3ip_sysfs_frame/cpld_sysfs.c @@ -0,0 +1,365 @@ +/* + * cpld_sysfs.c + * + * This module create cpld kobjects and attributes in /sys/s3ip/cpld + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "switch.h" +#include "cpld_sysfs.h" + +static int g_cpld_loglevel = 0; + +#define CPLD_INFO(fmt, args...) do { \ + if (g_cpld_loglevel & INFO) { \ + printk(KERN_INFO "[CPLD_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define CPLD_ERR(fmt, args...) do { \ + if (g_cpld_loglevel & ERR) { \ + printk(KERN_ERR "[CPLD_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define CPLD_DBG(fmt, args...) do { \ + if (g_cpld_loglevel & DBG) { \ + printk(KERN_DEBUG "[CPLD_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +struct cpld_obj_s { + struct switch_obj *obj; +}; + +struct cpld_s { + unsigned int cpld_number; + struct cpld_obj_s *cpld; +}; + +static struct cpld_s g_cpld; +static struct switch_obj *g_cpld_obj = NULL; +static struct s3ip_sysfs_cpld_drivers_s *g_cpld_drv = NULL; + +static ssize_t cpld_number_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + return (ssize_t)snprintf(buf, PAGE_SIZE, "%u\n", g_cpld.cpld_number); +} + +static ssize_t cpld_alias_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int cpld_index; + int ret; + + check_p(g_cpld_drv); + check_p(g_cpld_drv->get_main_board_cpld_alias); + + cpld_index = obj->index; + CPLD_DBG("cpld index: %u\n", cpld_index); + ret = g_cpld_drv->get_main_board_cpld_alias(cpld_index, buf, PAGE_SIZE); + if (ret < 0) { + CPLD_ERR("get cpld%u alias failed, ret: %d\n", cpld_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t cpld_type_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int cpld_index; + int ret; + + check_p(g_cpld_drv); + check_p(g_cpld_drv->get_main_board_cpld_type); + + cpld_index = obj->index; + CPLD_DBG("cpld index: %u\n", cpld_index); + ret = g_cpld_drv->get_main_board_cpld_type(cpld_index, buf, PAGE_SIZE); + if (ret < 0) { + CPLD_ERR("get cpld%u type failed, ret: %d\n", cpld_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t cpld_fw_version_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int cpld_index; + int ret; + + check_p(g_cpld_drv); + check_p(g_cpld_drv->get_main_board_cpld_firmware_version); + + cpld_index = obj->index; + CPLD_DBG("cpld index: %u\n", cpld_index); + ret = g_cpld_drv->get_main_board_cpld_firmware_version(cpld_index, buf, PAGE_SIZE); + if (ret < 0) { + CPLD_ERR("get cpld%u firmware version failed, ret: %d\n", cpld_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t cpld_board_version_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int cpld_index; + int ret; + + check_p(g_cpld_drv); + check_p(g_cpld_drv->get_main_board_cpld_board_version); + + cpld_index = obj->index; + CPLD_DBG("cpld index: %u\n", cpld_index); + ret = g_cpld_drv->get_main_board_cpld_board_version(cpld_index, buf, PAGE_SIZE); + if (ret < 0) { + CPLD_ERR("get cpld%u board version failed, ret: %d\n", cpld_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t cpld_test_reg_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int cpld_index; + int ret; + + check_p(g_cpld_drv); + check_p(g_cpld_drv->get_main_board_cpld_test_reg); + + cpld_index = obj->index; + CPLD_DBG("cpld index: %u\n", cpld_index); + ret = g_cpld_drv->get_main_board_cpld_test_reg(cpld_index, buf, PAGE_SIZE); + if (ret < 0) { + CPLD_ERR("get cpld%u test register failed, ret: %d\n", cpld_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t cpld_test_reg_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int cpld_index, value; + int ret; + + check_p(g_cpld_drv); + check_p(g_cpld_drv->set_main_board_cpld_test_reg); + + cpld_index = obj->index; + sscanf(buf, "0x%x", &value); + ret = g_cpld_drv->set_main_board_cpld_test_reg(cpld_index, value); + if (ret < 0) { + CPLD_ERR("set cpld%u test reg failed, value:0x%x, ret: %d.\n", cpld_index, value, ret); + return -EIO; + } + CPLD_DBG("set cpld%u test reg success, value: 0x%x.\n", cpld_index, value); + return count; +} + +/************************************cpld dir and attrs*******************************************/ +static struct switch_attribute cpld_number_att = __ATTR(number, S_IRUGO, cpld_number_show, NULL); + +static struct attribute *cpld_dir_attrs[] = { + &cpld_number_att.attr, + NULL, +}; + +static struct attribute_group cpld_root_attr_group = { + .attrs = cpld_dir_attrs, +}; + +/*******************************cpld[1-n] dir and attrs*******************************************/ +static struct switch_attribute cpld_alias_attr = __ATTR(alias, S_IRUGO, cpld_alias_show, NULL); +static struct switch_attribute cpld_type_attr = __ATTR(type, S_IRUGO, cpld_type_show, NULL); +static struct switch_attribute cpld_fw_version_attr = __ATTR(firmware_version, S_IRUGO, cpld_fw_version_show, NULL); +static struct switch_attribute cpld_board_version_attr = __ATTR(board_version, S_IRUGO, cpld_board_version_show, NULL); +static struct switch_attribute cpld_test_reg_attr = __ATTR(reg_test, S_IRUGO | S_IWUSR, cpld_test_reg_show, cpld_test_reg_store); + +static struct attribute *cpld_attrs[] = { + &cpld_alias_attr.attr, + &cpld_type_attr.attr, + &cpld_fw_version_attr.attr, + &cpld_board_version_attr.attr, + &cpld_test_reg_attr.attr, + NULL, +}; + +static struct attribute_group cpld_attr_group = { + .attrs = cpld_attrs, +}; + +static int cpld_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct cpld_obj_s *curr_cpld; + + curr_cpld = &g_cpld.cpld[index - 1]; + if (curr_cpld->obj) { + sysfs_remove_group(&curr_cpld->obj->kobj, &cpld_attr_group); + switch_kobject_delete(&curr_cpld->obj); + CPLD_DBG("delete cpld%u dir and attrs success.\n", index); + } + + return 0; +} + +static int cpld_sub_single_create_kobj_and_attrs(struct kobject *parent, unsigned int index) +{ + char name[8]; + struct cpld_obj_s *curr_cpld; + + curr_cpld = &g_cpld.cpld[index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "cpld%u", index); + curr_cpld->obj = switch_kobject_create(name, parent); + if (!curr_cpld->obj) { + CPLD_ERR("create %s object error!\n", name); + return -EBADRQC; + } + curr_cpld->obj->index = index; + if (sysfs_create_group(&curr_cpld->obj->kobj, &cpld_attr_group) != 0) { + CPLD_ERR("create %s attrs error.\n", name); + switch_kobject_delete(&curr_cpld->obj); + return -EBADRQC; + } + CPLD_DBG("create %s dir and attrs success.\n", name); + return 0; +} + +static int cpld_sub_create_kobj_and_attrs(struct kobject *parent, int cpld_num) +{ + unsigned int cpld_index, i; + + g_cpld.cpld = kzalloc(sizeof(struct cpld_obj_s) * cpld_num, GFP_KERNEL); + if (!g_cpld.cpld) { + CPLD_ERR("kzalloc g_cpld.cpld error, cpld number = %d.\n", cpld_num); + return -ENOMEM; + } + + for(cpld_index = 1; cpld_index <= cpld_num; cpld_index++) { + if(cpld_sub_single_create_kobj_and_attrs(parent, cpld_index) != 0) { + goto error; + } + } + return 0; +error: + for(i = cpld_index; i > 0; i--) { + cpld_sub_single_remove_kobj_and_attrs(i); + } + kfree(g_cpld.cpld); + g_cpld.cpld = NULL; + return -EBADRQC; +} + +/* create cpld[1-n] directory and attributes*/ +static int cpld_sub_create(void) +{ + int ret; + + ret = cpld_sub_create_kobj_and_attrs(&g_cpld_obj->kobj, g_cpld.cpld_number); + return ret; +} + +/* delete cpld[1-n] directory and attributes*/ +static void cpld_sub_remove(void) +{ + unsigned int cpld_index; + + if (g_cpld.cpld) { + for (cpld_index = g_cpld.cpld_number; cpld_index > 0; cpld_index--) { + cpld_sub_single_remove_kobj_and_attrs(cpld_index); + } + kfree(g_cpld.cpld); + g_cpld.cpld = NULL; + } + g_cpld.cpld_number = 0; + return; +} + +/* create cpld directory and number attributes */ +static int cpld_root_create(void) +{ + g_cpld_obj = switch_kobject_create("cpld", NULL); + if (!g_cpld_obj) { + CPLD_ERR("switch_kobject_create cpld error!\n"); + return -ENOMEM; + } + + if (sysfs_create_group(&g_cpld_obj->kobj, &cpld_root_attr_group) != 0) { + switch_kobject_delete(&g_cpld_obj); + CPLD_ERR("create cpld dir attrs error!\n"); + return -EBADRQC; + } + return 0; +} + +/* delete cpld directory and number attributes */ +static void cpld_root_remove(void) +{ + if (g_cpld_obj) { + sysfs_remove_group(&g_cpld_obj->kobj, &cpld_root_attr_group); + switch_kobject_delete(&g_cpld_obj); + } + + return; +} + +int s3ip_sysfs_cpld_drivers_register(struct s3ip_sysfs_cpld_drivers_s *drv) +{ + int ret, cpld_num; + + CPLD_INFO("s3ip_sysfs_cpld_drivers_register...\n"); + if (g_cpld_drv) { + CPLD_ERR("g_cpld_drv is not NULL, can't register\n"); + return -EPERM; + } + + check_p(drv); + check_p(drv->get_main_board_cpld_number); + g_cpld_drv = drv; + + cpld_num = g_cpld_drv->get_main_board_cpld_number(); + if (cpld_num <= 0) { + CPLD_ERR("cpld number: %d, don't need to create cpld dirs and attrs.\n", cpld_num); + g_cpld_drv = NULL; + return -EINVAL; + } + + memset(&g_cpld, 0, sizeof(struct cpld_s)); + g_cpld.cpld_number = cpld_num; + ret = cpld_root_create(); + if (ret < 0) { + CPLD_ERR("create cpld root dir and attrs failed, ret: %d\n", ret); + g_cpld_drv = NULL; + return ret; + } + ret = cpld_sub_create(); + if (ret < 0) { + CPLD_ERR("create cpld sub dir and attrs failed, ret: %d\n", ret); + cpld_root_remove(); + g_cpld_drv = NULL; + return ret; + } + CPLD_INFO("s3ip_sysfs_cpld_drivers_register success\n"); + return 0; +} + +void s3ip_sysfs_cpld_drivers_unregister(void) +{ + if (g_cpld_drv) { + cpld_sub_remove(); + cpld_root_remove(); + g_cpld_drv = NULL; + CPLD_DBG("s3ip_sysfs_cpld_drivers_unregister success.\n"); + } + return; +} + +EXPORT_SYMBOL(s3ip_sysfs_cpld_drivers_register); +EXPORT_SYMBOL(s3ip_sysfs_cpld_drivers_unregister); +module_param(g_cpld_loglevel, int, 0644); +MODULE_PARM_DESC(g_cpld_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); diff --git a/platform/s3ip-sysfs/s3ip_sysfs_frame/curr_sensor_sysfs.c b/platform/s3ip-sysfs/s3ip_sysfs_frame/curr_sensor_sysfs.c new file mode 100644 index 000000000000..7972dd9b3ee1 --- /dev/null +++ b/platform/s3ip-sysfs/s3ip_sysfs_frame/curr_sensor_sysfs.c @@ -0,0 +1,391 @@ +/* + * curr_sensor_sysfs.c + * + * This module create curr sensor kobjects and attributes in /sys/s3ip/curr_sensor + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "switch.h" +#include "curr_sensor_sysfs.h" + +static int g_curr_sensor_loglevel = 0; + +#define CURR_SENSOR_INFO(fmt, args...) do { \ + if (g_curr_sensor_loglevel & INFO) { \ + printk(KERN_INFO "[CURR_SENSOR][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define CURR_SENSOR_ERR(fmt, args...) do { \ + if (g_curr_sensor_loglevel & ERR) { \ + printk(KERN_ERR "[CURR_SENSOR][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define CURR_SENSOR_DBG(fmt, args...) do { \ + if (g_curr_sensor_loglevel & DBG) { \ + printk(KERN_DEBUG "[CURR_SENSOR][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +struct curr_sensor_obj_s { + struct switch_obj *obj; +}; + +struct curr_sensor_s { + unsigned int curr_number; + struct curr_sensor_obj_s *curr; +}; + +static struct s3ip_sysfs_curr_sensor_drivers_s *g_curr_sensor_drv = NULL; +static struct curr_sensor_s g_curr_sensor; +static struct switch_obj *g_curr_sensor_obj = NULL; + +static ssize_t curr_sensor_number_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + return (ssize_t)snprintf(buf, PAGE_SIZE, "%u\n", g_curr_sensor.curr_number); +} + +static ssize_t curr_sensor_value_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int curr_index; + int ret; + + check_p(g_curr_sensor_drv); + check_p(g_curr_sensor_drv->get_main_board_curr_value); + + curr_index = obj->index; + CURR_SENSOR_DBG("curr index: %u\n", curr_index); + ret = g_curr_sensor_drv->get_main_board_curr_value(curr_index, buf, PAGE_SIZE); + if (ret < 0) { + CURR_SENSOR_ERR("get curr%u value failed, ret: %d\n", curr_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t curr_sensor_alias_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int curr_index; + int ret; + + check_p(g_curr_sensor_drv); + check_p(g_curr_sensor_drv->get_main_board_curr_alias); + + curr_index = obj->index; + CURR_SENSOR_DBG("curr index: %u\n", curr_index); + ret = g_curr_sensor_drv->get_main_board_curr_alias(curr_index, buf, PAGE_SIZE); + if (ret < 0) { + CURR_SENSOR_ERR("get curr%u alias failed, ret: %d\n", curr_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t curr_sensor_type_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int curr_index; + int ret; + + check_p(g_curr_sensor_drv); + check_p(g_curr_sensor_drv->get_main_board_curr_type); + + curr_index = obj->index; + CURR_SENSOR_DBG("curr index: %u\n", curr_index); + ret = g_curr_sensor_drv->get_main_board_curr_type(curr_index, buf, PAGE_SIZE); + if (ret < 0) { + CURR_SENSOR_ERR("get curr%u type failed, ret: %d\n", curr_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t curr_sensor_max_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int curr_index; + int ret; + + check_p(g_curr_sensor_drv); + check_p(g_curr_sensor_drv->get_main_board_curr_max); + + curr_index = obj->index; + CURR_SENSOR_DBG("curr index: %u\n", curr_index); + ret = g_curr_sensor_drv->get_main_board_curr_max(curr_index, buf, PAGE_SIZE); + if (ret < 0) { + CURR_SENSOR_ERR("get curr%u max threshold failed, ret: %d\n", curr_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t curr_sensor_max_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int curr_index; + int ret; + + check_p(g_curr_sensor_drv); + check_p(g_curr_sensor_drv->set_main_board_curr_max); + + curr_index = obj->index; + CURR_SENSOR_DBG("curr index: %u\n", curr_index); + ret = g_curr_sensor_drv->set_main_board_curr_max(curr_index, buf, count); + if (ret < 0) { + CURR_SENSOR_ERR("set curr%u max threshold failed, value: %s, count: %lu, ret: %d\n", + curr_index, buf, count, ret); + return -EIO; + } + CURR_SENSOR_DBG("set curr%u max threshold success, value: %s, count: %lu, ret: %d\n", + curr_index, buf, count, ret); + return count; +} + +static ssize_t curr_sensor_min_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int curr_index; + int ret; + + check_p(g_curr_sensor_drv); + check_p(g_curr_sensor_drv->get_main_board_curr_min); + + curr_index = obj->index; + CURR_SENSOR_DBG("curr index: %u\n", curr_index); + ret = g_curr_sensor_drv->get_main_board_curr_min(curr_index, buf, PAGE_SIZE); + if (ret < 0) { + CURR_SENSOR_ERR("get curr%u min threshold failed, ret: %d\n", curr_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t curr_sensor_min_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int curr_index; + int ret; + + check_p(g_curr_sensor_drv); + check_p(g_curr_sensor_drv->set_main_board_curr_min); + + curr_index = obj->index; + CURR_SENSOR_DBG("curr index: %u\n", curr_index); + ret = g_curr_sensor_drv->set_main_board_curr_min(curr_index, buf, count); + if (ret < 0) { + CURR_SENSOR_ERR("set curr%u min threshold failed, value: %s, count: %lu, ret: %d\n", + curr_index, buf, count, ret); + return -EIO; + } + CURR_SENSOR_DBG("set curr%u min threshold success, value: %s, count: %lu, ret: %d\n", + curr_index, buf, count, ret); + return count; +} + +/************************************curr_sensor dir and attrs*******************************************/ +static struct switch_attribute num_curr_att = __ATTR(number, S_IRUGO, curr_sensor_number_show, NULL); + +static struct attribute *curr_sensor_dir_attrs[] = { + &num_curr_att.attr, + NULL, +}; + +static struct attribute_group curr_sensor_root_attr_group = { + .attrs = curr_sensor_dir_attrs, +}; + +/*******************************curr1 curr2 dir and attrs*******************************************/ +static struct switch_attribute curr_value_attr = __ATTR(value, S_IRUGO, curr_sensor_value_show, NULL); +static struct switch_attribute curr_alias_attr = __ATTR(alias, S_IRUGO, curr_sensor_alias_show, NULL); +static struct switch_attribute curr_type_attr = __ATTR(type, S_IRUGO, curr_sensor_type_show, NULL); +static struct switch_attribute curr_max_attr = __ATTR(max, S_IRUGO | S_IWUSR, curr_sensor_max_show, curr_sensor_max_store); +static struct switch_attribute curr_min_attr = __ATTR(min, S_IRUGO | S_IWUSR, curr_sensor_min_show, curr_sensor_min_store); + +static struct attribute *curr_sensor_attrs[] = { + &curr_value_attr.attr, + &curr_alias_attr.attr, + &curr_type_attr.attr, + &curr_max_attr.attr, + &curr_min_attr.attr, + NULL, +}; + +static struct attribute_group curr_sensor_attr_group = { + .attrs = curr_sensor_attrs, +}; + +static int curr_sensor_sub_single_create_kobj_and_attrs(struct kobject *parent, unsigned int index) +{ + char name[DIR_NAME_MAX_LEN]; + struct curr_sensor_obj_s *curr_sensor; + + curr_sensor = &g_curr_sensor.curr[index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "curr%u", index); + curr_sensor->obj = switch_kobject_create(name, parent); + if (!curr_sensor->obj) { + CURR_SENSOR_ERR("create %s object error.\n", name); + return -ENOMEM; + } + curr_sensor->obj->index = index; + if (sysfs_create_group(&curr_sensor->obj->kobj, &curr_sensor_attr_group) != 0) { + CURR_SENSOR_ERR("create %s attrs error.\n", name); + switch_kobject_delete(&curr_sensor->obj); + return -EBADRQC; + } + CURR_SENSOR_DBG("create %s dir and attrs success.\n", name); + return 0; +} + +static void curr_sensor_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct curr_sensor_obj_s *curr_sensor; + + curr_sensor = &g_curr_sensor.curr[index - 1]; + if (curr_sensor->obj) { + sysfs_remove_group(&curr_sensor->obj->kobj, &curr_sensor_attr_group); + switch_kobject_delete(&curr_sensor->obj); + CURR_SENSOR_DBG("delete curr%u dir and attrs success.\n", index); + } + + return; +} + +static int curr_sensor_sub_create_kobj_and_attrs(struct kobject *parent, int curr_num) +{ + unsigned int curr_index, i; + + g_curr_sensor.curr = kzalloc(sizeof(struct curr_sensor_obj_s) * curr_num, GFP_KERNEL); + if (!g_curr_sensor.curr) { + CURR_SENSOR_ERR("kzalloc g_curr_sensor.curr error, curr number: %d.\n", curr_num); + return -ENOMEM; + } + + for (curr_index = 1; curr_index <= curr_num; curr_index++) { + if (curr_sensor_sub_single_create_kobj_and_attrs(parent, curr_index) != 0) { + goto error; + } + } + return 0; +error: + for (i = curr_index; i > 0; i--) { + curr_sensor_sub_single_remove_kobj_and_attrs(i); + } + kfree(g_curr_sensor.curr); + g_curr_sensor.curr = NULL; + return -EBADRQC; +} + +/* create curr[1-n] directory and attributes*/ +static int curr_sensor_sub_create(void) +{ + int ret; + + ret = curr_sensor_sub_create_kobj_and_attrs(&g_curr_sensor_obj->kobj, + g_curr_sensor.curr_number); + return ret; +} + +/* delete curr[1-n] directory and attributes*/ +static void curr_sensor_sub_remove(void) +{ + unsigned int curr_index; + + if (g_curr_sensor.curr) { + for (curr_index = g_curr_sensor.curr_number; curr_index > 0; curr_index--) { + curr_sensor_sub_single_remove_kobj_and_attrs(curr_index); + } + kfree(g_curr_sensor.curr); + g_curr_sensor.curr = NULL; + } + g_curr_sensor.curr_number = 0; + return; +} + +/* create curr_sensor directory and number attributes */ +static int curr_sensor_root_create(void) +{ + g_curr_sensor_obj = switch_kobject_create("curr_sensor", NULL); + if (!g_curr_sensor_obj) { + CURR_SENSOR_ERR("switch_kobject_create curr_sensor error!\n"); + return -ENOMEM; + } + + if (sysfs_create_group(&g_curr_sensor_obj->kobj, &curr_sensor_root_attr_group) != 0) { + switch_kobject_delete(&g_curr_sensor_obj); + CURR_SENSOR_ERR("create curr_sensor dir attrs error!\n"); + return -EBADRQC; + } + return 0; +} + +/* delete curr_sensor directory and number attributes */ +static void curr_sensor_root_remove(void) +{ + if (g_curr_sensor_obj) { + sysfs_remove_group(&g_curr_sensor_obj->kobj, &curr_sensor_root_attr_group); + switch_kobject_delete(&g_curr_sensor_obj); + } + + return; +} + +int s3ip_sysfs_curr_sensor_drivers_register(struct s3ip_sysfs_curr_sensor_drivers_s *drv) +{ + int ret, curr_num; + + CURR_SENSOR_INFO("s3ip_sysfs_curr_sensor_drivers_register...\n"); + if (g_curr_sensor_drv) { + CURR_SENSOR_ERR("g_curr_sensor_drv is not NULL, can't register\n"); + return -EPERM; + } + + check_p(drv); + check_p(drv->get_main_board_curr_number); + g_curr_sensor_drv = drv; + + curr_num = g_curr_sensor_drv->get_main_board_curr_number(); + if (curr_num <= 0) { + CURR_SENSOR_ERR("curr sensor number: %d, don't need to create curr_sensor dirs and attrs.\n", + curr_num); + return -EINVAL; + } + memset(&g_curr_sensor, 0, sizeof(struct curr_sensor_s)); + g_curr_sensor.curr_number = curr_num; + ret = curr_sensor_root_create(); + if (ret < 0) { + CURR_SENSOR_ERR("create curr_sensor root dir and attrs failed, ret: %d\n", ret); + g_curr_sensor_drv = NULL; + return ret; + } + + ret = curr_sensor_sub_create(); + if (ret < 0) { + CURR_SENSOR_ERR("create curr_sensor sub dir and attrs failed, ret: %d\n", ret); + curr_sensor_root_remove(); + g_curr_sensor_drv = NULL; + return ret; + } + CURR_SENSOR_INFO("s3ip_sysfs_curr_sensor_drivers_register success\n"); + return ret; +} + +void s3ip_sysfs_curr_sensor_drivers_unregister(void) +{ + if (g_curr_sensor_drv) { + curr_sensor_sub_remove(); + curr_sensor_root_remove(); + g_curr_sensor_drv = NULL; + CURR_SENSOR_DBG("s3ip_sysfs_curr_sensor_drivers_unregister success.\n"); + } + return; +} + +EXPORT_SYMBOL(s3ip_sysfs_curr_sensor_drivers_register); +EXPORT_SYMBOL(s3ip_sysfs_curr_sensor_drivers_unregister); +module_param(g_curr_sensor_loglevel, int, 0644); +MODULE_PARM_DESC(g_curr_sensor_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); diff --git a/platform/s3ip-sysfs/s3ip_sysfs_frame/fan_sysfs.c b/platform/s3ip-sysfs/s3ip_sysfs_frame/fan_sysfs.c new file mode 100755 index 000000000000..b9602b9e2093 --- /dev/null +++ b/platform/s3ip-sysfs/s3ip_sysfs_frame/fan_sysfs.c @@ -0,0 +1,754 @@ +/* + * fan_sysfs.c + * + * This module create fan kobjects and attributes in /sys/s3ip/fan + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "switch.h" +#include "fan_sysfs.h" + +static int g_fan_loglevel = 0; + +#define FAN_INFO(fmt, args...) do { \ + if (g_fan_loglevel & INFO) { \ + printk(KERN_INFO "[FAN_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define FAN_ERR(fmt, args...) do { \ + if (g_fan_loglevel & ERR) { \ + printk(KERN_ERR "[FAN_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define FAN_DBG(fmt, args...) do { \ + if (g_fan_loglevel & DBG) { \ + printk(KERN_DEBUG "[FAN_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +struct motor_obj_s { + struct switch_obj *obj; +}; + +struct fan_obj_s { + unsigned int motor_number; + struct motor_obj_s *motor; + struct switch_obj *obj; +}; + +struct fan_s { + unsigned int fan_number; + struct fan_obj_s *fan; +}; + +static struct fan_s g_fan; +static struct switch_obj *g_fan_obj = NULL; +static struct s3ip_sysfs_fan_drivers_s *g_fan_drv = NULL; + +static ssize_t fan_number_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", g_fan.fan_number); +} + +static ssize_t fan_motor_number_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int index; + + index = obj->index; + FAN_DBG("fan_motor_number_show, fan index: %u\n", index); + + return (ssize_t)snprintf(buf, PAGE_SIZE, "%u\n", g_fan.fan[index - 1].motor_number); +} + +static ssize_t fan_model_name_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int fan_index; + int ret; + + check_p(g_fan_drv); + check_p(g_fan_drv->get_fan_model_name); + + fan_index = obj->index; + FAN_DBG("fan index: %u\n", fan_index); + ret = g_fan_drv->get_fan_model_name(fan_index, buf, PAGE_SIZE); + if (ret < 0) { + FAN_ERR("get fan%u model name failed, ret: %d\n", fan_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fan_sn_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int fan_index; + int ret; + + check_p(g_fan_drv); + check_p(g_fan_drv->get_fan_serial_number); + + fan_index = obj->index; + FAN_DBG("fan index: %u\n", fan_index); + ret = g_fan_drv->get_fan_serial_number(fan_index, buf, PAGE_SIZE); + if (ret < 0) { + FAN_ERR("get fan%u serial number failed, ret: %d\n", fan_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fan_pn_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int fan_index; + int ret; + + check_p(g_fan_drv); + check_p(g_fan_drv->get_fan_part_number); + + fan_index = obj->index; + FAN_DBG("fan index: %u\n", fan_index); + ret = g_fan_drv->get_fan_part_number(fan_index, buf, PAGE_SIZE); + if (ret < 0) { + FAN_ERR("get fan%u part number failed, ret: %d\n", fan_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fan_hw_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int fan_index; + int ret; + + check_p(g_fan_drv); + check_p(g_fan_drv->get_fan_hardware_version); + + fan_index = obj->index; + FAN_DBG("fan index: %u\n", fan_index); + ret = g_fan_drv->get_fan_hardware_version(fan_index, buf, PAGE_SIZE); + if (ret < 0) { + FAN_ERR("get fan%u hardware version failed, ret: %d\n", fan_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fan_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int fan_index; + int ret; + + check_p(g_fan_drv); + check_p(g_fan_drv->get_fan_status); + + fan_index = obj->index; + FAN_DBG("fan index: %u\n", fan_index); + ret = g_fan_drv->get_fan_status(fan_index, buf, PAGE_SIZE); + if (ret < 0) { + FAN_ERR("get fan%u status failed, ret: %d\n", fan_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fan_led_status_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int fan_index; + int ret; + + check_p(g_fan_drv); + check_p(g_fan_drv->get_fan_led_status); + + fan_index = obj->index; + FAN_DBG("fan index: %u\n", fan_index); + ret = g_fan_drv->get_fan_led_status(fan_index, buf, PAGE_SIZE); + if (ret < 0) { + FAN_ERR("get fan%u led status failed, ret: %d\n", fan_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fan_led_status_store(struct switch_obj *obj, struct switch_attribute *attr, + const char *buf, size_t count) +{ + unsigned int fan_index; + int ret, led_status; + + check_p(g_fan_drv); + check_p(g_fan_drv->set_fan_led_status); + + fan_index = obj->index; + sscanf(buf, "%d", &led_status); + FAN_DBG("fan index: %u, led_status: %d\n", fan_index, led_status); + ret = g_fan_drv->set_fan_led_status(fan_index, led_status); + if (ret < 0) { + FAN_ERR("set fan%u led_status: %d failed, ret: %d\n", fan_index, led_status, ret); + return -EIO; + } + FAN_DBG("set fan%u led_status: %d success\n", fan_index, led_status); + return count; +} + +static ssize_t fan_motor_speed_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int fan_index, motor_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_fan_drv); + check_p(g_fan_drv->get_fan_motor_speed); + + p_obj = to_switch_obj(obj->kobj.parent); + fan_index = p_obj->index; + motor_index = obj->index; + FAN_DBG("fan index: %u, motor index: %d\n", fan_index, motor_index); + ret = g_fan_drv->get_fan_motor_speed(fan_index, motor_index, buf, PAGE_SIZE); + if (ret < 0) { + FAN_ERR("get fan%u motor%u speed failed, ret: %d\n", fan_index, motor_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fan_motor_speed_tolerance_show(struct switch_obj *obj, + struct switch_attribute *attr, char *buf) +{ + unsigned int fan_index, motor_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_fan_drv); + check_p(g_fan_drv->get_fan_motor_speed_tolerance); + + p_obj = to_switch_obj(obj->kobj.parent); + fan_index = p_obj->index; + motor_index = obj->index; + FAN_DBG("fan index: %u, motor index: %d\n", fan_index, motor_index); + ret = g_fan_drv->get_fan_motor_speed_tolerance(fan_index, motor_index, buf, PAGE_SIZE); + if (ret < 0) { + FAN_ERR("get fan%u motor%u speed tolerance failed, ret: %d\n", + fan_index, motor_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fan_motor_speed_target_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int fan_index, motor_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_fan_drv); + check_p(g_fan_drv->get_fan_motor_speed_target); + + p_obj = to_switch_obj(obj->kobj.parent); + fan_index = p_obj->index; + motor_index = obj->index; + FAN_DBG("fan index: %u, motor index: %d\n", fan_index, motor_index); + ret = g_fan_drv->get_fan_motor_speed_target(fan_index, motor_index, buf, PAGE_SIZE); + if (ret < 0) { + FAN_ERR("get fan%u motor%u speed target failed, ret: %d\n", fan_index, motor_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fan_motor_speed_max_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int fan_index, motor_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_fan_drv); + check_p(g_fan_drv->get_fan_motor_speed_max); + + p_obj = to_switch_obj(obj->kobj.parent); + fan_index = p_obj->index; + motor_index = obj->index; + FAN_DBG("fan index: %u, motor index: %d\n", fan_index, motor_index); + ret = g_fan_drv->get_fan_motor_speed_max(fan_index, motor_index, buf, PAGE_SIZE); + if (ret < 0) { + FAN_ERR("get fan%u motor%u speed max threshold failed, ret: %d\n", + fan_index, motor_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fan_motor_speed_min_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int fan_index, motor_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_fan_drv); + check_p(g_fan_drv->get_fan_motor_speed_min); + + p_obj = to_switch_obj(obj->kobj.parent); + fan_index = p_obj->index; + motor_index = obj->index; + FAN_DBG("fan index: %u, motor index: %d\n", fan_index, motor_index); + ret = g_fan_drv->get_fan_motor_speed_min(fan_index, motor_index, buf, PAGE_SIZE); + if (ret < 0) { + FAN_ERR("get fan%u motor%u speed min threshold failed, ret: %d\n", + fan_index, motor_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +ssize_t fan_ratio_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int fan_index; + int ret; + + check_p(g_fan_drv); + check_p(g_fan_drv->get_fan_ratio); + + fan_index = obj->index; + FAN_DBG("fan index: %u\n", fan_index); + ret = g_fan_drv->get_fan_ratio(fan_index, buf, PAGE_SIZE); + if (ret < 0) { + FAN_ERR("get fan%u ratio failed, ret: %d\n", fan_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fan_ratio_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int fan_index; + int ret, ratio; + + check_p(g_fan_drv); + check_p(g_fan_drv->set_fan_ratio); + + fan_index = obj->index; + sscanf(buf, "%d", &ratio); + if (ratio < 0 || ratio > 100) { + FAN_ERR("param invalid, can not set ratio: %d.\n", ratio); + return -EINVAL; + } + FAN_DBG("fan index: %u, ratio: %d\n", fan_index, ratio); + ret = g_fan_drv->set_fan_ratio(fan_index, ratio); + if (ret < 0) { + FAN_ERR("set fan%u ratio: %d failed, ret: %d\n", fan_index, ratio, ret); + return -EIO; + } + FAN_DBG("set fan%u, ratio: %d success\n", fan_index, ratio); + return count; +} + +ssize_t fan_direction_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int fan_index; + int ret; + + check_p(g_fan_drv); + check_p(g_fan_drv->get_fan_direction); + + fan_index = obj->index; + FAN_DBG("fan index: %u\n", fan_index); + ret = g_fan_drv->get_fan_direction(fan_index, buf, PAGE_SIZE); + if (ret < 0) { + FAN_ERR("get fan%u direction failed, ret: %d\n", fan_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +/************************************fan dir and attrs*******************************************/ +static struct switch_attribute fan_number_att = __ATTR(number, S_IRUGO, fan_number_show, NULL); + +static struct attribute *fan_dir_attrs[] = { + &fan_number_att.attr, + NULL, +}; + +static struct attribute_group fan_root_attr_group = { + .attrs = fan_dir_attrs, +}; + +/*******************************fan1 fan2 dir and attrs*******************************************/ +static struct switch_attribute fan_model_name_attr = __ATTR(model_name, S_IRUGO, fan_model_name_show, NULL); +static struct switch_attribute fan_sn_attr = __ATTR(serial_number, S_IRUGO, fan_sn_show, NULL); +static struct switch_attribute fan_pn_attr = __ATTR(part_number, S_IRUGO, fan_pn_show, NULL); +static struct switch_attribute fan_hw_attr = __ATTR(hardware_version, S_IRUGO, fan_hw_show, NULL); +static struct switch_attribute fan_num_motors_attr = __ATTR(motor_number, S_IRUGO, fan_motor_number_show, NULL); +static struct switch_attribute fan_status_attr = __ATTR(status, S_IRUGO, fan_status_show, NULL); +static struct switch_attribute fan_led_status_attr = __ATTR(led_status, S_IRUGO | S_IWUSR, fan_led_status_show, fan_led_status_store); +static struct switch_attribute fan_direction_attr = __ATTR(direction, S_IRUGO, fan_direction_show, NULL); +static struct switch_attribute fan_ratio_attr = __ATTR(ratio, S_IRUGO | S_IWUSR, fan_ratio_show, fan_ratio_store); + + +static struct attribute *fan_attrs[] = { + &fan_model_name_attr.attr, + &fan_sn_attr.attr, + &fan_pn_attr.attr, + &fan_hw_attr.attr, + &fan_num_motors_attr.attr, + &fan_status_attr.attr, + &fan_led_status_attr.attr, + &fan_direction_attr.attr, + &fan_ratio_attr.attr, + NULL, +}; + +static struct attribute_group fan_attr_group = { + .attrs = fan_attrs, +}; + +/*******************************motor1 motor2 dir and attrs*******************************************/ +static struct switch_attribute motor_speed_attr = __ATTR(speed, S_IRUGO, fan_motor_speed_show, NULL); +static struct switch_attribute motor_speed_tolerance_attr = __ATTR(speed_tolerance, S_IRUGO, fan_motor_speed_tolerance_show, NULL); +static struct switch_attribute motor_speed_target_attr = __ATTR(speed_target, S_IRUGO, fan_motor_speed_target_show, NULL); +static struct switch_attribute motor_speed_max_attr = __ATTR(speed_max, S_IRUGO, fan_motor_speed_max_show, NULL); +static struct switch_attribute motor_speed_min_attr = __ATTR(speed_min, S_IRUGO, fan_motor_speed_min_show, NULL); + +static struct attribute *motor_attrs[] = { + &motor_speed_attr.attr, + &motor_speed_tolerance_attr.attr, + &motor_speed_target_attr.attr, + &motor_speed_max_attr.attr, + &motor_speed_min_attr.attr, + NULL, +}; + +static struct attribute_group motor_attr_group = { + .attrs = motor_attrs, +}; + +static void fanindex_single_motor_remove_kobj_and_attrs(struct fan_obj_s *curr_fan, unsigned int motor_index) +{ + struct motor_obj_s *curr_motor; /* point to motor1 motor2...*/ + + curr_motor = &curr_fan->motor[motor_index - 1]; + if (curr_motor->obj) { + sysfs_remove_group(&curr_motor->obj->kobj, &motor_attr_group); + switch_kobject_delete(&curr_motor->obj); + FAN_DBG("delete fan%u motor%u dir and attrs success.\n", curr_fan->obj->index, + motor_index); + } + return; +} + +static int fanindex_single_motor_create_kobj_and_attrs(struct fan_obj_s *curr_fan, unsigned int motor_index) +{ + char name[8]; + struct motor_obj_s *curr_motor; /* point to motor1 motor2...*/ + + curr_motor = &curr_fan->motor[motor_index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "motor%u", motor_index); + curr_motor->obj = switch_kobject_create(name, &curr_fan->obj->kobj); + if (!curr_motor->obj) { + FAN_ERR("create fan%u, motor%u object error!\n", curr_fan->obj->index, motor_index); + return -ENOMEM; + } + + curr_motor->obj->index = motor_index; + if (sysfs_create_group(&curr_motor->obj->kobj, &motor_attr_group) != 0) { + FAN_ERR("create fan%u, motor%u attrs error.\n", curr_fan->obj->index, motor_index); + switch_kobject_delete(&curr_motor->obj); + return -EBADRQC; + } + FAN_DBG("create fan%u, motor%u dir and attrs success.\n", curr_fan->obj->index, motor_index); + return 0; +} + +/* create motor[1-n] directory and attributes in fan directory */ +static int fanindex_motor_create_kobj_and_attrs(struct fan_obj_s *curr_fan) +{ + unsigned int motor_index, i, motor_num; + + motor_num = curr_fan->motor_number; + curr_fan->motor = kzalloc(sizeof(struct motor_obj_s) * motor_num, GFP_KERNEL); + if (!curr_fan->motor) { + FAN_ERR("kzalloc motor error, fan index: %u, motor number: %d.\n", + curr_fan->obj->index, motor_num); + return -ENOMEM; + } + for(motor_index = 1; motor_index <= motor_num; motor_index++) { + if(fanindex_single_motor_create_kobj_and_attrs(curr_fan, motor_index) != 0 ) { + goto motor_error; + } + } + return 0; +motor_error: + for(i = motor_index; i > 0; i--) { + fanindex_single_motor_remove_kobj_and_attrs(curr_fan, i); + } + kfree(curr_fan->motor); + curr_fan->motor = NULL; + return -EBADRQC; +} + +/* delete motor[1-n] directory and attributes in fan directory */ +static void fanindex_motor_remove_kobj_and_attrs(struct fan_obj_s *curr_fan) +{ + unsigned int motor_index, motor_num; + + if (curr_fan->motor) { + motor_num = curr_fan->motor_number; + for(motor_index = motor_num; motor_index > 0; motor_index--) { + fanindex_single_motor_remove_kobj_and_attrs(curr_fan, motor_index); + } + kfree(curr_fan->motor); + curr_fan->motor = NULL; + } + + return; +} + +/* create motor[1-n] directory and attributes */ +static int fan_motor_create(void) +{ + int fan_num, motor_num; + unsigned int fan_index, i; + struct fan_obj_s *curr_fan; /* point to fan1 fan2...*/ + + fan_num = g_fan.fan_number; + if (fan_num <= 0) { + FAN_DBG("fan number: %d, skip to create motor* dirs and attrs.\n", fan_num); + return 0; + } + + check_p(g_fan_drv->get_fan_motor_number); + + for(fan_index = 1; fan_index <= fan_num; fan_index++) { + motor_num = g_fan_drv->get_fan_motor_number(fan_index); + if (motor_num <= 0) { + FAN_DBG("fan%u motor number: %d, don't need to create motor* dirs and attrs.\n", + fan_index, motor_num); + continue; + } + curr_fan = &g_fan.fan[fan_index - 1]; + curr_fan->motor_number = motor_num; + if(fanindex_motor_create_kobj_and_attrs(curr_fan) != 0) { + goto error; + } + } + return 0; +error: + for(i = fan_index; i > 0; i--) { + curr_fan = &g_fan.fan[i - 1]; + fanindex_motor_remove_kobj_and_attrs(curr_fan); + } + return -EBADRQC; +} + +/* delete motor[1-n] directory and attributes */ +static void fan_motor_remove(void) +{ + unsigned int fan_index; + struct fan_obj_s *curr_fan; + + if (g_fan.fan) { + for (fan_index = g_fan.fan_number; fan_index > 0; fan_index--) { + curr_fan = &g_fan.fan[fan_index - 1]; + fanindex_motor_remove_kobj_and_attrs(curr_fan); + curr_fan->motor_number = 0; + } + } + return; +} + +static int fan_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct fan_obj_s *curr_fan; + + curr_fan = &g_fan.fan[index - 1]; + if (curr_fan->obj) { + sysfs_remove_group(&curr_fan->obj->kobj, &fan_attr_group); + switch_kobject_delete(&curr_fan->obj); + FAN_DBG("delete fan%u dir and attrs success.\n", index); + } + return 0; +} + +static int fan_sub_single_create_kobj_and_attrs(struct kobject *parent, unsigned int index) +{ + char name[8]; + struct fan_obj_s *curr_fan; + + curr_fan = &g_fan.fan[index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "fan%u", index); + curr_fan->obj = switch_kobject_create(name, parent); + if (!curr_fan->obj) { + FAN_ERR("create %s object error!\n", name); + return -ENOMEM; + } + + curr_fan->obj->index = index; + if (sysfs_create_group(&curr_fan->obj->kobj, &fan_attr_group) != 0) { + FAN_ERR("create %s attrs error.\n", name); + switch_kobject_delete(&curr_fan->obj); + return -EBADRQC; + } + FAN_DBG("create %s dir and attrs success.\n", name); + return 0; +} + +/* create fan[1-n] directory and attributes */ +static int fan_sub_create_kobj_and_attrs(struct kobject *parent, int fan_num) +{ + unsigned int fan_index, i; + + g_fan.fan = kzalloc(sizeof(struct fan_obj_s) * fan_num, GFP_KERNEL); + if (!g_fan.fan) { + FAN_ERR("kzalloc fan.fan error, fan number: %d.\n", fan_num); + return -ENOMEM; + } + + for(fan_index = 1; fan_index <= fan_num; fan_index++) { + if(fan_sub_single_create_kobj_and_attrs(parent, fan_index) != 0 ) { + goto error; + } + } + return 0; +error: + for(i = fan_index; i > 0; i--) { + fan_sub_single_remove_kobj_and_attrs(i); + } + kfree(g_fan.fan); + g_fan.fan = NULL; + return -EBADRQC; +} + +static int fan_sub_create(void) +{ + int ret; + + ret = fan_sub_create_kobj_and_attrs(&g_fan_obj->kobj, g_fan.fan_number); + return ret; +} + +/* delete fan[1-n] directory and attributes */ +static void fan_sub_remove(void) +{ + unsigned int fan_index; + + if (g_fan.fan) { + for (fan_index = g_fan.fan_number; fan_index > 0; fan_index--) { + fan_sub_single_remove_kobj_and_attrs(fan_index); + } + kfree(g_fan.fan); + g_fan.fan = NULL; + } + g_fan.fan_number = 0; + + return; +} + +/* create fan directory and number attributes */ +static int fan_root_create(void) +{ + g_fan_obj = switch_kobject_create("fan", NULL); + if (!g_fan_obj) { + FAN_ERR("switch_kobject_create fan error!\n"); + return -ENOMEM; + } + + if (sysfs_create_group(&g_fan_obj->kobj, &fan_root_attr_group) != 0) { + switch_kobject_delete(&g_fan_obj); + FAN_ERR("create fan dir attrs error!\n"); + return -EBADRQC; + } + return 0; +} + +/* delete fan directory and number attributes */ +static void fan_root_remove(void) +{ + if (g_fan_obj) { + sysfs_remove_group(&g_fan_obj->kobj, &fan_root_attr_group); + switch_kobject_delete(&g_fan_obj); + FAN_DBG("delete fan dir and attrs success.\n"); + } + return; +} + +int s3ip_sysfs_fan_drivers_register(struct s3ip_sysfs_fan_drivers_s *drv) +{ + int ret, fan_num; + + FAN_INFO("s3ip_sysfs_fan_drivers_register...\n"); + if (g_fan_drv) { + FAN_ERR("g_fan_drv is not NULL, can't register\n"); + return -EPERM; + } + + check_p(drv); + check_p(drv->get_fan_number); + g_fan_drv = drv; + + fan_num = g_fan_drv->get_fan_number(); + if (fan_num <= 0) { + FAN_ERR("fan number: %d, don't need to create fan dirs and attrs.\n", fan_num); + g_fan_drv = NULL; + return -EINVAL; + } + + memset(&g_fan, 0, sizeof(struct fan_s)); + g_fan.fan_number = fan_num; + ret = fan_root_create(); + if (ret < 0) { + FAN_ERR("create fan root dir and attrs failed, ret: %d\n", ret); + g_fan_drv = NULL; + return ret; + } + + ret = fan_sub_create(); + if (ret < 0) { + FAN_ERR("create fan sub dir and attrs failed, ret: %d\n", ret); + fan_root_remove(); + g_fan_drv = NULL; + return ret; + } + + ret = fan_motor_create(); + if (ret < 0) { + FAN_ERR("create fan motor dir and attrs failed, ret: %d\n", ret); + fan_sub_remove(); + fan_root_remove(); + g_fan_drv = NULL; + return ret; + } + FAN_INFO("s3ip_sysfs_fan_drivers_register success.\n"); + return 0; +} + +void s3ip_sysfs_fan_drivers_unregister(void) +{ + if (g_fan_drv) { + fan_motor_remove(); + fan_sub_remove(); + fan_root_remove(); + g_fan_drv = NULL; + FAN_DBG("s3ip_sysfs_fan_drivers_unregister success.\n"); + } + return; +} + +EXPORT_SYMBOL(s3ip_sysfs_fan_drivers_register); +EXPORT_SYMBOL(s3ip_sysfs_fan_drivers_unregister); +module_param(g_fan_loglevel, int, 0644); +MODULE_PARM_DESC(g_fan_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); diff --git a/platform/s3ip-sysfs/s3ip_sysfs_frame/fpga_sysfs.c b/platform/s3ip-sysfs/s3ip_sysfs_frame/fpga_sysfs.c new file mode 100644 index 000000000000..8fc5736c0154 --- /dev/null +++ b/platform/s3ip-sysfs/s3ip_sysfs_frame/fpga_sysfs.c @@ -0,0 +1,366 @@ +/* + * fpga_sysfs.c + * + * This module create fpga kobjects and attributes in /sys/s3ip/fpga + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "switch.h" +#include "fpga_sysfs.h" + +static int g_fpga_loglevel = 0; + +#define FPGA_INFO(fmt, args...) do { \ + if (g_fpga_loglevel & INFO) { \ + printk(KERN_INFO "[FPGA_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define FPGA_ERR(fmt, args...) do { \ + if (g_fpga_loglevel & ERR) { \ + printk(KERN_ERR "[FPGA_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define FPGA_DBG(fmt, args...) do { \ + if (g_fpga_loglevel & DBG) { \ + printk(KERN_DEBUG "[FPGA_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +struct fpga_obj_s { + struct switch_obj *obj; +}; + +struct fpga_s { + unsigned int fpga_number; + struct fpga_obj_s *fpga; +}; + +static struct fpga_s g_fpga; +static struct switch_obj *g_fpga_obj = NULL; +static struct s3ip_sysfs_fpga_drivers_s *g_fpga_drv = NULL; + +static ssize_t fpga_number_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + return (ssize_t)snprintf(buf, PAGE_SIZE, "%u\n", g_fpga.fpga_number); +} + +static ssize_t fpga_alias_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int fpga_index; + int ret; + + check_p(g_fpga_drv); + check_p(g_fpga_drv->get_main_board_fpga_alias); + + fpga_index = obj->index; + FPGA_DBG("fpga index: %u\n", fpga_index); + ret = g_fpga_drv->get_main_board_fpga_alias(fpga_index, buf, PAGE_SIZE); + if (ret < 0) { + FPGA_ERR("get fpga%u alias failed, ret: %d\n", fpga_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fpga_type_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int fpga_index; + int ret; + + check_p(g_fpga_drv); + check_p(g_fpga_drv->get_main_board_fpga_type); + + fpga_index = obj->index; + FPGA_DBG("fpga index: %u\n", fpga_index); + ret = g_fpga_drv->get_main_board_fpga_type(fpga_index, buf, PAGE_SIZE); + if (ret < 0) { + FPGA_ERR("get fpga%u type failed, ret: %d\n", fpga_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fpga_fw_version_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int fpga_index; + int ret; + + check_p(g_fpga_drv); + check_p(g_fpga_drv->get_main_board_fpga_firmware_version); + + fpga_index = obj->index; + FPGA_DBG("fpga index: %u\n", fpga_index); + ret = g_fpga_drv->get_main_board_fpga_firmware_version(fpga_index, buf, PAGE_SIZE); + if (ret < 0) { + FPGA_ERR("get fpga%u firmware version failed, ret: %d\n", fpga_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fpga_board_version_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int fpga_index; + int ret; + + check_p(g_fpga_drv); + check_p(g_fpga_drv->get_main_board_fpga_board_version); + + fpga_index = obj->index; + FPGA_DBG("fpga index: %u\n", fpga_index); + ret = g_fpga_drv->get_main_board_fpga_board_version(fpga_index, buf, PAGE_SIZE); + if (ret < 0) { + FPGA_ERR("get fpga%u board version failed, ret: %d\n", fpga_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fpga_test_reg_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int fpga_index; + int ret; + + check_p(g_fpga_drv); + check_p(g_fpga_drv->get_main_board_fpga_test_reg); + + fpga_index = obj->index; + FPGA_DBG("fpga index: %u\n", fpga_index); + ret = g_fpga_drv->get_main_board_fpga_test_reg(fpga_index, buf, PAGE_SIZE); + if (ret < 0) { + FPGA_ERR("get fpga%u test register failed, ret: %d\n", fpga_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fpga_test_reg_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int fpga_index, value; + int ret; + + check_p(g_fpga_drv); + check_p(g_fpga_drv->set_main_board_fpga_test_reg); + + fpga_index = obj->index; + sscanf(buf, "0x%x", &value); + ret = g_fpga_drv->set_main_board_fpga_test_reg(fpga_index, value); + if (ret < 0) { + FPGA_ERR("set fpga%u test reg failed, value:0x%x, ret: %d.\n", fpga_index, value, ret); + return -EIO; + } + FPGA_DBG("set fpga%u test reg success, value: 0x%x.\n", fpga_index, value); + return count; +} + +/************************************fpga dir and attrs*******************************************/ +static struct switch_attribute fpga_number_att = __ATTR(number, S_IRUGO, fpga_number_show, NULL); + +static struct attribute *fpga_dir_attrs[] = { + &fpga_number_att.attr, + NULL, +}; + +static struct attribute_group fpga_root_attr_group = { + .attrs = fpga_dir_attrs, +}; + +/*******************************fpga[1-n] dir and attrs*******************************************/ +static struct switch_attribute fpga_alias_attr = __ATTR(alias, S_IRUGO, fpga_alias_show, NULL); +static struct switch_attribute fpga_type_attr = __ATTR(type, S_IRUGO, fpga_type_show, NULL); +static struct switch_attribute fpga_fw_version_attr = __ATTR(firmware_version, S_IRUGO, fpga_fw_version_show, NULL); +static struct switch_attribute fpga_board_version_attr = __ATTR(board_version, S_IRUGO, fpga_board_version_show, NULL); +static struct switch_attribute fpga_test_reg_attr = __ATTR(reg_test, S_IRUGO | S_IWUSR, fpga_test_reg_show, fpga_test_reg_store); + +static struct attribute *fpga_attrs[] = { + &fpga_alias_attr.attr, + &fpga_type_attr.attr, + &fpga_fw_version_attr.attr, + &fpga_board_version_attr.attr, + &fpga_test_reg_attr.attr, + NULL, +}; + +static struct attribute_group fpga_attr_group = { + .attrs = fpga_attrs, +}; + +static int fpga_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct fpga_obj_s *curr_fpga; + + curr_fpga = &g_fpga.fpga[index - 1]; + if (curr_fpga->obj) { + sysfs_remove_group(&curr_fpga->obj->kobj, &fpga_attr_group); + switch_kobject_delete(&curr_fpga->obj); + FPGA_DBG("delete fpga%u dir and attrs success.\n", index); + } + return 0; +} + +static int fpga_sub_single_create_kobj_and_attrs(struct kobject *parent, unsigned int index) +{ + char name[8]; + struct fpga_obj_s *curr_fpga; + + curr_fpga = &g_fpga.fpga[index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "fpga%u", index); + curr_fpga->obj = switch_kobject_create(name, parent); + if (!curr_fpga->obj) { + FPGA_ERR("create %s object error!\n", name); + return -EBADRQC; + } + curr_fpga->obj->index = index; + if (sysfs_create_group(&curr_fpga->obj->kobj, &fpga_attr_group) != 0) { + FPGA_ERR("create %s attrs error.\n", name); + switch_kobject_delete(&curr_fpga->obj); + return -EBADRQC; + } + FPGA_DBG("create %s dir and attrs success.\n", name); + return 0; +} + +static int fpga_sub_create_kobj_and_attrs(struct kobject *parent, int fpga_num) +{ + unsigned int fpga_index, i; + + g_fpga.fpga = kzalloc(sizeof(struct fpga_obj_s) * fpga_num, GFP_KERNEL); + if (!g_fpga.fpga) { + FPGA_ERR("kzalloc g_fpga.fpga error, fpga number = %d.\n", fpga_num); + return -ENOMEM; + } + + for(fpga_index = 1; fpga_index <= fpga_num; fpga_index++) { + if(fpga_sub_single_create_kobj_and_attrs(parent, fpga_index) != 0 ) { + goto error; + } + } + return 0; +error: + for(i = fpga_index; i > 0; i--) { + fpga_sub_single_remove_kobj_and_attrs(i); + } + kfree(g_fpga.fpga); + g_fpga.fpga = NULL; + return -EBADRQC; +} + +/* create fpga[1-n] directory and attributes*/ +static int fpga_sub_create(void) +{ + int ret; + + ret = fpga_sub_create_kobj_and_attrs(&g_fpga_obj->kobj, g_fpga.fpga_number); + return ret; +} + +/* delete fpga[1-n] directory and attributes*/ +static void fpga_sub_remove(void) +{ + unsigned int fpga_index; + + if (g_fpga.fpga) { + for (fpga_index = g_fpga.fpga_number; fpga_index > 0; fpga_index--) { + fpga_sub_single_remove_kobj_and_attrs(fpga_index); + } + kfree(g_fpga.fpga); + g_fpga.fpga = NULL; + } + g_fpga.fpga_number = 0; + return; +} + +/* create fpga directory and number attributes */ +static int fpga_root_create(void) +{ + g_fpga_obj = switch_kobject_create("fpga", NULL); + if (!g_fpga_obj) { + FPGA_ERR("switch_kobject_create fpga error!\n"); + return -ENOMEM; + } + + if (sysfs_create_group(&g_fpga_obj->kobj, &fpga_root_attr_group) != 0) { + switch_kobject_delete(&g_fpga_obj); + FPGA_ERR("create fpga dir attrs error!\n"); + return -EBADRQC; + } + return 0; +} + +/* delete fpga directory and number attributes */ +static void fpga_root_remove(void) +{ + if (g_fpga_obj) { + sysfs_remove_group(&g_fpga_obj->kobj, &fpga_root_attr_group); + switch_kobject_delete(&g_fpga_obj); + } + + return; +} + +int s3ip_sysfs_fpga_drivers_register(struct s3ip_sysfs_fpga_drivers_s *drv) +{ + int ret, fpga_num; + + FPGA_INFO("s3ip_sysfs_fpga_drivers_register...\n"); + if (g_fpga_drv) { + FPGA_ERR("g_fpga_drv is not NULL, can't register\n"); + return -EPERM; + } + + check_p(drv); + check_p(drv->get_main_board_fpga_number); + g_fpga_drv = drv; + + fpga_num = g_fpga_drv->get_main_board_fpga_number(); + if (fpga_num <= 0) { + FPGA_ERR("fpga number: %d, don't need to create fpga dirs and attrs.\n", fpga_num); + g_fpga_drv = NULL; + return -EINVAL; + } + + memset(&g_fpga, 0, sizeof(struct fpga_s)); + g_fpga.fpga_number = fpga_num; + ret = fpga_root_create(); + if (ret < 0) { + FPGA_ERR("create fpga root dir and attrs failed, ret: %d\n", ret); + g_fpga_drv = NULL; + return ret; + } + ret = fpga_sub_create(); + if (ret < 0) { + FPGA_ERR("create fpga sub dir and attrs failed, ret: %d\n", ret); + fpga_root_remove(); + g_fpga_drv = NULL; + return ret; + } + FPGA_INFO("s3ip_sysfs_fpga_drivers_register success\n"); + return 0; +} + +void s3ip_sysfs_fpga_drivers_unregister(void) +{ + if (g_fpga_drv) { + fpga_sub_remove(); + fpga_root_remove(); + g_fpga_drv = NULL; + FPGA_DBG("s3ip_sysfs_fpga_drivers_unregister success.\n"); + } + + return; +} + +EXPORT_SYMBOL(s3ip_sysfs_fpga_drivers_register); +EXPORT_SYMBOL(s3ip_sysfs_fpga_drivers_unregister); +module_param(g_fpga_loglevel, int, 0644); +MODULE_PARM_DESC(g_fpga_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); + diff --git a/platform/s3ip-sysfs/s3ip_sysfs_frame/include/cpld_sysfs.h b/platform/s3ip-sysfs/s3ip_sysfs_frame/include/cpld_sysfs.h new file mode 100644 index 000000000000..3d47a422ae01 --- /dev/null +++ b/platform/s3ip-sysfs/s3ip_sysfs_frame/include/cpld_sysfs.h @@ -0,0 +1,16 @@ +#ifndef _CPLD_SYSFS_H_ +#define _CPLD_SYSFS_H_ + +struct s3ip_sysfs_cpld_drivers_s { + int (*get_main_board_cpld_number)(void); + ssize_t (*get_main_board_cpld_alias)(unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_main_board_cpld_type)(unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_main_board_cpld_firmware_version)(unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_main_board_cpld_board_version)(unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_main_board_cpld_test_reg)(unsigned int cpld_index, char *buf, size_t count); + int (*set_main_board_cpld_test_reg)(unsigned int cpld_index, unsigned int value); +}; + +extern int s3ip_sysfs_cpld_drivers_register(struct s3ip_sysfs_cpld_drivers_s *drv); +extern void s3ip_sysfs_cpld_drivers_unregister(void); +#endif /*_CPLD_SYSFS_H_ */ diff --git a/platform/s3ip-sysfs/s3ip_sysfs_frame/include/curr_sensor_sysfs.h b/platform/s3ip-sysfs/s3ip_sysfs_frame/include/curr_sensor_sysfs.h new file mode 100644 index 000000000000..7a0b85a0fc3c --- /dev/null +++ b/platform/s3ip-sysfs/s3ip_sysfs_frame/include/curr_sensor_sysfs.h @@ -0,0 +1,17 @@ +#ifndef _CURR_SENSOR_SYSFS_H_ +#define _CURR_SENSOR_SYSFS_H_ + +struct s3ip_sysfs_curr_sensor_drivers_s { + int (*get_main_board_curr_number)(void); + ssize_t (*get_main_board_curr_alias)(unsigned int curr_index, char *buf, size_t count); + ssize_t (*get_main_board_curr_type)(unsigned int curr_index, char *buf, size_t count); + ssize_t (*get_main_board_curr_max)(unsigned int curr_index, char *buf, size_t count); + int (*set_main_board_curr_max)(unsigned int curr_index, const char *buf, size_t count); + ssize_t (*get_main_board_curr_min)(unsigned int curr_index, char *buf, size_t count); + int (*set_main_board_curr_min)(unsigned int curr_index, const char *buf, size_t count); + ssize_t (*get_main_board_curr_value)(unsigned int curr_index, char *buf, size_t count); +}; + +extern int s3ip_sysfs_curr_sensor_drivers_register(struct s3ip_sysfs_curr_sensor_drivers_s *drv); +extern void s3ip_sysfs_curr_sensor_drivers_unregister(void); +#endif /*_CURR_SENSOR_SYSFS_H_ */ diff --git a/platform/s3ip-sysfs/s3ip_sysfs_frame/include/fan_sysfs.h b/platform/s3ip-sysfs/s3ip_sysfs_frame/include/fan_sysfs.h new file mode 100755 index 000000000000..fbd5ea82eca0 --- /dev/null +++ b/platform/s3ip-sysfs/s3ip_sysfs_frame/include/fan_sysfs.h @@ -0,0 +1,26 @@ +#ifndef _FAN_SYSFS_H_ +#define _FAN_SYSFS_H_ + +struct s3ip_sysfs_fan_drivers_s { + int (*get_fan_number)(void); + int (*get_fan_motor_number)(unsigned int fan_index); + ssize_t (*get_fan_model_name)(unsigned int fan_index, char *buf, size_t count); + ssize_t (*get_fan_serial_number)(unsigned int fan_index, char *buf, size_t count); + ssize_t (*get_fan_part_number)(unsigned int fan_index, char *buf, size_t count); + ssize_t (*get_fan_hardware_version)(unsigned int fan_index, char *buf, size_t count); + ssize_t (*get_fan_status)(unsigned int fan_index, char *buf, size_t count); + ssize_t (*get_fan_led_status)(unsigned int fan_index, char *buf, size_t count); + int (*set_fan_led_status)(unsigned int fan_index, int status); + ssize_t (*get_fan_direction)(unsigned int fan_index, char *buf, size_t count); + ssize_t (*get_fan_motor_speed)(unsigned int fan_index, unsigned int motor_index, char *buf, size_t count); + ssize_t (*get_fan_motor_speed_tolerance)(unsigned int fan_index, unsigned int motor_index, char *buf, size_t count); + ssize_t (*get_fan_motor_speed_target)(unsigned int fan_index, unsigned int motor_index, char *buf, size_t count); + ssize_t (*get_fan_motor_speed_max)(unsigned int fan_index, unsigned int motor_index, char *buf, size_t count); + ssize_t (*get_fan_motor_speed_min)(unsigned int fan_index, unsigned int motor_index, char *buf, size_t count); + ssize_t (*get_fan_ratio)(unsigned int fan_index, char *buf, size_t count); + int (*set_fan_ratio)(unsigned int fan_index, int ratio); +}; + +extern int s3ip_sysfs_fan_drivers_register(struct s3ip_sysfs_fan_drivers_s *drv); +extern void s3ip_sysfs_fan_drivers_unregister(void); +#endif /*_FAN_SYSFS_H_ */ diff --git a/platform/s3ip-sysfs/s3ip_sysfs_frame/include/fpga_sysfs.h b/platform/s3ip-sysfs/s3ip_sysfs_frame/include/fpga_sysfs.h new file mode 100644 index 000000000000..c8a6935e4638 --- /dev/null +++ b/platform/s3ip-sysfs/s3ip_sysfs_frame/include/fpga_sysfs.h @@ -0,0 +1,16 @@ +#ifndef _FPGA_SYSFS_H_ +#define _FPGA_SYSFS_H_ + +struct s3ip_sysfs_fpga_drivers_s { + int (*get_main_board_fpga_number)(void); + ssize_t (*get_main_board_fpga_alias)(unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_main_board_fpga_type)(unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_main_board_fpga_firmware_version)(unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_main_board_fpga_board_version)(unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_main_board_fpga_test_reg)(unsigned int fpga_index, char *buf, size_t count); + int (*set_main_board_fpga_test_reg)(unsigned int fpga_index, unsigned int value); +}; + +extern int s3ip_sysfs_fpga_drivers_register(struct s3ip_sysfs_fpga_drivers_s *drv); +extern void s3ip_sysfs_fpga_drivers_unregister(void); +#endif /*_FPGA_SYSFS_H_ */ diff --git a/platform/s3ip-sysfs/s3ip_sysfs_frame/include/psu_sysfs.h b/platform/s3ip-sysfs/s3ip_sysfs_frame/include/psu_sysfs.h new file mode 100644 index 000000000000..4f6d1aba3d92 --- /dev/null +++ b/platform/s3ip-sysfs/s3ip_sysfs_frame/include/psu_sysfs.h @@ -0,0 +1,38 @@ +#ifndef _PSU_SYSFS_H_ +#define _PSU_SYSFS_H_ + +struct s3ip_sysfs_psu_drivers_s { + int (*get_psu_number)(void); + int (*get_psu_temp_number)(unsigned int psu_index); + ssize_t (*get_psu_model_name)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_serial_number)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_part_number)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_hardware_version)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_type)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_in_curr)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_in_vol)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_in_power)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_out_curr)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_out_vol)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_out_power)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_out_max_power)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_present_status)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_in_status)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_out_status)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_fan_speed)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_fan_ratio)(unsigned int psu_index, char *buf, size_t count); + int (*set_psu_fan_ratio)(unsigned int psu_index, int ratio); + ssize_t (*get_psu_fan_direction)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_led_status)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_temp_alias)(unsigned int psu_index, unsigned int temp_index, char *buf, size_t count); + ssize_t (*get_psu_temp_type)(unsigned int psu_index, unsigned int temp_index, char *buf, size_t count); + ssize_t (*get_psu_temp_max)(unsigned int psu_index, unsigned int temp_index, char *buf, size_t count); + int (*set_psu_temp_max)(unsigned int psu_index, unsigned int temp_index, const char *buf, size_t count); + ssize_t (*get_psu_temp_min)(unsigned int psu_index, unsigned int temp_index, char *buf, size_t count); + int (*set_psu_temp_min)(unsigned int psu_index, unsigned int temp_index, const char *buf, size_t count); + ssize_t (*get_psu_temp_value)(unsigned int psu_index, unsigned int temp_index, char *buf, size_t count); +}; + +extern int s3ip_sysfs_psu_drivers_register(struct s3ip_sysfs_psu_drivers_s *drv); +extern void s3ip_sysfs_psu_drivers_unregister(void); +#endif /*_PSU_SYSFS_H_ */ diff --git a/platform/s3ip-sysfs/s3ip_sysfs_frame/include/slot_sysfs.h b/platform/s3ip-sysfs/s3ip_sysfs_frame/include/slot_sysfs.h new file mode 100644 index 000000000000..058ee450598b --- /dev/null +++ b/platform/s3ip-sysfs/s3ip_sysfs_frame/include/slot_sysfs.h @@ -0,0 +1,57 @@ +#ifndef _SLOT_SYSFS_H_ +#define _SLOT_SYSFS_H_ + +struct s3ip_sysfs_slot_drivers_s { + int (*get_slot_number)(void); + int (*get_slot_temp_number)(unsigned int slot_index); + int (*get_slot_vol_number)(unsigned int slot_index); + int (*get_slot_curr_number)(unsigned int slot_index); + int (*get_slot_cpld_number)(unsigned int slot_index); + int (*get_slot_fpga_number)(unsigned int slot_index); + ssize_t (*get_slot_model_name)(unsigned int slot_index, char *buf, size_t count); + ssize_t (*get_slot_serial_number)(unsigned int slot_index, char *buf, size_t count); + ssize_t (*get_slot_part_number)(unsigned int slot_index, char *buf, size_t count); + ssize_t (*get_slot_hardware_version)(unsigned int slot_index, char *buf, size_t count); + ssize_t (*get_slot_status)(unsigned int slot_index, char *buf, size_t count); + ssize_t (*get_slot_led_status)(unsigned int slot_index, char *buf, size_t count); + int (*set_slot_led_status)(unsigned int slot_index, int status); + ssize_t (*get_slot_temp_alias)(unsigned int slot_index, unsigned int temp_index, char *buf, size_t count); + ssize_t (*get_slot_temp_type)(unsigned int slot_index, unsigned int temp_index, char *buf, size_t count); + ssize_t (*get_slot_temp_max)(unsigned int slot_index, unsigned int temp_index, char *buf, size_t count); + int (*set_slot_temp_max)(unsigned int slot_index, unsigned int temp_index, const char *buf, size_t count); + ssize_t (*get_slot_temp_min)(unsigned int slot_index, unsigned int temp_index, char *buf, size_t count); + int (*set_slot_temp_min)(unsigned int slot_index, unsigned int temp_index, const char *buf, size_t count); + ssize_t (*get_slot_temp_value)(unsigned int slot_index, unsigned int temp_index, char *buf, size_t count); + ssize_t (*get_slot_vol_alias)(unsigned int slot_index, unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_slot_vol_type)(unsigned int slot_index, unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_slot_vol_max)(unsigned int slot_index, unsigned int vol_index, char *buf, size_t count); + int (*set_slot_vol_max)(unsigned int slot_index, unsigned int vol_index, const char *buf, size_t count); + ssize_t (*get_slot_vol_min)(unsigned int slot_index, unsigned int vol_index, char *buf, size_t count); + int (*set_slot_vol_min)(unsigned int slot_index, unsigned int vol_index, const char *buf, size_t count); + ssize_t (*get_slot_vol_range)(unsigned int slot_index, unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_slot_vol_nominal_value)(unsigned int slot_index, unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_slot_vol_value)(unsigned int slot_index, unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_slot_curr_alias)(unsigned int slot_index, unsigned int curr_index, char *buf, size_t count); + ssize_t (*get_slot_curr_type)(unsigned int slot_index, unsigned int curr_index, char *buf, size_t count); + ssize_t (*get_slot_curr_max)(unsigned int slot_index, unsigned int curr_index, char *buf, size_t count); + int (*set_slot_curr_max)(unsigned int slot_index, unsigned int curr_index, const char *buf, size_t count); + ssize_t (*get_slot_curr_min)(unsigned int slot_index, unsigned int curr_index, char *buf, size_t count); + int (*set_slot_curr_min)(unsigned int slot_index, unsigned int curr_index, const char *buf, size_t count); + ssize_t (*get_slot_curr_value)(unsigned int slot_index, unsigned int curr_index, char *buf, size_t count); + ssize_t (*get_slot_fpga_alias)(unsigned int slot_index, unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_slot_fpga_type)(unsigned int slot_index, unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_slot_fpga_firmware_version)(unsigned int slot_index, unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_slot_fpga_board_version)(unsigned int slot_index, unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_slot_fpga_test_reg)(unsigned int slot_index, unsigned int fpga_index, char *buf, size_t count); + int (*set_slot_fpga_test_reg)(unsigned int slot_index, unsigned int fpga_index, unsigned int value); + ssize_t (*get_slot_cpld_alias)(unsigned int slot_index, unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_slot_cpld_type)(unsigned int slot_index, unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_slot_cpld_firmware_version)(unsigned int slot_index, unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_slot_cpld_board_version)(unsigned int slot_index, unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_slot_cpld_test_reg)(unsigned int slot_index, unsigned int cpld_index, char *buf, size_t count); + int (*set_slot_cpld_test_reg)(unsigned int slot_index, unsigned int cpld_index, unsigned int value); +}; + +extern int s3ip_sysfs_slot_drivers_register(struct s3ip_sysfs_slot_drivers_s *drv); +extern void s3ip_sysfs_slot_drivers_unregister(void); +#endif /*_SLOT_SYSFS_H_ */ diff --git a/platform/s3ip-sysfs/s3ip_sysfs_frame/include/switch.h b/platform/s3ip-sysfs/s3ip_sysfs_frame/include/switch.h new file mode 100644 index 000000000000..ea0b1a266b1f --- /dev/null +++ b/platform/s3ip-sysfs/s3ip_sysfs_frame/include/switch.h @@ -0,0 +1,68 @@ +#ifndef _SWITCH_H_ +#define _SWITCH_H_ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define DIR_NAME_MAX_LEN (64) +#define SYSFS_DEV_ERROR "NA" + +enum LOG_LEVEL{ + INFO = 0x1, + ERR = 0x2, + DBG = 0x4, + ALL = 0xf +}; + +extern int g_switch_loglevel; + +#define check_pfun(p) do { \ + if (p == NULL) { \ + if (g_switch_loglevel & ERR) { \ + printk( KERN_ERR "%s, %s is NULL.\n", __FUNCTION__, #p); \ + } \ + return -ENOSYS; \ + } \ +} while(0) + +#define check_p(p) check_pfun(p) + +#define to_switch_obj(x) container_of(x, struct switch_obj, kobj) +#define to_switch_attr(x) container_of(x, struct switch_attribute, attr) +#define to_switch_device_attr(x) container_of(x, struct switch_device_attribute, switch_attr) + +#define SWITCH_ATTR(_name, _mode, _show, _store, _type) \ + { .switch_attr = __ATTR(_name, _mode, _show, _store), \ + .type = _type } + +#define SWITCH_DEVICE_ATTR(_name, _mode, _show, _store, _type) \ +struct switch_device_attribute switch_dev_attr_##_name \ + = SWITCH_ATTR(_name, _mode, _show, _store, _type) + +struct switch_obj { + struct kobject kobj; + unsigned int index; +}; + +/* a custom attribute that works just for a struct switch_obj. */ +struct switch_attribute { + struct attribute attr; + ssize_t (*show)(struct switch_obj *foo, struct switch_attribute *attr, char *buf); + ssize_t (*store)(struct switch_obj *foo, struct switch_attribute *attr, const char *buf, size_t count); +}; + +struct switch_device_attribute { + struct switch_attribute switch_attr; + int type; +}; + +struct switch_obj *switch_kobject_create(const char *name, struct kobject *parent); +void switch_kobject_delete(struct switch_obj **obj); + +#endif /* _SWITCH_H_ */ diff --git a/platform/s3ip-sysfs/s3ip_sysfs_frame/include/syseeprom_sysfs.h b/platform/s3ip-sysfs/s3ip_sysfs_frame/include/syseeprom_sysfs.h new file mode 100644 index 000000000000..c6b2c5c3456f --- /dev/null +++ b/platform/s3ip-sysfs/s3ip_sysfs_frame/include/syseeprom_sysfs.h @@ -0,0 +1,12 @@ +#ifndef _SYSEEPROM_SYSFS_H_ +#define _SYSEEPROM_SYSFS_H_ + +struct s3ip_sysfs_syseeprom_drivers_s { + int (*get_syseeprom_size)(void); + ssize_t (*read_syseeprom_data)(char *buf, loff_t offset, size_t count); + ssize_t (*write_syseeprom_data)(char *buf, loff_t offset, size_t count); +}; + +extern int s3ip_sysfs_syseeprom_drivers_register(struct s3ip_sysfs_syseeprom_drivers_s *drv); +extern void s3ip_sysfs_syseeprom_drivers_unregister(void); +#endif /*_SYSEEPROM_SYSFS_H_ */ diff --git a/platform/s3ip-sysfs/s3ip_sysfs_frame/include/sysled_sysfs.h b/platform/s3ip-sysfs/s3ip_sysfs_frame/include/sysled_sysfs.h new file mode 100644 index 000000000000..e4383a4eea27 --- /dev/null +++ b/platform/s3ip-sysfs/s3ip_sysfs_frame/include/sysled_sysfs.h @@ -0,0 +1,19 @@ +#ifndef _SYSLED_SYSFS_H_ +#define _SYSLED_SYSFS_H_ + +struct s3ip_sysfs_sysled_drivers_s { + ssize_t (*get_sys_led_status)(char *buf, size_t count); + int (*set_sys_led_status)(int status); + ssize_t (*get_bmc_led_status)(char *buf, size_t count); + int (*set_bmc_led_status)(int status); + ssize_t (*get_sys_fan_led_status)(char *buf, size_t count); + int (*set_sys_fan_led_status)(int status); + ssize_t (*get_sys_psu_led_status)(char *buf, size_t count); + int (*set_sys_psu_led_status)(int status); + ssize_t (*get_id_led_status)(char *buf, size_t count); + int (*set_id_led_status)(int status); +}; + +extern int s3ip_sysfs_sysled_drivers_register(struct s3ip_sysfs_sysled_drivers_s *drv); +extern void s3ip_sysfs_sysled_drivers_unregister(void); +#endif /*_SYSLED_SYSFS_H_ */ diff --git a/platform/s3ip-sysfs/s3ip_sysfs_frame/include/temp_sensor_sysfs.h b/platform/s3ip-sysfs/s3ip_sysfs_frame/include/temp_sensor_sysfs.h new file mode 100644 index 000000000000..db03a96a0cba --- /dev/null +++ b/platform/s3ip-sysfs/s3ip_sysfs_frame/include/temp_sensor_sysfs.h @@ -0,0 +1,17 @@ +#ifndef _TEMP_SENSOR_SYSFS_H_ +#define _TEMP_SENSOR_SYSFS_H_ + +struct s3ip_sysfs_temp_sensor_drivers_s { + int (*get_main_board_temp_number)(void); + ssize_t (*get_main_board_temp_alias)(unsigned int temp_index, char *buf, size_t count); + ssize_t (*get_main_board_temp_type)(unsigned int temp_index, char *buf, size_t count); + ssize_t (*get_main_board_temp_max)(unsigned int temp_index, char *buf, size_t count); + int (*set_main_board_temp_max)(unsigned int temp_index, const char *buf, size_t count); + ssize_t (*get_main_board_temp_min)(unsigned int temp_index, char *buf, size_t count); + int (*set_main_board_temp_min)(unsigned int temp_index, const char *buf, size_t count); + ssize_t (*get_main_board_temp_value)(unsigned int temp_index, char *buf, size_t count); +}; + +extern int s3ip_sysfs_temp_sensor_drivers_register(struct s3ip_sysfs_temp_sensor_drivers_s *drv); +extern void s3ip_sysfs_temp_sensor_drivers_unregister(void); +#endif /*_TEMP_SENSOR_SYSFS_H_ */ diff --git a/platform/s3ip-sysfs/s3ip_sysfs_frame/include/transceiver_sysfs.h b/platform/s3ip-sysfs/s3ip_sysfs_frame/include/transceiver_sysfs.h new file mode 100644 index 000000000000..7e8634c1ef01 --- /dev/null +++ b/platform/s3ip-sysfs/s3ip_sysfs_frame/include/transceiver_sysfs.h @@ -0,0 +1,26 @@ +#ifndef _TRANSCEIVER_SYSFS_H_ +#define _TRANSCEIVER_SYSFS_H_ + +struct s3ip_sysfs_transceiver_drivers_s { + int (*get_eth_number)(void); + ssize_t (*get_transceiver_power_on_status)(char *buf, size_t count); + int (*set_transceiver_power_on_status)(int status); + ssize_t (*get_eth_power_on_status)(unsigned int eth_index, char *buf, size_t count); + int (*set_eth_power_on_status)(unsigned int eth_index, int status); + ssize_t (*get_eth_tx_fault_status)(unsigned int eth_index, char *buf, size_t count); + ssize_t (*get_eth_tx_disable_status)(unsigned int eth_index, char *buf, size_t count); + int (*set_eth_tx_disable_status)(unsigned int eth_index, int status); + ssize_t (*get_eth_present_status)(unsigned int eth_index, char *buf, size_t count); + ssize_t (*get_eth_rx_los_status)(unsigned int eth_index, char *buf, size_t count); + ssize_t (*get_eth_reset_status)(unsigned int eth_index, char *buf, size_t count); + int (*set_eth_reset_status)(unsigned int eth_index, int status); + ssize_t (*get_eth_low_power_mode_status)(unsigned int eth_index, char *buf, size_t count); + ssize_t (*get_eth_interrupt_status)(unsigned int eth_index, char *buf, size_t count); + int (*get_eth_eeprom_size)(unsigned int eth_index); + ssize_t (*read_eth_eeprom_data)(unsigned int eth_index, char *buf, loff_t offset, size_t count); + ssize_t (*write_eth_eeprom_data)(unsigned int eth_index, char *buf, loff_t offset, size_t count); +}; + +extern int s3ip_sysfs_sff_drivers_register(struct s3ip_sysfs_transceiver_drivers_s *drv); +extern void s3ip_sysfs_sff_drivers_unregister(void); +#endif /*_TRANSCEIVER_SYSFS_H_ */ diff --git a/platform/s3ip-sysfs/s3ip_sysfs_frame/include/vol_sensor_sysfs.h b/platform/s3ip-sysfs/s3ip_sysfs_frame/include/vol_sensor_sysfs.h new file mode 100644 index 000000000000..b2d7d615c421 --- /dev/null +++ b/platform/s3ip-sysfs/s3ip_sysfs_frame/include/vol_sensor_sysfs.h @@ -0,0 +1,19 @@ +#ifndef _VOL_SENSOR_SYSFS_H_ +#define _VOL_SENSOR_SYSFS_H_ + +struct s3ip_sysfs_vol_sensor_drivers_s { + int (*get_main_board_vol_number)(void); + ssize_t (*get_main_board_vol_alias)(unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_main_board_vol_type)(unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_main_board_vol_max)(unsigned int vol_index, char *buf, size_t count); + int (*set_main_board_vol_max)(unsigned int vol_index, const char *buf, size_t count); + ssize_t (*get_main_board_vol_min)(unsigned int vol_index, char *buf, size_t count); + int (*set_main_board_vol_min)(unsigned int vol_index, const char *buf, size_t count); + ssize_t (*get_main_board_vol_range)(unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_main_board_vol_nominal_value)(unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_main_board_vol_value)(unsigned int vol_index, char *buf, size_t count); +}; + +extern int s3ip_sysfs_vol_sensor_drivers_register(struct s3ip_sysfs_vol_sensor_drivers_s *drv); +extern void s3ip_sysfs_vol_sensor_drivers_unregister(void); +#endif /*_VOL_SENSOR_SYSFS_H_ */ diff --git a/platform/s3ip-sysfs/s3ip_sysfs_frame/include/watchdog_sysfs.h b/platform/s3ip-sysfs/s3ip_sysfs_frame/include/watchdog_sysfs.h new file mode 100755 index 000000000000..7e86e4c006d9 --- /dev/null +++ b/platform/s3ip-sysfs/s3ip_sysfs_frame/include/watchdog_sysfs.h @@ -0,0 +1,16 @@ +#ifndef _WATCHDOG_SYSFS_H_ +#define _WATCHDOG_SYSFS_H_ + +struct s3ip_sysfs_watchdog_drivers_s { + ssize_t (*get_watchdog_identify)(char *buf, size_t count); + ssize_t (*get_watchdog_timeleft)(char *buf, size_t count); + ssize_t (*get_watchdog_timeout)(char *buf, size_t count); + int (*set_watchdog_timeout)(int value); + ssize_t (*get_watchdog_enable_status)(char *buf, size_t count); + int (*set_watchdog_enable_status)(int value); + int (*set_watchdog_reset)(int value); +}; + +extern int s3ip_sysfs_watchdog_drivers_register(struct s3ip_sysfs_watchdog_drivers_s *drv); +extern void s3ip_sysfs_watchdog_drivers_unregister(void); +#endif /*_WATCHDOG_SYSFS_H_ */ diff --git a/platform/s3ip-sysfs/s3ip_sysfs_frame/psu_sysfs.c b/platform/s3ip-sysfs/s3ip_sysfs_frame/psu_sysfs.c new file mode 100755 index 000000000000..50005f875345 --- /dev/null +++ b/platform/s3ip-sysfs/s3ip_sysfs_frame/psu_sysfs.c @@ -0,0 +1,990 @@ +/* + * psu_sysfs.c + * + * This module create psu kobjects and attributes in /sys/s3ip/psu + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "switch.h" +#include "psu_sysfs.h" + +static int g_psu_loglevel = 0; + +#define PSU_INFO(fmt, args...) do { \ + if (g_psu_loglevel & INFO) { \ + printk(KERN_INFO "[PSU_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define PSU_ERR(fmt, args...) do { \ + if (g_psu_loglevel & ERR) { \ + printk(KERN_ERR "[PSU_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define PSU_DBG(fmt, args...) do { \ + if (g_psu_loglevel & DBG) { \ + printk(KERN_DEBUG "[PSU_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +struct temp_obj_s { + struct switch_obj *obj; +}; + +struct psu_obj_s { + unsigned int temp_number; + struct temp_obj_s *temp; + struct switch_obj *obj; +}; + +struct psu_s{ + unsigned int psu_number; + struct psu_obj_s *psu; +}; + +static struct psu_s g_psu; +static struct switch_obj *g_psu_obj = NULL; +static struct s3ip_sysfs_psu_drivers_s *g_psu_drv = NULL; + +static ssize_t psu_number_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", g_psu.psu_number); +} + +static ssize_t psu_temp_number_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int index; + + index = obj->index; + PSU_DBG("psu index: %u\n",index); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%u\n", g_psu.psu[index - 1].temp_number); +} + +static ssize_t psu_model_name_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_model_name); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_model_name(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u model name failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_hw_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_hardware_version); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_hardware_version(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u hardware version failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_sn_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_serial_number); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_serial_number(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u serial number failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_pn_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_part_number); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_part_number(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u part number failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_type_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_type); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_type(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u type failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_in_curr_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_in_curr); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_in_curr(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u input current failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_in_vol_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_in_vol); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_in_vol(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u input voltage failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_in_power_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_in_power); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_in_power(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u input power failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_out_curr_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_out_curr); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_out_curr(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u output current failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_out_vol_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_out_vol); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_out_vol(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u output voltage failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_out_power_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_out_power); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_out_power(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u outout power failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_out_max_power_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_out_max_power); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_out_max_power(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u outout max power failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_present_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_present_status); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_present_status(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u present status failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_out_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_out_status); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_out_status(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u outout status failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_in_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_in_status); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_in_status(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u input status failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_fan_speed_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_fan_speed); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_fan_speed(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u fan speed failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +ssize_t psu_fan_ratio_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_fan_ratio); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_fan_ratio(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u fan ratio failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_fan_ratio_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int psu_index; + int ret, ratio; + + check_p(g_psu_drv); + check_p(g_psu_drv->set_psu_fan_ratio); + + psu_index = obj->index; + sscanf(buf, "%d", &ratio); + if (ratio < 0 || ratio > 100) { + PSU_ERR("param invalid, can not set ratio: %d.\n", ratio); + return -EINVAL; + } + PSU_DBG("psu index: %u, ratio: %d\n", psu_index, ratio); + ret = g_psu_drv->set_psu_fan_ratio(psu_index, ratio); + if (ret < 0) { + PSU_ERR("set psu%u ratio: %d failed, ret: %d\n", + psu_index, ratio, ret); + return -EIO; + } + PSU_DBG("set psu%u, ratio: %d success\n", psu_index, ratio); + return count; +} + +static ssize_t psu_fan_direction_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_fan_direction); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_fan_direction(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u fan direction failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_led_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_led_status); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_led_status(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u led status failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_temp_value_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_temp_value); + + p_obj = to_switch_obj(obj->kobj.parent); + psu_index = p_obj->index; + temp_index = obj->index; + + PSU_DBG("psu index: %u, temp index: %u\n", psu_index, temp_index); + ret = g_psu_drv->get_psu_temp_value(psu_index, temp_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u temp%u value failed, ret: %d\n", psu_index, temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_temp_alias_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_temp_alias); + + p_obj = to_switch_obj(obj->kobj.parent); + psu_index = p_obj->index; + temp_index = obj->index; + + PSU_DBG("psu index: %u, temp index: %u\n", psu_index, temp_index); + ret = g_psu_drv->get_psu_temp_alias(psu_index, temp_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u temp%u alias failed, ret: %d\n", psu_index, temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_temp_type_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_temp_type); + + p_obj = to_switch_obj(obj->kobj.parent); + psu_index = p_obj->index; + temp_index = obj->index; + + PSU_DBG("psu index: %u, temp index: %u\n", psu_index, temp_index); + ret = g_psu_drv->get_psu_temp_type(psu_index, temp_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u temp%u type failed, ret: %d\n", psu_index, temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_temp_max_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_temp_max); + + p_obj = to_switch_obj(obj->kobj.parent); + psu_index = p_obj->index; + temp_index = obj->index; + + PSU_DBG("psu index: %u, temp index: %u\n", psu_index, temp_index); + ret = g_psu_drv->get_psu_temp_max(psu_index, temp_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u temp%u max threshold failed, ret: %d\n", + psu_index, temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_temp_max_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int psu_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_psu_drv); + check_p(g_psu_drv->set_psu_temp_max); + + p_obj = to_switch_obj(obj->kobj.parent); + psu_index = p_obj->index; + temp_index = obj->index; + ret = g_psu_drv->set_psu_temp_max(psu_index, temp_index, buf, count); + if (ret < 0) { + PSU_ERR("set psu%u temp%u max threshold failed, value: %s, count: %lu, ret: %d\n", + psu_index, temp_index, buf, count, ret); + return -EIO; + } + PSU_DBG("set psu%u temp%u max threshold success, value: %s, count: %lu, ret: %d\n", + psu_index, temp_index, buf, count, ret); + return count; +} + +static ssize_t psu_temp_min_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_temp_min); + + p_obj = to_switch_obj(obj->kobj.parent); + psu_index = p_obj->index; + temp_index = obj->index; + + PSU_DBG("psu index: %u, temp index: %u\n", psu_index, temp_index); + ret = g_psu_drv->get_psu_temp_min(psu_index, temp_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u temp%u min threshold failed, ret: %d\n", + psu_index, temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_temp_min_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int psu_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_psu_drv); + check_p(g_psu_drv->set_psu_temp_min); + + p_obj = to_switch_obj(obj->kobj.parent); + psu_index = p_obj->index; + temp_index = obj->index; + ret = g_psu_drv->set_psu_temp_min(psu_index, temp_index, buf, count); + if (ret < 0) { + PSU_ERR("set psu%u temp%u min threshold failed, value: %s, count: %lu, ret: %d\n", + psu_index, temp_index, buf, count, ret); + return -EIO; + } + PSU_DBG("set psu%u temp%u min threshold success, value: %s, count: %lu, ret: %d\n", + psu_index, temp_index, buf, count, ret); + return count; +} + +/************************************psu dir and attrs*******************************************/ +static struct switch_attribute psu_number_att = __ATTR(number, S_IRUGO, psu_number_show, NULL); + +static struct attribute *psu_dir_attrs[] = { + &psu_number_att.attr, + NULL, +}; + +static struct attribute_group psu_root_attr_group = { + .attrs = psu_dir_attrs, +}; + +/*******************************psu[1-n] dir and attrs*******************************************/ +static struct switch_attribute psu_model_name_attr = __ATTR(model_name, S_IRUGO, psu_model_name_show, NULL); +static struct switch_attribute psu_hw_attr = __ATTR(hardware_version, S_IRUGO, psu_hw_show, NULL); +static struct switch_attribute psu_sn_attr = __ATTR(serial_number, S_IRUGO, psu_sn_show, NULL); +static struct switch_attribute psu_pn_attr = __ATTR(part_number, S_IRUGO, psu_pn_show, NULL); +static struct switch_attribute psu_type_attr = __ATTR(type, S_IRUGO, psu_type_show, NULL); +static struct switch_attribute psu_in_curr_attr = __ATTR(in_curr, S_IRUGO, psu_in_curr_show, NULL); +static struct switch_attribute psu_in_vol_attr = __ATTR(in_vol, S_IRUGO, psu_in_vol_show, NULL); +static struct switch_attribute psu_in_power_attr = __ATTR(in_power, S_IRUGO, psu_in_power_show, NULL); +static struct switch_attribute psu_out_curr_attr = __ATTR(out_curr, S_IRUGO, psu_out_curr_show, NULL); +static struct switch_attribute psu_out_vol_attr = __ATTR(out_vol, S_IRUGO, psu_out_vol_show, NULL); +static struct switch_attribute psu_out_power_attr = __ATTR(out_power, S_IRUGO, psu_out_power_show, NULL); +static struct switch_attribute psu_out_max_power_attr = __ATTR(out_max_power, S_IRUGO, psu_out_max_power_show, NULL); +static struct switch_attribute psu_num_temps_attr = __ATTR(num_temp_sensors, S_IRUGO, psu_temp_number_show, NULL); +static struct switch_attribute psu_present_attr = __ATTR(present, S_IRUGO, psu_present_status_show, NULL); +static struct switch_attribute psu_out_status_attr = __ATTR(out_status, S_IRUGO, psu_out_status_show, NULL); +static struct switch_attribute psu_in_status_attr = __ATTR(in_status, S_IRUGO, psu_in_status_show, NULL); +static struct switch_attribute psu_fan_speed_attr = __ATTR(fan_speed, S_IRUGO, psu_fan_speed_show, NULL); +static struct switch_attribute psu_fan_ratio_attr = __ATTR(fan_ratio, S_IRUGO | S_IWUSR, psu_fan_ratio_show, psu_fan_ratio_store); +static struct switch_attribute psu_fan_direction_attr = __ATTR(fan_direction, S_IRUGO, psu_fan_direction_show, NULL); +static struct switch_attribute psu_led_status_attr = __ATTR(led_status, S_IRUGO, psu_led_status_show, NULL); + +static struct attribute *psu_attrs[] = { + &psu_model_name_attr.attr, + &psu_hw_attr.attr, + &psu_sn_attr.attr, + &psu_pn_attr.attr, + &psu_type_attr.attr, + &psu_in_curr_attr.attr, + &psu_in_vol_attr.attr, + &psu_in_power_attr.attr, + &psu_out_curr_attr.attr, + &psu_out_vol_attr.attr, + &psu_out_power_attr.attr, + &psu_out_max_power_attr.attr, + &psu_num_temps_attr.attr, + &psu_present_attr.attr, + &psu_out_status_attr.attr, + &psu_in_status_attr.attr, + &psu_fan_speed_attr.attr, + &psu_fan_ratio_attr.attr, + &psu_fan_direction_attr.attr, + &psu_led_status_attr.attr, + NULL, +}; + +static struct attribute_group psu_attr_group = { + .attrs = psu_attrs, +}; + +/*******************************psu temp[1-n] dir and attrs*******************************************/ +static struct switch_attribute psu_temp_alias_attr = __ATTR(alias, S_IRUGO, psu_temp_alias_show, NULL); +static struct switch_attribute psu_temp_type_attr = __ATTR(type, S_IRUGO, psu_temp_type_show, NULL); +static struct switch_attribute psu_temp_max_attr = __ATTR(max, S_IRUGO | S_IWUSR, psu_temp_max_show, psu_temp_max_store); +static struct switch_attribute psu_temp_min_attr = __ATTR(min, S_IRUGO | S_IWUSR, psu_temp_min_show, psu_temp_min_store); +static struct switch_attribute psu_temp_value_attr = __ATTR(value, S_IRUGO, psu_temp_value_show, NULL); + +static struct attribute *psu_temp_attrs[] = { + &psu_temp_alias_attr.attr, + &psu_temp_type_attr.attr, + &psu_temp_max_attr.attr, + &psu_temp_min_attr.attr, + &psu_temp_value_attr.attr, + NULL, +}; + +static struct attribute_group psu_temp_attr_group = { + .attrs = psu_temp_attrs, +}; + +static void psuindex_single_temp_remove_kobj_and_attrs(struct psu_obj_s *curr_psu, unsigned int temp_index) +{ + struct temp_obj_s *curr_temp; /* point to temp1 temp2...*/ + + curr_temp = &curr_psu->temp[temp_index - 1]; + if (curr_temp->obj) { + sysfs_remove_group(&curr_temp->obj->kobj, &psu_temp_attr_group); + switch_kobject_delete(&curr_temp->obj); + PSU_DBG("delete psu%u temp%u dir and attrs success.\n", curr_psu->obj->index, temp_index); + } + return; +} + +static int psuindex_single_temp_create_kobj_and_attrs(struct psu_obj_s *curr_psu, unsigned int temp_index) +{ + char name[DIR_NAME_MAX_LEN]; + struct temp_obj_s *curr_temp; /* point to temp1 temp2...*/ + + curr_temp = &curr_psu->temp[temp_index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "temp%u", temp_index); + curr_temp->obj = switch_kobject_create(name, &curr_psu->obj->kobj); + if (!curr_temp->obj) { + PSU_ERR("create psu%u, %s object error!\n", curr_psu->obj->index, name); + return -ENOMEM; + } + curr_temp->obj->index = temp_index; + if (sysfs_create_group(&curr_temp->obj->kobj, &psu_temp_attr_group) != 0) { + PSU_ERR("create psu%u, %s attrs error.\n", curr_psu->obj->index, name); + switch_kobject_delete(&curr_temp->obj); + return -EBADRQC; + } + PSU_DBG("create psu%u, %s success.\n", curr_psu->obj->index, name); + return 0; +} + +static int psuindex_temp_create_kobj_and_attrs(struct psu_obj_s *curr_psu) +{ + unsigned int temp_index, i, temp_num; + + temp_num = curr_psu->temp_number; + curr_psu->temp = kzalloc(sizeof(struct temp_obj_s) * temp_num, GFP_KERNEL); + if (!curr_psu->temp) { + PSU_ERR("kzalloc temp error, psu index: %u, temp number: %u.\n", + curr_psu->obj->index, temp_num); + return -ENOMEM; + } + for(temp_index = 1; temp_index <= temp_num; temp_index++) { + if(psuindex_single_temp_create_kobj_and_attrs(curr_psu, temp_index) != 0 ) { + goto temp_error; + } + } + return 0; +temp_error: + for(i = temp_index; i > 0; i--) { + psuindex_single_temp_remove_kobj_and_attrs(curr_psu, i); + } + kfree(curr_psu->temp); + curr_psu->temp = NULL; + return -EBADRQC; +} + +static void psuindex_temp_remove_kobj_and_attrs(struct psu_obj_s *curr_psu) +{ + unsigned int temp_index, temp_num; + + if (curr_psu->temp) { + temp_num = curr_psu->temp_number; + for (temp_index = temp_num; temp_index > 0; temp_index--) { + psuindex_single_temp_remove_kobj_and_attrs(curr_psu, temp_index); + } + kfree(curr_psu->temp); + curr_psu->temp = NULL; + } + return; +} + +/* create psu temp[1-n] directory and attributes*/ +static int psu_temp_create(void) +{ + int psu_num, temp_num; + unsigned int psu_index, i; + struct psu_obj_s *curr_psu; /* point to psu1 psu2...*/ + + psu_num = g_psu.psu_number; + if (psu_num <= 0) { + PSU_DBG("psu number: %d, skip to create temp* dirs and attrs.\n", psu_num); + return 0; + } + + check_p(g_psu_drv->get_psu_temp_number); + for(psu_index = 1; psu_index <= psu_num; psu_index++) { + temp_num = g_psu_drv->get_psu_temp_number(psu_index); + if (temp_num <= 0) { + PSU_DBG("psu%u temp number: %d, don't need to create temp* dirs and attrs.\n", + psu_index, temp_num); + continue; + } + curr_psu = &g_psu.psu[psu_index - 1]; + curr_psu->temp_number = temp_num; + if(psuindex_temp_create_kobj_and_attrs(curr_psu) != 0) { + goto error; + } + } + return 0; +error: + for(i = psu_index; i > 0; i--) { + curr_psu = &g_psu.psu[i - 1]; + psuindex_temp_remove_kobj_and_attrs(curr_psu); + } + return -EBADRQC; +} + +/* delete psu temp[1-n] directory and attributes*/ +static void psu_temp_remove(void) +{ + unsigned int psu_index; + struct psu_obj_s *curr_psu; + + if (g_psu.psu) { + for(psu_index = g_psu.psu_number; psu_index > 0; psu_index--) { + curr_psu = &g_psu.psu[psu_index - 1]; + psuindex_temp_remove_kobj_and_attrs(curr_psu); + curr_psu->temp_number = 0; + } + } + return; +} + +static int psu_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct psu_obj_s *curr_psu; + + curr_psu = &g_psu.psu[index - 1]; + if (curr_psu->obj) { + sysfs_remove_group(&curr_psu->obj->kobj, &psu_attr_group); + switch_kobject_delete(&curr_psu->obj); + PSU_DBG("delete psu%u dir and attrs success.\n", index); + } + return 0; +} + +static int psu_sub_single_create_kobj_and_attrs(struct kobject *parent, unsigned int index) +{ + char name[DIR_NAME_MAX_LEN]; + struct psu_obj_s *curr_psu; + + curr_psu = &g_psu.psu[index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "psu%u", index); + curr_psu->obj = switch_kobject_create(name, parent); + if (!curr_psu->obj) { + PSU_ERR("create %s object error!\n", name); + return -ENOMEM; + } + curr_psu->obj->index = index; + if (sysfs_create_group(&curr_psu->obj->kobj, &psu_attr_group) != 0) { + PSU_ERR("create %s attrs error.\n", name); + switch_kobject_delete(&curr_psu->obj); + return -EBADRQC; + } + PSU_DBG("create %s dir and attrs success.\n", name); + return 0; +} + +static int psu_sub_create_kobj_and_attrs(struct kobject *parent, int psu_num) +{ + unsigned int psu_index, i; + + g_psu.psu = kzalloc(sizeof(struct psu_obj_s) * psu_num, GFP_KERNEL); + if (!g_psu.psu) { + PSU_ERR("kzalloc psu.psu error, psu number = %d.\n", psu_num); + return -ENOMEM; + } + + for(psu_index = 1; psu_index <= psu_num; psu_index++) { + if(psu_sub_single_create_kobj_and_attrs(parent, psu_index) != 0 ) { + goto error; + } + } + return 0; +error: + for(i = psu_index; i > 0; i--) { + psu_sub_single_remove_kobj_and_attrs(i); + } + kfree(g_psu.psu); + g_psu.psu = NULL; + return -EBADRQC; +} + +/* create psu[1-n] directory and attributes*/ +static int psu_sub_create(void) +{ + int ret; + + ret = psu_sub_create_kobj_and_attrs(&g_psu_obj->kobj, g_psu.psu_number); + return ret; +} + +/* delete psu[1-n] directory and attributes*/ +static void psu_sub_remove(void) +{ + unsigned int psu_index; + + if (g_psu.psu) { + for (psu_index = g_psu.psu_number; psu_index > 0; psu_index--) { + psu_sub_single_remove_kobj_and_attrs(psu_index); + } + kfree(g_psu.psu); + g_psu.psu = NULL; + } + g_psu.psu_number = 0; + return; +} + +/* create psu directory and number attributes*/ +static int psu_root_create(void) +{ + g_psu_obj = switch_kobject_create("psu", NULL); + if (!g_psu_obj) { + PSU_ERR("switch_kobject_create psu error!\n"); + return -ENOMEM; + } + + if (sysfs_create_group(&g_psu_obj->kobj, &psu_root_attr_group) != 0) { + switch_kobject_delete(&g_psu_obj); + PSU_ERR("create psu dir attrs error!\n"); + return -EBADRQC; + } + return 0; +} + +/* delete psu directory and number attributes*/ +static void psu_root_remove(void) +{ + if (g_psu_obj) { + sysfs_remove_group(&g_psu_obj->kobj, &psu_root_attr_group); + switch_kobject_delete(&g_psu_obj); + PSU_DBG("delete psu dir and attrs success.\n"); + } + return; +} + +int s3ip_sysfs_psu_drivers_register(struct s3ip_sysfs_psu_drivers_s *drv) +{ + int ret, psu_num; + + PSU_INFO("s3ip_sysfs_psu_drivers_register...\n"); + if (g_psu_drv) { + PSU_ERR("g_psu_drv is not NULL, can't register\n"); + return -EPERM; + } + + check_p(drv); + check_p(drv->get_psu_number); + g_psu_drv = drv; + + psu_num = g_psu_drv->get_psu_number(); + if (psu_num <= 0) { + PSU_ERR("psu number: %d, don't need to create psu dirs and attrs.\n", psu_num); + g_psu_drv = NULL; + return -EINVAL; + } + + memset(&g_psu, 0, sizeof(struct psu_s)); + g_psu.psu_number = psu_num; + ret = psu_root_create(); + if (ret < 0) { + PSU_ERR("create psu root dir and attrs failed, ret: %d\n", ret); + g_psu_drv = NULL; + return ret; + } + + ret = psu_sub_create(); + if (ret < 0) { + PSU_ERR("create psu sub dir and attrs failed, ret: %d\n", ret); + psu_root_remove(); + g_psu_drv = NULL; + return ret; + } + + ret = psu_temp_create(); + if (ret < 0) { + PSU_ERR("create psu temp dir and attrs failed, ret: %d\n", ret); + psu_sub_remove(); + psu_root_remove(); + g_psu_drv = NULL; + return ret; + } + PSU_INFO("s3ip_sysfs_psu_drivers_register success.\n"); + return 0; +} + +void s3ip_sysfs_psu_drivers_unregister(void) +{ + if (g_psu_drv) { + psu_temp_remove(); + psu_sub_remove(); + psu_root_remove(); + g_psu_drv = NULL; + PSU_DBG("s3ip_sysfs_psu_drivers_unregister success.\n"); + } + + return; +} + +EXPORT_SYMBOL(s3ip_sysfs_psu_drivers_register); +EXPORT_SYMBOL(s3ip_sysfs_psu_drivers_unregister); +module_param(g_psu_loglevel, int, 0644); +MODULE_PARM_DESC(g_psu_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); diff --git a/platform/s3ip-sysfs/s3ip_sysfs_frame/slot_sysfs.c b/platform/s3ip-sysfs/s3ip_sysfs_frame/slot_sysfs.c new file mode 100644 index 000000000000..b0186ac6ad29 --- /dev/null +++ b/platform/s3ip-sysfs/s3ip_sysfs_frame/slot_sysfs.c @@ -0,0 +1,2099 @@ +/* + * slot_sysfs.c + * + * This module create slot kobjects and attributes in /sys/s3ip/slot + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "switch.h" +#include "slot_sysfs.h" + +static int g_slot_loglevel = 0; + +#define SLOT_INFO(fmt, args...) do { \ + if (g_slot_loglevel & INFO) { \ + printk(KERN_INFO "[SLOT_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define SLOT_ERR(fmt, args...) do { \ + if (g_slot_loglevel & ERR) { \ + printk(KERN_ERR "[SLOT_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define SLOT_DBG(fmt, args...) do { \ + if (g_slot_loglevel & DBG) { \ + printk(KERN_DEBUG "[SLOT_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +struct slot_temp_obj_s { + struct switch_obj *obj; +}; + +struct slot_vol_obj_s { + struct switch_obj *obj; +}; + +struct slot_curr_obj_s { + struct switch_obj *obj; +}; + +struct slot_fpga_obj_s { + struct switch_obj *obj; +}; + +struct slot_cpld_obj_s { + struct switch_obj *obj; +}; + +struct slot_obj_s { + unsigned int temp_number; + unsigned int vol_number; + unsigned int curr_number; + unsigned int fpga_number; + unsigned int cpld_number; + struct slot_temp_obj_s *temp; + struct slot_vol_obj_s *vol; + struct slot_curr_obj_s *curr; + struct slot_fpga_obj_s *fpga; + struct slot_cpld_obj_s *cpld; + struct switch_obj *obj; +}; + +struct slot_s { + unsigned int slot_number; + struct slot_obj_s *slot; +}; + +static struct slot_s g_slot; +static struct switch_obj *g_slot_obj = NULL; +static struct s3ip_sysfs_slot_drivers_s *g_slot_drv = NULL; + +static ssize_t slot_number_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + return (ssize_t)snprintf(buf, PAGE_SIZE, "%u\n", g_slot.slot_number); +} + +static ssize_t slot_temp_number_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int index; + + index = obj->index; + return (ssize_t)snprintf(buf, PAGE_SIZE, "%u\n", g_slot.slot[index - 1].temp_number); +} + +static ssize_t slot_vol_number_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int index; + + index = obj->index; + return (ssize_t)snprintf(buf, PAGE_SIZE, "%u\n", g_slot.slot[index - 1].vol_number); +} + +static ssize_t slot_curr_number_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int index; + + index = obj->index; + return (ssize_t)snprintf(buf, PAGE_SIZE, "%u\n", g_slot.slot[index - 1].curr_number); +} + +static ssize_t slot_fpga_number_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int index; + + index = obj->index; + return (ssize_t)snprintf(buf, PAGE_SIZE, "%u\n", g_slot.slot[index - 1].fpga_number); +} + +static ssize_t slot_cpld_number_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int index; + + index = obj->index; + return (ssize_t)snprintf(buf, PAGE_SIZE, "%u\n", g_slot.slot[index - 1].cpld_number); +} + +static ssize_t slot_model_name_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int slot_index; + int ret; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_model_name); + + slot_index = obj->index; + SLOT_DBG("slot index: %u\n", slot_index); + ret = g_slot_drv->get_slot_model_name(slot_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u model name failed, ret: %d\n", slot_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_sn_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int slot_index; + int ret; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_serial_number); + + slot_index = obj->index; + SLOT_DBG("slot index: %u\n", slot_index); + ret = g_slot_drv->get_slot_serial_number(slot_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u serial number failed, ret: %d\n", slot_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_pn_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index; + int ret; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_part_number); + + slot_index = obj->index; + SLOT_DBG("slot index: %u\n", slot_index); + ret = g_slot_drv->get_slot_part_number(slot_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u part number failed, ret: %d\n", slot_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_hw_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index; + int ret; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_hardware_version); + + slot_index = obj->index; + SLOT_DBG("slot index: %u\n", slot_index); + ret = g_slot_drv->get_slot_hardware_version(slot_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u hardware version failed, ret: %d\n", slot_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index; + int ret; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_status); + + slot_index = obj->index; + SLOT_DBG("slot index: %u\n", slot_index); + ret = g_slot_drv->get_slot_status(slot_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u status failed, ret: %d\n", slot_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_led_status_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int slot_index; + int ret; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_led_status); + + slot_index = obj->index; + SLOT_DBG("slot index: %u\n", slot_index); + ret = g_slot_drv->get_slot_led_status(slot_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u led status failed, ret: %d\n", slot_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_led_status_store(struct switch_obj *obj, struct switch_attribute *attr, + const char *buf, size_t count) +{ + unsigned int slot_index; + int ret, led_status; + + check_p(g_slot_drv); + check_p(g_slot_drv->set_slot_led_status); + + slot_index = obj->index; + sscanf(buf, "%d", &led_status); + SLOT_DBG("slot index: %u, led_status: %d\n", slot_index, led_status); + ret = g_slot_drv->set_slot_led_status(slot_index, led_status); + if (ret < 0) { + SLOT_ERR("set slot%u led_status: %d failed, ret: %d\n", slot_index, led_status, ret); + return -EIO; + } + SLOT_DBG("set slot%u led_status: %d success\n", slot_index, led_status); + return count; +} + +/*************************************slot temp*************************************************/ +static ssize_t slot_temp_value_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_temp_value); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + temp_index = obj->index; + + SLOT_DBG("slot index: %u, temp index: %u\n", slot_index, temp_index); + ret = g_slot_drv->get_slot_temp_value(slot_index, temp_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u temp%u value failed, ret: %d\n", slot_index, temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_temp_alias_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_temp_alias); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + temp_index = obj->index; + + SLOT_DBG("slot index: %u, temp index: %u\n", slot_index, temp_index); + ret = g_slot_drv->get_slot_temp_alias(slot_index, temp_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u temp%u alias failed, ret: %d\n", slot_index, temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_temp_type_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_temp_type); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + temp_index = obj->index; + + SLOT_DBG("slot index: %u, temp index: %u\n", slot_index, temp_index); + ret = g_slot_drv->get_slot_temp_type(slot_index, temp_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u temp%u type failed, ret: %d\n", slot_index, temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_temp_max_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_temp_max); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + temp_index = obj->index; + + SLOT_DBG("slot index: %u, temp index: %u\n", slot_index, temp_index); + ret = g_slot_drv->get_slot_temp_max(slot_index, temp_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u temp%u max threshold failed, ret: %d\n", + slot_index, temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_temp_max_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int slot_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->set_slot_temp_max); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + temp_index = obj->index; + ret = g_slot_drv->set_slot_temp_max(slot_index, temp_index, buf, count); + if (ret < 0) { + SLOT_ERR("set slot%u temp%u max threshold failed, value: %s, count: %lu, ret: %d\n", + slot_index, temp_index, buf, count, ret); + return -EIO; + } + SLOT_DBG("set slot%u temp%u max threshold success, value: %s, count: %lu, ret: %d\n", + slot_index, temp_index, buf, count, ret); + return count; +} + +static ssize_t slot_temp_min_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_temp_min); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + temp_index = obj->index; + + SLOT_DBG("slot index: %u, temp index: %u\n", slot_index, temp_index); + ret = g_slot_drv->get_slot_temp_min(slot_index, temp_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u temp%u min threshold failed, ret: %d\n", + slot_index, temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_temp_min_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int slot_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->set_slot_temp_min); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + temp_index = obj->index; + ret = g_slot_drv->set_slot_temp_min(slot_index, temp_index, buf, count); + if (ret < 0) { + SLOT_ERR("set slot%u temp%u min threshold failed, value: %s, count: %lu, ret: %d\n", + slot_index, temp_index, buf, count, ret); + return -EIO; + } + SLOT_DBG("set slot%u temp%u min threshold success, value: %s, count: %lu, ret: %d\n", + slot_index, temp_index, buf, count, ret); + return count; +} +/**********************************end of slot temp**********************************************/ + +/*************************************slot vol*************************************************/ +static ssize_t slot_vol_value_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, vol_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_vol_value); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + vol_index = obj->index; + + SLOT_DBG("slot index: %u, vol index: %u\n", slot_index, vol_index); + ret = g_slot_drv->get_slot_vol_value(slot_index, vol_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u vol%u value failed, ret: %d\n", slot_index, vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_vol_alias_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, vol_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_vol_alias); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + vol_index = obj->index; + + SLOT_DBG("slot index: %u, vol index: %u\n", slot_index, vol_index); + ret = g_slot_drv->get_slot_vol_alias(slot_index, vol_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u vol%u alias failed, ret: %d\n", slot_index, vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_vol_type_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, vol_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_vol_type); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + vol_index = obj->index; + + SLOT_DBG("slot index: %u, vol index: %u\n", slot_index, vol_index); + ret = g_slot_drv->get_slot_vol_type(slot_index, vol_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u vol%u type failed, ret: %d\n", slot_index, vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_vol_max_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, vol_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_vol_max); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + vol_index = obj->index; + + SLOT_DBG("slot index: %u, vol index: %u\n", slot_index, vol_index); + ret = g_slot_drv->get_slot_vol_max(slot_index, vol_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u vol%u max threshold failed, ret: %d\n", + slot_index, vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_vol_max_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int slot_index, vol_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->set_slot_vol_max); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + vol_index = obj->index; + ret = g_slot_drv->set_slot_vol_max(slot_index, vol_index, buf, count); + if (ret < 0) { + SLOT_ERR("set slot%u vol%u max threshold failed, value: %s, count: %lu, ret: %d\n", + slot_index, vol_index, buf, count, ret); + return -EIO; + } + SLOT_DBG("set slot%u vol%u max threshold success, value: %s, count: %lu, ret: %d\n", + slot_index, vol_index, buf, count, ret); + return count; +} + +static ssize_t slot_vol_min_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, vol_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_vol_min); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + vol_index = obj->index; + + SLOT_DBG("slot index: %u, vol index: %u\n", slot_index, vol_index); + ret = g_slot_drv->get_slot_vol_min(slot_index, vol_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u vol%u min threshold failed, ret: %d\n", + slot_index, vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_vol_min_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int slot_index, vol_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->set_slot_vol_min); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + vol_index = obj->index; + ret = g_slot_drv->set_slot_vol_min(slot_index, vol_index, buf, count); + if (ret < 0) { + SLOT_ERR("set slot%u vol%u min threshold failed, value: %s, count: %lu, ret: %d\n", + slot_index, vol_index, buf, count, ret); + return -EIO; + } + SLOT_DBG("set slot%u vol%u min threshold success, value: %s, count: %lu, ret: %d\n", + slot_index, vol_index, buf, count, ret); + return count; +} + +static ssize_t slot_vol_range_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, vol_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_vol_range); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + vol_index = obj->index; + + SLOT_DBG("slot index: %u, vol index: %u\n", slot_index, vol_index); + ret = g_slot_drv->get_slot_vol_range(slot_index, vol_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u vol%u voltage range failed, ret: %d\n", + slot_index, vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_vol_nominal_value_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, vol_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_vol_nominal_value); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + vol_index = obj->index; + + SLOT_DBG("slot index: %u, vol index: %u\n", slot_index, vol_index); + ret = g_slot_drv->get_slot_vol_nominal_value(slot_index, vol_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u vol%u voltage nominal value failed, ret: %d\n", + slot_index, vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} +/**********************************end of slot vol**********************************************/ +/*************************************slot curr*************************************************/ +static ssize_t slot_curr_value_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, curr_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_curr_value); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + curr_index = obj->index; + + SLOT_DBG("slot index: %u, curr index: %u\n", slot_index, curr_index); + ret = g_slot_drv->get_slot_curr_value(slot_index, curr_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u curr%u value failed, ret: %d\n", slot_index, curr_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_curr_alias_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, curr_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_curr_alias); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + curr_index = obj->index; + + SLOT_DBG("slot index: %u, curr index: %u\n", slot_index, curr_index); + ret = g_slot_drv->get_slot_curr_alias(slot_index, curr_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u curr%u alias failed, ret: %d\n", slot_index, curr_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_curr_type_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, curr_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_curr_type); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + curr_index = obj->index; + + SLOT_DBG("slot index: %u, curr index: %u\n", slot_index, curr_index); + ret = g_slot_drv->get_slot_curr_type(slot_index, curr_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u curr%u type failed, ret: %d\n", slot_index, curr_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_curr_max_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, curr_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_curr_max); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + curr_index = obj->index; + + SLOT_DBG("slot index: %u, curr index: %u\n", slot_index, curr_index); + ret = g_slot_drv->get_slot_curr_max(slot_index, curr_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u curr%u max threshold failed, ret: %d\n", + slot_index, curr_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_curr_max_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int slot_index, curr_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->set_slot_curr_max); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + curr_index = obj->index; + ret = g_slot_drv->set_slot_curr_max(slot_index, curr_index, buf, count); + if (ret < 0) { + SLOT_ERR("set slot%u curr%u max threshold failed, value: %s, count: %lu, ret: %d\n", + slot_index, curr_index, buf, count, ret); + return -EIO; + } + SLOT_DBG("set slot%u curr%u max threshold success, value: %s, count: %lu, ret: %d\n", + slot_index, curr_index, buf, count, ret); + return count; +} + +static ssize_t slot_curr_min_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, curr_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_curr_min); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + curr_index = obj->index; + + SLOT_DBG("slot index: %u, curr index: %u\n", slot_index, curr_index); + ret = g_slot_drv->get_slot_curr_min(slot_index, curr_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u curr%u min threshold failed, ret: %d\n", + slot_index, curr_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_curr_min_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int slot_index, curr_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->set_slot_curr_min); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + curr_index = obj->index; + ret = g_slot_drv->set_slot_curr_min(slot_index, curr_index, buf, count); + if (ret < 0) { + SLOT_ERR("set slot%u curr%u min threshold failed, value: %s, count: %lu, ret: %d\n", + slot_index, curr_index, buf, count, ret); + return -EIO; + } + SLOT_DBG("set slot%u curr%u min threshold success, value: %s, count: %lu, ret: %d\n", + slot_index, curr_index, buf, count, ret); + return count; +} +/**********************************end of slot curr**********************************************/ +/*************************************slot fpga*************************************************/ +static ssize_t slot_fpga_alias_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, fpga_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_fpga_alias); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + fpga_index = obj->index; + + SLOT_DBG("slot index: %u, fpga index: %u\n", slot_index, fpga_index); + ret = g_slot_drv->get_slot_fpga_alias(slot_index, fpga_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u fpga%u alias failed, ret: %d\n", slot_index, fpga_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_fpga_type_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, fpga_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_fpga_type); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + fpga_index = obj->index; + + SLOT_DBG("slot index: %u, fpga index: %u\n", slot_index, fpga_index); + ret = g_slot_drv->get_slot_fpga_type(slot_index, fpga_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u fpga%u type failed, ret: %d\n", slot_index, fpga_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_fpga_fw_version_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int slot_index, fpga_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_fpga_firmware_version); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + fpga_index = obj->index; + + SLOT_DBG("slot index: %u, fpga index: %u\n", slot_index, fpga_index); + ret = g_slot_drv->get_slot_fpga_firmware_version(slot_index, fpga_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u fpga%u firmware version failed, ret: %d\n", slot_index, fpga_index, + ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_fpga_board_version_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int slot_index, fpga_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_fpga_board_version); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + fpga_index = obj->index; + + SLOT_DBG("slot index: %u, fpga index: %u\n", slot_index, fpga_index); + ret = g_slot_drv->get_slot_fpga_board_version(slot_index, fpga_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u fpga%u board version failed, ret: %d\n", slot_index, fpga_index, + ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_fpga_test_reg_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int slot_index, fpga_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_fpga_test_reg); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + fpga_index = obj->index; + + SLOT_DBG("slot index: %u, fpga index: %u\n", slot_index, fpga_index); + ret = g_slot_drv->get_slot_fpga_test_reg(slot_index, fpga_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u fpga%u test register failed, ret: %d\n", slot_index, fpga_index, + ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_fpga_test_reg_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int slot_index, fpga_index, value; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->set_slot_fpga_test_reg); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + fpga_index = obj->index; + sscanf(buf, "0x%x", &value); + ret = g_slot_drv->set_slot_fpga_test_reg(slot_index, fpga_index, value); + if (ret < 0) { + SLOT_ERR("set slot%u fpga%u test reg failed, value:0x%x, ret: %d.\n", + slot_index, fpga_index, value, ret); + return -EIO; + } + SLOT_DBG("set slot%u fpga%u test reg success, value: 0x%x.\n", slot_index, fpga_index, value); + return count; +} +/**********************************end of slot fpga**********************************************/ +/*************************************slot cpld*************************************************/ +static ssize_t slot_cpld_alias_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, cpld_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_cpld_alias); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + cpld_index = obj->index; + + SLOT_DBG("slot index: %u, cpld index: %u\n", slot_index, cpld_index); + ret = g_slot_drv->get_slot_cpld_alias(slot_index, cpld_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u cpld%u alias failed, ret: %d\n", slot_index, cpld_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_cpld_type_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, cpld_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_cpld_type); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + cpld_index = obj->index; + + SLOT_DBG("slot index: %u, cpld index: %u\n", slot_index, cpld_index); + ret = g_slot_drv->get_slot_cpld_type(slot_index, cpld_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u cpld%u type failed, ret: %d\n", slot_index, cpld_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_cpld_fw_version_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int slot_index, cpld_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_cpld_firmware_version); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + cpld_index = obj->index; + + SLOT_DBG("slot index: %u, cpld index: %u\n", slot_index, cpld_index); + ret = g_slot_drv->get_slot_cpld_firmware_version(slot_index, cpld_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u cpld%u firmware version failed, ret: %d\n", slot_index, cpld_index, + ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_cpld_board_version_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int slot_index, cpld_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_cpld_board_version); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + cpld_index = obj->index; + + SLOT_DBG("slot index: %u, cpld index: %u\n", slot_index, cpld_index); + ret = g_slot_drv->get_slot_cpld_board_version(slot_index, cpld_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u cpld%u board version failed, ret: %d\n", slot_index, cpld_index, + ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_cpld_test_reg_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int slot_index, cpld_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_cpld_test_reg); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + cpld_index = obj->index; + + SLOT_DBG("slot index: %u, cpld index: %u\n", slot_index, cpld_index); + ret = g_slot_drv->get_slot_cpld_test_reg(slot_index, cpld_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u cpld%u test register failed, ret: %d\n", slot_index, cpld_index, + ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_cpld_test_reg_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int slot_index, cpld_index, value; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->set_slot_cpld_test_reg); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + cpld_index = obj->index; + sscanf(buf, "0x%x", &value); + ret = g_slot_drv->set_slot_cpld_test_reg(slot_index, cpld_index, value); + if (ret < 0) { + SLOT_ERR("set slot%u cpld%u test reg failed, value:0x%x, ret: %d.\n", + slot_index, cpld_index, value, ret); + return -EIO; + } + SLOT_DBG("set slot%u cpld%u test reg success, value: 0x%x.\n", slot_index, cpld_index, value); + return count; +} +/**********************************end of slot cpld**********************************************/ +/**********************************slot dir and attrs********************************************/ +static struct switch_attribute slot_number_attr = __ATTR(number, S_IRUGO, slot_number_show, NULL); + +static struct attribute *slot_dir_attrs[] = { + &slot_number_attr.attr, + NULL, +}; + +static struct attribute_group slot_root_attr_group = { + .attrs = slot_dir_attrs, +}; + +/*******************************slot[1-n] dir and attrs*******************************************/ +static struct switch_attribute slot_model_name_attr = __ATTR(model_name, S_IRUGO, slot_model_name_show, NULL); +static struct switch_attribute slot_hw_attr = __ATTR(hardware_version, S_IRUGO, slot_hw_show, NULL); +static struct switch_attribute slot_sn_attr = __ATTR(serial_number, S_IRUGO, slot_sn_show, NULL); +static struct switch_attribute slot_pn_attr = __ATTR(part_number, S_IRUGO, slot_pn_show, NULL); +static struct switch_attribute slot_status_attr = __ATTR(status, S_IRUGO, slot_status_show, NULL); +static struct switch_attribute slot_led_status_attr = __ATTR(led_status, S_IRUGO | S_IWUSR, slot_led_status_show, slot_led_status_store); +static struct switch_attribute num_temp_sensors_attr = __ATTR(num_temp_sensors, S_IRUGO, slot_temp_number_show, NULL); +static struct switch_attribute num_vol_sensors_attr = __ATTR(num_vol_sensors, S_IRUGO, slot_vol_number_show, NULL); +static struct switch_attribute num_curr_sensors_attr = __ATTR(num_curr_sensors, S_IRUGO, slot_curr_number_show, NULL); +static struct switch_attribute num_fpga_attr = __ATTR(num_fpgas, S_IRUGO, slot_fpga_number_show, NULL); +static struct switch_attribute num_cpld_attr = __ATTR(num_cplds, S_IRUGO, slot_cpld_number_show, NULL); + +static struct attribute *slot_attrs[] = { + &slot_model_name_attr.attr, + &slot_hw_attr.attr, + &slot_sn_attr.attr, + &slot_pn_attr.attr, + &slot_status_attr.attr, + &slot_led_status_attr.attr, + &num_temp_sensors_attr.attr, + &num_vol_sensors_attr.attr, + &num_curr_sensors_attr.attr, + &num_fpga_attr.attr, + &num_cpld_attr.attr, + NULL, +}; + +static struct attribute_group slot_attr_group = { + .attrs = slot_attrs, +}; + +/*******************************slot temp[1-n] dir and attrs*******************************************/ +static struct switch_attribute slot_temp_alias_attr = __ATTR(alias, S_IRUGO, slot_temp_alias_show, NULL); +static struct switch_attribute slot_temp_type_attr = __ATTR(type, S_IRUGO, slot_temp_type_show, NULL); +static struct switch_attribute slot_temp_max_attr = __ATTR(max, S_IRUGO | S_IWUSR, slot_temp_max_show, slot_temp_max_store); +static struct switch_attribute slot_temp_min_attr = __ATTR(min, S_IRUGO | S_IWUSR, slot_temp_min_show, slot_temp_min_store); +static struct switch_attribute slot_temp_value_attr = __ATTR(value, S_IRUGO, slot_temp_value_show, NULL); + +static struct attribute *slot_temp_attrs[] = { + &slot_temp_alias_attr.attr, + &slot_temp_type_attr.attr, + &slot_temp_max_attr.attr, + &slot_temp_min_attr.attr, + &slot_temp_value_attr.attr, + NULL, +}; + +static struct attribute_group slot_temp_attr_group = { + .attrs = slot_temp_attrs, +}; + +/*******************************slot vol[1-n] dir and attrs*******************************************/ +static struct switch_attribute slot_vol_alias_attr = __ATTR(alias, S_IRUGO, slot_vol_alias_show, NULL); +static struct switch_attribute slot_vol_type_attr = __ATTR(type, S_IRUGO, slot_vol_type_show, NULL); +static struct switch_attribute slot_vol_max_attr = __ATTR(max, S_IRUGO | S_IWUSR, slot_vol_max_show, slot_vol_max_store); +static struct switch_attribute slot_vol_min_attr = __ATTR(min, S_IRUGO | S_IWUSR, slot_vol_min_show, slot_vol_min_store); +static struct switch_attribute slot_vol_value_attr = __ATTR(value, S_IRUGO, slot_vol_value_show, NULL); +static struct switch_attribute slot_vol_range_attr = __ATTR(range, S_IRUGO, slot_vol_range_show, NULL); +static struct switch_attribute slot_vol_nominal_value_attr = __ATTR(nominal_value, S_IRUGO, slot_vol_nominal_value_show, NULL); + +static struct attribute *slot_vol_attrs[] = { + &slot_vol_alias_attr.attr, + &slot_vol_type_attr.attr, + &slot_vol_max_attr.attr, + &slot_vol_min_attr.attr, + &slot_vol_value_attr.attr, + &slot_vol_range_attr.attr, + &slot_vol_nominal_value_attr.attr, + NULL, +}; + +static struct attribute_group slot_vol_attr_group = { + .attrs = slot_vol_attrs, +}; + +/*******************************slot curr[1-n] dir and attrs*******************************************/ +static struct switch_attribute slot_curr_alias_attr = __ATTR(alias, S_IRUGO, slot_curr_alias_show, NULL); +static struct switch_attribute slot_curr_type_attr = __ATTR(type, S_IRUGO, slot_curr_type_show, NULL); +static struct switch_attribute slot_curr_max_attr = __ATTR(max, S_IRUGO | S_IWUSR, slot_curr_max_show, slot_curr_max_store); +static struct switch_attribute slot_curr_min_attr = __ATTR(min, S_IRUGO | S_IWUSR, slot_curr_min_show, slot_curr_min_store); +static struct switch_attribute slot_curr_value_attr = __ATTR(value, S_IRUGO, slot_curr_value_show, NULL); + +static struct attribute *slot_curr_attrs[] = { + &slot_curr_alias_attr.attr, + &slot_curr_type_attr.attr, + &slot_curr_max_attr.attr, + &slot_curr_min_attr.attr, + &slot_curr_value_attr.attr, + NULL, +}; + +static struct attribute_group slot_curr_attr_group = { + .attrs = slot_curr_attrs, +}; + +/*******************************slot fpga[1-n] dir and attrs*******************************************/ +static struct switch_attribute slot_fpga_alias_attr = __ATTR(alias, S_IRUGO, slot_fpga_alias_show, NULL); +static struct switch_attribute slot_fpga_type_attr = __ATTR(type, S_IRUGO, slot_fpga_type_show, NULL); +static struct switch_attribute slot_fpga_fw_version_attr = __ATTR(firmware_version, S_IRUGO, slot_fpga_fw_version_show, NULL); +static struct switch_attribute slot_fpga_board_version_attr = __ATTR(board_version, S_IRUGO, slot_fpga_board_version_show, NULL); +static struct switch_attribute slot_fpga_test_reg_attr = __ATTR(reg_test, S_IRUGO | S_IWUSR, slot_fpga_test_reg_show, slot_fpga_test_reg_store); + +static struct attribute *slot_fpga_attrs[] = { + &slot_fpga_alias_attr.attr, + &slot_fpga_type_attr.attr, + &slot_fpga_fw_version_attr.attr, + &slot_fpga_board_version_attr.attr, + &slot_fpga_test_reg_attr.attr, + NULL, +}; + +static struct attribute_group slot_fpga_attr_group = { + .attrs = slot_fpga_attrs, +}; + +/*******************************slot cpld[1-n] dir and attrs*******************************************/ +static struct switch_attribute slot_cpld_alias_attr = __ATTR(alias, S_IRUGO, slot_cpld_alias_show, NULL); +static struct switch_attribute slot_cpld_type_attr = __ATTR(type, S_IRUGO, slot_cpld_type_show, NULL); +static struct switch_attribute slot_cpld_fw_version_attr = __ATTR(firmware_version, S_IRUGO, slot_cpld_fw_version_show, NULL); +static struct switch_attribute slot_cpld_board_version_attr = __ATTR(board_version, S_IRUGO, slot_cpld_board_version_show, NULL); +static struct switch_attribute slot_cpld_test_reg_attr = __ATTR(reg_test, S_IRUGO | S_IWUSR, slot_cpld_test_reg_show, slot_cpld_test_reg_store); + +static struct attribute *slot_cpld_attrs[] = { + &slot_cpld_alias_attr.attr, + &slot_cpld_type_attr.attr, + &slot_cpld_fw_version_attr.attr, + &slot_cpld_board_version_attr.attr, + &slot_cpld_test_reg_attr.attr, + NULL, +}; + +static struct attribute_group slot_cpld_attr_group = { + .attrs = slot_cpld_attrs, +}; + +/***************************************slot cpld*****************************************/ +static void slotindex_single_cpld_remove_kobj_and_attrs(struct slot_obj_s *curr_slot, + unsigned int cpld_index) +{ + struct slot_cpld_obj_s *curr_cpld; + + curr_cpld = &curr_slot->cpld[cpld_index - 1]; + if (curr_cpld->obj) { + sysfs_remove_group(&curr_cpld->obj->kobj, &slot_cpld_attr_group); + switch_kobject_delete(&curr_cpld->obj); + SLOT_DBG("delete slot%u cpld%u dir and attrs success.\n", curr_slot->obj->index, + cpld_index); + } + return; +} + +static int slotindex_single_cpld_create_kobj_and_attrs(struct slot_obj_s *curr_slot, + unsigned int cpld_index) +{ + char name[DIR_NAME_MAX_LEN]; + struct slot_cpld_obj_s *curr_cpld; + + curr_cpld = &curr_slot->cpld[cpld_index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "cpld%u", cpld_index); + curr_cpld->obj = switch_kobject_create(name, &curr_slot->obj->kobj); + if (!curr_cpld->obj) { + SLOT_ERR("create slot%u %s object error!\n", curr_slot->obj->index, name); + return -ENOMEM; + } + curr_cpld->obj->index = cpld_index; + if (sysfs_create_group(&curr_cpld->obj->kobj, &slot_cpld_attr_group) != 0) { + SLOT_ERR("create slot%u %s attrs error.\n", curr_slot->obj->index, name); + switch_kobject_delete(&curr_cpld->obj); + return -EBADRQC; + } + SLOT_DBG("create slot%u %s success.\n", curr_slot->obj->index, name); + return 0; +} + +static void slotindex_cpld_remove_kobj_and_attrs(struct slot_obj_s *curr_slot) +{ + unsigned int cpld_index, cpld_num; + + if (curr_slot->cpld) { + cpld_num = curr_slot->cpld_number; + for (cpld_index = cpld_num; cpld_index > 0; cpld_index--) { + slotindex_single_cpld_remove_kobj_and_attrs(curr_slot, cpld_index); + } + kfree(curr_slot->cpld); + curr_slot->cpld = NULL; + } + return; +} + +static int slotindex_cpld_create_kobj_and_attrs(struct slot_obj_s *curr_slot) +{ + unsigned int cpld_index, i, cpld_num; + + cpld_num = curr_slot->cpld_number; + curr_slot->cpld = kzalloc(sizeof(struct slot_cpld_obj_s) * cpld_num, GFP_KERNEL); + if (!curr_slot->cpld) { + SLOT_ERR("kzalloc slot cpld error, slot index: %u, cpld number: %u.\n", + curr_slot->obj->index, cpld_num); + return -ENOMEM; + } + + for (cpld_index = 1; cpld_index <= cpld_num; cpld_index++) { + if (slotindex_single_cpld_create_kobj_and_attrs(curr_slot, cpld_index) != 0) { + goto error; + } + } + return 0; +error: + for (i = cpld_index; i > 0; i--) { + slotindex_single_cpld_remove_kobj_and_attrs(curr_slot, i); + } + kfree(curr_slot->cpld); + curr_slot->cpld = NULL; + return -EBADRQC; +} + +/* create slot cpld[1-n] directory and attributes*/ +static int slot_cpld_create(void) +{ + int cpld_num; + unsigned int slot_index, i; + struct slot_obj_s *curr_slot; + + check_p(g_slot_drv->get_slot_cpld_number); + for (slot_index = 1; slot_index <= g_slot.slot_number; slot_index++) { + cpld_num = g_slot_drv->get_slot_cpld_number(slot_index); + if (cpld_num <= 0) { + SLOT_DBG("slot%u cpld number: %d, don't need to create cpld* dirs and attrs.\n", + slot_index, cpld_num); + continue; + } + curr_slot = &g_slot.slot[slot_index - 1]; + curr_slot->cpld_number = cpld_num; + if (slotindex_cpld_create_kobj_and_attrs(curr_slot) != 0) { + goto error; + } + } + return 0; +error: + for (i = slot_index; i > 0; i--) { + curr_slot = &g_slot.slot[i - 1]; + slotindex_cpld_remove_kobj_and_attrs(curr_slot); + } + return -EBADRQC; +} + +/* delete slot cpld[1-n] directory and attributes*/ +static void slot_cpld_remove(void) +{ + unsigned int slot_index; + struct slot_obj_s *curr_slot; + + if (g_slot.slot) { + for (slot_index = g_slot.slot_number; slot_index > 0; slot_index--) { + curr_slot = &g_slot.slot[slot_index - 1]; + slotindex_cpld_remove_kobj_and_attrs(curr_slot); + curr_slot->cpld_number = 0; + } + } + return; +} +/************************************end of slot cpld**************************************/ +/***************************************slot fpga*****************************************/ +static void slotindex_single_fpga_remove_kobj_and_attrs(struct slot_obj_s *curr_slot, + unsigned int fpga_index) +{ + struct slot_fpga_obj_s *curr_fpga; + + curr_fpga = &curr_slot->fpga[fpga_index - 1]; + if (curr_fpga->obj) { + sysfs_remove_group(&curr_fpga->obj->kobj, &slot_fpga_attr_group); + switch_kobject_delete(&curr_fpga->obj); + SLOT_DBG("delete slot%u fpga%u dir and attrs success.\n", curr_slot->obj->index, + fpga_index); + } + return; +} + +static int slotindex_single_fpga_create_kobj_and_attrs(struct slot_obj_s *curr_slot, + unsigned int fpga_index) +{ + char name[DIR_NAME_MAX_LEN]; + struct slot_fpga_obj_s *curr_fpga; + + curr_fpga = &curr_slot->fpga[fpga_index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "fpga%u", fpga_index); + curr_fpga->obj = switch_kobject_create(name, &curr_slot->obj->kobj); + if (!curr_fpga->obj) { + SLOT_ERR("create slot%u %s object error!\n", curr_slot->obj->index, name); + return -ENOMEM; + } + curr_fpga->obj->index = fpga_index; + if (sysfs_create_group(&curr_fpga->obj->kobj, &slot_fpga_attr_group) != 0) { + SLOT_ERR("create slot%u %s attrs error.\n", curr_slot->obj->index, name); + switch_kobject_delete(&curr_fpga->obj); + return -EBADRQC; + } + SLOT_DBG("create slot%u %s success.\n", curr_slot->obj->index, name); + return 0; +} + +static void slotindex_fpga_remove_kobj_and_attrs(struct slot_obj_s *curr_slot) +{ + unsigned int fpga_index, fpga_num; + + if (curr_slot->fpga) { + fpga_num = curr_slot->fpga_number; + for (fpga_index = fpga_num; fpga_index > 0; fpga_index--) { + slotindex_single_fpga_remove_kobj_and_attrs(curr_slot, fpga_index); + } + kfree(curr_slot->fpga); + curr_slot->fpga = NULL; + } + return; +} + +static int slotindex_fpga_create_kobj_and_attrs(struct slot_obj_s *curr_slot) +{ + unsigned int fpga_index, i, fpga_num; + + fpga_num = curr_slot->fpga_number; + curr_slot->fpga = kzalloc(sizeof(struct slot_fpga_obj_s) * fpga_num, GFP_KERNEL); + if (!curr_slot->fpga) { + SLOT_ERR("kzalloc slot fpga error, slot index: %u, fpga number: %u.\n", + curr_slot->obj->index, fpga_num); + return -ENOMEM; + } + + for (fpga_index = 1; fpga_index <= fpga_num; fpga_index++) { + if (slotindex_single_fpga_create_kobj_and_attrs(curr_slot, fpga_index) != 0) { + goto error; + } + } + return 0; +error: + for (i = fpga_index; i > 0; i--) { + slotindex_single_fpga_remove_kobj_and_attrs(curr_slot, i); + } + kfree(curr_slot->fpga); + curr_slot->fpga = NULL; + return -EBADRQC; +} + +/* create slot fpga[1-n] directory and attributes*/ +static int slot_fpga_create(void) +{ + int fpga_num; + unsigned int slot_index, i; + struct slot_obj_s *curr_slot; + + check_p(g_slot_drv->get_slot_fpga_number); + for (slot_index = 1; slot_index <= g_slot.slot_number; slot_index++) { + fpga_num = g_slot_drv->get_slot_fpga_number(slot_index); + if (fpga_num <= 0) { + SLOT_DBG("slot%u fpga number: %d, don't need to create fpga* dirs and attrs.\n", + slot_index, fpga_num); + continue; + } + curr_slot = &g_slot.slot[slot_index - 1]; + curr_slot->fpga_number = fpga_num; + if (slotindex_fpga_create_kobj_and_attrs(curr_slot) != 0) { + goto error; + } + } + return 0; +error: + for (i = slot_index; i > 0; i--) { + curr_slot = &g_slot.slot[i - 1]; + slotindex_fpga_remove_kobj_and_attrs(curr_slot); + } + return -EBADRQC; +} + +/* delete slot fpga[1-n] directory and attributes*/ +static void slot_fpga_remove(void) +{ + unsigned int slot_index; + struct slot_obj_s *curr_slot; + + if (g_slot.slot) { + for (slot_index = g_slot.slot_number; slot_index > 0; slot_index--) { + curr_slot = &g_slot.slot[slot_index - 1]; + slotindex_fpga_remove_kobj_and_attrs(curr_slot); + curr_slot->fpga_number = 0; + } + } + return; +} +/************************************end of slot fpga**************************************/ +/*************************************slot current*****************************************/ +static void slotindex_single_curr_remove_kobj_and_attrs(struct slot_obj_s *curr_slot, + unsigned int curr_index) +{ + struct slot_curr_obj_s *curr; + + curr = &curr_slot->curr[curr_index - 1]; + if (curr->obj) { + sysfs_remove_group(&curr->obj->kobj, &slot_curr_attr_group); + switch_kobject_delete(&curr->obj); + SLOT_DBG("delete slot%u curr_sensor%u dir and attrs success.\n", curr_slot->obj->index, + curr_index); + } + return; +} + +static int slotindex_single_curr_create_kobj_and_attrs(struct slot_obj_s *curr_slot, + unsigned int curr_index) +{ + char name[DIR_NAME_MAX_LEN]; + struct slot_curr_obj_s *curr; + + curr = &curr_slot->curr[curr_index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "curr_sensor%u", curr_index); + curr->obj = switch_kobject_create(name, &curr_slot->obj->kobj); + if (!curr->obj) { + SLOT_ERR("create slot%u %s object error!\n", curr_slot->obj->index, name); + return -ENOMEM; + } + curr->obj->index = curr_index; + if (sysfs_create_group(&curr->obj->kobj, &slot_curr_attr_group) != 0) { + SLOT_ERR("create slot%u %s attrs error.\n", curr_slot->obj->index, name); + switch_kobject_delete(&curr->obj); + return -EBADRQC; + } + SLOT_DBG("create slot%u %s success.\n", curr_slot->obj->index, name); + return 0; +} + +static void slotindex_curr_remove_kobj_and_attrs(struct slot_obj_s *curr_slot) +{ + unsigned int curr_index, curr_num; + + if (curr_slot->curr) { + curr_num = curr_slot->curr_number; + for (curr_index = curr_num; curr_index > 0; curr_index--) { + slotindex_single_curr_remove_kobj_and_attrs(curr_slot, curr_index); + } + kfree(curr_slot->curr); + curr_slot->curr = NULL; + } + return; +} + +static int slotindex_curr_create_kobj_and_attrs(struct slot_obj_s *curr_slot) +{ + unsigned int curr_index, i, curr_num; + + curr_num = curr_slot->curr_number; + curr_slot->curr = kzalloc(sizeof(struct slot_curr_obj_s) * curr_num, GFP_KERNEL); + if (!curr_slot->curr) { + SLOT_ERR("kzalloc slot curr error, slot index: %u, curr number: %u.\n", + curr_slot->obj->index, curr_num); + return -ENOMEM; + } + + for (curr_index = 1; curr_index <= curr_num; curr_index++) { + if (slotindex_single_curr_create_kobj_and_attrs(curr_slot, curr_index) != 0) { + goto error; + } + } + return 0; +error: + for (i = curr_index; i > 0; i--) { + slotindex_single_curr_remove_kobj_and_attrs(curr_slot, i); + } + kfree(curr_slot->curr); + curr_slot->curr = NULL; + return -EBADRQC; +} + +/* create slot curr_snesor[1-n] directory and attributes*/ +static int slot_curr_create(void) +{ + int curr_num; + unsigned int slot_index, i; + struct slot_obj_s *curr_slot; + + check_p(g_slot_drv->get_slot_curr_number); + for (slot_index = 1; slot_index <= g_slot.slot_number; slot_index++) { + curr_num = g_slot_drv->get_slot_curr_number(slot_index); + if (curr_num <= 0) { + SLOT_DBG("slot%u curr number: %d, don't need to create curr_sensor* dirs and attrs.\n", + slot_index, curr_num); + continue; + } + curr_slot = &g_slot.slot[slot_index - 1]; + curr_slot->curr_number = curr_num; + if (slotindex_curr_create_kobj_and_attrs(curr_slot) != 0) { + goto error; + } + } + return 0; +error: + for (i = slot_index; i > 0; i--) { + curr_slot = &g_slot.slot[i - 1]; + slotindex_curr_remove_kobj_and_attrs(curr_slot); + } + return -EBADRQC; +} + +/* delete slot curr_sensor[1-n] directory and attributes*/ +static void slot_curr_remove(void) +{ + unsigned int slot_index; + struct slot_obj_s *curr_slot; + + if (g_slot.slot) { + for (slot_index = g_slot.slot_number; slot_index > 0; slot_index--) { + curr_slot = &g_slot.slot[slot_index - 1]; + slotindex_curr_remove_kobj_and_attrs(curr_slot); + curr_slot->curr_number = 0; + } + } + return; +} +/**********************************end of slot current************************************/ +/*************************************slot voltage****************************************/ +static void slotindex_single_vol_remove_kobj_and_attrs(struct slot_obj_s *curr_slot, + unsigned int vol_index) +{ + struct slot_vol_obj_s *curr_vol; + + curr_vol = &curr_slot->vol[vol_index - 1]; + if (curr_vol->obj) { + sysfs_remove_group(&curr_vol->obj->kobj, &slot_vol_attr_group); + switch_kobject_delete(&curr_vol->obj); + SLOT_DBG("delete slot%u vol_sensor%u dir and attrs success.\n", curr_slot->obj->index, + vol_index); + } + return; +} + +static int slotindex_single_vol_create_kobj_and_attrs(struct slot_obj_s *curr_slot, + unsigned int vol_index) +{ + char name[DIR_NAME_MAX_LEN]; + struct slot_vol_obj_s *curr_vol; + + curr_vol = &curr_slot->vol[vol_index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "vol_sensor%u", vol_index); + curr_vol->obj = switch_kobject_create(name, &curr_slot->obj->kobj); + if (!curr_vol->obj) { + SLOT_ERR("create slot%u %s object error!\n", curr_slot->obj->index, name); + return -ENOMEM; + } + curr_vol->obj->index = vol_index; + if (sysfs_create_group(&curr_vol->obj->kobj, &slot_vol_attr_group) != 0) { + SLOT_ERR("create slot%u %s attrs error.\n", curr_slot->obj->index, name); + switch_kobject_delete(&curr_vol->obj); + return -EBADRQC; + } + SLOT_DBG("create slot%u %s success.\n", curr_slot->obj->index, name); + return 0; +} + +static void slotindex_vol_remove_kobj_and_attrs(struct slot_obj_s *curr_slot) +{ + unsigned int vol_index, vol_num; + + if (curr_slot->vol) { + vol_num = curr_slot->vol_number; + for (vol_index = vol_num; vol_index > 0; vol_index--) { + slotindex_single_vol_remove_kobj_and_attrs(curr_slot, vol_index); + } + kfree(curr_slot->vol); + curr_slot->vol = NULL; + } + return; +} + +static int slotindex_vol_create_kobj_and_attrs(struct slot_obj_s *curr_slot) +{ + unsigned int vol_index, i, vol_num; + + vol_num = curr_slot->vol_number; + curr_slot->vol = kzalloc(sizeof(struct slot_vol_obj_s) * vol_num, GFP_KERNEL); + if (!curr_slot->vol) { + SLOT_ERR("kzalloc slot vol error, slot index: %u, vol number: %u.\n", + curr_slot->obj->index, vol_num); + return -ENOMEM; + } + + for (vol_index = 1; vol_index <= vol_num; vol_index++) { + if (slotindex_single_vol_create_kobj_and_attrs(curr_slot, vol_index) != 0) { + goto error; + } + } + return 0; +error: + for (i = vol_index; i > 0; i--) { + slotindex_single_vol_remove_kobj_and_attrs(curr_slot, i); + } + kfree(curr_slot->vol); + curr_slot->vol = NULL; + return -EBADRQC; +} + +/* create slot vol_snesor[1-n] directory and attributes*/ +static int slot_vol_create(void) +{ + int vol_num; + unsigned int slot_index, i; + struct slot_obj_s *curr_slot; + + check_p(g_slot_drv->get_slot_vol_number); + for (slot_index = 1; slot_index <= g_slot.slot_number; slot_index++) { + vol_num = g_slot_drv->get_slot_vol_number(slot_index); + if (vol_num <= 0) { + SLOT_DBG("slot%u vol number: %d, don't need to create vol_sensor* dirs and attrs.\n", + slot_index, vol_num); + continue; + } + curr_slot = &g_slot.slot[slot_index - 1]; + curr_slot->vol_number = vol_num; + if (slotindex_vol_create_kobj_and_attrs(curr_slot) != 0) { + goto error; + } + } + return 0; +error: + for (i = slot_index; i > 0; i--) { + curr_slot = &g_slot.slot[i - 1]; + slotindex_vol_remove_kobj_and_attrs(curr_slot); + } + return -EBADRQC; +} + +/* delete slot vol_sensor[1-n] directory and attributes*/ +static void slot_vol_remove(void) +{ + unsigned int slot_index; + struct slot_obj_s *curr_slot; + + if (g_slot.slot) { + for (slot_index = g_slot.slot_number; slot_index > 0; slot_index--) { + curr_slot = &g_slot.slot[slot_index - 1]; + slotindex_vol_remove_kobj_and_attrs(curr_slot); + curr_slot->vol_number = 0; + } + } + return; +} +/**********************************end of slot voltage************************************/ +/***************************************slot temp*****************************************/ +static void slotindex_single_temp_remove_kobj_and_attrs(struct slot_obj_s *curr_slot, + unsigned int temp_index) +{ + struct slot_temp_obj_s *curr_temp; + + curr_temp = &curr_slot->temp[temp_index - 1]; + if (curr_temp->obj) { + sysfs_remove_group(&curr_temp->obj->kobj, &slot_temp_attr_group); + switch_kobject_delete(&curr_temp->obj); + SLOT_DBG("delete slot%u temp_sensor%u dir and attrs success.\n", curr_slot->obj->index, + temp_index); + } + return; +} + +static int slotindex_single_temp_create_kobj_and_attrs(struct slot_obj_s *curr_slot, + unsigned int temp_index) +{ + char name[DIR_NAME_MAX_LEN]; + struct slot_temp_obj_s *curr_temp; + + curr_temp = &curr_slot->temp[temp_index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "temp_sensor%u", temp_index); + curr_temp->obj = switch_kobject_create(name, &curr_slot->obj->kobj); + if (!curr_temp->obj) { + SLOT_ERR("create slot%u %s object error!\n", curr_slot->obj->index, name); + return -ENOMEM; + } + curr_temp->obj->index = temp_index; + if (sysfs_create_group(&curr_temp->obj->kobj, &slot_temp_attr_group) != 0) { + SLOT_ERR("create slot%u %s attrs error.\n", curr_slot->obj->index, name); + switch_kobject_delete(&curr_temp->obj); + return -EBADRQC; + } + SLOT_DBG("create slot%u %s success.\n", curr_slot->obj->index, name); + return 0; +} + +static void slotindex_temp_remove_kobj_and_attrs(struct slot_obj_s *curr_slot) +{ + unsigned int temp_index, temp_num; + + if (curr_slot->temp) { + temp_num = curr_slot->temp_number; + for (temp_index = temp_num; temp_index > 0; temp_index--) { + slotindex_single_temp_remove_kobj_and_attrs(curr_slot, temp_index); + } + kfree(curr_slot->temp); + curr_slot->temp = NULL; + } + return; +} + +static int slotindex_temp_create_kobj_and_attrs(struct slot_obj_s *curr_slot) +{ + unsigned int temp_index, i, temp_num; + + temp_num = curr_slot->temp_number; + curr_slot->temp = kzalloc(sizeof(struct slot_temp_obj_s) * temp_num, GFP_KERNEL); + if (!curr_slot->temp) { + SLOT_ERR("kzalloc slot temp error, slot index: %u, temp number: %u.\n", + curr_slot->obj->index, temp_num); + return -ENOMEM; + } + + for (temp_index = 1; temp_index <= temp_num; temp_index++) { + if (slotindex_single_temp_create_kobj_and_attrs(curr_slot, temp_index) != 0) { + goto error; + } + } + return 0; +error: + for (i = temp_index; i > 0; i--) { + slotindex_single_temp_remove_kobj_and_attrs(curr_slot, i); + } + kfree(curr_slot->temp); + curr_slot->temp = NULL; + return -EBADRQC; +} + +/* create slot temp_sensor[1-n] directory and attributes*/ +static int slot_temp_create(void) +{ + int temp_num; + unsigned int slot_index, i; + struct slot_obj_s *curr_slot; + + check_p(g_slot_drv->get_slot_temp_number); + for (slot_index = 1; slot_index <= g_slot.slot_number; slot_index++) { + temp_num = g_slot_drv->get_slot_temp_number(slot_index); + if (temp_num <= 0) { + SLOT_DBG("slot%u temp number: %d, don't need to create temp_sensor* dirs and attrs.\n", + slot_index, temp_num); + continue; + } + curr_slot = &g_slot.slot[slot_index - 1]; + curr_slot->temp_number = temp_num; + if (slotindex_temp_create_kobj_and_attrs(curr_slot) != 0) { + goto error; + } + } + return 0; +error: + for (i = slot_index; i > 0; i--) { + curr_slot = &g_slot.slot[i - 1]; + slotindex_temp_remove_kobj_and_attrs(curr_slot); + } + return -EBADRQC; +} + +/* delete slot temp_sensor[1-n] directory and attributes*/ +static void slot_temp_remove(void) +{ + unsigned int slot_index; + struct slot_obj_s *curr_slot; + + if (g_slot.slot) { + for (slot_index = g_slot.slot_number; slot_index > 0; slot_index--) { + curr_slot = &g_slot.slot[slot_index - 1]; + slotindex_temp_remove_kobj_and_attrs(curr_slot); + curr_slot->temp_number = 0; + } + } + return; +} +/************************************end of slot temp**************************************/ + +static int slot_child_obj_create(void) +{ + int ret; + + if (g_slot.slot_number <= 0) { + SLOT_DBG("slot number: %u, skip to create slot child dirs and attrs.\n", + g_slot.slot_number); + return 0; + } + /* temp create */ + ret = slot_temp_create(); + if (ret < 0) { + goto temp_err; + } + /* Voltage create */ + ret = slot_vol_create(); + if(ret < 0) { + goto vol_err; + } + /* current create */ + ret = slot_curr_create(); + if(ret < 0) { + goto curr_err; + } + /* fpga create */ + ret = slot_fpga_create(); + if(ret < 0) { + goto fpga_err; + } + /* cplf create */ + ret = slot_cpld_create(); + if(ret < 0) { + goto cpld_err; + } + return 0; +cpld_err: + slot_fpga_remove(); +fpga_err: + slot_curr_remove(); +curr_err: + slot_vol_remove(); +vol_err: + slot_temp_remove(); +temp_err: + return ret; +} + +static void slot_child_obj_remove(void) +{ + slot_cpld_remove(); + slot_fpga_remove(); + slot_curr_remove(); + slot_vol_remove(); + slot_temp_remove(); + return; +} + +static void slot_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct slot_obj_s *curr_slot; + + curr_slot = &g_slot.slot[index - 1]; + if (curr_slot->obj) { + sysfs_remove_group(&curr_slot->obj->kobj, &slot_attr_group); + switch_kobject_delete(&curr_slot->obj); + SLOT_DBG("delete slot%u dir and attrs success.\n", index); + } + + return; +} + +static int slot_sub_single_create_kobj_and_attrs(struct kobject *parent, unsigned int index) +{ + char name[DIR_NAME_MAX_LEN]; + struct slot_obj_s * curr_slot; + + curr_slot = &g_slot.slot[index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "slot%u", index); + curr_slot->obj = switch_kobject_create(name, parent); + if (!curr_slot->obj) { + SLOT_ERR("create %s object error!\n", name); + return -EBADRQC; + } + curr_slot->obj->index = index; + if (sysfs_create_group(&curr_slot->obj->kobj, &slot_attr_group) != 0) { + SLOT_ERR("create %s attrs error.\n", name); + switch_kobject_delete(&curr_slot->obj); + return -EBADRQC; + } + SLOT_DBG("create %s dir and attrs success.\n", name); + return 0; +} + +static int slot_sub_create_kobj_and_attrs(struct kobject *parent, int slot_num) +{ + unsigned int slot_index, i; + + g_slot.slot = kzalloc(sizeof(struct slot_obj_s) * slot_num, GFP_KERNEL); + if (!g_slot.slot) { + SLOT_ERR("kzalloc slot.slot error, slot number = %d.\n", slot_num); + return -ENOMEM; + } + + for(slot_index = 1; slot_index <= slot_num; slot_index++) { + if(slot_sub_single_create_kobj_and_attrs(parent, slot_index) != 0 ) { + goto error; + } + } + return 0; +error: + for(i = slot_index; i > 0; i--) { + slot_sub_single_remove_kobj_and_attrs(i); + } + kfree(g_slot.slot); + g_slot.slot = NULL; + return -EBADRQC; +} + +/* create slot[1-n] directory and attributes*/ +static int slot_sub_create(void) +{ + int ret; + + ret = slot_sub_create_kobj_and_attrs(&g_slot_obj->kobj, g_slot.slot_number); + return ret; +} + +/* delete slot[1-n] directory and attributes*/ +static void slot_sub_remove(void) +{ + unsigned int slot_index; + + if (g_slot.slot) { + for (slot_index = g_slot.slot_number; slot_index > 0; slot_index--) { + slot_sub_single_remove_kobj_and_attrs(slot_index); + } + kfree(g_slot.slot); + g_slot.slot = NULL; + } + g_slot.slot_number = 0; + return; +} + +/* create slot directory and number attributes*/ +static int slot_root_create(void) +{ + g_slot_obj = switch_kobject_create("slot", NULL); + if (!g_slot_obj) { + SLOT_ERR("switch_kobject_create slot error!\n"); + return -ENOMEM; + } + + if (sysfs_create_group(&g_slot_obj->kobj, &slot_root_attr_group) != 0) { + switch_kobject_delete(&g_slot_obj); + SLOT_ERR("create slot dir attrs error!\n"); + return -EBADRQC; + } + return 0; +} + +/* delete slot directory and number attributes*/ +static void slot_root_remove(void) +{ + if (g_slot_obj) { + sysfs_remove_group(&g_slot_obj->kobj, &slot_root_attr_group); + switch_kobject_delete(&g_slot_obj); + } + + return; +} + +int s3ip_sysfs_slot_drivers_register(struct s3ip_sysfs_slot_drivers_s *drv) +{ + int ret, slot_num; + + SLOT_INFO("s3ip_sysfs_slot_drivers_register...\n"); + if (g_slot_drv) { + SLOT_ERR("g_slot_drv is not NULL, can't register\n"); + return -EPERM; + } + + check_p(drv); + check_p(drv->get_slot_number); + g_slot_drv = drv; + + slot_num = g_slot_drv->get_slot_number(); + if (slot_num <= 0) { + SLOT_ERR("slot number: %d, don't need to create slot dirs and attrs.\n", slot_num); + g_slot_drv = NULL; + return -EINVAL; + } + + memset(&g_slot, 0, sizeof(struct slot_s)); + g_slot.slot_number = slot_num; + ret = slot_root_create(); + if (ret < 0) { + SLOT_ERR("create slot root dir and attrs failed, ret: %d\n", ret); + g_slot_drv = NULL; + return ret; + } + + ret = slot_sub_create(); + if (ret < 0) { + SLOT_ERR("create slot sub dir and attrs failed, ret: %d\n", ret); + slot_root_remove(); + g_slot_drv = NULL; + return ret; + } + + ret = slot_child_obj_create(); + if (ret < 0) { + SLOT_ERR("create slot child dir and attrs failed, ret: %d\n", ret); + slot_sub_remove(); + slot_root_remove(); + g_slot_drv = NULL; + return ret; + } + SLOT_INFO("s3ip_sysfs_slot_drivers_register success.\n"); + return 0; +} + +void s3ip_sysfs_slot_drivers_unregister(void) +{ + if (g_slot_drv) { + slot_child_obj_remove(); + slot_sub_remove(); + slot_root_remove(); + g_slot_drv = NULL; + SLOT_DBG("s3ip_sysfs_slot_drivers_unregister success.\n"); + } + return; +} + +EXPORT_SYMBOL(s3ip_sysfs_slot_drivers_register); +EXPORT_SYMBOL(s3ip_sysfs_slot_drivers_unregister); +module_param(g_slot_loglevel, int, 0644); +MODULE_PARM_DESC(g_slot_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); diff --git a/platform/s3ip-sysfs/s3ip_sysfs_frame/switch.c b/platform/s3ip-sysfs/s3ip_sysfs_frame/switch.c new file mode 100644 index 000000000000..6bd07cfa0c65 --- /dev/null +++ b/platform/s3ip-sysfs/s3ip_sysfs_frame/switch.c @@ -0,0 +1,270 @@ +/* + * switch.c + * + * This module create a kset in sysfs called /sys/s3ip + * Then other switch kobjects are created and assigned to this kset, + * such as "cpld", "fan", "psu", ... + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include "switch.h" +#include "syseeprom_sysfs.h" + +int g_switch_loglevel = 0; + +#define SWITCH_INFO(fmt, args...) do { \ + if (g_switch_loglevel & INFO) { \ + printk(KERN_INFO "[SWITCH][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define SWITCH_ERR(fmt, args...) do { \ + if (g_switch_loglevel & ERR) { \ + printk(KERN_ERR "[SWITCH][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define SWITCH_DBG(fmt, args...) do { \ + if (g_switch_loglevel & DBG) { \ + printk(KERN_DEBUG "[SWITCH][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +struct syseeprom_s { + struct bin_attribute bin; + int creat_eeprom_bin_flag; +}; + +static struct s3ip_sysfs_syseeprom_drivers_s *g_syseeprom_drv = NULL; +static struct kset *switch_kset; +static struct syseeprom_s g_syseeprom; + +static ssize_t switch_attr_show(struct kobject *kobj, struct attribute *attr, char *buf) +{ + struct switch_attribute *attribute; + struct switch_obj *device; + + attribute = to_switch_attr(attr); + device = to_switch_obj(kobj); + + if (!attribute->show) { + return -ENOSYS; + } + + return attribute->show(device, attribute, buf); +} + +static ssize_t switch_attr_store(struct kobject *kobj, struct attribute *attr, const char *buf, + size_t len) +{ + struct switch_attribute *attribute; + struct switch_obj *obj; + + attribute = to_switch_attr(attr); + obj = to_switch_obj(kobj); + + if (!attribute->store) { + return -ENOSYS; + } + + return attribute->store(obj, attribute, buf, len); +} + +static const struct sysfs_ops switch_sysfs_ops = { + .show = switch_attr_show, + .store = switch_attr_store, +}; + +static void switch_obj_release(struct kobject *kobj) +{ + struct switch_obj *obj; + + obj = to_switch_obj(kobj); + kfree(obj); + return; +} + +static struct kobj_type switch_ktype = { + .sysfs_ops = &switch_sysfs_ops, + .release = switch_obj_release, + .default_attrs = NULL, +}; + +static ssize_t syseeprom_read(struct file *filp, struct kobject *kobj, struct bin_attribute *attr, + char *buf, loff_t offset, size_t count) +{ + ssize_t rd_len; + + check_p(g_syseeprom_drv); + check_p(g_syseeprom_drv->read_syseeprom_data); + + memset(buf, 0, count); + rd_len = g_syseeprom_drv->read_syseeprom_data(buf, offset, count); + if (rd_len < 0) { + SWITCH_ERR("read syseeprom data error, offset: 0x%llx, read len: %lu, ret: %ld.\n", + offset, count, rd_len); + return -EIO; + } + SWITCH_DBG("read syseeprom data success, offset:0x%llx, read len:%lu, really read len:%ld.\n", + offset, count, rd_len); + return rd_len; +} + +static ssize_t syseeprom_write(struct file *filp, struct kobject *kobj, struct bin_attribute *attr, + char *buf, loff_t offset, size_t count) +{ + ssize_t wr_len; + + check_p(g_syseeprom_drv); + check_p(g_syseeprom_drv->write_syseeprom_data); + + wr_len = g_syseeprom_drv->write_syseeprom_data(buf, offset, count); + if (wr_len < 0) { + SWITCH_ERR("write syseeprom data error, offset: 0x%llx, read len: %lu, ret: %ld.\n", + offset, count, wr_len); + return -EIO; + } + SWITCH_DBG("write syseeprom data success, offset:0x%llx, write len:%lu, really write len:%ld.\n", + offset, count, wr_len); + return wr_len; +} + +static int syseeprom_create_eeprom_attrs(void) +{ + int ret, eeprom_size; + + eeprom_size = g_syseeprom_drv->get_syseeprom_size(); + if (eeprom_size <= 0) { + SWITCH_ERR("syseeprom size: %d, invalid.\n", eeprom_size); + return -EINVAL; + } + + sysfs_bin_attr_init(&g_syseeprom.bin); + g_syseeprom.bin.attr.name = "syseeprom"; + g_syseeprom.bin.attr.mode = 0644; + g_syseeprom.bin.read = syseeprom_read; + g_syseeprom.bin.write = syseeprom_write; + g_syseeprom.bin.size = eeprom_size; + + ret = sysfs_create_bin_file(&switch_kset->kobj, &g_syseeprom.bin); + if (ret) { + SWITCH_ERR("create syseeprom bin error, ret: %d. \n", ret); + return -EBADRQC; + } + SWITCH_DBG("create syseeprom bin file success, eeprom size:%d.\n", eeprom_size); + g_syseeprom.creat_eeprom_bin_flag = 1; + return 0; +} + +static void syseeprom_remove_eeprom_attrs(void) +{ + if (g_syseeprom.creat_eeprom_bin_flag) { + sysfs_remove_bin_file(&switch_kset->kobj, &g_syseeprom.bin); + g_syseeprom.creat_eeprom_bin_flag = 0; + } + + return; +} + +int s3ip_sysfs_syseeprom_drivers_register(struct s3ip_sysfs_syseeprom_drivers_s *drv) +{ + int ret; + + SWITCH_INFO("s3ip_sysfs_syseeprom_drivers_register...\n"); + if (g_syseeprom_drv) { + SWITCH_ERR("g_syseeprom_drv is not NULL, can't register\n"); + return -EPERM; + } + + check_p(drv); + check_p(drv->get_syseeprom_size); + g_syseeprom_drv = drv; + + ret = syseeprom_create_eeprom_attrs(); + if (ret < 0) { + SWITCH_ERR("create syseeprom attributes failed, ret: %d\n", ret); + g_syseeprom_drv = NULL; + return ret; + } + SWITCH_INFO("s3ip_sysfs_syseeprom_drivers_register success.\n"); + return 0; +} + +void s3ip_sysfs_syseeprom_drivers_unregister(void) +{ + if (g_syseeprom_drv) { + syseeprom_remove_eeprom_attrs(); + g_syseeprom_drv = NULL; + SWITCH_DBG("s3ip_sysfs_syseeprom_drivers_unregister success.\n"); + } + + return; +} + +struct switch_obj *switch_kobject_create(const char *name, struct kobject *parent) +{ + struct switch_obj *obj; + int ret; + + obj = kzalloc(sizeof(*obj), GFP_KERNEL); + if (!obj) { + SWITCH_DBG("switch_kobject_create %s kzalloc error", name); + return NULL; + } + + obj->kobj.kset = switch_kset; + + ret = kobject_init_and_add(&obj->kobj, &switch_ktype, parent, "%s", name); + if (ret) { + kobject_put(&obj->kobj); + SWITCH_DBG("kobject_init_and_add %s error", name); + return NULL; + } + + return obj; +} + +void switch_kobject_delete(struct switch_obj **obj) +{ + if (*obj) { + SWITCH_DBG("%s delete %s.\n", (*obj)->kobj.parent->name, (*obj)->kobj.name); + kobject_put(&((*obj)->kobj)); + *obj = NULL; + } +} + +static int __init switch_init(void) +{ + SWITCH_INFO("switch_init...\n"); + + switch_kset = kset_create_and_add("s3ip", NULL, NULL); + if (!switch_kset) { + SWITCH_ERR("create switch_kset error.\n"); + return -ENOMEM; + } + + SWITCH_INFO("switch_init success.\n"); + return 0; +} + +static void __exit switch_exit(void) +{ + if (switch_kset) { + kset_unregister(switch_kset); + } + + SWITCH_INFO("switch_exit success.\n"); +} + +module_init(switch_init); +module_exit(switch_exit); +EXPORT_SYMBOL(s3ip_sysfs_syseeprom_drivers_register); +EXPORT_SYMBOL(s3ip_sysfs_syseeprom_drivers_unregister); +module_param(g_switch_loglevel, int, 0644); +MODULE_PARM_DESC(g_switch_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_DESCRIPTION("switch driver"); diff --git a/platform/s3ip-sysfs/s3ip_sysfs_frame/sysled_sysfs.c b/platform/s3ip-sysfs/s3ip_sysfs_frame/sysled_sysfs.c new file mode 100644 index 000000000000..e42d40a755a2 --- /dev/null +++ b/platform/s3ip-sysfs/s3ip_sysfs_frame/sysled_sysfs.c @@ -0,0 +1,314 @@ +/* + * sysled_sysfs.c + * + * This module create sysled kobjects and attributes in /sys/s3ip/sysled + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "switch.h" +#include "sysled_sysfs.h" + +static int g_sysled_loglevel = 0; + +#define SYSLED_INFO(fmt, args...) do { \ + if (g_sysled_loglevel & INFO) { \ + printk(KERN_INFO "[SYSLED_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define SYSLED_ERR(fmt, args...) do { \ + if (g_sysled_loglevel & ERR) { \ + printk(KERN_ERR "[SYSLED_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define SYSLED_DBG(fmt, args...) do { \ + if (g_sysled_loglevel & DBG) { \ + printk(KERN_DEBUG "[SYSLED_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static struct switch_obj *g_sysled_obj = NULL; +static struct s3ip_sysfs_sysled_drivers_s *g_sysled_drv = NULL; + +static ssize_t sys_led_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + int ret; + + check_p(g_sysled_drv); + check_p(g_sysled_drv->get_sys_led_status); + + ret = g_sysled_drv->get_sys_led_status(buf, PAGE_SIZE); + if (ret < 0) { + SYSLED_ERR("get sys led status failed, ret: %d:\n", ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + SYSLED_DBG("get sys led status success:\n"); + return ret; +} + +static ssize_t sys_led_status_store(struct switch_obj *obj, struct switch_attribute *attr, + const char *buf, size_t count) +{ + int ret, value; + + check_p(g_sysled_drv); + check_p(g_sysled_drv->set_sys_led_status); + + sscanf(buf, "%d", &value); + if (value < 0) { + SYSLED_ERR("invaild led status value: %d, can't set sys led status\n", value); + return -EINVAL; + } + ret = g_sysled_drv->set_sys_led_status(value); + if (ret < 0) { + SYSLED_ERR("set sys led status %d faield, ret: %d\n", value, ret); + return -EIO; + } + SYSLED_DBG("set sys led status %d success\n", value); + return count; +} + +static ssize_t bmc_led_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + int ret; + + check_p(g_sysled_drv); + check_p(g_sysled_drv->get_bmc_led_status); + + ret = g_sysled_drv->get_bmc_led_status(buf, PAGE_SIZE); + if (ret < 0) { + SYSLED_ERR("get bmc led status failed, ret: %d:\n", ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + SYSLED_DBG("get bmc led status success:\n"); + return ret; +} + +static ssize_t bmc_led_status_store(struct switch_obj *obj, struct switch_attribute *attr, + const char *buf, size_t count) +{ + int ret, value; + + check_p(g_sysled_drv); + check_p(g_sysled_drv->set_bmc_led_status); + + sscanf(buf, "%d", &value); + if (value < 0) { + SYSLED_ERR("invaild led status value: %d, can't set bmc led status\n", value); + return -EINVAL; + } + ret = g_sysled_drv->set_bmc_led_status(value); + if (ret < 0) { + SYSLED_ERR("set bmc led status %d faield, ret: %d\n", value, ret); + return -EIO; + } + SYSLED_DBG("set bmc led status %d success\n", value); + return count; +} + +static ssize_t sys_fan_led_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + int ret; + + check_p(g_sysled_drv); + check_p(g_sysled_drv->get_sys_fan_led_status); + + ret = g_sysled_drv->get_sys_fan_led_status(buf, PAGE_SIZE); + if (ret < 0) { + SYSLED_ERR("get sys fan led status failed, ret: %d:\n", ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + SYSLED_DBG("get sys fan led status success:\n"); + return ret; +} + +static ssize_t sys_fan_led_status_store(struct switch_obj *obj, struct switch_attribute *attr, + const char *buf, size_t count) +{ + int ret, value; + + check_p(g_sysled_drv); + check_p(g_sysled_drv->set_sys_fan_led_status); + + sscanf(buf, "%d", &value); + if (value < 0) { + SYSLED_ERR("invaild led status value: %d, can't set sys fan led status\n", value); + return -EINVAL; + } + ret = g_sysled_drv->set_sys_fan_led_status(value); + if (ret < 0) { + SYSLED_ERR("set sys fan led status %d faield, ret: %d\n", value, ret); + return -EIO; + } + SYSLED_DBG("set sys fan led status %d success\n", value); + return count; +} + +static ssize_t sys_psu_led_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + int ret; + + check_p(g_sysled_drv); + check_p(g_sysled_drv->get_sys_psu_led_status); + + ret = g_sysled_drv->get_sys_psu_led_status(buf, PAGE_SIZE); + if (ret < 0) { + SYSLED_ERR("get sys psu led status failed, ret: %d:\n", ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + SYSLED_DBG("get sys psu led status success:\n"); + return ret; +} + +static ssize_t sys_psu_led_status_store(struct switch_obj *obj, struct switch_attribute *attr, + const char *buf, size_t count) +{ + int ret, value; + + check_p(g_sysled_drv); + check_p(g_sysled_drv->set_sys_psu_led_status); + + sscanf(buf, "%d", &value); + if (value < 0) { + SYSLED_ERR("invaild led status value: %d, can't set sys psu led status\n", value); + return -EINVAL; + } + ret = g_sysled_drv->set_sys_psu_led_status(value); + if (ret < 0) { + SYSLED_ERR("set sys psu led status %d faield, ret: %d\n", value, ret); + return -EIO; + } + SYSLED_DBG("set sys psu led status %d success\n", value); + return count; +} + +static ssize_t id_led_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + int ret; + + check_p(g_sysled_drv); + check_p(g_sysled_drv->get_id_led_status); + + ret = g_sysled_drv->get_id_led_status(buf, PAGE_SIZE); + if (ret < 0) { + SYSLED_ERR("get id led status failed, ret: %d:\n", ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + SYSLED_DBG("get id led status success:\n"); + return ret; +} + +static ssize_t id_led_status_store(struct switch_obj *obj, struct switch_attribute *attr, + const char *buf, size_t count) +{ + int ret, value; + + check_p(g_sysled_drv); + check_p(g_sysled_drv->set_id_led_status); + + sscanf(buf, "%d", &value); + if (value < 0) { + SYSLED_ERR("invaild led status value: %d, can't set id led status\n", value); + return -EINVAL; + } + ret = g_sysled_drv->set_id_led_status(value); + if (ret < 0) { + SYSLED_ERR("set id led status %d faield, ret: %d\n", value, ret); + return -EIO; + } + SYSLED_DBG("set id led status %d success\n", value); + return count; +} + +/************************************syseeprom dir and attrs*******************************************/ +static struct switch_attribute sys_led_attr = __ATTR(sys_led_status, S_IRUGO | S_IWUSR, sys_led_status_show, sys_led_status_store); +static struct switch_attribute bmc_led_attr = __ATTR(bmc_led_status, S_IRUGO | S_IWUSR, bmc_led_status_show, bmc_led_status_store); +static struct switch_attribute fan_led_attr = __ATTR(fan_led_status, S_IRUGO | S_IWUSR, sys_fan_led_status_show, sys_fan_led_status_store); +static struct switch_attribute psu_led_attr = __ATTR(psu_led_status, S_IRUGO | S_IWUSR, sys_psu_led_status_show, sys_psu_led_status_store); +static struct switch_attribute id_led_attr = __ATTR(id_led_status, S_IRUGO | S_IWUSR, id_led_status_show, id_led_status_store); + +static struct attribute *sysled_dir_attrs[] = { + &sys_led_attr.attr, + &bmc_led_attr.attr, + &fan_led_attr.attr, + &psu_led_attr.attr, + &id_led_attr.attr, + NULL, +}; + +static struct attribute_group sysled_attr_group = { + .attrs = sysled_dir_attrs, +}; + +/* create syseled directory and attributes*/ +static int sysled_root_create(void) +{ + g_sysled_obj = switch_kobject_create("sysled", NULL); + if (!g_sysled_obj) { + SYSLED_ERR("switch_kobject_create sysled error!\n"); + return -ENOMEM; + } + + if (sysfs_create_group(&g_sysled_obj->kobj, &sysled_attr_group) != 0) { + switch_kobject_delete(&g_sysled_obj); + SYSLED_ERR("create sysled dir attrs error!\n"); + return -EBADRQC; + } + + return 0; +} + +/* delete syseled directory and attributes*/ +static void sysled_root_remove(void) +{ + if (g_sysled_obj) { + sysfs_remove_group(&g_sysled_obj->kobj, &sysled_attr_group); + switch_kobject_delete(&g_sysled_obj); + } + + return; +} + +int s3ip_sysfs_sysled_drivers_register(struct s3ip_sysfs_sysled_drivers_s *drv) +{ + int ret; + + SYSLED_INFO("s3ip_sysfs_sysled_drivers_register...\n"); + if (g_sysled_drv) { + SYSLED_ERR("g_sysled_drv is not NULL, can't register\n"); + return -EPERM; + } + + check_p(drv); + g_sysled_drv = drv; + + ret = sysled_root_create(); + if (ret < 0) { + SYSLED_ERR("sysled create error.\n"); + g_sysled_drv = NULL; + return ret; + } + SYSLED_INFO("s3ip_sysfs_sysled_drivers_register success\n"); + return 0; +} + +void s3ip_sysfs_sysled_drivers_unregister(void) +{ + if (g_sysled_drv) { + sysled_root_remove(); + g_sysled_drv = NULL; + SYSLED_DBG("s3ip_sysfs_sysled_drivers_unregister success.\n"); + } + return; +} + +EXPORT_SYMBOL(s3ip_sysfs_sysled_drivers_register); +EXPORT_SYMBOL(s3ip_sysfs_sysled_drivers_unregister); +module_param(g_sysled_loglevel, int, 0644); +MODULE_PARM_DESC(g_sysled_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); diff --git a/platform/s3ip-sysfs/s3ip_sysfs_frame/temp_sensor_sysfs.c b/platform/s3ip-sysfs/s3ip_sysfs_frame/temp_sensor_sysfs.c new file mode 100644 index 000000000000..0e794dcf19ee --- /dev/null +++ b/platform/s3ip-sysfs/s3ip_sysfs_frame/temp_sensor_sysfs.c @@ -0,0 +1,392 @@ +/* + * temp_sensor_sysfs.c + * + * This module create temp sensor kobjects and attributes in /sys/s3ip/temp_sensor + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "switch.h" +#include "temp_sensor_sysfs.h" + +static int g_temp_sensor_loglevel = 0; + +#define TEMP_SENSOR_INFO(fmt, args...) do { \ + if (g_temp_sensor_loglevel & INFO) { \ + printk(KERN_INFO "[TEMP_SENSOR][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define TEMP_SENSOR_ERR(fmt, args...) do { \ + if (g_temp_sensor_loglevel & ERR) { \ + printk(KERN_ERR "[TEMP_SENSOR][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define TEMP_SENSOR_DBG(fmt, args...) do { \ + if (g_temp_sensor_loglevel & DBG) { \ + printk(KERN_DEBUG "[TEMP_SENSOR][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +struct temp_sensor_obj_s { + struct switch_obj *obj; +}; + +struct temp_sensor_s { + unsigned int temp_number; + struct temp_sensor_obj_s *temp; +}; + +static struct s3ip_sysfs_temp_sensor_drivers_s *g_temp_sensor_drv = NULL; +static struct temp_sensor_s g_temp_sensor; +static struct switch_obj *g_temp_sensor_obj = NULL; + +static ssize_t temp_sensor_number_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + return (ssize_t)snprintf(buf, PAGE_SIZE, "%u\n", g_temp_sensor.temp_number); +} + +static ssize_t temp_sensor_value_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int temp_index; + int ret; + + check_p(g_temp_sensor_drv); + check_p(g_temp_sensor_drv->get_main_board_temp_value); + + temp_index = obj->index; + TEMP_SENSOR_DBG("temp index: %u\n", temp_index); + ret = g_temp_sensor_drv->get_main_board_temp_value(temp_index, buf, PAGE_SIZE); + if (ret < 0) { + TEMP_SENSOR_ERR("get temp%u value failed, ret: %d\n", temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t temp_sensor_alias_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int temp_index; + int ret; + + check_p(g_temp_sensor_drv); + check_p(g_temp_sensor_drv->get_main_board_temp_alias); + + temp_index = obj->index; + TEMP_SENSOR_DBG("temp index: %u\n", temp_index); + ret = g_temp_sensor_drv->get_main_board_temp_alias(temp_index, buf, PAGE_SIZE); + if (ret < 0) { + TEMP_SENSOR_ERR("get temp%u alias failed, ret: %d\n", temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t temp_sensor_type_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int temp_index; + int ret; + + check_p(g_temp_sensor_drv); + check_p(g_temp_sensor_drv->get_main_board_temp_type); + + temp_index = obj->index; + TEMP_SENSOR_DBG("temp index: %u\n", temp_index); + ret = g_temp_sensor_drv->get_main_board_temp_type(temp_index, buf, PAGE_SIZE); + if (ret < 0) { + TEMP_SENSOR_ERR("get temp%u type failed, ret: %d\n", temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t temp_sensor_max_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int temp_index; + int ret; + + check_p(g_temp_sensor_drv); + check_p(g_temp_sensor_drv->get_main_board_temp_max); + + temp_index = obj->index; + TEMP_SENSOR_DBG("temp index: %u\n", temp_index); + ret = g_temp_sensor_drv->get_main_board_temp_max(temp_index, buf, PAGE_SIZE); + if (ret < 0) { + TEMP_SENSOR_ERR("get temp%u max threshold failed, ret: %d\n", temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t temp_sensor_max_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int temp_index; + int ret; + + check_p(g_temp_sensor_drv); + check_p(g_temp_sensor_drv->set_main_board_temp_max); + + temp_index = obj->index; + TEMP_SENSOR_DBG("temp index: %u\n", temp_index); + ret = g_temp_sensor_drv->set_main_board_temp_max(temp_index, buf, count); + if (ret < 0) { + TEMP_SENSOR_ERR("set temp%u max threshold failed, value: %s, count: %lu, ret: %d\n", + temp_index, buf, count, ret); + return -EIO; + } + TEMP_SENSOR_DBG("set temp%u max threshold success, value: %s, count: %lu, ret: %d\n", + temp_index, buf, count, ret); + return count; +} + +static ssize_t temp_sensor_min_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int temp_index; + int ret; + + check_p(g_temp_sensor_drv); + check_p(g_temp_sensor_drv->get_main_board_temp_min); + + temp_index = obj->index; + TEMP_SENSOR_DBG("temp index: %u\n", temp_index); + ret = g_temp_sensor_drv->get_main_board_temp_min(temp_index, buf, PAGE_SIZE); + if (ret < 0) { + TEMP_SENSOR_ERR("get temp%u min threshold failed, ret: %d\n", temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t temp_sensor_min_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int temp_index; + int ret; + + check_p(g_temp_sensor_drv); + check_p(g_temp_sensor_drv->set_main_board_temp_min); + + temp_index = obj->index; + TEMP_SENSOR_DBG("temp index: %u\n", temp_index); + ret = g_temp_sensor_drv->set_main_board_temp_min(temp_index, buf, count); + if (ret < 0) { + TEMP_SENSOR_ERR("set temp%u min threshold failed, value: %s, count: %lu, ret: %d\n", + temp_index, buf, count, ret); + return -EIO; + } + TEMP_SENSOR_DBG("set temp%u min threshold success, value: %s, count: %lu, ret: %d\n", + temp_index, buf, count, ret); + return count; +} + +/************************************temp_sensor dir and attrs*******************************************/ +static struct switch_attribute num_temp_att = __ATTR(number, S_IRUGO, temp_sensor_number_show, NULL); + +static struct attribute *temp_sensor_dir_attrs[] = { + &num_temp_att.attr, + NULL, +}; + +static struct attribute_group temp_sensor_root_attr_group = { + .attrs = temp_sensor_dir_attrs, +}; + +/*******************************temp1 temp2 dir and attrs*******************************************/ +static struct switch_attribute temp_value_attr = __ATTR(value, S_IRUGO, temp_sensor_value_show, NULL); +static struct switch_attribute temp_alias_attr = __ATTR(alias, S_IRUGO, temp_sensor_alias_show, NULL); +static struct switch_attribute temp_type_attr = __ATTR(type, S_IRUGO, temp_sensor_type_show, NULL); +static struct switch_attribute temp_max_attr = __ATTR(max, S_IRUGO | S_IWUSR, temp_sensor_max_show, temp_sensor_max_store); +static struct switch_attribute temp_min_attr = __ATTR(min, S_IRUGO | S_IWUSR, temp_sensor_min_show, temp_sensor_min_store); + +static struct attribute *temp_sensor_attrs[] = { + &temp_value_attr.attr, + &temp_alias_attr.attr, + &temp_type_attr.attr, + &temp_max_attr.attr, + &temp_min_attr.attr, + NULL, +}; + +static struct attribute_group temp_sensor_attr_group = { + .attrs = temp_sensor_attrs, +}; + +static int temp_sensor_sub_single_create_kobj_and_attrs(struct kobject *parent, unsigned int index) +{ + char name[DIR_NAME_MAX_LEN]; + struct temp_sensor_obj_s *temp_sensor; + + temp_sensor = &g_temp_sensor.temp[index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "temp%u", index); + temp_sensor->obj = switch_kobject_create(name, parent); + if (!temp_sensor->obj) { + TEMP_SENSOR_ERR("create %s object error.\n", name); + return -ENOMEM; + } + temp_sensor->obj->index = index; + if (sysfs_create_group(&temp_sensor->obj->kobj, &temp_sensor_attr_group) != 0) { + TEMP_SENSOR_ERR("create %s attrs error.\n", name); + switch_kobject_delete(&temp_sensor->obj); + return -EBADRQC; + } + TEMP_SENSOR_DBG("create %s dir and attrs success.\n", name); + return 0; +} + +static void temp_sensor_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct temp_sensor_obj_s *temp_sensor; + + temp_sensor = &g_temp_sensor.temp[index - 1]; + if (temp_sensor->obj) { + sysfs_remove_group(&temp_sensor->obj->kobj, &temp_sensor_attr_group); + switch_kobject_delete(&temp_sensor->obj); + TEMP_SENSOR_DBG("delete temp%u dir and attrs success.\n", index); + } + + return; +} + +static int temp_sensor_sub_create_kobj_and_attrs(struct kobject *parent, int temp_num) +{ + unsigned int temp_index, i; + + g_temp_sensor.temp = kzalloc(sizeof(struct temp_sensor_obj_s) * temp_num, GFP_KERNEL); + if (!g_temp_sensor.temp) { + TEMP_SENSOR_ERR("kzalloc g_temp_sensor.temp error, temp number: %d.\n", temp_num); + return -ENOMEM; + } + + for (temp_index = 1; temp_index <= temp_num; temp_index++) { + if (temp_sensor_sub_single_create_kobj_and_attrs(parent, temp_index) != 0) { + goto error; + } + } + return 0; +error: + for (i = temp_index; i > 0; i--) { + temp_sensor_sub_single_remove_kobj_and_attrs(i); + } + kfree(g_temp_sensor.temp); + g_temp_sensor.temp = NULL; + return -EBADRQC; +} + +/* create temp[1-n] directory and attributes*/ +static int temp_sensor_sub_create(void) +{ + int ret; + + ret = temp_sensor_sub_create_kobj_and_attrs(&g_temp_sensor_obj->kobj, + g_temp_sensor.temp_number); + return ret; +} + +/* delete temp[1-n] directory and attributes*/ +static void temp_sensor_sub_remove(void) +{ + unsigned int temp_index; + + if (g_temp_sensor.temp) { + for (temp_index = g_temp_sensor.temp_number; temp_index > 0; temp_index--) { + temp_sensor_sub_single_remove_kobj_and_attrs(temp_index); + } + kfree(g_temp_sensor.temp); + g_temp_sensor.temp = NULL; + } + + return; +} + +/* create temp_sensor directory and number attributes */ +static int temp_sensor_root_create(void) +{ + g_temp_sensor_obj = switch_kobject_create("temp_sensor", NULL); + if (!g_temp_sensor_obj) { + TEMP_SENSOR_ERR("switch_kobject_create temp_sensor error!\n"); + return -ENOMEM; + } + + if (sysfs_create_group(&g_temp_sensor_obj->kobj, &temp_sensor_root_attr_group) != 0) { + switch_kobject_delete(&g_temp_sensor_obj); + TEMP_SENSOR_ERR("create temp_sensor dir attrs error!\n"); + return -EBADRQC; + } + return 0; +} + +/* delete temp_sensor directory and number attributes */ +static void temp_sensor_root_remove(void) +{ + if (g_temp_sensor_obj) { + sysfs_remove_group(&g_temp_sensor_obj->kobj, &temp_sensor_root_attr_group); + switch_kobject_delete(&g_temp_sensor_obj); + } + + return; +} + +int s3ip_sysfs_temp_sensor_drivers_register(struct s3ip_sysfs_temp_sensor_drivers_s *drv) +{ + int ret, temp_num; + + TEMP_SENSOR_INFO("s3ip_sysfs_temp_sensor_drivers_register...\n"); + if (g_temp_sensor_drv) { + TEMP_SENSOR_ERR("g_temp_sensor_drv is not NULL, can't register\n"); + return -EPERM; + } + + check_p(drv); + check_p(drv->get_main_board_temp_number); + g_temp_sensor_drv = drv; + + temp_num = g_temp_sensor_drv->get_main_board_temp_number(); + if (temp_num <= 0) { + TEMP_SENSOR_ERR("temp sensor number: %d, don't need to create temp_sensor dirs and attrs.\n", + temp_num); + return -EINVAL; + } + memset(&g_temp_sensor, 0, sizeof(struct temp_sensor_s)); + g_temp_sensor.temp_number = temp_num; + ret = temp_sensor_root_create(); + if (ret < 0) { + TEMP_SENSOR_ERR("create temp_sensor root dir and attrs failed, ret: %d\n", ret); + g_temp_sensor_drv = NULL; + return ret; + } + + ret = temp_sensor_sub_create(); + if (ret < 0) { + TEMP_SENSOR_ERR("create temp_sensor sub dir and attrs failed, ret: %d\n", ret); + temp_sensor_root_remove(); + g_temp_sensor_drv = NULL; + return ret; + } + TEMP_SENSOR_INFO("s3ip_sysfs_temp_sensor_drivers_register success\n"); + return ret; +} + +void s3ip_sysfs_temp_sensor_drivers_unregister(void) +{ + if (g_temp_sensor_drv) { + temp_sensor_sub_remove(); + temp_sensor_root_remove(); + g_temp_sensor_drv = NULL; + TEMP_SENSOR_DBG("s3ip_sysfs_temp_sensor_drivers_unregister success.\n"); + } + return; +} + + +EXPORT_SYMBOL(s3ip_sysfs_temp_sensor_drivers_register); +EXPORT_SYMBOL(s3ip_sysfs_temp_sensor_drivers_unregister); +module_param(g_temp_sensor_loglevel, int, 0644); +MODULE_PARM_DESC(g_temp_sensor_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); diff --git a/platform/s3ip-sysfs/s3ip_sysfs_frame/transceiver_sysfs.c b/platform/s3ip-sysfs/s3ip_sysfs_frame/transceiver_sysfs.c new file mode 100644 index 000000000000..02ad4d7a8688 --- /dev/null +++ b/platform/s3ip-sysfs/s3ip_sysfs_frame/transceiver_sysfs.c @@ -0,0 +1,618 @@ +/* + * transceiver_sysfs.c + * + * This module create eth kobjects and attributes in /sys/s3ip/transceiver + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "switch.h" +#include "transceiver_sysfs.h" + +static int g_sff_loglevel = 0; + +#define SFF_INFO(fmt, args...) do { \ + if (g_sff_loglevel & INFO) { \ + printk(KERN_INFO "[SFF_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define SFF_ERR(fmt, args...) do { \ + if (g_sff_loglevel & ERR) { \ + printk(KERN_ERR "[SFF_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define SFF_DBG(fmt, args...) do { \ + if (g_sff_loglevel & DBG) { \ + printk(KERN_DEBUG "[SFF_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +struct sff_obj_s { + struct switch_obj *sff_obj; + struct bin_attribute bin; + int sff_creat_bin_flag; +}; + +struct sff_s { + unsigned int sff_number; + struct sff_obj_s *sff; +}; + +static struct sff_s g_sff; +static struct switch_obj *g_sff_obj = NULL; +static struct s3ip_sysfs_transceiver_drivers_s *g_sff_drv = NULL; + +static ssize_t transceiver_power_on_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + int ret; + + check_p(g_sff_drv); + check_p(g_sff_drv->get_transceiver_power_on_status); + + ret = g_sff_drv->get_transceiver_power_on_status(buf, PAGE_SIZE); + if (ret < 0) { + SFF_ERR("get transceiver power on status failed, ret: %d\n", ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t transceiver_power_on_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + int ret, value; + + check_p(g_sff_drv); + check_p(g_sff_drv->set_transceiver_power_on_status); + + sscanf(buf, "%d", &value); + if (value < 0 || value > 1) { + SFF_ERR("invalid value: %d, can't set transceiver power on status.\n", value); + return -EINVAL; + } + + ret = g_sff_drv->set_transceiver_power_on_status(value); + if (ret < 0) { + SFF_ERR("set transceiver power on status %d failed, ret: %d\n", value, ret); + return -EIO; + } + return count; +} + +static ssize_t eth_power_on_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int eth_index; + int ret; + + check_p(g_sff_drv); + check_p(g_sff_drv->get_eth_power_on_status); + + eth_index = obj->index; + SFF_DBG("eth index: %u\n", eth_index); + ret = g_sff_drv->get_eth_power_on_status(eth_index, buf, PAGE_SIZE); + if (ret < 0) { + SFF_ERR("get eth%u power on status failed, ret: %d\n", eth_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t eth_power_on_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int eth_index; + int ret, value; + + check_p(g_sff_drv); + check_p(g_sff_drv->set_eth_power_on_status); + + sscanf(buf, "%d", &value); + eth_index = obj->index; + if (value < 0 || value > 1) { + SFF_ERR("invalid value: %d, can't set eth%u power on status.\n", value, eth_index); + return -EINVAL; + } + + ret = g_sff_drv->set_eth_power_on_status(eth_index, value); + if (ret < 0) { + SFF_ERR("set eth%u power on status %d failed, ret: %d\n", eth_index, value, ret); + return -EIO; + } + SFF_DBG("set eth%u power on status %d success\n", eth_index, value); + return count; +} + +static ssize_t eth_tx_fault_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int eth_index; + int ret; + + check_p(g_sff_drv); + check_p(g_sff_drv->get_eth_tx_fault_status); + + eth_index = obj->index; + SFF_DBG("eth index: %u\n", eth_index); + ret = g_sff_drv->get_eth_tx_fault_status(eth_index, buf, PAGE_SIZE); + if (ret < 0) { + SFF_ERR("get eth%u tx fault status failed, ret: %d\n", eth_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t eth_tx_disable_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int eth_index; + int ret; + + check_p(g_sff_drv); + check_p(g_sff_drv->get_eth_tx_disable_status); + + eth_index = obj->index; + SFF_DBG("eth index: %u\n", eth_index); + ret = g_sff_drv->get_eth_tx_disable_status(eth_index, buf, PAGE_SIZE); + if (ret < 0) { + SFF_ERR("get eth%u tx disable status failed, ret: %d\n", eth_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t eth_tx_disable_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int eth_index; + int ret, value; + + check_p(g_sff_drv); + check_p(g_sff_drv->set_eth_tx_disable_status); + + sscanf(buf, "%d", &value); + eth_index = obj->index; + if (value < 0 || value > 1) { + SFF_ERR("invalid value: %d, can't set eth%u tx disable status.\n", value, eth_index); + return -EINVAL; + } + + ret = g_sff_drv->set_eth_tx_disable_status(eth_index, value); + if (ret < 0) { + SFF_ERR("set eth%u tx disable status %d failed, ret: %d\n", eth_index, value, ret); + return -EIO; + } + SFF_DBG("set eth%u tx disable status %d success\n", eth_index, value); + return count; +} + +static ssize_t eth_present_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int eth_index; + int ret; + + check_p(g_sff_drv); + check_p(g_sff_drv->get_eth_present_status); + + eth_index = obj->index; + SFF_DBG("eth index: %u\n", eth_index); + ret = g_sff_drv->get_eth_present_status(eth_index, buf, PAGE_SIZE); + if (ret < 0) { + SFF_ERR("get eth%u present status failed, ret: %d\n", eth_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t eth_rx_los_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int eth_index; + int ret; + + check_p(g_sff_drv); + check_p(g_sff_drv->get_eth_rx_los_status); + + eth_index = obj->index; + SFF_DBG("eth index: %u\n", eth_index); + ret = g_sff_drv->get_eth_rx_los_status(eth_index, buf, PAGE_SIZE); + if (ret < 0) { + SFF_ERR("get eth%u rx los status failed, ret: %d\n", eth_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t eth_reset_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int eth_index; + int ret; + + check_p(g_sff_drv); + check_p(g_sff_drv->get_eth_reset_status); + + eth_index = obj->index; + SFF_DBG("eth index: %u\n", eth_index); + ret = g_sff_drv->get_eth_reset_status(eth_index, buf, PAGE_SIZE); + if (ret < 0) { + SFF_ERR("get eth%u reset status failed, ret: %d\n", eth_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t eth_reset_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int eth_index; + int ret, value; + + check_p(g_sff_drv); + check_p(g_sff_drv->set_eth_reset_status); + + sscanf(buf, "%d", &value); + eth_index = obj->index; + if (value < 0 || value > 1) { + SFF_ERR("invalid value: %d, can't set eth%u reset status.\n", value, eth_index); + return -EINVAL; + } + + ret = g_sff_drv->set_eth_reset_status(eth_index, value); + if (ret < 0) { + SFF_ERR("set eth%u reset status %d failed, ret: %d\n", eth_index, value, ret); + return -EIO; + } + SFF_DBG("set eth%u reset status %d success\n", eth_index, value); + return count; +} + +static ssize_t eth_low_power_mode_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int eth_index; + int ret; + + check_p(g_sff_drv); + check_p(g_sff_drv->get_eth_low_power_mode_status); + + eth_index = obj->index; + SFF_DBG("eth index: %u\n", eth_index); + ret = g_sff_drv->get_eth_low_power_mode_status(eth_index, buf, PAGE_SIZE); + if (ret < 0) { + SFF_ERR("get eth%u low power mode status failed, ret: %d\n", eth_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t eth_interrupt_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int eth_index; + int ret; + + check_p(g_sff_drv); + check_p(g_sff_drv->get_eth_interrupt_status); + + eth_index = obj->index; + SFF_DBG("eth index: %u\n", eth_index); + ret = g_sff_drv->get_eth_interrupt_status(eth_index, buf, PAGE_SIZE); + if (ret < 0) { + SFF_ERR("get eth%u interrupt status failed, ret: %d\n", eth_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t eth_eeprom_read(struct file *filp, struct kobject *kobj, struct bin_attribute *attr, + char *buf, loff_t offset, size_t count) +{ + struct switch_obj *eth_obj; + ssize_t rd_len; + unsigned int eth_index; + + check_p(g_sff_drv); + check_p(g_sff_drv->read_eth_eeprom_data); + + eth_obj = to_switch_obj(kobj); + eth_index = eth_obj->index; + memset(buf, 0, count); + rd_len = g_sff_drv->read_eth_eeprom_data(eth_index, buf, offset, count); + if (rd_len < 0) { + SFF_ERR("read eth%u eeprom data error, offset: 0x%llx, read len: %lu, ret: %ld.\n", + eth_index, offset, count, rd_len); + return -EIO; + } + + SFF_DBG("read eth%u eeprom data success, offset:0x%llx, read len:%lu, really read len:%ld.\n", + eth_index, offset, count, rd_len); + + return rd_len; +} + +static ssize_t eth_eeprom_write(struct file *filp, struct kobject *kobj, struct bin_attribute *attr, + char *buf, loff_t offset, size_t count) +{ + struct switch_obj *eth_obj; + ssize_t wr_len; + unsigned int eth_index; + + check_p(g_sff_drv); + check_p(g_sff_drv->write_eth_eeprom_data); + + eth_obj = to_switch_obj(kobj); + eth_index = eth_obj->index; + wr_len = g_sff_drv->write_eth_eeprom_data(eth_index, buf, offset, count); + if (wr_len < 0) { + SFF_ERR("write eth%u eeprom data error, offset: 0x%llx, read len: %lu, ret: %ld.\n", + eth_index, offset, count, wr_len); + return -EIO; + } + + SFF_DBG("write eth%u eeprom data success, offset:0x%llx, write len:%lu, really write len:%ld.\n", + eth_index, offset, count, wr_len); + + return wr_len; +} + +/************************************eth* signal attrs*******************************************/ +static struct switch_attribute eth_power_on_attr = __ATTR(power_on, S_IRUGO | S_IWUSR, eth_power_on_show, eth_power_on_store); +static struct switch_attribute eth_tx_fault_attr = __ATTR(tx_fault, S_IRUGO, eth_tx_fault_show, NULL); +static struct switch_attribute eth_tx_disable_attr = __ATTR(tx_disable, S_IRUGO | S_IWUSR, eth_tx_disable_show, eth_tx_disable_store); +static struct switch_attribute eth_present_attr = __ATTR(present, S_IRUGO, eth_present_show, NULL); +static struct switch_attribute eth_rx_los_attr = __ATTR(rx_los, S_IRUGO, eth_rx_los_show, NULL); +static struct switch_attribute eth_reset_attr = __ATTR(reset, S_IRUGO | S_IWUSR, eth_reset_show, eth_reset_store); +static struct switch_attribute eth_low_power_mode_attr = __ATTR(low_power_mode, S_IRUGO, eth_low_power_mode_show, NULL); +static struct switch_attribute eth_interrupt_attr = __ATTR(interrupt, S_IRUGO, eth_interrupt_show, NULL); + +static struct attribute *sff_signal_attrs[] = { + ð_power_on_attr.attr, + ð_tx_fault_attr.attr, + ð_tx_disable_attr.attr, + ð_present_attr.attr, + ð_rx_los_attr.attr, + ð_reset_attr.attr, + ð_low_power_mode_attr.attr, + ð_interrupt_attr.attr, + NULL, +}; + +static struct attribute_group sff_signal_attr_group = { + .attrs = sff_signal_attrs, +}; + +/*******************************transceiver dir and attrs*******************************************/ +static struct switch_attribute transceiver_power_on_attr = __ATTR(power_on, S_IRUGO | S_IWUSR, transceiver_power_on_show, transceiver_power_on_store); + +static struct attribute *transceiver_dir_attrs[] = { + &transceiver_power_on_attr.attr, + NULL, +}; + +static struct attribute_group sff_transceiver_attr_group = { + .attrs = transceiver_dir_attrs, +}; + +/* create eth* eeprom attributes */ +static int sff_sub_single_create_eeprom_attrs(unsigned int index) +{ + int ret, eeprom_size; + struct sff_obj_s *curr_sff; + + check_p(g_sff_drv->get_eth_eeprom_size); + eeprom_size = g_sff_drv->get_eth_eeprom_size(index); + if (eeprom_size <= 0) { + SFF_INFO("eth%u, eeprom_size: %d, don't need to creat eeprom attr.\n", + index, eeprom_size); + return 0; + } + + curr_sff = &g_sff.sff[index - 1]; + sysfs_bin_attr_init(&curr_sff->bin); + curr_sff->bin.attr.name = "eeprom"; + curr_sff->bin.attr.mode = 0644; + curr_sff->bin.read = eth_eeprom_read; + curr_sff->bin.write = eth_eeprom_write; + curr_sff->bin.size = eeprom_size; + + ret = sysfs_create_bin_file(&curr_sff->sff_obj->kobj, &curr_sff->bin); + if (ret) { + SFF_ERR("eth%u, create eeprom bin error, ret: %d. \n", index, ret); + return -EBADRQC; + } + + SFF_DBG("eth%u, create bin file success, eeprom size:%d.\n", index, eeprom_size); + curr_sff->sff_creat_bin_flag = 1; + return 0; +} + +static int sff_sub_single_create_kobj(struct kobject *parent, unsigned int index) +{ + struct sff_obj_s *curr_sff; + char sff_dir_name[DIR_NAME_MAX_LEN]; + + curr_sff = &g_sff.sff[index - 1]; + memset(sff_dir_name, 0, sizeof(sff_dir_name)); + snprintf(sff_dir_name, sizeof(sff_dir_name), "eth%d", index); + curr_sff->sff_obj = switch_kobject_create(sff_dir_name, parent); + if (!curr_sff->sff_obj) { + SFF_ERR("create eth%d object error! \n", index); + return -EBADRQC; + } + curr_sff->sff_obj->index = index; + if (sysfs_create_group(&curr_sff->sff_obj->kobj, &sff_signal_attr_group) != 0) { + switch_kobject_delete(&curr_sff->sff_obj); + return -EBADRQC; + } + + SFF_DBG("create eth%d dir and attrs success\n", index); + return 0; +} + +/* remove eth directory and attributes */ +static void sff_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct sff_obj_s *curr_sff; + + curr_sff = &g_sff.sff[index - 1]; + if (curr_sff->sff_obj) { + if (curr_sff->sff_creat_bin_flag) { + sysfs_remove_bin_file(&curr_sff->sff_obj->kobj, &curr_sff->bin); + curr_sff->sff_creat_bin_flag = 0; + } + sysfs_remove_group(&curr_sff->sff_obj->kobj, &sff_signal_attr_group); + switch_kobject_delete(&curr_sff->sff_obj); + } + + return; +} + +static int sff_sub_single_create_kobj_and_attrs(struct kobject *parent, unsigned int index) +{ + int ret; + + ret = sff_sub_single_create_kobj(parent, index); + if (ret < 0) { + SFF_ERR("create eth%d dir error.\n", index); + return ret; + } + + sff_sub_single_create_eeprom_attrs(index); + return 0; +} + +static int sff_sub_create_kobj_and_attrs(struct kobject *parent, int sff_num) +{ + unsigned int sff_index, i; + + g_sff.sff = kzalloc(sizeof(struct sff_obj_s) * sff_num, GFP_KERNEL); + if (!g_sff.sff) { + SFF_ERR("kzalloc g_sff.sff error, sff number = %d.\n", sff_num); + return -ENOMEM; + } + + for (sff_index = 1; sff_index <= sff_num; sff_index++) { + if (sff_sub_single_create_kobj_and_attrs(parent, sff_index) != 0 ) { + goto error; + } + } + return 0; +error: + for (i = sff_index; i > 0; i--) { + sff_sub_single_remove_kobj_and_attrs(i); + } + kfree(g_sff.sff); + g_sff.sff = NULL; + return -EBADRQC; +} + +/* create eth directory and attributes */ +static int sff_sub_create(void) +{ + int ret; + + ret = sff_sub_create_kobj_and_attrs(&g_sff_obj->kobj, g_sff.sff_number); + return ret; +} + +/* delete eth directory and attributes */ +static void sff_sub_remove(void) +{ + unsigned int sff_index; + + if (g_sff.sff) { + for (sff_index = g_sff.sff_number; sff_index > 0; sff_index--) { + sff_sub_single_remove_kobj_and_attrs(sff_index); + } + kfree(g_sff.sff); + g_sff.sff = NULL; + } + g_sff.sff_number = 0; + return; +} + +/* create transceiver directory and attributes */ +static int sff_transceiver_create(void) +{ + g_sff_obj = switch_kobject_create("transceiver", NULL); + if (!g_sff_obj) { + SFF_ERR("switch_kobject_create transceiver error!\n"); + return -ENOMEM; + } + g_sff_obj->index = 0; + if (sysfs_create_group(&g_sff_obj->kobj, &sff_transceiver_attr_group) != 0) { + switch_kobject_delete(&g_sff_obj); + SFF_ERR("create transceiver dir attrs error!\n"); + return -EBADRQC; + } + return 0; +} + +/* delete transceiver directory and attributes */ +static void sff_transceiver_remove(void) +{ + if (g_sff_obj) { + sysfs_remove_group(&g_sff_obj->kobj, &sff_transceiver_attr_group); + switch_kobject_delete(&g_sff_obj); + } + + return; +} + +int s3ip_sysfs_sff_drivers_register(struct s3ip_sysfs_transceiver_drivers_s *drv) +{ + int ret, sff_num; + + SFF_INFO("s3ip_sysfs_sff_drivers_register...\n"); + if (g_sff_drv) { + SFF_ERR("g_sff_drv is not NULL, can't register\n"); + return -EPERM; + } + + check_p(drv); + check_p(drv->get_eth_number); + g_sff_drv = drv; + + sff_num = g_sff_drv->get_eth_number(); + if (sff_num <= 0) { + SFF_ERR("eth number: %d, don't need to create transceiver dirs and attrs.\n", sff_num); + g_sff_drv = NULL; + return -EINVAL; + } + + memset(&g_sff, 0, sizeof(struct sff_s)); + g_sff.sff_number = sff_num; + ret = sff_transceiver_create(); + if (ret < 0) { + SFF_ERR("create transceiver root dir and attrs failed, ret: %d\n", ret); + g_sff_drv = NULL; + return ret; + } + ret = sff_sub_create(); + if (ret < 0) { + SFF_ERR("create transceiver sub dir and attrs failed, ret: %d\n", ret); + sff_transceiver_remove(); + g_sff_drv = NULL; + return ret; + } + SFF_INFO("s3ip_sysfs_sff_drivers_register success\n"); + return ret; +} + +void s3ip_sysfs_sff_drivers_unregister(void) +{ + if (g_sff_drv) { + sff_sub_remove(); + sff_transceiver_remove(); + g_sff_drv = NULL; + SFF_DBG("s3ip_sysfs_sff_drivers_unregister success.\n"); + } + return; +} + +EXPORT_SYMBOL(s3ip_sysfs_sff_drivers_register); +EXPORT_SYMBOL(s3ip_sysfs_sff_drivers_unregister); +module_param(g_sff_loglevel, int, 0644); +MODULE_PARM_DESC(g_sff_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); diff --git a/platform/s3ip-sysfs/s3ip_sysfs_frame/vol_sensor_sysfs.c b/platform/s3ip-sysfs/s3ip_sysfs_frame/vol_sensor_sysfs.c new file mode 100644 index 000000000000..41e21512f0de --- /dev/null +++ b/platform/s3ip-sysfs/s3ip_sysfs_frame/vol_sensor_sysfs.c @@ -0,0 +1,434 @@ +/* + * vol_sensor_sysfs.c + * + * This module create vol sensor kobjects and attributes in /sys/s3ip/vol_sensor + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "switch.h" +#include "vol_sensor_sysfs.h" + +static int g_vol_sensor_loglevel = 0; + +#define VOL_SENSOR_INFO(fmt, args...) do { \ + if (g_vol_sensor_loglevel & INFO) { \ + printk(KERN_INFO "[VOL_SENSOR][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define VOL_SENSOR_ERR(fmt, args...) do { \ + if (g_vol_sensor_loglevel & ERR) { \ + printk(KERN_ERR "[VOL_SENSOR][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define VOL_SENSOR_DBG(fmt, args...) do { \ + if (g_vol_sensor_loglevel & DBG) { \ + printk(KERN_DEBUG "[VOL_SENSOR][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +struct vol_sensor_obj_s { + struct switch_obj *obj; +}; + +struct vol_sensor_s { + unsigned int vol_number; + struct vol_sensor_obj_s *vol; +}; + +static struct s3ip_sysfs_vol_sensor_drivers_s *g_vol_sensor_drv = NULL; +static struct vol_sensor_s g_vol_sensor; +static struct switch_obj *g_vol_sensor_obj = NULL; + +static ssize_t vol_sensor_number_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + return (ssize_t)snprintf(buf, PAGE_SIZE, "%u\n", g_vol_sensor.vol_number); +} + +static ssize_t vol_sensor_value_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int vol_index; + int ret; + + check_p(g_vol_sensor_drv); + check_p(g_vol_sensor_drv->get_main_board_vol_value); + + vol_index = obj->index; + VOL_SENSOR_DBG("vol index: %u\n", vol_index); + ret = g_vol_sensor_drv->get_main_board_vol_value(vol_index, buf, PAGE_SIZE); + if (ret < 0) { + VOL_SENSOR_ERR("get vol%u value failed, ret: %d\n", vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t vol_sensor_alias_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int vol_index; + int ret; + + check_p(g_vol_sensor_drv); + check_p(g_vol_sensor_drv->get_main_board_vol_alias); + + vol_index = obj->index; + VOL_SENSOR_DBG("vol index: %u\n", vol_index); + ret = g_vol_sensor_drv->get_main_board_vol_alias(vol_index, buf, PAGE_SIZE); + if (ret < 0) { + VOL_SENSOR_ERR("get vol%u alias failed, ret: %d\n", vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t vol_sensor_type_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int vol_index; + int ret; + + check_p(g_vol_sensor_drv); + check_p(g_vol_sensor_drv->get_main_board_vol_type); + + vol_index = obj->index; + VOL_SENSOR_DBG("vol index: %u\n", vol_index); + ret = g_vol_sensor_drv->get_main_board_vol_type(vol_index, buf, PAGE_SIZE); + if (ret < 0) { + VOL_SENSOR_ERR("get vol%u type failed, ret: %d\n", vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t vol_sensor_max_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int vol_index; + int ret; + + check_p(g_vol_sensor_drv); + check_p(g_vol_sensor_drv->get_main_board_vol_max); + + vol_index = obj->index; + VOL_SENSOR_DBG("vol index: %u\n", vol_index); + ret = g_vol_sensor_drv->get_main_board_vol_max(vol_index, buf, PAGE_SIZE); + if (ret < 0) { + VOL_SENSOR_ERR("get vol%u max threshold failed, ret: %d\n", vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t vol_sensor_max_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int vol_index; + int ret; + + check_p(g_vol_sensor_drv); + check_p(g_vol_sensor_drv->set_main_board_vol_max); + + vol_index = obj->index; + VOL_SENSOR_DBG("vol index: %u\n", vol_index); + ret = g_vol_sensor_drv->set_main_board_vol_max(vol_index, buf, count); + if (ret < 0) { + VOL_SENSOR_ERR("set vol%u max threshold failed, value: %s, count: %lu, ret: %d\n", + vol_index, buf, count, ret); + return -EIO; + } + VOL_SENSOR_DBG("set vol%u max threshold success, value: %s, count: %lu, ret: %d\n", + vol_index, buf, count, ret); + return count; +} + +static ssize_t vol_sensor_min_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int vol_index; + int ret; + + check_p(g_vol_sensor_drv); + check_p(g_vol_sensor_drv->get_main_board_vol_min); + + vol_index = obj->index; + VOL_SENSOR_DBG("vol index: %u\n", vol_index); + ret = g_vol_sensor_drv->get_main_board_vol_min(vol_index, buf, PAGE_SIZE); + if (ret < 0) { + VOL_SENSOR_ERR("get vol%u min threshold failed, ret: %d\n", vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t vol_sensor_min_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int vol_index; + int ret; + + check_p(g_vol_sensor_drv); + check_p(g_vol_sensor_drv->set_main_board_vol_min); + + vol_index = obj->index; + VOL_SENSOR_DBG("vol index: %u\n", vol_index); + ret = g_vol_sensor_drv->set_main_board_vol_min(vol_index, buf, count); + if (ret < 0) { + VOL_SENSOR_ERR("set vol%u min threshold failed, value: %s, count: %lu, ret: %d\n", + vol_index, buf, count, ret); + return -EIO; + } + VOL_SENSOR_DBG("set vol%u min threshold success, value: %s, count: %lu, ret: %d\n", + vol_index, buf, count, ret); + return count; +} + +static ssize_t vol_sensor_range_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int vol_index; + int ret; + + check_p(g_vol_sensor_drv); + check_p(g_vol_sensor_drv->get_main_board_vol_range); + + vol_index = obj->index; + VOL_SENSOR_DBG("vol index: %u\n", vol_index); + ret = g_vol_sensor_drv->get_main_board_vol_range(vol_index, buf, PAGE_SIZE); + if (ret < 0) { + VOL_SENSOR_ERR("get vol%u range failed, ret: %d\n", vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t vol_sensor_nominal_value_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int vol_index; + int ret; + + check_p(g_vol_sensor_drv); + check_p(g_vol_sensor_drv->get_main_board_vol_nominal_value); + + vol_index = obj->index; + VOL_SENSOR_DBG("vol index: %u\n", vol_index); + ret = g_vol_sensor_drv->get_main_board_vol_nominal_value(vol_index, buf, PAGE_SIZE); + if (ret < 0) { + VOL_SENSOR_ERR("get vol%u nominal value failed, ret: %d\n", vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +/************************************vol_sensor dir and attrs*******************************************/ +static struct switch_attribute num_vol_att = __ATTR(number, S_IRUGO, vol_sensor_number_show, NULL); + +static struct attribute *vol_sensor_dir_attrs[] = { + &num_vol_att.attr, + NULL, +}; + +static struct attribute_group vol_sensor_root_attr_group = { + .attrs = vol_sensor_dir_attrs, +}; + +/*******************************vol1 vol2 dir and attrs*******************************************/ +static struct switch_attribute vol_value_attr = __ATTR(value, S_IRUGO, vol_sensor_value_show, NULL); +static struct switch_attribute vol_alias_attr = __ATTR(alias, S_IRUGO, vol_sensor_alias_show, NULL); +static struct switch_attribute vol_type_attr = __ATTR(type, S_IRUGO, vol_sensor_type_show, NULL); +static struct switch_attribute vol_max_attr = __ATTR(max, S_IRUGO | S_IWUSR, vol_sensor_max_show, vol_sensor_max_store); +static struct switch_attribute vol_min_attr = __ATTR(min, S_IRUGO | S_IWUSR, vol_sensor_min_show, vol_sensor_min_store); +static struct switch_attribute vol_range_attr = __ATTR(range, S_IRUGO, vol_sensor_range_show, NULL); +static struct switch_attribute vol_nominal_value_attr = __ATTR(nominal_value, S_IRUGO, vol_sensor_nominal_value_show, NULL); + + +static struct attribute *vol_sensor_attrs[] = { + &vol_value_attr.attr, + &vol_alias_attr.attr, + &vol_type_attr.attr, + &vol_max_attr.attr, + &vol_min_attr.attr, + &vol_range_attr.attr, + &vol_nominal_value_attr.attr, + NULL, +}; + +static struct attribute_group vol_sensor_attr_group = { + .attrs = vol_sensor_attrs, +}; + +static int vol_sensor_sub_single_create_kobj_and_attrs(struct kobject *parent, unsigned int index) +{ + char name[DIR_NAME_MAX_LEN]; + struct vol_sensor_obj_s *vol_sensor; + + vol_sensor = &g_vol_sensor.vol[index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "vol%u", index); + vol_sensor->obj = switch_kobject_create(name, parent); + if (!vol_sensor->obj) { + VOL_SENSOR_ERR("create %s object error.\n", name); + return -ENOMEM; + } + + vol_sensor->obj->index = index; + if (sysfs_create_group(&vol_sensor->obj->kobj, &vol_sensor_attr_group) != 0) { + VOL_SENSOR_ERR("create %s attrs error.\n", name); + switch_kobject_delete(&vol_sensor->obj); + return -EBADRQC; + } + VOL_SENSOR_DBG("create %s dir and attrs success.\n", name); + + return 0; +} + +static void vol_sensor_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct vol_sensor_obj_s *vol_sensor; + + vol_sensor = &g_vol_sensor.vol[index - 1]; + if (vol_sensor->obj) { + sysfs_remove_group(&vol_sensor->obj->kobj, &vol_sensor_attr_group); + switch_kobject_delete(&vol_sensor->obj); + VOL_SENSOR_DBG("delete vol%u dir and attrs success.\n", index); + } + + return; +} + +static int vol_sensor_sub_create_kobj_and_attrs(struct kobject *parent, int vol_num) +{ + unsigned int vol_index, i; + + g_vol_sensor.vol = kzalloc(sizeof(struct vol_sensor_obj_s) * vol_num, GFP_KERNEL); + if (!g_vol_sensor.vol) { + VOL_SENSOR_ERR("kzalloc g_vol_sensor.vol error, vol number: %d.\n", vol_num); + return -ENOMEM; + } + + for (vol_index = 1; vol_index <= vol_num; vol_index++) { + if (vol_sensor_sub_single_create_kobj_and_attrs(parent, vol_index) != 0) { + goto error; + } + } + return 0; +error: + for (i = vol_index; i > 0; i--) { + vol_sensor_sub_single_remove_kobj_and_attrs(i); + } + kfree(g_vol_sensor.vol); + g_vol_sensor.vol = NULL; + return -EBADRQC; +} + +/* create vol[1-n] directory and attributes*/ +static int vol_sensor_sub_create(void) +{ + int ret; + + ret = vol_sensor_sub_create_kobj_and_attrs(&g_vol_sensor_obj->kobj, g_vol_sensor.vol_number); + return ret; +} + +/* delete vol[1-n] directory and attributes*/ +static void vol_sensor_sub_remove(void) +{ + unsigned int vol_index; + + if (g_vol_sensor.vol) { + for (vol_index = g_vol_sensor.vol_number; vol_index > 0; vol_index--) { + vol_sensor_sub_single_remove_kobj_and_attrs(vol_index); + } + kfree(g_vol_sensor.vol); + g_vol_sensor.vol = NULL; + } + + return; +} + +/* create vol_sensor directory and number attributes */ +static int vol_sensor_root_create(void) +{ + g_vol_sensor_obj = switch_kobject_create("vol_sensor", NULL); + if (!g_vol_sensor_obj) { + VOL_SENSOR_ERR("switch_kobject_create vol_sensor error!\n"); + return -ENOMEM; + } + + if (sysfs_create_group(&g_vol_sensor_obj->kobj, &vol_sensor_root_attr_group) != 0) { + switch_kobject_delete(&g_vol_sensor_obj); + VOL_SENSOR_ERR("create vol_sensor dir attrs error!\n"); + return -EBADRQC; + } + + return 0; +} + +/* delete vol_sensor directory and number attributes */ +static void vol_sensor_root_remove(void) +{ + if (g_vol_sensor_obj) { + sysfs_remove_group(&g_vol_sensor_obj->kobj, &vol_sensor_root_attr_group); + switch_kobject_delete(&g_vol_sensor_obj); + } + + return; +} + +int s3ip_sysfs_vol_sensor_drivers_register(struct s3ip_sysfs_vol_sensor_drivers_s *drv) +{ + int ret, vol_num; + + VOL_SENSOR_INFO("s3ip_sysfs_vol_sensor_drivers_register...\n"); + if (g_vol_sensor_drv) { + VOL_SENSOR_ERR("g_vol_sensor_drv is not NULL, can't register\n"); + return -EPERM; + } + + check_p(drv); + check_p(drv->get_main_board_vol_number); + g_vol_sensor_drv = drv; + + vol_num = g_vol_sensor_drv->get_main_board_vol_number(); + if (vol_num <= 0) { + VOL_SENSOR_ERR("vol sensor number: %d, don't need to create vol_sensor dirs and attrs.\n", + vol_num); + return -EINVAL; + } + memset(&g_vol_sensor, 0, sizeof(struct vol_sensor_s)); + g_vol_sensor.vol_number = vol_num; + ret = vol_sensor_root_create(); + if (ret < 0) { + VOL_SENSOR_ERR("create vol_sensor root dir and attrs failed, ret: %d\n", ret); + g_vol_sensor_drv = NULL; + return ret; + } + + ret = vol_sensor_sub_create(); + if (ret < 0) { + VOL_SENSOR_ERR("create vol_sensor sub dir and attrs failed, ret: %d\n", ret); + vol_sensor_root_remove(); + g_vol_sensor_drv = NULL; + return ret; + } + VOL_SENSOR_INFO("s3ip_sysfs_vol_sensor_drivers_register success\n"); + return ret; +} + +void s3ip_sysfs_vol_sensor_drivers_unregister(void) +{ + if (g_vol_sensor_drv) { + vol_sensor_sub_remove(); + vol_sensor_root_remove(); + g_vol_sensor_drv = NULL; + VOL_SENSOR_DBG("s3ip_sysfs_vol_sensor_drivers_unregister success.\n"); + } + return; +} + +EXPORT_SYMBOL(s3ip_sysfs_vol_sensor_drivers_register); +EXPORT_SYMBOL(s3ip_sysfs_vol_sensor_drivers_unregister); +module_param(g_vol_sensor_loglevel, int, 0644); +MODULE_PARM_DESC(g_vol_sensor_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); diff --git a/platform/s3ip-sysfs/s3ip_sysfs_frame/watchdog_sysfs.c b/platform/s3ip-sysfs/s3ip_sysfs_frame/watchdog_sysfs.c new file mode 100755 index 000000000000..4487d5d19ac7 --- /dev/null +++ b/platform/s3ip-sysfs/s3ip_sysfs_frame/watchdog_sysfs.c @@ -0,0 +1,263 @@ +/* + * watchdog_sysfs.c + * + * This module create watchdog kobjects and attributes in /sys/s3ip/watchdog + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "switch.h" +#include "watchdog_sysfs.h" + +static int g_wdt_loglevel = 0; + +#define WDT_INFO(fmt, args...) do { \ + if (g_wdt_loglevel & INFO) { \ + printk(KERN_INFO "[WDT_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define WDT_ERR(fmt, args...) do { \ + if (g_wdt_loglevel & ERR) { \ + printk(KERN_ERR "[WDT_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define WDT_DBG(fmt, args...) do { \ + if (g_wdt_loglevel & DBG) { \ + printk(KERN_DEBUG "[WDT_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +typedef enum wdt_enable_status_e { + WDT_DISENABLE = 0, /* close watchdog */ + WDT_ENABLE = 1, /* open watchdog */ +} wdt_enable_status_t; + +static struct switch_obj *g_watchdog_obj = NULL; +static struct s3ip_sysfs_watchdog_drivers_s *g_wdt_drv = NULL; + +static ssize_t watchdog_identify_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + int ret; + + check_p(g_wdt_drv); + check_p(g_wdt_drv->get_watchdog_identify); + + ret = g_wdt_drv->get_watchdog_identify(buf, PAGE_SIZE); + if (ret < 0) { + WDT_ERR("get watchdog identify failed, ret: %d\n", ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + WDT_DBG("get watchdog identify success\n"); + return ret; +} + +static ssize_t watchdog_timeleft_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + int ret; + + check_p(g_wdt_drv); + check_p(g_wdt_drv->get_watchdog_timeleft); + + ret = g_wdt_drv->get_watchdog_timeleft(buf, PAGE_SIZE); + if (ret < 0) { + WDT_ERR("get watchdog timeleft failed, ret: %d\n", ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + WDT_DBG("get watchdog timeleft success\n"); + return ret; +} + +static ssize_t watchdog_timeout_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + int ret; + + check_p(g_wdt_drv); + check_p(g_wdt_drv->get_watchdog_timeout); + + ret = g_wdt_drv->get_watchdog_timeout(buf, PAGE_SIZE); + if (ret < 0) { + WDT_ERR("get watchdog timeout failed, ret: %d\n", ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + WDT_DBG("get watchdog timeout success\n"); + return ret; +} + +static ssize_t watchdog_timeout_store(struct switch_obj *obj, struct switch_attribute *attr, + const char *buf, size_t count) +{ + int ret, value; + + check_p(g_wdt_drv); + check_p(g_wdt_drv->set_watchdog_timeout); + + sscanf(buf, "%d", &value); + if (value < 0) { + WDT_ERR("invaild timeout value: %d, can't set watchdog timeout\n", value); + return -EINVAL; + } + + ret = g_wdt_drv->set_watchdog_timeout(value); + if (ret < 0) { + WDT_ERR("set watchdog timeout value: %d failed, ret: %d\n", value, ret); + return -EIO; + } + WDT_DBG("set watchdog timeout value: %d success\n", ret); + return count; +} + +static ssize_t watchdog_enable_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + int ret; + + check_p(g_wdt_drv); + check_p(g_wdt_drv->get_watchdog_enable_status); + + ret = g_wdt_drv->get_watchdog_enable_status(buf, PAGE_SIZE); + if (ret < 0) { + WDT_ERR("get watchdog enable status failed, ret: %d\n", ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + WDT_DBG("get watchdog enable status success\n"); + return ret; +} + +static ssize_t watchdog_enable_status_store(struct switch_obj *obj, struct switch_attribute *attr, + const char *buf, size_t count) +{ + int ret, value; + + check_p(g_wdt_drv); + check_p(g_wdt_drv->set_watchdog_enable_status); + + sscanf(buf, "%d", &value); + if ((value != WDT_DISENABLE) && (value != WDT_ENABLE)) { + WDT_ERR("invaild enable value: %d, can't set watchdog enable status\n", value); + return -EINVAL; + } + + ret = g_wdt_drv->set_watchdog_enable_status(value); + if (ret < 0) { + WDT_ERR("set watchdog enable status %d failed, ret: %d\n", value, ret); + return -EIO; + } + WDT_DBG("set watchdog enable status %d success\n", ret); + return count; +} + +static ssize_t watchdog_reset_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + int ret, value; + + check_p(g_wdt_drv); + check_p(g_wdt_drv->set_watchdog_reset); + + ret = kstrtoint(buf, 0, &value); + if (ret) { + WDT_ERR("invalid value: %s \n", buf); + return -EINVAL; + } + + ret = g_wdt_drv->set_watchdog_reset(value); + if (ret < 0) { + WDT_ERR("set watchdog reset %d failed, ret: %d\n", value, ret); + return -EIO; + } + WDT_DBG("set watchdog reset %d success\n", ret); + return count; +} + +/************************************watchdog*******************************************/ +static struct switch_attribute watchdog_identify_attr = __ATTR(identify, S_IRUGO, watchdog_identify_show, NULL); +static struct switch_attribute watchdog_timeleft_attr = __ATTR(timeleft, S_IRUGO, watchdog_timeleft_show, NULL); +static struct switch_attribute watchdog_timeout_attr = __ATTR(timeout, S_IRUGO | S_IWUSR, watchdog_timeout_show, watchdog_timeout_store); +static struct switch_attribute watchdog_enable_attr = __ATTR(enable, S_IRUGO | S_IWUSR, watchdog_enable_status_show, watchdog_enable_status_store); +static struct switch_attribute watchdog_reset_attr = __ATTR(reset, S_IWUSR, NULL, watchdog_reset_store); + +static struct attribute *watchdog_dir_attrs[] = { + &watchdog_identify_attr.attr, + &watchdog_timeleft_attr.attr, + &watchdog_timeout_attr.attr, + &watchdog_enable_attr.attr, + &watchdog_reset_attr.attr, + NULL, +}; + +static struct attribute_group watchdog_attr_group = { + .attrs = watchdog_dir_attrs, +}; + +/* create watchdog directory and attributes */ +static int watchdog_root_create(void) +{ + g_watchdog_obj = switch_kobject_create("watchdog", NULL); + if (!g_watchdog_obj) { + WDT_ERR("switch_kobject_create watchdog error!\n"); + return -ENOMEM; + } + + if (sysfs_create_group(&g_watchdog_obj->kobj, &watchdog_attr_group) != 0) { + switch_kobject_delete(&g_watchdog_obj); + WDT_ERR("create fan dir attrs error!\n"); + return -EBADRQC; + } + + return 0; +} + +/* delete watchdog directory and attributes */ +static void watchdog_root_remove(void) +{ + if (g_watchdog_obj) { + sysfs_remove_group(&g_watchdog_obj->kobj, &watchdog_attr_group); + switch_kobject_delete(&g_watchdog_obj); + } + + return; +} + +int s3ip_sysfs_watchdog_drivers_register(struct s3ip_sysfs_watchdog_drivers_s *drv) +{ + int ret; + + WDT_INFO("s3ip_sysfs_watchdog_drivers_register...\n"); + if (g_wdt_drv) { + WDT_ERR("g_wdt_drv is not NULL, can't register\n"); + return -EPERM; + } + + check_p(drv); + g_wdt_drv = drv; + + ret = watchdog_root_create(); + if (ret < 0) { + WDT_ERR("watchdog create error.\n"); + g_wdt_drv = NULL; + return ret; + } + WDT_INFO("s3ip_sysfs_watchdog_drivers_register success\n"); + return 0; +} + +void s3ip_sysfs_watchdog_drivers_unregister(void) +{ + if (g_wdt_drv) { + watchdog_root_remove(); + g_wdt_drv = NULL; + WDT_DBG("s3ip_sysfs_watchdog_drivers_unregister success.\n"); + } + + return; +} + +EXPORT_SYMBOL(s3ip_sysfs_watchdog_drivers_register); +EXPORT_SYMBOL(s3ip_sysfs_watchdog_drivers_unregister); +module_param(g_wdt_loglevel, int, 0644); +MODULE_PARM_DESC(g_wdt_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); diff --git a/platform/s3ip-sysfs/scripts/s3ip-sysfs.service b/platform/s3ip-sysfs/scripts/s3ip-sysfs.service new file mode 100644 index 000000000000..2446df59d7a5 --- /dev/null +++ b/platform/s3ip-sysfs/scripts/s3ip-sysfs.service @@ -0,0 +1,15 @@ +[Unit] +Description=s3ip sysfs service +Wants=network-online.target +After=network-online.target + +[Service] +Type=oneshot +User=root +ExecStart=/usr/bin/s3ip_sysfs_tool.sh start +ExecStop=/usr/bin/s3ip_sysfs_tool.sh stop +RemainAfterExit=yes + +[Install] +WantedBy=default.target + diff --git a/platform/s3ip-sysfs/scripts/s3ip_load.py b/platform/s3ip-sysfs/scripts/s3ip_load.py new file mode 100755 index 000000000000..38ae5fb000a6 --- /dev/null +++ b/platform/s3ip-sysfs/scripts/s3ip_load.py @@ -0,0 +1,32 @@ +#!/usr/bin/python +# -*- coding: UTF-8 -*- +import json +import os + +if __name__ == '__main__': + os.system("sudo rm -rf /sys_switch;sudo mkdir -p -m 777 /sys_switch") + + with open('/etc/s3ip/s3ip_sysfs_conf.json', 'r') as jsonfile: + json_string = json.load(jsonfile) + for s3ip_sysfs_path in json_string['s3ip_syfs_paths']: + #print('path:' + s3ip_sysfs_path['path']) + #print('type:' + s3ip_sysfs_path['type']) + #print('value:' + s3ip_sysfs_path['value']) + + if s3ip_sysfs_path['type'] == "string" : + (path, file) = os.path.split(s3ip_sysfs_path['path']) + #创建文件 + command = "sudo mkdir -p -m 777 " + path + #print(command) + os.system(command) + command = "sudo echo " + "\"" + s3ip_sysfs_path['value'] + "\"" + " > " + s3ip_sysfs_path['path'] + #print(command) + os.system(command) + elif s3ip_sysfs_path['type'] == "path" : + command = "sudo ln -s " + s3ip_sysfs_path['value'] + " " + s3ip_sysfs_path['path'] + #print(command) + os.system(command) + else: + print('error type:' + s3ip_sysfs_path['type']) + os.system("tree -l /sys_switch") + diff --git a/platform/s3ip-sysfs/scripts/s3ip_sysfs_conf.json b/platform/s3ip-sysfs/scripts/s3ip_sysfs_conf.json new file mode 100644 index 000000000000..fc72263c5197 --- /dev/null +++ b/platform/s3ip-sysfs/scripts/s3ip_sysfs_conf.json @@ -0,0 +1,76 @@ +{ + "s3ip_syfs_paths": [ + { + "path": "/sys_switch/temp_sensor", + "type" : "path", + "value" : "/sys/s3ip/temp_sensor", + "description": "temperature information" + }, + { + "path": "/sys_switch/vol_sensor", + "type" : "path", + "value" : "/sys/s3ip/vol_sensor", + "description": "voltage sensor information" + }, + { + "path": "/sys_switch/syseeprom", + "type" : "path", + "value" : "/sys/s3ip/syseeprom", + "description": "ONIE EEPROM" + }, + { + "path": "/sys_switch/fan", + "type" : "path", + "value" : "/sys/s3ip/fan", + "description": "fan information" + }, + { + "path": "/sys_switch/psu", + "type" : "path", + "value" : "/sys/s3ip/psu", + "description": "PSU information" + }, + { + "path": "/sys_switch/transceiver", + "type" : "path", + "value" : "/sys/s3ip/transceiver", + "description": "transceiver information" + }, + { + "path": "/sys_switch/sysled", + "type" : "path", + "value" : "/sys/s3ip/sysled", + "description": "SYS LED information" + }, + { + "path": "/sys_switch/fpga", + "type" : "path", + "value" : "/sys/s3ip/fpga", + "description": "FPGA information" + }, + { + "path": "/sys_switch/cpld", + "type" : "path", + "value" : "/sys/s3ip/cpld", + "description": "CPLD information" + }, + { + "path": "/sys_switch/watchdog", + "type" : "path", + "value" : "/sys/s3ip/watchdog", + "description": "watchdog information" + }, + { + "path": "/sys_switch/curr_sensor", + "type" : "path", + "value" : "/sys/s3ip/curr_sensor", + "description": "current sensor information" + }, + { + "path": "/sys_switch/slot", + "type" : "path", + "value" : "/sys/s3ip/slot", + "description": "slot information" + } + ] +} diff --git a/platform/s3ip-sysfs/scripts/s3ip_sysfs_tool.sh b/platform/s3ip-sysfs/scripts/s3ip_sysfs_tool.sh new file mode 100755 index 000000000000..ed65f0d1d9e8 --- /dev/null +++ b/platform/s3ip-sysfs/scripts/s3ip_sysfs_tool.sh @@ -0,0 +1,59 @@ +#! /bin/bash + +s3ip_start(){ + sudo insmod /lib/modules/s3ip/s3ip_sysfs.ko + sudo insmod /lib/modules/s3ip/syseeprom_device_driver.ko + sudo insmod /lib/modules/s3ip/fan_device_driver.ko + sudo insmod /lib/modules/s3ip/cpld_device_driver.ko + sudo insmod /lib/modules/s3ip/sysled_device_driver.ko + sudo insmod /lib/modules/s3ip/psu_device_driver.ko + sudo insmod /lib/modules/s3ip/transceiver_device_driver.ko + sudo insmod /lib/modules/s3ip/temp_sensor_device_driver.ko + sudo insmod /lib/modules/s3ip/vol_sensor_device_driver.ko + sudo insmod /lib/modules/s3ip/fpga_device_driver.ko + sudo insmod /lib/modules/s3ip/watchdog_device_driver.ko + sudo insmod /lib/modules/s3ip/curr_sensor_device_driver.ko + sudo insmod /lib/modules/s3ip/slot_device_driver.ko + sudo rm -rf /sys_switch + sudo /usr/bin/s3ip_load.py + echo "s3ip service start" +} +s3ip_stop(){ + sudo rmmod slot_device_driver + sudo rmmod curr_sensor_device_driver + sudo rmmod watchdog_device_driver + sudo rmmod fpga_device_driver + sudo rmmod vol_sensor_device_driver + sudo rmmod temp_sensor_device_driver + sudo rmmod transceiver_device_driver + sudo rmmod psu_device_driver + sudo rmmod sysled_device_driver + sudo rmmod cpld_device_driver + sudo rmmod fan_device_driver + sudo rmmod syseeprom_device_driver + sudo rmmod s3ip_sysfs + sudo rm -rf /sys_switch + echo "s3ip service stop" + +} + +case "$1" in + start) + s3ip_start + ;; + stop) + s3ip_stop + ;; + status) + sudo tree -l /sys_switch + ;; + restart) + s3ip_stop + s3ip_start + ;; + *) + echo "Usage: $0 {start|stop|status|restart}" + exit 1 +esac +exit + diff --git a/platform/vs/docker-gbsyncd-vs/Dockerfile.j2 b/platform/vs/docker-gbsyncd-vs/Dockerfile.j2 index 4dd9abf49ee7..7e5219f5512e 100644 --- a/platform/vs/docker-gbsyncd-vs/Dockerfile.j2 +++ b/platform/vs/docker-gbsyncd-vs/Dockerfile.j2 @@ -2,8 +2,6 @@ FROM docker-config-engine-bullseye-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} ARG docker_container_name -RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf - ## Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive diff --git a/platform/vs/docker-sonic-vs/Dockerfile.j2 b/platform/vs/docker-sonic-vs/Dockerfile.j2 index 7585b7f6f6e3..56180b51b1c3 100644 --- a/platform/vs/docker-sonic-vs/Dockerfile.j2 +++ b/platform/vs/docker-sonic-vs/Dockerfile.j2 @@ -1,6 +1,7 @@ FROM docker-config-engine-buster-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} ARG docker_container_name +COPY ["etc/rsyslog.conf", "/etc/rsyslog.conf"] RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf ## Make apt-get non-interactive diff --git a/dockers/docker-base-bullseye/etc/rsyslog.conf b/platform/vs/docker-sonic-vs/etc/rsyslog.conf similarity index 99% rename from dockers/docker-base-bullseye/etc/rsyslog.conf rename to platform/vs/docker-sonic-vs/etc/rsyslog.conf index ef249229ab1e..aa638f77dbef 100644 --- a/dockers/docker-base-bullseye/etc/rsyslog.conf +++ b/platform/vs/docker-sonic-vs/etc/rsyslog.conf @@ -73,4 +73,4 @@ $RepeatedMsgReduction on ############### #### RULES #### -############### +############### \ No newline at end of file diff --git a/platform/vs/docker-syncd-vs/Dockerfile.j2 b/platform/vs/docker-syncd-vs/Dockerfile.j2 index dd6bc2d0f71e..27506903b7f4 100644 --- a/platform/vs/docker-syncd-vs/Dockerfile.j2 +++ b/platform/vs/docker-syncd-vs/Dockerfile.j2 @@ -2,8 +2,6 @@ FROM docker-config-engine-buster-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} ARG docker_container_name -RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf - ## Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive diff --git a/platform/vs/sonic-version.mk b/platform/vs/sonic-version.mk index 9e21573227b3..82409abd1ec1 100644 --- a/platform/vs/sonic-version.mk +++ b/platform/vs/sonic-version.mk @@ -2,9 +2,11 @@ sonic_version=$(SONIC_GET_VERSION) sonic_asic_platform=$(CONFIGURED_PLATFORM) +sonic_os_version=$(SONIC_OS_VERSION) export sonic_version export sonic_asic_platform +export sonic_os_version SONIC_VERSION = sonic_version.yml $(SONIC_VERSION)_SRC_PATH = $(PLATFORM_PATH)/sonic-version diff --git a/rules/config b/rules/config index 0391abff36bd..d3e345cd46a6 100644 --- a/rules/config +++ b/rules/config @@ -139,7 +139,7 @@ INCLUDE_MGMT_FRAMEWORK = y # ENABLE_HOST_SERVICE_ON_START - enable sonic-host-server for mgmt-framework and/or # telemetry containers to access host functionality by default -ENABLE_HOST_SERVICE_ON_START = n +ENABLE_HOST_SERVICE_ON_START = y # INCLUDE_RESTAPI - build docker-sonic-restapi for configuring the switch using REST APIs INCLUDE_RESTAPI = n @@ -160,12 +160,22 @@ ENABLE_AUTO_TECH_SUPPORT = y # Uncomment to enable: # ENABLE_TRANSLIB_WRITE = y +# ENABLE_NATIVE_WRITE - Enable native write/config operations via the gNMI interface. +# Uncomment to enable: +# ENABLE_NATIVE_WRITE = y + # INCLUDE_MACSEC - build docker-macsec for macsec support INCLUDE_MACSEC = y +# INCLUDE_TEAMD - build docker-teamd for LAG protocol support +INCLUDE_TEAMD ?= y + +# INCLUDE_ROUTER_ADVERTISER - build docker-router-advertiser for router advertisements support +INCLUDE_ROUTER_ADVERTISER ?= y + # INCLUDE_KUBERNETES - if set to y kubernetes packages are installed to be able to # run as worker node in kubernetes cluster. -INCLUDE_KUBERNETES = n +INCLUDE_KUBERNETES ?= n KUBE_DOCKER_PROXY = http://172.16.1.1:3128/ @@ -225,6 +235,9 @@ TRUSTED_GPG_URLS = https://packages.trafficmanager.net/debian/public_key.gpg,htt # docker: docker base images SONIC_VERSION_CONTROL_COMPONENTS ?= none +# MIRROR_SNAPSHOT - support mirror snapshot flag +MIRROR_SNAPSHOT ?= n + # SONiC docker registry # # Set the env variable ENABLE_DOCKER_BASE_PULL = y to enable pulling sonic-slave docker from registry @@ -256,3 +269,6 @@ ENABLE_FIPS ?= n # SONIC_SLAVE_DOCKER_DRIVER - set the sonic slave docker storage driver SONIC_SLAVE_DOCKER_DRIVER ?= vfs + +# SONIC_OS_VERSION - sonic os version +SONIC_OS_VERSION ?= 11 diff --git a/rules/docker-config-engine-bullseye.mk b/rules/docker-config-engine-bullseye.mk index ea0ae43b54b9..9548391a6917 100644 --- a/rules/docker-config-engine-bullseye.mk +++ b/rules/docker-config-engine-bullseye.mk @@ -11,8 +11,9 @@ $(DOCKER_CONFIG_ENGINE_BULLSEYE)_DEPENDS += $(LIBSWSSCOMMON) \ $(SONIC_DB_CLI) \ $(SONIC_EVENTD) $(DOCKER_CONFIG_ENGINE_BULLSEYE)_PYTHON_WHEELS += $(SONIC_PY_COMMON_PY3) \ - $(SONIC_YANG_MGMT_PY3) \ - $(SONIC_YANG_MODELS_PY3) + $(SONIC_YANG_MGMT_PY3) \ + $(SONIC_YANG_MODELS_PY3) \ + $(SONIC_CONTAINERCFGD) $(DOCKER_CONFIG_ENGINE_BULLSEYE)_PYTHON_WHEELS += $(SONIC_CONFIG_ENGINE_PY3) $(DOCKER_CONFIG_ENGINE_BULLSEYE)_LOAD_DOCKERS += $(DOCKER_BASE_BULLSEYE) $(DOCKER_CONFIG_ENGINE_BULLSEYE)_FILES += $(SWSS_VARS_TEMPLATE) diff --git a/rules/docker-config-engine-buster.mk b/rules/docker-config-engine-buster.mk index 38a94bae4c1d..cd6d6f43b46d 100644 --- a/rules/docker-config-engine-buster.mk +++ b/rules/docker-config-engine-buster.mk @@ -11,7 +11,8 @@ $(DOCKER_CONFIG_ENGINE_BUSTER)_DEPENDS += $(LIBSWSSCOMMON) \ $(SONIC_DB_CLI) $(DOCKER_CONFIG_ENGINE_BUSTER)_PYTHON_WHEELS += $(SONIC_PY_COMMON_PY3) \ $(SONIC_YANG_MGMT_PY3) \ - $(SONIC_YANG_MODELS_PY3) + $(SONIC_YANG_MODELS_PY3) \ + $(SONIC_CONTAINERCFGD) $(DOCKER_CONFIG_ENGINE_BUSTER)_PYTHON_WHEELS += $(SONIC_CONFIG_ENGINE_PY3) $(DOCKER_CONFIG_ENGINE_BUSTER)_LOAD_DOCKERS += $(DOCKER_BASE_BUSTER) $(DOCKER_CONFIG_ENGINE_BUSTER)_FILES += $(SWSS_VARS_TEMPLATE) diff --git a/rules/docker-router-advertiser.mk b/rules/docker-router-advertiser.mk index 6d5b9e4717bd..255ca00c01c7 100644 --- a/rules/docker-router-advertiser.mk +++ b/rules/docker-router-advertiser.mk @@ -19,10 +19,14 @@ $(DOCKER_ROUTER_ADVERTISER)_WARM_SHUTDOWN_BEFORE = swss $(DOCKER_ROUTER_ADVERTISER)_FAST_SHUTDOWN_BEFORE = swss SONIC_DOCKER_IMAGES += $(DOCKER_ROUTER_ADVERTISER) +ifeq ($(INCLUDE_ROUTER_ADVERTISER), y) SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_ROUTER_ADVERTISER) +endif SONIC_DOCKER_DBG_IMAGES += $(DOCKER_ROUTER_ADVERTISER_DBG) +ifeq ($(INCLUDE_ROUTER_ADVERTISER), y) SONIC_INSTALL_DOCKER_DBG_IMAGES += $(DOCKER_ROUTER_ADVERTISER_DBG) +endif $(DOCKER_ROUTER_ADVERTISER)_CONTAINER_NAME = radv $(DOCKER_ROUTER_ADVERTISER)_RUN_OPT += --privileged -t diff --git a/rules/docker-sonic-sdk-buildenv.mk b/rules/docker-sonic-sdk-buildenv.mk index fc3ee9fac986..8410d2d12cb9 100644 --- a/rules/docker-sonic-sdk-buildenv.mk +++ b/rules/docker-sonic-sdk-buildenv.mk @@ -28,5 +28,5 @@ $(DOCKER_SONIC_SDK_BUILDENV)_LOAD_DOCKERS += $(DOCKER_SONIC_SDK) SONIC_DOCKER_IMAGES += $(DOCKER_SONIC_SDK_BUILDENV) SONIC_DOCKER_DBG_IMAGES += $(DOCKER_SONIC_SDK_BUILDENV_DBG) -SONIC_BUSTER_DOCKERS += $(DOCKER_SONIC_SDK_BUILDENV) -SONIC_BUSTER_DBG_DOCKERS += $(DOCKER_SONIC_SDK_BUILDENV_DBG) +SONIC_BULLSEYE_DOCKERS += $(DOCKER_SONIC_SDK_BUILDENV) +SONIC_BULLSEYE_DBG_DOCKERS += $(DOCKER_SONIC_SDK_BUILDENV_DBG) diff --git a/rules/docker-sonic-sdk.mk b/rules/docker-sonic-sdk.mk index d1253aeb1fca..3c3e0b0f7b4f 100644 --- a/rules/docker-sonic-sdk.mk +++ b/rules/docker-sonic-sdk.mk @@ -8,12 +8,12 @@ $(DOCKER_SONIC_SDK)_PATH = $(DOCKERS_PATH)/docker-sonic-sdk $(DOCKER_SONIC_SDK)_DEPENDS += $(LIBSAIREDIS) \ $(LIBSAIMETADATA) -$(DOCKER_SONIC_SDK)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_BUSTER) +$(DOCKER_SONIC_SDK)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_BULLSEYE) -$(DOCKER_SONIC_SDK)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_DEPENDS) \ +$(DOCKER_SONIC_SDK)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_BULLSEYE)_DBG_DEPENDS) \ $(LIBSAIREDIS_DBG) \ $(LIBSAIMETADATA_DBG) -$(DOCKER_SONIC_SDK)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_IMAGE_PACKAGES) +$(DOCKER_SONIC_SDK)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BULLSEYE)_DBG_IMAGE_PACKAGES) SONIC_DOCKER_IMAGES += $(DOCKER_SONIC_SDK) SONIC_DOCKER_DBG_IMAGES += $(DOCKER_SONIC_SDK_DBG) @@ -23,5 +23,5 @@ $(DOCKER_SONIC_SDK)_LABELS += com.azure.sonic.versions.libsairedis=$(LIBSAIREDIS $(DOCKER_SONIC_SDK)_FILES += $(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT) -SONIC_BUSTER_DOCKERS += $(DOCKER_SONIC_SDK) -SONIC_BUSTER_DBG_DOCKERS += $(DOCKER_SONIC_SDK_DBG) +SONIC_BULLSEYE_DOCKERS += $(DOCKER_SONIC_SDK) +SONIC_BULLSEYE_DBG_DOCKERS += $(DOCKER_SONIC_SDK_DBG) diff --git a/rules/docker-teamd.mk b/rules/docker-teamd.mk index 9a04bc1f6859..8d92cd2533f4 100644 --- a/rules/docker-teamd.mk +++ b/rules/docker-teamd.mk @@ -23,10 +23,14 @@ $(DOCKER_TEAMD)_FAST_SHUTDOWN_BEFORE = syncd $(DOCKER_TEAMD)_FAST_SHUTDOWN_AFTER = swss SONIC_DOCKER_IMAGES += $(DOCKER_TEAMD) +ifeq ($(INCLUDE_TEAMD), y) SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_TEAMD) +endif SONIC_DOCKER_DBG_IMAGES += $(DOCKER_TEAMD_DBG) +ifeq ($(INCLUDE_TEAMD), y) SONIC_INSTALL_DOCKER_DBG_IMAGES += $(DOCKER_TEAMD_DBG) +endif $(DOCKER_TEAMD)_CONTAINER_NAME = teamd $(DOCKER_TEAMD)_RUN_OPT += --privileged -t diff --git a/rules/functions b/rules/functions index 62b3c8a98375..ab0096d6ac5a 100644 --- a/rules/functions +++ b/rules/functions @@ -198,6 +198,7 @@ define generate_manifest $(eval export config_cli_plugin=$($(1).gz_CLI_CONFIG_PLUGIN)) $(eval export show_cli_plugin=$($(1).gz_CLI_SHOW_PLUGIN)) $(eval export clear_cli_plugin=$($(1).gz_CLI_CLEAR_PLUGIN)) + $(eval export support_rate_limit=$($(1).gz_SUPPORT_RATE_LIMIT)) j2 --customize scripts/j2cli/json_filter.py files/build_templates/manifest.json.j2 > $($(1).gz_PATH)/manifest.common.json if [ -f $($*.gz_PATH)/manifest.part.json.j2 ]; then j2 --customize scripts/j2cli/json_filter.py $($(1).gz_PATH)/manifest.part.json.j2 > $($(1).gz_PATH)/manifest.part.json diff --git a/rules/isc-dhcp.mk b/rules/isc-dhcp.mk index 1a1ad54678b8..0951836470ce 100644 --- a/rules/isc-dhcp.mk +++ b/rules/isc-dhcp.mk @@ -1,7 +1,7 @@ # isc-dhcp packages ISC_DHCP_VERSION = 4.4.1 -ISC_DHCP_VERSION_FULL = ${ISC_DHCP_VERSION}-2.3 +ISC_DHCP_VERSION_FULL = ${ISC_DHCP_VERSION}-2.3+deb11u1 export ISC_DHCP_VERSION ISC_DHCP_VERSION_FULL diff --git a/rules/linux-kernel.mk b/rules/linux-kernel.mk index ffc735b4dc95..8e7b7c337a97 100644 --- a/rules/linux-kernel.mk +++ b/rules/linux-kernel.mk @@ -12,14 +12,14 @@ endif # Place an URL here to .tar.gz file if you want to include those patches EXTERNAL_KERNEL_PATCH_URL = # Set y to include non upstream patches tarball provided by the corresponding platform -INCLUDE_EXTERNAL_PATCH_TAR = n -# platforms should override this and provide an absolute path to the tarball -EXTERNAL_KERNEL_PATCH_TAR = +INCLUDE_EXTERNAL_PATCHES = n +# platforms should override this and provide an absolute location to the patches +EXTERNAL_KERNEL_PATCH_LOC = export KVERSION_SHORT KVERSION KERNEL_VERSION KERNEL_SUBVERSION export EXTERNAL_KERNEL_PATCH_URL -export INCLUDE_EXTERNAL_PATCH_TAR -export EXTERNAL_KERNEL_PATCH_TAR +export INCLUDE_EXTERNAL_PATCHES +export EXTERNAL_KERNEL_PATCH_LOC LINUX_HEADERS_COMMON = linux-headers-$(KVERSION_SHORT)-common_$(KERNEL_VERSION)-$(KERNEL_SUBVERSION)_all.deb $(LINUX_HEADERS_COMMON)_SRC_PATH = $(SRC_PATH)/sonic-linux-kernel diff --git a/rules/phy-credo.mk b/rules/phy-credo.mk index 197888e518bf..2ade08eba19d 100644 --- a/rules/phy-credo.mk +++ b/rules/phy-credo.mk @@ -1,3 +1,3 @@ PHY_CREDO = phy-credo_1.0_amd64.deb -$(PHY_CREDO)_URL = "https://github.com/aristanetworks/sonic-firmware/raw/e89a1696954fd381e1e95edf208cffc97caf15d4/phy/phy-credo_1.0_amd64.deb" +$(PHY_CREDO)_URL = "https://github.com/aristanetworks/sonic-firmware/raw/446f30ccd8626f904d89d5798da7294948e090a6/phy/phy-credo_1.0_amd64.deb" SONIC_ONLINE_DEBS += $(PHY_CREDO) diff --git a/rules/sonic-chassisd.mk b/rules/sonic-chassisd.mk index 46a49d359769..6e8a987de2a9 100644 --- a/rules/sonic-chassisd.mk +++ b/rules/sonic-chassisd.mk @@ -2,7 +2,7 @@ SONIC_CHASSISD_PY3 = sonic_chassisd-1.0-py3-none-any.whl $(SONIC_CHASSISD_PY3)_SRC_PATH = $(SRC_PATH)/sonic-platform-daemons/sonic-chassisd -$(SONIC_CHASSISD_PY3)_DEPENDS = $(SONIC_PY_COMMON_PY3) +$(SONIC_CHASSISD_PY3)_DEPENDS = $(SONIC_PY_COMMON_PY3) $(SONIC_PLATFORM_COMMON_PY3) $(SONIC_CHASSISD_PY3)_DEBS_DEPENDS = $(LIBSWSSCOMMON) $(PYTHON3_SWSSCOMMON) $(SONIC_CHASSISD_PY3)_PYTHON_VERSION = 3 SONIC_PYTHON_WHEELS += $(SONIC_CHASSISD_PY3) diff --git a/rules/sonic-containercfgd.dep b/rules/sonic-containercfgd.dep new file mode 100644 index 000000000000..48f8d320af92 --- /dev/null +++ b/rules/sonic-containercfgd.dep @@ -0,0 +1,10 @@ +SPATH := $($(SONIC_CONTAINERCFGD)_SRC_PATH) +DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/sonic-containercfgd.mk rules/sonic-containercfgd.dep +DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) +SMDEP_FILES := $(addprefix $(SPATH)/,$(shell cd $(SPATH) && git ls-files)) + +$(SONIC_CONTAINERCFGD)_CACHE_MODE := GIT_CONTENT_SHA +$(SONIC_CONTAINERCFGD)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) +$(SONIC_CONTAINERCFGD)_DEP_FILES := $(DEP_FILES) +$(SONIC_CONTAINERCFGD)_SMDEP_FILES := $(SMDEP_FILES) +$(SONIC_CONTAINERCFGD)_SMDEP_PATHS := $(SPATH) diff --git a/rules/sonic-containercfgd.mk b/rules/sonic-containercfgd.mk new file mode 100644 index 000000000000..e59f3bbd0b45 --- /dev/null +++ b/rules/sonic-containercfgd.mk @@ -0,0 +1,8 @@ +# sonic-bgpcfgd package + +SONIC_CONTAINERCFGD = sonic_containercfgd-1.0-py3-none-any.whl +$(SONIC_CONTAINERCFGD)_SRC_PATH = $(SRC_PATH)/sonic-containercfgd +$(SONIC_CONTAINERCFGD)_DEPENDS += $(SONIC_PY_COMMON_PY3) +$(SONIC_CONTAINERCFGD)_DEBS_DEPENDS = $(LIBSWSSCOMMON) $(PYTHON3_SWSSCOMMON) +$(SONIC_CONTAINERCFGD)_PYTHON_VERSION = 3 +SONIC_PYTHON_WHEELS += $(SONIC_CONTAINERCFGD) diff --git a/rules/sonic-fips.mk b/rules/sonic-fips.mk index 8303918e2e1b..9eb2d86bfb4d 100644 --- a/rules/sonic-fips.mk +++ b/rules/sonic-fips.mk @@ -1,7 +1,7 @@ # fips packages -FIPS_VERSION = 0.4 -FIPS_OPENSSL_VERSION = 1.1.1n-0+deb11u3+fips +FIPS_VERSION = 0.7 +FIPS_OPENSSL_VERSION = 1.1.1n-0+deb11u4+fips FIPS_OPENSSH_VERSION = 8.4p1-5+deb11u1+fips FIPS_PYTHON_MAIN_VERSION = 3.9 FIPS_PYTHON_VERSION = 3.9.2-1+fips diff --git a/rules/swss-common.mk b/rules/swss-common.mk index d2c4390ef4ff..462e0b3e96f3 100644 --- a/rules/swss-common.mk +++ b/rules/swss-common.mk @@ -27,7 +27,7 @@ endif PYTHON3_SWSSCOMMON = python3-swsscommon_$(LIBSWSSCOMMON_VERSION)_$(CONFIGURED_ARCH).deb $(eval $(call add_derived_package,$(LIBSWSSCOMMON),$(PYTHON3_SWSSCOMMON))) -LIBSWSSCOMMON_DBG = $(LIBSWSSCOMMON_NAME)-dbg_$(LIBSWSSCOMMON_VERSION)_$(CONFIGURED_ARCH).deb +LIBSWSSCOMMON_DBG = $(LIBSWSSCOMMON_NAME)-dbgsym_$(LIBSWSSCOMMON_VERSION)_$(CONFIGURED_ARCH).deb $(LIBSWSSCOMMON_DBG)_DEPENDS += $(LIBSWSSCOMMON) $(LIBSWSSCOMMON_DBG)_RDEPENDS += $(LIBSWSSCOMMON) $(eval $(call add_derived_package,$(LIBSWSSCOMMON),$(LIBSWSSCOMMON_DBG))) diff --git a/scripts/build_debian_base_system.sh b/scripts/build_debian_base_system.sh index 1532befdbe58..f90e72de0c77 100755 --- a/scripts/build_debian_base_system.sh +++ b/scripts/build_debian_base_system.sh @@ -21,6 +21,12 @@ generate_version_file() sudo LANG=C chroot $FILESYSTEM_ROOT /bin/bash -c "dpkg-query -W -f '\${Package}==\${Version}\n'" > $TARGET_BASEIMAGE_PATH/versions-deb-${IMAGE_DISTRO}-${CONFIGURED_ARCH} } +MIRROR_URL=http://deb.debian.org/debian +if [ "$MIRROR_SNAPSHOT" == y ]; then + SNAPSHOT_TIMESTAMP=$(grep "^debian==" $TARGET/versions/default/versions-mirror | tail -n 1 | sed 's/.*==//') + MIRROR_URL=http://packages.trafficmanager.net/snapshot/debian/$SNAPSHOT_TIMESTAMP +fi + if [ "$ENABLE_VERSION_CONTROL_DEB" != "y" ] || [ ! -d files/build/versions/host-base-image ]; then if [[ $CONFIGURED_ARCH == armhf || $CONFIGURED_ARCH == arm64 ]]; then if [[ $MULTIARCH_QEMU_ENVIRON == y || $CROSS_BUILD_ENVIRON == y ]]; then @@ -28,13 +34,13 @@ if [ "$ENABLE_VERSION_CONTROL_DEB" != "y" ] || [ ! -d files/build/versions/host- sudo mkdir -p $FILESYSTEM_ROOT/usr/bin sudo cp /usr/bin/qemu*static $FILESYSTEM_ROOT/usr/bin || true fi - sudo http_proxy=$HTTP_PROXY SKIP_BUILD_HOOK=y debootstrap --foreign --variant=minbase --arch $CONFIGURED_ARCH $IMAGE_DISTRO $FILESYSTEM_ROOT http://deb.debian.org/debian + sudo http_proxy=$HTTP_PROXY SKIP_BUILD_HOOK=y debootstrap --foreign --variant=minbase --arch $CONFIGURED_ARCH $IMAGE_DISTRO $FILESYSTEM_ROOT "$MIRROR_URL" sudo rm $FILESYSTEM_ROOT/proc -rf sudo mkdir $FILESYSTEM_ROOT/proc sudo mount -t proc proc $FILESYSTEM_ROOT/proc sudo LANG=C chroot $FILESYSTEM_ROOT /debootstrap/debootstrap --second-stage else - sudo http_proxy=$HTTP_PROXY SKIP_BUILD_HOOK=y debootstrap --variant=minbase --arch $CONFIGURED_ARCH $IMAGE_DISTRO $FILESYSTEM_ROOT http://debian-archive.trafficmanager.net/debian + sudo http_proxy=$HTTP_PROXY SKIP_BUILD_HOOK=y debootstrap --variant=minbase --arch $CONFIGURED_ARCH $IMAGE_DISTRO $FILESYSTEM_ROOT "$MIRROR_URL" fi RET=$? if [ $RET -ne 0 ]; then diff --git a/scripts/build_mirror_config.sh b/scripts/build_mirror_config.sh index 5f94e701cbde..aee56f23ae6a 100755 --- a/scripts/build_mirror_config.sh +++ b/scripts/build_mirror_config.sh @@ -5,16 +5,41 @@ CONFIG_PATH=$1 export ARCHITECTURE=$2 export DISTRIBUTION=$3 +DEFAULT_MIRROR_URL_PREFIX=http://packages.trafficmanager.net +MIRROR_VERSION_FILE= +[[ "$SONIC_VERSION_CONTROL_COMPONENTS" == *deb* || $SONIC_VERSION_CONTROL_COMPONENTS == *all* ]] && MIRROR_VERSION_FILE=files/build/versions/default/versions-mirror +[ -f target/versions/default/versions-mirror ] && MIRROR_VERSION_FILE=target/versions/default/versions-mirror + # The default mirror urls DEFAULT_MIRROR_URLS=http://debian-archive.trafficmanager.net/debian/,http://packages.trafficmanager.net/debian/debian/ DEFAULT_MIRROR_SECURITY_URLS=http://debian-archive.trafficmanager.net/debian-security/,http://packages.trafficmanager.net/debian/debian-security/ + # The debian-archive.trafficmanager.net does not support armhf, use debian.org instead if [ "$ARCHITECTURE" == "armhf" ]; then DEFAULT_MIRROR_URLS=http://deb.debian.org/debian/,http://packages.trafficmanager.net/debian/debian/ DEFAULT_MIRROR_SECURITY_URLS=http://deb.debian.org/debian-security/,http://packages.trafficmanager.net/debian/debian-security/ fi +if [ "$MIRROR_SNAPSHOT" == y ]; then + if [ -f "$MIRROR_VERSION_FILE" ]; then + DEBIAN_TIMESTAMP=$(grep "^debian==" $MIRROR_VERSION_FILE | tail -n 1 | sed 's/.*==//') + DEBIAN_SECURITY_TIMESTAMP=$(grep "^debian-security==" $MIRROR_VERSION_FILE | tail -n 1 | sed 's/.*==//') + elif [ -z "$DEBIAN_TIMESTAMP" ] || [ -z "$DEBIAN_SECURITY_TIMESTAMP" ]; then + DEBIAN_TIMESTAMP=$(curl $DEFAULT_MIRROR_URL_PREFIX/snapshot/debian/latest/timestamp) + DEBIAN_SECURITY_TIMESTAMP=$(curl $DEFAULT_MIRROR_URL_PREFIX/snapshot/debian-security/latest/timestamp) + fi + + DEFAULT_MIRROR_URLS=http://deb.debian.org/debian/,http://packages.trafficmanager.net/snapshot/debian/$DEBIAN_TIMESTAMP/ + DEFAULT_MIRROR_SECURITY_URLS=http://deb.debian.org/debian-security/,http://packages.trafficmanager.net/snapshot/debian-security/$DEBIAN_SECURITY_TIMESTAMP/ + + mkdir -p target/versions/default + if [ ! -f target/versions/default/versions-mirror ]; then + echo "debian==$DEBIAN_TIMESTAMP" > target/versions/default/versions-mirror + echo "debian-security==$DEBIAN_SECURITY_TIMESTAMP" >> target/versions/default/versions-mirror + fi +fi + [ -z "$MIRROR_URLS" ] && MIRROR_URLS=$DEFAULT_MIRROR_URLS [ -z "$MIRROR_SECURITY_URLS" ] && MIRROR_SECURITY_URLS=$DEFAULT_MIRROR_SECURITY_URLS @@ -24,3 +49,7 @@ TEMPLATE=files/apt/sources.list.j2 [ -f $CONFIG_PATH/sources.list.$ARCHITECTURE.j2 ] && TEMPLATE=$CONFIG_PATH/sources.list.$ARCHITECTURE.j2 MIRROR_URLS=$MIRROR_URLS MIRROR_SECURITY_URLS=$MIRROR_SECURITY_URLS j2 $TEMPLATE | sed '/^$/N;/^\n$/D' > $CONFIG_PATH/sources.list.$ARCHITECTURE +if [ "$MIRROR_SNAPSHOT" == y ]; then + # Set the snapshot mirror, and add the SET_REPR_MIRRORS flag + sed -i -e "/^#*deb.*packages.trafficmanager.net/! s/^#*deb/#&/" -e "\$a#SET_REPR_MIRRORS" $CONFIG_PATH/sources.list.$ARCHITECTURE +fi diff --git a/scripts/collect_build_version_files.sh b/scripts/collect_build_version_files.sh index b650e421996b..e35ca0590334 100755 --- a/scripts/collect_build_version_files.sh +++ b/scripts/collect_build_version_files.sh @@ -23,6 +23,6 @@ mkdir -p $VERSION_SLAVE_PATH scripts/versions_manager.py merge -t $VERSION_SLAVE_PATH -b $LOG_VERSION_PATH -e $POST_VERSION_PATH -rm -rf $BUILD_VERSION_PATH/* +[ -d $BUILD_VERSION_PATH ] && rm -rf $BUILD_VERSION_PATH/* exit $RET diff --git a/scripts/collect_docker_version_files.sh b/scripts/collect_docker_version_files.sh index 73f0a9b53198..1f5cc544972c 100755 --- a/scripts/collect_docker_version_files.sh +++ b/scripts/collect_docker_version_files.sh @@ -1,12 +1,17 @@ #!/bin/bash +set -x DOCKER_IMAGE=$1 TARGET_PATH=$2 +DOCKER_IMAGE_TAG=$3 +DOCKER_PATH=$4 +DOCKER_FILE=$5 [ -z "$TARGET_PATH" ] && TARGET_PATH=./target -DOCKER_IMAGE_NAME=$(echo $DOCKER_IMAGE | cut -d: -f1) -DOCKER_CONTAINER=$DOCKER_IMAGE_NAME +DOCKER_IMAGE_NAME=$(echo $DOCKER_IMAGE | cut -d: -f1 | sed "s/-$DOCKER_USERNAME\$//") +#Create the container specific to the user tag and slave tag +DOCKER_CONTAINER=${DOCKER_IMAGE_TAG/:/-} TARGET_VERSIONS_PATH=$TARGET_PATH/versions/dockers/$DOCKER_IMAGE_NAME [ -d $TARGET_VERSIONS_PATH ] && rm -rf $TARGET_VERSIONS_PATH @@ -18,8 +23,16 @@ export DOCKER_CLI_EXPERIMENTAL=enabled if docker container inspect $DOCKER_IMAGE > /dev/null 2>&1; then docker container rm $DOCKER_IMAGE > /dev/null fi -docker create --name $DOCKER_CONTAINER --entrypoint /bin/bash $DOCKER_IMAGE +docker create --name $DOCKER_CONTAINER --entrypoint /bin/bash $DOCKER_IMAGE_TAG docker cp -L $DOCKER_CONTAINER:/etc/os-release $TARGET_VERSIONS_PATH/ docker cp -L $DOCKER_CONTAINER:/usr/local/share/buildinfo/pre-versions $TARGET_VERSIONS_PATH/ docker cp -L $DOCKER_CONTAINER:/usr/local/share/buildinfo/post-versions $TARGET_VERSIONS_PATH/ + +# Save the cache contents from docker build +IMAGENAME=${DOCKER_IMAGE_TAG} j2 files/build_templates/build_docker_cache.j2 > ${DOCKER_FILE}.cleanup +docker tag ${DOCKER_IMAGE_TAG} tmp-${DOCKER_IMAGE_TAG} +DOCKER_BUILDKIT=1 docker build -f ${DOCKER_PATH}/Dockerfile.cleanup --target output -o target/vcache/${DOCKER_IMAGE_NAME} ${DOCKER_PATH} +DOCKER_BUILDKIT=1 docker build -f ${DOCKER_PATH}/Dockerfile.cleanup --no-cache --target final --tag ${DOCKER_IMAGE_TAG} ${DOCKER_PATH} +docker rmi tmp-${DOCKER_IMAGE_TAG} + docker container rm $DOCKER_CONTAINER diff --git a/scripts/collect_host_image_version_files.sh b/scripts/collect_host_image_version_files.sh index 2cabc049d9c7..d0d7aabcf9d2 100755 --- a/scripts/collect_host_image_version_files.sh +++ b/scripts/collect_host_image_version_files.sh @@ -3,11 +3,13 @@ TARGET=$1 FILESYSTEM_ROOT=$2 VERSIONS_PATH=$TARGET/versions/host-image +IMAGENAME="host-image" [ -d $VERSIONS_PATH ] && sudo rm -rf $VERSIONS_PATH mkdir -p $VERSIONS_PATH -sudo LANG=C chroot $FILESYSTEM_ROOT post_run_buildinfo +mkdir -p target/vcache/${IMAGENAME} +sudo LANG=C chroot $FILESYSTEM_ROOT post_run_buildinfo ${IMAGENAME} cp -r $FILESYSTEM_ROOT/usr/local/share/buildinfo/pre-versions $VERSIONS_PATH/ cp -r $FILESYSTEM_ROOT/usr/local/share/buildinfo/post-versions $VERSIONS_PATH/ diff --git a/scripts/generate_buildinfo_config.sh b/scripts/generate_buildinfo_config.sh index fe7657a6b6c9..080e6a321a6b 100755 --- a/scripts/generate_buildinfo_config.sh +++ b/scripts/generate_buildinfo_config.sh @@ -8,3 +8,4 @@ mkdir -p $BUILDINFO_PATH/buildinfo/config echo "PACKAGE_URL_PREFIX=$PACKAGE_URL_PREFIX" > $BUILDINFO_CONFIG echo "SONIC_VERSION_CONTROL_COMPONENTS=$SONIC_VERSION_CONTROL_COMPONENTS" >> $BUILDINFO_CONFIG +echo "export MIRROR_SNAPSHOT=$MIRROR_SNAPSHOT" >> $BUILDINFO_CONFIG diff --git a/scripts/prepare_docker_buildinfo.sh b/scripts/prepare_docker_buildinfo.sh index 3c1104eddc53..ea4ce079bdd3 100755 --- a/scripts/prepare_docker_buildinfo.sh +++ b/scripts/prepare_docker_buildinfo.sh @@ -11,6 +11,7 @@ DISTRO=$5 DOCKERFILE_PATH=$(dirname "$DOCKERFILE_TARGE") BUILDINFO_PATH="${DOCKERFILE_PATH}/buildinfo" BUILDINFO_VERSION_PATH="${BUILDINFO_PATH}/versions" +DOCKER_PATH=$(dirname $DOCKERFILE) [ -d $BUILDINFO_PATH ] && rm -rf $BUILDINFO_PATH mkdir -p $BUILDINFO_VERSION_PATH @@ -22,7 +23,7 @@ if [ -z "$DISTRO" ]; then [ -z "$DISTRO" ] && DISTRO=jessie fi -if [[ "$IMAGENAME" == docker-base-* ]]; then +if [[ "$IMAGENAME" == sonic-slave-* ]] || [[ "$IMAGENAME" == docker-base-* ]] || [[ "$IMAGENAME" == docker-ptf ]]; then scripts/build_mirror_config.sh ${DOCKERFILE_PATH} $ARCH $DISTRO fi @@ -31,8 +32,11 @@ scripts/docker_version_control.sh $@ DOCKERFILE_PRE_SCRIPT='# Auto-Generated for buildinfo COPY ["buildinfo", "/usr/local/share/buildinfo"] +COPY vcache/ /sonic/target/vcache/'${IMAGENAME}' RUN dpkg -i /usr/local/share/buildinfo/sonic-build-hooks_1.0_all.deb -RUN pre_run_buildinfo' +ENV IMAGENAME='${IMAGENAME}' +RUN pre_run_buildinfo '${IMAGENAME}' +' # Add the auto-generate code if it is not added in the target Dockerfile if [ ! -f $DOCKERFILE_TARGE ] || ! grep -q "Auto-Generated for buildinfo" $DOCKERFILE_TARGE; then @@ -42,7 +46,7 @@ if [ ! -f $DOCKERFILE_TARGE ] || ! grep -q "Auto-Generated for buildinfo" $DOCKE awk -v text="${DOCKERFILE_PRE_SCRIPT}" -v linenumber=$LINE_NUMBER 'NR==linenumber{print text}1' $DOCKERFILE > $TEMP_FILE # Append the docker build script at the end of the docker file - echo -e "\nRUN post_run_buildinfo" >> $TEMP_FILE + echo -e "\nRUN post_run_buildinfo ${IMAGENAME} " >> $TEMP_FILE cat $TEMP_FILE > $DOCKERFILE_TARGE rm -f $TEMP_FILE @@ -55,3 +59,8 @@ cp -rf src/sonic-build-hooks/buildinfo/* $BUILDINFO_PATH scripts/versions_manager.py generate -t "$BUILDINFO_VERSION_PATH" -n "$IMAGENAME" -d "$DISTRO" -a "$ARCH" touch $BUILDINFO_VERSION_PATH/versions-deb + +# Create the cache directories +LOCAL_CACHE_DIR=target/vcache/${IMAGENAME} +mkdir -p ${LOCAL_CACHE_DIR} ${DOCKER_PATH}/vcache/ +chmod -f 777 ${LOCAL_CACHE_DIR} ${DOCKER_PATH}/vcache/ diff --git a/scripts/run_with_retry b/scripts/run_with_retry new file mode 100755 index 000000000000..9e709bbf1bda --- /dev/null +++ b/scripts/run_with_retry @@ -0,0 +1,17 @@ +#!/bin/bash + +run_with_retry(){ + [ "$SONIC_BUILD_RETRY_COUNT" -gt 0 ] || SONIC_BUILD_RETRY_COUNT=0 + [[ "$*" == "" ]] && { echo "run_with_retry: input command can't be empty." 1>&2;exit 1; } + for ((i=0; i<=$SONIC_BUILD_RETRY_COUNT; i++)) + do + if [[ $i != 0 ]];then + echo "==============================================================================" 1>&2 + echo "Waiting $SONIC_BUILD_RETRY_INTERVAL to run again, $i/$SONIC_BUILD_RETRY_COUNT" 1>&2 + echo "==============================================================================" 1>&2 + sleep $SONIC_BUILD_RETRY_INTERVAL + fi + "$@" && break + done +} +run_with_retry "$@" diff --git a/scripts/versions_manager.py b/scripts/versions_manager.py index a20684e97bb4..d4127dece932 100755 --- a/scripts/versions_manager.py +++ b/scripts/versions_manager.py @@ -475,12 +475,13 @@ def filter(self, ctypes=[]): module.filter(ctypes=ctypes) def get_default_module(self): - if DEFAULT_MODULE in self.modules: - return self.modules[DEFAULT_MODULE] + default_module = self.modules.get(DEFAULT_MODULE, VersionModule(DEFAULT_MODULE, [])) ctypes = self.get_component_types() dists = self.get_dists() components = [] for ctype in ctypes: + if ctype in DEFAULT_OVERWRITE_COMPONENTS: + continue if ctype == 'deb': for dist in dists: versions = self._get_versions(ctype, dist) @@ -492,7 +493,9 @@ def get_default_module(self): common_versions = self._get_common_versions(versions) component = Component(common_versions, ctype) components.append(component) - return VersionModule(DEFAULT_MODULE, components) + module = VersionModule(DEFAULT_MODULE, components) + module.overwrite(default_module, True, True) + return module def get_aggregatable_modules(self): modules = {} diff --git a/slave.mk b/slave.mk index 32ca3cb2bfed..6b6b65086e7e 100644 --- a/slave.mk +++ b/slave.mk @@ -11,7 +11,7 @@ UID = $(shell id -u) GUID = $(shell id -g) ifeq ($(SONIC_IMAGE_VERSION),) - override SONIC_IMAGE_VERSION = $(shell export BUILD_TIMESTAMP=$(BUILD_TIMESTAMP) && export BUILD_NUMBER=$(BUILD_NUMBER) && . functions.sh && sonic_get_version) + override SONIC_IMAGE_VERSION := $(shell export BUILD_TIMESTAMP=$(BUILD_TIMESTAMP) && export BUILD_NUMBER=$(BUILD_NUMBER) && . functions.sh && sonic_get_version) endif .SECONDEXPANSION: @@ -86,6 +86,8 @@ export DOCKER_BASE_ARCH export CROSS_BUILD_ENVIRON export BLDENV export BUILD_WORKDIR +export MIRROR_SNAPSHOT +export SONIC_OS_VERSION ############################################################################### ## Utility rules @@ -111,6 +113,7 @@ configure : $(Q)mkdir -p $(PYTHON_DEBS_PATH) $(Q)mkdir -p $(PYTHON_WHEELS_PATH) $(Q)mkdir -p $(DPKG_ADMINDIR_PATH) + $(Q)mkdir -p $(TARGET_PATH)/vcache $(Q)echo $(PLATFORM) > .platform $(Q)echo $(PLATFORM_ARCH) > .arch @@ -186,10 +189,27 @@ endif override INCLUDE_P4RT = n endif +# Pre-built Bazel is not available for arm64, so exclude P4RT +# TODO(PINS): Remove when Bazel binaries are available for arm64 +ifeq ($(CONFIGURED_ARCH),arm64) +ifeq ($(INCLUDE_P4RT),y) +$(Q)echo "Disabling P4RT due to incompatible CPU architecture: $(CONFIGURED_ARCH)" +endif +override INCLUDE_P4RT = n +endif + ifeq ($(SONIC_INCLUDE_MACSEC),y) INCLUDE_MACSEC = y endif +ifneq ($(SONIC_INCLUDE_TEAMD),) +override INCLUDE_TEAMD = $(SONIC_INCLUDE_TEAMD) +endif + +ifneq ($(SONIC_INCLUDE_ROUTER_ADVERTISER),) +override INCLUDE_ROUTER_ADVERTISER = $(SONIC_INCLUDE_ROUTER_ADVERTISER) +endif + ifeq ($(ENABLE_AUTO_TECH_SUPPORT),y) ENABLE_AUTO_TECH_SUPPORT = y endif @@ -392,10 +412,13 @@ $(info "INCLUDE_KUBERNETES" : "$(INCLUDE_KUBERNETES)") $(info "INCLUDE_KUBERNETES_MASTER" : "$(INCLUDE_KUBERNETES_MASTER)") $(info "INCLUDE_MACSEC" : "$(INCLUDE_MACSEC)") $(info "INCLUDE_MUX" : "$(INCLUDE_MUX)") +$(info "INCLUDE_TEAMD" : "$(INCLUDE_TEAMD)") +$(info "INCLUDE_ROUTER_ADVERTISER" : "$(INCLUDE_ROUTER_ADVERTISER)") $(info "INCLUDE_BOOTCHART : "$(INCLUDE_BOOTCHART)") $(info "ENABLE_BOOTCHART : "$(ENABLE_BOOTCHART)") $(info "ENABLE_FIPS_FEATURE" : "$(ENABLE_FIPS_FEATURE)") $(info "ENABLE_TRANSLIB_WRITE" : "$(ENABLE_TRANSLIB_WRITE)") +$(info "ENABLE_NATIVE_WRITE" : "$(ENABLE_NATIVE_WRITE)") $(info "ENABLE_AUTO_TECH_SUPPORT" : "$(ENABLE_AUTO_TECH_SUPPORT)") $(info "PDDF_SUPPORT" : "$(PDDF_SUPPORT)") $(info "MULTIARCH_QEMU_ENVIRON" : "$(MULTIARCH_QEMU_ENVIRON)") @@ -439,6 +462,15 @@ export vs_build_prepare_mem=$(VS_PREPARE_MEM) ## ## docker-swss:latest <=SAVE/LOAD=> docker-swss-: +# $(call docker-get-tag,tag) +# Get the docker tag. For packages it is an image version, for other dockers it stays latest. +# +# $(1) => Docker name + +define docker-get-tag +$(shell [ ! -z $(filter $(1).gz,$(SONIC_PACKAGES_LOCAL)) ] && [ x$(SONIC_CONFIG_USE_NATIVE_DOCKERD_FOR_BUILD) == x"y" ] && echo $(SONIC_IMAGE_VERSION) || echo latest) +endef + # $(call docker-image-save,from,to) # Sonic docker images are always created with username as extension. During the save operation, # it removes the username extension from docker image and saved them as compressed tar file for SONiC image generation. @@ -451,13 +483,13 @@ define docker-image-save @echo "Attempting docker image lock for $(1) save" $(LOG) $(call MOD_LOCK,$(1),$(DOCKER_LOCKDIR),$(DOCKER_LOCKFILE_SUFFIX),$(DOCKER_LOCKFILE_TIMEOUT)) @echo "Obtained docker image lock for $(1) save" $(LOG) - @echo "Tagging docker image $(1)-$(DOCKER_USERNAME):$(DOCKER_USERTAG) as $(1):latest" $(LOG) - docker tag $(1)-$(DOCKER_USERNAME):$(DOCKER_USERTAG) $(1):latest $(LOG) - @echo "Saving docker image $(1):latest" $(LOG) - docker save $(1):latest | gzip -c > $(2) + @echo "Tagging docker image $(1)-$(DOCKER_USERNAME):$(DOCKER_USERTAG) as $(1):$(call docker-get-tag,$(1))" $(LOG) + docker tag $(1)-$(DOCKER_USERNAME):$(DOCKER_USERTAG) $(1):$(call docker-get-tag,$(1)) $(LOG) + @echo "Saving docker image $(1):$(call docker-get-tag,$(1))" $(LOG) + docker save $(1):$(call docker-get-tag,$(1)) | gzip -c > $(2) if [ x$(SONIC_CONFIG_USE_NATIVE_DOCKERD_FOR_BUILD) == x"y" ]; then - @echo "Removing docker image $(1):latest" $(LOG) - docker rmi -f $(1):latest $(LOG) + @echo "Removing docker image $(1):$(call docker-get-tag,$(1))" $(LOG) + docker rmi -f $(1):$(call docker-get-tag,$(1)) $(LOG) fi $(call MOD_UNLOCK,$(1)) @echo "Released docker image lock for $(1) save" $(LOG) @@ -478,11 +510,11 @@ define docker-image-load @echo "Obtained docker image lock for $(1) load" $(LOG) @echo "Loading docker image $(TARGET_PATH)/$(1).gz" $(LOG) docker load -i $(TARGET_PATH)/$(1).gz $(LOG) - @echo "Tagging docker image $(1):latest as $(1)-$(DOCKER_USERNAME):$(DOCKER_USERTAG)" $(LOG) - docker tag $(1):latest $(1)-$(DOCKER_USERNAME):$(DOCKER_USERTAG) $(LOG) + @echo "Tagging docker image $(1):$(call docker-get-tag,$(1)) as $(1)-$(DOCKER_USERNAME):$(DOCKER_USERTAG)" $(LOG) + docker tag $(1):$(call docker-get-tag,$(1)) $(1)-$(DOCKER_USERNAME):$(DOCKER_USERTAG) $(LOG) if [ x$(SONIC_CONFIG_USE_NATIVE_DOCKERD_FOR_BUILD) == x"y" ]; then @echo "Removing docker image $(1):latest" $(LOG) - docker rmi -f $(1):latest $(LOG) + docker rmi -f $(1):$(call docker-get-tag,$(1)) $(LOG) fi $(call MOD_UNLOCK,$(1)) @echo "Released docker image lock for $(1) load" $(LOG) @@ -585,11 +617,11 @@ $(addprefix $(FILES_PATH)/, $(SONIC_MAKE_FILES)) : $(FILES_PATH)/% : .platform $ # Remove target to force rebuild rm -f $(addprefix $(FILES_PATH)/, $*) # 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 + if [ -f $($*_SRC_PATH).patch/series ]; then pushd $($*_SRC_PATH) && quilt applied || QUILT_PATCHES=../$(notdir $($*_SRC_PATH)).patch quilt push -a; popd; fi $(LOG) # Build project and take package make DEST=$(shell pwd)/$(FILES_PATH) -C $($*_SRC_PATH) $(shell pwd)/$(FILES_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 + if [ -f $($*_SRC_PATH).patch/series ]; then pushd $($*_SRC_PATH) && quilt pop -a -f; [ -d .pc ] && rm -rf .pc; popd; fi $(LOG) # Save the target deb into DPKG cache $(call SAVE_CACHE,$*,$@) @@ -629,12 +661,12 @@ $(addprefix $(DEBS_PATH)/, $(SONIC_MAKE_DEBS)) : $(DEBS_PATH)/% : .platform $$(a # Remove target to force rebuild rm -f $(addprefix $(DEBS_PATH)/, $* $($*_DERIVED_DEBS) $($*_EXTRA_DEBS)) # 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 + if [ -f $($*_SRC_PATH).patch/series ]; then pushd $($*_SRC_PATH) && quilt applied || QUILT_PATCHES=../$(notdir $($*_SRC_PATH)).patch quilt push -a; popd; fi $(LOG) # Build project and take package $(SETUP_OVERLAYFS_FOR_DPKG_ADMINDIR) DEB_BUILD_OPTIONS="${DEB_BUILD_OPTIONS_GENERIC}" $(ANT_DEB_CONFIG) $(CROSS_COMPILE_FLAGS) make -j$(SONIC_CONFIG_MAKE_JOBS) 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 + if [ -f $($*_SRC_PATH).patch/series ]; then pushd $($*_SRC_PATH) && quilt pop -a -f; [ -d .pc ] && rm -rf .pc; popd; fi $(LOG) # Save the target deb into DPKG cache $(call SAVE_CACHE,$*,$@) @@ -669,7 +701,7 @@ $(addprefix $(DEBS_PATH)/, $(SONIC_DPKG_DEBS)) : $(DEBS_PATH)/% : .platform $$(a # Remove old build logs if they exist rm -f $($*_SRC_PATH)/debian/*.debhelper.log # 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 + if [ -f $($*_SRC_PATH).patch/series ]; then pushd $($*_SRC_PATH) && quilt applied || QUILT_PATCHES=../$(notdir $($*_SRC_PATH)).patch quilt push -a; popd; fi $(LOG) # Build project pushd $($*_SRC_PATH) $(LOG_SIMPLE) if [ -f ./autogen.sh ]; then ./autogen.sh $(LOG); fi @@ -783,14 +815,14 @@ $(addprefix $(PYTHON_DEBS_PATH)/, $(SONIC_PYTHON_STDEB_DEBS)) : $(PYTHON_DEBS_PA if [ -z '$($*_CACHE_LOADED)' ] ; then # 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 + if [ -f $($*_SRC_PATH).patch/series ]; then pushd $($*_SRC_PATH) && quilt applied || QUILT_PATCHES=../$(notdir $($*_SRC_PATH)).patch quilt push -a; popd; fi $(LOG) # Build project pushd $($*_SRC_PATH) $(LOG_SIMPLE) rm -rf deb_dist/* $(LOG) python setup.py --command-packages=stdeb.command bdist_deb $(LOG) popd $(LOG_SIMPLE) # Clean up - if [ -f $($*_SRC_PATH).patch/series ]; then pushd $($*_SRC_PATH) && quilt pop -a -f; [ -d .pc ] && rm -rf .pc; popd; fi + if [ -f $($*_SRC_PATH).patch/series ]; then pushd $($*_SRC_PATH) && quilt pop -a -f; [ -d .pc ] && rm -rf .pc; popd; fi $(LOG) # Take built package(s) mv -f $(addprefix $($*_SRC_PATH)/deb_dist/, $* $($*_DERIVED_DEBS)) $(PYTHON_DEBS_PATH) $(LOG) @@ -823,7 +855,7 @@ $(addprefix $(PYTHON_WHEELS_PATH)/, $(SONIC_PYTHON_WHEELS)) : $(PYTHON_WHEELS_PA pushd $($*_SRC_PATH) $(LOG_SIMPLE) # apply series of patches if exist - if [ -f ../$(notdir $($*_SRC_PATH)).patch/series ]; then QUILT_PATCHES=../$(notdir $($*_SRC_PATH)).patch quilt push -a; fi + if [ -f ../$(notdir $($*_SRC_PATH)).patch/series ]; then quilt applied || QUILT_PATCHES=../$(notdir $($*_SRC_PATH)).patch quilt push -a; fi $(LOG) ifneq ($(CROSS_BUILD_ENVIRON),y) # Use pip instead of later setup.py to install dependencies into user home, but uninstall self pip$($*_PYTHON_VERSION) install . && pip$($*_PYTHON_VERSION) uninstall --yes `python$($*_PYTHON_VERSION) setup.py --name` @@ -889,7 +921,7 @@ docker-start : $(addprefix $(TARGET_PATH)/, $(SONIC_SIMPLE_DOCKER_IMAGES)) : $(TARGET_PATH)/%.gz : .platform docker-start $$(addsuffix -load,$$(addprefix $(TARGET_PATH)/,$$($$*.gz_LOAD_DOCKERS))) $(HEADER) # Apply series of patches if exist - if [ -f $($*.gz_PATH).patch/series ]; then pushd $($*.gz_PATH) && QUILT_PATCHES=../$(notdir $($*.gz_PATH)).patch quilt push -a; popd; fi + if [ -f $($*.gz_PATH).patch/series ]; then pushd $($*.gz_PATH) && quilt applied || QUILT_PATCHES=../$(notdir $($*.gz_PATH)).patch quilt push -a; popd; fi $(LOG) # Prepare docker build info scripts/prepare_docker_buildinfo.sh $* $($*.gz_PATH)/Dockerfile $(CONFIGURED_ARCH) $(TARGET_DOCKERFILE)/Dockerfile.buildinfo docker info $(LOG) @@ -904,8 +936,10 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_SIMPLE_DOCKER_IMAGES)) : $(TARGET_PATH)/%.g --label Tag=$(SONIC_IMAGE_VERSION) \ -f $(TARGET_DOCKERFILE)/Dockerfile.buildinfo \ -t $(DOCKER_IMAGE_REF) $($*.gz_PATH) $(LOG) + if [ x$(SONIC_CONFIG_USE_NATIVE_DOCKERD_FOR_BUILD) == x"y" ]; then docker tag $(DOCKER_IMAGE_REF) $*; fi - scripts/collect_docker_version_files.sh $(DOCKER_IMAGE_REF) $(TARGET_PATH) + scripts/collect_docker_version_files.sh $* $(TARGET_PATH) $(DOCKER_IMAGE_REF) $($*.gz_PATH) $(LOG) + $(call docker-image-save,$*,$@) # Clean up if [ -f $($*.gz_PATH).patch/series ]; then pushd $($*.gz_PATH) && quilt pop -a -f; [ -d .pc ] && rm -rf .pc; popd; fi @@ -978,11 +1012,12 @@ $(addprefix $(TARGET_PATH)/, $(DOCKER_IMAGES)) : $(TARGET_PATH)/%.gz : .platform if [ -z '$($*.gz_CACHE_LOADED)' ] ; then # Apply series of patches if exist - if [ -f $($*.gz_PATH).patch/series ]; then pushd $($*.gz_PATH) && QUILT_PATCHES=../$(notdir $($*.gz_PATH)).patch quilt push -a; popd; fi + if [ -f $($*.gz_PATH).patch/series ]; then pushd $($*.gz_PATH) && quilt applied || QUILT_PATCHES=../$(notdir $($*.gz_PATH)).patch quilt push -a; popd; fi $(LOG) mkdir -p $($*.gz_PATH)/debs $(LOG) mkdir -p $($*.gz_PATH)/files $(LOG) mkdir -p $($*.gz_PATH)/python-debs $(LOG) mkdir -p $($*.gz_PATH)/python-wheels $(LOG) + mkdir -p $(TARGET_PATH)/vcache/$* $($*.gz_PATH)/vcache $(LOG) sudo mount --bind $($*.gz_DEBS_PATH) $($*.gz_PATH)/debs $(LOG) sudo mount --bind $($*.gz_FILES_PATH) $($*.gz_PATH)/files $(LOG) sudo mount --bind $(PYTHON_DEBS_PATH) $($*.gz_PATH)/python-debs $(LOG) @@ -1024,8 +1059,11 @@ $(addprefix $(TARGET_PATH)/, $(DOCKER_IMAGES)) : $(TARGET_PATH)/%.gz : .platform --label Tag=$(SONIC_IMAGE_VERSION) \ $($(subst -,_,$(notdir $($*.gz_PATH)))_labels) \ -t $(DOCKER_IMAGE_REF) $($*.gz_PATH) $(LOG) + if [ x$(SONIC_CONFIG_USE_NATIVE_DOCKERD_FOR_BUILD) == x"y" ]; then docker tag $(DOCKER_IMAGE_REF) $*; fi - scripts/collect_docker_version_files.sh $(DOCKER_IMAGE_REF) $(TARGET_PATH) + scripts/collect_docker_version_files.sh $* $(TARGET_PATH) $(DOCKER_IMAGE_REF) $($*.gz_PATH) $($*.gz_PATH)/Dockerfile $(LOG) + if [ ! -z $(filter $*.gz,$(SONIC_PACKAGES_LOCAL)) ]; then docker tag $(DOCKER_IMAGE_REF) $*:$(SONIC_IMAGE_VERSION); fi + $(call docker-image-save,$*,$@) # Clean up if [ -f $($*.gz_PATH).patch/series ]; then pushd $($*.gz_PATH) && quilt pop -a -f; [ -d .pc ] && rm -rf .pc; popd; fi @@ -1054,6 +1092,7 @@ $(addprefix $(TARGET_PATH)/, $(DOCKER_DBG_IMAGES)) : $(TARGET_PATH)/%-$(DBG_IMAG mkdir -p $($*.gz_PATH)/debs $(LOG) sudo mount --bind $($*.gz_DEBS_PATH) $($*.gz_PATH)/debs $(LOG) + mkdir -p $(TARGET_PATH)/vcache/$*-dbg $($*.gz_PATH)/vcache $(LOG) # Export variables for j2. Use path for unique variable names, e.g. docker_orchagent_debs $(eval export $(subst -,_,$(notdir $($*.gz_PATH)))_dbg_debs=$(shell printf "$(subst $(SPACE),\n,$(call expand,$($*.gz_DBG_DEPENDS),RDEPENDS))\n" | awk '!a[$$0]++')) $(eval export $(subst -,_,$(notdir $($*.gz_PATH)))_image_dbgs=$(shell printf "$(subst $(SPACE),\n,$(call expand,$($*.gz_DBG_IMAGE_PACKAGES)))\n" | awk '!a[$$0]++')) @@ -1077,8 +1116,11 @@ $(addprefix $(TARGET_PATH)/, $(DOCKER_DBG_IMAGES)) : $(TARGET_PATH)/%-$(DBG_IMAG --label Tag=$(SONIC_IMAGE_VERSION) \ --file $($*.gz_PATH)/Dockerfile-dbg \ -t $(DOCKER_DBG_IMAGE_REF) $($*.gz_PATH) $(LOG) + if [ x$(SONIC_CONFIG_USE_NATIVE_DOCKERD_FOR_BUILD) == x"y" ]; then docker tag $(DOCKER_IMAGE_REF) $*; fi - scripts/collect_docker_version_files.sh $(DOCKER_DBG_IMAGE_REF) $(TARGET_PATH) + scripts/collect_docker_version_files.sh $*-dbg $(TARGET_PATH) $(DOCKER_DBG_IMAGE_REF) $($*.gz_PATH) $($*.gz_PATH)/Dockerfile-dbg $(LOG) + if [ ! -z $(filter $*.gz,$(SONIC_PACKAGES_LOCAL)) ]; then docker tag $(DOCKER_IMAGE_REF) $*:$(SONIC_IMAGE_VERSION); fi + $(call docker-image-save,$*-$(DBG_IMAGE_MARK),$@) # Clean up docker rmi -f $(DOCKER_IMAGE_REF) &> /dev/null || true @@ -1186,6 +1228,8 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \ export enable_organization_extensions="$(ENABLE_ORGANIZATION_EXTENSIONS)" export enable_dhcp_graph_service="$(ENABLE_DHCP_GRAPH_SERVICE)" export enable_ztp="$(ENABLE_ZTP)" + export include_teamd="$(INCLUDE_TEAMD)" + export include_router_advertiser="$(INCLUDE_ROUTER_ADVERTISER)" export include_system_telemetry="$(INCLUDE_SYSTEM_TELEMETRY)" export include_restapi="$(INCLUDE_RESTAPI)" export include_nat="$(INCLUDE_NAT)" diff --git a/sonic-slave-bullseye/Dockerfile.j2 b/sonic-slave-bullseye/Dockerfile.j2 index b22639e8318b..fc129a5f684b 100644 --- a/sonic-slave-bullseye/Dockerfile.j2 +++ b/sonic-slave-bullseye/Dockerfile.j2 @@ -22,6 +22,7 @@ FROM {{ prefix }}debian:bullseye MAINTAINER gulv@microsoft.com COPY ["no-check-valid-until", "/etc/apt/apt.conf.d/"] +COPY ["apt-multiple-retries", "/etc/apt/apt.conf.d/"] {%- if CROSS_BUILD_ENVIRON != "y" %} COPY ["sources.list.{{ CONFIGURED_ARCH }}", "/etc/apt/sources.list"] @@ -225,6 +226,9 @@ RUN apt-get update && apt-get install -y \ libpcap-dev \ dnsutils \ libusb-dev \ +# For cisco sdk build + libgrpc++1 \ + libabsl-dev \ # For debian image reconfiguration augeas-tools \ # For p4 build @@ -470,7 +474,7 @@ RUN apt-get purge -y python3-pip python3-yaml # For building Python packages RUN pip3 install setuptools==49.6.00 -RUN pip3 install wheel==0.35.1 +RUN pip3 install wheel==0.38.1 {%- if CONFIGURED_ARCH == "armhf" %} # Allow only manylinux wheels on armhf, to ensure that binaries/libraries work correctly on armhf @@ -490,6 +494,19 @@ RUN pip3 install pytest-runner==5.2 RUN pip3 install nose==1.3.7 RUN pip3 install mockredispy==2.9.3 +# Fix CVE-2021-23437, need to build and install libjpeg-dev for armhf for pillow 9.4.0 +{%- if CONFIGURED_ARCH == "armhf" %} +RUN TMP_DIR=$(mktemp -d) && \ + cd $TMP_DIR && \ + apt-get install -y nasm && \ + apt-get source libjpeg-turbo && \ + cd $(ls -d libjpeg-turbo*/) && \ + dpkg-buildpackage -rfakeroot -b -us -uc > $TMP_DIR/libjpeg-dev.log && \ + dpkg -i $TMP_DIR/libjpeg*-dev*.deb && \ + rm -rf $TMP_DIR +{%- endif %} +RUN pip3 install pillow==9.4.0 + # For p4 build RUN pip3 install \ ctypesgen==1.0.2 \ @@ -508,7 +525,7 @@ RUN pip3 install j2cli==0.3.10 # For sonic-mgmt-framework RUN pip3 install "PyYAML==5.4.1" {%- if CROSS_BUILD_ENVIRON != "y" %} -RUN pip3 install "lxml==4.6.2" +RUN pip3 install "lxml==4.9.1" {%- endif %} # For sonic-platform-common testing @@ -528,6 +545,9 @@ RUN pip3 install mmh3==2.5.1 RUN pip3 install parameterized==0.8.1 +# For latest version error, use previous version +RUN pip3 install deepdiff==6.2.2 + RUN apt-get install -y xsltproc # Install dependencies for isc-dhcp-relay build diff --git a/sonic-slave-bullseye/apt-multiple-retries b/sonic-slave-bullseye/apt-multiple-retries new file mode 100644 index 000000000000..c4c638252f92 --- /dev/null +++ b/sonic-slave-bullseye/apt-multiple-retries @@ -0,0 +1,4 @@ +# Instruct apt to retry downloads on failures +# This is required only for bullseye. + +Acquire::Retries "3"; diff --git a/sonic-slave-buster/Dockerfile.j2 b/sonic-slave-buster/Dockerfile.j2 index 73e9febda14b..60282b627aab 100644 --- a/sonic-slave-buster/Dockerfile.j2 +++ b/sonic-slave-buster/Dockerfile.j2 @@ -69,7 +69,7 @@ RUN cd /python_virtualenv && python3 -m virtualenv -p /usr/bin/python env2 RUN cd /python_virtualenv && python3 -m virtualenv --copies -p /usr/bin/python3 env3 RUN PATH=/python_virtualenv/env2/bin/:$PATH pip2 install setuptools==40.8.0 wheel==0.35.1 fastentrypoints pytest pytest-cov pytest-runner==4.4 nose==1.3.7 mockredispy==2.9.3 mock==3.0.5 j2cli==0.3.10 PyYAML==5.4.1 pexpect==4.6.0 Pympler==0.8 ctypesgen==1.0.2 natsort==6.2.1 redis==3.5.3 protobuf==3.17.3 -RUN PATH=/python_virtualenv/env3/bin/:$PATH pip3 install setuptools==49.6.00 wheel==0.35.1 fastentrypoints pytest pytest-cov pytest-runner==5.2 nose==1.3.7 mockredispy==2.9.3 mock==3.0.5 PyYAML==5.4.1 redis==3.5.3 pexpect==4.8.0 Pympler==0.8 parameterized natsort==6.2.1 MarkupSafe==2.0.1 Jinja2==3.0.3 sphinx && ln -s /python_virtualenv/env3/bin/pytest /python_virtualenv/env3/bin/pytest-3 +RUN PATH=/python_virtualenv/env3/bin/:$PATH pip3 install setuptools==49.6.00 wheel==0.35.1 fastentrypoints pytest pytest-cov pytest-runner==5.2 nose==1.3.7 mockredispy==2.9.3 mock==3.0.5 PyYAML==5.4.1 redis==3.5.3 pexpect==4.8.0 Pympler==0.8 parameterized natsort==6.2.1 MarkupSafe==2.0.1 Jinja2==3.0.3 sphinx && ln -s /python_virtualenv/env3/bin/pytest /python_virtualenv/env3/bin/pytest-3 RUN apt-get --fix-broken install -y RUN LIBPYTHON3_DEPS="`apt-cache depends libpython3-dev:$arch |grep Depends|awk {'print \$2;'}|tr "\n" " "`" && apt-get install -y libpython2.7-dev:$arch $LIBPYTHON3_DEPS libxml2-dev:$arch libxslt-dev:$arch libssl-dev:$arch libz-dev:$arch @@ -228,6 +228,9 @@ RUN apt-get update && apt-get install -y \ libpcap-dev \ dnsutils \ libusb-dev \ +# For cisco sdk build + libgrpc++1 \ + libabsl-dev \ # For debian image reconfiguration augeas-tools \ # For p4 build @@ -484,7 +487,7 @@ RUN apt-get purge -y python-pip python3-pip python3-yaml RUN pip2 install setuptools==40.8.0 RUN pip2 install wheel==0.35.1 RUN pip3 install setuptools==49.6.00 -RUN pip3 install wheel==0.35.1 +RUN pip3 install wheel==0.38.1 # For building sonic-utilities RUN pip2 install fastentrypoints @@ -498,6 +501,19 @@ RUN pip3 install nose==1.3.7 RUN pip2 install mockredispy==2.9.3 RUN pip3 install mockredispy==2.9.3 +# Fix CVE-2021-23437, need to build and install libjpeg-dev for armhf for pillow 9.4.0 +{%- if CONFIGURED_ARCH == "armhf" %} +RUN TMP_DIR=$(mktemp -d) && \ + cd $TMP_DIR && \ + apt-get install -y nasm && \ + apt-get source libjpeg-turbo && \ + cd $(ls -d libjpeg-turbo*/) && \ + dpkg-buildpackage -rfakeroot -b -us -uc > $TMP_DIR/libjpeg-dev.log && \ + dpkg -i $TMP_DIR/libjpeg*-dev*.deb && \ + rm -rf $TMP_DIR +{%- endif %} +RUN pip3 install pillow==9.4.0 + # For Python 2 unit tests, we need 'mock'. The last version of 'mock' # which supports Python 2 is 3.0.5. In Python 3, 'mock' is part of 'unittest' # in the standard library @@ -528,8 +544,8 @@ RUN pip2 install "PyYAML==5.4.1" RUN pip3 install "PyYAML==5.4.1" {%- if CROSS_BUILD_ENVIRON != "y" %} -RUN pip2 install "lxml==4.6.5" -RUN pip3 install "lxml==4.6.5" +RUN pip2 install "lxml==4.9.1" +RUN pip3 install "lxml==4.9.1" {%- endif %} # For sonic-platform-common testing @@ -599,7 +615,7 @@ RUN add-apt-repository \ $(lsb_release -cs) \ stable" RUN apt-get update -RUN apt-get install -y docker-ce=5:18.09.5~3-0~debian-buster docker-ce-cli=5:18.09.5~3-0~debian-buster +RUN apt-get install -y docker-ce=5:20.10.21~3-0~debian-buster docker-ce-cli=5:20.10.21~3-0~debian-buster RUN echo "DOCKER_OPTS=\"--experimental --storage-driver=vfs {{ DOCKER_EXTRA_OPTS }}\"" >> /etc/default/docker RUN update-alternatives --set iptables /usr/sbin/iptables-legacy diff --git a/sonic-slave-stretch/Dockerfile.j2 b/sonic-slave-stretch/Dockerfile.j2 index 1397df1c7368..36af8f908b44 100644 --- a/sonic-slave-stretch/Dockerfile.j2 +++ b/sonic-slave-stretch/Dockerfile.j2 @@ -331,8 +331,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.5" -RUN pip3 install "lxml==4.6.5" +RUN pip2 install "lxml==4.9.1" +RUN pip3 install "lxml==4.9.1" # For sonic-platform-common testing @@ -354,7 +354,7 @@ RUN pip2 install Pympler==0.8 RUN pip3 install pyang==2.4.0 # For mgmt-framework build -RUN pip2 install mmh3 +RUN pip2 install mmh3==2.5.1 # Install dependencies for isc-dhcp-relay build RUN apt-get -y build-dep isc-dhcp diff --git a/src/dhcpmon/src/dhcp_device.cpp b/src/dhcpmon/src/dhcp_device.cpp index 8ec91b057b64..12c0e1544903 100644 --- a/src/dhcpmon/src/dhcp_device.cpp +++ b/src/dhcpmon/src/dhcp_device.cpp @@ -24,6 +24,7 @@ #include "subscriberstatetable.h" #include "select.h" +#include "dhcp_devman.h" #include "dhcp_device.h" /** Counter print width */ @@ -41,6 +42,7 @@ #define DHCP_OPTIONS_HEADER_SIZE 240 /** Offset of DHCP GIADDR */ #define DHCP_GIADDR_OFFSET 24 +#define CLIENT_IF_PREFIX "Ethernet" #define OP_LDHA (BPF_LD | BPF_H | BPF_ABS) /** bpf ldh Abs */ #define OP_LDHI (BPF_LD | BPF_H | BPF_IND) /** bpf ldh Ind */ @@ -51,19 +53,60 @@ #define OP_JSET (BPF_JMP | BPF_JSET | BPF_K) /** bpf jset */ #define OP_LDXB (BPF_LDX | BPF_B | BPF_MSH) /** bpf ldxb */ +std::shared_ptr mConfigDbPtr = std::make_shared ("CONFIG_DB", 0); std::shared_ptr mStateDbPtr = std::make_shared ("STATE_DB", 0); std::shared_ptr mStateDbMuxTablePtr = std::make_shared ( mStateDbPtr.get(), "HW_MUX_CABLE_TABLE" ); -swss::DBConnector configDb("CONFIG_DB", 0); + +/* interface to vlan mapping */ +std::unordered_map vlan_map; + +/* interface to port-channel mapping */ +std::unordered_map portchan_map; + +/* interface to mgmt port mapping */ +std::unordered_map mgmt_map; + +/** Berkeley Packet Filter program for "udp and (port 67 or port 68)". + * This program is obtained using the following command tcpdump: + * `tcpdump -dd "outbound and udp and (port 67 or port 68)"` + */ +static struct sock_filter dhcp_outbound_bpf_code[] = { + {.code = OP_LDHA, .jt = 0, .jf = 0, .k = 0xfffff004}, // (000) ldh #fffff004 + {.code = OP_JEQ, .jt = 0, .jf = 22, .k = 0x00000004}, // (001) jeq #0x04 jt 0 jf 22 + {.code = OP_LDHA, .jt = 0, .jf = 0, .k = 0x0000000c}, // (002) ldh [12] + {.code = OP_JEQ, .jt = 0, .jf = 7, .k = 0x000086dd}, // (003) jeq #0x86dd jt 2 jf 9 + {.code = OP_LDB, .jt = 0, .jf = 0, .k = 0x00000014}, // (004) ldb [20] + {.code = OP_JEQ, .jt = 0, .jf = 18, .k = 0x00000011}, // (005) jeq #0x11 jt 4 jf 22 + {.code = OP_LDHA, .jt = 0, .jf = 0, .k = 0x00000036}, // (006) ldh [54] + {.code = OP_JEQ, .jt = 15, .jf = 0, .k = 0x00000043}, // (007) jeq #0x43 jt 21 jf 6 + {.code = OP_JEQ, .jt = 14, .jf = 0, .k = 0x00000044}, // (008) jeq #0x44 jt 21 jf 7 + {.code = OP_LDHA, .jt = 0, .jf = 0, .k = 0x00000038}, // (009) ldh [56] + {.code = OP_JEQ, .jt = 12, .jf = 11, .k = 0x00000043}, // (010) jeq #0x43 jt 21 jf 20 + {.code = OP_JEQ, .jt = 0, .jf = 12, .k = 0x00000800}, // (011) jeq #0x800 jt 10 jf 22 + {.code = OP_LDB, .jt = 0, .jf = 0, .k = 0x00000017}, // (012) ldb [23] + {.code = OP_JEQ, .jt = 0, .jf = 10, .k = 0x00000011}, // (013) jeq #0x11 jt 12 jf 22 + {.code = OP_LDHA, .jt = 0, .jf = 0, .k = 0x00000014}, // (014) ldh [20] + {.code = OP_JSET, .jt = 8, .jf = 0, .k = 0x00001fff}, // (015) jset #0x1fff jt 22 jf 14 + {.code = OP_LDXB, .jt = 0, .jf = 0, .k = 0x0000000e}, // (016) ldxb 4*([14]&0xf) + {.code = OP_LDHI, .jt = 0, .jf = 0, .k = 0x0000000e}, // (017) ldh [x + 14] + {.code = OP_JEQ, .jt = 4, .jf = 0, .k = 0x00000043}, // (018) jeq #0x43 jt 21 jf 17 + {.code = OP_JEQ, .jt = 3, .jf = 0, .k = 0x00000044}, // (019) jeq #0x44 jt 21 jf 18 + {.code = OP_LDHI, .jt = 0, .jf = 0, .k = 0x00000010}, // (020) ldh [x + 16] + {.code = OP_JEQ, .jt = 1, .jf = 0, .k = 0x00000043}, // (021) jeq #0x43 jt 21 jf 20 + {.code = OP_JEQ, .jt = 0, .jf = 1, .k = 0x00000044}, // (022) jeq #0x44 jt 21 jf 22 + {.code = OP_RET, .jt = 0, .jf = 0, .k = 0x00040000}, // (023) ret #262144 + {.code = OP_RET, .jt = 0, .jf = 0, .k = 0x00000000}, // (024) ret #0 +}; /** Berkeley Packet Filter program for "udp and (port 67 or port 68)". * This program is obtained using the following command tcpdump: * `tcpdump -dd "inbound and udp and (port 67 or port 68)"` */ -static struct sock_filter dhcp_bpf_code[] = { +static struct sock_filter dhcp_inbound_bpf_code[] = { {.code = OP_LDHA, .jt = 0, .jf = 0, .k = 0xfffff004}, // (000) ldh #fffff004 - {.code = OP_JEQ, .jt = 22, .jf = 0, .k = 0x00000004}, // (001) jeq #0x04 jt 22 jf 0 + {.code = OP_JEQ, .jt = 22, .jf = 0, .k = 0x00000004}, // (001) jeq #0x04 jt 22 jf 0 {.code = OP_LDHA, .jt = 0, .jf = 0, .k = 0x0000000c}, // (002) ldh [12] {.code = OP_JEQ, .jt = 0, .jf = 7, .k = 0x000086dd}, // (003) jeq #0x86dd jt 2 jf 9 {.code = OP_LDB, .jt = 0, .jf = 0, .k = 0x00000014}, // (004) ldb [20] @@ -90,10 +133,17 @@ static struct sock_filter dhcp_bpf_code[] = { }; /** Filter program socket struct */ -static struct sock_fprog dhcp_sock_bfp = { - .len = sizeof(dhcp_bpf_code) / sizeof(*dhcp_bpf_code), .filter = dhcp_bpf_code +static struct sock_fprog dhcp_outbound_sock_bfp = { + .len = sizeof(dhcp_outbound_bpf_code) / sizeof(*dhcp_outbound_bpf_code), .filter = dhcp_outbound_bpf_code +}; +static struct sock_fprog dhcp_inbound_sock_bfp = { + .len = sizeof(dhcp_inbound_bpf_code) / sizeof(*dhcp_inbound_bpf_code), .filter = dhcp_inbound_bpf_code }; +static uint8_t *rx_recv_buffer = NULL; +static uint8_t *tx_recv_buffer = NULL; +static uint32_t snap_length; + /** Aggregate device of DHCP interfaces. It contains aggregate counters from all interfaces */ @@ -107,6 +157,56 @@ static dhcp_message_type_t monitored_msgs[] = { DHCP_MESSAGE_TYPE_ACK }; +/** update ethernet interface to vlan map + * VLAN_MEMBER|Vlan1000|Ethernet48 + */ +void update_vlan_mapping(std::shared_ptr db_conn) { + auto match_pattern = std::string("VLAN_MEMBER|*"); + auto keys = db_conn->keys(match_pattern); + for (auto &itr : keys) { + auto first = itr.find_first_of('|'); + auto second = itr.find_last_of('|'); + auto vlan = itr.substr(first + 1, second - first - 1); + auto interface = itr.substr(second + 1); + vlan_map[interface] = vlan; + syslog(LOG_INFO, "add <%s, %s> into interface vlan map\n", interface.c_str(), vlan.c_str()); + } +} + +/** update ethernet interface to port-channel map + * PORTCHANNEL_MEMBER|PortChannel101|Ethernet112 + */ +void update_portchannel_mapping(std::shared_ptr db_conn) { + auto match_pattern = std::string("PORTCHANNEL_MEMBER|*"); + auto keys = db_conn->keys(match_pattern); + for (auto &itr : keys) { + auto first = itr.find_first_of('|'); + auto second = itr.find_last_of('|'); + auto portchannel = itr.substr(first + 1, second - first - 1); + auto interface = itr.substr(second + 1); + portchan_map[interface] = portchannel; + syslog(LOG_INFO, "add <%s, %s> into interface port-channel map\n", interface.c_str(), portchannel.c_str()); + } +} + +/** update interface to mgmt map + */ +void update_mgmt_mapping() { + auto mgmt = dhcp_devman_get_mgmt_dev(); + if (mgmt) { + auto name = std::string(mgmt->intf); + mgmt_map[name] = name; + } +} + +dhcp_device_context_t *find_device_context(std::unordered_map *intfs, std::string if_name) { + auto intf = intfs->find(if_name); + if (intf == intfs->end()) { + return NULL; + } + return intf->second->dev_context; +} + /** Number of monitored DHCP message type */ static uint8_t monitored_msg_sz = sizeof(monitored_msgs) / sizeof(*monitored_msgs); @@ -163,78 +263,86 @@ static void handle_dhcp_option_53(dhcp_device_context_t *context, } /** - * @code read_callback(fd, event, arg); + * @code client_packet_handler(dhcp_device_context_t *context, ssize_t buffer_sz); * - * @brief callback for libevent which is called every time out in order to read queued packet capture + * @brief packet handler to process received rx and tx packets * - * @param fd socket to read from - * @param event libevent triggered event - * @param arg user provided argument for callback (interface context) + * @param context pointer to device (interface) context + * @param buffer_sz buffer that stores received packet data * * @return none */ -static void read_callback(int fd, short event, void *arg) +static void client_packet_handler(dhcp_device_context_t *context, uint8_t *buffer, + ssize_t buffer_sz, dhcp_packet_direction_t dir) { - dhcp_device_context_t *context = (dhcp_device_context_t*) arg; - ssize_t buffer_sz; + struct ip *iphdr = (struct ip*) (buffer + IP_START_OFFSET); + struct udphdr *udp = (struct udphdr*) (buffer + UDP_START_OFFSET); + uint8_t *dhcphdr = buffer + DHCP_START_OFFSET; + int dhcp_option_offset = DHCP_START_OFFSET + DHCP_OPTIONS_HEADER_SIZE; - while ((event == EV_READ) && - ((buffer_sz = recv(fd, context->buffer, context->snaplen, MSG_DONTWAIT)) > 0)) { - struct ether_header *ethhdr = (struct ether_header*) context->buffer; - struct ip *iphdr = (struct ip*) (context->buffer + IP_START_OFFSET); - struct udphdr *udp = (struct udphdr*) (context->buffer + UDP_START_OFFSET); - uint8_t *dhcphdr = context->buffer + DHCP_START_OFFSET; - int dhcp_option_offset = DHCP_START_OFFSET + DHCP_OPTIONS_HEADER_SIZE; - - if (((unsigned)buffer_sz > UDP_START_OFFSET + sizeof(struct udphdr) + DHCP_OPTIONS_HEADER_SIZE) && - (ntohs(udp->len) > DHCP_OPTIONS_HEADER_SIZE)) { - int dhcp_sz = ntohs(udp->len) < buffer_sz - UDP_START_OFFSET - sizeof(struct udphdr) ? - ntohs(udp->len) : buffer_sz - UDP_START_OFFSET - sizeof(struct udphdr); - int dhcp_option_sz = dhcp_sz - DHCP_OPTIONS_HEADER_SIZE; - const u_char *dhcp_option = context->buffer + dhcp_option_offset; - dhcp_packet_direction_t dir = (ethhdr->ether_shost[0] == context->mac[0] && - ethhdr->ether_shost[1] == context->mac[1] && - ethhdr->ether_shost[2] == context->mac[2] && - ethhdr->ether_shost[3] == context->mac[3] && - ethhdr->ether_shost[4] == context->mac[4] && - ethhdr->ether_shost[5] == context->mac[5]) ? - DHCP_TX : DHCP_RX; - int offset = 0; - int stop_dhcp_processing = 0; - while ((offset < (dhcp_option_sz + 1)) && dhcp_option[offset] != 255) { - switch (dhcp_option[offset]) - { - case 53: - if (offset < (dhcp_option_sz + 2)) { - handle_dhcp_option_53(context, &dhcp_option[offset], dir, iphdr, dhcphdr); - } - stop_dhcp_processing = 1; // break while loop since we are only interested in Option 53 - break; - default: - break; + if (((unsigned)buffer_sz > UDP_START_OFFSET + sizeof(struct udphdr) + DHCP_OPTIONS_HEADER_SIZE) && + (ntohs(udp->len) > DHCP_OPTIONS_HEADER_SIZE)) + { + int dhcp_sz = ntohs(udp->len) < buffer_sz - UDP_START_OFFSET - sizeof(struct udphdr) ? + ntohs(udp->len) : buffer_sz - UDP_START_OFFSET - sizeof(struct udphdr); + int dhcp_option_sz = dhcp_sz - DHCP_OPTIONS_HEADER_SIZE; + const u_char *dhcp_option = buffer + dhcp_option_offset; + + int offset = 0; + while ((offset < (dhcp_option_sz + 1)) && dhcp_option[offset] != 255) { + if (dhcp_option[offset] == OPTION_DHCP_MESSAGE_TYPE) { + if (offset < (dhcp_option_sz + 2)) { + handle_dhcp_option_53(context, &dhcp_option[offset], dir, iphdr, dhcphdr); } + break; // break while loop since we are only interested in Option 53 + } - if (stop_dhcp_processing == 1) { - break; - } + if (dhcp_option[offset] == 0) { // DHCP Option Padding + offset++; + } else { + offset += dhcp_option[offset + 1] + 2; + } + } + } else { + syslog(LOG_WARNING, "read_callback(%s %s): read length (%ld) is too small to capture DHCP options", + context->intf, dir == DHCP_TX ? "TX" : "RX", buffer_sz); + } +} - if (dhcp_option[offset] == 0) { // DHCP Option Padding - offset++; - } else { - offset += dhcp_option[offset + 1] + 2; - } +static dhcp_device_context_t *interface_to_dev_context(std::unordered_map *devices, + std::string ifname) +{ + auto vlan = vlan_map.find(ifname); + if (vlan != vlan_map.end()) { + if (dual_tor_sock) { + std::string state; + mStateDbMuxTablePtr->hget(ifname, "state", state); + if (state == "standby") { + return NULL; + } + } + return find_device_context(devices, vlan->second); + } else { + auto port_channel = portchan_map.find(ifname); + if (port_channel != portchan_map.end()) { + return find_device_context(devices, port_channel->second); + } + else { + // mgmt interface check + auto mgmt = mgmt_map.find(ifname); + if (mgmt != mgmt_map.end()) { + return find_device_context(devices, mgmt->second); } - } else { - syslog(LOG_WARNING, "read_callback(%s): read length (%ld) is too small to capture DHCP options", - context->intf, buffer_sz); } } + return NULL; } + /** - * @code read_callback_dual_tor(fd, event, arg); + * @code read_tx_callback(fd, event, arg); * - * @brief callback for libevent which is called every time out in order to read queued packet capture when dual tor mode is enabled + * @brief callback for libevent which is called every time out in order to read queued outgoing packet capture * * @param fd socket to read from * @param event libevent triggered event @@ -242,72 +350,59 @@ static void read_callback(int fd, short event, void *arg) * * @return none */ -static void read_callback_dual_tor(int fd, short event, void *arg) +static void read_tx_callback(int fd, short event, void *arg) { - dhcp_device_context_t *context = (dhcp_device_context_t*) arg; + auto devices = (std::unordered_map *)arg; ssize_t buffer_sz; struct sockaddr_ll sll; socklen_t slen = sizeof sll; + dhcp_device_context_t *context = NULL; - while ((event == EV_READ) && - ((buffer_sz = recvfrom(fd, context->buffer, context->snaplen, MSG_DONTWAIT, (struct sockaddr *)&sll, &slen)) > 0)) + while ((buffer_sz = recvfrom(fd, tx_recv_buffer, snap_length, MSG_DONTWAIT, (struct sockaddr *)&sll, &slen)) > 0) { - std::string member_table = std::string("VLAN_MEMBER|") + context->intf + "|"; char interfaceName[IF_NAMESIZE]; - char *interface = if_indextoname(sll.sll_ifindex, interfaceName); - std::string state; - std::string intf(interface); - mStateDbMuxTablePtr->hget(intf, "state", state); - if (state != "standby" && configDb.exists(member_table.append(interface))) { - struct ether_header *ethhdr = (struct ether_header*) context->buffer; - struct ip *iphdr = (struct ip*) (context->buffer + IP_START_OFFSET); - struct udphdr *udp = (struct udphdr*) (context->buffer + UDP_START_OFFSET); - uint8_t *dhcphdr = context->buffer + DHCP_START_OFFSET; - int dhcp_option_offset = DHCP_START_OFFSET + DHCP_OPTIONS_HEADER_SIZE; - - if (((unsigned)buffer_sz > UDP_START_OFFSET + sizeof(struct udphdr) + DHCP_OPTIONS_HEADER_SIZE) && - (ntohs(udp->len) > DHCP_OPTIONS_HEADER_SIZE)) - { - int dhcp_sz = ntohs(udp->len) < buffer_sz - UDP_START_OFFSET - sizeof(struct udphdr) ? - ntohs(udp->len) : buffer_sz - UDP_START_OFFSET - sizeof(struct udphdr); - int dhcp_option_sz = dhcp_sz - DHCP_OPTIONS_HEADER_SIZE; - const u_char *dhcp_option = context->buffer + dhcp_option_offset; - dhcp_packet_direction_t dir = (ethhdr->ether_shost[0] == context->mac[0] && - ethhdr->ether_shost[1] == context->mac[1] && - ethhdr->ether_shost[2] == context->mac[2] && - ethhdr->ether_shost[3] == context->mac[3] && - ethhdr->ether_shost[4] == context->mac[4] && - ethhdr->ether_shost[5] == context->mac[5]) ? - DHCP_TX : DHCP_RX; - int offset = 0; - int stop_dhcp_processing = 0; - while ((offset < (dhcp_option_sz + 1)) && dhcp_option[offset] != 255) { - switch (dhcp_option[offset]) - { - case 53: - if (offset < (dhcp_option_sz + 2)) { - handle_dhcp_option_53(context, &dhcp_option[offset], dir, iphdr, dhcphdr); - } - stop_dhcp_processing = 1; // break while loop since we are only interested in Option 53 - break; - default: - break; - } - - if (stop_dhcp_processing == 1) { - break; - } - - if (dhcp_option[offset] == 0) { // DHCP Option Padding - offset++; - } else { - offset += dhcp_option[offset + 1] + 2; - } - } - } else { - syslog(LOG_WARNING, "read_callback(%s): read length (%ld) is too small to capture DHCP options", - context->intf, buffer_sz); - } + if (if_indextoname(sll.sll_ifindex, interfaceName) == NULL) { + syslog(LOG_WARNING, "invalid output interface index %d\n", sll.sll_ifindex); + continue; + } + std::string intf(interfaceName); + context = find_device_context(devices, intf); + if (context) { + client_packet_handler(context, tx_recv_buffer, buffer_sz, DHCP_TX); + } + } +} + +/** + * @code read_rx_callback(fd, event, arg); + * + * @brief callback for libevent which is called every time out in order to read queued incoming packet capture + * + * @param fd socket to read from + * @param event libevent triggered event + * @param arg user provided argument for callback (interface context) + * + * @return none + */ +static void read_rx_callback(int fd, short event, void *arg) +{ + auto devices = (std::unordered_map *)arg; + ssize_t buffer_sz; + struct sockaddr_ll sll; + socklen_t slen = sizeof(sll); + dhcp_device_context_t *context = NULL; + + while ((buffer_sz = recvfrom(fd, rx_recv_buffer, snap_length, MSG_DONTWAIT, (struct sockaddr *)&sll, &slen)) > 0) + { + char interfaceName[IF_NAMESIZE]; + if (if_indextoname(sll.sll_ifindex, interfaceName) == NULL) { + syslog(LOG_WARNING, "invalid input interface index %d\n", sll.sll_ifindex); + continue; + } + std::string intf(interfaceName); + context = interface_to_dev_context(devices, intf); + if (context) { + client_packet_handler(context, rx_recv_buffer, buffer_sz, DHCP_RX); } } } @@ -480,46 +575,70 @@ static void dhcp_print_counters(const char *vlan_intf, } /** - * @code init_socket(context, intf); + * @code init_socket(); * - * @brief initializes socket, bind it to interface and bpf program, and - * associate with libevent base - * - * @param context pointer to device (interface) context - * @param intf interface name + * @brief initializes rx/tx sockets, bind it to interface and bpf program * * @return 0 on success, otherwise for failure */ -static int init_socket(dhcp_device_context_t *context, const char *intf) +static int init_socket() { int rv = -1; do { - context->sock = socket(AF_PACKET, SOCK_RAW | SOCK_NONBLOCK, htons(ETH_P_ALL)); - if (context->sock < 0) { + auto rx_sock = socket(AF_PACKET, SOCK_RAW | SOCK_NONBLOCK, htons(ETH_P_ALL)); + auto tx_sock = socket(AF_PACKET, SOCK_RAW | SOCK_NONBLOCK, htons(ETH_P_ALL)); + if (rx_sock < 0 || tx_sock < 0) { syslog(LOG_ALERT, "socket: failed to open socket with '%s'\n", strerror(errno)); - break; + exit(1); } - struct sockaddr_ll addr; - memset(&addr, 0, sizeof(addr)); - addr.sll_ifindex = 0; // any interface - addr.sll_family = AF_PACKET; - addr.sll_protocol = htons(ETH_P_ALL); - if (bind(context->sock, (struct sockaddr *) &addr, sizeof(addr))) { - syslog(LOG_ALERT, "bind: failed to bind to interface '%s' with '%s'\n", intf, strerror(errno)); + struct sockaddr_ll rx_addr; + memset(&rx_addr, 0, sizeof(rx_addr)); + rx_addr.sll_ifindex = 0; // any interface + rx_addr.sll_family = AF_PACKET; + rx_addr.sll_protocol = htons(ETH_P_ALL); + if (bind(rx_sock, (struct sockaddr *) &rx_addr, sizeof(rx_addr))) { + syslog(LOG_ALERT, "bind: failed to bind to all interface with '%s'\n", strerror(errno)); break; } - strncpy(context->intf, intf, sizeof(context->intf) - 1); - context->intf[sizeof(context->intf) - 1] = '\0'; + struct sockaddr_ll tx_addr; + memset(&tx_addr, 0, sizeof(tx_addr)); + tx_addr.sll_ifindex = 0; // any interface + tx_addr.sll_family = AF_PACKET; + tx_addr.sll_protocol = htons(ETH_P_ALL); + if (bind(tx_sock, (struct sockaddr *) &tx_addr, sizeof(tx_addr))) { + syslog(LOG_ALERT, "bind: failed to bind to interface with '%s'\n", strerror(errno)); + exit(1); + } + for (auto &itr : intfs) { + itr.second->dev_context->rx_sock = rx_sock; + itr.second->dev_context->tx_sock = tx_sock; + } rv = 0; } while (0); return rv; } +static void init_recv_buffers(int snaplen) +{ + snap_length = snaplen; + rx_recv_buffer = (uint8_t *) malloc(snaplen); + if (rx_recv_buffer == NULL) { + syslog(LOG_ALERT, "malloc: failed to allocate memory for socket rx buffer '%s'\n", strerror(errno)); + exit(1); + } + + tx_recv_buffer = (uint8_t *) malloc(snaplen); + if (tx_recv_buffer == NULL) { + syslog(LOG_ALERT, "malloc: failed to allocate memory for socket tx buffer '%s'\n", strerror(errno)); + exit(1); + } +} + /** * @code initialize_intf_mac_and_ip_addr(context); * @@ -611,16 +730,15 @@ int dhcp_device_init(dhcp_device_context_t **context, const char *intf, uint8_t dhcp_device_context_t *dev_context = NULL; if ((context != NULL) && (strlen(intf) < sizeof(dev_context->intf))) { - dev_context = (dhcp_device_context_t *) malloc(sizeof(dhcp_device_context_t)); if (dev_context != NULL) { - if ((init_socket(dev_context, intf) == 0) && - (initialize_intf_mac_and_ip_addr(dev_context) == 0)) { - + // set device name + strncpy(dev_context->intf, intf, sizeof(dev_context->intf) - 1); + dev_context->intf[sizeof(dev_context->intf) - 1] = '\0'; + // set device meta data + if (initialize_intf_mac_and_ip_addr(dev_context) == 0) { dev_context->is_uplink = is_uplink; - memset(dev_context->counters, 0, sizeof(dev_context->counters)); - *context = dev_context; rv = 0; } @@ -634,53 +752,62 @@ int dhcp_device_init(dhcp_device_context_t **context, const char *intf, uint8_t } /** - * @code dhcp_device_start_capture(context, snaplen, base, giaddr_ip); + * @code dhcp_device_start_capture(snaplen, base, giaddr_ip); * * @brief starts packet capture on this interface */ -int dhcp_device_start_capture(dhcp_device_context_t *context, - size_t snaplen, - struct event_base *base, - in_addr_t giaddr_ip) +int dhcp_device_start_capture(size_t snaplen, struct event_base *base, in_addr_t giaddr_ip) { int rv = -1; - struct event *ev; + struct event *rx_ev; + struct event *tx_ev; + int rx_sock = -1, tx_sock = -1; do { - if (context == NULL) { - syslog(LOG_ALERT, "NULL interface context pointer'\n"); - break; - } - if (snaplen < UDP_START_OFFSET + sizeof(struct udphdr) + DHCP_OPTIONS_HEADER_SIZE) { - syslog(LOG_ALERT, "dhcp_device_start_capture(%s): snap length is too low to capture DHCP options", context->intf); - break; + syslog(LOG_ALERT, "dhcp_device_start_capture: snap length is too low to capture DHCP options"); + exit(1); } - context->giaddr_ip = giaddr_ip; + init_socket(); - context->buffer = (uint8_t *) malloc(snaplen); - if (context->buffer == NULL) { - syslog(LOG_ALERT, "malloc: failed to allocate memory for socket buffer '%s'\n", strerror(errno)); - break; + init_recv_buffers(snaplen); + + update_vlan_mapping(mConfigDbPtr); + update_portchannel_mapping(mConfigDbPtr); + update_mgmt_mapping(); + + for (auto &itr : intfs) { + itr.second->dev_context->snaplen = snaplen; + itr.second->dev_context->giaddr_ip = giaddr_ip; + // all interface dev context has same rx/tx socket + rx_sock = itr.second->dev_context->rx_sock; + tx_sock = itr.second->dev_context->tx_sock; } - context->snaplen = snaplen; - if (setsockopt(context->sock, SOL_SOCKET, SO_ATTACH_FILTER, &dhcp_sock_bfp, sizeof(dhcp_sock_bfp)) != 0) { + if (rx_sock == -1 || tx_sock == -1) { + syslog(LOG_ALERT, "dhcp_device_start_capture: invalid rx_sock or tx_sock"); + exit(1); + } + if (setsockopt(rx_sock, SOL_SOCKET, SO_ATTACH_FILTER, &dhcp_inbound_sock_bfp, sizeof(dhcp_inbound_sock_bfp)) != 0) { syslog(LOG_ALERT, "setsockopt: failed to attach filter with '%s'\n", strerror(errno)); - break; + exit(1); } - if (dual_tor_sock) - ev = event_new(base, context->sock, EV_READ | EV_PERSIST, read_callback_dual_tor, context); - else - ev = event_new(base, context->sock, EV_READ | EV_PERSIST, read_callback, context); + if (setsockopt(tx_sock, SOL_SOCKET, SO_ATTACH_FILTER, &dhcp_outbound_sock_bfp, sizeof(dhcp_outbound_sock_bfp)) != 0) { + syslog(LOG_ALERT, "setsockopt: failed to attach filter with '%s'\n", strerror(errno)); + exit(1); + } + + rx_ev = event_new(base, rx_sock, EV_READ | EV_PERSIST, read_rx_callback, &intfs); + tx_ev = event_new(base, tx_sock, EV_READ | EV_PERSIST, read_tx_callback, &intfs); - if (ev == NULL) { + if (rx_ev == NULL || tx_ev == NULL) { syslog(LOG_ALERT, "event_new: failed to allocate memory for libevent event '%s'\n", strerror(errno)); - break; + exit(1); } - event_add(ev, NULL); + event_add(rx_ev, NULL); + event_add(tx_ev, NULL); rv = 0; } while (0); diff --git a/src/dhcpmon/src/dhcp_device.h b/src/dhcpmon/src/dhcp_device.h index a2b2a789fca6..cd8eab1ee7eb 100644 --- a/src/dhcpmon/src/dhcp_device.h +++ b/src/dhcpmon/src/dhcp_device.h @@ -17,6 +17,7 @@ #include extern bool dual_tor_sock; +extern std::unordered_map intfs; /** * DHCP message types @@ -35,6 +36,11 @@ typedef enum DHCP_MESSAGE_TYPE_COUNT } dhcp_message_type_t; +enum +{ + OPTION_DHCP_MESSAGE_TYPE = 53, +}; + /** packet direction */ typedef enum { @@ -71,13 +77,13 @@ typedef enum /** DHCP device (interface) context */ typedef struct { - int sock; /** Raw socket associated with this device/interface */ + int rx_sock; /** Raw socket associated with this device/interface to count rx packets */ + int tx_sock; /** Raw socket associated with this device/interface to count tx packets*/ in_addr_t ip; /** network address of this device (interface) */ uint8_t mac[ETHER_ADDR_LEN]; /** hardware address of this device (interface) */ in_addr_t giaddr_ip; /** Gateway IP address */ uint8_t is_uplink; /** north interface? */ char intf[IF_NAMESIZE]; /** device (interface) name */ - uint8_t *buffer; /** buffer used to read socket data */ size_t snaplen; /** snap length or buffer size */ uint64_t counters[DHCP_COUNTERS_COUNT][DHCP_DIR_COUNT][DHCP_MESSAGE_TYPE_COUNT]; /** current/snapshot counters of DHCP packets */ @@ -131,21 +137,17 @@ int dhcp_device_init(dhcp_device_context_t **context, uint8_t is_uplink); /** - * @code dhcp_device_start_capture(context, snaplen, base, giaddr_ip); + * @code dhcp_device_start_capture(snaplen, base, giaddr_ip); * * @brief starts packet capture on this interface * - * @param context pointer to device (interface) context * @param snaplen length of packet capture * @param base pointer to libevent base * @param giaddr_ip gateway IP address * * @return 0 on success, otherwise for failure */ -int dhcp_device_start_capture(dhcp_device_context_t *context, - size_t snaplen, - struct event_base *base, - in_addr_t giaddr_ip); +int dhcp_device_start_capture(size_t snaplen, struct event_base *base, in_addr_t giaddr_ip); /** * @code dhcp_device_shutdown(context); diff --git a/src/dhcpmon/src/dhcp_devman.cpp b/src/dhcpmon/src/dhcp_devman.cpp index b215f978a7c4..0fa490d138bd 100644 --- a/src/dhcpmon/src/dhcp_devman.cpp +++ b/src/dhcpmon/src/dhcp_devman.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include "dhcp_devman.h" @@ -15,17 +14,8 @@ /** Prefix appended to Aggregation device */ #define AGG_DEV_PREFIX "Agg-" -/** struct for interface information */ -struct intf -{ - const char *name; /** interface name */ - uint8_t is_uplink; /** is uplink (north) interface */ - dhcp_device_context_t *dev_context; /** device (interface_ context */ - LIST_ENTRY(intf) entry; /** list link/pointers entries */ -}; - -/** intfs list of interfaces */ -static LIST_HEAD(intf_list, intf) intfs; +/** intfs map of interfaces */ +std::unordered_map intfs; /** dhcp_num_south_intf number of south interfaces */ static uint32_t dhcp_num_south_intf = 0; /** dhcp_num_north_intf number of north interfaces */ @@ -66,17 +56,6 @@ dhcp_device_context_t* dhcp_devman_get_mgmt_dev() return mgmt_intf ? mgmt_intf->dev_context : NULL; } -/** - * @code dhcp_devman_init(); - * - * initializes device (interface) manager that keeps track of interfaces and assert that there is one south - * interface and as many north interfaces - */ -void dhcp_devman_init() -{ - LIST_INIT(&intfs); -} - /** * @code dhcp_devman_shutdown(); * @@ -85,20 +64,11 @@ void dhcp_devman_init() */ void dhcp_devman_shutdown() { - struct intf *int_ptr, *prev_intf = NULL; - - LIST_FOREACH(int_ptr, &intfs, entry) { - dhcp_device_shutdown(int_ptr->dev_context); - if (prev_intf) { - LIST_REMOVE(prev_intf, entry); - free(prev_intf); - prev_intf = int_ptr; - } - } - - if (prev_intf) { - LIST_REMOVE(prev_intf, entry); - free(prev_intf); + for (auto it = intfs.begin(); it != intfs.end();) { + auto inf = it->second; + dhcp_device_shutdown(inf->dev_context); + it = intfs.erase(it); + free(inf); } } @@ -140,12 +110,14 @@ int dhcp_devman_add_intf(const char *name, char intf_type) dhcp_device_context_t *agg_dev = dhcp_device_get_aggregate_context(); - strncpy(agg_dev->intf, AGG_DEV_PREFIX, sizeof(AGG_DEV_PREFIX)); - strncpy(agg_dev->intf + sizeof(AGG_DEV_PREFIX) - 1, name, sizeof(agg_dev->intf) - sizeof(AGG_DEV_PREFIX)); + strncpy(agg_dev->intf, AGG_DEV_PREFIX, strlen(AGG_DEV_PREFIX) + 1); + strncpy(agg_dev->intf + strlen(AGG_DEV_PREFIX), name, sizeof(agg_dev->intf) - strlen(AGG_DEV_PREFIX) - 1); agg_dev->intf[sizeof(agg_dev->intf) - 1] = '\0'; + syslog(LOG_INFO, "dhcpmon add aggregate interface '%s'\n", agg_dev->intf); } - - LIST_INSERT_HEAD(&intfs, dev, entry); + std::string if_name; + if_name.assign(dev->name); + intfs[if_name] = dev; } else { syslog(LOG_ALERT, "malloc: failed to allocate memory for intf '%s'\n", name); @@ -193,21 +165,12 @@ int dhcp_devman_setup_dual_tor_mode(const char *name) int dhcp_devman_start_capture(size_t snaplen, struct event_base *base) { int rv = -1; - struct intf *int_ptr; if ((dhcp_num_south_intf == 1) && (dhcp_num_north_intf >= 1)) { - LIST_FOREACH(int_ptr, &intfs, entry) { - rv = dhcp_device_start_capture(int_ptr->dev_context, snaplen, base, dual_tor_mode ? loopback_ip : vlan_ip); - if (rv == 0) { - syslog(LOG_INFO, - "Capturing DHCP packets on interface %s, ip: 0x%08x, mac [%02x:%02x:%02x:%02x:%02x:%02x] \n", - int_ptr->name, int_ptr->dev_context->ip, int_ptr->dev_context->mac[0], - int_ptr->dev_context->mac[1], int_ptr->dev_context->mac[2], int_ptr->dev_context->mac[3], - int_ptr->dev_context->mac[4], int_ptr->dev_context->mac[5]); - } - else { - break; - } + rv = dhcp_device_start_capture(snaplen, base, dual_tor_mode ? loopback_ip : vlan_ip); + if (rv != 0) { + syslog(LOG_ALERT, "Capturing DHCP packets on interface failed"); + exit(1); } } else { @@ -236,12 +199,9 @@ dhcp_mon_status_t dhcp_devman_get_status(dhcp_mon_check_t check_type, dhcp_devic void dhcp_devman_update_snapshot(dhcp_device_context_t *context) { if (context == NULL) { - struct intf *int_ptr; - - LIST_FOREACH(int_ptr, &intfs, entry) { - dhcp_device_update_snapshot(int_ptr->dev_context); + for (auto &itr : intfs) { + dhcp_device_update_snapshot(itr.second->dev_context); } - dhcp_device_update_snapshot(dhcp_devman_get_agg_dev()); } else { dhcp_device_update_snapshot(context); @@ -256,12 +216,9 @@ void dhcp_devman_update_snapshot(dhcp_device_context_t *context) void dhcp_devman_print_status(dhcp_device_context_t *context, dhcp_counters_type_t type) { if (context == NULL) { - struct intf *int_ptr; - - LIST_FOREACH(int_ptr, &intfs, entry) { - dhcp_device_print_status(int_ptr->dev_context, type); + for (auto &itr : intfs) { + dhcp_device_print_status(itr.second->dev_context, type); } - dhcp_device_print_status(dhcp_devman_get_agg_dev(), type); } else { dhcp_device_print_status(context, type); diff --git a/src/dhcpmon/src/dhcp_devman.h b/src/dhcpmon/src/dhcp_devman.h index 948e79cde4f4..d1c80cf30e9f 100644 --- a/src/dhcpmon/src/dhcp_devman.h +++ b/src/dhcpmon/src/dhcp_devman.h @@ -8,9 +8,19 @@ #define DHCP_DEVMAN_H_ #include +#include +#include #include "dhcp_device.h" +/** struct for interface information */ +struct intf +{ + const char *name; /** interface name */ + uint8_t is_uplink; /** is uplink (north) interface */ + dhcp_device_context_t *dev_context; /** device (interface_ context */ +}; + /** * @code dhcp_devman_init(); * diff --git a/src/dhcpmon/src/dhcp_mon.cpp b/src/dhcpmon/src/dhcp_mon.cpp index 4860b2b06a55..66f2001b6e27 100644 --- a/src/dhcpmon/src/dhcp_mon.cpp +++ b/src/dhcpmon/src/dhcp_mon.cpp @@ -30,6 +30,8 @@ typedef struct static int window_interval_sec = 18; /** dhcp_unhealthy_max_count max count of consecutive unhealthy statuses before reporting to syslog */ static int dhcp_unhealthy_max_count = 10; +/** dhcpmon debug mode control flag */ +static bool debug_on = false; /** libevent base struct */ static struct event_base *base; /** libevent timeout event struct */ @@ -99,7 +101,7 @@ static void check_dhcp_relay_health(dhcp_mon_state_t *state_data) case DHCP_MON_STATUS_UNHEALTHY: if (++state_data->count > dhcp_unhealthy_max_count) { auto duration = state_data->count * window_interval_sec; - std::string vlan(context->intf); + std::string vlan(context->intf); syslog(LOG_ALERT, state_data->msg, duration, context->intf); if (state_data->check_type == DHCP_MON_CHECK_POSITIVE) { event_params_t params = { @@ -143,6 +145,11 @@ static void timeout_callback(evutil_socket_t fd, short event, void *arg) } dhcp_devman_update_snapshot(NULL); + + if (debug_on) { + dhcp_devman_print_status(NULL, DHCP_COUNTERS_SNAPSHOT); + dhcp_devman_print_status(NULL, DHCP_COUNTERS_CURRENT); + } } /** @@ -221,13 +228,14 @@ void dhcp_mon_shutdown() } /** - * @code dhcp_mon_start(snaplen); + * @code dhcp_mon_start(snaplen, debug_mode); * * @brief start monitoring DHCP Relay */ -int dhcp_mon_start(size_t snaplen) +int dhcp_mon_start(size_t snaplen, bool debug_mode) { int rv = -1; + debug_on = debug_mode; do { @@ -260,7 +268,6 @@ int dhcp_mon_start(size_t snaplen) syslog(LOG_ERR, "Could not start libevent dispatching loop!\n"); break; } - rv = 0; } while (0); diff --git a/src/dhcpmon/src/dhcp_mon.h b/src/dhcpmon/src/dhcp_mon.h index ae8911ab51fc..5bae01f5962b 100644 --- a/src/dhcpmon/src/dhcp_mon.h +++ b/src/dhcpmon/src/dhcp_mon.h @@ -32,15 +32,16 @@ int dhcp_mon_init(int window_sec, int max_count); void dhcp_mon_shutdown(); /** - * @code dhcp_mon_start(snaplen); + * @code dhcp_mon_start(snaplen, debug); * * @brief start monitoring DHCP Relay * * @param snaplen packet capture length + * @param debug turn on debug or not * * @return 0 upon success, otherwise upon failure */ -int dhcp_mon_start(size_t snaplen); +int dhcp_mon_start(size_t snaplen, bool debug); /** * @code dhcp_mon_stop(); diff --git a/src/dhcpmon/src/main.cpp b/src/dhcpmon/src/main.cpp index aefaea2d01dd..e660bbd908a9 100644 --- a/src/dhcpmon/src/main.cpp +++ b/src/dhcpmon/src/main.cpp @@ -46,7 +46,7 @@ bool dual_tor_sock = false; static void usage(const char *prog) { printf("Usage: %s -id {-iu }+ -im [-u ]" - "[-w ] [-c ] [-s ] [-d]\n", prog); + "[-w ] [-c ] [-s ] [-D] [-d]\n", prog); printf("where\n"); printf("\tsouth interface: is a vlan interface,\n"); printf("\tnorth interface: is a TOR-T1 interface,\n"); @@ -57,6 +57,7 @@ static void usage(const char *prog) "(default %d),\n", dhcpmon_default_unhealthy_max_count); printf("\tsnap length: snap length of packet capture (default %ld),\n", dhcpmon_default_snaplen); + printf("\t-D: debug mode: print counter to syslog\n"); printf("\t-d: daemonize %s.\n", prog); exit(EXIT_SUCCESS); @@ -117,12 +118,11 @@ int main(int argc, char **argv) int max_unhealthy_count = dhcpmon_default_unhealthy_max_count; size_t snaplen = dhcpmon_default_snaplen; int make_daemon = 0; + bool debug_mode = false; setlogmask(LOG_UPTO(LOG_INFO)); openlog(basename(argv[0]), LOG_CONS | LOG_PID | LOG_NDELAY, LOG_DAEMON); - dhcp_devman_init(); - for (i = 1; i < argc;) { if ((argv[i] == NULL) || (argv[i][0] != '-')) { break; @@ -161,6 +161,10 @@ int main(int argc, char **argv) max_unhealthy_count = atoi(argv[i + 1]); i += 2; break; + case 'D': + debug_mode = true; + i += 1; + break; default: fprintf(stderr, "%s: %c: Unknown option\n", basename(argv[0]), argv[i][1]); usage(basename(argv[0])); @@ -172,7 +176,7 @@ int main(int argc, char **argv) } if ((dhcp_mon_init(window_interval, max_unhealthy_count) == 0) && - (dhcp_mon_start(snaplen) == 0)) { + (dhcp_mon_start(snaplen, debug_mode) == 0)) { rv = EXIT_SUCCESS; diff --git a/src/dhcprelay b/src/dhcprelay index 9c3b73837f76..67a3bdf12e7d 160000 --- a/src/dhcprelay +++ b/src/dhcprelay @@ -1 +1 @@ -Subproject commit 9c3b73837f768b3220d68ed01030d204c650d476 +Subproject commit 67a3bdf12e7d24260bf114c46da033e2be5f57cd diff --git a/src/libteam/patch/0008-libteam-Add-warm_reboot-mode.patch b/src/libteam/patch/0008-libteam-Add-warm_reboot-mode.patch index 4ef38ee138f3..397ee8565961 100644 --- a/src/libteam/patch/0008-libteam-Add-warm_reboot-mode.patch +++ b/src/libteam/patch/0008-libteam-Add-warm_reboot-mode.patch @@ -5,12 +5,13 @@ Subject: [PATCH] [libteam]: Reimplement Warm-Reboot procedure' --- libteam/ifinfo.c | 6 +- + libteam/ports.c | 19 +- teamd/teamd.c | 51 +++- teamd/teamd.h | 6 + teamd/teamd_events.c | 13 ++ teamd/teamd_per_port.c | 6 + teamd/teamd_runner_lacp.c | 475 +++++++++++++++++++++++++++++++++++--- - 6 files changed, 513 insertions(+), 44 deletions(-) + 7 files changed, 530 insertions(+), 46 deletions(-) diff --git a/libteam/ifinfo.c b/libteam/ifinfo.c index 46d56a2..b86d34c 100644 @@ -34,6 +35,58 @@ index 46d56a2..b86d34c 100644 set_changed(ifinfo, CHANGED_HWADDR); } } +diff --git a/libteam/ports.c b/libteam/ports.c +index 9ebf30f..0bd7cc0 100644 +--- a/libteam/ports.c ++++ b/libteam/ports.c +@@ -128,6 +128,12 @@ int get_port_list_handler(struct nl_msg *msg, void *arg) + struct nlattr *port_attrs[TEAM_ATTR_PORT_MAX + 1]; + int i; + uint32_t team_ifindex = 0; ++ /* ++ * In case get_port_list is being called from check_call_change_handlers recursively, ++ * there can be some attributes which have not been consumed by callbacks. ++ * In this case, we should only merge the new attributes into the existing ones without clearing them ++ */ ++ bool recursive = (th->change_handler.pending_type_mask & TEAM_PORT_CHANGE) ? true : false; + + genlmsg_parse(nlh, 0, attrs, TEAM_ATTR_MAX, NULL); + if (attrs[TEAM_ATTR_TEAM_IFINDEX]) +@@ -140,7 +146,8 @@ int get_port_list_handler(struct nl_msg *msg, void *arg) + return NL_SKIP; + + if (!th->msg_recv_started) { +- port_list_cleanup_last_state(th); ++ if (!recursive) ++ port_list_cleanup_last_state(th); + th->msg_recv_started = true; + } + nla_for_each_nested(nl_port, attrs[TEAM_ATTR_LIST_PORT], i) { +@@ -165,7 +172,9 @@ int get_port_list_handler(struct nl_msg *msg, void *arg) + if (!port) + return NL_SKIP; + } +- port->changed = port_attrs[TEAM_ATTR_PORT_CHANGED] ? true : false; ++ ++ if (!port->changed || !recursive) ++ port->changed = port_attrs[TEAM_ATTR_PORT_CHANGED] ? true : false; + port->linkup = port_attrs[TEAM_ATTR_PORT_LINKUP] ? true : false; + port->removed = port_attrs[TEAM_ATTR_PORT_REMOVED] ? true : false; + if (port_attrs[TEAM_ATTR_PORT_SPEED]) +@@ -196,6 +204,13 @@ static int get_port_list(struct team_handle *th) + if (err) + return err; + ++ /* ++ * Do not call check_call_change_handlers if this is called recursively to avoid racing conditions ++ * It will be called by the outer call ++ */ ++ if (th->change_handler.pending_type_mask & TEAM_PORT_CHANGE) ++ return 0; ++ + return check_call_change_handlers(th, TEAM_PORT_CHANGE); + + nla_put_failure: diff --git a/teamd/teamd.c b/teamd/teamd.c index 421e34d..33512a6 100644 --- a/teamd/teamd.c @@ -881,5 +934,5 @@ index 955ef0c..782fc05 100644 const struct teamd_runner teamd_runner_lacp = { -- -2.17.1 +2.30.2 diff --git a/src/libteam/patch/0013-set-port-to-disabled-state-during-removal.patch b/src/libteam/patch/0013-set-port-to-disabled-state-during-removal.patch new file mode 100644 index 000000000000..8341a53572e1 --- /dev/null +++ b/src/libteam/patch/0013-set-port-to-disabled-state-during-removal.patch @@ -0,0 +1,108 @@ +From fd26b370d85d63cca0736d7e666736bb15c395aa Mon Sep 17 00:00:00 2001 +From: Jiri Pirko +Date: Wed, 7 Dec 2022 10:44:35 +0100 +Subject: [PATCH] teamd: lacp: set port to disabled state during removal + +Currently, the disabled state is set only after port is removed from +team master in kernel. Team driver puts the port netdevice down right +away. In some cases, there is nice to send LACPDU to the partner with +flags set accordingly for the disabled port. + +Introduce "port_removing" op and call it right before kernel +is asked to remove the port. Implement the op in LACP runner +to disable the port which leads to proper LACPDU send. + +Signed-off-by: Jiri Pirko +--- + teamd/teamd.h | 4 ++++ + teamd/teamd_events.c | 12 ++++++++++++ + teamd/teamd_per_port.c | 1 + + teamd/teamd_runner_lacp.c | 12 ++++++++++++ + 4 files changed, 29 insertions(+) +diff --git a/teamd/teamd.h b/teamd/teamd.h +index 701a6a4..d1d0f7f 100644 +--- a/teamd/teamd.h ++++ b/teamd/teamd.h +@@ -183,6 +183,8 @@ struct teamd_event_watch_ops { + int (*admin_state_changed)(struct teamd_context *ctx, void *priv); + int (*port_added)(struct teamd_context *ctx, + struct teamd_port *tdport, void *priv); ++ void (*port_removing)(struct teamd_context *ctx, ++ struct teamd_port *tdport, void *priv); + void (*port_removed)(struct teamd_context *ctx, + struct teamd_port *tdport, void *priv); + int (*port_changed)(struct teamd_context *ctx, +@@ -209,6 +211,8 @@ void teamd_refresh_ports(struct teamd_context *ctx); + void teamd_ports_flush_data(struct teamd_context *ctx); + int teamd_event_port_added(struct teamd_context *ctx, + struct teamd_port *tdport); ++void teamd_event_port_removing(struct teamd_context *ctx, ++ struct teamd_port *tdport); + void teamd_event_port_removed(struct teamd_context *ctx, + struct teamd_port *tdport); + int teamd_event_port_changed(struct teamd_context *ctx, +diff --git a/teamd/teamd_events.c b/teamd/teamd_events.c +index bd4dcc1..ff39990 100644 +--- a/teamd/teamd_events.c ++++ b/teamd/teamd_events.c +@@ -76,6 +76,18 @@ int teamd_event_port_added(struct teamd_context *ctx, + return 0; + } + ++void teamd_event_port_removing(struct teamd_context *ctx, ++ struct teamd_port *tdport) ++{ ++ struct event_watch_item *watch; ++ ++ list_for_each_node_entry(watch, &ctx->event_watch_list, list) { ++ if (!watch->ops->port_removing) ++ continue; ++ watch->ops->port_removing(ctx, tdport, watch->priv); ++ } ++} ++ + void teamd_event_port_removed(struct teamd_context *ctx, + struct teamd_port *tdport) + { +diff --git a/teamd/teamd_per_port.c b/teamd/teamd_per_port.c +index cefd6c2..68fc553 100644 +--- a/teamd/teamd_per_port.c ++++ b/teamd/teamd_per_port.c +@@ -358,6 +358,7 @@ static int teamd_port_remove(struct teamd_context *ctx, + + teamd_log_dbg(ctx, "%s: Removing port (found ifindex \"%d\").", + tdport->ifname, tdport->ifindex); ++ teamd_event_port_removing(ctx, tdport); + err = team_port_remove(ctx->th, tdport->ifindex); + if (err) + teamd_log_err("%s: Failed to remove port.", tdport->ifname); +diff --git a/teamd/teamd_runner_lacp.c b/teamd/teamd_runner_lacp.c +index 82b8b86..89f462a 100644 +--- a/teamd/teamd_runner_lacp.c ++++ b/teamd/teamd_runner_lacp.c +@@ -1779,6 +1779,17 @@ static int lacp_event_watch_port_added(struct teamd_context *ctx, + return teamd_balancer_port_added(lacp->tb, tdport); + } + ++static void lacp_event_watch_port_removing(struct teamd_context *ctx, ++ struct teamd_port *tdport, void *priv) ++{ ++ struct lacp *lacp = priv; ++ struct lacp_port *lacp_port = lacp_port_get(lacp, tdport); ++ ++ /* Ensure that no incoming LACPDU is going to be processed. */ ++ teamd_loop_callback_disable(ctx, LACP_SOCKET_CB_NAME, lacp_port); ++ lacp_port_set_state(lacp_port, PORT_STATE_DISABLED); ++} ++ + static void lacp_event_watch_port_removed(struct teamd_context *ctx, + struct teamd_port *tdport, void *priv) + { +@@ -1845,6 +1856,7 @@ static const struct teamd_event_watch_ops lacp_event_watch_ops = { + .hwaddr_changed = lacp_event_watch_hwaddr_changed, + .port_hwaddr_changed = lacp_event_watch_port_hwaddr_changed, + .port_added = lacp_event_watch_port_added, ++ .port_removing = lacp_event_watch_port_removing, + .port_removed = lacp_event_watch_port_removed, + .port_changed = lacp_event_watch_port_changed, + .admin_state_changed = lacp_event_watch_admin_state_changed, diff --git a/src/libteam/patch/0014-dont-move-the-port-state-from-disabled-when-admin-state-is-down.patch b/src/libteam/patch/0014-dont-move-the-port-state-from-disabled-when-admin-state-is-down.patch new file mode 100644 index 000000000000..82637529fcb3 --- /dev/null +++ b/src/libteam/patch/0014-dont-move-the-port-state-from-disabled-when-admin-state-is-down.patch @@ -0,0 +1,32 @@ +From 23ab49c4df0c06eb629ce2e3bb4c4dd7c527975a Mon Sep 17 00:00:00 2001 +From: Jiri Pirko +Date: Thu, 2 Feb 2023 17:00:51 +0100 +Subject: [PATCH] teamd: lacp: don't move the port state from disabled when + admin state is down + +When the team admin state is down, the port should stay in disabled +state, no matter what's happening. So check the admin state and bail out +in that case. + +Signed-off-by: Jiri Pirko +--- + teamd/teamd_runner_lacp.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/teamd/teamd_runner_lacp.c b/teamd/teamd_runner_lacp.c +index 51c7714..a76c372 100644 +--- a/teamd/teamd_runner_lacp.c ++++ b/teamd/teamd_runner_lacp.c +@@ -956,9 +956,11 @@ static int lacpdu_send(struct lacp_port *lacp_port); + static int lacp_port_set_state(struct lacp_port *lacp_port, + enum lacp_port_state new_state) + { ++ bool admin_state = team_get_ifinfo_admin_state(lacp_port->ctx->ifinfo); + int err; + +- if (new_state == lacp_port->state) ++ if (new_state == lacp_port->state || ++ (!admin_state && new_state != PORT_STATE_DISABLED)) + return 0; + if (new_state == PORT_STATE_DISABLED) + lacp_port_periodic_off(lacp_port); diff --git a/src/libteam/patch/series b/src/libteam/patch/series index cd7522918f43..f47ee9c06a3f 100644 --- a/src/libteam/patch/series +++ b/src/libteam/patch/series @@ -10,3 +10,5 @@ 0010-When-read-of-timerfd-returned-0-don-t-consider-this-.patch 0011-Remove-extensive-debug-output.patch 0012-Increase-min_ports-upper-limit-to-1024.patch +0013-set-port-to-disabled-state-during-removal.patch +0014-dont-move-the-port-state-from-disabled-when-admin-state-is-down.patch diff --git a/src/linkmgrd b/src/linkmgrd index b3501d27daa1..1c755c492053 160000 --- a/src/linkmgrd +++ b/src/linkmgrd @@ -1 +1 @@ -Subproject commit b3501d27daa12760e3203c66ea757800d7fe5102 +Subproject commit 1c755c492053a6cfc203b2d0fe08ac4683fadef3 diff --git a/src/sonic-bgpcfgd/bgpcfgd/managers_rm.py b/src/sonic-bgpcfgd/bgpcfgd/managers_rm.py index 08609c68f9a6..35a3f864d55c 100644 --- a/src/sonic-bgpcfgd/bgpcfgd/managers_rm.py +++ b/src/sonic-bgpcfgd/bgpcfgd/managers_rm.py @@ -1,8 +1,9 @@ from .manager import Manager +from swsscommon import swsscommon from .log import log_err, log_debug ROUTE_MAPS = ["FROM_SDN_SLB_ROUTES"] - +FROM_SDN_SLB_DEPLOYMENT_ID = '2' class RouteMapMgr(Manager): """This class add route-map when BGP_PROFILE_TABLE in APPL_DB is updated""" @@ -71,8 +72,28 @@ def __del_handler_validate(self, key): return False return True + def __read_asn(self): + if not 'deployment_id_asn_map' in self.constants: + log_err("BGPRouteMapMgr:: 'deployment_id_asn_map' key is not found in constants") + return None + if FROM_SDN_SLB_DEPLOYMENT_ID in self.constants['deployment_id_asn_map']: + return self.constants['deployment_id_asn_map'][FROM_SDN_SLB_DEPLOYMENT_ID] + log_err("BGPRouteMapMgr:: deployment id %s is not found in constants" % (FROM_SDN_SLB_DEPLOYMENT_ID)) + return None + def __update_rm(self, rm, data): - cmds = ["route-map %s permit 100" % ("%s_RM" % rm), " set community %s" % data["community_id"]] - log_debug("BGPRouteMapMgr:: update route-map %s community %s" % ("%s_RM" % rm, data["community_id"])) - self.cfg_mgr.push_list(cmds) + cmds = [] + if rm == "FROM_SDN_SLB_ROUTES": + cmds.append("route-map %s permit 100" % ("%s_RM" % rm)) + bgp_asn = self.__read_asn() + if bgp_asn is None or bgp_asn is '': + log_debug("BGPRouteMapMgr:: update route-map %s, but asn is not found in constants" % ("%s_RM" % rm)) + return + cmds.append(" set as-path prepend %s %s" % (bgp_asn, bgp_asn)) + cmds.append(" set community %s" % data["community_id"]) + cmds.append(" set origin incomplete") + log_debug("BGPRouteMapMgr:: update route-map %s community %s origin incomplete as-path prepend %s %s" % \ + ("%s_RM" % rm, data["community_id"], bgp_asn, bgp_asn)) + if cmds: + self.cfg_mgr.push_list(cmds) log_debug("BGPRouteMapMgr::Done") diff --git a/src/sonic-bgpcfgd/bgpcfgd/static_rt_timer.py b/src/sonic-bgpcfgd/bgpcfgd/static_rt_timer.py index 0af4bc26d040..a0e7d041382a 100644 --- a/src/sonic-bgpcfgd/bgpcfgd/static_rt_timer.py +++ b/src/sonic-bgpcfgd/bgpcfgd/static_rt_timer.py @@ -12,17 +12,19 @@ def __init__(self): DEFAULT_TIMER = 180 DEFAULT_SLEEP = 60 - MAX_TIMER = 1800 + # keep same range as value defined in sonic-restapi/sonic_api.yaml + MAX_TIMER = 172800 def set_timer(self): - """ Check for custom route expiry time in STATIC_ROUTE:EXPIRY_TIME """ + """ Check for custom route expiry time in STATIC_ROUTE_EXPIRY_TIME """ timer = self.db.get(self.db.APPL_DB, "STATIC_ROUTE_EXPIRY_TIME", "time") if timer is not None: - timer = int(timer) - if timer > 0 and timer <= self.MAX_TIMER: - self.timer = timer - return - log_err("Custom static route expiry time of {}s is invalid!".format(timer)) + if timer.isdigit(): + timer = int(timer) + if timer > 0 and timer <= self.MAX_TIMER: + self.timer = timer + return + log_err("Custom static route expiry time of {}s is invalid!".format(timer)) return def alarm(self): @@ -54,4 +56,5 @@ def run(self): else: time.sleep(self.DEFAULT_SLEEP) if time.time() - self.start >= self.DEFAULT_TIMER: - self.alarm() \ No newline at end of file + self.alarm() + diff --git a/src/sonic-bgpcfgd/tests/data/voq_chassis/peer-group.conf/result_all.conf b/src/sonic-bgpcfgd/tests/data/voq_chassis/peer-group.conf/result_all.conf index 1ec1cffed952..cf5020ee49f8 100644 --- a/src/sonic-bgpcfgd/tests/data/voq_chassis/peer-group.conf/result_all.conf +++ b/src/sonic-bgpcfgd/tests/data/voq_chassis/peer-group.conf/result_all.conf @@ -16,8 +16,8 @@ neighbor VOQ_CHASSIS_V6_PEER activate neighbor VOQ_CHASSIS_V6_PEER addpath-tx-all-paths neighbor VOQ_CHASSIS_V6_PEER soft-reconfiguration inbound - neighbor VOQ_CHASSIS_V4_PEER route-map FROM_VOQ_CHASSIS_V6_PEER in - neighbor VOQ_CHASSIS_V4_PEER route-map TO_VOQ_CHASSIS_V6_PEER out + neighbor VOQ_CHASSIS_V6_PEER route-map FROM_VOQ_CHASSIS_V6_PEER in + neighbor VOQ_CHASSIS_V6_PEER route-map TO_VOQ_CHASSIS_V6_PEER out exit-address-family ! ! end of template: bgpd/templates/voq_chassis/peer-group.conf.j2 diff --git a/src/sonic-bgpcfgd/tests/data/voq_chassis/peer-group.conf/result_base.conf b/src/sonic-bgpcfgd/tests/data/voq_chassis/peer-group.conf/result_base.conf index a8f7a0eea528..61813254acc2 100644 --- a/src/sonic-bgpcfgd/tests/data/voq_chassis/peer-group.conf/result_base.conf +++ b/src/sonic-bgpcfgd/tests/data/voq_chassis/peer-group.conf/result_base.conf @@ -14,8 +14,8 @@ neighbor VOQ_CHASSIS_V6_PEER activate neighbor VOQ_CHASSIS_V6_PEER addpath-tx-all-paths neighbor VOQ_CHASSIS_V6_PEER soft-reconfiguration inbound - neighbor VOQ_CHASSIS_V4_PEER route-map FROM_VOQ_CHASSIS_V6_PEER in - neighbor VOQ_CHASSIS_V4_PEER route-map TO_VOQ_CHASSIS_V6_PEER out + neighbor VOQ_CHASSIS_V6_PEER route-map FROM_VOQ_CHASSIS_V6_PEER in + neighbor VOQ_CHASSIS_V6_PEER route-map TO_VOQ_CHASSIS_V6_PEER out exit-address-family ! ! end of template: bgpd/templates/voq_chassis/peer-group.conf.j2 diff --git a/src/sonic-bgpcfgd/tests/test_rm.py b/src/sonic-bgpcfgd/tests/test_rm.py index fe89055d27f4..867ae1a7a51c 100644 --- a/src/sonic-bgpcfgd/tests/test_rm.py +++ b/src/sonic-bgpcfgd/tests/test_rm.py @@ -3,13 +3,23 @@ from bgpcfgd.managers_rm import RouteMapMgr from swsscommon import swsscommon + +test_rm_constants = { + "deployment_id_asn_map": { + "1": 12345, + "2": 12346, + "3": 12347, + "4": 12348, + } +} + def constructor(): cfg_mgr = MagicMock() common_objs = { 'directory': Directory(), 'cfg_mgr': cfg_mgr, - 'constants': {}, + 'constants': test_rm_constants, } mgr = RouteMapMgr(common_objs, "APPL_DB", "BGP_PROFILE_TABLE") @@ -47,7 +57,9 @@ def test_set_del(): True, [ ["route-map FROM_SDN_SLB_ROUTES_RM permit 100", - " set community 1234:1234"] + " set as-path prepend 12346 12346", + " set community 1234:1234", + " set origin incomplete"] ] ) diff --git a/src/sonic-build-hooks/Makefile b/src/sonic-build-hooks/Makefile index 786af9056332..b45be9dd07f6 100644 --- a/src/sonic-build-hooks/Makefile +++ b/src/sonic-build-hooks/Makefile @@ -21,7 +21,7 @@ DPKGTOOL = $(shell which dpkg-deb) ifeq ($(shell which dpkg-deb),) BUILD_COMMAND=docker run --user $(shell id -u):$(shell id -g) --rm -v $(shell pwd):/build debian:buster bash -c 'cd /build; dpkg-deb --build $(TMP_DIR)/$(SONIC_BUILD_HOOKS) $(SONIC_BUILD_HOOKS_TARGET)' else -BUILD_COMMAND=dpkg-deb --build $(TMP_DIR)/$(SONIC_BUILD_HOOKS) $(SONIC_BUILD_HOOKS_TARGET) +BUILD_COMMAND=dpkg-deb -Zxz --build $(TMP_DIR)/$(SONIC_BUILD_HOOKS) $(SONIC_BUILD_HOOKS_TARGET) endif DEPENDS := $(shell find scripts hooks debian -type f) diff --git a/src/sonic-build-hooks/scripts/buildinfo_base.sh b/src/sonic-build-hooks/scripts/buildinfo_base.sh index ff249dfdfb91..965edb4055e6 100755 --- a/src/sonic-build-hooks/scripts/buildinfo_base.sh +++ b/src/sonic-build-hooks/scripts/buildinfo_base.sh @@ -11,10 +11,19 @@ POST_VERSION_PATH=$BUILDINFO_PATH/post-versions VERSION_DEB_PREFERENCE=$BUILDINFO_PATH/versions/01-versions-deb WEB_VERSION_FILE=$VERSION_PATH/versions-web BUILD_WEB_VERSION_FILE=$BUILD_VERSION_PATH/versions-web -REPR_MIRROR_URL_PATTERN='http:\/\/packages.trafficmanager.net\/debian' +REPR_MIRROR_URL_PATTERN='http:\/\/packages.trafficmanager.net\/' DPKG_INSTALLTION_LOCK_FILE=/tmp/.dpkg_installation.lock . $BUILDINFO_PATH/config/buildinfo.config +if [ -e /vcache ]; then + PKG_CACHE_PATH=/vcache/${IMAGENAME} +else + PKG_CACHE_PATH=/sonic/target/vcache/${IMAGENAME} +fi +PKG_CACHE_FILE_NAME=${PKG_CACHE_PATH}/cache.tgz +mkdir -p ${PKG_CACHE_PATH} + + URL_PREFIX=$(echo "${PACKAGE_URL_PREFIX}" | sed -E "s#(//[^/]*/).*#\1#") @@ -71,15 +80,40 @@ check_if_url_exist() set_reproducible_mirrors() { # Remove the charater # in front of the line if matched - local expression="s/^#\(.*$REPR_MIRROR_URL_PATTERN\)/\1/" + local expression="s/^#\s*\(.*$REPR_MIRROR_URL_PATTERN\)/\1/" + # Add the character # in front of the line, if not match the URL pattern condition + local expression2="/^#*deb.*$REPR_MIRROR_URL_PATTERN/! s/^#*deb/#&/" + local expression3="\$a#SET_REPR_MIRRORS" if [ "$1" = "-d" ]; then # Add the charater # in front of the line if match expression="s/^deb.*$REPR_MIRROR_URL_PATTERN/#\0/" + # Remove the character # in front of the line, if not match the URL pattern condition + expression2="/^#*deb.*$REPR_MIRROR_URL_PATTERN/! s/^#\s*(#*deb)/\1/" + expression3="/#SET_REPR_MIRRORS/d" fi local mirrors="/etc/apt/sources.list $(find /etc/apt/sources.list.d/ -type f)" for mirror in $mirrors; do + if ! grep -iq "$REPR_MIRROR_URL_PATTERN" "$mirror"; then + continue + fi + + # Make sure no duplicate operations on the mirror config file + if ([ "$1" == "-d" ] && ! grep -iq "#SET_REPR_MIRRORS" "$mirror") || + ([ "$1" != "-d" ] && grep -iq "#SET_REPR_MIRRORS" "$mirror"); then + continue + fi + + # Enable or disable the reproducible mirrors $SUDO sed -i "$expression" "$mirror" + + # Enable or disable the none reproducible mirrors + if [ "$MIRROR_SNAPSHOT" == y ]; then + $SUDO sed -ri "$expression2" "$mirror" + fi + + # Add or remove the SET_REPR_MIRRORS flag + $SUDO sed -i "$expression3" "$mirror" done } @@ -183,6 +217,11 @@ run_pip_command() $REAL_COMMAND "${parameters[@]}" local result=$? + if [ "$result" != 0 ]; then + echo "Failed to run the command with constraint, try to install with the original command" 1>&2 + $REAL_COMMAND "$@" + result=$? + fi rm $tmp_version_file return $result } @@ -312,6 +351,9 @@ update_version_file() update_version_files() { local version_names="versions-deb versions-py2 versions-py3" + if [ "$MIRROR_SNAPSHOT" == y ]; then + version_names="versions-py2 versions-py3" + fi for version_name in $version_names; do update_version_file $version_name done diff --git a/src/sonic-build-hooks/scripts/collect_version_files b/src/sonic-build-hooks/scripts/collect_version_files index a4b33eeaa897..3fcc99a87106 100755 --- a/src/sonic-build-hooks/scripts/collect_version_files +++ b/src/sonic-build-hooks/scripts/collect_version_files @@ -18,6 +18,13 @@ dpkg-query -W -f '${Package}==${Version}\n' >> "${TARGET_PATH}/versions-deb-${DI ## Add the the packages purged [ -f $POST_VERSION_PATH/purge-versions-deb ] && cat $POST_VERSION_PATH/purge-versions-deb >> "${TARGET_PATH}/versions-deb-${DIST}-${ARCH}" +## Add mirror versions +while read -r line; do + mirror=$(echo "$line" | sed "s/.*\///" | sed "s/_InRelease.*//") + date=$(date --date="$(echo "$line" | cut -d: -f3-)" +%Y-%m-%dT%H:%M:%SZ) + echo "$mirror==$date" >> ${TARGET_PATH}/versions-mirror +done < <(grep Date: /var/lib/apt/lists/*_InRelease 2>/dev/null) + ## Print the unique and sorted result sort -u "${TARGET_PATH}/versions-deb-${DIST}-${ARCH}" -o "${TARGET_PATH}/versions-deb-${DIST}-${ARCH}" if [ -e "${TARGET_PATH}/versions-py2-${DIST}-${ARCH}" ]; then @@ -26,5 +33,8 @@ fi if [ -e "${TARGET_PATH}/versions-py3-${DIST}-${ARCH}" ]; then sort -u "${TARGET_PATH}/versions-py3-${DIST}-${ARCH}" -o "${TARGET_PATH}/versions-py3-${DIST}-${ARCH}" fi +if [ -e "${TARGET_PATH}/versions-mirror" ]; then + sort -u "${TARGET_PATH}/versions-mirror" -o "${TARGET_PATH}/versions-mirror" +fi exit 0 diff --git a/src/sonic-build-hooks/scripts/post_run_buildinfo b/src/sonic-build-hooks/scripts/post_run_buildinfo index 97f47f7efcf1..0b23d44fd365 100755 --- a/src/sonic-build-hooks/scripts/post_run_buildinfo +++ b/src/sonic-build-hooks/scripts/post_run_buildinfo @@ -1,12 +1,14 @@ #!/bin/bash +IMAGENAME=$1 + . /usr/local/share/buildinfo/scripts/buildinfo_base.sh # Collect the version files collect_version_files $POST_VERSION_PATH -[ -d $BUILD_VERSION_PATH ] && [ ! -z "$(ls -A $BUILD_VERSION_PATH)" ] && cp -rf $BUILD_VERSION_PATH/* $POST_VERSION_PATH -rm -rf $BUILD_VERSION_PATH/* +#Save the cache file for exporting it to host. +tar -C ${PKG_CACHE_PATH} --exclude=cache.tgz -zcvf /cache.tgz . # Disable the build hooks symlink_build_hooks -d @@ -14,3 +16,4 @@ set_reproducible_mirrors -d # Remove the version deb preference rm -f $VERSION_DEB_PREFERENCE +rm -f /etc/apt/preferences.d/01-versions-deb diff --git a/src/sonic-build-hooks/scripts/pre_run_buildinfo b/src/sonic-build-hooks/scripts/pre_run_buildinfo index 5a8f00b55ecb..eb4d04225ec5 100755 --- a/src/sonic-build-hooks/scripts/pre_run_buildinfo +++ b/src/sonic-build-hooks/scripts/pre_run_buildinfo @@ -1,5 +1,7 @@ #!/bin/bash +IMAGENAME=$1 + . /usr/local/share/buildinfo/scripts/buildinfo_base.sh [ -d $DIFF_VERSION_PATH ] && rm -rf $DIFF_VERSION_PATH @@ -15,10 +17,14 @@ update_version_files symlink_build_hooks set_reproducible_mirrors +mkdir -p /var/cache/apt/archives/ + chmod -R a+rw $BUILDINFO_PATH if [ "$ENABLE_VERSION_CONTROL_DEB" == "y" ] && [ -f $VERSION_DEB_PREFERENCE ]; then cp -f $VERSION_DEB_PREFERENCE /etc/apt/preferences.d/ fi +DISTRO=${DISTRO} apt-get update && apt-get install -y rsync + exit 0 diff --git a/src/sonic-config-engine/minigraph.py b/src/sonic-config-engine/minigraph.py index 9cd43b6b0ab8..68f20b4677a8 100644 --- a/src/sonic-config-engine/minigraph.py +++ b/src/sonic-config-engine/minigraph.py @@ -532,9 +532,9 @@ def parse_dpg(dpg, hname): intfs_inpc.append(pcmbr_list[i]) pc_members[(pcintfname, pcmbr_list[i])] = {} if pcintf.find(str(QName(ns, "Fallback"))) != None: - pcs[pcintfname] = {'members': pcmbr_list, 'fallback': pcintf.find(str(QName(ns, "Fallback"))).text, 'min_links': str(int(math.ceil(len() * 0.75))), 'lacp_key': 'auto'} + pcs[pcintfname] = {'fallback': pcintf.find(str(QName(ns, "Fallback"))).text, 'min_links': str(int(math.ceil(len() * 0.75))), 'lacp_key': 'auto'} else: - pcs[pcintfname] = {'members': pcmbr_list, 'min_links': str(int(math.ceil(len(pcmbr_list) * 0.75))), 'lacp_key': 'auto' } + pcs[pcintfname] = {'min_links': str(int(math.ceil(len(pcmbr_list) * 0.75))), 'lacp_key': 'auto' } port_nhipv4_map = {} port_nhipv6_map = {} nhg_int = "" @@ -657,6 +657,40 @@ def parse_dpg(dpg, hname): is_mirror = False is_mirror_v6 = False is_mirror_dscp = False + use_port_alias = True + + # Walk through all interface names/alias to determine whether the input string is + # port name or alias.We need this logic because there can be duplicaitons in port alias + # and port names + # The input port name/alias can be either port_name or port_alias. A mix of name and alias is not accepted + port_name_count = 0 + port_alias_count = 0 + total_count = 0 + for member in aclattach: + member = member.strip() + if member in pcs or \ + member in vlans or \ + member.lower().startswith('erspan') or \ + member.lower().startswith('egress_erspan') or \ + member.lower().startswith('erspan_dscp'): + continue + total_count += 1 + if member in port_alias_map: + port_alias_count += 1 + if member in port_names_map: + port_name_count += 1 + # All inputs are port alias + if port_alias_count == total_count: + use_port_alias = True + # All inputs are port name + elif port_name_count == total_count: + use_port_alias = False + # There are both port alias and port name, then port alias is preferred to keep the behavior not changed + else: + use_port_alias = True + # For CTRLPLANE ACL, both counters are 0 + if (port_alias_count != 0) and (port_name_count != 0): + print("Warning: The given port name for ACL " + aclname + " is inconsistent. It must be either port name or alias ", file=sys.stderr) # TODO: Ensure that acl_intfs will only ever contain front-panel interfaces (e.g., # maybe we should explicity ignore management and loopback interfaces?) because we @@ -674,11 +708,15 @@ def parse_dpg(dpg, hname): acl_intfs.extend(vlan_member_list[member]) else: acl_intfs.append(member) - elif member in port_alias_map: + elif use_port_alias and (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 if port_alias_map[member] in intfs_inpc: print("Warning: ACL " + aclname + " is attached to a LAG member interface " + port_alias_map[member] + ", instead of LAG interface", file=sys.stderr) + elif (not use_port_alias) and (member in port_names_map): + acl_intfs.append(member) + if member in intfs_inpc: + print("Warning: ACL " + aclname + " is attached to a LAG member interface " + member + ", instead of LAG interface", file=sys.stderr) elif member.lower().startswith('erspan') or member.lower().startswith('egress_erspan') or member.lower().startswith('erspan_dscp'): if 'dscp' in member.lower(): is_mirror_dscp = True @@ -1206,7 +1244,7 @@ def filter_acl_table_for_backend(acls, vlan_members): } return filter_acls -def filter_acl_table_bindings(acls, neighbors, port_channels, sub_role, device_type, is_storage_device, vlan_members): +def filter_acl_table_bindings(acls, neighbors, port_channels, pc_members, sub_role, device_type, is_storage_device, vlan_members): if device_type == 'BackEndToRRouter' and is_storage_device: return filter_acl_table_for_backend(acls, vlan_members) @@ -1225,8 +1263,8 @@ def filter_acl_table_bindings(acls, neighbors, port_channels, sub_role, device_t # Get the front panel port channel. for port_channel_intf in port_channels: - backend_port_channel = any(lag_member in backplane_port_list \ - for lag_member in port_channels[port_channel_intf]['members']) + backend_port_channel = any(lag_member[1] in backplane_port_list \ + for lag_member in list(pc_members.keys()) if lag_member[0] == port_channel_intf) if not backend_port_channel: front_port_channel_intf.append(port_channel_intf) @@ -1396,6 +1434,8 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw docker_routing_config_mode = child.text (ports, alias_map, alias_asic_map) = get_port_config(hwsku=hwsku, platform=platform, port_config_file=port_config_file, asic_name=asic_name, hwsku_config_file=hwsku_config_file) + + port_names_map.update(ports) port_alias_map.update(alias_map) port_alias_asic_map.update(alias_asic_map) @@ -1626,6 +1666,20 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw if port_name in mgmt_alias_reverse_mapping.keys(): continue + port_default_speed = port_speeds_default.get(port_name, None) + port_png_speed = port_speed_png[port_name] + + if switch_type == 'voq': + # when the port speed is changes from 400g to 100g + # update the port lanes, use the first 4 lanes of the 400G port to support 100G port + if port_default_speed == '400000' and port_png_speed == '100000': + port_lanes = ports[port_name].get('lanes', '').split(',') + # check if the 400g port has only 8 lanes + if len(port_lanes) != 8: + continue + updated_lanes = ",".join(port_lanes[:4]) + ports[port_name]['lanes'] = updated_lanes + ports.setdefault(port_name, {})['speed'] = port_speed_png[port_name] for port_name, port in list(ports.items()): @@ -1709,23 +1763,29 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw if inband_port in ports.keys(): ports[inband_port]['admin_status'] = 'up' - # bring up the recirc port for voq chassis + # bring up the recirc port for voq chassis, Set it as routed interface for port, port_attributes in ports.items(): port_role = port_attributes.get('role', None) if port_role == 'Rec': ports[port]['admin_status'] = 'up' + #Add the Recirc ports to the INTERFACES table to make it routed intf + results['INTERFACE'].update({port : {}}) + results['PORT'] = ports results['CONSOLE_PORT'] = console_ports if port_config_file: port_set = set(ports.keys()) - for (pc_name, mbr_map) in list(pcs.items()): + for (pc_name, pc_member) in list(pc_members.keys()): # remove portchannels that contain ports not existing in port_config.ini # when port_config.ini exists - if not set(mbr_map['members']).issubset(port_set): - print("Warning: ignore '%s' as part of its member interfaces is not in the port_config.ini" % pc_name, file=sys.stderr) + if (pc_name, pc_member) in pc_members and pc_member not in port_set: + print("Warning: ignore '%s' as at least one of its member interfaces ('%s') is not in the port_config.ini" % (pc_name, pc_member), file=sys.stderr) del pcs[pc_name] + pc_mbr_del_keys = [f for f in list(pc_members.keys()) if f[0] == pc_name] + for pc_mbr_del_key in pc_mbr_del_keys: + del pc_members[pc_mbr_del_key] # set default port channel MTU as 9100 and admin status up and default TPID 0x8100 for pc in pcs.values(): @@ -1829,7 +1889,7 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw results['DHCP_RELAY'] = dhcp_relay_table results['NTP_SERVER'] = dict((item, {}) for item in ntp_servers) results['TACPLUS_SERVER'] = dict((item, {'priority': '1', 'tcp_port': '49'}) for item in tacacs_servers) - results['ACL_TABLE'] = filter_acl_table_bindings(acls, neighbors, pcs, sub_role, current_device['type'], is_storage_device, vlan_members) + results['ACL_TABLE'] = filter_acl_table_bindings(acls, neighbors, pcs, pc_members, sub_role, current_device['type'], is_storage_device, vlan_members) results['FEATURE'] = { 'telemetry': { 'state': 'enabled' @@ -2064,6 +2124,7 @@ def parse_asic_meta_get_devices(root): return local_devices +port_names_map = {} port_alias_map = {} port_alias_asic_map = {} diff --git a/src/sonic-config-engine/tests/sample-arista-7050-t0-minigraph.xml b/src/sonic-config-engine/tests/sample-arista-7050-t0-minigraph.xml index 4d79d6f2c457..2ee9fdac8c2c 100644 --- a/src/sonic-config-engine/tests/sample-arista-7050-t0-minigraph.xml +++ b/src/sonic-config-engine/tests/sample-arista-7050-t0-minigraph.xml @@ -924,6 +924,11 @@ 10.0.0.16 + + ResourceType + + Storage + diff --git a/src/sonic-config-engine/tests/sample-arista-7060-t0-minigraph.xml b/src/sonic-config-engine/tests/sample-arista-7060-t0-minigraph.xml new file mode 100644 index 000000000000..eff3d88acbb9 --- /dev/null +++ b/src/sonic-config-engine/tests/sample-arista-7060-t0-minigraph.xml @@ -0,0 +1,1048 @@ + + + + + + false + str2-7060cx-32s-29 + 10.0.0.56 + ARISTA01T1 + 10.0.0.57 + 1 + 10 + 3 + + + str2-7060cx-32s-29 + FC00::71 + ARISTA01T1 + FC00::72 + 1 + 10 + 3 + + + false + str2-7060cx-32s-29 + 10.0.0.58 + ARISTA02T1 + 10.0.0.59 + 1 + 10 + 3 + + + str2-7060cx-32s-29 + FC00::75 + ARISTA02T1 + FC00::76 + 1 + 10 + 3 + + + false + str2-7060cx-32s-29 + 10.0.0.60 + ARISTA03T1 + 10.0.0.61 + 1 + 10 + 3 + + + str2-7060cx-32s-29 + FC00::79 + ARISTA03T1 + FC00::7A + 1 + 10 + 3 + + + false + str2-7060cx-32s-29 + 10.0.0.62 + ARISTA04T1 + 10.0.0.63 + 1 + 10 + 3 + + + str2-7060cx-32s-29 + FC00::7D + ARISTA04T1 + FC00::7E + 1 + 10 + 3 + + + + + 65100 + str2-7060cx-32s-29 + + +
10.0.0.57
+ + + +
+ +
10.0.0.59
+ + + +
+ +
10.0.0.61
+ + + +
+ +
10.0.0.63
+ + + +
+ + BGPPeer +
10.1.0.32
+ + + + BGPSLBPassive + 10.255.0.0/25 +
+ + BGPPeer +
10.1.0.32
+ + + + BGPVac + 192.168.0.0/21 +
+
+ +
+ + 64600 + ARISTA01T1 + + + + 64600 + ARISTA02T1 + + + + 64600 + ARISTA03T1 + + + + 64600 + ARISTA04T1 + + +
+
+ + + + + + HostIP + Loopback0 + + 10.1.0.32/32 + + 10.1.0.32/32 + + + HostIP1 + Loopback0 + + FC00:1::32/128 + + FC00:1::32/128 + + + + + HostIP + eth0 + + 10.3.146.57/23 + + 10.3.146.57/23 + + + V6HostIP + eth0 + + FC00:2::32/64 + + FC00:2::32/64 + + + + + + + str2-7060cx-32s-29 + + + PortChannel101 + Ethernet29/1 + + + + PortChannel102 + Ethernet30/1 + + + + PortChannel103 + Ethernet31/1 + + + + PortChannel104 + Ethernet32/1 + + + + + + Vlan1000 + Ethernet2/1;Ethernet3/1;Ethernet4/1;Ethernet5/1;Ethernet6/1;Ethernet7/1;Ethernet8/1;Ethernet9/1;Ethernet10/1;Ethernet11/1;Ethernet12/1;Ethernet13/1;Ethernet14/1;Ethernet15/1;Ethernet16/1;Ethernet17/1;Ethernet18/1;Ethernet19/1;Ethernet20/1;Ethernet21/1;Ethernet22/1;Ethernet23/1;Ethernet24/1;Ethernet25/1 + False + 0.0.0.0/0 + 192.0.0.1;192.0.0.2;192.0.0.3;192.0.0.4;192.0.0.5;192.0.0.6;192.0.0.7;192.0.0.8;192.0.0.9;192.0.0.10;192.0.0.11;192.0.0.12;192.0.0.13;192.0.0.14;192.0.0.15;192.0.0.16;192.0.0.17;192.0.0.18;192.0.0.19;192.0.0.20;192.0.0.21;192.0.0.22;192.0.0.23;192.0.0.24;192.0.0.25;192.0.0.26;192.0.0.27;192.0.0.28;192.0.0.29;192.0.0.30;192.0.0.31;192.0.0.32;192.0.0.33;192.0.0.34;192.0.0.35;192.0.0.36;192.0.0.37;192.0.0.38;192.0.0.39;192.0.0.40;192.0.0.41;192.0.0.42;192.0.0.43;192.0.0.44;192.0.0.45;192.0.0.46;192.0.0.47;192.0.0.48 + fc02:2000::1;fc02:2000::2;fc02:2000::3;fc02:2000::4 + 1000 + 1000 + 192.168.0.0/21 + + + + + + PortChannel101 + 10.0.0.56/31 + + + + PortChannel101 + FC00::71/126 + + + + PortChannel102 + 10.0.0.58/31 + + + + PortChannel102 + FC00::75/126 + + + + PortChannel103 + 10.0.0.60/31 + + + + PortChannel103 + FC00::79/126 + + + + PortChannel104 + 10.0.0.62/31 + + + + PortChannel104 + FC00::7D/126 + + + + Vlan1000 + 192.168.0.1/21 + + + + Vlan1000 + fc02:1000::1/64 + + + + + + NTP_ACL + NTP + NTP + + + SNMP_ACL + SNMP + SNMP + + + ERSPAN + Everflow + Everflow + + + ERSPANV6 + EverflowV6 + EverflowV6 + + + VTY_LINE + ssh-only + SSH + + + PortChannel101;PortChannel102;PortChannel103;PortChannel104 + DataAcl + DataPlane + + + + + + + + + + DeviceInterfaceLink + ARISTA01T1 + Ethernet1 + str2-7060cx-32s-29 + Ethernet29/1 + + + DeviceInterfaceLink + ARISTA02T1 + Ethernet1 + str2-7060cx-32s-29 + Ethernet30/1 + + + DeviceInterfaceLink + ARISTA03T1 + Ethernet1 + str2-7060cx-32s-29 + Ethernet31/1 + + + DeviceInterfaceLink + ARISTA04T1 + Ethernet1 + str2-7060cx-32s-29 + Ethernet32/1 + + + DeviceInterfaceLink + str2-7060cx-32s-29 + Ethernet2/1 + Servers0 + eth0 + + + DeviceInterfaceLink + str2-7060cx-32s-29 + Ethernet3/1 + Servers1 + eth0 + + + DeviceInterfaceLink + str2-7060cx-32s-29 + Ethernet4/1 + Servers2 + eth0 + + + DeviceInterfaceLink + str2-7060cx-32s-29 + Ethernet5/1 + Servers3 + eth0 + + + DeviceInterfaceLink + str2-7060cx-32s-29 + Ethernet6/1 + Servers4 + eth0 + + + DeviceInterfaceLink + str2-7060cx-32s-29 + Ethernet7/1 + Servers5 + eth0 + + + DeviceInterfaceLink + str2-7060cx-32s-29 + Ethernet8/1 + Servers6 + eth0 + + + DeviceInterfaceLink + str2-7060cx-32s-29 + Ethernet9/1 + Servers7 + eth0 + + + DeviceInterfaceLink + str2-7060cx-32s-29 + Ethernet10/1 + Servers8 + eth0 + + + DeviceInterfaceLink + str2-7060cx-32s-29 + Ethernet11/1 + Servers9 + eth0 + + + DeviceInterfaceLink + str2-7060cx-32s-29 + Ethernet12/1 + Servers10 + eth0 + + + DeviceInterfaceLink + str2-7060cx-32s-29 + Ethernet13/1 + Servers11 + eth0 + + + DeviceInterfaceLink + str2-7060cx-32s-29 + Ethernet14/1 + Servers12 + eth0 + + + DeviceInterfaceLink + str2-7060cx-32s-29 + Ethernet15/1 + Servers13 + eth0 + + + DeviceInterfaceLink + str2-7060cx-32s-29 + Ethernet16/1 + Servers14 + eth0 + + + DeviceInterfaceLink + str2-7060cx-32s-29 + Ethernet17/1 + Servers15 + eth0 + + + DeviceInterfaceLink + str2-7060cx-32s-29 + Ethernet18/1 + Servers16 + eth0 + + + DeviceInterfaceLink + str2-7060cx-32s-29 + Ethernet19/1 + Servers17 + eth0 + + + DeviceInterfaceLink + str2-7060cx-32s-29 + Ethernet20/1 + Servers18 + eth0 + + + DeviceInterfaceLink + str2-7060cx-32s-29 + Ethernet21/1 + Servers19 + eth0 + + + DeviceInterfaceLink + str2-7060cx-32s-29 + Ethernet22/1 + Servers20 + eth0 + + + DeviceInterfaceLink + str2-7060cx-32s-29 + Ethernet23/1 + Servers21 + eth0 + + + DeviceInterfaceLink + str2-7060cx-32s-29 + Ethernet24/1 + Servers22 + eth0 + + + DeviceInterfaceLink + str2-7060cx-32s-29 + Ethernet25/1 + Servers23 + eth0 + + + + + str2-7060cx-32s-29 + Arista-7060CX-32S-D48C8 + + 10.3.146.57 + + + + ARISTA04T1 + + 172.16.137.127 + + Arista-VM + + + ARISTA03T1 + + 172.16.137.126 + + Arista-VM + + + ARISTA02T1 + + 172.16.137.125 + + Arista-VM + + + ARISTA01T1 + + 172.16.137.124 + + Arista-VM + + + + + + true + + + DeviceInterface + + true + true + 1 + Ethernet1/1 + + false + 0 + 0 + 40000 + + + DeviceInterface + + true + true + 1 + Ethernet2/1 + + false + 0 + 0 + 40000 + + + DeviceInterface + + true + true + 1 + Ethernet3/1 + + false + 0 + 0 + 40000 + + + DeviceInterface + + true + true + 1 + Ethernet4/1 + + false + 0 + 0 + 40000 + + + DeviceInterface + + true + true + 1 + Ethernet5/1 + + false + 0 + 0 + 40000 + + + DeviceInterface + + true + true + 1 + Ethernet6/1 + + false + 0 + 0 + 40000 + + + DeviceInterface + + true + true + 1 + Ethernet7/1 + + false + 0 + 0 + 40000 + + + DeviceInterface + + true + true + 1 + Ethernet8/1 + + false + 0 + 0 + 40000 + + + DeviceInterface + + true + true + 1 + Ethernet9/1 + + false + 0 + 0 + 40000 + + + DeviceInterface + + true + true + 1 + Ethernet10/1 + + false + 0 + 0 + 40000 + + + DeviceInterface + + true + true + 1 + Ethernet11/1 + + false + 0 + 0 + 40000 + + + DeviceInterface + + true + true + 1 + Ethernet12/1 + + false + 0 + 0 + 40000 + + + DeviceInterface + + true + true + 1 + Ethernet13/1 + + false + 0 + 0 + 40000 + + + DeviceInterface + + true + true + 1 + Ethernet14/1 + + false + 0 + 0 + 40000 + + + DeviceInterface + + true + true + 1 + Ethernet15/1 + + false + 0 + 0 + 40000 + + + DeviceInterface + + true + true + 1 + Ethernet16/1 + + false + 0 + 0 + 40000 + + + DeviceInterface + + true + true + 1 + Ethernet17/1 + + false + 0 + 0 + 40000 + + + DeviceInterface + + true + true + 1 + Ethernet18/1 + + false + 0 + 0 + 40000 + + + DeviceInterface + + true + true + 1 + Ethernet19/1 + + false + 0 + 0 + 40000 + + + DeviceInterface + + true + true + 1 + Ethernet20/1 + + false + 0 + 0 + 40000 + + + DeviceInterface + + true + true + 1 + Ethernet21/1 + + false + 0 + 0 + 40000 + + + DeviceInterface + + true + true + 1 + Ethernet22/1 + + false + 0 + 0 + 40000 + + + DeviceInterface + + true + true + 1 + Ethernet23/1 + + false + 0 + 0 + 40000 + + + DeviceInterface + + true + true + 1 + Ethernet24/1 + + false + 0 + 0 + 40000 + + + DeviceInterface + + true + true + 1 + Ethernet25/1 + + false + 0 + 0 + 40000 + + + DeviceInterface + + true + true + 1 + Ethernet26/1 + + false + 0 + 0 + 40000 + + + DeviceInterface + + true + true + 1 + Ethernet27/1 + + false + 0 + 0 + 40000 + + + DeviceInterface + + true + true + 1 + Ethernet28/1 + + false + 0 + 0 + 40000 + + + DeviceInterface + + true + true + 1 + Ethernet29/1 + + false + 0 + 0 + 40000 + + + DeviceInterface + + true + true + 1 + Ethernet30/1 + + false + 0 + 0 + 40000 + + + DeviceInterface + + true + true + 1 + Ethernet31/1 + + false + 0 + 0 + 40000 + + + DeviceInterface + + true + true + 1 + Ethernet32/1 + + false + 0 + 0 + 40000 + + + true + 0 + Arista-7060CX-32S-D48C8 + + + + + + + str2-7060cx-32s-29 + + + DeploymentId + + 1 + + + QosProfile + + Profile0 + + + DhcpResources + + 192.0.0.1;192.0.0.2;192.0.0.3;192.0.0.4;192.0.0.5;192.0.0.6;192.0.0.7;192.0.0.8;192.0.0.9;192.0.0.10;192.0.0.11;192.0.0.12;192.0.0.13;192.0.0.14;192.0.0.15;192.0.0.16;192.0.0.17;192.0.0.18;192.0.0.19;192.0.0.20;192.0.0.21;192.0.0.22;192.0.0.23;192.0.0.24;192.0.0.25;192.0.0.26;192.0.0.27;192.0.0.28;192.0.0.29;192.0.0.30;192.0.0.31;192.0.0.32;192.0.0.33;192.0.0.34;192.0.0.35;192.0.0.36;192.0.0.37;192.0.0.38;192.0.0.39;192.0.0.40;192.0.0.41;192.0.0.42;192.0.0.43;192.0.0.44;192.0.0.45;192.0.0.46;192.0.0.47;192.0.0.48 + + + NtpResources + + 10.20.8.129;10.20.8.130 + + + SnmpResources + + 10.3.145.98 + + + SyslogResources + + 10.64.246.95 + + + TacacsGroup + + Starlab + + + TacacsServer + + 100.127.20.21 + + + ForcedMgmtRoutes + + 10.3.145.98/31;10.3.145.8;100.127.20.16/28;10.3.149.170/31;40.122.216.24;13.91.48.226;10.3.145.14;10.64.246.0/23;10.3.146.0/23;10.64.5.5;10.201.148.32/28;10.64.247.0/24 + + + ErspanDestinationIpv4 + + 10.20.6.16 + + + + + + + str2-7060cx-32s-29 + Arista-7060CX-32S-D48C8 +
diff --git a/src/sonic-config-engine/tests/sample-mellanox-4600c-t0-minigraph-remap-disabled.xml b/src/sonic-config-engine/tests/sample-mellanox-4600c-t0-minigraph-remap-disabled.xml new file mode 100644 index 000000000000..0154df6fffcd --- /dev/null +++ b/src/sonic-config-engine/tests/sample-mellanox-4600c-t0-minigraph-remap-disabled.xml @@ -0,0 +1,4002 @@ + + + + + + false + r-tigon-20 + 10.0.0.56 + ARISTA01T1 + 10.0.0.57 + 1 + 10 + 3 + + + r-tigon-20 + FC00::71 + ARISTA01T1 + FC00::72 + 1 + 10 + 3 + + + false + r-tigon-20 + 10.0.0.58 + ARISTA02T1 + 10.0.0.59 + 1 + 10 + 3 + + + r-tigon-20 + FC00::75 + ARISTA02T1 + FC00::76 + 1 + 10 + 3 + + + false + r-tigon-20 + 10.0.0.60 + ARISTA03T1 + 10.0.0.61 + 1 + 10 + 3 + + + r-tigon-20 + FC00::79 + ARISTA03T1 + FC00::7A + 1 + 10 + 3 + + + false + r-tigon-20 + 10.0.0.62 + ARISTA04T1 + 10.0.0.63 + 1 + 10 + 3 + + + r-tigon-20 + FC00::7D + ARISTA04T1 + FC00::7E + 1 + 10 + 3 + + + + + 65100 + r-tigon-20 + + +
10.0.0.57
+ + + +
+ +
10.0.0.59
+ + + +
+ +
10.0.0.61
+ + + +
+ +
10.0.0.63
+ + + +
+ + BGPPeer +
10.1.0.32
+ + + + BGPSLBPassive + 10.255.0.0/25 +
+ + BGPPeer +
10.1.0.32
+ + + + BGPVac + 192.168.0.0/21 +
+
+ +
+ + 64600 + ARISTA01T1 + + + + 64600 + ARISTA02T1 + + + + 64600 + ARISTA03T1 + + + + 64600 + ARISTA04T1 + + +
+
+ + + + + + HostIP + Loopback0 + + 10.1.0.32/32 + + 10.1.0.32/32 + + + HostIP1 + Loopback0 + + FC00:1::32/128 + + FC00:1::32/128 + + + HostIP2 + Loopback1 + + 10.1.0.34/32 + + 10.1.0.34/32 + + + HostIP3 + Loopback1 + + FC00:1::34/128 + + FC00:1::34/128 + + HostIP6 + Loopback3 + + 10.1.0.38/32 + + 10.1.0.38/32 + + + HostIP7 + Loopback3 + + FC00:1::38/128 + + FC00:1::38/128 + + HostIP4 + Loopback2 + + 10.1.0.36/32 + + 10.1.0.36/32 + + + HostIP5 + Loopback2 + + FC00:1::36/128 + + FC00:1::36/128 + + + + HostIP + eth0 + + 10.210.24.183/22 + + 10.210.24.183/22 + + + V6HostIP + eth0 + + fe80::bace:f6ff:fedc:bd4c/64 + + fe80::bace:f6ff:fedc:bd4c/64 + + + + + + + r-tigon-20 + + + PortChannel101 + etp63a + + + + PortChannel102 + etp63b + + + + PortChannel103 + etp64a + + + + PortChannel104 + etp64b + + + + + + + + + Vlan1000 + etp1b;etp2a;etp2b;etp3a;etp3b;etp4a;etp4b;etp5a;etp5b;etp6a;etp6b;etp7a;etp7b;etp8a;etp8b;etp9a;etp9b;etp10a;etp10b;etp11a;etp11b;etp12a;etp12b;etp13a + False + 0.0.0.0/0 + 192.0.0.1;192.0.0.2;192.0.0.3;192.0.0.4 + fc02:2000::1;fc02:2000::2;fc02:2000::3;fc02:2000::4 + 1000 + 1000 + 192.168.0.0/21 + 00:aa:bb:cc:dd:ee + + + + + + PortChannel101 + 10.0.0.56/31 + + + + PortChannel101 + FC00::71/126 + + + + PortChannel102 + 10.0.0.58/31 + + + + PortChannel102 + FC00::75/126 + + + + PortChannel103 + 10.0.0.60/31 + + + + PortChannel103 + FC00::79/126 + + + + PortChannel104 + 10.0.0.62/31 + + + + PortChannel104 + FC00::7D/126 + + + + Vlan1000 + 192.168.0.1/21 + + + + Vlan1000 + fc02:1000::1/64 + + + + + + NTP_ACL + NTP + NTP + + + SNMP_ACL + SNMP + SNMP + + + ERSPAN + Everflow + Everflow + + + ERSPANV6 + EverflowV6 + EverflowV6 + + + VTY_LINE + ssh-only + SSH + + + PortChannel101;PortChannel102;PortChannel103;PortChannel104 + DataAcl + DataPlane + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.2/21 + + 192.168.0.2/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::2/64 + + fc02:1000::2/64 + + + + + + + + Servers0 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.3/21 + + 192.168.0.3/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::3/64 + + fc02:1000::3/64 + + + + + + + + Servers1 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.4/21 + + 192.168.0.4/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::4/64 + + fc02:1000::4/64 + + + + + + + + Servers2 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.5/21 + + 192.168.0.5/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::5/64 + + fc02:1000::5/64 + + + + + + + + Servers3 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.6/21 + + 192.168.0.6/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::6/64 + + fc02:1000::6/64 + + + + + + + + Servers4 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.7/21 + + 192.168.0.7/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::7/64 + + fc02:1000::7/64 + + + + + + + + Servers5 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.8/21 + + 192.168.0.8/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::8/64 + + fc02:1000::8/64 + + + + + + + + Servers6 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.9/21 + + 192.168.0.9/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::9/64 + + fc02:1000::9/64 + + + + + + + + Servers7 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.10/21 + + 192.168.0.10/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::a/64 + + fc02:1000::a/64 + + + + + + + + Servers8 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.11/21 + + 192.168.0.11/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::b/64 + + fc02:1000::b/64 + + + + + + + + Servers9 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.12/21 + + 192.168.0.12/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::c/64 + + fc02:1000::c/64 + + + + + + + + Servers10 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.13/21 + + 192.168.0.13/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::d/64 + + fc02:1000::d/64 + + + + + + + + Servers11 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.14/21 + + 192.168.0.14/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::e/64 + + fc02:1000::e/64 + + + + + + + + Servers12 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.15/21 + + 192.168.0.15/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::f/64 + + fc02:1000::f/64 + + + + + + + + Servers13 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.16/21 + + 192.168.0.16/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::10/64 + + fc02:1000::10/64 + + + + + + + + Servers14 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.17/21 + + 192.168.0.17/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::11/64 + + fc02:1000::11/64 + + + + + + + + Servers15 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.18/21 + + 192.168.0.18/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::12/64 + + fc02:1000::12/64 + + + + + + + + Servers16 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.19/21 + + 192.168.0.19/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::13/64 + + fc02:1000::13/64 + + + + + + + + Servers17 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.20/21 + + 192.168.0.20/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::14/64 + + fc02:1000::14/64 + + + + + + + + Servers18 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.21/21 + + 192.168.0.21/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::15/64 + + fc02:1000::15/64 + + + + + + + + Servers19 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.22/21 + + 192.168.0.22/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::16/64 + + fc02:1000::16/64 + + + + + + + + Servers20 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.23/21 + + 192.168.0.23/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::17/64 + + fc02:1000::17/64 + + + + + + + + Servers21 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.24/21 + + 192.168.0.24/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::18/64 + + fc02:1000::18/64 + + + + + + + + Servers22 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.25/21 + + 192.168.0.25/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::19/64 + + fc02:1000::19/64 + + + + + + + + Servers23 + + + + + + + + + + + + + + DeviceInterfaceLink + ARISTA01T1 + Ethernet1 + r-tigon-20 + etp63a + + + DeviceInterfaceLink + ARISTA02T1 + Ethernet1 + r-tigon-20 + etp63b + + + DeviceInterfaceLink + ARISTA03T1 + Ethernet1 + r-tigon-20 + etp64a + + + DeviceInterfaceLink + ARISTA04T1 + Ethernet1 + r-tigon-20 + etp64b + + + DeviceInterfaceLink + r-tigon-20 + etp1b + Servers0 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp2a + Servers1 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp2b + Servers2 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp3a + Servers3 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp3b + Servers4 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp4a + Servers5 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp4b + Servers6 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp5a + Servers7 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp5b + Servers8 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp6a + Servers9 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp6b + Servers10 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp7a + Servers11 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp7b + Servers12 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp8a + Servers13 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp8b + Servers14 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp9a + Servers15 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp9b + Servers16 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp10a + Servers17 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp10b + Servers18 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp11a + Servers19 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp11b + Servers20 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp12a + Servers21 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp12b + Servers22 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp13a + Servers23 + eth0 + + + LogicalLink + r-tigon-20 + etp1b + r-tigon-20-Servers0-SC + U + + + LogicalLink + r-tigon-20 + etp2a + r-tigon-20-Servers1-SC + U + + + LogicalLink + r-tigon-20 + etp2b + r-tigon-20-Servers2-SC + U + + + LogicalLink + r-tigon-20 + etp3a + r-tigon-20-Servers3-SC + U + + + LogicalLink + r-tigon-20 + etp3b + r-tigon-20-Servers4-SC + U + + + LogicalLink + r-tigon-20 + etp4a + r-tigon-20-Servers5-SC + U + + + LogicalLink + r-tigon-20 + etp4b + r-tigon-20-Servers6-SC + U + + + LogicalLink + r-tigon-20 + etp5a + r-tigon-20-Servers7-SC + U + + + LogicalLink + r-tigon-20 + etp5b + r-tigon-20-Servers8-SC + U + + + LogicalLink + r-tigon-20 + etp6a + r-tigon-20-Servers9-SC + U + + + LogicalLink + r-tigon-20 + etp6b + r-tigon-20-Servers10-SC + U + + + LogicalLink + r-tigon-20 + etp7a + r-tigon-20-Servers11-SC + U + + + LogicalLink + r-tigon-20 + etp7b + r-tigon-20-Servers12-SC + U + + + LogicalLink + r-tigon-20 + etp8a + r-tigon-20-Servers13-SC + U + + + LogicalLink + r-tigon-20 + etp8b + r-tigon-20-Servers14-SC + U + + + LogicalLink + r-tigon-20 + etp9a + r-tigon-20-Servers15-SC + U + + + LogicalLink + r-tigon-20 + etp9b + r-tigon-20-Servers16-SC + U + + + LogicalLink + r-tigon-20 + etp10a + r-tigon-20-Servers17-SC + U + + + LogicalLink + r-tigon-20 + etp10b + r-tigon-20-Servers18-SC + U + + + LogicalLink + r-tigon-20 + etp11a + r-tigon-20-Servers19-SC + U + + + LogicalLink + r-tigon-20 + etp11b + r-tigon-20-Servers20-SC + U + + + LogicalLink + r-tigon-20 + etp12a + r-tigon-20-Servers21-SC + U + + + LogicalLink + r-tigon-20 + etp12b + r-tigon-20-Servers22-SC + U + + + LogicalLink + r-tigon-20 + etp13a + r-tigon-20-Servers23-SC + U + + + + + r-tigon-20 + Mellanox-SN4600C-D48C40 +
+ 10.1.0.32/32 +
+ + FC00:1::32/128 + + + 10.210.24.183 + +
+ + r-tigon-21 + Mellanox-SN4600C-D48C40 +
+ 10.1.0.33/32 +
+ + FC00:1::33/128 + + + 10.210.24.193 + +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers0-SC +
+ + Server +
+ 192.168.0.2/26 +
+ + fc02:1000::2/96 + + + 0.0.0.0/0 + + Servers0 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers1-SC +
+ + Server +
+ 192.168.0.3/26 +
+ + fc02:1000::3/96 + + + 0.0.0.0/0 + + Servers1 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers2-SC +
+ + Server +
+ 192.168.0.4/26 +
+ + fc02:1000::4/96 + + + 0.0.0.0/0 + + Servers2 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers3-SC +
+ + Server +
+ 192.168.0.5/26 +
+ + fc02:1000::5/96 + + + 0.0.0.0/0 + + Servers3 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers4-SC +
+ + Server +
+ 192.168.0.6/26 +
+ + fc02:1000::6/96 + + + 0.0.0.0/0 + + Servers4 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers5-SC +
+ + Server +
+ 192.168.0.7/26 +
+ + fc02:1000::7/96 + + + 0.0.0.0/0 + + Servers5 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers6-SC +
+ + Server +
+ 192.168.0.8/26 +
+ + fc02:1000::8/96 + + + 0.0.0.0/0 + + Servers6 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers7-SC +
+ + Server +
+ 192.168.0.9/26 +
+ + fc02:1000::9/96 + + + 0.0.0.0/0 + + Servers7 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers8-SC +
+ + Server +
+ 192.168.0.10/26 +
+ + fc02:1000::a/96 + + + 0.0.0.0/0 + + Servers8 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers9-SC +
+ + Server +
+ 192.168.0.11/26 +
+ + fc02:1000::b/96 + + + 0.0.0.0/0 + + Servers9 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers10-SC +
+ + Server +
+ 192.168.0.12/26 +
+ + fc02:1000::c/96 + + + 0.0.0.0/0 + + Servers10 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers11-SC +
+ + Server +
+ 192.168.0.13/26 +
+ + fc02:1000::d/96 + + + 0.0.0.0/0 + + Servers11 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers12-SC +
+ + Server +
+ 192.168.0.14/26 +
+ + fc02:1000::e/96 + + + 0.0.0.0/0 + + Servers12 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers13-SC +
+ + Server +
+ 192.168.0.15/26 +
+ + fc02:1000::f/96 + + + 0.0.0.0/0 + + Servers13 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers14-SC +
+ + Server +
+ 192.168.0.16/26 +
+ + fc02:1000::10/96 + + + 0.0.0.0/0 + + Servers14 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers15-SC +
+ + Server +
+ 192.168.0.17/26 +
+ + fc02:1000::11/96 + + + 0.0.0.0/0 + + Servers15 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers16-SC +
+ + Server +
+ 192.168.0.18/26 +
+ + fc02:1000::12/96 + + + 0.0.0.0/0 + + Servers16 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers17-SC +
+ + Server +
+ 192.168.0.19/26 +
+ + fc02:1000::13/96 + + + 0.0.0.0/0 + + Servers17 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers18-SC +
+ + Server +
+ 192.168.0.20/26 +
+ + fc02:1000::14/96 + + + 0.0.0.0/0 + + Servers18 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers19-SC +
+ + Server +
+ 192.168.0.21/26 +
+ + fc02:1000::15/96 + + + 0.0.0.0/0 + + Servers19 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers20-SC +
+ + Server +
+ 192.168.0.22/26 +
+ + fc02:1000::16/96 + + + 0.0.0.0/0 + + Servers20 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers21-SC +
+ + Server +
+ 192.168.0.23/26 +
+ + fc02:1000::17/96 + + + 0.0.0.0/0 + + Servers21 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers22-SC +
+ + Server +
+ 192.168.0.24/26 +
+ + fc02:1000::18/96 + + + 0.0.0.0/0 + + Servers22 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers23-SC +
+ + Server +
+ 192.168.0.25/26 +
+ + fc02:1000::19/96 + + + 0.0.0.0/0 + + Servers23 +
+ + ARISTA04T1 + + 10.215.18.187 + + Arista-VM + + + ARISTA03T1 + + 10.215.18.186 + + Arista-VM + + + ARISTA02T1 + + 10.215.18.185 + + Arista-VM + + + ARISTA01T1 + + 10.215.18.184 + + Arista-VM + +
+
+ + + true + + + DeviceInterface + + true + true + 1 + etp1a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp1b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp2a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp2b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp3a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp3b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp4a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp4b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp5a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp5b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp6a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp6b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp7a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp7b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp8a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp8b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp9a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp9b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp10a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp10b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp11a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp11b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp12a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp12b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp13a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp13b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp14a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp14b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp63a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp63b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp64a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp64b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp17a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp17b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp18a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp18b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp19a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp19b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp20a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp20b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp21a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp21b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp22a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp22b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp23a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp23b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp24a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp24b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp25 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + true + 1 + etp26 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + true + 1 + etp27a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp27b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp28a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp28b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp29 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + true + 1 + etp30 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + true + 1 + etp31a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp31b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp32a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp32b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp33 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + true + 1 + etp34 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + true + 1 + etp35a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp35b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp36a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp36b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp37 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + true + 1 + etp38 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + true + 1 + etp39a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp39b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp40a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp40b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp41a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp41b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp42a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp42b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp43a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp43b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp44a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp44b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp45a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp45b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp46a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp46b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp47a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp47b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp48a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp48b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp49a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp49b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp50a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp50b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp51a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp51b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp52a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp52b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp53a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp53b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp54a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp54b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp55a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp55b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp56a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp56b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp57a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp57b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp58a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp58b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp59a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp59b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp60a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp60b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp61a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp61b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp62a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp62b + + false + 0 + 0 + 50000 + + + true + 0 + Mellanox-SN4600C-D48C40 + + + + + + + r-tigon-20 + + + DeploymentId + + 1 + + + QosProfile + + Profile0 + + + DhcpResources + + 192.0.0.1;192.0.0.2;192.0.0.3;192.0.0.4 + + + NtpResources + + 10.210.25.32;10.75.202.2 + + + SnmpResources + + 10.0.0.9 + + + TacacsGroup + + testlab + + + TacacsServer + + 10.7.34.20 + + + ForcedMgmtRoutes + + 10.75.0.0/16;10.213.0.0/16;10.215.0.0/16;10.9.0.0/16;10.212.0.0/16 + + + ErspanDestinationIpv4 + + 10.0.0.7 + + + + + + + r-tigon-20 + Mellanox-SN4600C-D48C40 +
diff --git a/src/sonic-config-engine/tests/sample-mellanox-4600c-t0-minigraph.xml b/src/sonic-config-engine/tests/sample-mellanox-4600c-t0-minigraph.xml new file mode 100644 index 000000000000..2674ab1fed91 --- /dev/null +++ b/src/sonic-config-engine/tests/sample-mellanox-4600c-t0-minigraph.xml @@ -0,0 +1,3929 @@ + + + + + + false + r-tigon-20 + 10.0.0.56 + ARISTA01T1 + 10.0.0.57 + 1 + 10 + 3 + + + r-tigon-20 + FC00::71 + ARISTA01T1 + FC00::72 + 1 + 10 + 3 + + + false + r-tigon-20 + 10.0.0.58 + ARISTA02T1 + 10.0.0.59 + 1 + 10 + 3 + + + r-tigon-20 + FC00::75 + ARISTA02T1 + FC00::76 + 1 + 10 + 3 + + + false + r-tigon-20 + 10.0.0.60 + ARISTA03T1 + 10.0.0.61 + 1 + 10 + 3 + + + r-tigon-20 + FC00::79 + ARISTA03T1 + FC00::7A + 1 + 10 + 3 + + + false + r-tigon-20 + 10.0.0.62 + ARISTA04T1 + 10.0.0.63 + 1 + 10 + 3 + + + r-tigon-20 + FC00::7D + ARISTA04T1 + FC00::7E + 1 + 10 + 3 + + + + + 65100 + r-tigon-20 + + +
10.0.0.57
+ + + +
+ +
10.0.0.59
+ + + +
+ +
10.0.0.61
+ + + +
+ +
10.0.0.63
+ + + +
+ + BGPPeer +
10.1.0.32
+ + + + BGPSLBPassive + 10.255.0.0/25 +
+ + BGPPeer +
10.1.0.32
+ + + + BGPVac + 192.168.0.0/21 +
+
+ +
+ + 64600 + ARISTA01T1 + + + + 64600 + ARISTA02T1 + + + + 64600 + ARISTA03T1 + + + + 64600 + ARISTA04T1 + + +
+
+ + + + + + HostIP + Loopback0 + + 10.1.0.32/32 + + 10.1.0.32/32 + + + HostIP1 + Loopback0 + + FC00:1::32/128 + + FC00:1::32/128 + + + HostIP2 + Loopback1 + + 10.1.0.34/32 + + 10.1.0.34/32 + + + HostIP3 + Loopback1 + + FC00:1::34/128 + + FC00:1::34/128 + + HostIP6 + Loopback3 + + 10.1.0.38/32 + + 10.1.0.38/32 + + + HostIP7 + Loopback3 + + FC00:1::38/128 + + FC00:1::38/128 + + HostIP4 + Loopback2 + + 10.1.0.36/32 + + 10.1.0.36/32 + + + HostIP5 + Loopback2 + + FC00:1::36/128 + + FC00:1::36/128 + + + + HostIP + eth0 + + 10.210.24.183/22 + + 10.210.24.183/22 + + + V6HostIP + eth0 + + fe80::bace:f6ff:fedc:bd4c/64 + + fe80::bace:f6ff:fedc:bd4c/64 + + + + + + + r-tigon-20 + + + PortChannel101 + etp63a + + + + PortChannel102 + etp63b + + + + PortChannel103 + etp64a + + + + PortChannel104 + etp64b + + + + + + + + + Vlan1000 + etp1b;etp2a;etp2b;etp3a;etp3b;etp4a;etp4b;etp5a;etp5b;etp6a;etp6b;etp7a;etp7b;etp8a;etp8b;etp9a;etp9b;etp10a;etp10b;etp13a + False + 0.0.0.0/0 + 192.0.0.1;192.0.0.2;192.0.0.3;192.0.0.4 + fc02:2000::1;fc02:2000::2;fc02:2000::3;fc02:2000::4 + 1000 + 1000 + 192.168.0.0/21 + 00:aa:bb:cc:dd:ee + + + + + + PortChannel101 + 10.0.0.56/31 + + + + PortChannel101 + FC00::71/126 + + + + PortChannel102 + 10.0.0.58/31 + + + + PortChannel102 + FC00::75/126 + + + + PortChannel103 + 10.0.0.60/31 + + + + PortChannel103 + FC00::79/126 + + + + PortChannel104 + 10.0.0.62/31 + + + + PortChannel104 + FC00::7D/126 + + + + Vlan1000 + 192.168.0.1/21 + + + + Vlan1000 + fc02:1000::1/64 + + + + + + NTP_ACL + NTP + NTP + + + SNMP_ACL + SNMP + SNMP + + + ERSPAN + Everflow + Everflow + + + ERSPANV6 + EverflowV6 + EverflowV6 + + + VTY_LINE + ssh-only + SSH + + + PortChannel101;PortChannel102;PortChannel103;PortChannel104 + DataAcl + DataPlane + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.2/21 + + 192.168.0.2/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::2/64 + + fc02:1000::2/64 + + + + + + + + Servers0 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.3/21 + + 192.168.0.3/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::3/64 + + fc02:1000::3/64 + + + + + + + + Servers1 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.4/21 + + 192.168.0.4/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::4/64 + + fc02:1000::4/64 + + + + + + + + Servers2 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.5/21 + + 192.168.0.5/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::5/64 + + fc02:1000::5/64 + + + + + + + + Servers3 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.6/21 + + 192.168.0.6/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::6/64 + + fc02:1000::6/64 + + + + + + + + Servers4 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.7/21 + + 192.168.0.7/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::7/64 + + fc02:1000::7/64 + + + + + + + + Servers5 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.8/21 + + 192.168.0.8/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::8/64 + + fc02:1000::8/64 + + + + + + + + Servers6 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.9/21 + + 192.168.0.9/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::9/64 + + fc02:1000::9/64 + + + + + + + + Servers7 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.10/21 + + 192.168.0.10/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::a/64 + + fc02:1000::a/64 + + + + + + + + Servers8 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.11/21 + + 192.168.0.11/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::b/64 + + fc02:1000::b/64 + + + + + + + + Servers9 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.12/21 + + 192.168.0.12/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::c/64 + + fc02:1000::c/64 + + + + + + + + Servers10 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.13/21 + + 192.168.0.13/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::d/64 + + fc02:1000::d/64 + + + + + + + + Servers11 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.14/21 + + 192.168.0.14/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::e/64 + + fc02:1000::e/64 + + + + + + + + Servers12 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.15/21 + + 192.168.0.15/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::f/64 + + fc02:1000::f/64 + + + + + + + + Servers13 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.16/21 + + 192.168.0.16/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::10/64 + + fc02:1000::10/64 + + + + + + + + Servers14 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.17/21 + + 192.168.0.17/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::11/64 + + fc02:1000::11/64 + + + + + + + + Servers15 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.18/21 + + 192.168.0.18/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::12/64 + + fc02:1000::12/64 + + + + + + + + Servers16 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.19/21 + + 192.168.0.19/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::13/64 + + fc02:1000::13/64 + + + + + + + + Servers17 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.20/21 + + 192.168.0.20/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::14/64 + + fc02:1000::14/64 + + + + + + + + Servers18 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.21/21 + + 192.168.0.21/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::15/64 + + fc02:1000::15/64 + + + + + + + + Servers19 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.22/21 + + 192.168.0.22/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::16/64 + + fc02:1000::16/64 + + + + + + + + Servers20 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.23/21 + + 192.168.0.23/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::17/64 + + fc02:1000::17/64 + + + + + + + + Servers21 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.24/21 + + 192.168.0.24/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::18/64 + + fc02:1000::18/64 + + + + + + + + Servers22 + + + + + + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 192.168.0.25/21 + + 192.168.0.25/21 + + + LoopbackInterface + HostIP1 + Loopback0 + + fc02:1000::19/64 + + fc02:1000::19/64 + + + + + + + + Servers23 + + + + + + + + + + + + + + DeviceInterfaceLink + ARISTA01T1 + Ethernet1 + r-tigon-20 + etp63a + + + DeviceInterfaceLink + ARISTA02T1 + Ethernet1 + r-tigon-20 + etp63b + + + DeviceInterfaceLink + ARISTA03T1 + Ethernet1 + r-tigon-20 + etp64a + + + DeviceInterfaceLink + ARISTA04T1 + Ethernet1 + r-tigon-20 + etp64b + + + DeviceInterfaceLink + r-tigon-20 + etp1b + Servers0 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp2a + Servers1 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp2b + Servers2 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp3a + Servers3 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp3b + Servers4 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp4a + Servers5 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp4b + Servers6 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp5a + Servers7 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp5b + Servers8 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp6a + Servers9 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp6b + Servers10 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp7a + Servers11 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp7b + Servers12 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp8a + Servers13 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp8b + Servers14 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp9a + Servers15 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp9b + Servers16 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp10a + Servers17 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp10b + Servers18 + eth0 + + + DeviceInterfaceLink + r-tigon-20 + etp13a + Servers23 + eth0 + + + LogicalLink + r-tigon-20 + etp1b + r-tigon-20-Servers0-SC + U + + + LogicalLink + r-tigon-20 + etp2a + r-tigon-20-Servers1-SC + U + + + LogicalLink + r-tigon-20 + etp2b + r-tigon-20-Servers2-SC + U + + + LogicalLink + r-tigon-20 + etp3a + r-tigon-20-Servers3-SC + U + + + LogicalLink + r-tigon-20 + etp3b + r-tigon-20-Servers4-SC + U + + + LogicalLink + r-tigon-20 + etp4a + r-tigon-20-Servers5-SC + U + + + LogicalLink + r-tigon-20 + etp4b + r-tigon-20-Servers6-SC + U + + + LogicalLink + r-tigon-20 + etp5a + r-tigon-20-Servers7-SC + U + + + LogicalLink + r-tigon-20 + etp5b + r-tigon-20-Servers8-SC + U + + + LogicalLink + r-tigon-20 + etp6a + r-tigon-20-Servers9-SC + U + + + LogicalLink + r-tigon-20 + etp6b + r-tigon-20-Servers10-SC + U + + + LogicalLink + r-tigon-20 + etp7a + r-tigon-20-Servers11-SC + U + + + LogicalLink + r-tigon-20 + etp7b + r-tigon-20-Servers12-SC + U + + + LogicalLink + r-tigon-20 + etp8a + r-tigon-20-Servers13-SC + U + + + LogicalLink + r-tigon-20 + etp8b + r-tigon-20-Servers14-SC + U + + + LogicalLink + r-tigon-20 + etp9a + r-tigon-20-Servers15-SC + U + + + LogicalLink + r-tigon-20 + etp9b + r-tigon-20-Servers16-SC + U + + + LogicalLink + r-tigon-20 + etp10a + r-tigon-20-Servers17-SC + U + + + LogicalLink + r-tigon-20 + etp10b + r-tigon-20-Servers18-SC + U + + + LogicalLink + r-tigon-20 + etp13a + r-tigon-20-Servers23-SC + U + + + + + r-tigon-20 + Mellanox-SN4600C-D48C40 +
+ 10.1.0.32/32 +
+ + FC00:1::32/128 + + + 10.210.24.183 + +
+ + r-tigon-21 + Mellanox-SN4600C-D48C40 +
+ 10.1.0.33/32 +
+ + FC00:1::33/128 + + + 10.210.24.193 + +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers0-SC +
+ + Server +
+ 192.168.0.2/26 +
+ + fc02:1000::2/96 + + + 0.0.0.0/0 + + Servers0 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers1-SC +
+ + Server +
+ 192.168.0.3/26 +
+ + fc02:1000::3/96 + + + 0.0.0.0/0 + + Servers1 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers2-SC +
+ + Server +
+ 192.168.0.4/26 +
+ + fc02:1000::4/96 + + + 0.0.0.0/0 + + Servers2 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers3-SC +
+ + Server +
+ 192.168.0.5/26 +
+ + fc02:1000::5/96 + + + 0.0.0.0/0 + + Servers3 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers4-SC +
+ + Server +
+ 192.168.0.6/26 +
+ + fc02:1000::6/96 + + + 0.0.0.0/0 + + Servers4 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers5-SC +
+ + Server +
+ 192.168.0.7/26 +
+ + fc02:1000::7/96 + + + 0.0.0.0/0 + + Servers5 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers6-SC +
+ + Server +
+ 192.168.0.8/26 +
+ + fc02:1000::8/96 + + + 0.0.0.0/0 + + Servers6 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers7-SC +
+ + Server +
+ 192.168.0.9/26 +
+ + fc02:1000::9/96 + + + 0.0.0.0/0 + + Servers7 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers8-SC +
+ + Server +
+ 192.168.0.10/26 +
+ + fc02:1000::a/96 + + + 0.0.0.0/0 + + Servers8 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers9-SC +
+ + Server +
+ 192.168.0.11/26 +
+ + fc02:1000::b/96 + + + 0.0.0.0/0 + + Servers9 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers10-SC +
+ + Server +
+ 192.168.0.12/26 +
+ + fc02:1000::c/96 + + + 0.0.0.0/0 + + Servers10 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers11-SC +
+ + Server +
+ 192.168.0.13/26 +
+ + fc02:1000::d/96 + + + 0.0.0.0/0 + + Servers11 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers12-SC +
+ + Server +
+ 192.168.0.14/26 +
+ + fc02:1000::e/96 + + + 0.0.0.0/0 + + Servers12 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers13-SC +
+ + Server +
+ 192.168.0.15/26 +
+ + fc02:1000::f/96 + + + 0.0.0.0/0 + + Servers13 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers14-SC +
+ + Server +
+ 192.168.0.16/26 +
+ + fc02:1000::10/96 + + + 0.0.0.0/0 + + Servers14 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers15-SC +
+ + Server +
+ 192.168.0.17/26 +
+ + fc02:1000::11/96 + + + 0.0.0.0/0 + + Servers15 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers16-SC +
+ + Server +
+ 192.168.0.18/26 +
+ + fc02:1000::12/96 + + + 0.0.0.0/0 + + Servers16 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers17-SC +
+ + Server +
+ 192.168.0.19/26 +
+ + fc02:1000::13/96 + + + 0.0.0.0/0 + + Servers17 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers18-SC +
+ + Server +
+ 192.168.0.20/26 +
+ + fc02:1000::14/96 + + + 0.0.0.0/0 + + Servers18 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers19-SC +
+ + Server +
+ 192.168.0.21/26 +
+ + fc02:1000::15/96 + + + 0.0.0.0/0 + + Servers19 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers20-SC +
+ + Server +
+ 192.168.0.22/26 +
+ + fc02:1000::16/96 + + + 0.0.0.0/0 + + Servers20 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers21-SC +
+ + Server +
+ 192.168.0.23/26 +
+ + fc02:1000::17/96 + + + 0.0.0.0/0 + + Servers21 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers22-SC +
+ + Server +
+ 192.168.0.24/26 +
+ + fc02:1000::18/96 + + + 0.0.0.0/0 + + Servers22 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + r-tigon-20-Servers23-SC +
+ + Server +
+ 192.168.0.25/26 +
+ + fc02:1000::19/96 + + + 0.0.0.0/0 + + Servers23 +
+ + ARISTA04T1 + + 10.215.18.187 + + Arista-VM + + + ARISTA03T1 + + 10.215.18.186 + + Arista-VM + + + ARISTA02T1 + + 10.215.18.185 + + Arista-VM + + + ARISTA01T1 + + 10.215.18.184 + + Arista-VM + +
+
+ + + true + + + DeviceInterface + + true + true + 1 + etp1a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp1b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp2a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp2b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp3a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp3b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp4a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp4b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp5a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp5b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp6a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp6b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp7a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp7b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp8a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp8b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp9a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp9b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp10a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp10b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp13a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp13b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp14a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp14b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp63a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp63b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp64a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp64b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp17a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp17b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp18a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp18b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp19a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp19b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp20a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp20b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp21a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp21b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp22a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp22b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp23a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp23b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp24a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp24b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp25 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + true + 1 + etp26 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + true + 1 + etp27a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp27b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp28a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp28b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp29 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + true + 1 + etp30 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + true + 1 + etp31a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp31b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp32a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp32b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp33 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + true + 1 + etp34 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + true + 1 + etp35a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp35b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp36a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp36b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp37 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + true + 1 + etp38 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + true + 1 + etp39a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp39b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp40a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp40b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp41a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp41b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp42a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp42b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp43a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp43b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp44a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp44b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp45a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp45b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp46a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp46b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp47a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp47b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp48a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp48b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp49a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp49b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp50a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp50b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp51a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp51b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp52a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp52b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp53a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp53b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp54a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp54b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp55a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp55b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp56a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp56b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp57a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp57b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp58a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp58b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp59a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp59b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp60a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp60b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp61a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp61b + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp62a + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + etp62b + + false + 0 + 0 + 50000 + + + true + 0 + Mellanox-SN4600C-D48C40 + + + + + + + r-tigon-20 + + + DeploymentId + + 1 + + + QosProfile + + Profile0 + + + GeminiEnabled + + True + + + RedundancyType + + Gemini + + + DhcpResources + + 192.0.0.1;192.0.0.2;192.0.0.3;192.0.0.4 + + + NtpResources + + 10.210.25.32;10.75.202.2 + + + SnmpResources + + 10.0.0.9 + + + TacacsGroup + + testlab + + + TacacsServer + + 10.7.34.20 + + + ForcedMgmtRoutes + + 10.75.0.0/16;10.213.0.0/16;10.215.0.0/16;10.9.0.0/16;10.212.0.0/16 + + + ErspanDestinationIpv4 + + 10.0.0.7 + + + + + + + + + + + + + GeminiPeeringLink + + True + + + UpperTOR + + r-tigon-20 + + + LowerTOR + + r-tigon-21 + + + r-tigon-21:MuxTunnel0;r-tigon-20:MuxTunnel0 + + + + r-tigon-20 + Mellanox-SN4600C-D48C40 +
diff --git a/src/sonic-config-engine/tests/sample_output/py2/bgpd_frr_dualtor.conf b/src/sonic-config-engine/tests/sample_output/py2/bgpd_frr_dualtor.conf new file mode 100644 index 000000000000..364a2c34bcaa --- /dev/null +++ b/src/sonic-config-engine/tests/sample_output/py2/bgpd_frr_dualtor.conf @@ -0,0 +1,79 @@ +! +! template: bgpd/bgpd.conf.j2 +! +! +! =========== Managed by sonic-cfggen DO NOT edit manually! ==================== +! generated by templates/quagga/bgpd.conf.j2 with config DB data +! file: bgpd.conf +! +! +! template: common/daemons.common.conf.j2 +! +hostname switch-t0 +password zebra +enable password zebra +! +log syslog informational +log facility local4 +! +! end of template: common/daemons.common.conf.j2! +agentx +! +! +! +! template: bgpd/bgpd.main.conf.j2 +! +! bgp multiple-instance +! +! BGP configuration +! +! TSA configuration +! +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.200.0/27 +! +ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 10 permit 192.168.0.0/27 +! +! +! +router bgp 65100 +! + bgp log-neighbor-changes + no bgp default ipv4-unicast + no bgp ebgp-requires-policy + coalesce-time 10000 +! + bgp bestpath as-path multipath-relax +! + bgp graceful-restart restart-time 240 + bgp graceful-restart + bgp graceful-restart preserve-fw-state + bgp graceful-restart select-defer-time 45 +! + bgp router-id 10.1.0.32 +! + network 10.1.0.32/32 +! + address-family ipv6 + network fc00:1::32/64 + exit-address-family +! + network 192.168.200.1/27 + network 192.168.0.1/27 +! +! +! + address-family ipv4 + maximum-paths 64 + exit-address-family + address-family ipv6 + maximum-paths 64 + exit-address-family +! +! end of template: bgpd/bgpd.main.conf.j2 +!! +! end of template: bgpd/bgpd.conf.j2 +! diff --git a/src/sonic-config-engine/tests/sample_output/py2/buffer-arista7060-t0.json b/src/sonic-config-engine/tests/sample_output/py2/buffer-arista7060-t0.json new file mode 100644 index 000000000000..f883dd1aa417 --- /dev/null +++ b/src/sonic-config-engine/tests/sample_output/py2/buffer-arista7060-t0.json @@ -0,0 +1,440 @@ +{ + "CABLE_LENGTH": { + "AZURE": { + "Ethernet8": "5m", + "Ethernet2": "5m", + "Ethernet0": "5m", + "Ethernet6": "5m", + "Ethernet4": "5m", + "Ethernet108": "5m", + "Ethernet100": "5m", + "Ethernet104": "5m", + "Ethernet106": "5m", + "Ethernet58": "5m", + "Ethernet126": "5m", + "Ethernet96": "5m", + "Ethernet124": "40m", + "Ethernet122": "5m", + "Ethernet92": "5m", + "Ethernet120": "40m", + "Ethernet50": "5m", + "Ethernet52": "5m", + "Ethernet54": "5m", + "Ethernet56": "5m", + "Ethernet76": "5m", + "Ethernet74": "5m", + "Ethernet18": "5m", + "Ethernet70": "5m", + "Ethernet32": "5m", + "Ethernet72": "5m", + "Ethernet16": "5m", + "Ethernet36": "5m", + "Ethernet78": "5m", + "Ethernet60": "5m", + "Ethernet28": "5m", + "Ethernet62": "5m", + "Ethernet14": "5m", + "Ethernet88": "5m", + "Ethernet118": "5m", + "Ethernet24": "5m", + "Ethernet116": "40m", + "Ethernet82": "5m", + "Ethernet114": "5m", + "Ethernet80": "5m", + "Ethernet112": "40m", + "Ethernet86": "5m", + "Ethernet110": "5m", + "Ethernet84": "5m", + "Ethernet48": "5m", + "Ethernet10": "5m", + "Ethernet44": "5m", + "Ethernet42": "5m", + "Ethernet40": "5m", + "Ethernet64": "5m", + "Ethernet66": "5m", + "Ethernet12": "5m", + "Ethernet46": "5m", + "Ethernet20": "5m", + "Ethernet22": "5m", + "Ethernet68": "5m" + } + }, + + "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":"ingress_lossless_pool", + "size":"0", + "dynamic_th":"3" + }, + "egress_lossless_profile": { + "pool":"egress_lossless_pool", + "size":"1518", + "static_th":"15982720" + }, + "egress_lossy_profile": { + "pool":"egress_lossy_pool", + "size":"1518", + "dynamic_th":"3" + } + }, + + "BUFFER_PG": { + "Ethernet8|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet4|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet68|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet96|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet124|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet92|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet120|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet52|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet56|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet76|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet72|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet32|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet16|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet36|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet12|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet28|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet88|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet116|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet80|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet112|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet84|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet48|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet44|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet40|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet64|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet60|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet20|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet24|0": { + "profile" : "ingress_lossy_profile" + } + }, + + "BUFFER_QUEUE": { + "Ethernet8|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet4|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet68|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet96|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet124|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet92|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet120|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet52|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet56|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet76|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet72|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet32|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet16|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet36|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet12|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet28|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet88|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet116|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet80|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet112|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet84|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet48|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet44|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet40|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet64|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet60|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet20|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet24|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet8|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet4|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet68|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet96|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet124|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet92|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet120|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet52|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet56|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet76|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet72|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet32|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet16|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet36|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet12|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet28|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet88|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet116|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet80|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet112|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet84|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet48|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet44|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet40|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet64|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet60|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet20|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet24|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet8|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet4|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet68|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet96|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet124|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet92|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet120|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet52|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet56|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet76|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet72|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet32|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet16|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet36|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet12|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet28|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet88|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet116|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet80|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet112|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet84|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet48|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet44|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet40|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet64|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet60|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet20|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet24|5-6": { + "profile" : "egress_lossy_profile" + } + } +} diff --git a/src/sonic-config-engine/tests/sample_output/py3/bgpd_frr_dualtor.conf b/src/sonic-config-engine/tests/sample_output/py3/bgpd_frr_dualtor.conf new file mode 100644 index 000000000000..4f606b80838c --- /dev/null +++ b/src/sonic-config-engine/tests/sample_output/py3/bgpd_frr_dualtor.conf @@ -0,0 +1,79 @@ +! +! template: bgpd/bgpd.conf.j2 +! +! +! =========== Managed by sonic-cfggen DO NOT edit manually! ==================== +! generated by templates/quagga/bgpd.conf.j2 with config DB data +! file: bgpd.conf +! +! +! template: common/daemons.common.conf.j2 +! +hostname switch-t0 +password zebra +enable password zebra +! +log syslog informational +log facility local4 +! +! end of template: common/daemons.common.conf.j2! +agentx +! +! +! +! template: bgpd/bgpd.main.conf.j2 +! +! bgp multiple-instance +! +! BGP configuration +! +! TSA configuration +! +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 10 permit 192.168.200.0/27 +! +! +! +router bgp 65100 +! + bgp log-neighbor-changes + no bgp default ipv4-unicast + no bgp ebgp-requires-policy + coalesce-time 10000 +! + bgp bestpath as-path multipath-relax +! + bgp graceful-restart restart-time 240 + bgp graceful-restart + bgp graceful-restart preserve-fw-state + bgp graceful-restart select-defer-time 45 +! + bgp router-id 10.1.0.32 +! + network 10.1.0.32/32 +! + address-family ipv6 + network fc00:1::32/64 + exit-address-family +! + network 192.168.0.1/27 + network 192.168.200.1/27 +! +! +! + address-family ipv4 + maximum-paths 64 + exit-address-family + address-family ipv6 + maximum-paths 64 + exit-address-family +! +! end of template: bgpd/bgpd.main.conf.j2 +!! +! end of template: bgpd/bgpd.conf.j2 +! diff --git a/src/sonic-config-engine/tests/sample_output/py3/buffer-arista7060-t0.json b/src/sonic-config-engine/tests/sample_output/py3/buffer-arista7060-t0.json new file mode 100644 index 000000000000..f883dd1aa417 --- /dev/null +++ b/src/sonic-config-engine/tests/sample_output/py3/buffer-arista7060-t0.json @@ -0,0 +1,440 @@ +{ + "CABLE_LENGTH": { + "AZURE": { + "Ethernet8": "5m", + "Ethernet2": "5m", + "Ethernet0": "5m", + "Ethernet6": "5m", + "Ethernet4": "5m", + "Ethernet108": "5m", + "Ethernet100": "5m", + "Ethernet104": "5m", + "Ethernet106": "5m", + "Ethernet58": "5m", + "Ethernet126": "5m", + "Ethernet96": "5m", + "Ethernet124": "40m", + "Ethernet122": "5m", + "Ethernet92": "5m", + "Ethernet120": "40m", + "Ethernet50": "5m", + "Ethernet52": "5m", + "Ethernet54": "5m", + "Ethernet56": "5m", + "Ethernet76": "5m", + "Ethernet74": "5m", + "Ethernet18": "5m", + "Ethernet70": "5m", + "Ethernet32": "5m", + "Ethernet72": "5m", + "Ethernet16": "5m", + "Ethernet36": "5m", + "Ethernet78": "5m", + "Ethernet60": "5m", + "Ethernet28": "5m", + "Ethernet62": "5m", + "Ethernet14": "5m", + "Ethernet88": "5m", + "Ethernet118": "5m", + "Ethernet24": "5m", + "Ethernet116": "40m", + "Ethernet82": "5m", + "Ethernet114": "5m", + "Ethernet80": "5m", + "Ethernet112": "40m", + "Ethernet86": "5m", + "Ethernet110": "5m", + "Ethernet84": "5m", + "Ethernet48": "5m", + "Ethernet10": "5m", + "Ethernet44": "5m", + "Ethernet42": "5m", + "Ethernet40": "5m", + "Ethernet64": "5m", + "Ethernet66": "5m", + "Ethernet12": "5m", + "Ethernet46": "5m", + "Ethernet20": "5m", + "Ethernet22": "5m", + "Ethernet68": "5m" + } + }, + + "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":"ingress_lossless_pool", + "size":"0", + "dynamic_th":"3" + }, + "egress_lossless_profile": { + "pool":"egress_lossless_pool", + "size":"1518", + "static_th":"15982720" + }, + "egress_lossy_profile": { + "pool":"egress_lossy_pool", + "size":"1518", + "dynamic_th":"3" + } + }, + + "BUFFER_PG": { + "Ethernet8|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet4|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet68|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet96|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet124|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet92|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet120|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet52|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet56|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet76|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet72|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet32|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet16|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet36|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet12|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet28|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet88|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet116|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet80|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet112|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet84|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet48|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet44|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet40|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet64|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet60|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet20|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet24|0": { + "profile" : "ingress_lossy_profile" + } + }, + + "BUFFER_QUEUE": { + "Ethernet8|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet4|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet68|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet96|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet124|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet92|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet120|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet52|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet56|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet76|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet72|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet32|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet16|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet36|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet12|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet28|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet88|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet116|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet80|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet112|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet84|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet48|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet44|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet40|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet64|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet60|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet20|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet24|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet8|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet4|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet68|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet96|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet124|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet92|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet120|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet52|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet56|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet76|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet72|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet32|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet16|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet36|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet12|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet28|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet88|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet116|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet80|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet112|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet84|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet48|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet44|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet40|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet64|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet60|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet20|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet24|0-2": { + "profile" : "egress_lossy_profile" + }, + "Ethernet8|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet4|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet68|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet96|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet124|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet92|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet120|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet52|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet56|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet76|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet72|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet32|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet16|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet36|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet12|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet28|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet88|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet116|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet80|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet112|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet84|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet48|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet44|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet40|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet64|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet60|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet20|5-6": { + "profile" : "egress_lossy_profile" + }, + "Ethernet24|5-6": { + "profile" : "egress_lossy_profile" + } + } +} diff --git a/src/sonic-config-engine/tests/sample_output/py3/buffers-mellanox4600c-t0-dynamic-remap-disabled.json b/src/sonic-config-engine/tests/sample_output/py3/buffers-mellanox4600c-t0-dynamic-remap-disabled.json new file mode 100644 index 000000000000..c70d257b3a8d --- /dev/null +++ b/src/sonic-config-engine/tests/sample_output/py3/buffers-mellanox4600c-t0-dynamic-remap-disabled.json @@ -0,0 +1,2008 @@ +{ + "CABLE_LENGTH": { + "AZURE": { + "Ethernet0": "5m", + "Ethernet2": "5m", + "Ethernet4": "5m", + "Ethernet6": "5m", + "Ethernet8": "5m", + "Ethernet10": "5m", + "Ethernet12": "5m", + "Ethernet14": "5m", + "Ethernet16": "5m", + "Ethernet18": "5m", + "Ethernet20": "5m", + "Ethernet22": "5m", + "Ethernet24": "5m", + "Ethernet26": "5m", + "Ethernet28": "5m", + "Ethernet30": "5m", + "Ethernet32": "5m", + "Ethernet34": "5m", + "Ethernet36": "5m", + "Ethernet38": "5m", + "Ethernet40": "5m", + "Ethernet44": "5m", + "Ethernet48": "5m", + "Ethernet50": "5m", + "Ethernet52": "5m", + "Ethernet54": "5m", + "Ethernet56": "5m", + "Ethernet60": "5m", + "Ethernet64": "5m", + "Ethernet68": "5m", + "Ethernet72": "5m", + "Ethernet76": "5m", + "Ethernet80": "5m", + "Ethernet84": "5m", + "Ethernet88": "5m", + "Ethernet92": "5m", + "Ethernet96": "5m", + "Ethernet100": "5m", + "Ethernet104": "5m", + "Ethernet108": "5m", + "Ethernet112": "5m", + "Ethernet116": "5m", + "Ethernet120": "5m", + "Ethernet124": "5m", + "Ethernet128": "5m", + "Ethernet132": "5m", + "Ethernet136": "5m", + "Ethernet140": "5m", + "Ethernet144": "5m", + "Ethernet148": "5m", + "Ethernet152": "5m", + "Ethernet156": "5m", + "Ethernet160": "5m", + "Ethernet164": "5m", + "Ethernet168": "5m", + "Ethernet172": "5m", + "Ethernet176": "5m", + "Ethernet180": "5m", + "Ethernet184": "5m", + "Ethernet188": "5m", + "Ethernet192": "5m", + "Ethernet194": "5m", + "Ethernet196": "5m", + "Ethernet198": "5m", + "Ethernet200": "5m", + "Ethernet204": "5m", + "Ethernet208": "5m", + "Ethernet210": "5m", + "Ethernet212": "5m", + "Ethernet214": "5m", + "Ethernet216": "5m", + "Ethernet220": "5m", + "Ethernet224": "5m", + "Ethernet226": "5m", + "Ethernet228": "5m", + "Ethernet230": "5m", + "Ethernet232": "5m", + "Ethernet234": "5m", + "Ethernet236": "5m", + "Ethernet238": "5m", + "Ethernet240": "5m", + "Ethernet242": "5m", + "Ethernet244": "5m", + "Ethernet246": "5m", + "Ethernet248": "40m", + "Ethernet250": "40m", + "Ethernet252": "40m", + "Ethernet254": "40m" + } + }, + + "BUFFER_POOL": { + "ingress_lossless_pool": { + "type": "ingress", + "mode": "dynamic" + }, + "egress_lossless_pool": { + "size": "60817392", + "type": "egress", + "mode": "dynamic" + }, + "egress_lossy_pool": { + "type": "egress", + "mode": "dynamic" + } + }, + "BUFFER_PROFILE": { + "ingress_lossless_profile": { + "pool":"ingress_lossless_pool", + "size":"0", + "dynamic_th":"7" + }, + "ingress_lossy_profile": { + "pool":"ingress_lossless_pool", + "size":"0", + "dynamic_th":"3" + }, + "egress_lossless_profile": { + "pool":"egress_lossless_pool", + "size":"0", + "dynamic_th":"7" + }, + "egress_lossy_profile": { + "pool":"egress_lossy_pool", + "size":"9216", + "dynamic_th":"7" + }, + "q_lossy_profile": { + "pool":"egress_lossy_pool", + "size":"0", + "dynamic_th":"3" + } + }, + "BUFFER_PORT_INGRESS_PROFILE_LIST": { + "Ethernet248": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet250": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet252": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet254": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet2": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet4": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet6": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet8": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet10": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet12": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet14": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet16": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet18": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet20": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet22": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet24": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet26": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet28": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet30": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet32": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet34": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet36": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet38": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet48": { + "profile_list" : "ingress_lossless_profile" + } +, + "Ethernet0": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet40": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet44": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet50": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet52": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet54": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet56": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet60": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet64": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet68": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet72": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet76": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet80": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet84": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet88": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet92": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet96": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet100": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet104": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet108": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet112": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet116": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet120": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet124": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet128": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet132": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet136": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet140": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet144": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet148": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet152": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet156": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet160": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet164": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet168": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet172": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet176": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet180": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet184": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet188": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet192": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet194": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet196": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet198": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet200": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet204": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet208": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet210": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet212": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet214": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet216": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet220": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet224": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet226": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet228": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet230": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet232": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet234": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet236": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet238": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet240": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet242": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet244": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet246": { + "profile_list" : "ingress_lossless_profile" + } + }, + "BUFFER_PORT_EGRESS_PROFILE_LIST": { + "Ethernet248": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet250": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet252": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet254": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet2": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet4": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet6": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet8": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet10": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet12": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet14": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet16": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet18": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet20": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet22": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet24": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet26": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet28": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet30": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet32": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet34": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet36": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet38": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet48": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + } +, + "Ethernet0": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet40": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet44": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet50": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet52": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet54": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet56": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet60": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet64": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet68": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet72": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet76": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet80": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet84": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet88": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet92": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet96": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet100": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet104": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet108": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet112": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet116": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet120": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet124": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet128": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet132": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet136": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet140": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet144": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet148": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet152": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet156": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet160": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet164": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet168": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet172": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet176": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet180": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet184": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet188": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet192": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet194": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet196": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet198": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet200": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet204": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet208": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet210": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet212": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet214": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet216": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet220": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet224": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet226": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet228": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet230": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet232": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet234": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet236": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet238": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet240": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet242": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet244": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet246": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + } + }, + + "BUFFER_PG": { + "Ethernet248|3-4": { + "profile" : "NULL" + }, + "Ethernet248|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet250|3-4": { + "profile" : "NULL" + }, + "Ethernet250|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet252|3-4": { + "profile" : "NULL" + }, + "Ethernet252|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet254|3-4": { + "profile" : "NULL" + }, + "Ethernet254|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet2|3-4": { + "profile" : "NULL" + }, + "Ethernet2|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet4|3-4": { + "profile" : "NULL" + }, + "Ethernet4|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet6|3-4": { + "profile" : "NULL" + }, + "Ethernet6|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet8|3-4": { + "profile" : "NULL" + }, + "Ethernet8|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet10|3-4": { + "profile" : "NULL" + }, + "Ethernet10|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet12|3-4": { + "profile" : "NULL" + }, + "Ethernet12|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet14|3-4": { + "profile" : "NULL" + }, + "Ethernet14|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet16|3-4": { + "profile" : "NULL" + }, + "Ethernet16|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet18|3-4": { + "profile" : "NULL" + }, + "Ethernet18|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet20|3-4": { + "profile" : "NULL" + }, + "Ethernet20|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet22|3-4": { + "profile" : "NULL" + }, + "Ethernet22|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet24|3-4": { + "profile" : "NULL" + }, + "Ethernet24|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet26|3-4": { + "profile" : "NULL" + }, + "Ethernet26|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet28|3-4": { + "profile" : "NULL" + }, + "Ethernet28|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet30|3-4": { + "profile" : "NULL" + }, + "Ethernet30|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet32|3-4": { + "profile" : "NULL" + }, + "Ethernet32|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet34|3-4": { + "profile" : "NULL" + }, + "Ethernet34|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet36|3-4": { + "profile" : "NULL" + }, + "Ethernet36|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet38|3-4": { + "profile" : "NULL" + }, + "Ethernet38|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet48|3-4": { + "profile" : "NULL" + }, + "Ethernet48|0": { + "profile" : "ingress_lossy_profile" + } +, "Ethernet0|3-4": { + "profile" : "NULL" + }, + "Ethernet0|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet40|3-4": { + "profile" : "NULL" + }, + "Ethernet40|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet44|3-4": { + "profile" : "NULL" + }, + "Ethernet44|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet50|3-4": { + "profile" : "NULL" + }, + "Ethernet50|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet52|3-4": { + "profile" : "NULL" + }, + "Ethernet52|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet54|3-4": { + "profile" : "NULL" + }, + "Ethernet54|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet56|3-4": { + "profile" : "NULL" + }, + "Ethernet56|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet60|3-4": { + "profile" : "NULL" + }, + "Ethernet60|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet64|3-4": { + "profile" : "NULL" + }, + "Ethernet64|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet68|3-4": { + "profile" : "NULL" + }, + "Ethernet68|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet72|3-4": { + "profile" : "NULL" + }, + "Ethernet72|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet76|3-4": { + "profile" : "NULL" + }, + "Ethernet76|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet80|3-4": { + "profile" : "NULL" + }, + "Ethernet80|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet84|3-4": { + "profile" : "NULL" + }, + "Ethernet84|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet88|3-4": { + "profile" : "NULL" + }, + "Ethernet88|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet92|3-4": { + "profile" : "NULL" + }, + "Ethernet92|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet96|3-4": { + "profile" : "NULL" + }, + "Ethernet96|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet100|3-4": { + "profile" : "NULL" + }, + "Ethernet100|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet104|3-4": { + "profile" : "NULL" + }, + "Ethernet104|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet108|3-4": { + "profile" : "NULL" + }, + "Ethernet108|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet112|3-4": { + "profile" : "NULL" + }, + "Ethernet112|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet116|3-4": { + "profile" : "NULL" + }, + "Ethernet116|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet120|3-4": { + "profile" : "NULL" + }, + "Ethernet120|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet124|3-4": { + "profile" : "NULL" + }, + "Ethernet124|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet128|3-4": { + "profile" : "NULL" + }, + "Ethernet128|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet132|3-4": { + "profile" : "NULL" + }, + "Ethernet132|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet136|3-4": { + "profile" : "NULL" + }, + "Ethernet136|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet140|3-4": { + "profile" : "NULL" + }, + "Ethernet140|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet144|3-4": { + "profile" : "NULL" + }, + "Ethernet144|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet148|3-4": { + "profile" : "NULL" + }, + "Ethernet148|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet152|3-4": { + "profile" : "NULL" + }, + "Ethernet152|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet156|3-4": { + "profile" : "NULL" + }, + "Ethernet156|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet160|3-4": { + "profile" : "NULL" + }, + "Ethernet160|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet164|3-4": { + "profile" : "NULL" + }, + "Ethernet164|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet168|3-4": { + "profile" : "NULL" + }, + "Ethernet168|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet172|3-4": { + "profile" : "NULL" + }, + "Ethernet172|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet176|3-4": { + "profile" : "NULL" + }, + "Ethernet176|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet180|3-4": { + "profile" : "NULL" + }, + "Ethernet180|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet184|3-4": { + "profile" : "NULL" + }, + "Ethernet184|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet188|3-4": { + "profile" : "NULL" + }, + "Ethernet188|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet192|3-4": { + "profile" : "NULL" + }, + "Ethernet192|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet194|3-4": { + "profile" : "NULL" + }, + "Ethernet194|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet196|3-4": { + "profile" : "NULL" + }, + "Ethernet196|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet198|3-4": { + "profile" : "NULL" + }, + "Ethernet198|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet200|3-4": { + "profile" : "NULL" + }, + "Ethernet200|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet204|3-4": { + "profile" : "NULL" + }, + "Ethernet204|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet208|3-4": { + "profile" : "NULL" + }, + "Ethernet208|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet210|3-4": { + "profile" : "NULL" + }, + "Ethernet210|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet212|3-4": { + "profile" : "NULL" + }, + "Ethernet212|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet214|3-4": { + "profile" : "NULL" + }, + "Ethernet214|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet216|3-4": { + "profile" : "NULL" + }, + "Ethernet216|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet220|3-4": { + "profile" : "NULL" + }, + "Ethernet220|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet224|3-4": { + "profile" : "NULL" + }, + "Ethernet224|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet226|3-4": { + "profile" : "NULL" + }, + "Ethernet226|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet228|3-4": { + "profile" : "NULL" + }, + "Ethernet228|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet230|3-4": { + "profile" : "NULL" + }, + "Ethernet230|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet232|3-4": { + "profile" : "NULL" + }, + "Ethernet232|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet234|3-4": { + "profile" : "NULL" + }, + "Ethernet234|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet236|3-4": { + "profile" : "NULL" + }, + "Ethernet236|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet238|3-4": { + "profile" : "NULL" + }, + "Ethernet238|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet240|3-4": { + "profile" : "NULL" + }, + "Ethernet240|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet242|3-4": { + "profile" : "NULL" + }, + "Ethernet242|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet244|3-4": { + "profile" : "NULL" + }, + "Ethernet244|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet246|3-4": { + "profile" : "NULL" + }, + "Ethernet246|0": { + "profile" : "ingress_lossy_profile" + } + }, + + "BUFFER_QUEUE": { + "Ethernet248|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet250|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet252|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet254|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet2|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet4|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet6|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet8|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet10|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet12|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet14|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet16|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet18|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet20|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet22|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet24|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet26|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet28|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet30|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet32|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet34|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet36|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet38|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet48|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet248|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet250|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet252|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet254|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet2|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet4|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet6|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet8|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet10|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet12|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet14|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet16|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet18|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet20|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet22|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet24|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet26|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet28|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet30|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet32|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet34|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet36|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet38|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet48|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet248|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet250|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet252|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet254|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet2|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet4|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet6|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet8|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet10|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet12|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet14|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet16|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet18|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet20|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet22|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet24|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet26|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet28|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet30|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet32|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet34|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet36|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet38|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet48|5-6": { + "profile" : "q_lossy_profile" + } +, + "Ethernet0|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet40|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet44|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet50|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet52|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet54|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet56|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet60|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet64|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet68|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet72|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet76|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet80|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet84|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet88|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet92|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet96|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet100|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet104|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet108|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet112|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet116|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet120|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet124|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet128|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet132|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet136|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet140|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet144|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet148|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet152|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet156|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet160|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet164|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet168|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet172|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet176|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet180|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet184|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet188|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet192|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet194|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet196|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet198|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet200|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet204|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet208|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet210|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet212|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet214|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet216|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet220|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet224|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet226|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet228|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet230|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet232|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet234|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet236|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet238|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet240|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet242|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet244|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet246|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet0|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet40|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet44|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet50|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet52|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet54|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet56|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet60|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet64|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet68|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet72|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet76|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet80|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet84|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet88|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet92|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet96|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet100|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet104|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet108|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet112|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet116|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet120|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet124|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet128|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet132|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet136|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet140|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet144|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet148|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet152|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet156|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet160|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet164|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet168|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet172|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet176|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet180|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet184|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet188|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet192|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet194|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet196|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet198|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet200|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet204|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet208|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet210|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet212|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet214|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet216|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet220|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet224|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet226|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet228|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet230|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet232|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet234|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet236|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet238|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet240|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet242|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet244|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet246|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet0|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet40|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet44|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet50|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet52|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet54|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet56|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet60|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet64|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet68|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet72|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet76|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet80|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet84|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet88|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet92|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet96|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet100|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet104|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet108|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet112|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet116|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet120|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet124|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet128|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet132|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet136|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet140|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet144|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet148|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet152|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet156|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet160|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet164|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet168|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet172|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet176|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet180|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet184|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet188|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet192|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet194|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet196|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet198|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet200|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet204|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet208|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet210|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet212|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet214|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet216|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet220|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet224|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet226|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet228|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet230|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet232|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet234|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet236|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet238|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet240|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet242|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet244|5-6": { + "profile" : "q_lossy_profile" + }, + "Ethernet246|5-6": { + "profile" : "q_lossy_profile" + } + } +, "DEFAULT_LOSSLESS_BUFFER_PARAMETER": { + "AZURE": { + "default_dynamic_th": "0"} + }, + "LOSSLESS_TRAFFIC_PATTERN": { + "AZURE": { + "mtu": "1024", + "small_packet_percentage": "100" + } + } +} diff --git a/src/sonic-config-engine/tests/sample_output/py3/buffers-mellanox4600c-t0-dynamic.json b/src/sonic-config-engine/tests/sample_output/py3/buffers-mellanox4600c-t0-dynamic.json new file mode 100644 index 000000000000..a784d0e0cff3 --- /dev/null +++ b/src/sonic-config-engine/tests/sample_output/py3/buffers-mellanox4600c-t0-dynamic.json @@ -0,0 +1,2044 @@ +{ + "CABLE_LENGTH": { + "AZURE": { + "Ethernet0": "5m", + "Ethernet2": "5m", + "Ethernet4": "5m", + "Ethernet6": "5m", + "Ethernet8": "5m", + "Ethernet10": "5m", + "Ethernet12": "5m", + "Ethernet14": "5m", + "Ethernet16": "5m", + "Ethernet18": "5m", + "Ethernet20": "5m", + "Ethernet22": "5m", + "Ethernet24": "5m", + "Ethernet26": "5m", + "Ethernet28": "5m", + "Ethernet30": "5m", + "Ethernet32": "5m", + "Ethernet34": "5m", + "Ethernet36": "5m", + "Ethernet38": "5m", + "Ethernet40": "5m", + "Ethernet44": "5m", + "Ethernet48": "5m", + "Ethernet50": "5m", + "Ethernet52": "5m", + "Ethernet54": "5m", + "Ethernet56": "5m", + "Ethernet60": "5m", + "Ethernet64": "5m", + "Ethernet68": "5m", + "Ethernet72": "5m", + "Ethernet76": "5m", + "Ethernet80": "5m", + "Ethernet84": "5m", + "Ethernet88": "5m", + "Ethernet92": "5m", + "Ethernet96": "5m", + "Ethernet100": "5m", + "Ethernet104": "5m", + "Ethernet108": "5m", + "Ethernet112": "5m", + "Ethernet116": "5m", + "Ethernet120": "5m", + "Ethernet124": "5m", + "Ethernet128": "5m", + "Ethernet132": "5m", + "Ethernet136": "5m", + "Ethernet140": "5m", + "Ethernet144": "5m", + "Ethernet148": "5m", + "Ethernet152": "5m", + "Ethernet156": "5m", + "Ethernet160": "5m", + "Ethernet164": "5m", + "Ethernet168": "5m", + "Ethernet172": "5m", + "Ethernet176": "5m", + "Ethernet180": "5m", + "Ethernet184": "5m", + "Ethernet188": "5m", + "Ethernet192": "5m", + "Ethernet194": "5m", + "Ethernet196": "5m", + "Ethernet198": "5m", + "Ethernet200": "5m", + "Ethernet204": "5m", + "Ethernet208": "5m", + "Ethernet210": "5m", + "Ethernet212": "5m", + "Ethernet214": "5m", + "Ethernet216": "5m", + "Ethernet220": "5m", + "Ethernet224": "5m", + "Ethernet226": "5m", + "Ethernet228": "5m", + "Ethernet230": "5m", + "Ethernet232": "5m", + "Ethernet234": "5m", + "Ethernet236": "5m", + "Ethernet238": "5m", + "Ethernet240": "5m", + "Ethernet242": "5m", + "Ethernet244": "5m", + "Ethernet246": "5m", + "Ethernet248": "40m", + "Ethernet250": "40m", + "Ethernet252": "40m", + "Ethernet254": "40m" + } + }, + + "BUFFER_POOL": { + "ingress_lossless_pool": { + "type": "ingress", + "mode": "dynamic" + }, + "egress_lossless_pool": { + "size": "60817392", + "type": "egress", + "mode": "dynamic" + }, + "egress_lossy_pool": { + "type": "egress", + "mode": "dynamic" + } + }, + "BUFFER_PROFILE": { + "ingress_lossless_profile": { + "pool":"ingress_lossless_pool", + "size":"0", + "dynamic_th":"7" + }, + "ingress_lossy_profile": { + "pool":"ingress_lossless_pool", + "size":"0", + "dynamic_th":"3" + }, + "egress_lossless_profile": { + "pool":"egress_lossless_pool", + "size":"0", + "dynamic_th":"7" + }, + "egress_lossy_profile": { + "pool":"egress_lossy_pool", + "size":"9216", + "dynamic_th":"7" + }, + "q_lossy_profile": { + "pool":"egress_lossy_pool", + "size":"0", + "dynamic_th":"3" + } + }, + "BUFFER_PORT_INGRESS_PROFILE_LIST": { + "Ethernet248": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet250": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet252": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet254": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet2": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet4": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet6": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet8": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet10": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet12": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet14": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet16": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet18": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet20": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet22": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet24": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet26": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet28": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet30": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet32": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet34": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet36": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet38": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet48": { + "profile_list" : "ingress_lossless_profile" + } +, + "Ethernet0": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet40": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet44": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet50": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet52": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet54": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet56": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet60": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet64": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet68": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet72": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet76": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet80": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet84": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet88": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet92": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet96": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet100": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet104": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet108": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet112": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet116": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet120": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet124": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet128": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet132": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet136": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet140": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet144": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet148": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet152": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet156": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet160": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet164": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet168": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet172": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet176": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet180": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet184": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet188": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet192": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet194": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet196": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet198": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet200": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet204": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet208": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet210": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet212": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet214": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet216": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet220": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet224": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet226": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet228": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet230": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet232": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet234": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet236": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet238": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet240": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet242": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet244": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet246": { + "profile_list" : "ingress_lossless_profile" + } + }, + "BUFFER_PORT_EGRESS_PROFILE_LIST": { + "Ethernet248": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet250": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet252": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet254": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet2": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet4": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet6": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet8": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet10": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet12": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet14": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet16": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet18": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet20": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet22": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet24": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet26": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet28": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet30": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet32": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet34": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet36": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet38": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet48": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + } +, + "Ethernet0": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet40": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet44": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet50": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet52": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet54": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet56": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet60": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet64": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet68": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet72": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet76": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet80": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet84": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet88": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet92": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet96": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet100": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet104": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet108": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet112": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet116": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet120": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet124": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet128": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet132": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet136": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet140": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet144": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet148": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet152": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet156": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet160": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet164": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet168": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet172": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet176": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet180": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet184": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet188": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet192": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet194": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet196": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet198": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet200": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet204": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet208": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet210": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet212": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet214": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet216": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet220": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet224": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet226": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet228": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet230": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet232": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet234": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet236": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet238": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet240": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet242": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet244": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet246": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + } + }, + + "BUFFER_PG": { + "Ethernet2|3-4": { + "profile" : "NULL" + }, + "Ethernet2|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet4|3-4": { + "profile" : "NULL" + }, + "Ethernet4|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet6|3-4": { + "profile" : "NULL" + }, + "Ethernet6|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet8|3-4": { + "profile" : "NULL" + }, + "Ethernet8|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet10|3-4": { + "profile" : "NULL" + }, + "Ethernet10|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet12|3-4": { + "profile" : "NULL" + }, + "Ethernet12|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet14|3-4": { + "profile" : "NULL" + }, + "Ethernet14|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet16|3-4": { + "profile" : "NULL" + }, + "Ethernet16|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet18|3-4": { + "profile" : "NULL" + }, + "Ethernet18|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet20|3-4": { + "profile" : "NULL" + }, + "Ethernet20|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet22|3-4": { + "profile" : "NULL" + }, + "Ethernet22|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet24|3-4": { + "profile" : "NULL" + }, + "Ethernet24|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet26|3-4": { + "profile" : "NULL" + }, + "Ethernet26|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet28|3-4": { + "profile" : "NULL" + }, + "Ethernet28|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet30|3-4": { + "profile" : "NULL" + }, + "Ethernet30|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet32|3-4": { + "profile" : "NULL" + }, + "Ethernet32|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet34|3-4": { + "profile" : "NULL" + }, + "Ethernet34|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet36|3-4": { + "profile" : "NULL" + }, + "Ethernet36|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet38|3-4": { + "profile" : "NULL" + }, + "Ethernet38|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet48|3-4": { + "profile" : "NULL" + }, + "Ethernet48|0": { + "profile" : "ingress_lossy_profile" + } +, "Ethernet248|2-4": { + "profile" : "NULL" + }, + "Ethernet248|6": { + "profile" : "NULL" + }, + "Ethernet248|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet250|2-4": { + "profile" : "NULL" + }, + "Ethernet250|6": { + "profile" : "NULL" + }, + "Ethernet250|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet252|2-4": { + "profile" : "NULL" + }, + "Ethernet252|6": { + "profile" : "NULL" + }, + "Ethernet252|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet254|2-4": { + "profile" : "NULL" + }, + "Ethernet254|6": { + "profile" : "NULL" + }, + "Ethernet254|0": { + "profile" : "ingress_lossy_profile" + } +, "Ethernet0|3-4": { + "profile" : "NULL" + }, + "Ethernet0|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet40|3-4": { + "profile" : "NULL" + }, + "Ethernet40|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet44|3-4": { + "profile" : "NULL" + }, + "Ethernet44|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet50|3-4": { + "profile" : "NULL" + }, + "Ethernet50|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet52|3-4": { + "profile" : "NULL" + }, + "Ethernet52|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet54|3-4": { + "profile" : "NULL" + }, + "Ethernet54|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet56|3-4": { + "profile" : "NULL" + }, + "Ethernet56|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet60|3-4": { + "profile" : "NULL" + }, + "Ethernet60|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet64|3-4": { + "profile" : "NULL" + }, + "Ethernet64|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet68|3-4": { + "profile" : "NULL" + }, + "Ethernet68|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet72|3-4": { + "profile" : "NULL" + }, + "Ethernet72|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet76|3-4": { + "profile" : "NULL" + }, + "Ethernet76|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet80|3-4": { + "profile" : "NULL" + }, + "Ethernet80|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet84|3-4": { + "profile" : "NULL" + }, + "Ethernet84|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet88|3-4": { + "profile" : "NULL" + }, + "Ethernet88|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet92|3-4": { + "profile" : "NULL" + }, + "Ethernet92|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet96|3-4": { + "profile" : "NULL" + }, + "Ethernet96|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet100|3-4": { + "profile" : "NULL" + }, + "Ethernet100|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet104|3-4": { + "profile" : "NULL" + }, + "Ethernet104|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet108|3-4": { + "profile" : "NULL" + }, + "Ethernet108|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet112|3-4": { + "profile" : "NULL" + }, + "Ethernet112|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet116|3-4": { + "profile" : "NULL" + }, + "Ethernet116|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet120|3-4": { + "profile" : "NULL" + }, + "Ethernet120|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet124|3-4": { + "profile" : "NULL" + }, + "Ethernet124|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet128|3-4": { + "profile" : "NULL" + }, + "Ethernet128|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet132|3-4": { + "profile" : "NULL" + }, + "Ethernet132|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet136|3-4": { + "profile" : "NULL" + }, + "Ethernet136|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet140|3-4": { + "profile" : "NULL" + }, + "Ethernet140|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet144|3-4": { + "profile" : "NULL" + }, + "Ethernet144|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet148|3-4": { + "profile" : "NULL" + }, + "Ethernet148|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet152|3-4": { + "profile" : "NULL" + }, + "Ethernet152|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet156|3-4": { + "profile" : "NULL" + }, + "Ethernet156|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet160|3-4": { + "profile" : "NULL" + }, + "Ethernet160|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet164|3-4": { + "profile" : "NULL" + }, + "Ethernet164|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet168|3-4": { + "profile" : "NULL" + }, + "Ethernet168|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet172|3-4": { + "profile" : "NULL" + }, + "Ethernet172|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet176|3-4": { + "profile" : "NULL" + }, + "Ethernet176|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet180|3-4": { + "profile" : "NULL" + }, + "Ethernet180|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet184|3-4": { + "profile" : "NULL" + }, + "Ethernet184|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet188|3-4": { + "profile" : "NULL" + }, + "Ethernet188|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet192|3-4": { + "profile" : "NULL" + }, + "Ethernet192|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet194|3-4": { + "profile" : "NULL" + }, + "Ethernet194|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet196|3-4": { + "profile" : "NULL" + }, + "Ethernet196|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet198|3-4": { + "profile" : "NULL" + }, + "Ethernet198|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet200|3-4": { + "profile" : "NULL" + }, + "Ethernet200|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet204|3-4": { + "profile" : "NULL" + }, + "Ethernet204|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet208|3-4": { + "profile" : "NULL" + }, + "Ethernet208|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet210|3-4": { + "profile" : "NULL" + }, + "Ethernet210|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet212|3-4": { + "profile" : "NULL" + }, + "Ethernet212|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet214|3-4": { + "profile" : "NULL" + }, + "Ethernet214|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet216|3-4": { + "profile" : "NULL" + }, + "Ethernet216|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet220|3-4": { + "profile" : "NULL" + }, + "Ethernet220|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet224|3-4": { + "profile" : "NULL" + }, + "Ethernet224|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet226|3-4": { + "profile" : "NULL" + }, + "Ethernet226|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet228|3-4": { + "profile" : "NULL" + }, + "Ethernet228|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet230|3-4": { + "profile" : "NULL" + }, + "Ethernet230|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet232|3-4": { + "profile" : "NULL" + }, + "Ethernet232|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet234|3-4": { + "profile" : "NULL" + }, + "Ethernet234|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet236|3-4": { + "profile" : "NULL" + }, + "Ethernet236|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet238|3-4": { + "profile" : "NULL" + }, + "Ethernet238|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet240|3-4": { + "profile" : "NULL" + }, + "Ethernet240|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet242|3-4": { + "profile" : "NULL" + }, + "Ethernet242|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet244|3-4": { + "profile" : "NULL" + }, + "Ethernet244|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet246|3-4": { + "profile" : "NULL" + }, + "Ethernet246|0": { + "profile" : "ingress_lossy_profile" + } + }, + + "BUFFER_QUEUE": { + "Ethernet2|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet4|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet6|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet8|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet10|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet12|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet14|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet16|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet18|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet20|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet22|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet24|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet26|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet28|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet30|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet32|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet34|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet36|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet38|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet48|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet2|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet4|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet6|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet8|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet10|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet12|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet14|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet16|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet18|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet20|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet22|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet24|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet26|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet28|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet30|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet32|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet34|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet36|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet38|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet48|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet2|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet4|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet6|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet8|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet10|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet12|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet14|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet16|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet18|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet20|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet22|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet24|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet26|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet28|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet30|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet32|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet34|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet36|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet38|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet48|5-7": { + "profile" : "q_lossy_profile" + } +, "Ethernet248|0-1": { + "profile" : "q_lossy_profile" + }, + "Ethernet248|2-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet248|5": { + "profile" : "q_lossy_profile" + }, + "Ethernet248|6": { + "profile" : "egress_lossless_profile" + }, + "Ethernet248|7": { + "profile" : "q_lossy_profile" + }, + "Ethernet250|0-1": { + "profile" : "q_lossy_profile" + }, + "Ethernet250|2-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet250|5": { + "profile" : "q_lossy_profile" + }, + "Ethernet250|6": { + "profile" : "egress_lossless_profile" + }, + "Ethernet250|7": { + "profile" : "q_lossy_profile" + }, + "Ethernet252|0-1": { + "profile" : "q_lossy_profile" + }, + "Ethernet252|2-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet252|5": { + "profile" : "q_lossy_profile" + }, + "Ethernet252|6": { + "profile" : "egress_lossless_profile" + }, + "Ethernet252|7": { + "profile" : "q_lossy_profile" + }, + "Ethernet254|0-1": { + "profile" : "q_lossy_profile" + }, + "Ethernet254|2-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet254|5": { + "profile" : "q_lossy_profile" + }, + "Ethernet254|6": { + "profile" : "egress_lossless_profile" + }, + "Ethernet254|7": { + "profile" : "q_lossy_profile" + } +, + "Ethernet0|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet40|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet44|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet50|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet52|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet54|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet56|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet60|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet64|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet68|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet72|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet76|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet80|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet84|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet88|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet92|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet96|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet100|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet104|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet108|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet112|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet116|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet120|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet124|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet128|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet132|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet136|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet140|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet144|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet148|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet152|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet156|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet160|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet164|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet168|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet172|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet176|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet180|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet184|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet188|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet192|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet194|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet196|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet198|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet200|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet204|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet208|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet210|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet212|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet214|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet216|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet220|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet224|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet226|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet228|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet230|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet232|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet234|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet236|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet238|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet240|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet242|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet244|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet246|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet0|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet40|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet44|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet50|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet52|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet54|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet56|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet60|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet64|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet68|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet72|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet76|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet80|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet84|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet88|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet92|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet96|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet100|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet104|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet108|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet112|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet116|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet120|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet124|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet128|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet132|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet136|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet140|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet144|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet148|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet152|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet156|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet160|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet164|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet168|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet172|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet176|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet180|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet184|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet188|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet192|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet194|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet196|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet198|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet200|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet204|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet208|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet210|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet212|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet214|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet216|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet220|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet224|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet226|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet228|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet230|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet232|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet234|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet236|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet238|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet240|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet242|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet244|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet246|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet0|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet40|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet44|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet50|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet52|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet54|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet56|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet60|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet64|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet68|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet72|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet76|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet80|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet84|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet88|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet92|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet96|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet100|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet104|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet108|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet112|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet116|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet120|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet124|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet128|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet132|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet136|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet140|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet144|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet148|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet152|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet156|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet160|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet164|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet168|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet172|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet176|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet180|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet184|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet188|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet192|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet194|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet196|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet198|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet200|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet204|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet208|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet210|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet212|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet214|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet216|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet220|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet224|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet226|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet228|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet230|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet232|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet234|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet236|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet238|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet240|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet242|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet244|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet246|5-7": { + "profile" : "q_lossy_profile" + } + } +, "DEFAULT_LOSSLESS_BUFFER_PARAMETER": { + "AZURE": { + "default_dynamic_th": "0"} + }, + "LOSSLESS_TRAFFIC_PATTERN": { + "AZURE": { + "mtu": "1024", + "small_packet_percentage": "100" + } + } +} diff --git a/src/sonic-config-engine/tests/sample_output/py3/buffers-mellanox2700.json b/src/sonic-config-engine/tests/sample_output/py3/buffers-mellanox4600c-t0-remap-disabled.json similarity index 55% rename from src/sonic-config-engine/tests/sample_output/py3/buffers-mellanox2700.json rename to src/sonic-config-engine/tests/sample_output/py3/buffers-mellanox4600c-t0-remap-disabled.json index 49da9b064afa..deaf75d0db24 100644 --- a/src/sonic-config-engine/tests/sample_output/py3/buffers-mellanox2700.json +++ b/src/sonic-config-engine/tests/sample_output/py3/buffers-mellanox4600c-t0-remap-disabled.json @@ -14,49 +14,81 @@ "Ethernet20": "5m", "Ethernet22": "5m", "Ethernet24": "5m", + "Ethernet26": "5m", "Ethernet28": "5m", + "Ethernet30": "5m", "Ethernet32": "5m", + "Ethernet34": "5m", "Ethernet36": "5m", + "Ethernet38": "5m", "Ethernet40": "5m", - "Ethernet42": "5m", "Ethernet44": "5m", - "Ethernet46": "5m", "Ethernet48": "5m", "Ethernet50": "5m", "Ethernet52": "5m", "Ethernet54": "5m", "Ethernet56": "5m", - "Ethernet58": "5m", "Ethernet60": "5m", - "Ethernet62": "5m", - "Ethernet64": "40m", - "Ethernet66": "40m", - "Ethernet68": "40m", - "Ethernet70": "40m", + "Ethernet64": "5m", + "Ethernet68": "5m", "Ethernet72": "5m", - "Ethernet74": "5m", "Ethernet76": "5m", - "Ethernet78": "5m", "Ethernet80": "5m", - "Ethernet82": "5m", "Ethernet84": "5m", - "Ethernet86": "5m", "Ethernet88": "5m", "Ethernet92": "5m", "Ethernet96": "5m", "Ethernet100": "5m", "Ethernet104": "5m", - "Ethernet106": "5m", "Ethernet108": "5m", - "Ethernet110": "5m", "Ethernet112": "5m", - "Ethernet114": "5m", "Ethernet116": "5m", - "Ethernet118": "5m", "Ethernet120": "5m", - "Ethernet122": "5m", "Ethernet124": "5m", - "Ethernet126": "5m" + "Ethernet128": "5m", + "Ethernet132": "5m", + "Ethernet136": "5m", + "Ethernet140": "5m", + "Ethernet144": "5m", + "Ethernet148": "5m", + "Ethernet152": "5m", + "Ethernet156": "5m", + "Ethernet160": "5m", + "Ethernet164": "5m", + "Ethernet168": "5m", + "Ethernet172": "5m", + "Ethernet176": "5m", + "Ethernet180": "5m", + "Ethernet184": "5m", + "Ethernet188": "5m", + "Ethernet192": "5m", + "Ethernet194": "5m", + "Ethernet196": "5m", + "Ethernet198": "5m", + "Ethernet200": "5m", + "Ethernet204": "5m", + "Ethernet208": "5m", + "Ethernet210": "5m", + "Ethernet212": "5m", + "Ethernet214": "5m", + "Ethernet216": "5m", + "Ethernet220": "5m", + "Ethernet224": "5m", + "Ethernet226": "5m", + "Ethernet228": "5m", + "Ethernet230": "5m", + "Ethernet232": "5m", + "Ethernet234": "5m", + "Ethernet236": "5m", + "Ethernet238": "5m", + "Ethernet240": "5m", + "Ethernet242": "5m", + "Ethernet244": "5m", + "Ethernet246": "5m", + "Ethernet248": "40m", + "Ethernet250": "40m", + "Ethernet252": "40m", + "Ethernet254": "40m" } }, @@ -67,18 +99,18 @@ "size": "0" }, "ingress_lossless_pool": { - "size": "7719936", - "xoff": "1032192", + "size": "55902208", + "xoff": "1179648", "type": "ingress", "mode": "dynamic" }, "egress_lossless_pool": { - "size": "13945824", + "size": "60817392", "type": "egress", "mode": "dynamic" }, "egress_lossy_pool": { - "size": "7719936", + "size": "55902208", "type": "egress", "mode": "dynamic" } @@ -131,16 +163,16 @@ } }, "BUFFER_PORT_INGRESS_PROFILE_LIST": { - "Ethernet64": { + "Ethernet248": { "profile_list" : "ingress_lossless_profile" }, - "Ethernet66": { + "Ethernet250": { "profile_list" : "ingress_lossless_profile" }, - "Ethernet68": { + "Ethernet252": { "profile_list" : "ingress_lossless_profile" }, - "Ethernet70": { + "Ethernet254": { "profile_list" : "ingress_lossless_profile" }, "Ethernet2": { @@ -179,79 +211,73 @@ "Ethernet24": { "profile_list" : "ingress_lossless_profile" }, - "Ethernet28": { + "Ethernet26": { "profile_list" : "ingress_lossless_profile" }, - "Ethernet32": { + "Ethernet28": { "profile_list" : "ingress_lossless_profile" }, - "Ethernet36": { + "Ethernet30": { "profile_list" : "ingress_lossless_profile" }, - "Ethernet40": { + "Ethernet32": { "profile_list" : "ingress_lossless_profile" }, - "Ethernet42": { + "Ethernet34": { "profile_list" : "ingress_lossless_profile" }, - "Ethernet44": { + "Ethernet36": { "profile_list" : "ingress_lossless_profile" }, - "Ethernet46": { + "Ethernet38": { "profile_list" : "ingress_lossless_profile" }, "Ethernet48": { "profile_list" : "ingress_lossless_profile" + } +, + "Ethernet0": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet40": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet44": { + "profile_list" : "ingress_lossless_zero_profile" }, "Ethernet50": { - "profile_list" : "ingress_lossless_profile" + "profile_list" : "ingress_lossless_zero_profile" }, "Ethernet52": { - "profile_list" : "ingress_lossless_profile" + "profile_list" : "ingress_lossless_zero_profile" }, "Ethernet54": { - "profile_list" : "ingress_lossless_profile" - }, - "Ethernet56": { - "profile_list" : "ingress_lossless_profile" - } -, - "Ethernet0": { "profile_list" : "ingress_lossless_zero_profile" }, - "Ethernet58": { + "Ethernet56": { "profile_list" : "ingress_lossless_zero_profile" }, "Ethernet60": { "profile_list" : "ingress_lossless_zero_profile" }, - "Ethernet62": { + "Ethernet64": { "profile_list" : "ingress_lossless_zero_profile" }, - "Ethernet72": { + "Ethernet68": { "profile_list" : "ingress_lossless_zero_profile" }, - "Ethernet74": { + "Ethernet72": { "profile_list" : "ingress_lossless_zero_profile" }, "Ethernet76": { "profile_list" : "ingress_lossless_zero_profile" }, - "Ethernet78": { - "profile_list" : "ingress_lossless_zero_profile" - }, "Ethernet80": { "profile_list" : "ingress_lossless_zero_profile" }, - "Ethernet82": { - "profile_list" : "ingress_lossless_zero_profile" - }, "Ethernet84": { "profile_list" : "ingress_lossless_zero_profile" }, - "Ethernet86": { - "profile_list" : "ingress_lossless_zero_profile" - }, "Ethernet88": { "profile_list" : "ingress_lossless_zero_profile" }, @@ -267,51 +293,153 @@ "Ethernet104": { "profile_list" : "ingress_lossless_zero_profile" }, - "Ethernet106": { + "Ethernet108": { "profile_list" : "ingress_lossless_zero_profile" }, - "Ethernet108": { + "Ethernet112": { "profile_list" : "ingress_lossless_zero_profile" }, - "Ethernet110": { + "Ethernet116": { "profile_list" : "ingress_lossless_zero_profile" }, - "Ethernet112": { + "Ethernet120": { "profile_list" : "ingress_lossless_zero_profile" }, - "Ethernet114": { + "Ethernet124": { "profile_list" : "ingress_lossless_zero_profile" }, - "Ethernet116": { + "Ethernet128": { "profile_list" : "ingress_lossless_zero_profile" }, - "Ethernet118": { + "Ethernet132": { "profile_list" : "ingress_lossless_zero_profile" }, - "Ethernet120": { + "Ethernet136": { "profile_list" : "ingress_lossless_zero_profile" }, - "Ethernet122": { + "Ethernet140": { "profile_list" : "ingress_lossless_zero_profile" }, - "Ethernet124": { + "Ethernet144": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet148": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet152": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet156": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet160": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet164": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet168": { "profile_list" : "ingress_lossless_zero_profile" }, - "Ethernet126": { + "Ethernet172": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet176": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet180": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet184": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet188": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet192": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet194": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet196": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet198": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet200": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet204": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet208": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet210": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet212": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet214": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet216": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet220": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet224": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet226": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet228": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet230": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet232": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet234": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet236": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet238": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet240": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet242": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet244": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet246": { "profile_list" : "ingress_lossless_zero_profile" } }, "BUFFER_PORT_EGRESS_PROFILE_LIST": { - "Ethernet64": { + "Ethernet248": { "profile_list" : "egress_lossless_profile,egress_lossy_profile" }, - "Ethernet66": { + "Ethernet250": { "profile_list" : "egress_lossless_profile,egress_lossy_profile" }, - "Ethernet68": { + "Ethernet252": { "profile_list" : "egress_lossless_profile,egress_lossy_profile" }, - "Ethernet70": { + "Ethernet254": { "profile_list" : "egress_lossless_profile,egress_lossy_profile" }, "Ethernet2": { @@ -350,79 +478,73 @@ "Ethernet24": { "profile_list" : "egress_lossless_profile,egress_lossy_profile" }, - "Ethernet28": { + "Ethernet26": { "profile_list" : "egress_lossless_profile,egress_lossy_profile" }, - "Ethernet32": { + "Ethernet28": { "profile_list" : "egress_lossless_profile,egress_lossy_profile" }, - "Ethernet36": { + "Ethernet30": { "profile_list" : "egress_lossless_profile,egress_lossy_profile" }, - "Ethernet40": { + "Ethernet32": { "profile_list" : "egress_lossless_profile,egress_lossy_profile" }, - "Ethernet42": { + "Ethernet34": { "profile_list" : "egress_lossless_profile,egress_lossy_profile" }, - "Ethernet44": { + "Ethernet36": { "profile_list" : "egress_lossless_profile,egress_lossy_profile" }, - "Ethernet46": { + "Ethernet38": { "profile_list" : "egress_lossless_profile,egress_lossy_profile" }, "Ethernet48": { "profile_list" : "egress_lossless_profile,egress_lossy_profile" + } +, + "Ethernet0": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet40": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet44": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" }, "Ethernet50": { - "profile_list" : "egress_lossless_profile,egress_lossy_profile" + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" }, "Ethernet52": { - "profile_list" : "egress_lossless_profile,egress_lossy_profile" + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" }, "Ethernet54": { - "profile_list" : "egress_lossless_profile,egress_lossy_profile" - }, - "Ethernet56": { - "profile_list" : "egress_lossless_profile,egress_lossy_profile" - } -, - "Ethernet0": { "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" }, - "Ethernet58": { + "Ethernet56": { "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" }, "Ethernet60": { "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" }, - "Ethernet62": { + "Ethernet64": { "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" }, - "Ethernet72": { + "Ethernet68": { "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" }, - "Ethernet74": { + "Ethernet72": { "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" }, "Ethernet76": { "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" }, - "Ethernet78": { - "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" - }, "Ethernet80": { "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" }, - "Ethernet82": { - "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" - }, "Ethernet84": { "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" }, - "Ethernet86": { - "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" - }, "Ethernet88": { "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" }, @@ -438,51 +560,154 @@ "Ethernet104": { "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" }, - "Ethernet106": { + "Ethernet108": { "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" }, - "Ethernet108": { + "Ethernet112": { "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" }, - "Ethernet110": { + "Ethernet116": { "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" }, - "Ethernet112": { + "Ethernet120": { "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" }, - "Ethernet114": { + "Ethernet124": { "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" }, - "Ethernet116": { + "Ethernet128": { "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" }, - "Ethernet118": { + "Ethernet132": { "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" }, - "Ethernet120": { + "Ethernet136": { "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" }, - "Ethernet122": { + "Ethernet140": { "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" }, - "Ethernet124": { + "Ethernet144": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet148": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet152": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet156": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet160": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet164": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet168": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet172": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet176": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet180": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet184": { "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" }, - "Ethernet126": { + "Ethernet188": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet192": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet194": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet196": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet198": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet200": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet204": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet208": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet210": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet212": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet214": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet216": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet220": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet224": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet226": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet228": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet230": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet232": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet234": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet236": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet238": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet240": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet242": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet244": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet246": { "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" } }, + "BUFFER_PG": { - "Ethernet64|0": { + "Ethernet248|0": { "profile" : "ingress_lossy_profile" }, - "Ethernet66|0": { + "Ethernet250|0": { "profile" : "ingress_lossy_profile" }, - "Ethernet68|0": { + "Ethernet252|0": { "profile" : "ingress_lossy_profile" }, - "Ethernet70|0": { + "Ethernet254|0": { "profile" : "ingress_lossy_profile" }, "Ethernet2|0": { @@ -521,76 +746,70 @@ "Ethernet24|0": { "profile" : "ingress_lossy_profile" }, - "Ethernet28|0": { + "Ethernet26|0": { "profile" : "ingress_lossy_profile" }, - "Ethernet32|0": { + "Ethernet28|0": { "profile" : "ingress_lossy_profile" }, - "Ethernet36|0": { + "Ethernet30|0": { "profile" : "ingress_lossy_profile" }, - "Ethernet40|0": { + "Ethernet32|0": { "profile" : "ingress_lossy_profile" }, - "Ethernet42|0": { + "Ethernet34|0": { "profile" : "ingress_lossy_profile" }, - "Ethernet44|0": { + "Ethernet36|0": { "profile" : "ingress_lossy_profile" }, - "Ethernet46|0": { + "Ethernet38|0": { "profile" : "ingress_lossy_profile" }, "Ethernet48|0": { "profile" : "ingress_lossy_profile" - }, - "Ethernet50|0": { - "profile" : "ingress_lossy_profile" - }, - "Ethernet52|0": { - "profile" : "ingress_lossy_profile" - }, - "Ethernet54|0": { - "profile" : "ingress_lossy_profile" - }, - "Ethernet56|0": { - "profile" : "ingress_lossy_profile" } , "Ethernet0|0": { "profile" : "ingress_lossy_pg_zero_profile" }, - "Ethernet58|0": { + "Ethernet40|0": { "profile" : "ingress_lossy_pg_zero_profile" }, - "Ethernet60|0": { + "Ethernet44|0": { "profile" : "ingress_lossy_pg_zero_profile" }, - "Ethernet62|0": { + "Ethernet50|0": { "profile" : "ingress_lossy_pg_zero_profile" }, - "Ethernet72|0": { + "Ethernet52|0": { "profile" : "ingress_lossy_pg_zero_profile" }, - "Ethernet74|0": { + "Ethernet54|0": { "profile" : "ingress_lossy_pg_zero_profile" }, - "Ethernet76|0": { + "Ethernet56|0": { "profile" : "ingress_lossy_pg_zero_profile" }, - "Ethernet78|0": { + "Ethernet60|0": { "profile" : "ingress_lossy_pg_zero_profile" }, - "Ethernet80|0": { + "Ethernet64|0": { "profile" : "ingress_lossy_pg_zero_profile" }, - "Ethernet82|0": { + "Ethernet68|0": { "profile" : "ingress_lossy_pg_zero_profile" }, - "Ethernet84|0": { + "Ethernet72|0": { "profile" : "ingress_lossy_pg_zero_profile" }, - "Ethernet86|0": { + "Ethernet76|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet80|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet84|0": { "profile" : "ingress_lossy_pg_zero_profile" }, "Ethernet88|0": { @@ -608,52 +827,154 @@ "Ethernet104|0": { "profile" : "ingress_lossy_pg_zero_profile" }, - "Ethernet106|0": { + "Ethernet108|0": { "profile" : "ingress_lossy_pg_zero_profile" }, - "Ethernet108|0": { + "Ethernet112|0": { "profile" : "ingress_lossy_pg_zero_profile" }, - "Ethernet110|0": { + "Ethernet116|0": { "profile" : "ingress_lossy_pg_zero_profile" }, - "Ethernet112|0": { + "Ethernet120|0": { "profile" : "ingress_lossy_pg_zero_profile" }, - "Ethernet114|0": { + "Ethernet124|0": { "profile" : "ingress_lossy_pg_zero_profile" }, - "Ethernet116|0": { + "Ethernet128|0": { "profile" : "ingress_lossy_pg_zero_profile" }, - "Ethernet118|0": { + "Ethernet132|0": { "profile" : "ingress_lossy_pg_zero_profile" }, - "Ethernet120|0": { + "Ethernet136|0": { "profile" : "ingress_lossy_pg_zero_profile" }, - "Ethernet122|0": { + "Ethernet140|0": { "profile" : "ingress_lossy_pg_zero_profile" }, - "Ethernet124|0": { + "Ethernet144|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet148|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet152|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet156|0": { "profile" : "ingress_lossy_pg_zero_profile" }, - "Ethernet126|0": { + "Ethernet160|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet164|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet168|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet172|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet176|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet180|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet184|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet188|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet192|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet194|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet196|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet198|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet200|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet204|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet208|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet210|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet212|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet214|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet216|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet220|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet224|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet226|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet228|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet230|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet232|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet234|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet236|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet238|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet240|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet242|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet244|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet246|0": { "profile" : "ingress_lossy_pg_zero_profile" } }, "BUFFER_QUEUE": { - "Ethernet64|3-4": { + "Ethernet248|3-4": { "profile" : "egress_lossless_profile" }, - "Ethernet66|3-4": { + "Ethernet250|3-4": { "profile" : "egress_lossless_profile" }, - "Ethernet68|3-4": { + "Ethernet252|3-4": { "profile" : "egress_lossless_profile" }, - "Ethernet70|3-4": { + "Ethernet254|3-4": { "profile" : "egress_lossless_profile" }, "Ethernet2|3-4": { @@ -692,52 +1013,40 @@ "Ethernet24|3-4": { "profile" : "egress_lossless_profile" }, - "Ethernet28|3-4": { + "Ethernet26|3-4": { "profile" : "egress_lossless_profile" }, - "Ethernet32|3-4": { + "Ethernet28|3-4": { "profile" : "egress_lossless_profile" }, - "Ethernet36|3-4": { + "Ethernet30|3-4": { "profile" : "egress_lossless_profile" }, - "Ethernet40|3-4": { + "Ethernet32|3-4": { "profile" : "egress_lossless_profile" }, - "Ethernet42|3-4": { + "Ethernet34|3-4": { "profile" : "egress_lossless_profile" }, - "Ethernet44|3-4": { + "Ethernet36|3-4": { "profile" : "egress_lossless_profile" }, - "Ethernet46|3-4": { + "Ethernet38|3-4": { "profile" : "egress_lossless_profile" }, "Ethernet48|3-4": { "profile" : "egress_lossless_profile" }, - "Ethernet50|3-4": { - "profile" : "egress_lossless_profile" - }, - "Ethernet52|3-4": { - "profile" : "egress_lossless_profile" - }, - "Ethernet54|3-4": { - "profile" : "egress_lossless_profile" - }, - "Ethernet56|3-4": { - "profile" : "egress_lossless_profile" - }, - "Ethernet64|0-2": { + "Ethernet248|0-2": { "profile" : "q_lossy_profile" }, - "Ethernet66|0-2": { + "Ethernet250|0-2": { "profile" : "q_lossy_profile" }, - "Ethernet68|0-2": { + "Ethernet252|0-2": { "profile" : "q_lossy_profile" }, - "Ethernet70|0-2": { + "Ethernet254|0-2": { "profile" : "q_lossy_profile" }, "Ethernet2|0-2": { @@ -776,52 +1085,40 @@ "Ethernet24|0-2": { "profile" : "q_lossy_profile" }, - "Ethernet28|0-2": { + "Ethernet26|0-2": { "profile" : "q_lossy_profile" }, - "Ethernet32|0-2": { + "Ethernet28|0-2": { "profile" : "q_lossy_profile" }, - "Ethernet36|0-2": { + "Ethernet30|0-2": { "profile" : "q_lossy_profile" }, - "Ethernet40|0-2": { + "Ethernet32|0-2": { "profile" : "q_lossy_profile" }, - "Ethernet42|0-2": { + "Ethernet34|0-2": { "profile" : "q_lossy_profile" }, - "Ethernet44|0-2": { + "Ethernet36|0-2": { "profile" : "q_lossy_profile" }, - "Ethernet46|0-2": { + "Ethernet38|0-2": { "profile" : "q_lossy_profile" }, "Ethernet48|0-2": { "profile" : "q_lossy_profile" }, - "Ethernet50|0-2": { + "Ethernet248|5-6": { "profile" : "q_lossy_profile" }, - "Ethernet52|0-2": { + "Ethernet250|5-6": { "profile" : "q_lossy_profile" }, - "Ethernet54|0-2": { + "Ethernet252|5-6": { "profile" : "q_lossy_profile" }, - "Ethernet56|0-2": { - "profile" : "q_lossy_profile" - }, - "Ethernet64|5-6": { - "profile" : "q_lossy_profile" - }, - "Ethernet66|5-6": { - "profile" : "q_lossy_profile" - }, - "Ethernet68|5-6": { - "profile" : "q_lossy_profile" - }, - "Ethernet70|5-6": { + "Ethernet254|5-6": { "profile" : "q_lossy_profile" }, "Ethernet2|5-6": { @@ -860,77 +1157,71 @@ "Ethernet24|5-6": { "profile" : "q_lossy_profile" }, - "Ethernet28|5-6": { + "Ethernet26|5-6": { "profile" : "q_lossy_profile" }, - "Ethernet32|5-6": { + "Ethernet28|5-6": { "profile" : "q_lossy_profile" }, - "Ethernet36|5-6": { + "Ethernet30|5-6": { "profile" : "q_lossy_profile" }, - "Ethernet40|5-6": { + "Ethernet32|5-6": { "profile" : "q_lossy_profile" }, - "Ethernet42|5-6": { + "Ethernet34|5-6": { "profile" : "q_lossy_profile" }, - "Ethernet44|5-6": { + "Ethernet36|5-6": { "profile" : "q_lossy_profile" }, - "Ethernet46|5-6": { + "Ethernet38|5-6": { "profile" : "q_lossy_profile" }, "Ethernet48|5-6": { "profile" : "q_lossy_profile" - }, - "Ethernet50|5-6": { - "profile" : "q_lossy_profile" - }, - "Ethernet52|5-6": { - "profile" : "q_lossy_profile" - }, - "Ethernet54|5-6": { - "profile" : "q_lossy_profile" - }, - "Ethernet56|5-6": { - "profile" : "q_lossy_profile" } , "Ethernet0|3-4": { "profile" : "egress_lossless_zero_profile" }, - "Ethernet58|3-4": { + "Ethernet40|3-4": { "profile" : "egress_lossless_zero_profile" }, - "Ethernet60|3-4": { + "Ethernet44|3-4": { "profile" : "egress_lossless_zero_profile" }, - "Ethernet62|3-4": { + "Ethernet50|3-4": { "profile" : "egress_lossless_zero_profile" }, - "Ethernet72|3-4": { + "Ethernet52|3-4": { "profile" : "egress_lossless_zero_profile" }, - "Ethernet74|3-4": { + "Ethernet54|3-4": { "profile" : "egress_lossless_zero_profile" }, - "Ethernet76|3-4": { + "Ethernet56|3-4": { "profile" : "egress_lossless_zero_profile" }, - "Ethernet78|3-4": { + "Ethernet60|3-4": { "profile" : "egress_lossless_zero_profile" }, - "Ethernet80|3-4": { + "Ethernet64|3-4": { "profile" : "egress_lossless_zero_profile" }, - "Ethernet82|3-4": { + "Ethernet68|3-4": { "profile" : "egress_lossless_zero_profile" }, - "Ethernet84|3-4": { + "Ethernet72|3-4": { "profile" : "egress_lossless_zero_profile" }, - "Ethernet86|3-4": { + "Ethernet76|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet80|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet84|3-4": { "profile" : "egress_lossless_zero_profile" }, "Ethernet88|3-4": { @@ -948,73 +1239,181 @@ "Ethernet104|3-4": { "profile" : "egress_lossless_zero_profile" }, - "Ethernet106|3-4": { + "Ethernet108|3-4": { "profile" : "egress_lossless_zero_profile" }, - "Ethernet108|3-4": { + "Ethernet112|3-4": { "profile" : "egress_lossless_zero_profile" }, - "Ethernet110|3-4": { + "Ethernet116|3-4": { "profile" : "egress_lossless_zero_profile" }, - "Ethernet112|3-4": { + "Ethernet120|3-4": { "profile" : "egress_lossless_zero_profile" }, - "Ethernet114|3-4": { + "Ethernet124|3-4": { "profile" : "egress_lossless_zero_profile" }, - "Ethernet116|3-4": { + "Ethernet128|3-4": { "profile" : "egress_lossless_zero_profile" }, - "Ethernet118|3-4": { + "Ethernet132|3-4": { "profile" : "egress_lossless_zero_profile" }, - "Ethernet120|3-4": { + "Ethernet136|3-4": { "profile" : "egress_lossless_zero_profile" }, - "Ethernet122|3-4": { + "Ethernet140|3-4": { "profile" : "egress_lossless_zero_profile" }, - "Ethernet124|3-4": { + "Ethernet144|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet148|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet152|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet156|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet160|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet164|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet168|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet172|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet176|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet180|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet184|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet188|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet192|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet194|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet196|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet198|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet200|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet204|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet208|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet210|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet212|3-4": { "profile" : "egress_lossless_zero_profile" }, - "Ethernet126|3-4": { + "Ethernet214|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet216|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet220|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet224|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet226|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet228|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet230|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet232|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet234|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet236|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet238|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet240|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet242|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet244|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet246|3-4": { "profile" : "egress_lossless_zero_profile" }, "Ethernet0|0-2": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet58|0-2": { + "Ethernet40|0-2": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet60|0-2": { + "Ethernet44|0-2": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet62|0-2": { + "Ethernet50|0-2": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet72|0-2": { + "Ethernet52|0-2": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet74|0-2": { + "Ethernet54|0-2": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet76|0-2": { + "Ethernet56|0-2": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet78|0-2": { + "Ethernet60|0-2": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet80|0-2": { + "Ethernet64|0-2": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet82|0-2": { + "Ethernet68|0-2": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet84|0-2": { + "Ethernet72|0-2": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet86|0-2": { + "Ethernet76|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet80|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet84|0-2": { "profile" : "egress_lossy_zero_profile" }, "Ethernet88|0-2": { @@ -1032,73 +1431,181 @@ "Ethernet104|0-2": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet106|0-2": { + "Ethernet108|0-2": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet108|0-2": { + "Ethernet112|0-2": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet110|0-2": { + "Ethernet116|0-2": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet112|0-2": { + "Ethernet120|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet124|0-2": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet114|0-2": { + "Ethernet128|0-2": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet116|0-2": { + "Ethernet132|0-2": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet118|0-2": { + "Ethernet136|0-2": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet120|0-2": { + "Ethernet140|0-2": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet122|0-2": { + "Ethernet144|0-2": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet124|0-2": { + "Ethernet148|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet152|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet156|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet160|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet164|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet168|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet172|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet176|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet180|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet184|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet188|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet192|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet194|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet196|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet198|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet200|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet204|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet208|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet210|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet212|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet214|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet216|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet220|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet224|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet226|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet228|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet230|0-2": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet126|0-2": { + "Ethernet232|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet234|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet236|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet238|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet240|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet242|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet244|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet246|0-2": { "profile" : "egress_lossy_zero_profile" }, "Ethernet0|5-6": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet58|5-6": { + "Ethernet40|5-6": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet60|5-6": { + "Ethernet44|5-6": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet62|5-6": { + "Ethernet50|5-6": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet72|5-6": { + "Ethernet52|5-6": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet74|5-6": { + "Ethernet54|5-6": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet76|5-6": { + "Ethernet56|5-6": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet78|5-6": { + "Ethernet60|5-6": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet80|5-6": { + "Ethernet64|5-6": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet82|5-6": { + "Ethernet68|5-6": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet84|5-6": { + "Ethernet72|5-6": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet86|5-6": { + "Ethernet76|5-6": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet80|5-6": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet84|5-6": { "profile" : "egress_lossy_zero_profile" }, "Ethernet88|5-6": { @@ -1116,37 +1623,139 @@ "Ethernet104|5-6": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet106|5-6": { + "Ethernet108|5-6": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet108|5-6": { + "Ethernet112|5-6": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet110|5-6": { + "Ethernet116|5-6": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet112|5-6": { + "Ethernet120|5-6": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet124|5-6": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet114|5-6": { + "Ethernet128|5-6": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet116|5-6": { + "Ethernet132|5-6": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet118|5-6": { + "Ethernet136|5-6": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet120|5-6": { + "Ethernet140|5-6": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet122|5-6": { + "Ethernet144|5-6": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet124|5-6": { + "Ethernet148|5-6": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet152|5-6": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet156|5-6": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet160|5-6": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet164|5-6": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet168|5-6": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet172|5-6": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet176|5-6": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet180|5-6": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet184|5-6": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet188|5-6": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet192|5-6": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet194|5-6": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet196|5-6": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet198|5-6": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet200|5-6": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet204|5-6": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet208|5-6": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet210|5-6": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet212|5-6": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet214|5-6": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet216|5-6": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet220|5-6": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet224|5-6": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet226|5-6": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet228|5-6": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet230|5-6": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet232|5-6": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet234|5-6": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet236|5-6": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet238|5-6": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet240|5-6": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet242|5-6": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet244|5-6": { "profile" : "egress_lossy_zero_profile" }, - "Ethernet126|5-6": { + "Ethernet246|5-6": { "profile" : "egress_lossy_zero_profile" } } diff --git a/src/sonic-config-engine/tests/sample_output/py3/buffers-mellanox4600c-t0.json b/src/sonic-config-engine/tests/sample_output/py3/buffers-mellanox4600c-t0.json new file mode 100644 index 000000000000..e41215e6efb0 --- /dev/null +++ b/src/sonic-config-engine/tests/sample_output/py3/buffers-mellanox4600c-t0.json @@ -0,0 +1,1786 @@ +{ + "CABLE_LENGTH": { + "AZURE": { + "Ethernet0": "5m", + "Ethernet2": "5m", + "Ethernet4": "5m", + "Ethernet6": "5m", + "Ethernet8": "5m", + "Ethernet10": "5m", + "Ethernet12": "5m", + "Ethernet14": "5m", + "Ethernet16": "5m", + "Ethernet18": "5m", + "Ethernet20": "5m", + "Ethernet22": "5m", + "Ethernet24": "5m", + "Ethernet26": "5m", + "Ethernet28": "5m", + "Ethernet30": "5m", + "Ethernet32": "5m", + "Ethernet34": "5m", + "Ethernet36": "5m", + "Ethernet38": "5m", + "Ethernet40": "5m", + "Ethernet44": "5m", + "Ethernet48": "5m", + "Ethernet50": "5m", + "Ethernet52": "5m", + "Ethernet54": "5m", + "Ethernet56": "5m", + "Ethernet60": "5m", + "Ethernet64": "5m", + "Ethernet68": "5m", + "Ethernet72": "5m", + "Ethernet76": "5m", + "Ethernet80": "5m", + "Ethernet84": "5m", + "Ethernet88": "5m", + "Ethernet92": "5m", + "Ethernet96": "5m", + "Ethernet100": "5m", + "Ethernet104": "5m", + "Ethernet108": "5m", + "Ethernet112": "5m", + "Ethernet116": "5m", + "Ethernet120": "5m", + "Ethernet124": "5m", + "Ethernet128": "5m", + "Ethernet132": "5m", + "Ethernet136": "5m", + "Ethernet140": "5m", + "Ethernet144": "5m", + "Ethernet148": "5m", + "Ethernet152": "5m", + "Ethernet156": "5m", + "Ethernet160": "5m", + "Ethernet164": "5m", + "Ethernet168": "5m", + "Ethernet172": "5m", + "Ethernet176": "5m", + "Ethernet180": "5m", + "Ethernet184": "5m", + "Ethernet188": "5m", + "Ethernet192": "5m", + "Ethernet194": "5m", + "Ethernet196": "5m", + "Ethernet198": "5m", + "Ethernet200": "5m", + "Ethernet204": "5m", + "Ethernet208": "5m", + "Ethernet210": "5m", + "Ethernet212": "5m", + "Ethernet214": "5m", + "Ethernet216": "5m", + "Ethernet220": "5m", + "Ethernet224": "5m", + "Ethernet226": "5m", + "Ethernet228": "5m", + "Ethernet230": "5m", + "Ethernet232": "5m", + "Ethernet234": "5m", + "Ethernet236": "5m", + "Ethernet238": "5m", + "Ethernet240": "5m", + "Ethernet242": "5m", + "Ethernet244": "5m", + "Ethernet246": "5m", + "Ethernet248": "40m", + "Ethernet250": "40m", + "Ethernet252": "40m", + "Ethernet254": "40m" + } + }, + + "BUFFER_POOL": { + "ingress_zero_pool" : { + "mode": "static", + "type": "ingress", + "size": "0" + }, + "ingress_lossless_pool": { + "size": "55058432", + "xoff": "1712128", + "type": "ingress", + "mode": "dynamic" + }, + "egress_lossless_pool": { + "size": "60817392", + "type": "egress", + "mode": "dynamic" + }, + "egress_lossy_pool": { + "size": "55058432", + "type": "egress", + "mode": "dynamic" + } + }, + "BUFFER_PROFILE": { + "ingress_lossy_pg_zero_profile" : { + "pool":"ingress_zero_pool", + "size":"0", + "static_th":"0" + }, + "ingress_lossless_zero_profile" : { + "pool":"ingress_lossless_pool", + "size":"0", + "dynamic_th":"-8" + }, + "egress_lossless_zero_profile" : { + "pool":"egress_lossless_pool", + "size":"0", + "dynamic_th":"-8" + }, + "egress_lossy_zero_profile" : { + "pool":"egress_lossy_pool", + "size":"0", + "dynamic_th":"-8" + }, + "ingress_lossless_profile": { + "pool":"ingress_lossless_pool", + "size":"0", + "dynamic_th":"7" + }, + "ingress_lossy_profile": { + "pool":"ingress_lossless_pool", + "size":"0", + "dynamic_th":"3" + }, + "egress_lossless_profile": { + "pool":"egress_lossless_pool", + "size":"0", + "dynamic_th":"7" + }, + "egress_lossy_profile": { + "pool":"egress_lossy_pool", + "size":"9216", + "dynamic_th":"7" + }, + "q_lossy_profile": { + "pool":"egress_lossy_pool", + "size":"0", + "dynamic_th":"3" + } + }, + "BUFFER_PORT_INGRESS_PROFILE_LIST": { + "Ethernet248": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet250": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet252": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet254": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet2": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet4": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet6": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet8": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet10": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet12": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet14": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet16": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet18": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet20": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet22": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet24": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet26": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet28": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet30": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet32": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet34": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet36": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet38": { + "profile_list" : "ingress_lossless_profile" + }, + "Ethernet48": { + "profile_list" : "ingress_lossless_profile" + } +, + "Ethernet0": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet40": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet44": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet50": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet52": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet54": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet56": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet60": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet64": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet68": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet72": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet76": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet80": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet84": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet88": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet92": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet96": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet100": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet104": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet108": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet112": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet116": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet120": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet124": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet128": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet132": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet136": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet140": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet144": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet148": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet152": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet156": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet160": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet164": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet168": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet172": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet176": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet180": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet184": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet188": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet192": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet194": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet196": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet198": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet200": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet204": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet208": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet210": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet212": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet214": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet216": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet220": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet224": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet226": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet228": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet230": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet232": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet234": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet236": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet238": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet240": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet242": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet244": { + "profile_list" : "ingress_lossless_zero_profile" + }, + "Ethernet246": { + "profile_list" : "ingress_lossless_zero_profile" + } + }, + "BUFFER_PORT_EGRESS_PROFILE_LIST": { + "Ethernet248": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet250": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet252": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet254": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet2": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet4": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet6": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet8": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet10": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet12": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet14": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet16": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet18": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet20": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet22": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet24": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet26": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet28": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet30": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet32": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet34": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet36": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet38": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + }, + "Ethernet48": { + "profile_list" : "egress_lossless_profile,egress_lossy_profile" + } +, + "Ethernet0": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet40": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet44": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet50": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet52": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet54": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet56": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet60": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet64": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet68": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet72": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet76": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet80": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet84": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet88": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet92": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet96": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet100": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet104": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet108": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet112": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet116": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet120": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet124": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet128": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet132": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet136": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet140": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet144": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet148": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet152": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet156": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet160": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet164": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet168": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet172": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet176": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet180": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet184": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet188": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet192": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet194": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet196": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet198": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet200": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet204": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet208": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet210": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet212": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet214": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet216": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet220": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet224": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet226": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet228": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet230": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet232": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet234": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet236": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet238": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet240": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet242": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet244": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + }, + "Ethernet246": { + "profile_list" : "egress_lossless_zero_profile,egress_lossy_zero_profile" + } + }, + + "BUFFER_PG": { + "Ethernet2|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet4|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet6|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet8|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet10|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet12|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet14|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet16|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet18|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet20|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet22|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet24|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet26|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet28|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet30|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet32|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet34|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet36|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet38|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet48|0": { + "profile" : "ingress_lossy_profile" + } +, "Ethernet248|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet250|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet252|0": { + "profile" : "ingress_lossy_profile" + }, + "Ethernet254|0": { + "profile" : "ingress_lossy_profile" + } +, "Ethernet0|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet40|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet44|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet50|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet52|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet54|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet56|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet60|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet64|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet68|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet72|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet76|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet80|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet84|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet88|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet92|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet96|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet100|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet104|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet108|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet112|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet116|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet120|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet124|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet128|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet132|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet136|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet140|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet144|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet148|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet152|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet156|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet160|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet164|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet168|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet172|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet176|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet180|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet184|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet188|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet192|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet194|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet196|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet198|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet200|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet204|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet208|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet210|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet212|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet214|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet216|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet220|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet224|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet226|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet228|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet230|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet232|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet234|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet236|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet238|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet240|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet242|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet244|0": { + "profile" : "ingress_lossy_pg_zero_profile" + }, + "Ethernet246|0": { + "profile" : "ingress_lossy_pg_zero_profile" + } + }, + + "BUFFER_QUEUE": { + "Ethernet2|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet4|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet6|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet8|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet10|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet12|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet14|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet16|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet18|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet20|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet22|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet24|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet26|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet28|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet30|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet32|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet34|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet36|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet38|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet48|3-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet2|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet4|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet6|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet8|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet10|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet12|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet14|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet16|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet18|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet20|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet22|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet24|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet26|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet28|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet30|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet32|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet34|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet36|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet38|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet48|0-2": { + "profile" : "q_lossy_profile" + }, + "Ethernet2|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet4|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet6|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet8|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet10|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet12|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet14|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet16|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet18|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet20|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet22|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet24|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet26|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet28|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet30|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet32|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet34|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet36|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet38|5-7": { + "profile" : "q_lossy_profile" + }, + "Ethernet48|5-7": { + "profile" : "q_lossy_profile" + } +, "Ethernet248|0-1": { + "profile" : "q_lossy_profile" + }, + "Ethernet248|2-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet248|5": { + "profile" : "q_lossy_profile" + }, + "Ethernet248|6": { + "profile" : "egress_lossless_profile" + }, + "Ethernet248|7": { + "profile" : "q_lossy_profile" + }, + "Ethernet250|0-1": { + "profile" : "q_lossy_profile" + }, + "Ethernet250|2-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet250|5": { + "profile" : "q_lossy_profile" + }, + "Ethernet250|6": { + "profile" : "egress_lossless_profile" + }, + "Ethernet250|7": { + "profile" : "q_lossy_profile" + }, + "Ethernet252|0-1": { + "profile" : "q_lossy_profile" + }, + "Ethernet252|2-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet252|5": { + "profile" : "q_lossy_profile" + }, + "Ethernet252|6": { + "profile" : "egress_lossless_profile" + }, + "Ethernet252|7": { + "profile" : "q_lossy_profile" + }, + "Ethernet254|0-1": { + "profile" : "q_lossy_profile" + }, + "Ethernet254|2-4": { + "profile" : "egress_lossless_profile" + }, + "Ethernet254|5": { + "profile" : "q_lossy_profile" + }, + "Ethernet254|6": { + "profile" : "egress_lossless_profile" + }, + "Ethernet254|7": { + "profile" : "q_lossy_profile" + } +, + "Ethernet0|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet40|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet44|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet50|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet52|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet54|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet56|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet60|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet64|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet68|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet72|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet76|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet80|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet84|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet88|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet92|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet96|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet100|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet104|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet108|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet112|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet116|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet120|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet124|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet128|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet132|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet136|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet140|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet144|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet148|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet152|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet156|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet160|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet164|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet168|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet172|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet176|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet180|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet184|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet188|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet192|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet194|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet196|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet198|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet200|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet204|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet208|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet210|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet212|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet214|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet216|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet220|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet224|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet226|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet228|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet230|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet232|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet234|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet236|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet238|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet240|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet242|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet244|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet246|3-4": { + "profile" : "egress_lossless_zero_profile" + }, + "Ethernet0|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet40|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet44|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet50|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet52|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet54|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet56|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet60|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet64|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet68|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet72|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet76|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet80|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet84|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet88|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet92|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet96|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet100|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet104|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet108|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet112|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet116|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet120|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet124|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet128|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet132|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet136|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet140|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet144|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet148|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet152|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet156|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet160|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet164|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet168|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet172|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet176|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet180|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet184|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet188|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet192|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet194|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet196|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet198|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet200|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet204|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet208|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet210|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet212|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet214|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet216|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet220|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet224|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet226|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet228|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet230|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet232|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet234|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet236|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet238|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet240|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet242|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet244|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet246|0-2": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet0|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet40|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet44|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet50|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet52|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet54|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet56|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet60|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet64|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet68|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet72|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet76|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet80|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet84|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet88|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet92|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet96|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet100|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet104|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet108|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet112|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet116|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet120|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet124|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet128|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet132|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet136|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet140|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet144|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet148|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet152|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet156|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet160|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet164|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet168|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet172|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet176|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet180|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet184|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet188|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet192|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet194|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet196|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet198|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet200|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet204|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet208|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet210|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet212|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet214|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet216|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet220|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet224|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet226|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet228|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet230|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet232|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet234|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet236|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet238|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet240|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet242|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet244|5-7": { + "profile" : "egress_lossy_zero_profile" + }, + "Ethernet246|5-7": { + "profile" : "egress_lossy_zero_profile" + } + } +} diff --git a/src/sonic-config-engine/tests/sample_output/py3/qos-arista7050-t0-storage-backend.json b/src/sonic-config-engine/tests/sample_output/py3/qos-arista7050-t0-storage-backend.json index 94aa8d8a7d1d..8070e38a0c99 100644 --- a/src/sonic-config-engine/tests/sample_output/py3/qos-arista7050-t0-storage-backend.json +++ b/src/sonic-config-engine/tests/sample_output/py3/qos-arista7050-t0-storage-backend.json @@ -65,7 +65,7 @@ "wred_yellow_enable" : "true", "wred_red_enable" : "true", "ecn" : "ecn_all", - "green_max_threshold" : "2097152", + "green_max_threshold" : "12000144", "green_min_threshold" : "1048576", "yellow_max_threshold" : "2097152", "yellow_min_threshold" : "1048576", diff --git a/src/sonic-config-engine/tests/sample_output/py3/qos-arista7050cx3-dualtor.json b/src/sonic-config-engine/tests/sample_output/py3/qos-arista7050cx3-dualtor.json index afe1e9946eb6..842a84274c66 100644 --- a/src/sonic-config-engine/tests/sample_output/py3/qos-arista7050cx3-dualtor.json +++ b/src/sonic-config-engine/tests/sample_output/py3/qos-arista7050cx3-dualtor.json @@ -15,7 +15,7 @@ "AZURE": { "0": "0", "1": "1", - "2": "1", + "2": "1", "3": "3", "4": "4", "5": "5", @@ -23,6 +23,17 @@ "7": "7", "8": "1" }, + "AZURE_UPLINK": { + "0": "0", + "1": "1", + "2": "2", + "3": "3", + "4": "4", + "5": "5", + "6": "6", + "7": "7", + "8": "1" + }, "AZURE_TUNNEL": { "0": "0", "1": "1", @@ -102,6 +113,72 @@ "62": "1", "63": "1" }, + "AZURE_UPLINK": { + "0" : "1", + "1" : "1", + "2" : "2", + "3" : "3", + "4" : "4", + "5" : "1", + "6" : "6", + "7" : "1", + "8" : "0", + "9" : "1", + "10": "1", + "11": "1", + "12": "1", + "13": "1", + "14": "1", + "15": "1", + "16": "1", + "17": "1", + "18": "1", + "19": "1", + "20": "1", + "21": "1", + "22": "1", + "23": "1", + "24": "1", + "25": "1", + "26": "1", + "27": "1", + "28": "1", + "29": "1", + "30": "1", + "31": "1", + "32": "1", + "33": "8", + "34": "1", + "35": "1", + "36": "1", + "37": "1", + "38": "1", + "39": "1", + "40": "1", + "41": "1", + "42": "1", + "43": "1", + "44": "1", + "45": "1", + "46": "5", + "47": "1", + "48": "7", + "49": "1", + "50": "1", + "51": "1", + "52": "1", + "53": "1", + "54": "1", + "55": "1", + "56": "1", + "57": "1", + "58": "1", + "59": "1", + "60": "1", + "61": "1", + "62": "1", + "63": "1" + }, "AZURE_TUNNEL": { "0" : "1", "1" : "1", @@ -269,32 +346,32 @@ "pfcwd_sw_enable" : "3,4" }, "Ethernet24": { - "dscp_to_tc_map" : "AZURE", - "tc_to_queue_map" : "AZURE", + "dscp_to_tc_map" : "AZURE_UPLINK", + "tc_to_queue_map" : "AZURE_UPLINK", "tc_to_pg_map" : "AZURE", "pfc_to_queue_map": "AZURE", "pfc_enable" : "2,3,4,6", "pfcwd_sw_enable" : "3,4" }, "Ethernet28": { - "dscp_to_tc_map" : "AZURE", - "tc_to_queue_map" : "AZURE", + "dscp_to_tc_map" : "AZURE_UPLINK", + "tc_to_queue_map" : "AZURE_UPLINK", "tc_to_pg_map" : "AZURE", "pfc_to_queue_map": "AZURE", "pfc_enable" : "2,3,4,6", "pfcwd_sw_enable" : "3,4" }, "Ethernet32": { - "dscp_to_tc_map" : "AZURE", - "tc_to_queue_map" : "AZURE", + "dscp_to_tc_map" : "AZURE_UPLINK", + "tc_to_queue_map" : "AZURE_UPLINK", "tc_to_pg_map" : "AZURE", "pfc_to_queue_map": "AZURE", "pfc_enable" : "2,3,4,6", "pfcwd_sw_enable" : "3,4" }, "Ethernet36": { - "dscp_to_tc_map" : "AZURE", - "tc_to_queue_map" : "AZURE", + "dscp_to_tc_map" : "AZURE_UPLINK", + "tc_to_queue_map" : "AZURE_UPLINK", "tc_to_pg_map" : "AZURE", "pfc_to_queue_map": "AZURE", "pfc_enable" : "2,3,4,6", @@ -397,32 +474,32 @@ "pfcwd_sw_enable" : "3,4" }, "Ethernet88": { - "dscp_to_tc_map" : "AZURE", - "tc_to_queue_map" : "AZURE", + "dscp_to_tc_map" : "AZURE_UPLINK", + "tc_to_queue_map" : "AZURE_UPLINK", "tc_to_pg_map" : "AZURE", "pfc_to_queue_map": "AZURE", "pfc_enable" : "2,3,4,6", "pfcwd_sw_enable" : "3,4" }, "Ethernet92": { - "dscp_to_tc_map" : "AZURE", - "tc_to_queue_map" : "AZURE", + "dscp_to_tc_map" : "AZURE_UPLINK", + "tc_to_queue_map" : "AZURE_UPLINK", "tc_to_pg_map" : "AZURE", "pfc_to_queue_map": "AZURE", "pfc_enable" : "2,3,4,6", "pfcwd_sw_enable" : "3,4" }, "Ethernet96": { - "dscp_to_tc_map" : "AZURE", - "tc_to_queue_map" : "AZURE", + "dscp_to_tc_map" : "AZURE_UPLINK", + "tc_to_queue_map" : "AZURE_UPLINK", "tc_to_pg_map" : "AZURE", "pfc_to_queue_map": "AZURE", "pfc_enable" : "2,3,4,6", "pfcwd_sw_enable" : "3,4" }, "Ethernet100": { - "dscp_to_tc_map" : "AZURE", - "tc_to_queue_map" : "AZURE", + "dscp_to_tc_map" : "AZURE_UPLINK", + "tc_to_queue_map" : "AZURE_UPLINK", "tc_to_pg_map" : "AZURE", "pfc_to_queue_map": "AZURE", "pfc_enable" : "2,3,4,6", diff --git a/src/sonic-config-engine/tests/sample_output/py3/qos-arista7260-dualtor.json b/src/sonic-config-engine/tests/sample_output/py3/qos-arista7260-dualtor.json index b4f5b5f42e77..40768edc934d 100644 --- a/src/sonic-config-engine/tests/sample_output/py3/qos-arista7260-dualtor.json +++ b/src/sonic-config-engine/tests/sample_output/py3/qos-arista7260-dualtor.json @@ -23,6 +23,17 @@ "7": "7", "8": "1" }, + "AZURE_UPLINK": { + "0": "0", + "1": "1", + "2": "2", + "3": "3", + "4": "4", + "5": "5", + "6": "6", + "7": "7", + "8": "1" + }, "AZURE_TUNNEL": { "0": "0", "1": "1", @@ -102,6 +113,72 @@ "62": "1", "63": "1" }, + "AZURE_UPLINK": { + "0" : "1", + "1" : "1", + "2" : "2", + "3" : "3", + "4" : "4", + "5" : "1", + "6" : "6", + "7" : "1", + "8" : "0", + "9" : "1", + "10": "1", + "11": "1", + "12": "1", + "13": "1", + "14": "1", + "15": "1", + "16": "1", + "17": "1", + "18": "1", + "19": "1", + "20": "1", + "21": "1", + "22": "1", + "23": "1", + "24": "1", + "25": "1", + "26": "1", + "27": "1", + "28": "1", + "29": "1", + "30": "1", + "31": "1", + "32": "1", + "33": "8", + "34": "1", + "35": "1", + "36": "1", + "37": "1", + "38": "1", + "39": "1", + "40": "1", + "41": "1", + "42": "1", + "43": "1", + "44": "1", + "45": "1", + "46": "5", + "47": "1", + "48": "7", + "49": "1", + "50": "1", + "51": "1", + "52": "1", + "53": "1", + "54": "1", + "55": "1", + "56": "1", + "57": "1", + "58": "1", + "59": "1", + "60": "1", + "61": "1", + "62": "1", + "63": "1" + }, "AZURE_TUNNEL": { "0" : "1", "1" : "1", @@ -317,64 +394,64 @@ "pfcwd_sw_enable" : "3,4" }, "Ethernet48": { - "dscp_to_tc_map" : "AZURE", - "tc_to_queue_map" : "AZURE", + "dscp_to_tc_map" : "AZURE_UPLINK", + "tc_to_queue_map" : "AZURE_UPLINK", "tc_to_pg_map" : "AZURE", "pfc_to_queue_map": "AZURE", "pfc_enable" : "2,3,4,6", "pfcwd_sw_enable" : "3,4" }, "Ethernet52": { - "dscp_to_tc_map" : "AZURE", - "tc_to_queue_map" : "AZURE", + "dscp_to_tc_map" : "AZURE_UPLINK", + "tc_to_queue_map" : "AZURE_UPLINK", "tc_to_pg_map" : "AZURE", "pfc_to_queue_map": "AZURE", "pfc_enable" : "2,3,4,6", "pfcwd_sw_enable" : "3,4" }, "Ethernet56": { - "dscp_to_tc_map" : "AZURE", - "tc_to_queue_map" : "AZURE", + "dscp_to_tc_map" : "AZURE_UPLINK", + "tc_to_queue_map" : "AZURE_UPLINK", "tc_to_pg_map" : "AZURE", "pfc_to_queue_map": "AZURE", "pfc_enable" : "2,3,4,6", "pfcwd_sw_enable" : "3,4" }, "Ethernet60": { - "dscp_to_tc_map" : "AZURE", - "tc_to_queue_map" : "AZURE", + "dscp_to_tc_map" : "AZURE_UPLINK", + "tc_to_queue_map" : "AZURE_UPLINK", "tc_to_pg_map" : "AZURE", "pfc_to_queue_map": "AZURE", "pfc_enable" : "2,3,4,6", "pfcwd_sw_enable" : "3,4" }, "Ethernet64": { - "dscp_to_tc_map" : "AZURE", - "tc_to_queue_map" : "AZURE", + "dscp_to_tc_map" : "AZURE_UPLINK", + "tc_to_queue_map" : "AZURE_UPLINK", "tc_to_pg_map" : "AZURE", "pfc_to_queue_map": "AZURE", "pfc_enable" : "2,3,4,6", "pfcwd_sw_enable" : "3,4" }, "Ethernet68": { - "dscp_to_tc_map" : "AZURE", - "tc_to_queue_map" : "AZURE", + "dscp_to_tc_map" : "AZURE_UPLINK", + "tc_to_queue_map" : "AZURE_UPLINK", "tc_to_pg_map" : "AZURE", "pfc_to_queue_map": "AZURE", "pfc_enable" : "2,3,4,6", "pfcwd_sw_enable" : "3,4" }, "Ethernet72": { - "dscp_to_tc_map" : "AZURE", - "tc_to_queue_map" : "AZURE", + "dscp_to_tc_map" : "AZURE_UPLINK", + "tc_to_queue_map" : "AZURE_UPLINK", "tc_to_pg_map" : "AZURE", "pfc_to_queue_map": "AZURE", "pfc_enable" : "2,3,4,6", "pfcwd_sw_enable" : "3,4" }, "Ethernet76": { - "dscp_to_tc_map" : "AZURE", - "tc_to_queue_map" : "AZURE", + "dscp_to_tc_map" : "AZURE_UPLINK", + "tc_to_queue_map" : "AZURE_UPLINK", "tc_to_pg_map" : "AZURE", "pfc_to_queue_map": "AZURE", "pfc_enable" : "2,3,4,6", diff --git a/src/sonic-config-engine/tests/sample_output/py3/qos-mellanox4600c-d48c40-t0-remap-disabled.json b/src/sonic-config-engine/tests/sample_output/py3/qos-mellanox4600c-d48c40-t0-remap-disabled.json new file mode 100644 index 000000000000..a131d36a5f82 --- /dev/null +++ b/src/sonic-config-engine/tests/sample_output/py3/qos-mellanox4600c-d48c40-t0-remap-disabled.json @@ -0,0 +1,884 @@ + +{ + "TC_TO_PRIORITY_GROUP_MAP": { + "AZURE": { + "0": "0", + "1": "0", + "2": "0", + "3": "3", + "4": "4", + "5": "0", + "6": "0", + "7": "7" + } + }, + "MAP_PFC_PRIORITY_TO_QUEUE": { + "AZURE": { + "0": "0", + "1": "1", + "2": "2", + "3": "3", + "4": "4", + "5": "5", + "6": "6", + "7": "7" + } + }, + "TC_TO_QUEUE_MAP": { + "AZURE": { + "0": "0", + "1": "1", + "2": "2", + "3": "3", + "4": "4", + "5": "5", + "6": "6", + "7": "7" + } + }, + "DSCP_TO_TC_MAP": { + "AZURE": { + "0" : "1", + "1" : "1", + "2" : "1", + "3" : "3", + "4" : "4", + "5" : "2", + "6" : "1", + "7" : "1", + "8" : "0", + "9" : "1", + "10": "1", + "11": "1", + "12": "1", + "13": "1", + "14": "1", + "15": "1", + "16": "1", + "17": "1", + "18": "1", + "19": "1", + "20": "1", + "21": "1", + "22": "1", + "23": "1", + "24": "1", + "25": "1", + "26": "1", + "27": "1", + "28": "1", + "29": "1", + "30": "1", + "31": "1", + "32": "1", + "33": "1", + "34": "1", + "35": "1", + "36": "1", + "37": "1", + "38": "1", + "39": "1", + "40": "1", + "41": "1", + "42": "1", + "43": "1", + "44": "1", + "45": "1", + "46": "5", + "47": "1", + "48": "6", + "49": "1", + "50": "1", + "51": "1", + "52": "1", + "53": "1", + "54": "1", + "55": "1", + "56": "1", + "57": "1", + "58": "1", + "59": "1", + "60": "1", + "61": "1", + "62": "1", + "63": "1" + } + }, + "SCHEDULER": { + "scheduler.0": { + "type" : "DWRR", + "weight": "14" + }, + "scheduler.1": { + "type" : "DWRR", + "weight": "15" + } + }, + "PORT_QOS_MAP": { + "global": { + "dscp_to_tc_map" : "AZURE" + }, "Ethernet2": { + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet4": { + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet6": { + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet8": { + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet10": { + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet12": { + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet14": { + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet16": { + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet18": { + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet20": { + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet22": { + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet24": { + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet26": { + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet28": { + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet30": { + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet32": { + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet34": { + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet36": { + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet38": { + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet48": { + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet248": { + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet250": { + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet252": { + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet254": { + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + } + }, + "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" : "1048576", + "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" + } + }, + "QUEUE": { + "Ethernet2|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet4|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet6|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet8|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet10|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet12|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet14|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet16|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet18|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet20|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet22|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet24|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet26|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet28|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet30|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet32|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet34|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet36|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet38|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet48|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet248|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet250|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet252|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet254|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet2|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet4|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet6|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet8|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet10|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet12|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet14|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet16|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet18|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet20|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet22|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet24|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet26|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet28|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet30|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet32|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet34|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet36|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet38|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet48|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet248|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet250|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet252|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet254|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet2|0": { + "scheduler": "scheduler.0" + }, + "Ethernet4|0": { + "scheduler": "scheduler.0" + }, + "Ethernet6|0": { + "scheduler": "scheduler.0" + }, + "Ethernet8|0": { + "scheduler": "scheduler.0" + }, + "Ethernet10|0": { + "scheduler": "scheduler.0" + }, + "Ethernet12|0": { + "scheduler": "scheduler.0" + }, + "Ethernet14|0": { + "scheduler": "scheduler.0" + }, + "Ethernet16|0": { + "scheduler": "scheduler.0" + }, + "Ethernet18|0": { + "scheduler": "scheduler.0" + }, + "Ethernet20|0": { + "scheduler": "scheduler.0" + }, + "Ethernet22|0": { + "scheduler": "scheduler.0" + }, + "Ethernet24|0": { + "scheduler": "scheduler.0" + }, + "Ethernet26|0": { + "scheduler": "scheduler.0" + }, + "Ethernet28|0": { + "scheduler": "scheduler.0" + }, + "Ethernet30|0": { + "scheduler": "scheduler.0" + }, + "Ethernet32|0": { + "scheduler": "scheduler.0" + }, + "Ethernet34|0": { + "scheduler": "scheduler.0" + }, + "Ethernet36|0": { + "scheduler": "scheduler.0" + }, + "Ethernet38|0": { + "scheduler": "scheduler.0" + }, + "Ethernet48|0": { + "scheduler": "scheduler.0" + }, + "Ethernet248|0": { + "scheduler": "scheduler.0" + }, + "Ethernet250|0": { + "scheduler": "scheduler.0" + }, + "Ethernet252|0": { + "scheduler": "scheduler.0" + }, + "Ethernet254|0": { + "scheduler": "scheduler.0" + }, + "Ethernet2|1": { + "scheduler": "scheduler.0" + }, + "Ethernet4|1": { + "scheduler": "scheduler.0" + }, + "Ethernet6|1": { + "scheduler": "scheduler.0" + }, + "Ethernet8|1": { + "scheduler": "scheduler.0" + }, + "Ethernet10|1": { + "scheduler": "scheduler.0" + }, + "Ethernet12|1": { + "scheduler": "scheduler.0" + }, + "Ethernet14|1": { + "scheduler": "scheduler.0" + }, + "Ethernet16|1": { + "scheduler": "scheduler.0" + }, + "Ethernet18|1": { + "scheduler": "scheduler.0" + }, + "Ethernet20|1": { + "scheduler": "scheduler.0" + }, + "Ethernet22|1": { + "scheduler": "scheduler.0" + }, + "Ethernet24|1": { + "scheduler": "scheduler.0" + }, + "Ethernet26|1": { + "scheduler": "scheduler.0" + }, + "Ethernet28|1": { + "scheduler": "scheduler.0" + }, + "Ethernet30|1": { + "scheduler": "scheduler.0" + }, + "Ethernet32|1": { + "scheduler": "scheduler.0" + }, + "Ethernet34|1": { + "scheduler": "scheduler.0" + }, + "Ethernet36|1": { + "scheduler": "scheduler.0" + }, + "Ethernet38|1": { + "scheduler": "scheduler.0" + }, + "Ethernet48|1": { + "scheduler": "scheduler.0" + }, + "Ethernet248|1": { + "scheduler": "scheduler.0" + }, + "Ethernet250|1": { + "scheduler": "scheduler.0" + }, + "Ethernet252|1": { + "scheduler": "scheduler.0" + }, + "Ethernet254|1": { + "scheduler": "scheduler.0" + }, + "Ethernet2|2": { + "scheduler": "scheduler.0" + }, + "Ethernet4|2": { + "scheduler": "scheduler.0" + }, + "Ethernet6|2": { + "scheduler": "scheduler.0" + }, + "Ethernet8|2": { + "scheduler": "scheduler.0" + }, + "Ethernet10|2": { + "scheduler": "scheduler.0" + }, + "Ethernet12|2": { + "scheduler": "scheduler.0" + }, + "Ethernet14|2": { + "scheduler": "scheduler.0" + }, + "Ethernet16|2": { + "scheduler": "scheduler.0" + }, + "Ethernet18|2": { + "scheduler": "scheduler.0" + }, + "Ethernet20|2": { + "scheduler": "scheduler.0" + }, + "Ethernet22|2": { + "scheduler": "scheduler.0" + }, + "Ethernet24|2": { + "scheduler": "scheduler.0" + }, + "Ethernet26|2": { + "scheduler": "scheduler.0" + }, + "Ethernet28|2": { + "scheduler": "scheduler.0" + }, + "Ethernet30|2": { + "scheduler": "scheduler.0" + }, + "Ethernet32|2": { + "scheduler": "scheduler.0" + }, + "Ethernet34|2": { + "scheduler": "scheduler.0" + }, + "Ethernet36|2": { + "scheduler": "scheduler.0" + }, + "Ethernet38|2": { + "scheduler": "scheduler.0" + }, + "Ethernet48|2": { + "scheduler": "scheduler.0" + }, + "Ethernet248|2": { + "scheduler": "scheduler.0" + }, + "Ethernet250|2": { + "scheduler": "scheduler.0" + }, + "Ethernet252|2": { + "scheduler": "scheduler.0" + }, + "Ethernet254|2": { + "scheduler": "scheduler.0" + }, + "Ethernet2|5": { + "scheduler": "scheduler.0" + }, + "Ethernet4|5": { + "scheduler": "scheduler.0" + }, + "Ethernet6|5": { + "scheduler": "scheduler.0" + }, + "Ethernet8|5": { + "scheduler": "scheduler.0" + }, + "Ethernet10|5": { + "scheduler": "scheduler.0" + }, + "Ethernet12|5": { + "scheduler": "scheduler.0" + }, + "Ethernet14|5": { + "scheduler": "scheduler.0" + }, + "Ethernet16|5": { + "scheduler": "scheduler.0" + }, + "Ethernet18|5": { + "scheduler": "scheduler.0" + }, + "Ethernet20|5": { + "scheduler": "scheduler.0" + }, + "Ethernet22|5": { + "scheduler": "scheduler.0" + }, + "Ethernet24|5": { + "scheduler": "scheduler.0" + }, + "Ethernet26|5": { + "scheduler": "scheduler.0" + }, + "Ethernet28|5": { + "scheduler": "scheduler.0" + }, + "Ethernet30|5": { + "scheduler": "scheduler.0" + }, + "Ethernet32|5": { + "scheduler": "scheduler.0" + }, + "Ethernet34|5": { + "scheduler": "scheduler.0" + }, + "Ethernet36|5": { + "scheduler": "scheduler.0" + }, + "Ethernet38|5": { + "scheduler": "scheduler.0" + }, + "Ethernet48|5": { + "scheduler": "scheduler.0" + }, + "Ethernet248|5": { + "scheduler": "scheduler.0" + }, + "Ethernet250|5": { + "scheduler": "scheduler.0" + }, + "Ethernet252|5": { + "scheduler": "scheduler.0" + }, + "Ethernet254|5": { + "scheduler": "scheduler.0" + }, + "Ethernet2|6": { + "scheduler": "scheduler.0" + }, + "Ethernet4|6": { + "scheduler": "scheduler.0" + }, + "Ethernet6|6": { + "scheduler": "scheduler.0" + }, + "Ethernet8|6": { + "scheduler": "scheduler.0" + }, + "Ethernet10|6": { + "scheduler": "scheduler.0" + }, + "Ethernet12|6": { + "scheduler": "scheduler.0" + }, + "Ethernet14|6": { + "scheduler": "scheduler.0" + }, + "Ethernet16|6": { + "scheduler": "scheduler.0" + }, + "Ethernet18|6": { + "scheduler": "scheduler.0" + }, + "Ethernet20|6": { + "scheduler": "scheduler.0" + }, + "Ethernet22|6": { + "scheduler": "scheduler.0" + }, + "Ethernet24|6": { + "scheduler": "scheduler.0" + }, + "Ethernet26|6": { + "scheduler": "scheduler.0" + }, + "Ethernet28|6": { + "scheduler": "scheduler.0" + }, + "Ethernet30|6": { + "scheduler": "scheduler.0" + }, + "Ethernet32|6": { + "scheduler": "scheduler.0" + }, + "Ethernet34|6": { + "scheduler": "scheduler.0" + }, + "Ethernet36|6": { + "scheduler": "scheduler.0" + }, + "Ethernet38|6": { + "scheduler": "scheduler.0" + }, + "Ethernet48|6": { + "scheduler": "scheduler.0" + }, + "Ethernet248|6": { + "scheduler": "scheduler.0" + }, + "Ethernet250|6": { + "scheduler": "scheduler.0" + }, + "Ethernet252|6": { + "scheduler": "scheduler.0" + }, + "Ethernet254|6": { + "scheduler": "scheduler.0" + } + } +} diff --git a/src/sonic-config-engine/tests/sample_output/py3/qos-mellanox4600c-d48c40-t0.json b/src/sonic-config-engine/tests/sample_output/py3/qos-mellanox4600c-d48c40-t0.json new file mode 100644 index 000000000000..90190f9b133f --- /dev/null +++ b/src/sonic-config-engine/tests/sample_output/py3/qos-mellanox4600c-d48c40-t0.json @@ -0,0 +1,1155 @@ + + +{ + "TC_TO_PRIORITY_GROUP_MAP": { + "AZURE_TUNNEL": { + "0": "0", + "1": "0", + "2": "0", + "3": "2", + "4": "6", + "5": "0", + "6": "0", + "7": "0", + "8": "0" + }, + "AZURE": { + "0": "0", + "1": "0", + "2": "2", + "3": "3", + "4": "4", + "5": "0", + "6": "6", + "7": "0", + "8": "0" + } + }, + "MAP_PFC_PRIORITY_TO_QUEUE": { + "AZURE": { + "0": "0", + "1": "1", + "2": "2", + "3": "3", + "4": "4", + "5": "5", + "6": "6", + "7": "7" + } + }, + "TC_TO_QUEUE_MAP": { + "AZURE_TUNNEL": { + "0": "0", + "1": "1", + "2": "2", + "3": "2", + "4": "6", + "5": "5", + "6": "6", + "7": "7", + "8": "1" + }, + "AZURE": { + "0": "0", + "1": "1", + "2": "2", + "3": "3", + "4": "4", + "5": "5", + "6": "6", + "7": "7", + "8": "1" + } + }, + "DSCP_TO_TC_MAP": { + "AZURE_UPLINK": { + "0" : "1", + "1" : "1", + "2" : "2", + "3" : "3", + "4" : "4", + "5" : "1", + "6" : "6", + "7" : "1", + "8" : "0", + "9" : "1", + "10": "1", + "11": "1", + "12": "1", + "13": "1", + "14": "1", + "15": "1", + "16": "1", + "17": "1", + "18": "1", + "19": "1", + "20": "1", + "21": "1", + "22": "1", + "23": "1", + "24": "1", + "25": "1", + "26": "1", + "27": "1", + "28": "1", + "29": "1", + "30": "1", + "31": "1", + "32": "1", + "33": "8", + "34": "1", + "35": "1", + "36": "1", + "37": "1", + "38": "1", + "39": "1", + "40": "1", + "41": "1", + "42": "1", + "43": "1", + "44": "1", + "45": "1", + "46": "5", + "47": "1", + "48": "7", + "49": "1", + "50": "1", + "51": "1", + "52": "1", + "53": "1", + "54": "1", + "55": "1", + "56": "1", + "57": "1", + "58": "1", + "59": "1", + "60": "1", + "61": "1", + "62": "1", + "63": "1" + }, + "AZURE_TUNNEL": + { + "0" : "1", + "1" : "1", + "2" : "1", + "3" : "3", + "4" : "4", + "5" : "1", + "6" : "1", + "7" : "1", + "8" : "0", + "9" : "1", + "10": "1", + "11": "1", + "12": "1", + "13": "1", + "14": "1", + "15": "1", + "16": "1", + "17": "1", + "18": "1", + "19": "1", + "20": "1", + "21": "1", + "22": "1", + "23": "1", + "24": "1", + "25": "1", + "26": "1", + "27": "1", + "28": "1", + "29": "1", + "30": "1", + "31": "1", + "32": "1", + "33": "8", + "34": "1", + "35": "1", + "36": "1", + "37": "1", + "38": "1", + "39": "1", + "40": "1", + "41": "1", + "42": "1", + "43": "1", + "44": "1", + "45": "1", + "46": "5", + "47": "1", + "48": "7", + "49": "1", + "50": "1", + "51": "1", + "52": "1", + "53": "1", + "54": "1", + "55": "1", + "56": "1", + "57": "1", + "58": "1", + "59": "1", + "60": "1", + "61": "1", + "62": "1", + "63": "1" + }, + "AZURE": + { + "0" : "1", + "1" : "1", + "2" : "1", + "3" : "3", + "4" : "4", + "5" : "1", + "6" : "1", + "7" : "1", + "8" : "0", + "9" : "1", + "10": "1", + "11": "1", + "12": "1", + "13": "1", + "14": "1", + "15": "1", + "16": "1", + "17": "1", + "18": "1", + "19": "1", + "20": "1", + "21": "1", + "22": "1", + "23": "1", + "24": "1", + "25": "1", + "26": "1", + "27": "1", + "28": "1", + "29": "1", + "30": "1", + "31": "1", + "32": "1", + "33": "8", + "34": "1", + "35": "1", + "36": "1", + "37": "1", + "38": "1", + "39": "1", + "40": "1", + "41": "1", + "42": "1", + "43": "1", + "44": "1", + "45": "1", + "46": "5", + "47": "1", + "48": "7", + "49": "1", + "50": "1", + "51": "1", + "52": "1", + "53": "1", + "54": "1", + "55": "1", + "56": "1", + "57": "1", + "58": "1", + "59": "1", + "60": "1", + "61": "1", + "62": "1", + "63": "1" + } + }, + "TC_TO_DSCP_MAP": { + "AZURE_TUNNEL": { + "0": "8", + "1": "0", + "2": "2", + "3": "2", + "4": "6", + "5": "46", + "6": "6", + "7": "48", + "8": "33" + } + }, + "SCHEDULER": { + "scheduler.0": { + "type" : "DWRR", + "weight": "14" + }, + "scheduler.1": { + "type" : "DWRR", + "weight": "15" + } + }, + "PORT_QOS_MAP": { + + "Ethernet2": { + + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet4": { + + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet6": { + + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet8": { + + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet10": { + + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet12": { + + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet14": { + + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet16": { + + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet18": { + + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet20": { + + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet22": { + + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet24": { + + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet26": { + + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet28": { + + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet30": { + + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet32": { + + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet34": { + + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet36": { + + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet38": { + + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet48": { + + "dscp_to_tc_map" : "AZURE", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet248": { + "dscp_to_tc_map" : "AZURE_UPLINK", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "2,3,4,6", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet250": { + "dscp_to_tc_map" : "AZURE_UPLINK", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "2,3,4,6", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet252": { + "dscp_to_tc_map" : "AZURE_UPLINK", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "2,3,4,6", + "pfcwd_sw_enable" : "3,4" + }, + "Ethernet254": { + "dscp_to_tc_map" : "AZURE_UPLINK", + "tc_to_queue_map" : "AZURE", + "tc_to_pg_map" : "AZURE", + "pfc_to_queue_map": "AZURE", + "pfc_enable" : "2,3,4,6", + "pfcwd_sw_enable" : "3,4" + } + }, + "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" : "1048576", + "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" + } + }, + "QUEUE": { + "Ethernet2|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet4|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet6|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet8|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet10|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet12|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet14|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet16|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet18|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet20|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet22|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet24|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet26|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet28|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet30|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet32|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet34|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet36|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet38|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet48|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet248|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet250|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet252|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet254|3": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet2|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet4|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet6|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet8|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet10|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet12|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet14|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet16|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet18|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet20|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet22|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet24|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet26|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet28|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet30|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet32|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet34|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet36|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet38|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet48|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet248|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet250|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet252|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet254|4": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet2|0": { + "scheduler": "scheduler.0" + }, + "Ethernet4|0": { + "scheduler": "scheduler.0" + }, + "Ethernet6|0": { + "scheduler": "scheduler.0" + }, + "Ethernet8|0": { + "scheduler": "scheduler.0" + }, + "Ethernet10|0": { + "scheduler": "scheduler.0" + }, + "Ethernet12|0": { + "scheduler": "scheduler.0" + }, + "Ethernet14|0": { + "scheduler": "scheduler.0" + }, + "Ethernet16|0": { + "scheduler": "scheduler.0" + }, + "Ethernet18|0": { + "scheduler": "scheduler.0" + }, + "Ethernet20|0": { + "scheduler": "scheduler.0" + }, + "Ethernet22|0": { + "scheduler": "scheduler.0" + }, + "Ethernet24|0": { + "scheduler": "scheduler.0" + }, + "Ethernet26|0": { + "scheduler": "scheduler.0" + }, + "Ethernet28|0": { + "scheduler": "scheduler.0" + }, + "Ethernet30|0": { + "scheduler": "scheduler.0" + }, + "Ethernet32|0": { + "scheduler": "scheduler.0" + }, + "Ethernet34|0": { + "scheduler": "scheduler.0" + }, + "Ethernet36|0": { + "scheduler": "scheduler.0" + }, + "Ethernet38|0": { + "scheduler": "scheduler.0" + }, + "Ethernet48|0": { + "scheduler": "scheduler.0" + }, + "Ethernet248|0": { + "scheduler": "scheduler.0" + }, + "Ethernet250|0": { + "scheduler": "scheduler.0" + }, + "Ethernet252|0": { + "scheduler": "scheduler.0" + }, + "Ethernet254|0": { + "scheduler": "scheduler.0" + }, + "Ethernet2|1": { + "scheduler": "scheduler.0" + }, + "Ethernet4|1": { + "scheduler": "scheduler.0" + }, + "Ethernet6|1": { + "scheduler": "scheduler.0" + }, + "Ethernet8|1": { + "scheduler": "scheduler.0" + }, + "Ethernet10|1": { + "scheduler": "scheduler.0" + }, + "Ethernet12|1": { + "scheduler": "scheduler.0" + }, + "Ethernet14|1": { + "scheduler": "scheduler.0" + }, + "Ethernet16|1": { + "scheduler": "scheduler.0" + }, + "Ethernet18|1": { + "scheduler": "scheduler.0" + }, + "Ethernet20|1": { + "scheduler": "scheduler.0" + }, + "Ethernet22|1": { + "scheduler": "scheduler.0" + }, + "Ethernet24|1": { + "scheduler": "scheduler.0" + }, + "Ethernet26|1": { + "scheduler": "scheduler.0" + }, + "Ethernet28|1": { + "scheduler": "scheduler.0" + }, + "Ethernet30|1": { + "scheduler": "scheduler.0" + }, + "Ethernet32|1": { + "scheduler": "scheduler.0" + }, + "Ethernet34|1": { + "scheduler": "scheduler.0" + }, + "Ethernet36|1": { + "scheduler": "scheduler.0" + }, + "Ethernet38|1": { + "scheduler": "scheduler.0" + }, + "Ethernet48|1": { + "scheduler": "scheduler.0" + }, + "Ethernet248|1": { + "scheduler": "scheduler.0" + }, + "Ethernet250|1": { + "scheduler": "scheduler.0" + }, + "Ethernet252|1": { + "scheduler": "scheduler.0" + }, + "Ethernet254|1": { + "scheduler": "scheduler.0" + }, + "Ethernet2|2": { + "scheduler": "scheduler.0" + }, + "Ethernet4|2": { + "scheduler": "scheduler.0" + }, + "Ethernet6|2": { + "scheduler": "scheduler.0" + }, + "Ethernet8|2": { + "scheduler": "scheduler.0" + }, + "Ethernet10|2": { + "scheduler": "scheduler.0" + }, + "Ethernet12|2": { + "scheduler": "scheduler.0" + }, + "Ethernet14|2": { + "scheduler": "scheduler.0" + }, + "Ethernet16|2": { + "scheduler": "scheduler.0" + }, + "Ethernet18|2": { + "scheduler": "scheduler.0" + }, + "Ethernet20|2": { + "scheduler": "scheduler.0" + }, + "Ethernet22|2": { + "scheduler": "scheduler.0" + }, + "Ethernet24|2": { + "scheduler": "scheduler.0" + }, + "Ethernet26|2": { + "scheduler": "scheduler.0" + }, + "Ethernet28|2": { + "scheduler": "scheduler.0" + }, + "Ethernet30|2": { + "scheduler": "scheduler.0" + }, + "Ethernet32|2": { + "scheduler": "scheduler.0" + }, + "Ethernet34|2": { + "scheduler": "scheduler.0" + }, + "Ethernet36|2": { + "scheduler": "scheduler.0" + }, + "Ethernet38|2": { + "scheduler": "scheduler.0" + }, + "Ethernet48|2": { + "scheduler": "scheduler.0" + }, + "Ethernet248|2": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet250|2": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet252|2": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet254|2": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet2|5": { + "scheduler": "scheduler.0" + }, + "Ethernet4|5": { + "scheduler": "scheduler.0" + }, + "Ethernet6|5": { + "scheduler": "scheduler.0" + }, + "Ethernet8|5": { + "scheduler": "scheduler.0" + }, + "Ethernet10|5": { + "scheduler": "scheduler.0" + }, + "Ethernet12|5": { + "scheduler": "scheduler.0" + }, + "Ethernet14|5": { + "scheduler": "scheduler.0" + }, + "Ethernet16|5": { + "scheduler": "scheduler.0" + }, + "Ethernet18|5": { + "scheduler": "scheduler.0" + }, + "Ethernet20|5": { + "scheduler": "scheduler.0" + }, + "Ethernet22|5": { + "scheduler": "scheduler.0" + }, + "Ethernet24|5": { + "scheduler": "scheduler.0" + }, + "Ethernet26|5": { + "scheduler": "scheduler.0" + }, + "Ethernet28|5": { + "scheduler": "scheduler.0" + }, + "Ethernet30|5": { + "scheduler": "scheduler.0" + }, + "Ethernet32|5": { + "scheduler": "scheduler.0" + }, + "Ethernet34|5": { + "scheduler": "scheduler.0" + }, + "Ethernet36|5": { + "scheduler": "scheduler.0" + }, + "Ethernet38|5": { + "scheduler": "scheduler.0" + }, + "Ethernet48|5": { + "scheduler": "scheduler.0" + }, + "Ethernet248|5": { + "scheduler": "scheduler.0" + }, + "Ethernet250|5": { + "scheduler": "scheduler.0" + }, + "Ethernet252|5": { + "scheduler": "scheduler.0" + }, + "Ethernet254|5": { + "scheduler": "scheduler.0" + }, + "Ethernet2|6": { + "scheduler": "scheduler.0" + }, + "Ethernet4|6": { + "scheduler": "scheduler.0" + }, + "Ethernet6|6": { + "scheduler": "scheduler.0" + }, + "Ethernet8|6": { + "scheduler": "scheduler.0" + }, + "Ethernet10|6": { + "scheduler": "scheduler.0" + }, + "Ethernet12|6": { + "scheduler": "scheduler.0" + }, + "Ethernet14|6": { + "scheduler": "scheduler.0" + }, + "Ethernet16|6": { + "scheduler": "scheduler.0" + }, + "Ethernet18|6": { + "scheduler": "scheduler.0" + }, + "Ethernet20|6": { + "scheduler": "scheduler.0" + }, + "Ethernet22|6": { + "scheduler": "scheduler.0" + }, + "Ethernet24|6": { + "scheduler": "scheduler.0" + }, + "Ethernet26|6": { + "scheduler": "scheduler.0" + }, + "Ethernet28|6": { + "scheduler": "scheduler.0" + }, + "Ethernet30|6": { + "scheduler": "scheduler.0" + }, + "Ethernet32|6": { + "scheduler": "scheduler.0" + }, + "Ethernet34|6": { + "scheduler": "scheduler.0" + }, + "Ethernet36|6": { + "scheduler": "scheduler.0" + }, + "Ethernet38|6": { + "scheduler": "scheduler.0" + }, + "Ethernet48|6": { + "scheduler": "scheduler.0" + }, + "Ethernet248|6": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet250|6": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet252|6": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet254|6": { + "scheduler" : "scheduler.1", + "wred_profile": "AZURE_LOSSLESS" + }, + "Ethernet2|7": { + "scheduler": "scheduler.0" + }, + "Ethernet4|7": { + "scheduler": "scheduler.0" + }, + "Ethernet6|7": { + "scheduler": "scheduler.0" + }, + "Ethernet8|7": { + "scheduler": "scheduler.0" + }, + "Ethernet10|7": { + "scheduler": "scheduler.0" + }, + "Ethernet12|7": { + "scheduler": "scheduler.0" + }, + "Ethernet14|7": { + "scheduler": "scheduler.0" + }, + "Ethernet16|7": { + "scheduler": "scheduler.0" + }, + "Ethernet18|7": { + "scheduler": "scheduler.0" + }, + "Ethernet20|7": { + "scheduler": "scheduler.0" + }, + "Ethernet22|7": { + "scheduler": "scheduler.0" + }, + "Ethernet24|7": { + "scheduler": "scheduler.0" + }, + "Ethernet26|7": { + "scheduler": "scheduler.0" + }, + "Ethernet28|7": { + "scheduler": "scheduler.0" + }, + "Ethernet30|7": { + "scheduler": "scheduler.0" + }, + "Ethernet32|7": { + "scheduler": "scheduler.0" + }, + "Ethernet34|7": { + "scheduler": "scheduler.0" + }, + "Ethernet36|7": { + "scheduler": "scheduler.0" + }, + "Ethernet38|7": { + "scheduler": "scheduler.0" + }, + "Ethernet48|7": { + "scheduler": "scheduler.0" + }, + "Ethernet248|7": { + "scheduler": "scheduler.0" + }, + "Ethernet250|7": { + "scheduler": "scheduler.0" + }, + "Ethernet252|7": { + "scheduler": "scheduler.0" + }, + "Ethernet254|7": { + "scheduler": "scheduler.0" + } + } +} diff --git a/src/sonic-config-engine/tests/simple-sample-graph-case-acl-test.xml b/src/sonic-config-engine/tests/simple-sample-graph-case-acl-test.xml new file mode 100644 index 000000000000..13dbbd17a234 --- /dev/null +++ b/src/sonic-config-engine/tests/simple-sample-graph-case-acl-test.xml @@ -0,0 +1,974 @@ + + + + + + false + switch-t0 + 10.0.0.56 + ARISTA01T1 + 10.0.0.57 + 1 + 180 + 60 + + + switch-t0 + FC00::71 + ARISTA01T1 + FC00::72 + 1 + 180 + 60 + + + false + switch-t0 + 10.0.0.58 + ARISTA02T1 + 10.0.0.59 + 1 + 180 + 60 + + + switch-t0 + FC00::75 + ARISTA02T1 + FC00::76 + 1 + 180 + 60 + + + + + 65100 + switch-t0 + + +
10.0.0.57
+ + + +
+ +
10.0.0.59
+ + + +
+
+ +
+ + 64600 + ARISTA01T1 + + + + 64600 + ARISTA02T1 + + + + 64600 + ARISTA03T1 + + + + 64600 + ARISTA04T1 + + +
+
+ + + + + + HostIP + Loopback0 + + 10.1.0.32/32 + + 10.1.0.32/32 + + + HostIP1 + Loopback0 + + FC00:1::32/128 + + FC00:1::32/128 + + + + + HostIP + eth0 + + 10.0.0.100/24 + + 10.0.0.100/24 + + + + + + + switch-t0 + + + PortChannel01 + fortyGigE0/4 + + + + + + + + + ab1 + fortyGigE0/8 + 192.0.0.1;192.0.0.2 + fc02:2000::1;fc02:2000::2 + 1000 + 1000 + 192.168.0.0/27 + 00:aa:bb:cc:dd:ee + + + ab2 + fortyGigE0/4 + 192.0.0.1 + fc02:2000::3;fc02:2000::4 + 2000 + 2000 + + + + + + + PortChannel01 + 10.0.0.56/31 + + + + PortChannel01 + FC00::71/126 + + + + fortyGigE0/0 + 10.0.0.58/31 + + + + fortyGigE0/0 + FC00::75/126 + + + + ab1 + 192.168.0.1/27 + + + + + + PortChannel01;Ethernet20;Ethernet24 + DataAcl_port_name + DataPlane + + + PortChannel01;Ethernet6/1;Ethernet7/1 + DataAcl_port_alias + DataPlane + + + PortChannel01;Ethernet0;Ethernet1;Ethernet2;Ethernet3 + DataAcl_mixed_name_alias_1 + DataPlane + + + PortChannel01;Ethernet1;Ethernet2;Ethernet6/1;Ethernet7/1 + DataAcl_mixed_name_alias_2 + DataPlane + + + Ethernet1 + DataAcl_mixed_name_alias_3 + DataPlane + + + SNMP + SNMP_ACL + SNMP + + + ERSPAN_DSCP + Everflow_dscp + Everflow_dscp + + + + + + + + + + LoopbackInterface + HostIP + Loopback0 + + 10.10.10.2/32 + + 10.10.10.2/32 + + + LoopbackInterface + HostIP1 + Loopback0 + + fe80::0002/128 + + fe80::0002/128 + + + LoopbackInterface + SoCHostIP0 + server2SOC + + 10.10.10.3/32 + + 10.10.10.3/32 + + + LoopbackInterface + SoCHostIP1 + server2SOC + + fe80::0003/128 + + fe80::0003/128 + + + + + + + + server2 + + + + + + + + + + + + + + + DeviceSerialLink + 9600 + switch-t0 + console + true + switch-t1 + 1 + + + DeviceSerialLink + 9600 + switch-t0 + 1 + true + managed_device + console + + + DeviceInterfaceLink + 10000 + switch-t0 + fortyGigE0/0 + switch-01t1 + port1 + + + DeviceInterfaceLink + 10000 + switch-t0 + fortyGigE0/12 + switch-02t1 + port1 + + + DeviceInterfaceLink + 25000 + switch-t0 + fortyGigE0/4 + server1 + port1 + + + DeviceInterfaceLink + 40000 + switch-t0 + fortyGigE0/8 + server2 + port1 + + + LogicalLink + 10000 + false + switch-t0 + fortyGigE0/4 + true + server1-SC + L + true + + + LogicalLink + 0 + false + switch-t0 + MuxTunnel0 + false + switch2-t0 + MuxTunnel0 + true + + + + + ToRRouter +
+ 26.1.1.10/32 +
+ switch-t0 + Force10-S6000 + AAA00PrdStr00 +
+ +
+ 25.1.1.10/32 +
+ + 10.7.0.196/26 + + switch2-t0 + Force10-S6000 +
+ + switch-01t1 +
+ 10.1.0.186/32 +
+ 2 + + + 10.7.0.196/26 + + Force10-S6000 +
+ + SmartCable +
+ 0.0.0.0/0 +
+ + ::/0 + + + 0.0.0.0/0 + + + ::/0 + + + server1-SC + smartcable-sku +
+ + Server +
+ 10.10.10.1/32 +
+ + fe80::0001/80 + + + 10.0.0.1/32 + + server1 + server-sku +
+ + Server +
+ 10.10.10.2/32 +
+ + fe80::0002/128 + + + 10.0.0.2/32 + + server2 + server-sku +
+
+
+ + + + + + + GeminiPeeringLink + + True + + + UpperTOR + + switch-t0 + + + LowerTOR + + switch2-t0 + + + switch2-t0:MuxTunnel0;switch-t0:MuxTunnel0 + + + + + + AutoNegotiation + + True + + + switch-01t1:port1;switch-t0:fortyGigE0/0 + + + + + + AutoNegotiation + + True + + + switch-02t1:port1;switch-t0:fortyGigE0/12 + + + + + + AutoNegotiation + + True + + + server1:port1;switch-t0:fortyGigE0/4 + + + + + + AutoNegotiation + + True + + + server2:port1;switch-t0:fortyGigE0/8 + + + + + + + switch-t0 + + + DeploymentId + + 1 + + + ErspanDestinationIpv4 + + 10.0.100.1 + + + NtpResources + + 10.0.10.1;10.0.10.2 + + + + SnmpResources + + 10.0.10.3;10.0.10.4 + + + + SyslogResources + + 10.0.10.5;10.0.10.6 + + + + TacacsServer + + 10.0.10.7;10.0.10.8 + + + KubernetesEnabled + + 0 + + + KubernetesServerIp + + 10.10.10.10 + + + ResourceType + + Storage + + + RedundancyType + + Mixed + + + + + + + + + + + DeviceInterface + + true + 1 + fortyGigE0/0 + + false + 0 + 0 + 10000 + + + DeviceInterface + + true + 1 + fortyGigE0/4 + + false + 0 + 0 + 25000 + + + DeviceInterface + + true + 1 + fortyGigE0/8 + + false + 0 + 0 + 40000 + Interface description + + + DeviceInterface + + true + 1 + fortyGigE0/12 + + false + 0 + 0 + 100000 + Interface description + + + DeviceInterface + + true + 1 + fortyGigE0/16 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/20 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/24 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/28 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/32 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/36 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/40 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/44 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/48 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/52 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/56 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/60 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/64 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/68 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/72 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/76 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/80 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/84 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/88 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/92 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/96 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/100 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/104 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/108 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/112 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/116 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/120 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/124 + + false + 0 + 0 + 100000 + + + true + 0 + Force10-S6000 + + + DeviceInterface + + true + 1 + eth0 + false + eth0 + 1000 + + + + + switch-t0 + Force10-S6000 +
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 4165647a9aa3..89b0ca9e0d9d 100644 --- a/src/sonic-config-engine/tests/simple-sample-graph-case.xml +++ b/src/sonic-config-engine/tests/simple-sample-graph-case.xml @@ -180,7 +180,7 @@ - PortChannel01 + PortChannel01;Ethernet0;Ethernet12 DataAcl DataPlane diff --git a/src/sonic-config-engine/tests/t0-sample-port-config-duplicated-name-alias.ini b/src/sonic-config-engine/tests/t0-sample-port-config-duplicated-name-alias.ini new file mode 100644 index 000000000000..dafdb570e9cc --- /dev/null +++ b/src/sonic-config-engine/tests/t0-sample-port-config-duplicated-name-alias.ini @@ -0,0 +1,36 @@ +# name lanes alias index +Ethernet0 9 Ethernet1 1 +Ethernet1 10 Ethernet2 2 +Ethernet2 11 Ethernet3 3 +Ethernet3 12 Ethernet4 4 +Ethernet4 13,14,15,16 Ethernet6/1 6 +Ethernet8 17,18,19,20 Ethernet7/1 7 +Ethernet12 21,22,23,24 Ethernet8/1 8 +Ethernet16 29,30,31,32 Ethernet9/1 9 +Ethernet20 25,26,27,28 Ethernet10/1 10 +Ethernet24 33,34,35,36 Ethernet11/1 11 +Ethernet28 37,38,39,40 Ethernet12/1 12 +Ethernet32 45,46,47,48 Ethernet13/1 13 +Ethernet36 41,42,43,44 Ethernet14/1 14 +Ethernet40 49,50,51,52 Ethernet15/1 15 +Ethernet44 53,54,55,56 Ethernet16/1 16 +Ethernet48 69,70,71,72 Ethernet17/1 17 +Ethernet52 65,66,67,68 Ethernet18/1 18 +Ethernet56 73,74,75,76 Ethernet19/1 19 +Ethernet60 77,78,79,80 Ethernet20/1 20 +Ethernet64 93,94,95,96 Ethernet21/1 21 +Ethernet68 89,90,91,92 Ethernet22/1 22 +Ethernet72 97,98,99,100 Ethernet23/1 23 +Ethernet76 101,102,103,104 Ethernet24/1 24 +Ethernet80 109,110,111,112 Ethernet25/1 25 +Ethernet84 105,106,107,108 Ethernet26/1 26 +Ethernet88 121,122,123,124 Ethernet27/1 27 +Ethernet92 125,126,127,128 Ethernet28/1 28 +Ethernet96 61,62,63,64 Ethernet29 29 +Ethernet100 57,58,59,60 Ethernet30 30 +Ethernet104 81,82,83,84 Ethernet31 31 +Ethernet108 85,86,87,88 Ethernet32 32 +Ethernet112 117,118,119,120 Ethernet33 33 +Ethernet116 113,114,115,116 Ethernet34 34 +Ethernet120 1,2,3,4 Ethernet35 35 +Ethernet124 5,6,7,8 Ethernet36 36 diff --git a/src/sonic-config-engine/tests/test_cfggen.py b/src/sonic-config-engine/tests/test_cfggen.py index d1d5b898b4ff..ab8d705f4e9e 100644 --- a/src/sonic-config-engine/tests/test_cfggen.py +++ b/src/sonic-config-engine/tests/test_cfggen.py @@ -39,6 +39,8 @@ def setUp(self): self.packet_chassis_port_ini = os.path.join(self.test_dir, 'sample-chassis-packet-lc-port-config.ini') self.macsec_profile = os.path.join(self.test_dir, 'macsec_profile.json') self.sample_backend_graph = os.path.join(self.test_dir, 'sample-graph-storage-backend.xml') + self.voq_port_config_400g = os.path.join(self.test_dir, 'voq-sample-400g-port-config.ini') + self.voq_sample_masic_graph = os.path.join(self.test_dir, 'voq-sample-masic-graph.xml') # To ensure that mock config_db data is used for unit-test cases os.environ["CFGGEN_UNIT_TESTING"] = "2" @@ -328,7 +330,7 @@ def test_minigraph_portchannels(self, **kwargs): output = self.run_script(argument) self.assertEqual( utils.to_dict(output.strip()), - utils.to_dict("{'PortChannel1': {'admin_status': 'up', 'min_links': '1', 'members': ['Ethernet4'], 'mtu': '9100', 'tpid': '0x8100', 'lacp_key': 'auto'}}") + utils.to_dict("{'PortChannel1': {'admin_status': 'up', 'min_links': '1', 'mtu': '9100', 'tpid': '0x8100', 'lacp_key': 'auto'}}") ) def test_minigraph_portchannel_with_more_member(self): @@ -336,7 +338,7 @@ def test_minigraph_portchannel_with_more_member(self): output = self.run_script(argument) self.assertEqual( utils.to_dict(output.strip()), - utils.to_dict("{'PortChannel01': {'admin_status': 'up', 'min_links': '3', 'members': ['Ethernet112', 'Ethernet116', 'Ethernet120', 'Ethernet124'], 'mtu': '9100', 'tpid': '0x8100', 'lacp_key': 'auto'}}")) + utils.to_dict("{'PortChannel01': {'admin_status': 'up', 'min_links': '3', 'mtu': '9100', 'tpid': '0x8100', 'lacp_key': 'auto'}}")) def test_minigraph_portchannel_members(self): argument = ['-m', self.sample_graph_pc_test, '-p', self.port_config, '-v', "PORTCHANNEL_MEMBER.keys()|list"] @@ -959,6 +961,14 @@ def test_minigraph_voq_recirc_ports(self): "admin_status": "up" }) + argument = ["-j", self.macsec_profile, "-m", self.sample_graph_voq, "-p", self.voq_port_config, "--var-json", "INTERFACE"] + output = self.run_script(argument) + output_dict = utils.to_dict(output.strip()) + self.assertDictEqual( + output_dict['Ethernet-Rec0'], + {} + ) + def test_minigraph_dhcp(self): argument = ['-m', self.sample_graph_simple_case, '-p', self.port_config, '-v', 'DHCP_RELAY'] output = self.run_script(argument) @@ -1014,3 +1024,33 @@ def test_minigraph_packet_chassis_400g_zr_port_config(self): output_dict = utils.to_dict(output.strip()) self.assertEqual(output_dict['tx_power'], '7.5') self.assertEqual(output_dict['laser_freq'], 131000) + + def test_minigraph_400g_to_100G_speed(self): + argument = ["-j", self.macsec_profile, "-m", self.voq_sample_masic_graph, "-p", self.voq_port_config_400g, "-n", "asic0", "-v", "PORT"] + output = self.run_script(argument) + self.assertEqual( + utils.to_dict(output.strip()), + utils.to_dict( + "{'Ethernet0': {'lanes': '72,73,74,75', 'alias': 'Ethernet1/1', 'index': '1', 'role': 'Ext', 'speed': '100000', 'asic_port_name': 'Eth0-ASIC0', 'fec': 'rs', 'description': 'ARISTA01T3:Ethernet1', 'mtu': '9100', 'tpid': '0x8100', 'pfc_asym': 'off', 'admin_status': 'up'}, " + "'Ethernet8': {'lanes': '80,81,82,83', 'alias': 'Ethernet2/1', 'index': '2', 'role': 'Ext', 'speed': '100000', 'asic_port_name': 'Eth8-ASIC0', 'fec': 'rs', 'description': 'ARISTA01T3:Ethernet2', 'mtu': '9100', 'tpid': '0x8100', 'pfc_asym': 'off', 'admin_status': 'up'}, " + "'Ethernet16': {'lanes': '88,89,90,91', 'alias': 'Ethernet3/1', 'index': '3', 'role': 'Ext', 'speed': '100000', 'asic_port_name': 'Eth16-ASIC0', 'fec': 'rs', 'description': 'ARISTA03T3:Ethernet1', 'mtu': '9100', 'tpid': '0x8100', 'pfc_asym': 'off', 'admin_status': 'up'}, " + "'Ethernet24': {'lanes': '96,97,98,99,100,101,102,103', 'alias': 'Ethernet4/1', 'index': '4', 'role': 'Ext', 'speed': '400000', 'asic_port_name': 'Eth24-ASIC0', 'description': 'ARISTA03T3:Ethernet2', 'mtu': '9100', 'tpid': '0x8100', 'pfc_asym': 'off', 'admin_status': 'up'}, " + "'Ethernet32': {'lanes': '104,105,106,107,108,109,110,111', 'alias': 'Ethernet5/1', 'index': '5', 'role': 'Ext', 'speed': '400000', 'asic_port_name': 'Eth32-ASIC0', 'description': 'ARISTA05T3:Ethernet1', 'mtu': '9100', 'tpid': '0x8100', 'pfc_asym': 'off', 'admin_status': 'up'}, " + "'Ethernet40': {'lanes': '112,113,114,115,116,117,118,119', 'alias': 'Ethernet6/1', 'index': '6', 'role': 'Ext', 'speed': '400000', 'asic_port_name': 'Eth40-ASIC0', 'description': 'ARISTA05T3:Ethernet2', 'mtu': '9100', 'tpid': '0x8100', 'pfc_asym': 'off', 'admin_status': 'up'}, " + "'Ethernet48': {'lanes': '120,121,122,123,124,125,126,127', 'alias': 'Ethernet7/1', 'index': '7', 'role': 'Ext', 'speed': '400000', 'asic_port_name': 'Eth48-ASIC0', 'description': 'ARISTA07T3:Ethernet1', 'mtu': '9100', 'tpid': '0x8100', 'pfc_asym': 'off', 'admin_status': 'up'}, " + "'Ethernet56': {'lanes': '128,129,130,131', 'alias': 'Ethernet8/1', 'index': '8', 'role': 'Ext', 'speed': '100000', 'asic_port_name': 'Eth56-ASIC0', 'fec': 'rs', 'description': 'ARISTA07T3:Ethernet2', 'mtu': '9100', 'tpid': '0x8100', 'pfc_asym': 'off', 'admin_status': 'up'}, " + "'Ethernet64': {'lanes': '136,137,138,139', 'alias': 'Ethernet9/1', 'index': '9', 'role': 'Ext', 'speed': '100000', 'asic_port_name': 'Eth64-ASIC0', 'fec': 'rs', 'description': 'ARISTA09T3:Ethernet1', 'mtu': '9100', 'tpid': '0x8100', 'pfc_asym': 'off', 'admin_status': 'up'}, " + "'Ethernet72': {'lanes': '64,65,66,67', 'alias': 'Ethernet10/1', 'index': '10', 'role': 'Ext', 'speed': '100000', 'asic_port_name': 'Eth72-ASIC0', 'fec': 'rs', 'description': 'ARISTA09T3:Ethernet2', 'mtu': '9100', 'tpid': '0x8100', 'pfc_asym': 'off', 'admin_status': 'up'}, " + "'Ethernet80': {'lanes': '56,57,58,59', 'alias': 'Ethernet11/1', 'index': '11', 'role': 'Ext', 'speed': '100000', 'asic_port_name': 'Eth80-ASIC0', 'fec': 'rs', 'description': 'ARISTA11T3:Ethernet1', 'mtu': '9100', 'tpid': '0x8100', 'pfc_asym': 'off', 'admin_status': 'up'}, " + "'Ethernet88': {'lanes': '48,49,50,51', 'alias': 'Ethernet12/1', 'index': '12', 'role': 'Ext', 'speed': '100000', 'asic_port_name': 'Eth88-ASIC0', 'fec': 'rs', 'description': 'ARISTA11T3:Ethernet2', 'mtu': '9100', 'tpid': '0x8100', 'pfc_asym': 'off', 'admin_status': 'up'}, " + "'Ethernet96': {'lanes': '40,41,42,43', 'alias': 'Ethernet13/1', 'index': '13', 'role': 'Ext', 'speed': '100000', 'asic_port_name': 'Eth96-ASIC0', 'fec': 'rs', 'description': 'ARISTA13T3:Ethernet1', 'mtu': '9100', 'tpid': '0x8100', 'pfc_asym': 'off', 'admin_status': 'up'}, " + "'Ethernet104': {'lanes': '32,33,34,35', 'alias': 'Ethernet14/1', 'index': '14', 'role': 'Ext', 'speed': '100000', 'asic_port_name': 'Eth104-ASIC0', 'fec': 'rs', 'description': 'ARISTA15T3:Ethernet1', 'mtu': '9100', 'tpid': '0x8100', 'pfc_asym': 'off', 'admin_status': 'up'}, " + "'Ethernet112': {'lanes': '24,25,26,27', 'alias': 'Ethernet15/1', 'index': '15', 'role': 'Ext', 'speed': '100000', 'asic_port_name': 'Eth112-ASIC0', 'fec': 'rs', 'description': 'ARISTA15T3:Ethernet2', 'mtu': '9100', 'tpid': '0x8100', 'pfc_asym': 'off', 'admin_status': 'up'}, " + "'Ethernet120': {'lanes': '16,17,18,19', 'alias': 'Ethernet16/1', 'index': '16', 'role': 'Ext', 'speed': '100000', 'asic_port_name': 'Eth120-ASIC0', 'fec': 'rs', 'description': 'ARISTA17T3:Ethernet1', 'mtu': '9100', 'tpid': '0x8100', 'pfc_asym': 'off', 'admin_status': 'up'}, " + "'Ethernet128': {'lanes': '8,9,10,11', 'alias': 'Ethernet17/1', 'index': '17', 'role': 'Ext', 'speed': '100000', 'asic_port_name': 'Eth128-ASIC0', 'fec': 'rs', 'description': 'ARISTA18T3:Ethernet1', 'mtu': '9100', 'tpid': '0x8100', 'pfc_asym': 'off', 'admin_status': 'up'}, " + "'Ethernet136': {'lanes': '0,1,2,3', 'alias': 'Ethernet18/1', 'index': '18', 'role': 'Ext', 'speed': '100000', 'asic_port_name': 'Eth136-ASIC0', 'fec': 'rs', 'description': 'ARISTA18T3:Ethernet2', 'mtu': '9100', 'tpid': '0x8100', 'pfc_asym': 'off', 'admin_status': 'up'}, " + "'Ethernet-Rec0': {'lanes': '221', 'alias': 'Recirc0/0', 'index': '37', 'role': 'Rec', 'speed': '400000', 'asic_port_name': 'Rcy0-ASIC0', 'description': 'Recirc0/0', 'mtu': '9100', 'tpid': '0x8100', 'pfc_asym': 'off', 'admin_status': 'up'}," + "'Ethernet-IB0': {'lanes': '222', 'alias': 'Recirc0/1', 'index': '38', 'role': 'Inb', 'speed': '400000', 'asic_port_name': 'Rcy1-ASIC0', 'description': 'Recirc0/1', 'mtu': '9100', 'tpid': '0x8100', 'pfc_asym': 'off', 'admin_status': 'up'}}" + ) + ) + diff --git a/src/sonic-config-engine/tests/test_frr.py b/src/sonic-config-engine/tests/test_frr.py index 8f31b4ac7979..3b89f9452c50 100644 --- a/src/sonic-config-engine/tests/test_frr.py +++ b/src/sonic-config-engine/tests/test_frr.py @@ -1,4 +1,5 @@ import filecmp +import json import os import subprocess @@ -46,11 +47,13 @@ def run_diff(self, file1, file2): _, output = getstatusoutput_noshell(['diff', '-u', file1, file2]) return output - def run_case(self, template, target): + def run_case(self, template, target, extra_data=None): template_dir = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-fpm-frr', "frr") conf_template = os.path.join(template_dir, template) constants = os.path.join(self.test_dir, '..', '..', '..', 'files', 'image_config', 'constants', 'constants.yml') cmd = ['-m', self.t0_minigraph, '-p', self.t0_port_config, '-y', constants, '-t', conf_template, '-T', template_dir] + if extra_data: + cmd = ['-a', json.dumps(extra_data)] + cmd self.run_script(cmd, output_file=self.output_file) original_filename = os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, target) @@ -68,3 +71,6 @@ def test_bgpd_frr(self): def test_zebra_frr(self): self.assertTrue(*self.run_case('zebra/zebra.conf.j2', 'zebra_frr.conf')) + def test_bgpd_frr_dualtor(self): + extra_data = {"DEVICE_METADATA": {"localhost": {"subtype": "DualToR"}}} + self.assertTrue(*self.run_case('bgpd/bgpd.conf.j2', 'bgpd_frr_dualtor.conf', extra_data=extra_data)) diff --git a/src/sonic-config-engine/tests/test_j2files.py b/src/sonic-config-engine/tests/test_j2files.py index 40af24151c8b..44f5be3755a0 100644 --- a/src/sonic-config-engine/tests/test_j2files.py +++ b/src/sonic-config-engine/tests/test_j2files.py @@ -139,7 +139,7 @@ def test_interfaces(self): self.run_script(argument, output_file=self.output_file) self.assertTrue(utils.cmp(os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, 'mvrf_interfaces_nomgmt'), self.output_file)) - + def test_ports_json(self): ports_template = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-orchagent', 'ports.json.j2') argument = ['-m', self.simple_minigraph, '-p', self.t0_port_config, '-t', ports_template] @@ -223,7 +223,7 @@ def test_l2switch_template(self): output_json = json.loads(output) self.assertTrue(json.dumps(sample_output_json, sort_keys=True) == json.dumps(output_json, sort_keys=True)) - + def test_l1_ports_template(self): argument = ['-k', '32x1000Gb', '--preset', 'l1', '-p', self.l1_l3_port_config] output = self.run_script(argument) @@ -345,7 +345,7 @@ def _test_qos_render_template(self, vendor, platform, sku, minigraph, expected): # cleanup qos_config_file_new = os.path.join(dir_path, 'qos_config.j2') os.remove(qos_config_file_new) - + self.remove_machine_conf(file_exist, dir_exist) sample_output_file = os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, expected) @@ -365,6 +365,8 @@ def test_qos_dscp_remapping_render_template(self): '../../../device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-C64', '../../../device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-C64', '../../../device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-C64', + '../../../device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D48C40', + '../../../device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D48C40', '../../../device/arista/x86_64-arista_7050_qx32s/Arista-7050-QX-32S' ] sample_outputs = [ @@ -376,6 +378,8 @@ def test_qos_dscp_remapping_render_template(self): 'qos-arista7260-t1-remap-disabled.json', 'qos-mellanox4600c-c64.json', 'qos-mellanox4600c-c64-remap-disabled.json', + 'qos-mellanox4600c-d48c40-t0.json', + 'qos-mellanox4600c-d48c40-t0-remap-disabled.json', 'qos-arista7050-t0-storage-backend.json' ] sample_minigraph_files = [ @@ -387,6 +391,8 @@ def test_qos_dscp_remapping_render_template(self): 'sample-arista-7260-t1-minigraph-remap-disabled.xml', 'sample-mellanox-4600c-t1-minigraph.xml', 'sample-mellanox-4600c-t1-minigraph-remap-disabled.xml', + 'sample-mellanox-4600c-t0-minigraph.xml', + 'sample-mellanox-4600c-t0-minigraph-remap-disabled.xml', 'sample-arista-7050-t0-storage-backend-minigraph.xml' ] @@ -482,9 +488,6 @@ def _test_buffers_render_template(self, vendor, platform, sku, minigraph, buffer def test_buffers_dell6100_render_template(self): self._test_buffers_render_template('dell', 'x86_64-dell_s6100_c2538-r0', 'Force10-S6100', 'sample-dell-6100-t0-minigraph.xml', 'buffers.json.j2', 'buffers-dell6100.json') - def test_buffers_mellanox2700_render_template(self): - self._test_buffers_render_template('mellanox', 'x86_64-mlnx_msn2700-r0', 'Mellanox-SN2700-D48C8', 'sample-mellanox-2700-t0-minigraph.xml', 'buffers.json.j2', 'buffers-mellanox2700.json') - def test_buffers_mellanox2410_render_template(self): self._test_buffers_render_template('mellanox', 'x86_64-mlnx_msn2410-r0', 'ACS-MSN2410', 'sample-mellanox-2410-t1-minigraph.xml', 'buffers.json.j2', 'buffers-mellanox2410.json') @@ -507,8 +510,12 @@ def test_extra_lossless_buffer_for_tunnel_remapping(self): ('mellanox', 'x86_64-mlnx_msn4600c-r0', 'Mellanox-SN4600C-C64', 'sample-mellanox-4600c-t1-minigraph.xml', 'buffers_dynamic.json.j2', 'buffers-mellanox4600c-t1-dynamic.json'), ('mellanox', 'x86_64-mlnx_msn4600c-r0', 'Mellanox-SN4600C-C64', 'sample-mellanox-4600c-t1-minigraph.xml', 'buffers.json.j2', 'buffers-mellanox4600c-t1.json'), ('mellanox', 'x86_64-mlnx_msn4600c-r0', 'Mellanox-SN4600C-C64', 'sample-mellanox-4600c-t1-minigraph-remap-disabled.xml', 'buffers_dynamic.json.j2', 'buffers-mellanox4600c-t1-dynamic-remap-disabled.json'), - ('mellanox', 'x86_64-mlnx_msn4600c-r0', 'Mellanox-SN4600C-C64', 'sample-mellanox-4600c-t1-minigraph-remap-disabled.xml', 'buffers.json.j2', 'buffers-mellanox4600c-t1-remap-disabled.json') - ] + ('mellanox', 'x86_64-mlnx_msn4600c-r0', 'Mellanox-SN4600C-C64', 'sample-mellanox-4600c-t1-minigraph-remap-disabled.xml', 'buffers.json.j2', 'buffers-mellanox4600c-t1-remap-disabled.json'), + ('mellanox', 'x86_64-mlnx_msn4600c-r0', 'Mellanox-SN4600C-D48C40', 'sample-mellanox-4600c-t0-minigraph.xml', 'buffers_dynamic.json.j2', 'buffers-mellanox4600c-t0-dynamic.json'), + ('mellanox', 'x86_64-mlnx_msn4600c-r0', 'Mellanox-SN4600C-D48C40', 'sample-mellanox-4600c-t0-minigraph.xml', 'buffers.json.j2', 'buffers-mellanox4600c-t0.json'), + ('mellanox', 'x86_64-mlnx_msn4600c-r0', 'Mellanox-SN4600C-D48C40', 'sample-mellanox-4600c-t0-minigraph-remap-disabled.xml', 'buffers_dynamic.json.j2', 'buffers-mellanox4600c-t0-dynamic-remap-disabled.json'), + ('mellanox', 'x86_64-mlnx_msn4600c-r0', 'Mellanox-SN4600C-D48C40', 'sample-mellanox-4600c-t0-minigraph-remap-disabled.xml', 'buffers.json.j2', 'buffers-mellanox4600c-t0-remap-disabled.json') + ] for test_data in TEST_DATA: self._test_buffers_render_template(vendor=test_data[0], @@ -522,7 +529,7 @@ def test_ipinip_multi_asic(self): ipinip_file = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-orchagent', 'ipinip.json.j2') argument = ['-m', self.multi_asic_minigraph, '-p', self.multi_asic_port_config, '-t', ipinip_file, '-n', 'asic0'] print(argument) - self.run_script(argument, output_file=self.output_file) + self.run_script(argument, output_file=self.output_file) sample_output_file = os.path.join(self.test_dir, 'multi_npu_data', utils.PYvX_DIR, 'ipinip.json') assert utils.cmp(sample_output_file, self.output_file), self.run_diff(sample_output_file, self.output_file) @@ -629,6 +636,11 @@ def test_backend_acl_template_render(self): self.run_script(argument, output_file=self.output_file) assert utils.cmp(sample_output_file, self.output_file), self.run_diff(sample_output_file, self.output_file) + + def test_buffers_edgezone_aggregator_render_template(self): + self._test_buffers_render_template('arista', 'x86_64-arista_7060_cx32s', 'Arista-7060CX-32S-D48C8', 'sample-arista-7060-t0-minigraph.xml', 'buffers.json.j2', 'buffer-arista7060-t0.json') + + def tearDown(self): os.environ["CFGGEN_UNIT_TESTING"] = "" try: diff --git a/src/sonic-config-engine/tests/test_minigraph_case.py b/src/sonic-config-engine/tests/test_minigraph_case.py index 90731e0855a7..7f0319fa3413 100644 --- a/src/sonic-config-engine/tests/test_minigraph_case.py +++ b/src/sonic-config-engine/tests/test_minigraph_case.py @@ -158,7 +158,7 @@ def test_minigraph_portchannels(self): output = self.run_script(argument) self.assertEqual( utils.to_dict(output.strip()), - utils.to_dict("{'PortChannel01': {'admin_status': 'up', 'min_links': '1', 'members': ['Ethernet4'], 'mtu': '9100', 'tpid': '0x8100', 'lacp_key': 'auto'}}") + utils.to_dict("{'PortChannel01': {'admin_status': 'up', 'min_links': '1', 'mtu': '9100', 'tpid': '0x8100', 'lacp_key': 'auto'}}") ) def test_minigraph_console_mgmt_feature(self): @@ -467,6 +467,29 @@ def test_minigraph_mirror_dscp(self): expected_ports.sort() ) + def test_minigraph_acl_attach_to_ports(self): + """ + The test case is to verify ACL table can be bound to both port names and alias + """ + sample_graph = os.path.join(self.test_dir,'simple-sample-graph-case-acl-test.xml') + port_config_duplicated_name_alias = os.path.join(self.test_dir, 't0-sample-port-config-duplicated-name-alias.ini') + result = minigraph.parse_xml(sample_graph, port_config_file=port_config_duplicated_name_alias) + # TC1: All ports are portchannels or port names + expected_dataacl_ports = ['PortChannel01','Ethernet20','Ethernet24'] + self.assertEqual(sorted(result['ACL_TABLE']['DATAACL_PORT_NAME']['ports']), sorted(expected_dataacl_ports)) + # TC2: All ports are portchanels or port alias + expected_dataacl_ports = ['PortChannel01','Ethernet4','Ethernet8'] + self.assertEqual(sorted(result['ACL_TABLE']['DATAACL_PORT_ALIAS']['ports']), sorted(expected_dataacl_ports)) + # TC3: Duplicated values in port names and alias, but all fall in port names + expected_dataacl_ports = ['PortChannel01','Ethernet0','Ethernet1','Ethernet2','Ethernet3'] + self.assertEqual(sorted(result['ACL_TABLE']['DATAACL_MIXED_NAME_ALIAS_1']['ports']), sorted(expected_dataacl_ports)) + # TC4: Duplicated values in port names and alias, but all fall in port alias + expected_dataacl_ports = ['PortChannel01','Ethernet0','Ethernet1','Ethernet4','Ethernet8'] + self.assertEqual(sorted(result['ACL_TABLE']['DATAACL_MIXED_NAME_ALIAS_2']['ports']), sorted(expected_dataacl_ports)) + # TC5: Same count in port names and alias, port alias is preferred + expected_dataacl_ports = ['Ethernet0'] + self.assertEqual(sorted(result['ACL_TABLE']['DATAACL_MIXED_NAME_ALIAS_3']['ports']), sorted(expected_dataacl_ports)) + def test_parse_device_desc_xml_mgmt_interface(self): # Regular device_desc.xml with both IPv4 and IPv6 mgmt address result = minigraph.parse_device_desc_xml(self.sample_simple_device_desc) diff --git a/src/sonic-config-engine/tests/test_multinpu_cfggen.py b/src/sonic-config-engine/tests/test_multinpu_cfggen.py index 8559c10394a3..b4bff8b9ae5d 100644 --- a/src/sonic-config-engine/tests/test_multinpu_cfggen.py +++ b/src/sonic-config-engine/tests/test_multinpu_cfggen.py @@ -161,16 +161,16 @@ def test_frontend_asic_portchannels(self): argument = ["-m", self.sample_graph, "-p", self.port_config[0], "-n", "asic0", "--var-json", "PORTCHANNEL"] output = json.loads(self.run_script(argument)) self.assertDictEqual(output, \ - {'PortChannel0002': {'admin_status': 'up', 'min_links': '2', 'members': ['Ethernet0', 'Ethernet4'], 'mtu': '9100', 'tpid': '0x8100', 'lacp_key': 'auto'}, - 'PortChannel4001': {'admin_status': 'up', 'min_links': '2', 'members': ['Ethernet-BP0', 'Ethernet-BP4'], 'mtu': '9100', 'tpid': '0x8100', 'lacp_key': 'auto'}, - 'PortChannel4002': {'admin_status': 'up', 'min_links': '2', 'members': ['Ethernet-BP8', 'Ethernet-BP12'], 'mtu': '9100', 'tpid': '0x8100', 'lacp_key': 'auto'}}) + {'PortChannel0002': {'admin_status': 'up', 'min_links': '2', 'mtu': '9100', 'tpid': '0x8100', 'lacp_key': 'auto'}, + 'PortChannel4001': {'admin_status': 'up', 'min_links': '2', 'mtu': '9100', 'tpid': '0x8100', 'lacp_key': 'auto'}, + 'PortChannel4002': {'admin_status': 'up', 'min_links': '2', 'mtu': '9100', 'tpid': '0x8100', 'lacp_key': 'auto'}}) def test_backend_asic_portchannels(self): argument = ["-m", self.sample_graph, "-p", self.port_config[3], "-n", "asic3", "--var-json", "PORTCHANNEL"] output = json.loads(self.run_script(argument)) self.assertDictEqual(output, \ - {'PortChannel4013': {'admin_status': 'up', 'min_links': '2', 'members': ['Ethernet-BP384', 'Ethernet-BP388'], 'mtu': '9100', 'tpid': '0x8100', 'lacp_key': 'auto'}, - 'PortChannel4014': {'admin_status': 'up', 'min_links': '2', 'members': ['Ethernet-BP392', 'Ethernet-BP396'], 'mtu': '9100', 'tpid': '0x8100', 'lacp_key': 'auto'}}) + {'PortChannel4013': {'admin_status': 'up', 'min_links': '2', 'mtu': '9100', 'tpid': '0x8100', 'lacp_key': 'auto'}, + 'PortChannel4014': {'admin_status': 'up', 'min_links': '2', 'mtu': '9100', 'tpid': '0x8100', 'lacp_key': 'auto'}}) def test_frontend_asic_portchannel_mem(self): argument = ["-m", self.sample_graph, "-p", self.port_config[0], "-n", "asic0", "-v", "PORTCHANNEL_MEMBER.keys()|list"] diff --git a/src/sonic-config-engine/tests/voq-sample-400g-port-config.ini b/src/sonic-config-engine/tests/voq-sample-400g-port-config.ini new file mode 100644 index 000000000000..f86cdb335ed8 --- /dev/null +++ b/src/sonic-config-engine/tests/voq-sample-400g-port-config.ini @@ -0,0 +1,21 @@ +# name lanes alias index role speed asic_port_name +Ethernet0 72,73,74,75,76,77,78,79 Ethernet1/1 1 Ext 400000 Eth0-ASIC0 +Ethernet8 80,81,82,83,84,85,86,87 Ethernet2/1 2 Ext 400000 Eth8-ASIC0 +Ethernet16 88,89,90,91,92,93,94,95 Ethernet3/1 3 Ext 400000 Eth16-ASIC0 +Ethernet24 96,97,98,99,100,101,102,103 Ethernet4/1 4 Ext 400000 Eth24-ASIC0 +Ethernet32 104,105,106,107,108,109,110,111 Ethernet5/1 5 Ext 400000 Eth32-ASIC0 +Ethernet40 112,113,114,115,116,117,118,119 Ethernet6/1 6 Ext 400000 Eth40-ASIC0 +Ethernet48 120,121,122,123,124,125,126,127 Ethernet7/1 7 Ext 400000 Eth48-ASIC0 +Ethernet56 128,129,130,131,132,133,134,135 Ethernet8/1 8 Ext 400000 Eth56-ASIC0 +Ethernet64 136,137,138,139,140,141,142,143 Ethernet9/1 9 Ext 400000 Eth64-ASIC0 +Ethernet72 64,65,66,67,68,69,70,71 Ethernet10/1 10 Ext 400000 Eth72-ASIC0 +Ethernet80 56,57,58,59,60,61,62,63 Ethernet11/1 11 Ext 400000 Eth80-ASIC0 +Ethernet88 48,49,50,51,52,53,54,55 Ethernet12/1 12 Ext 400000 Eth88-ASIC0 +Ethernet96 40,41,42,43,44,45,46,47 Ethernet13/1 13 Ext 400000 Eth96-ASIC0 +Ethernet104 32,33,34,35,36,37,38,39 Ethernet14/1 14 Ext 400000 Eth104-ASIC0 +Ethernet112 24,25,26,27,28,29,30,31 Ethernet15/1 15 Ext 400000 Eth112-ASIC0 +Ethernet120 16,17,18,19,20,21,22,23 Ethernet16/1 16 Ext 400000 Eth120-ASIC0 +Ethernet128 8,9,10,11,12,13,14,15 Ethernet17/1 17 Ext 400000 Eth128-ASIC0 +Ethernet136 0,1,2,3,4,5,6,7 Ethernet18/1 18 Ext 400000 Eth136-ASIC0 +Ethernet-Rec0 221 Recirc0/0 37 Rec 400000 Rcy0-ASIC0 +Ethernet-IB0 222 Recirc0/1 38 Inb 400000 Rcy1-ASIC0 diff --git a/src/sonic-config-engine/tests/voq-sample-masic-graph.xml b/src/sonic-config-engine/tests/voq-sample-masic-graph.xml new file mode 100644 index 000000000000..cda6c1a6a3bf --- /dev/null +++ b/src/sonic-config-engine/tests/voq-sample-masic-graph.xml @@ -0,0 +1,3903 @@ + + + + + + false + str2-sonic-lc5-1 + 10.0.0.0 + ARISTA01T3 + 10.0.0.1 + 1 + 10 + 3 + + + false + ASIC0 + 10.0.0.0 + ARISTA01T3 + 10.0.0.1 + 1 + 10 + 3 + + + str2-sonic-lc5-1 + FC00::1 + ARISTA01T3 + FC00::2 + 1 + 10 + 3 + + + ASIC0 + FC00::1 + ARISTA01T3 + FC00::2 + 1 + 10 + 3 + + + false + str2-sonic-lc5-1 + 10.0.0.4 + ARISTA03T3 + 10.0.0.5 + 1 + 10 + 3 + + + false + ASIC0 + 10.0.0.4 + ARISTA03T3 + 10.0.0.5 + 1 + 10 + 3 + + + str2-sonic-lc5-1 + FC00::9 + ARISTA03T3 + FC00::A + 1 + 10 + 3 + + + ASIC0 + FC00::9 + ARISTA03T3 + FC00::A + 1 + 10 + 3 + + + false + str2-sonic-lc5-1 + 10.0.0.8 + ARISTA05T3 + 10.0.0.9 + 1 + 10 + 3 + + + false + ASIC0 + 10.0.0.8 + ARISTA05T3 + 10.0.0.9 + 1 + 10 + 3 + + + str2-sonic-lc5-1 + FC00::11 + ARISTA05T3 + FC00::12 + 1 + 10 + 3 + + + ASIC0 + FC00::11 + ARISTA05T3 + FC00::12 + 1 + 10 + 3 + + + false + str2-sonic-lc5-1 + 10.0.0.12 + ARISTA07T3 + 10.0.0.13 + 1 + 10 + 3 + + + false + ASIC0 + 10.0.0.12 + ARISTA07T3 + 10.0.0.13 + 1 + 10 + 3 + + + str2-sonic-lc5-1 + FC00::19 + ARISTA07T3 + FC00::1A + 1 + 10 + 3 + + + ASIC0 + FC00::19 + ARISTA07T3 + FC00::1A + 1 + 10 + 3 + + + false + str2-sonic-lc5-1 + 10.0.0.16 + ARISTA09T3 + 10.0.0.17 + 1 + 10 + 3 + + + false + ASIC0 + 10.0.0.16 + ARISTA09T3 + 10.0.0.17 + 1 + 10 + 3 + + + str2-sonic-lc5-1 + FC00::21 + ARISTA09T3 + FC00::22 + 1 + 10 + 3 + + + ASIC0 + FC00::21 + ARISTA09T3 + FC00::22 + 1 + 10 + 3 + + + false + str2-sonic-lc5-1 + 10.0.0.20 + ARISTA11T3 + 10.0.0.21 + 1 + 10 + 3 + + + false + ASIC0 + 10.0.0.20 + ARISTA11T3 + 10.0.0.21 + 1 + 10 + 3 + + + str2-sonic-lc5-1 + FC00::29 + ARISTA11T3 + FC00::2A + 1 + 10 + 3 + + + ASIC0 + FC00::29 + ARISTA11T3 + FC00::2A + 1 + 10 + 3 + + + false + str2-sonic-lc5-1 + 10.0.0.32 + ARISTA13T3 + 10.0.0.33 + 1 + 10 + 3 + + + false + ASIC0 + 10.0.0.32 + ARISTA13T3 + 10.0.0.33 + 1 + 10 + 3 + + + str2-sonic-lc5-1 + FC00::41 + ARISTA13T3 + FC00::42 + 1 + 10 + 3 + + + ASIC0 + FC00::41 + ARISTA13T3 + FC00::42 + 1 + 10 + 3 + + + false + str2-sonic-lc5-1 + 10.0.0.28 + ARISTA15T3 + 10.0.0.29 + 1 + 10 + 3 + + + false + ASIC0 + 10.0.0.28 + ARISTA15T3 + 10.0.0.29 + 1 + 10 + 3 + + + str2-sonic-lc5-1 + FC00::39 + ARISTA15T3 + FC00::3A + 1 + 10 + 3 + + + ASIC0 + FC00::39 + ARISTA15T3 + FC00::3A + 1 + 10 + 3 + + + false + str2-sonic-lc5-1 + 10.0.0.34 + ARISTA17T3 + 10.0.0.35 + 1 + 10 + 3 + + + false + ASIC0 + 10.0.0.34 + ARISTA17T3 + 10.0.0.35 + 1 + 10 + 3 + + + str2-sonic-lc5-1 + FC00::45 + ARISTA17T3 + FC00::46 + 1 + 10 + 3 + + + ASIC0 + FC00::45 + ARISTA17T3 + FC00::46 + 1 + 10 + 3 + + + false + str2-sonic-lc5-1 + 10.0.0.24 + ARISTA18T3 + 10.0.0.25 + 1 + 10 + 3 + + + false + ASIC0 + 10.0.0.24 + ARISTA18T3 + 10.0.0.25 + 1 + 10 + 3 + + + str2-sonic-lc5-1 + FC00::31 + ARISTA18T3 + FC00::32 + 1 + 10 + 3 + + + ASIC0 + FC00::31 + ARISTA18T3 + FC00::32 + 1 + 10 + 3 + + + false + str2-sonic-lc5-1 + 10.0.0.36 + ARISTA19T3 + 10.0.0.37 + 1 + 10 + 3 + + + false + ASIC1 + 10.0.0.36 + ARISTA19T3 + 10.0.0.37 + 1 + 10 + 3 + + + str2-sonic-lc5-1 + FC00::49 + ARISTA19T3 + FC00::4A + 1 + 10 + 3 + + + ASIC1 + FC00::49 + ARISTA19T3 + FC00::4A + 1 + 10 + 3 + + + false + str2-sonic-lc5-1 + 10.0.0.38 + ARISTA20T3 + 10.0.0.39 + 1 + 10 + 3 + + + false + ASIC1 + 10.0.0.38 + ARISTA20T3 + 10.0.0.39 + 1 + 10 + 3 + + + str2-sonic-lc5-1 + FC00::4D + ARISTA20T3 + FC00::4E + 1 + 10 + 3 + + + ASIC1 + FC00::4D + ARISTA20T3 + FC00::4E + 1 + 10 + 3 + + + false + str2-sonic-lc5-1 + 10.0.0.40 + ARISTA21T3 + 10.0.0.41 + 1 + 10 + 3 + + + false + ASIC1 + 10.0.0.40 + ARISTA21T3 + 10.0.0.41 + 1 + 10 + 3 + + + str2-sonic-lc5-1 + FC00::51 + ARISTA21T3 + FC00::52 + 1 + 10 + 3 + + + ASIC1 + FC00::51 + ARISTA21T3 + FC00::52 + 1 + 10 + 3 + + + false + str2-sonic-lc5-1 + 10.0.0.42 + ARISTA22T3 + 10.0.0.43 + 1 + 10 + 3 + + + false + ASIC1 + 10.0.0.42 + ARISTA22T3 + 10.0.0.43 + 1 + 10 + 3 + + + str2-sonic-lc5-1 + FC00::55 + ARISTA22T3 + FC00::56 + 1 + 10 + 3 + + + ASIC1 + FC00::55 + ARISTA22T3 + FC00::56 + 1 + 10 + 3 + + + false + str2-sonic-lc5-1 + 10.0.0.44 + ARISTA23T3 + 10.0.0.45 + 1 + 10 + 3 + + + false + ASIC1 + 10.0.0.44 + ARISTA23T3 + 10.0.0.45 + 1 + 10 + 3 + + + str2-sonic-lc5-1 + FC00::59 + ARISTA23T3 + FC00::5A + 1 + 10 + 3 + + + ASIC1 + FC00::59 + ARISTA23T3 + FC00::5A + 1 + 10 + 3 + + + false + str2-sonic-lc5-1 + 10.0.0.46 + ARISTA24T3 + 10.0.0.47 + 1 + 10 + 3 + + + false + ASIC1 + 10.0.0.46 + ARISTA24T3 + 10.0.0.47 + 1 + 10 + 3 + + + str2-sonic-lc5-1 + FC00::5D + ARISTA24T3 + FC00::5E + 1 + 10 + 3 + + + ASIC1 + FC00::5D + ARISTA24T3 + FC00::5E + 1 + 10 + 3 + + + false + str2-sonic-lc5-1 + 10.0.0.48 + ARISTA25T3 + 10.0.0.49 + 1 + 10 + 3 + + + false + ASIC1 + 10.0.0.48 + ARISTA25T3 + 10.0.0.49 + 1 + 10 + 3 + + + str2-sonic-lc5-1 + FC00::61 + ARISTA25T3 + FC00::62 + 1 + 10 + 3 + + + ASIC1 + FC00::61 + ARISTA25T3 + FC00::62 + 1 + 10 + 3 + + + false + str2-sonic-lc5-1 + 10.0.0.50 + ARISTA26T3 + 10.0.0.51 + 1 + 10 + 3 + + + false + ASIC1 + 10.0.0.50 + ARISTA26T3 + 10.0.0.51 + 1 + 10 + 3 + + + str2-sonic-lc5-1 + FC00::65 + ARISTA26T3 + FC00::66 + 1 + 10 + 3 + + + ASIC1 + FC00::65 + ARISTA26T3 + FC00::66 + 1 + 10 + 3 + + + false + str2-sonic-lc5-1 + 10.0.0.52 + ARISTA27T3 + 10.0.0.53 + 1 + 10 + 3 + + + false + ASIC1 + 10.0.0.52 + ARISTA27T3 + 10.0.0.53 + 1 + 10 + 3 + + + str2-sonic-lc5-1 + FC00::69 + ARISTA27T3 + FC00::6A + 1 + 10 + 3 + + + ASIC1 + FC00::69 + ARISTA27T3 + FC00::6A + 1 + 10 + 3 + + + false + str2-sonic-lc5-1 + 10.0.0.54 + ARISTA28T3 + 10.0.0.55 + 1 + 10 + 3 + + + false + ASIC1 + 10.0.0.54 + ARISTA28T3 + 10.0.0.55 + 1 + 10 + 3 + + + str2-sonic-lc5-1 + FC00::6D + ARISTA28T3 + FC00::6E + 1 + 10 + 3 + + + ASIC1 + FC00::6D + ARISTA28T3 + FC00::6E + 1 + 10 + 3 + + + false + str2-sonic-lc5-1 + 10.0.0.56 + ARISTA29T3 + 10.0.0.57 + 1 + 10 + 3 + + + false + ASIC1 + 10.0.0.56 + ARISTA29T3 + 10.0.0.57 + 1 + 10 + 3 + + + str2-sonic-lc5-1 + FC00::71 + ARISTA29T3 + FC00::72 + 1 + 10 + 3 + + + ASIC1 + FC00::71 + ARISTA29T3 + FC00::72 + 1 + 10 + 3 + + + false + str2-sonic-lc5-1 + 10.0.0.58 + ARISTA30T3 + 10.0.0.59 + 1 + 10 + 3 + + + false + ASIC1 + 10.0.0.58 + ARISTA30T3 + 10.0.0.59 + 1 + 10 + 3 + + + str2-sonic-lc5-1 + FC00::75 + ARISTA30T3 + FC00::76 + 1 + 10 + 3 + + + ASIC1 + FC00::75 + ARISTA30T3 + FC00::76 + 1 + 10 + 3 + + + false + str2-sonic-lc5-1 + 10.0.0.60 + ARISTA31T3 + 10.0.0.61 + 1 + 10 + 3 + + + false + ASIC1 + 10.0.0.60 + ARISTA31T3 + 10.0.0.61 + 1 + 10 + 3 + + + str2-sonic-lc5-1 + FC00::79 + ARISTA31T3 + FC00::7A + 1 + 10 + 3 + + + ASIC1 + FC00::79 + ARISTA31T3 + FC00::7A + 1 + 10 + 3 + + + false + str2-sonic-lc5-1 + 10.0.0.62 + ARISTA32T3 + 10.0.0.63 + 1 + 10 + 3 + + + false + ASIC1 + 10.0.0.62 + ARISTA32T3 + 10.0.0.63 + 1 + 10 + 3 + + + str2-sonic-lc5-1 + FC00::7D + ARISTA32T3 + FC00::7E + 1 + 10 + 3 + + + ASIC1 + FC00::7D + ARISTA32T3 + FC00::7E + 1 + 10 + 3 + + + + + ASIC0 + ASIC1 + 3.3.3.2 + 3.3.3.3 + 1 + 0 + 0 + voq + + + ASIC0 + ASIC1 + 3333::3:2 + 3333::3:3 + 1 + 0 + 0 + voq + + + ASIC0 + str2-sonic-lc3-1 + 3.3.3.2 + 3.3.3.1 + 1 + 0 + 0 + voq + + + ASIC0 + str2-sonic-lc3-1 + 3333::3:2 + 3333::3:1 + 1 + 0 + 0 + voq + + + ASIC0 + str2-sonic-lc7-1 + 3.3.3.2 + 3.3.3.5 + 1 + 0 + 0 + voq + + + ASIC0 + str2-sonic-lc7-1 + 3333::3:2 + 3333::3:5 + 1 + 0 + 0 + voq + + + ASIC1 + ASIC0 + 3.3.3.3 + 3.3.3.2 + 1 + 0 + 0 + voq + + + ASIC1 + ASIC0 + 3333::3:3 + 3333::3:2 + 1 + 0 + 0 + voq + + + ASIC1 + str2-sonic-lc3-1 + 3.3.3.3 + 3.3.3.1 + 1 + 0 + 0 + voq + + + ASIC1 + str2-sonic-lc3-1 + 3333::3:3 + 3333::3:1 + 1 + 0 + 0 + voq + + + ASIC1 + str2-sonic-lc7-1 + 3.3.3.3 + 3.3.3.5 + 1 + 0 + 0 + voq + + + ASIC1 + str2-sonic-lc7-1 + 3333::3:3 + 3333::3:5 + 1 + 0 + 0 + voq + + + + + 65100 + str2-sonic-lc5-1 + + +
10.0.0.1
+ + + +
+ +
10.0.0.5
+ + + +
+ +
10.0.0.9
+ + + +
+ +
10.0.0.13
+ + + +
+ +
10.0.0.17
+ + + +
+ +
10.0.0.21
+ + + +
+ +
10.0.0.33
+ + + +
+ +
10.0.0.29
+ + + +
+ +
10.0.0.35
+ + + +
+ +
10.0.0.25
+ + + +
+ +
10.0.0.37
+ + + +
+ +
10.0.0.39
+ + + +
+ +
10.0.0.41
+ + + +
+ +
10.0.0.43
+ + + +
+ +
10.0.0.45
+ + + +
+ +
10.0.0.47
+ + + +
+ +
10.0.0.49
+ + + +
+ +
10.0.0.51
+ + + +
+ +
10.0.0.53
+ + + +
+ +
10.0.0.55
+ + + +
+ +
10.0.0.57
+ + + +
+ +
10.0.0.59
+ + + +
+ +
10.0.0.61
+ + + +
+ +
10.0.0.63
+ + + +
+
+ +
+ + 65200 + ARISTA01T3 + + + + 65200 + ARISTA03T3 + + + + 65200 + ARISTA05T3 + + + + 65200 + ARISTA07T3 + + + + 65200 + ARISTA09T3 + + + + 65200 + ARISTA11T3 + + + + 65200 + ARISTA13T3 + + + + 65200 + ARISTA15T3 + + + + 65200 + ARISTA17T3 + + + + 65200 + ARISTA18T3 + + + + 65200 + ARISTA19T3 + + + + 65200 + ARISTA20T3 + + + + 65200 + ARISTA21T3 + + + + 65200 + ARISTA22T3 + + + + 65200 + ARISTA23T3 + + + + 65200 + ARISTA24T3 + + + + 65200 + ARISTA25T3 + + + + 65200 + ARISTA26T3 + + + + 65200 + ARISTA27T3 + + + + 65200 + ARISTA28T3 + + + + 65200 + ARISTA29T3 + + + + 65200 + ARISTA30T3 + + + + 65200 + ARISTA31T3 + + + + 65200 + ARISTA32T3 + + + + 65100 + ASIC1 + + +
10.0.0.37
+ + + +
+ +
10.0.0.39
+ + + +
+ +
10.0.0.41
+ + + +
+ +
10.0.0.43
+ + + +
+ +
10.0.0.45
+ + + +
+ +
10.0.0.47
+ + + +
+ +
10.0.0.49
+ + + +
+ +
10.0.0.51
+ + + +
+ +
10.0.0.53
+ + + +
+ +
10.0.0.55
+ + + +
+ +
10.0.0.57
+ + + +
+ +
10.0.0.59
+ + + +
+ +
10.0.0.61
+ + + +
+ +
10.0.0.63
+ + + +
+ +
3.3.3.2/32
+ + + +
+ +
3.3.3.1/32
+ + + +
+ +
3.3.3.5/32
+ + + +
+
+ +
+ + 65100 + ASIC0 + + +
10.0.0.1
+ + + +
+ +
10.0.0.5
+ + + +
+ +
10.0.0.9
+ + + +
+ +
10.0.0.13
+ + + +
+ +
10.0.0.17
+ + + +
+ +
10.0.0.21
+ + + +
+ +
10.0.0.33
+ + + +
+ +
10.0.0.29
+ + + +
+ +
10.0.0.35
+ + + +
+ +
10.0.0.25
+ + + +
+ +
3.3.3.3/32
+ + + +
+ +
3.3.3.1/32
+ + + +
+ +
3.3.3.5/32
+ + + +
+
+ +
+ + 65100 + str2-sonic-lc3-1 + + + + 65100 + str2-sonic-lc7-1 + + +
+
+ + + + + + HostIP + Loopback0 + + 10.1.0.1/32 + + 10.1.0.1/32 + + + HostIP1 + Loopback0 + + FC00:10::1/128 + + FC00:10::1/128 + + + + + HostIP + eth0 + + 10.3.147.27/23 + + 10.3.147.27/23 + + + V6HostIP + eth0 + + FC00:2::32/64 + + FC00:2::32/64 + + + + + + + str2-sonic-lc5-1 + + + PortChannel102 + Ethernet1/1;Ethernet2/1 + + + + PortChannel104 + Ethernet3/1;Ethernet4/1 + + + + PortChannel106 + Ethernet5/1;Ethernet6/1 + + + + PortChannel108 + Ethernet7/1;Ethernet8/1 + + + + PortChannel1010 + Ethernet9/1;Ethernet10/1 + + + + PortChannel1012 + Ethernet11/1;Ethernet12/1 + + + + PortChannel1016 + Ethernet14/1;Ethernet15/1 + + + + PortChannel1020 + Ethernet17/1;Ethernet18/1 + + + + + + + + + PortChannel102 + 10.0.0.0/31 + + + + PortChannel102 + FC00::1/126 + + + + PortChannel104 + 10.0.0.4/31 + + + + PortChannel104 + FC00::9/126 + + + + PortChannel106 + 10.0.0.8/31 + + + + PortChannel106 + FC00::11/126 + + + + PortChannel108 + 10.0.0.12/31 + + + + PortChannel108 + FC00::19/126 + + + + PortChannel1010 + 10.0.0.16/31 + + + + PortChannel1010 + FC00::21/126 + + + + PortChannel1012 + 10.0.0.20/31 + + + + PortChannel1012 + FC00::29/126 + + + + Ethernet13/1 + 10.0.0.32/31 + + + + Ethernet13/1 + FC00::41/126 + + + + PortChannel1016 + 10.0.0.28/31 + + + + PortChannel1016 + FC00::39/126 + + + + Ethernet16/1 + 10.0.0.34/31 + + + + Ethernet16/1 + FC00::45/126 + + + + PortChannel1020 + 10.0.0.24/31 + + + + PortChannel1020 + FC00::31/126 + + + + Ethernet19/1 + 10.0.0.36/31 + + + + Ethernet19/1 + FC00::49/126 + + + + Ethernet20/1 + 10.0.0.38/31 + + + + Ethernet20/1 + FC00::4D/126 + + + + Ethernet21/1 + 10.0.0.40/31 + + + + Ethernet21/1 + FC00::51/126 + + + + Ethernet22/1 + 10.0.0.42/31 + + + + Ethernet22/1 + FC00::55/126 + + + + Ethernet23/1 + 10.0.0.44/31 + + + + Ethernet23/1 + FC00::59/126 + + + + Ethernet24/1 + 10.0.0.46/31 + + + + Ethernet24/1 + FC00::5D/126 + + + + Ethernet25/1 + 10.0.0.48/31 + + + + Ethernet25/1 + FC00::61/126 + + + + Ethernet26/1 + 10.0.0.50/31 + + + + Ethernet26/1 + FC00::65/126 + + + + Ethernet27/1 + 10.0.0.52/31 + + + + Ethernet27/1 + FC00::69/126 + + + + Ethernet28/1 + 10.0.0.54/31 + + + + Ethernet28/1 + FC00::6D/126 + + + + Ethernet29/1 + 10.0.0.56/31 + + + + Ethernet29/1 + FC00::71/126 + + + + Ethernet30/1 + 10.0.0.58/31 + + + + Ethernet30/1 + FC00::75/126 + + + + Ethernet31/1 + 10.0.0.60/31 + + + + Ethernet31/1 + FC00::79/126 + + + + Ethernet32/1 + 10.0.0.62/31 + + + + Ethernet32/1 + FC00::7D/126 + + + + + + NTP_ACL + NTP + NTP + + + SNMP_ACL + SNMP + SNMP + + + ERSPAN + Everflow + Everflow + + + ERSPANV6 + EverflowV6 + EverflowV6 + + + VTY_LINE + ssh-only + SSH + + + PortChannel102;PortChannel104;PortChannel106;PortChannel108;PortChannel1010;PortChannel1012;PortChannel1016;PortChannel1020;Ethernet13/1;Ethernet16/1;Ethernet19/1;Ethernet20/1;Ethernet21/1;Ethernet22/1;Ethernet23/1;Ethernet24/1;Ethernet25/1;Ethernet26/1;Ethernet27/1;Ethernet28/1;Ethernet29/1;Ethernet30/1;Ethernet31/1;Ethernet32/1 + DataAcl + DataPlane + + + + + + + + + + HostIP + Loopback0 + + 10.1.0.1/32 + + 10.1.0.1/32 + + + HostIP1 + Loopback0 + + FC00:10::1/128 + + FC00:10::1/128 + + + HostIP1 + Loopback4096 + + 192.0.0.3/32 + + 192.0.0.3/32 + + + HostIP1 + Loopback4096 + + 2603:10e2:400::3/128 + + 2603:10e2:400::3/128 + + + + + HostIP + eth0 + + 10.3.147.27/23 + + 10.3.147.27/23 + + + V6HostIP + eth0 + + FC00:2::32/64 + + FC00:2::32/64 + + + + + + Ethernet-IB1 + port + 3.3.3.3/32 + + + Ethernet-IB1 + port + 3333::3:3/128 + + + + + + ASIC1 + + + + + + + Eth0-ASIC1 + 10.0.0.36/31 + + + + Eth0-ASIC1 + FC00::49/126 + + + + Eth8-ASIC1 + 10.0.0.38/31 + + + + Eth8-ASIC1 + FC00::4D/126 + + + + Eth16-ASIC1 + 10.0.0.40/31 + + + + Eth16-ASIC1 + FC00::51/126 + + + + Eth24-ASIC1 + 10.0.0.42/31 + + + + Eth24-ASIC1 + FC00::55/126 + + + + Eth32-ASIC1 + 10.0.0.44/31 + + + + Eth32-ASIC1 + FC00::59/126 + + + + Eth40-ASIC1 + 10.0.0.46/31 + + + + Eth40-ASIC1 + FC00::5D/126 + + + + Eth48-ASIC1 + 10.0.0.48/31 + + + + Eth48-ASIC1 + FC00::61/126 + + + + Eth56-ASIC1 + 10.0.0.50/31 + + + + Eth56-ASIC1 + FC00::65/126 + + + + Eth64-ASIC1 + 10.0.0.52/31 + + + + Eth64-ASIC1 + FC00::69/126 + + + + Eth72-ASIC1 + 10.0.0.54/31 + + + + Eth72-ASIC1 + FC00::6D/126 + + + + Eth80-ASIC1 + 10.0.0.56/31 + + + + Eth80-ASIC1 + FC00::71/126 + + + + Eth88-ASIC1 + 10.0.0.58/31 + + + + Eth88-ASIC1 + FC00::75/126 + + + + Eth96-ASIC1 + 10.0.0.60/31 + + + + Eth96-ASIC1 + FC00::79/126 + + + + Eth104-ASIC1 + 10.0.0.62/31 + + + + Eth104-ASIC1 + FC00::7D/126 + + + + + + SNMP_ACL + SNMP + SNMP + + + ERSPAN + Everflow + Everflow + + + ERSPANV6 + EverflowV6 + EverflowV6 + + + VTY_LINE + ssh-only + SSH + + + Eth0-ASIC1;Eth8-ASIC1;Eth16-ASIC1;Eth24-ASIC1;Eth32-ASIC1;Eth40-ASIC1;Eth48-ASIC1;Eth56-ASIC1;Eth64-ASIC1;Eth72-ASIC1;Eth80-ASIC1;Eth88-ASIC1;Eth96-ASIC1;Eth104-ASIC1 + DataAcl + DataPlane + + + + + + + + + + HostIP + Loopback0 + + 10.1.0.1/32 + + 10.1.0.1/32 + + + HostIP1 + Loopback0 + + FC00:10::1/128 + + FC00:10::1/128 + + + HostIP1 + Loopback4096 + + 192.0.0.2/32 + + 192.0.0.2/32 + + + HostIP1 + Loopback4096 + + 2603:10e2:400::2/128 + + 2603:10e2:400::2/128 + + + + + HostIP + eth0 + + 10.3.147.27/23 + + 10.3.147.27/23 + + + V6HostIP + eth0 + + FC00:2::32/64 + + FC00:2::32/64 + + + + + + Ethernet-IB0 + port + 3.3.3.2/32 + + + Ethernet-IB0 + port + 3333::3:2/128 + + + + + + ASIC0 + + + PortChannel102 + Eth0-ASIC0;Eth8-ASIC0 + + + + PortChannel104 + Eth16-ASIC0;Eth24-ASIC0 + + + + PortChannel106 + Eth32-ASIC0;Eth40-ASIC0 + + + + PortChannel108 + Eth48-ASIC0;Eth56-ASIC0 + + + + PortChannel1010 + Eth64-ASIC0;Eth72-ASIC0 + + + + PortChannel1012 + Eth80-ASIC0;Eth88-ASIC0 + + + + PortChannel1016 + Eth104-ASIC0;Eth112-ASIC0 + + + + PortChannel1020 + Eth128-ASIC0;Eth136-ASIC0 + + + + + + + + PortChannel102 + 10.0.0.0/31 + + + + PortChannel102 + FC00::1/126 + + + + PortChannel104 + 10.0.0.4/31 + + + + PortChannel104 + FC00::9/126 + + + + PortChannel106 + 10.0.0.8/31 + + + + PortChannel106 + FC00::11/126 + + + + PortChannel108 + 10.0.0.12/31 + + + + PortChannel108 + FC00::19/126 + + + + PortChannel1010 + 10.0.0.16/31 + + + + PortChannel1010 + FC00::21/126 + + + + PortChannel1012 + 10.0.0.20/31 + + + + PortChannel1012 + FC00::29/126 + + + + Eth96-ASIC0 + 10.0.0.32/31 + + + + Eth96-ASIC0 + FC00::41/126 + + + + PortChannel1016 + 10.0.0.28/31 + + + + PortChannel1016 + FC00::39/126 + + + + Eth120-ASIC0 + 10.0.0.34/31 + + + + Eth120-ASIC0 + FC00::45/126 + + + + PortChannel1020 + 10.0.0.24/31 + + + + PortChannel1020 + FC00::31/126 + + + + + + SNMP_ACL + SNMP + SNMP + + + ERSPAN + Everflow + Everflow + + + ERSPANV6 + EverflowV6 + EverflowV6 + + + VTY_LINE + ssh-only + SSH + + + PortChannel102;PortChannel104;PortChannel106;PortChannel108;PortChannel1010;PortChannel1012;PortChannel1016;PortChannel1020;Eth0-ASIC0;Eth16-ASIC0;Eth32-ASIC0;Eth48-ASIC0;Eth64-ASIC0;Eth80-ASIC0;Eth96-ASIC0;Eth104-ASIC0;Eth120-ASIC0;Eth128-ASIC0 + DataAcl + DataPlane + + + + + + + + + + DeviceInterfaceLink + ARISTA01T3 + Ethernet1 + str2-sonic-lc5-1 + Ethernet1/1 + 100000 + + + DeviceInterfaceLink + ARISTA01T3 + Ethernet2 + str2-sonic-lc5-1 + Ethernet2/1 + 100000 + + + DeviceInterfaceLink + ARISTA03T3 + Ethernet1 + str2-sonic-lc5-1 + Ethernet3/1 + 100000 + + + DeviceInterfaceLink + ARISTA03T3 + Ethernet2 + str2-sonic-lc5-1 + Ethernet4/1 + 400000 + + + DeviceInterfaceLink + ARISTA05T3 + Ethernet1 + str2-sonic-lc5-1 + Ethernet5/1 + 400000 + + + DeviceInterfaceLink + ARISTA05T3 + Ethernet2 + str2-sonic-lc5-1 + Ethernet6/1 + 400000 + + + DeviceInterfaceLink + ARISTA07T3 + Ethernet1 + str2-sonic-lc5-1 + Ethernet7/1 + 400000 + + + DeviceInterfaceLink + ARISTA07T3 + Ethernet2 + str2-sonic-lc5-1 + Ethernet8/1 + 100000 + + + DeviceInterfaceLink + ARISTA09T3 + Ethernet1 + str2-sonic-lc5-1 + Ethernet9/1 + 100000 + + + DeviceInterfaceLink + ARISTA09T3 + Ethernet2 + str2-sonic-lc5-1 + Ethernet10/1 + 100000 + + + DeviceInterfaceLink + ARISTA11T3 + Ethernet1 + str2-sonic-lc5-1 + Ethernet11/1 + 100000 + + + DeviceInterfaceLink + ARISTA11T3 + Ethernet2 + str2-sonic-lc5-1 + Ethernet12/1 + 100000 + + + DeviceInterfaceLink + ARISTA13T3 + Ethernet1 + str2-sonic-lc5-1 + Ethernet13/1 + 100000 + + + DeviceInterfaceLink + ARISTA15T3 + Ethernet1 + str2-sonic-lc5-1 + Ethernet14/1 + 100000 + + + DeviceInterfaceLink + ARISTA15T3 + Ethernet2 + str2-sonic-lc5-1 + Ethernet15/1 + 100000 + + + DeviceInterfaceLink + ARISTA17T3 + Ethernet1 + str2-sonic-lc5-1 + Ethernet16/1 + 100000 + + + DeviceInterfaceLink + ARISTA18T3 + Ethernet1 + str2-sonic-lc5-1 + Ethernet17/1 + 100000 + + + DeviceInterfaceLink + ARISTA18T3 + Ethernet2 + str2-sonic-lc5-1 + Ethernet18/1 + 100000 + + + DeviceInterfaceLink + ARISTA19T3 + Ethernet1 + str2-sonic-lc5-1 + Ethernet19/1 + 100000 + + + DeviceInterfaceLink + ARISTA20T3 + Ethernet1 + str2-sonic-lc5-1 + Ethernet20/1 + 100000 + + + DeviceInterfaceLink + ARISTA21T3 + Ethernet1 + str2-sonic-lc5-1 + Ethernet21/1 + 100000 + + + DeviceInterfaceLink + ARISTA22T3 + Ethernet1 + str2-sonic-lc5-1 + Ethernet22/1 + 100000 + + + DeviceInterfaceLink + ARISTA23T3 + Ethernet1 + str2-sonic-lc5-1 + Ethernet23/1 + 100000 + + + DeviceInterfaceLink + ARISTA24T3 + Ethernet1 + str2-sonic-lc5-1 + Ethernet24/1 + 100000 + + + DeviceInterfaceLink + ARISTA25T3 + Ethernet1 + str2-sonic-lc5-1 + Ethernet25/1 + 100000 + + + DeviceInterfaceLink + ARISTA26T3 + Ethernet1 + str2-sonic-lc5-1 + Ethernet26/1 + 100000 + + + DeviceInterfaceLink + ARISTA27T3 + Ethernet1 + str2-sonic-lc5-1 + Ethernet27/1 + 100000 + + + DeviceInterfaceLink + ARISTA28T3 + Ethernet1 + str2-sonic-lc5-1 + Ethernet28/1 + 100000 + + + DeviceInterfaceLink + ARISTA29T3 + Ethernet1 + str2-sonic-lc5-1 + Ethernet29/1 + 100000 + + + DeviceInterfaceLink + ARISTA30T3 + Ethernet1 + str2-sonic-lc5-1 + Ethernet30/1 + 100000 + + + DeviceInterfaceLink + ARISTA31T3 + Ethernet1 + str2-sonic-lc5-1 + Ethernet31/1 + 100000 + + + DeviceInterfaceLink + ARISTA32T3 + Ethernet1 + str2-sonic-lc5-1 + Ethernet32/1 + 100000 + + + DeviceInterfaceLink + 400000 + true + ASIC0 + Eth0-ASIC0 + true + str2-sonic-lc5-1 + Ethernet1/1 + true + + + DeviceInterfaceLink + 400000 + true + ASIC0 + Eth8-ASIC0 + true + str2-sonic-lc5-1 + Ethernet2/1 + true + + + DeviceInterfaceLink + 400000 + true + ASIC0 + Eth16-ASIC0 + true + str2-sonic-lc5-1 + Ethernet3/1 + true + + + DeviceInterfaceLink + 400000 + true + ASIC0 + Eth24-ASIC0 + true + str2-sonic-lc5-1 + Ethernet4/1 + true + + + DeviceInterfaceLink + 400000 + true + ASIC0 + Eth32-ASIC0 + true + str2-sonic-lc5-1 + Ethernet5/1 + true + + + DeviceInterfaceLink + 400000 + true + ASIC0 + Eth40-ASIC0 + true + str2-sonic-lc5-1 + Ethernet6/1 + true + + + DeviceInterfaceLink + 400000 + true + ASIC0 + Eth48-ASIC0 + true + str2-sonic-lc5-1 + Ethernet7/1 + true + + + DeviceInterfaceLink + 400000 + true + ASIC0 + Eth56-ASIC0 + true + str2-sonic-lc5-1 + Ethernet8/1 + true + + + DeviceInterfaceLink + 400000 + true + ASIC0 + Eth64-ASIC0 + true + str2-sonic-lc5-1 + Ethernet9/1 + true + + + DeviceInterfaceLink + 400000 + true + ASIC0 + Eth72-ASIC0 + true + str2-sonic-lc5-1 + Ethernet10/1 + true + + + DeviceInterfaceLink + 400000 + true + ASIC0 + Eth80-ASIC0 + true + str2-sonic-lc5-1 + Ethernet11/1 + true + + + DeviceInterfaceLink + 400000 + true + ASIC0 + Eth88-ASIC0 + true + str2-sonic-lc5-1 + Ethernet12/1 + true + + + DeviceInterfaceLink + 400000 + true + ASIC0 + Eth96-ASIC0 + true + str2-sonic-lc5-1 + Ethernet13/1 + true + + + DeviceInterfaceLink + 400000 + true + ASIC0 + Eth104-ASIC0 + true + str2-sonic-lc5-1 + Ethernet14/1 + true + + + DeviceInterfaceLink + 400000 + true + ASIC0 + Eth112-ASIC0 + true + str2-sonic-lc5-1 + Ethernet15/1 + true + + + DeviceInterfaceLink + 400000 + true + ASIC0 + Eth120-ASIC0 + true + str2-sonic-lc5-1 + Ethernet16/1 + true + + + DeviceInterfaceLink + 400000 + true + ASIC0 + Eth128-ASIC0 + true + str2-sonic-lc5-1 + Ethernet17/1 + true + + + DeviceInterfaceLink + 400000 + true + ASIC0 + Eth136-ASIC0 + true + str2-sonic-lc5-1 + Ethernet18/1 + true + + + DeviceInterfaceLink + 400000 + true + ASIC1 + Eth0-ASIC1 + true + str2-sonic-lc5-1 + Ethernet19/1 + true + + + DeviceInterfaceLink + 400000 + true + ASIC1 + Eth8-ASIC1 + true + str2-sonic-lc5-1 + Ethernet20/1 + true + + + DeviceInterfaceLink + 400000 + true + ASIC1 + Eth16-ASIC1 + true + str2-sonic-lc5-1 + Ethernet21/1 + true + + + DeviceInterfaceLink + 400000 + true + ASIC1 + Eth24-ASIC1 + true + str2-sonic-lc5-1 + Ethernet22/1 + true + + + DeviceInterfaceLink + 400000 + true + ASIC1 + Eth32-ASIC1 + true + str2-sonic-lc5-1 + Ethernet23/1 + true + + + DeviceInterfaceLink + 400000 + true + ASIC1 + Eth40-ASIC1 + true + str2-sonic-lc5-1 + Ethernet24/1 + true + + + DeviceInterfaceLink + 400000 + true + ASIC1 + Eth48-ASIC1 + true + str2-sonic-lc5-1 + Ethernet25/1 + true + + + DeviceInterfaceLink + 400000 + true + ASIC1 + Eth56-ASIC1 + true + str2-sonic-lc5-1 + Ethernet26/1 + true + + + DeviceInterfaceLink + 400000 + true + ASIC1 + Eth64-ASIC1 + true + str2-sonic-lc5-1 + Ethernet27/1 + true + + + DeviceInterfaceLink + 400000 + true + ASIC1 + Eth72-ASIC1 + true + str2-sonic-lc5-1 + Ethernet28/1 + true + + + DeviceInterfaceLink + 400000 + true + ASIC1 + Eth80-ASIC1 + true + str2-sonic-lc5-1 + Ethernet29/1 + true + + + DeviceInterfaceLink + 400000 + true + ASIC1 + Eth88-ASIC1 + true + str2-sonic-lc5-1 + Ethernet30/1 + true + + + DeviceInterfaceLink + 400000 + true + ASIC1 + Eth96-ASIC1 + true + str2-sonic-lc5-1 + Ethernet31/1 + true + + + DeviceInterfaceLink + 400000 + true + ASIC1 + Eth104-ASIC1 + true + str2-sonic-lc5-1 + Ethernet32/1 + true + + + DeviceInterfaceLink + 400000 + true + ASIC1 + Eth112-ASIC1 + true + str2-sonic-lc5-1 + Ethernet33/1 + true + + + DeviceInterfaceLink + 400000 + true + ASIC1 + Eth120-ASIC1 + true + str2-sonic-lc5-1 + Ethernet34/1 + true + + + DeviceInterfaceLink + 400000 + true + ASIC1 + Eth128-ASIC1 + true + str2-sonic-lc5-1 + Ethernet35/1 + true + + + DeviceInterfaceLink + 400000 + true + ASIC1 + Eth136-ASIC1 + true + str2-sonic-lc5-1 + Ethernet36/1 + true + + + + + str2-sonic-lc5-1 + Sonic-linecard-masic-hwsku + + 10.3.147.27 + + + + ARISTA05T3 + + 172.16.145.34 + + Arista-VM + + + ARISTA11T3 + + 172.16.145.37 + + Arista-VM + + + ARISTA17T3 + + 172.16.145.40 + + Arista-VM + + + ARISTA21T3 + + 172.16.145.44 + + Arista-VM + + + ARISTA19T3 + + 172.16.145.42 + + Arista-VM + + + ARISTA09T3 + + 172.16.145.36 + + Arista-VM + + + ARISTA20T3 + + 172.16.145.43 + + Arista-VM + + + ARISTA03T3 + + 172.16.145.33 + + Arista-VM + + + ARISTA07T3 + + 172.16.145.35 + + Arista-VM + + + ARISTA01T3 + + 172.16.145.32 + + Arista-VM + + + ARISTA27T3 + + 172.16.145.50 + + Arista-VM + + + ARISTA26T3 + + 172.16.145.49 + + Arista-VM + + + ARISTA32T3 + + 172.16.145.55 + + Arista-VM + + + ARISTA23T3 + + 172.16.145.46 + + Arista-VM + + + ARISTA25T3 + + 172.16.145.48 + + Arista-VM + + + ARISTA24T3 + + 172.16.145.47 + + Arista-VM + + + ARISTA22T3 + + 172.16.145.45 + + Arista-VM + + + ARISTA28T3 + + 172.16.145.51 + + Arista-VM + + + ARISTA30T3 + + 172.16.145.53 + + Arista-VM + + + ARISTA18T3 + + 172.16.145.41 + + Arista-VM + + + ARISTA29T3 + + 172.16.145.52 + + Arista-VM + + + ARISTA15T3 + + 172.16.145.39 + + Arista-VM + + + ARISTA13T3 + + 172.16.145.38 + + Arista-VM + + + ARISTA31T3 + + 172.16.145.54 + + Arista-VM + + + Asic +
+ 0.0.0.0/0 +
+ + ::/0 + + + + + + + + + + 0.0.0.0/0 + + + ::/0 + + + ASIC0 + Broadcom-Trident2 +
+ + Asic +
+ 0.0.0.0/0 +
+ + ::/0 + + + + + + + + + + 0.0.0.0/0 + + + ::/0 + + + ASIC1 + Broadcom-Trident2 +
+
+
+ + + true + + + DeviceInterface + + true + true + 1 + Ethernet1/1 + + false + 0 + 0 + 400000 + + + DeviceInterface + + true + true + 1 + Ethernet2/1 + + false + 0 + 0 + 400000 + + + DeviceInterface + + true + true + 1 + Ethernet3/1 + + false + 0 + 0 + 400000 + + + DeviceInterface + + true + true + 1 + Ethernet4/1 + + false + 0 + 0 + 400000 + + + DeviceInterface + + true + true + 1 + Ethernet5/1 + + false + 0 + 0 + 400000 + + + DeviceInterface + + true + true + 1 + Ethernet6/1 + + false + 0 + 0 + 400000 + + + DeviceInterface + + true + true + 1 + Ethernet7/1 + + false + 0 + 0 + 400000 + + + DeviceInterface + + true + true + 1 + Ethernet8/1 + + false + 0 + 0 + 400000 + + + DeviceInterface + + true + true + 1 + Ethernet9/1 + + false + 0 + 0 + 400000 + + + DeviceInterface + + true + true + 1 + Ethernet10/1 + + false + 0 + 0 + 400000 + + + DeviceInterface + + true + true + 1 + Ethernet11/1 + + false + 0 + 0 + 400000 + + + DeviceInterface + + true + true + 1 + Ethernet12/1 + + false + 0 + 0 + 400000 + + + DeviceInterface + + true + true + 1 + Ethernet13/1 + + false + 0 + 0 + 400000 + + + DeviceInterface + + true + true + 1 + Ethernet14/1 + + false + 0 + 0 + 400000 + + + DeviceInterface + + true + true + 1 + Ethernet15/1 + + false + 0 + 0 + 400000 + + + DeviceInterface + + true + true + 1 + Ethernet16/1 + + false + 0 + 0 + 400000 + + + DeviceInterface + + true + true + 1 + Ethernet17/1 + + false + 0 + 0 + 400000 + + + DeviceInterface + + true + true + 1 + Ethernet18/1 + + false + 0 + 0 + 400000 + + + DeviceInterface + + true + true + 1 + Ethernet19/1 + + false + 0 + 0 + 400000 + + + DeviceInterface + + true + true + 1 + Ethernet20/1 + + false + 0 + 0 + 400000 + + + DeviceInterface + + true + true + 1 + Ethernet21/1 + + false + 0 + 0 + 400000 + + + DeviceInterface + + true + true + 1 + Ethernet22/1 + + false + 0 + 0 + 400000 + + + DeviceInterface + + true + true + 1 + Ethernet23/1 + + false + 0 + 0 + 400000 + + + DeviceInterface + + true + true + 1 + Ethernet24/1 + + false + 0 + 0 + 400000 + + + DeviceInterface + + true + true + 1 + Ethernet25/1 + + false + 0 + 0 + 400000 + + + DeviceInterface + + true + true + 1 + Ethernet26/1 + + false + 0 + 0 + 400000 + + + DeviceInterface + + true + true + 1 + Ethernet27/1 + + false + 0 + 0 + 400000 + + + DeviceInterface + + true + true + 1 + Ethernet28/1 + + false + 0 + 0 + 400000 + + + DeviceInterface + + true + true + 1 + Ethernet29/1 + + false + 0 + 0 + 400000 + + + DeviceInterface + + true + true + 1 + Ethernet30/1 + + false + 0 + 0 + 400000 + + + DeviceInterface + + true + true + 1 + Ethernet31/1 + + false + 0 + 0 + 400000 + + + DeviceInterface + + true + true + 1 + Ethernet32/1 + + false + 0 + 0 + 400000 + + + DeviceInterface + + true + true + 1 + Ethernet33/1 + + false + 0 + 0 + 400000 + + + DeviceInterface + + true + true + 1 + Ethernet34/1 + + false + 0 + 0 + 400000 + + + DeviceInterface + + true + true + 1 + Ethernet35/1 + + false + 0 + 0 + 400000 + + + DeviceInterface + + true + true + 1 + Ethernet36/1 + + false + 0 + 0 + 400000 + + + true + 0 + Sonic-linecard-masic-hwsku + + + + + + + str2-sonic-lc5-1 + + + DeploymentId + + 1 + + + QosProfile + + Profile0 + + + DhcpResources + + 192.0.0.1;192.0.0.2;192.0.0.3;192.0.0.4;192.0.0.5;192.0.0.6;192.0.0.7;192.0.0.8;192.0.0.9;192.0.0.10;192.0.0.11;192.0.0.12;192.0.0.13;192.0.0.14;192.0.0.15;192.0.0.16;192.0.0.17;192.0.0.18;192.0.0.19;192.0.0.20;192.0.0.21;192.0.0.22;192.0.0.23;192.0.0.24;192.0.0.25;192.0.0.26;192.0.0.27;192.0.0.28;192.0.0.29;192.0.0.30;192.0.0.31;192.0.0.32;192.0.0.33;192.0.0.34;192.0.0.35;192.0.0.36;192.0.0.37;192.0.0.38;192.0.0.39;192.0.0.40;192.0.0.41;192.0.0.42;192.0.0.43;192.0.0.44;192.0.0.45;192.0.0.46;192.0.0.47;192.0.0.48 + + + NtpResources + + 10.20.8.129;10.20.8.130 + + + SnmpResources + + 10.3.145.98 + + + SyslogResources + + 10.64.246.95 + + + TacacsGroup + + Starlab + + + TacacsServer + + 100.127.20.21 + + + ForcedMgmtRoutes + + 10.3.145.98/31;10.3.145.8;100.127.20.16/28;10.3.149.170/31;40.122.216.24;13.91.48.226;10.3.145.14;10.64.246.0/24;10.3.146.0/23;10.64.5.5;10.201.148.32/28 + + + ErspanDestinationIpv4 + + 10.20.6.16 + + + SwitchType + + voq + + + MaxCores + + 16 + + + + + ASIC0 + + + SubRole + + FrontEnd + + + SwitchType + + voq + + + SwitchId + + 2 + + + MaxCores + + 16 + + + + + ASIC1 + + + SubRole + + FrontEnd + + + SwitchType + + voq + + + SwitchId + + 4 + + + MaxCores + + 16 + + + + + ASIC1 + + + DeploymentId + + 1 + + + SubRole + + FrontEnd + + + SwitchType + + voq + + + + + ASIC0 + + + DeploymentId + + 1 + + + SubRole + + FrontEnd + + + SwitchType + + voq + + + + + + + str2-sonic-lc5-1 + Sonic-linecard-masic-hwsku +
diff --git a/src/sonic-containercfgd/.gitignore b/src/sonic-containercfgd/.gitignore new file mode 100644 index 000000000000..5ae7a596bfb6 --- /dev/null +++ b/src/sonic-containercfgd/.gitignore @@ -0,0 +1,13 @@ +# Compiled Python files +*.pyc + +# Generated by packaging +*.egg-info/ +.eggs/ +build/ +dist/ + +# Unit test coverage +.coverage +coverage.xml +htmlcov/ diff --git a/src/sonic-containercfgd/containercfgd/__init__.py b/src/sonic-containercfgd/containercfgd/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/src/sonic-containercfgd/containercfgd/containercfgd.py b/src/sonic-containercfgd/containercfgd/containercfgd.py new file mode 100644 index 000000000000..4eda8a6d8b40 --- /dev/null +++ b/src/sonic-containercfgd/containercfgd/containercfgd.py @@ -0,0 +1,198 @@ +import os +import re +import signal +import subprocess +import sys + +from sonic_py_common import daemon_base, logger +from swsscommon.swsscommon import ConfigDBConnector, RestartWaiter + +SYSLOG_IDENTIFIER = "containercfgd" +logger = logger.Logger(SYSLOG_IDENTIFIER) + +# Table names +FEATURE_TABLE = 'FEATURE' +SYSLOG_CONFIG_FEATURE_TABLE = 'SYSLOG_CONFIG_FEATURE' + +# Table field names +SYSLOG_RATE_LIMIT_INTERVAL = 'rate_limit_interval' +SYSLOG_RATE_LIMIT_BURST = 'rate_limit_burst' + +# Container name +container_name = None + + +def run_command(command): + """ + Utility function to run an shell command and return the output. + :param command: Shell command string. + :return: Output of the shell command. + """ + return subprocess.check_output(command, text=True, stderr=subprocess.PIPE) + + +class ContainerConfigDaemon(daemon_base.DaemonBase): + handlers = {} + + def __init__(self): + super(ContainerConfigDaemon, self).__init__(SYSLOG_IDENTIFIER) + + def run(self): + """Register config handlers and listen to CONFIG DB changes + """ + config_db = ConfigDBConnector() + config_db.connect(wait_for_init=True, retry_on=True) + self.log_notice(f'Connected to CONFIG DB') + for table_name, handler in self.handlers.items(): + config_db.subscribe(table_name, handler.handle_config) + config_db.listen(init_data_handler=self.init_data_handler) + + def init_data_handler(self, init_data): + """Handle initial data in CONFIG DB + + Args: + init_data (dict): Initial data when first time connecting to CONFIG DB. {: {: }} + """ + for handler in self.handlers.values(): + handler.handle_init_data(init_data) + + @classmethod + def register_handler(cls, table_name, object_type): + """Register CONFIG DB handler + + Args: + table_name (str): CONFIG DB table name + object_type (class): Class of CONFIG DB handler + """ + cls.handlers[table_name] = object_type() + + def signal_handler(self, sig, frame): + if sig == signal.SIGHUP: + self.log_info("ContainerCfgd: Caught SIGHUP - ignoring...") + elif sig == signal.SIGINT: + self.log_info("ContainerCfgd: Caught SIGINT - exiting...") + sys.exit(128 + sig) + elif sig == signal.SIGTERM: + self.log_info("ContainerCfgd: Caught SIGTERM - exiting...") + sys.exit(128 + sig) + else: + self.log_warning("ContainerCfgd: Caught unhandled signal '{}'".format(sig)) + + +def config_handler(table_name): + """Decorator to register CONFIG DB handler + + Args: + table_name (str): CONFIG DB table name + """ + def wrapper(object_type): + ContainerConfigDaemon.register_handler(table_name, object_type) + return object_type + return wrapper + + +@config_handler(SYSLOG_CONFIG_FEATURE_TABLE) +class SyslogHandler: + # syslog conf file path in docker + SYSLOG_CONF_PATH = '/etc/rsyslog.conf' + # temporary syslog conf file path in docker + TMP_SYSLOG_CONF_PATH = '/tmp/rsyslog.conf' + + # Regular expressions to extract value from rsyslog.conf + INTERVAL_PATTERN = '.*SystemLogRateLimitInterval\s+(\d+).*' + BURST_PATTERN = '.*SystemLogRateLimitBurst\s+(\d+).*' + TARGET_IP_PATTERN = '.*target="(.*?)".*' + + def __init__(self): + self.current_interval, self.current_burst, self.target_ip = self.parse_syslog_conf() + + def handle_config(self, table, key, data): + """Handle CONFIG DB change. Callback by ConfigDBConnector. + + Args: + table (str): CONFIG DB table name + key (str): Key of the changed entry + data (dict): Data of the entry: {: } + """ + try: + if key != container_name: + return + self.update_syslog_config(data) + except Exception as e: + logger.log_error('Failed to config syslog for container {} with data {} - {}'.format(key, data, e)) + + def handle_init_data(self, init_data): + """Handle initial data in CONFIG DB. Callback by ConfigDBConnector. + + Args: + init_data (dict): Initial data when first time connecting to CONFIG DB. {: {: }} + """ + if SYSLOG_CONFIG_FEATURE_TABLE in init_data: + if container_name in init_data[SYSLOG_CONFIG_FEATURE_TABLE]: + self.update_syslog_config(init_data[SYSLOG_CONFIG_FEATURE_TABLE][container_name]) + + def update_syslog_config(self, data): + """Parse existing syslog conf and apply new syslog conf. + + Args: + data (dict): Data of the entry: {: } + """ + new_interval = '0' if not data else data.get(SYSLOG_RATE_LIMIT_INTERVAL, '0') + new_burst = '0' if not data else data.get(SYSLOG_RATE_LIMIT_BURST, '0') + + if new_interval == self.current_interval and new_burst == self.current_burst: + logger.log_notice('Syslog rate limit configuration does not change, ignore it') + return + + logger.log_notice(f'Configure syslog rate limit interval={new_interval}, burst={new_burst}') + + if os.path.exists(self.TMP_SYSLOG_CONF_PATH): + os.remove(self.TMP_SYSLOG_CONF_PATH) + with open(self.TMP_SYSLOG_CONF_PATH, 'w+') as f: + json_args = f'{{"target_ip": "{self.target_ip}", "container_name": "{container_name}" }}' + output = run_command(['sonic-cfggen', '-d', '-t', '/usr/share/sonic/templates/rsyslog-container.conf.j2', '-a', json_args]) + f.write(output) + run_command(['cp', self.TMP_SYSLOG_CONF_PATH, self.SYSLOG_CONF_PATH]) + run_command(['supervisorctl', 'restart', 'rsyslogd']) + self.current_interval = new_interval + self.current_burst = new_burst + + def parse_syslog_conf(self): + """Passe existing syslog conf and extract config values + + Returns: + tuple: interval,burst,target_ip + """ + interval = '0' + burst = '0' + target_ip = None + + with open(self.SYSLOG_CONF_PATH, 'r') as f: + content = f.read() + pattern = re.compile(self.INTERVAL_PATTERN) + for match in pattern.finditer(content): + interval = match.group(1) + break + + pattern = re.compile(self.BURST_PATTERN) + for match in pattern.finditer(content): + burst = match.group(1) + break + + pattern = re.compile(self.TARGET_IP_PATTERN) + for match in pattern.finditer(content): + target_ip = match.group(1) + break + return interval, burst, target_ip + + +def main(): + RestartWaiter.waitAdvancedBootDone() + global container_name + container_name = os.environ['CONTAINER_NAME'] + daemon = ContainerConfigDaemon() + daemon.run() + + +if __name__ == '__main__': + main() diff --git a/src/sonic-containercfgd/pytest.ini b/src/sonic-containercfgd/pytest.ini new file mode 100644 index 000000000000..2fc0931f27a7 --- /dev/null +++ b/src/sonic-containercfgd/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +addopts = --cov=containercfgd --cov-report html --cov-report term --cov-report xml diff --git a/src/sonic-containercfgd/setup.cfg b/src/sonic-containercfgd/setup.cfg new file mode 100644 index 000000000000..b7e478982ccf --- /dev/null +++ b/src/sonic-containercfgd/setup.cfg @@ -0,0 +1,2 @@ +[aliases] +test=pytest diff --git a/src/sonic-containercfgd/setup.py b/src/sonic-containercfgd/setup.py new file mode 100644 index 000000000000..9f60c58135b4 --- /dev/null +++ b/src/sonic-containercfgd/setup.py @@ -0,0 +1,48 @@ +from setuptools import setup + +dependencies = [ + 'sonic_py_common', +] + +setup( + name='sonic-containercfgd', + version='1.0', + description='SONiC container config daemon package', + license='Apache 2.0', + author='SONiC Team', + author_email='linuxnetdev@microsoft.com', + url='https://github.com/Azure/sonic-buildimage', + maintainer='Junchao Chen', + maintainer_email='junchaow@nvidia.com', + install_requires=dependencies, + entry_points={ + 'console_scripts': [ + 'containercfgd = containercfgd.containercfgd:main', + ] + }, + packages=[ + 'containercfgd', + 'tests' + ], + setup_requires=[ + 'pytest-runner' + ], + tests_require=[ + 'pytest', + 'mock>=2.0.0' + ], + classifiers=[ + 'Development Status :: 4 - Beta', + 'Environment :: No Input/Output (Daemon)', + '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 :: System :: Hardware', + ], + keywords='SONiC sonic container config daemon', + test_suite='setup.get_test_suite' +) diff --git a/src/sonic-containercfgd/tests/conftest.py b/src/sonic-containercfgd/tests/conftest.py new file mode 100644 index 000000000000..0ac7be4265bd --- /dev/null +++ b/src/sonic-containercfgd/tests/conftest.py @@ -0,0 +1,7 @@ +import os + + +def init_env(): + # Just make sure there is an environment variable CONTAINER_NAME + # The value of this environment variable is not important + os.environ["CONTAINER_NAME"] = "some_container" diff --git a/src/sonic-containercfgd/tests/mock_empty_rsyslog.conf b/src/sonic-containercfgd/tests/mock_empty_rsyslog.conf new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/src/sonic-containercfgd/tests/mock_rsyslog.conf b/src/sonic-containercfgd/tests/mock_rsyslog.conf new file mode 100644 index 000000000000..68e917b9344c --- /dev/null +++ b/src/sonic-containercfgd/tests/mock_rsyslog.conf @@ -0,0 +1,29 @@ +$ModLoad imuxsock # provides support for local system logging + +# +# Set a rate limit on messages from the container +# + + +$SystemLogRateLimitInterval 50 +$SystemLogRateLimitBurst 10002 + +#$ModLoad imklog # provides kernel logging support +#$ModLoad immark # provides --MARK-- message capability + +# provides UDP syslog reception +#$ModLoad imudp +#$UDPServerRun 514 + +# provides TCP syslog reception +#$ModLoad imtcp +#$InputTCPServerRun 514 + + +########################### +#### GLOBAL DIRECTIVES #### +########################### + +# Set remote syslog server +template (name="ForwardFormatInContainer" type="string" string="<%PRI%>%TIMESTAMP:::date-rfc3339% %HOSTNAME% pmon#%syslogtag%%msg:::sp-if-no-1st-sp%%msg%") +*.* action(type="omfwd" target="127.0.0.1" port="514" protocol="udp" Template="ForwardFormatInContainer") diff --git a/src/sonic-containercfgd/tests/test_config_daemon.py b/src/sonic-containercfgd/tests/test_config_daemon.py new file mode 100644 index 000000000000..3604a32ab2d8 --- /dev/null +++ b/src/sonic-containercfgd/tests/test_config_daemon.py @@ -0,0 +1,54 @@ +import os +import sys +from unittest import mock + +test_path = os.path.dirname(os.path.abspath(__file__)) +modules_path = os.path.dirname(test_path) +sys.path.insert(0, modules_path) + +from containercfgd import containercfgd + + +@containercfgd.config_handler('MockTable') +class MockHandler: + def handle_init_data(self, init_data): + pass + + def handle_config(self, table, key, data): + pass + + +def test_handler_register(): + assert 'MockTable' in containercfgd.ContainerConfigDaemon.handlers + assert isinstance(containercfgd.ContainerConfigDaemon.handlers['MockTable'], MockHandler) + + +def test_init_data_handler(): + mock_handler_cls = mock.MagicMock() + mock_handler_instance = mock.MagicMock() + mock_handler_instance.handle_init_data = mock.MagicMock() + mock_handler_cls.return_value = mock_handler_instance + + containercfgd.ContainerConfigDaemon.register_handler('LoadMock', mock_handler_cls) + daemon = containercfgd.ContainerConfigDaemon() + daemon.init_data_handler({}) + mock_handler_instance.handle_init_data.assert_called_once() + containercfgd.ContainerConfigDaemon.handlers.pop('LoadMock') + + +@mock.patch('containercfgd.containercfgd.ConfigDBConnector') +def test_run(mock_connector): + mock_db = mock.MagicMock() + mock_db.connect = mock.MagicMock() + mock_db.subscribe = mock.MagicMock() + mock_db.listen = mock.MagicMock() + mock_connector.return_value = mock_db + + daemon = containercfgd.ContainerConfigDaemon() + daemon.run() + mock_db.connect.assert_called_once() + expected = [] + for table_name, handler in containercfgd.ContainerConfigDaemon.handlers.items(): + expected.append(mock.call(table_name, handler.handle_config)) + mock_db.subscribe.assert_has_calls(expected, any_order=True) + mock_db.listen.assert_called_once() diff --git a/src/sonic-containercfgd/tests/test_syslog_config.py b/src/sonic-containercfgd/tests/test_syslog_config.py new file mode 100644 index 000000000000..23e5887b9d26 --- /dev/null +++ b/src/sonic-containercfgd/tests/test_syslog_config.py @@ -0,0 +1,81 @@ +import os +import sys +from unittest import mock + +test_path = os.path.dirname(os.path.abspath(__file__)) +modules_path = os.path.dirname(test_path) +sys.path.insert(0, modules_path) + +from containercfgd import containercfgd + +containercfgd.container_name = 'swss' + + +def test_handle_config(): + handler = containercfgd.SyslogHandler() + handler.update_syslog_config = mock.MagicMock() + + handler.handle_config(containercfgd.SYSLOG_CONFIG_FEATURE_TABLE, + 'bgp', + None) + handler.update_syslog_config.assert_not_called() + + handler.handle_config(containercfgd.SYSLOG_CONFIG_FEATURE_TABLE, + 'swss', + None) + handler.update_syslog_config.assert_called_once() + + handler.update_syslog_config.side_effect = Exception('') + handler.handle_config(containercfgd.SYSLOG_CONFIG_FEATURE_TABLE, + 'swss', + None) + + +def test_handle_init_data(): + handler = containercfgd.SyslogHandler() + handler.update_syslog_config = mock.MagicMock() + + init_data = {} + handler.handle_init_data(init_data) + handler.update_syslog_config.assert_not_called() + + init_data = {containercfgd.SYSLOG_CONFIG_FEATURE_TABLE: {}} + handler.handle_init_data(init_data) + handler.update_syslog_config.assert_not_called() + + init_data = {containercfgd.SYSLOG_CONFIG_FEATURE_TABLE: {'swss': {}}} + handler.handle_init_data(init_data) + handler.update_syslog_config.assert_called_once() + + +@mock.patch('containercfgd.containercfgd.run_command') +@mock.patch('containercfgd.containercfgd.SyslogHandler.parse_syslog_conf', mock.MagicMock(return_value=('100', '200', '127.0.0.1'))) +def test_update_syslog_config(mock_run_cmd): + mock_run_cmd.return_value = "" + handler = containercfgd.SyslogHandler() + + data = {containercfgd.SYSLOG_RATE_LIMIT_INTERVAL: '100', + containercfgd.SYSLOG_RATE_LIMIT_BURST: '200'} + handler.update_syslog_config(data) + mock_run_cmd.assert_not_called() + + data = {containercfgd.SYSLOG_RATE_LIMIT_INTERVAL: '200', + containercfgd.SYSLOG_RATE_LIMIT_BURST: '200'} + + handler.update_syslog_config(data) + mock_run_cmd.assert_called() + + +def test_parse_syslog_conf(): + handler = containercfgd.SyslogHandler() + handler.SYSLOG_CONF_PATH = os.path.join(test_path, 'mock_rsyslog.conf') + interval, burst, target_ip = handler.parse_syslog_conf() + assert interval == '50' + assert burst == '10002' + assert target_ip == '127.0.0.1' + + handler.SYSLOG_CONF_PATH = os.path.join(test_path, 'mock_empty_rsyslog.conf') + interval, burst, target_ip = handler.parse_syslog_conf() + assert interval == '0' + assert burst == '0' + assert target_ip is None diff --git a/src/sonic-ctrmgrd/ctrmgr/ctrmgrd.py b/src/sonic-ctrmgrd/ctrmgr/ctrmgrd.py index b6e9249fcb11..84c23f9f0eba 100755 --- a/src/sonic-ctrmgrd/ctrmgr/ctrmgrd.py +++ b/src/sonic-ctrmgrd/ctrmgr/ctrmgrd.py @@ -99,6 +99,8 @@ USE_K8S_PROXY: "" } +ENABLED_FEATURE_SET = {"telemetry", "snmp"} + def log_debug(m): msg = "{}: {}".format(inspect.stack()[1][3], m) syslog.syslog(syslog.LOG_DEBUG, msg) @@ -260,6 +262,8 @@ def run(self): key, op, fvs = subscriber.pop() if not key: continue + if subscriber.getTableName() == FEATURE_TABLE and key not in ENABLED_FEATURE_SET: + continue log_debug("Received message : '%s'" % str((key, op, fvs))) for callback in (self.callbacks [subscriber.getDbConnector().getDbName()] @@ -280,6 +284,8 @@ def set_node_labels(server): labels["sonic_version"] = version_info['build_version'] labels["hwsku"] = device_info.get_hwsku() if not UNIT_TESTING else "mock" labels["deployment_type"] = dep_type + platform = device_info.get_platform() + labels["worker.sonic/platform"] = platform if platform is not None else "" server.mod_db_entry(STATE_DB_NAME, KUBE_LABEL_TABLE, KUBE_LABEL_SET_KEY, labels) diff --git a/src/sonic-dbsyncd b/src/sonic-dbsyncd index 0d67faf36b36..fa8b709dc0df 160000 --- a/src/sonic-dbsyncd +++ b/src/sonic-dbsyncd @@ -1 +1 @@ -Subproject commit 0d67faf36b362be4fb38fdd449b98d67ff867c63 +Subproject commit fa8b709dc0df771341dad0ebc07c0e7f8fd1177c diff --git a/src/sonic-eventd/rsyslog_plugin_tests/rsyslog_plugin_ut.cpp b/src/sonic-eventd/rsyslog_plugin_tests/rsyslog_plugin_ut.cpp index be5a19ad5a5b..00bde81e2d00 100644 --- a/src/sonic-eventd/rsyslog_plugin_tests/rsyslog_plugin_ut.cpp +++ b/src/sonic-eventd/rsyslog_plugin_tests/rsyslog_plugin_ut.cpp @@ -19,6 +19,8 @@ using namespace std; using namespace swss; using json = nlohmann::json; +const string g_stored_year = "2024"; + vector createEventParams(vector params, vector luaCodes) { vector eventParams; for(long unsigned int i = 0; i < params.size(); i++) { @@ -85,13 +87,16 @@ TEST(syslog_parser, matching_regex_timestamp) { event_params_t expectedDict; expectedDict["message"] = "test_message"; expectedDict["other_data"] = "test_data"; - expectedDict["timestamp"] = "2022-07-21T02:10:00.000000Z"; + // Adding stored year to messages as syslog don't contain year + expectedDict["timestamp"] = g_stored_year + "-07-21T02:10:00.000000Z"; unique_ptr parser(new SyslogParser()); parser->m_regexList = regexList; lua_State* luaState = luaL_newstate(); luaL_openlibs(luaState); + parser->m_timestampFormatter->m_storedTimestamp = "010100:00:00.000000"; + parser->m_timestampFormatter->m_storedYear = g_stored_year; bool success = parser->parseMessage("Jul 21 02:10:00.000000 message test_message other_data test_data", tag, paramDict, luaState); EXPECT_EQ(true, success); EXPECT_EQ("test_tag", tag); @@ -186,13 +191,15 @@ TEST(syslog_parser, lua_code_valid_2) { expectedDict["ip"] = "10.10.24.216"; expectedDict["major-code"] = "6"; expectedDict["minor-code"] = "2"; - expectedDict["timestamp"] = "2022-12-03T12:36:24.503424Z"; + expectedDict["timestamp"] = g_stored_year + "-12-03T12:36:24.503424Z"; unique_ptr parser(new SyslogParser()); parser->m_regexList = regexList; lua_State* luaState = luaL_newstate(); luaL_openlibs(luaState); + parser->m_timestampFormatter->m_storedTimestamp = "010100:00:00.000000"; + parser->m_timestampFormatter->m_storedYear = g_stored_year; bool success = parser->parseMessage("Dec 3 12:36:24.503424 NOTIFICATION: received from neighbor 10.10.24.216 active 6/2 (Administrative Shutdown) 0 bytes", tag, paramDict, luaState); EXPECT_EQ(true, success); EXPECT_EQ("test_tag", tag); @@ -253,13 +260,22 @@ TEST(timestampFormatter, changeTimestampFormat) { vector timestampTwo = { "Jan", "1", "00:00:00.000000" }; vector timestampThree = { "Dec", "31", "23:59:59.000000" }; + formatter->m_storedTimestamp = "010100:00:00.000000"; + formatter->m_storedYear = g_stored_year; + string formattedTimestampOne = formatter->changeTimestampFormat(timestampOne); - EXPECT_EQ("2022-07-20T10:09:40.230874Z", formattedTimestampOne); + string expectedTimestampOne = g_stored_year + "-07-20T10:09:40.230874Z"; + + EXPECT_EQ(expectedTimestampOne, formattedTimestampOne); EXPECT_EQ("072010:09:40.230874", formatter->m_storedTimestamp); + formatter->m_storedTimestamp = "010100:00:00.000000"; + formatter->m_storedYear = g_stored_year; + string formattedTimestampTwo = formatter->changeTimestampFormat(timestampTwo); - EXPECT_EQ("2022-01-01T00:00:00.000000Z", formattedTimestampTwo); + string expectedTimestampTwo = g_stored_year + "-01-01T00:00:00.000000Z"; + EXPECT_EQ(expectedTimestampTwo, formattedTimestampTwo); formatter->m_storedTimestamp = "010100:00:00.000000"; formatter->m_storedYear = "2025"; diff --git a/src/sonic-eventd/tools/events_publish_tool.py b/src/sonic-eventd/tools/events_publish_tool.py index df2cbc8012a1..0d659eb78c14 100644 --- a/src/sonic-eventd/tools/events_publish_tool.py +++ b/src/sonic-eventd/tools/events_publish_tool.py @@ -1,4 +1,4 @@ -from swsscommon.swsscommon import events_init_publisher, event_publish, FieldValueMap +from swsscommon.swsscommon import events_init_publisher, events_deinit_publisher, event_publish, FieldValueMap import time import sys import ipaddress @@ -92,6 +92,7 @@ def main(): publishBGPEvents(publisher_handle, args.count, args.pause) else: publishEventsFromFile(publisher_handle, args.file, args.count, args.pause) + events_deinit_publisher(publisher_handle) if __name__ == "__main__": main() diff --git a/src/sonic-gnmi b/src/sonic-gnmi index 81174150846d..50123efb6737 160000 --- a/src/sonic-gnmi +++ b/src/sonic-gnmi @@ -1 +1 @@ -Subproject commit 81174150846d82ff918022d22b14fd927bae01cb +Subproject commit 50123efb6737909c81e5e0797de33ee7101f20f8 diff --git a/src/sonic-host-services b/src/sonic-host-services index 6eac2d3bb254..fe1c2bb4dea6 160000 --- a/src/sonic-host-services +++ b/src/sonic-host-services @@ -1 +1 @@ -Subproject commit 6eac2d3bb25405cd03424ece6ec8a469b7b9844c +Subproject commit fe1c2bb4dea6015dd3ba71513a6fc002d7b68932 diff --git a/src/sonic-linux-kernel b/src/sonic-linux-kernel index 34f26b35839d..cc6924675c68 160000 --- a/src/sonic-linux-kernel +++ b/src/sonic-linux-kernel @@ -1 +1 @@ -Subproject commit 34f26b35839d7c0c09d48176c4ec33197344643c +Subproject commit cc6924675c68ebe5eea14205f9c98dcf1f76ae48 diff --git a/src/sonic-mgmt-common b/src/sonic-mgmt-common index ec326905356c..68e03410b936 160000 --- a/src/sonic-mgmt-common +++ b/src/sonic-mgmt-common @@ -1 +1 @@ -Subproject commit ec326905356c59aed51c6f6516db5a1b5d8516d6 +Subproject commit 68e03410b936e814034795be85a78e1991d329f3 diff --git a/src/sonic-platform-common b/src/sonic-platform-common index aa86083707c8..a4ea689ae57a 160000 --- a/src/sonic-platform-common +++ b/src/sonic-platform-common @@ -1 +1 @@ -Subproject commit aa86083707c8f6eff24e02df1e5f2198259a8086 +Subproject commit a4ea689ae57a3c5e29d83f39d3774dd38621478f diff --git a/src/sonic-platform-daemons b/src/sonic-platform-daemons index 7c0a326e1dcd..6fb7265ae233 160000 --- a/src/sonic-platform-daemons +++ b/src/sonic-platform-daemons @@ -1 +1 @@ -Subproject commit 7c0a326e1dcd2be74a80f6d3a2d7c4af084c2035 +Subproject commit 6fb7265ae233ba6129e89fd244634cd6de7e5e51 diff --git a/src/sonic-py-common/setup.py b/src/sonic-py-common/setup.py index 144cf61f52c4..f0e97ed84c06 100644 --- a/src/sonic-py-common/setup.py +++ b/src/sonic-py-common/setup.py @@ -3,6 +3,7 @@ dependencies = [ 'natsort==6.2.1', # 6.2.1 is the last version which supports Python 2 'pyyaml', + 'redis-dump-load', ] setup( 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 48a7e76e2f81..e2f2271e7f72 100644 --- a/src/sonic-py-common/sonic_py_common/device_info.py +++ b/src/sonic-py-common/sonic_py_common/device_info.py @@ -647,9 +647,10 @@ def get_system_mac(namespace=None): # Align last byte of MAC if necessary if version_info and version_info['asic_type'] == 'centec': - last_byte = mac[-2:] - aligned_last_byte = format(int(int(last_byte, 16) + 1), '02x') - mac = mac[:-2] + aligned_last_byte + mac_tmp = mac.replace(':','') + mac_tmp = "{:012x}".format(int(mac_tmp, 16) + 1) + mac_tmp = re.sub("(.{2})", "\\1:", mac_tmp, 0, re.DOTALL) + mac = mac_tmp[:-1] return mac @@ -698,14 +699,16 @@ def is_warm_restart_enabled(container_name): # Check if System fast reboot is enabled. def is_fast_reboot_enabled(): - fb_system_state = 0 - cmd = ['sonic-db-cli', 'STATE_DB', 'get', "FAST_REBOOT|system"] - proc = subprocess.Popen(cmd, universal_newlines=True, stdout=subprocess.PIPE) - (stdout, stderr) = proc.communicate() - - if proc.returncode != 0: - log.log_error("Error running command '{}'".format(cmd)) - elif stdout: - fb_system_state = stdout.rstrip('\n') + state_db = SonicV2Connector(host='127.0.0.1') + state_db.connect(state_db.STATE_DB, False) + + TABLE_NAME_SEPARATOR = '|' + prefix = 'FAST_RESTART_ENABLE_TABLE' + TABLE_NAME_SEPARATOR + + # Get the system warm reboot enable state + _hash = '{}{}'.format(prefix, 'system') + fb_system_state = state_db.get(state_db.STATE_DB, _hash, "enable") + fb_enable_state = True if fb_system_state == "true" else False - return fb_system_state + state_db.close(state_db.STATE_DB) + return fb_enable_state diff --git a/src/sonic-py-swsssdk b/src/sonic-py-swsssdk index 7f008a1ca68d..d3584fcec306 160000 --- a/src/sonic-py-swsssdk +++ b/src/sonic-py-swsssdk @@ -1 +1 @@ -Subproject commit 7f008a1ca68db2dfd69ab05c870465c15360e100 +Subproject commit d3584fcec306a7b56d2c4ee02f7527c1044f298c diff --git a/src/sonic-restapi b/src/sonic-restapi index dac446feb2be..4f6f979a5b5a 160000 --- a/src/sonic-restapi +++ b/src/sonic-restapi @@ -1 +1 @@ -Subproject commit dac446feb2be3aa348f633a4d2e3c64993d7483a +Subproject commit 4f6f979a5b5ac833b4279c73ed6c91c762d904c4 diff --git a/src/sonic-sairedis b/src/sonic-sairedis index b7c85caa547c..62aa2448328f 160000 --- a/src/sonic-sairedis +++ b/src/sonic-sairedis @@ -1 +1 @@ -Subproject commit b7c85caa547c8ef81c58bd0ed6ae80ade4ebe425 +Subproject commit 62aa2448328f50815336561e141d076cf03d4087 diff --git a/src/sonic-swss b/src/sonic-swss index 81f4ea994fb3..03238b3bb4c5 160000 --- a/src/sonic-swss +++ b/src/sonic-swss @@ -1 +1 @@ -Subproject commit 81f4ea994fb3b440709f2db3c50c257148fe5e9e +Subproject commit 03238b3bb4c52d99db3349960398bcab4dfe83e5 diff --git a/src/sonic-swss-common b/src/sonic-swss-common index 545e7da1776a..d1916b86e3a5 160000 --- a/src/sonic-swss-common +++ b/src/sonic-swss-common @@ -1 +1 @@ -Subproject commit 545e7da1776a3effabe4c9abc400621c6c76462e +Subproject commit d1916b86e3a5695b47664f7c3496e2847a250b6c diff --git a/src/sonic-utilities b/src/sonic-utilities index d5a6da31ef94..4183785ac0b1 160000 --- a/src/sonic-utilities +++ b/src/sonic-utilities @@ -1 +1 @@ -Subproject commit d5a6da31ef94e350c2cb66c3c981145524d7de6f +Subproject commit 4183785ac0b18fa06fcb4d969486b9a15551a42c diff --git a/src/sonic-yang-mgmt/tests/test_cfghelp.py b/src/sonic-yang-mgmt/tests/test_cfghelp.py index 5867c78e5282..2eebebe7be3b 100644 --- a/src/sonic-yang-mgmt/tests/test_cfghelp.py +++ b/src/sonic-yang-mgmt/tests/test_cfghelp.py @@ -71,17 +71,17 @@ """ -portchannel_table_field_output="""\ +vlan_table_field_output="""\ -PORTCHANNEL -Description: PORTCHANNEL part of config_db.json +VLAN +Description: VLAN part of config_db.json key - name -+---------+-------------------------------------------+-------------+-----------+-------------+ -| Field | Description | Mandatory | Default | Reference | -+=========+===========================================+=============+===========+=============+ -| members | The field contains list of unique members | | | PORT:name | -+---------+-------------------------------------------+-------------+-----------+-------------+ ++--------------+------------------------------------------------------------------------+-------------+-----------+-------------+ +| Field | Description | Mandatory | Default | Reference | ++==============+========================================================================+=============+===========+=============+ +| dhcp_servers | The field contains list of unique membersConfigure the dhcp v4 servers | | | | ++--------------+------------------------------------------------------------------------+-------------+-----------+-------------+ """ @@ -153,9 +153,9 @@ def test_single_field(self): self.assertEqual(output, techsupport_table_field_output) def test_leaf_list(self): - argument = ['-t', 'PORTCHANNEL', '-f', 'members'] + argument = ['-t', 'VLAN', '-f', 'dhcp_servers'] output = self.run_script(argument) - self.assertEqual(output, portchannel_table_field_output) + self.assertEqual(output, vlan_table_field_output) def test_leaf_list_map(self): argument = ['-t', 'DSCP_TO_TC_MAP'] diff --git a/src/sonic-yang-models/doc/Configuration.md b/src/sonic-yang-models/doc/Configuration.md index ba51e8e1aa1b..84503f45ec1d 100644 --- a/src/sonic-yang-models/doc/Configuration.md +++ b/src/sonic-yang-models/doc/Configuration.md @@ -24,7 +24,8 @@ Table of Contents * [Data Plane L3 Interfaces](#data-plane-l3-interfaces) * [DEFAULT_LOSSLESS_BUFFER_PARAMETER](#DEFAULT_LOSSLESS_BUFFER_PARAMETER) * [Device Metadata](#device-metadata) - * [Device neighbor metada](#device-neighbor-metada) + * [Device neighbor metada](#device-neighbor-metada) + * [DHCP_RELAY](#dhcp_relay) * [DSCP_TO_TC_MAP](#dscp_to_tc_map) * [FLEX_COUNTER_TABLE](#flex_counter_table) * [KDUMP](#kdump) @@ -47,6 +48,8 @@ Table of Contents * [Scheduler](#scheduler) * [Port QoS Map](#port-qos-map) * [Queue](#queue) + * [Syslog Rate Limit](#syslog-rate-limit) + * [Sflow](#sflow) * [Restapi](#restapi) * [Tacplus Server](#tacplus-server) * [TC to Priority group map](#tc-to-priority-group-map) @@ -54,9 +57,9 @@ Table of Contents * [Telemetry](#telemetry) * [Versions](#versions) * [VLAN](#vlan) - * [VLAN_MEMBER](#vlan_member) - * [VOQ Inband Interface](#voq-inband-interface) - * [VXLAN](#vxlan) + * [VLAN_MEMBER](#vlan_member) + * [VOQ Inband Interface](#voq-inband-interface) + * [VXLAN](#vxlan) * [Virtual router](#virtual-router) * [LOGGER](#logger) * [WRED_PROFILE](#wred_profile) @@ -65,11 +68,11 @@ Table of Contents * [For Developers](#for-developers) * [Generating Application Config by Jinja2 Template](#generating-application-config-by-jinja2-template) * [Incremental Configuration by Subscribing to ConfigDB](#incremental-configuration-by-subscribing-to-configdb) + - -# Introduction -This document lists the configuration commands schema applied in the SONiC eco system. All these commands find relevance in collecting system information, analysis and even for trouble shooting. All the commands are categorized under relevant topics with corresponding examples. +# Introduction +This document lists the configuration commands schema applied in the SONiC eco system. All these commands find relevance in collecting system information, analysis and even for trouble shooting. All the commands are categorized under relevant topics with corresponding examples. # Configuration @@ -107,7 +110,7 @@ However, this feature is not implemented by all applications yet. By Sep is BGP (docker-fpm-quagga). For other applications, a manual restart is required after configuration changes in ConfigDB. -# **Redis and Json Schema** +# **Redis and Json Schema** ConfigDB uses a table-object schema that is similar with [AppDB](https://github.com/Azure/sonic-swss/blob/4c56d23b9ff4940bdf576cf7c9e5aa77adcbbdcc/doc/swss-schema.md), @@ -343,11 +346,11 @@ and migration plan } } ``` -### BGP Device Global +### BGP Device Global -The **BGP_DEVICE_GLOBAL** table contains device-level BGP global state. -It has a STATE object containing device state like **tsa_enabled** -which is set to true if device is currently isolated using +The **BGP_DEVICE_GLOBAL** table contains device-level BGP global state. +It has a STATE object containing device state like **tsa_enabled** +which is set to true if device is currently isolated using traffic-shift-away (TSA) route-maps in BGP ``` @@ -379,17 +382,17 @@ group name and IP ranges in **BGP_PEER_RANGE** table. "asn": 64009, "name": "ARISTA09T0" }, - + "10.0.0.63": { - "rrclient": "0", - "name": "ARISTA04T1", - "local_addr": "10.0.0.62", - "nhopself": "0", - "holdtime": "10", - "asn": "64600", + "rrclient": "0", + "name": "ARISTA04T1", + "local_addr": "10.0.0.62", + "nhopself": "0", + "holdtime": "10", + "asn": "64600", "keepalive": "3" } - + "BGP_PEER_RANGE": { "BGPSLBPassive": { "name": "BGPSLBPassive", @@ -573,7 +576,7 @@ This kind of profiles will be handled by buffer manager and won't be applied to } } } - + ``` ### Buffer port ingress profile list @@ -651,7 +654,7 @@ This kind of profiles will be handled by buffer manager and won't be applied to "queue": "0", "red_action": "drop" }, - + "trap.group.arp": { "cbs": "600", "cir": "600", @@ -663,21 +666,21 @@ This kind of profiles will be handled by buffer manager and won't be applied to "trap_ids": "arp_req,arp_resp,neigh_discovery", "trap_priority": "4" }, - + "trap.group.lldp.dhcp.udld": { "queue": "4", "trap_action": "trap", "trap_ids": "lldp,dhcp,udld", "trap_priority": "4" }, - + "trap.group.bgp.lacp": { "queue": "4", "trap_action": "trap", "trap_ids": "bgp,bgpv6,lacp", "trap_priority": "4" }, - + "trap.group.ip2me": { "cbs": "600", "cir": "600", @@ -863,6 +866,22 @@ instance is supported in SONiC. ``` +### DHCP_RELAY + +``` +{ +"DHCP_RELAY": { + "dhcpv6_servers": [ + "fc02:2000::1", + "fc02:2000::2", + "fc02:2000::3", + "fc02:2000::4" + ], + "rfc6939_support": "true", + "interface_id": "true" +} + +``` ### DSCP_TO_TC_MAP ``` @@ -909,17 +928,24 @@ instance is supported in SONiC. ``` { -"FLEX_COUNTER_TABLE": { - "PFCWD": { - "FLEX_COUNTER_STATUS": "enable" - }, - "PORT": { - "FLEX_COUNTER_STATUS": "enable" - }, - "QUEUE": { - "FLEX_COUNTER_STATUS": "enable" - } - } + "FLEX_COUNTER_TABLE": { + "PFCWD": { + "FLEX_COUNTER_STATUS": "enable", + "POLL_INTERVAL": "10000" + }, + "PORT": { + "FLEX_COUNTER_STATUS": "enable", + "POLL_INTERVAL": "1000" + }, + "QUEUE": { + "FLEX_COUNTER_STATUS": "enable", + "POLL_INTERVAL": "10000" + }, + "TUNNEL": { + "FLEX_COUNTER_STATUS": "enable", + "POLL_INTERVAL": "10000" + } + } } ``` @@ -1083,7 +1109,7 @@ instead of data network. } } } - + ``` @@ -1119,7 +1145,7 @@ instead of data network. ``` ### MUX_CABLE -The **MUX_CABLE** table is used for dualtor interface configuration. The `cable_type` and `soc_ipv4` objects are optional. +The **MUX_CABLE** table is used for dualtor interface configuration. The `cable_type` and `soc_ipv4` objects are optional. ``` { @@ -1162,7 +1188,7 @@ This option **has no effect** if the mgmt vrf is not enabled. ***NTP Source Port*** -This option sets the port which ntp will choose to send time update requests from by. +This option sets the port which ntp will choose to send time update requests from by. NOTE: If a Loopback interface is defined on the switch ntp will choose this by default, so this setting is **required** if the switch has a Loopback interface and the ntp peer does not have defined routes @@ -1232,7 +1258,7 @@ attributes in those objects. ### Peer Switch -Below is an exmaple of the peer switch table configuration. +Below is an exmaple of the peer switch table configuration. ``` { "PEER_SWITCH": { @@ -1332,6 +1358,33 @@ optional attributes. } } +2x100G port breakout +{ +"PORT": { + "Ethernet0": { + "admin_status": "up", + "index": "1", + "lanes": "101,102,103,104", + "description": "etp1a", + "mtu": "9100", + "alias": "etp1a", + "speed": "100000", + "channel": 1 + }, + "Ethernet4": { + "admin_status": "up", + "index": "1", + "lanes": "105,106,107,108", + "description": "etp1b", + "mtu": "9100", + "alias": "etp1b", + "speed": "100000", + "channel": 2 + }, + } +} + + ``` ### Port Channel @@ -1356,7 +1409,9 @@ name as object key and member list as attribute. "members": [ "Ethernet56" ], - "mtu": "9100" + "mtu": "9100", + "fallback": "false", + "fast_rate": "true" } } } @@ -1368,9 +1423,9 @@ name as object key and member list as attribute. ``` { "PORTCHANNEL_MEMBER": { - "PortChannel0001|Ethernet50": {}, - "PortChannel0002|Ethernet52": {}, - "PortChannel0003|Ethernet54": {}, + "PortChannel0001|Ethernet50": {}, + "PortChannel0002|Ethernet52": {}, + "PortChannel0003|Ethernet54": {}, "PortChannel0004|Ethernet56": {} } } @@ -1406,17 +1461,17 @@ name as object key and member list as attribute. { "PORT_QOS_MAP": { "Ethernet50,Ethernet52,Ethernet54,Ethernet56": { - "tc_to_pg_map": "AZURE", - "tc_to_queue_map": "AZURE", - "pfc_enable": "3,4", - "pfc_to_queue_map": "AZURE", + "tc_to_pg_map": "AZURE", + "tc_to_queue_map": "AZURE", + "pfc_enable": "3,4", + "pfc_to_queue_map": "AZURE", "dscp_to_tc_map": "AZURE", "dscp_to_fc_map": "AZURE", "exp_to_fc_map": "AZURE", "scheduler": "scheduler.port" } } -} +} ``` ### Queue @@ -1424,12 +1479,12 @@ name as object key and member list as attribute. { "QUEUE": { "Ethernet56|4": { - "wred_profile": "AZURE_LOSSLESS", + "wred_profile": "AZURE_LOSSLESS", "scheduler": "scheduler.1" - }, + }, "Ethernet56|5": { "scheduler": "scheduler.0" - }, + }, "Ethernet56|6": { "scheduler": "scheduler.0" } @@ -1454,6 +1509,68 @@ name as object key and member list as attribute. } } ``` +### Sflow + +The below are the tables and their schema for SFLOW feature + +SFLOW + +| Field | Description | Mandatory | Default | Reference | +|------------------|-----------------------------------------------------------------------------------------|-------------|-----------|-------------------------------------------| +| admin_state | Global sflow admin state | | down | | +| polling_interval | The interval within which sFlow data is collected and sent to the configured collectors | | 20 | | +| agent_id | Interface name | | | PORT:name,PORTCHANNEL:name,MGMT_PORT:name, VLAN:name | + +SFLOW_SESSION + +key - port +| Field | Description | Mandatory | Default | Reference | +|-------------|-------------------------------------------------------------------------------------------------------------------------|-------------|-----------|-------------| +| port | Sets sflow session table attributes for either all interfaces or a specific Ethernet interface. | | | PORT:name | +| admin_state | Per port sflow admin state | | up | | +| sample_rate | Sets the packet sampling rate. The rate is expressed as an integer N, where the intended sampling rate is 1/N packets. | | | | + +SFLOW_COLLECTOR + +key - name +| Field | Description | Mandatory | Default | Reference | +|----------------|-----------------------------------------------------------------------------------------|-------------|-----------|-------------| +| name | Name of the Sflow collector | | | | +| collector_ip | IPv4/IPv6 address of the Sflow collector | true | | | +| collector_port | Destination L4 port of the Sflow collector | | 6343 | | +| collector_vrf | Specify the Collector VRF. In this revision, it is either default VRF or Management VRF.| | | | + +### Syslog Rate Limit + +Host side configuration: + +``` +{ +"SYSLOG_CONFIG": { + "GLOBAL": { + "rate_limit_interval": "300", + "rate_limit_burst": "20000" + } + } +} +``` + +Container side configuration: + +``` +{ +"SYSLOG_CONFIG_FEATURE": { + "bgp": { + "rate_limit_interval": "300", + "rate_limit_burst": "20000" + }, + "pmon": { + "rate_limit_interval": "300", + "rate_limit_burst": "20000" + } + } +} +``` ### Tacplus Server @@ -1461,11 +1578,11 @@ name as object key and member list as attribute. { "TACPLUS_SERVER": { "10.0.0.8": { - "priority": "1", + "priority": "1", "tcp_port": "49" - }, + }, "10.0.0.9": { - "priority": "1", + "priority": "1", "tcp_port": "49" } } @@ -1479,17 +1596,17 @@ name as object key and member list as attribute. { "TC_TO_PRIORITY_GROUP_MAP": { "AZURE": { - "1": "1", - "0": "0", - "3": "3", - "2": "2", - "5": "5", - "4": "4", - "7": "7", + "1": "1", + "0": "0", + "3": "3", + "2": "2", + "5": "5", + "4": "4", + "7": "7", "6": "6" } } -} +} ``` ### TC to Queue map @@ -1498,17 +1615,17 @@ name as object key and member list as attribute. { "TC_TO_QUEUE_MAP": { "AZURE": { - "1": "1", - "0": "0", - "3": "3", - "2": "2", - "5": "5", - "4": "4", - "7": "7", + "1": "1", + "0": "0", + "3": "3", + "2": "2", + "5": "5", + "4": "4", + "7": "7", "6": "6" } } -} +} ``` ### Telemetry @@ -1610,8 +1727,8 @@ VOQ_INBAND_INTERFACE holds the name of the inband system port dedicated for cpu ### VXLAN -VXLAN_TUNNEL holds the VTEP source ip configuration. -VXLAN_TUNNEL_MAP holds the vlan to vni and vni to vlan mapping configuration. +VXLAN_TUNNEL holds the VTEP source ip configuration. +VXLAN_TUNNEL_MAP holds the vlan to vni and vni to vlan mapping configuration. VXLAN_EVPN_NVO holds the VXLAN_TUNNEL object to be used for BGP-EVPN discovered tunnels. ``` @@ -1657,6 +1774,7 @@ table allow to change properties of a virtual router. Attributes: packets with IP options - 'l3_mc_action' contains packet action. Defines the action for unknown L3 multicast packets +- 'vni' contains L3 VNI value. VNI associated Virtual router instance. The packet action could be: @@ -1678,7 +1796,8 @@ The packet action could be: 'src_mac': '02:04:05:06:07:08', 'ttl_action': 'copy', 'ip_opt_action': 'deny', - 'l3_mc_action': 'drop' + 'l3_mc_action': 'drop', + 'vni': '100' } ``` @@ -1689,18 +1808,18 @@ The packet action could be: { "WRED_PROFILE": { "AZURE_LOSSLESS": { - "red_max_threshold": "2097152", - "wred_green_enable": "true", - "ecn": "ecn_all", - "green_min_threshold": "1048576", - "red_min_threshold": "1048576", - "wred_yellow_enable": "true", - "yellow_min_threshold": "1048576", - "green_max_threshold": "2097152", - "green_drop_probability": "5", - "yellow_max_threshold": "2097152", - "wred_red_enable": "true", - "yellow_drop_probability": "5", + "red_max_threshold": "2097152", + "wred_green_enable": "true", + "ecn": "ecn_all", + "green_min_threshold": "1048576", + "red_min_threshold": "1048576", + "wred_yellow_enable": "true", + "yellow_min_threshold": "1048576", + "green_max_threshold": "2097152", + "green_drop_probability": "5", + "yellow_max_threshold": "2097152", + "wred_red_enable": "true", + "yellow_drop_probability": "5", "red_drop_probability": "5" } } diff --git a/src/sonic-yang-models/tests/files/sample_config_db.json b/src/sonic-yang-models/tests/files/sample_config_db.json index 1c3531787ffc..11655c5ecf5c 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -2,6 +2,7 @@ "SAMPLE_CONFIG_DB_JSON": { "VRF": { "Vrf_blue": { + "vni" : "100" } }, "DHCP_SERVER": { @@ -81,9 +82,6 @@ "PortChannel0003": { "admin_status": "up", "min_links": "1", - "members": [ - "Ethernet1" - ], "tpid": "0x8100", "mtu": "9100", "lacp_key": "auto" @@ -91,9 +89,6 @@ "PortChannel0004": { "admin_status": "up", "min_links": "1", - "members": [ - "Ethernet2" - ], "tpid": "0x9200", "mtu": "9100", "lacp_key": "auto" @@ -101,22 +96,17 @@ "PortChannel2": { "admin_status": "up", "min_links": "1", - "members": [ - "Ethernet12" - ], "tpid": "0x9200", "mtu": "9100", "lacp_key": "auto" }, "PortChannel42": { "admin_status": "up", - "members": [ - "Ethernet-BP0", - "Ethernet-BP4" - ], "min_links": "2", "mtu": "9100", - "tpid": "0x8100" + "tpid": "0x8100", + "fast_rate": "false", + "fallback" : "true" } }, "PORTCHANNEL_INTERFACE": { @@ -473,6 +463,22 @@ "vrf": "Vrf_blue" } }, + "SYSLOG_CONFIG" : { + "GLOBAL": { + "rate_limit_interval": "5", + "rate_limit_burst": "100" + } + }, + "SYSLOG_CONFIG_FEATURE" : { + "swss": { + "rate_limit_interval": "5", + "rate_limit_burst": "100" + }, + "bgp": { + "rate_limit_interval": "10", + "rate_limit_burst": "200" + } + }, "CABLE_LENGTH": { "AZURE": { "Ethernet0": "5m", @@ -518,7 +524,8 @@ "admin_status": "up", "autoneg": "on", "adv_speeds": "all", - "adv_interface_types": "all" + "adv_interface_types": "all", + "channel" : "0" }, "Ethernet3": { "alias": "Eth1/4", @@ -526,7 +533,8 @@ "description": "", "speed": "11100", "tpid": "0x88A8", - "admin_status": "up" + "admin_status": "up", + "channel": "1" }, "Ethernet4": { "alias": "Eth2/1", @@ -534,7 +542,8 @@ "description": "", "speed": "11100", "tpid": "0x9100", - "admin_status": "up" + "admin_status": "up", + "channel": "2" }, "Ethernet5": { "alias": "Eth2/2", @@ -542,7 +551,8 @@ "description": "", "speed": "11100", "tpid": "0x9200", - "admin_status": "up" + "admin_status": "up", + "channel": "3" }, "Ethernet6": { "alias": "Eth2/3", @@ -550,7 +560,8 @@ "description": "", "speed": "11100", "tpid": "0x8100", - "admin_status": "up" + "admin_status": "up", + "channel": "4" }, "Ethernet7": { "alias": "Eth2/4", @@ -558,7 +569,8 @@ "description": "", "speed": "11100", "tpid": "0x8100", - "admin_status": "up" + "admin_status": "up", + "channel": "5" }, "Ethernet8": { "alias": "Eth3/1", @@ -566,7 +578,8 @@ "description": "", "speed": "11100", "tpid": "0x8100", - "admin_status": "up" + "admin_status": "up", + "channel": "6" }, "Ethernet9": { "alias": "Eth3/2", @@ -574,7 +587,8 @@ "description": "", "speed": "11100", "tpid": "0x8100", - "admin_status": "up" + "admin_status": "up", + "channel": "7" }, "Ethernet10": { "alias": "Eth3/3", @@ -582,7 +596,8 @@ "description": "", "speed": "11100", "tpid": "0x8100", - "admin_status": "up" + "admin_status": "up", + "channel": "8" }, "Ethernet11": { "alias": "Eth3/4", @@ -1187,6 +1202,10 @@ "FLOW_CNT_ROUTE": { "FLEX_COUNTER_STATUS": "enable", "POLL_INTERVAL": "10000" + }, + "TUNNEL": { + "FLEX_COUNTER_STATUS": "enable", + "POLL_INTERVAL": "10000" } }, "FLOW_COUNTER_ROUTE_PATTERN": { @@ -1257,7 +1276,8 @@ "collector_port": "6343" }, "collector2": { - "collector_ip": "10.144.1.2" + "collector_ip": "10.144.1.2", + "collector_vrf": "mgmt" } }, @@ -1529,7 +1549,8 @@ "high_mem_alert": "disabled", "state": "enabled", "set_owner": "local", - "check_up_status": "False" + "check_up_status": "False", + "support_syslog_rate_limit": "True" }, "database": { "auto_restart": "always_enabled", @@ -1539,7 +1560,8 @@ "high_mem_alert": "disabled", "state": "always_enabled", "set_owner": "local", - "check_up_status": "false" + "check_up_status": "false", + "support_syslog_rate_limit": "True" }, "snmp": { "auto_restart": "enabled", @@ -1549,7 +1571,8 @@ "high_mem_alert": "disabled", "state": "enabled", "set_owner": "kube", - "check_up_status": "true" + "check_up_status": "true", + "support_syslog_rate_limit": "True" }, "swss": { "auto_restart": "enabled", @@ -1559,7 +1582,8 @@ "high_mem_alert": "disabled", "state": "enabled", "set_owner": "local", - "check_up_status": "false" + "check_up_status": "false", + "support_syslog_rate_limit": "True" }, "syncd": { "auto_restart": "enabled", @@ -1569,7 +1593,8 @@ "high_mem_alert": "disabled", "state": "enabled", "set_owner": "local", - "check_up_status": "false" + "check_up_status": "false", + "support_syslog_rate_limit": "True" }, "lldp": { "auto_restart": "enabled", @@ -1579,7 +1604,8 @@ "high_mem_alert": "disabled", "state": "enabled", "set_owner": "kube", - "check_up_status": "false" + "check_up_status": "false", + "support_syslog_rate_limit": "True" }, "dhcp_relay": { "auto_restart": "enabled", @@ -1589,7 +1615,8 @@ "high_mem_alert": "disabled", "state": "{% if not (DEVICE_METADATA is defined and DEVICE_METADATA['localhost'] is defined and DEVICE_METADATA['localhost']['type'] is defined and DEVICE_METADATA['localhost']['type'] != 'ToRRouter') %}enabled{% else %}disabled{% endif %}", "set_owner": "kube", - "check_up_status": "true" + "check_up_status": "true", + "support_syslog_rate_limit": "True" } }, "DHCP_RELAY": { @@ -1597,13 +1624,15 @@ "dhcpv6_servers": [ "2a04:5555:41::11" ], - "rfc6939_support": "true" + "rfc6939_support": "true", + "interface_id": "true" }, "Vlan777": { "dhcpv6_servers": [ "2a04:5555:41::11" ], - "rfc6939_support": "true" + "rfc6939_support": "true", + "interface_id": "true" } }, "SCHEDULER": { @@ -2037,6 +2066,10 @@ "SYSTEM_DEFAULTS": { "tunnel_qos_remap": { "status": "enabled" + }, + "mux_tunnel_egress_acl": + { + "status": "enabled" } }, "LOSSLESS_TRAFFIC_PATTERN": { diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/dhcpv6_relay.json b/src/sonic-yang-models/tests/yang_model_tests/tests/dhcpv6_relay.json index 318a5eb7682b..fb05271f99b4 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/dhcpv6_relay.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/dhcpv6_relay.json @@ -5,5 +5,9 @@ }, "DHCPV6_SERVER_VALID_FORMAT": { "desc": "Add dhcpv6_server in correct format." + }, + "DHCPv6_OPTION_WITH_INVALID_BOOLEAN_TYPE": { + "desc": "Add dhcpv6 option with invalid option boolean types.", + "eStrKey": "Pattern" } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/port.json b/src/sonic-yang-models/tests/yang_model_tests/tests/port.json index 6f7af54c4ad8..e02df9d54d7a 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/port.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/port.json @@ -120,6 +120,13 @@ "PORT_INVALID_MULTIASIC_TEST": { "desc": "PORT_INVALID_MULTIASIC_TEST invalid role pattern, expect fail", "eStrKey": "Pattern" + }, + "PORT_VALID_CHANNEL_NUMBER": { + "desc": "PORT_VALID_CHANNEL_NUMBER no failure." + }, + "PORT_INVALID_CHANNEL_NUMBER": { + "desc": "Out of range channel number", + "eStrKey": "Range", + "eStr": "0..8" } - } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/portchannel.json b/src/sonic-yang-models/tests/yang_model_tests/tests/portchannel.json index e69074bdfbf6..ae7a7dffd928 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/portchannel.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/portchannel.json @@ -19,6 +19,16 @@ "eStrKey" : "Pattern", "eStr": ["0x8100|0x9100|0x9200|0x88a8|0x88A8"] }, + "PORT_CHANNEL_INVALID_FALLBACK": { + "desc": "INCORRECT PORTCHANNEL FALLBACK IN PORT_CHANNEL TABLE.", + "eStrKey" : "Pattern", + "eStr": ["false|true|False|True"] + }, + "PORT_CHANNEL_INVALID_FAST_RATE": { + "desc": "INCORRECT PORTCHANNEL FAST_RATE IN PORT_CHANNEL TABLE.", + "eStrKey" : "Pattern", + "eStr": ["false|true|False|True"] + }, "PORTCHANNEL_INTERFACE_IP_ADDR_TEST": { "desc": "Configure IP address on PORTCHANNEL_INTERFACE table." }, diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/sflow.json b/src/sonic-yang-models/tests/yang_model_tests/tests/sflow.json index 42d09a773c0d..c631bf6979ae 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/sflow.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/sflow.json @@ -14,6 +14,21 @@ "desc": "Configure collectors above the specified limit in SFLOW_COLLECTOR table.", "eStr": ["Too many \"SFLOW_COLLECTOR_LIST\" elements"] }, + "SFLOW_TEST_WITH_COLLECTOR_DEFAULT_VRF": { + "desc": "Configure a collector in SFLOW_COLLECTOR table with default VRF." + }, + "SFLOW_TEST_WITH_COLLECTOR_MGMT_VRF": { + "desc": "Configure a collector in SFLOW_COLLECTOR table with mgmt VRF." + }, + "SFLOW_TEST_WITH_COLLECTOR_NON_EXISTING_MGMT_VRF": { + "desc": "Configure a collector in SFLOW_COLLECTOR table with mgmt VRF when MGMT VRF is not configured", + "eStrKey": "Must" + }, + "SFLOW_TEST_WITH_COLLECTOR_INVALID_VRF": { + "desc": "Configure a collector in SFLOW_COLLECTOR table with invalid vrf", + "eStrKey": "Pattern", + "eStr": ["mgmt|default"] + }, "SFLOW_SESSION_TEST": { "desc": "Configure a sflow session in SFLOW_SESSION table." }, diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/syslog.json b/src/sonic-yang-models/tests/yang_model_tests/tests/syslog.json index 8b110fbd8af8..da277f113486 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/syslog.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/syslog.json @@ -36,5 +36,31 @@ "SYSLOG_SERVER_INVALID_IPV6_ADDR_TEST": { "desc": "Load syslog server table with invalid ipv6 address as syslog server.", "eStrKey": "InvalidValue" + }, + "SYSLOG_CONFIG_VALID": { + "desc": "Configure SYSLOG_CONFIG." + }, + "SYSLOG_CONFIG_INVALID_INTERVAL": { + "desc": "Configure invalid rate limit interval in SYSLOG_CONFIG.", + "eStrKey": "InvalidValue" + }, + "SYSLOG_CONFIG_INVALID_BURST": { + "desc": "Configure invalid rate limit burst in SYSLOG_CONFIG.", + "eStrKey": "InvalidValue" + }, + "SYSLOG_CONFIG_FEATURE_VALID": { + "desc": "Configure SYSLOG_CONFIG_FEATURE." + }, + "SYSLOG_CONFIG_FEATURE_INVALID_SERVICE_NAME": { + "desc": "Configure invalid service in SYSLOG_CONFIG_FEATURE.", + "eStrKey": "LeafRef" + }, + "SYSLOG_CONFIG_FEATURE_INVALID_INTERVAL": { + "desc": "Configure invalid rate_limit_interval in SYSLOG_CONFIG_FEATURE.", + "eStrKey": "InvalidValue" + }, + "SYSLOG_CONFIG_FEATURE_INVALID_BURST": { + "desc": "Configure invalid rate_limit_burst in SYSLOG_CONFIG_FEATURE.", + "eStrKey": "InvalidValue" } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/vrf.json b/src/sonic-yang-models/tests/yang_model_tests/tests/vrf.json index a9d9bb0f9d9c..73e31ee109cc 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/vrf.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/vrf.json @@ -8,5 +8,12 @@ }, "VRF_TEST_WITH_FALLBACK": { "desc": "Configure VRF with fallback in VRF table." + }, + "VRF_TEST_WITH_VNI": { + "desc": "Configure VRF with VNI in VRF table." + }, + "VRF_TEST_WITH_VNI_OOR": { + "desc": "Configure VRF with out of range VNI in VRF table.", + "eStrKey": "Range" } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/vxlan.json b/src/sonic-yang-models/tests/yang_model_tests/tests/vxlan.json index 6bb0507fb050..880d0c015d0c 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/vxlan.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/vxlan.json @@ -2,6 +2,9 @@ "VXLAN_VALID_TEST": { "desc": "Valid VXLAN Configuration." }, + "VXLAN_VALID_V6_TUNNEL_TEST": { + "desc": "Valid VXLAN V6 Configuration." + }, "VXLAN_EVPN_NVO_WITHOUT_VTEP": { "desc": "Configure EVPN_NVO without VXLAN_TUNNEL entry", "eStrKey" : "LeafRef" diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/dhcpv6_relay.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/dhcpv6_relay.json index 68c077e51e91..3a8dc377c470 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/dhcpv6_relay.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/dhcpv6_relay.json @@ -76,11 +76,25 @@ "2001:1::2" ], "rfc6939_support": "true", - + "name": "Vlan400", + "interface_id": "true", "name": "Vlan400" } ] } } + }, + "DHCPv6_OPTION_WITH_INVALID_BOOLEAN_TYPE": { + "sonic-dhcpv6-relay:sonic-dhcpv6-relay": { + "sonic-dhcpv6-relay:DHCP_RELAY": { + "DHCP_RELAY_LIST": [ + { + "name": "Vlan500", + "rfc6939_support": "False", + "interface_id": "False" + } + ] + } + } } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/feature.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/feature.json index 31b12b6a19c3..dcba0bd317a1 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/feature.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/feature.json @@ -11,7 +11,8 @@ "has_global_scope": "True", "has_per_asic_scope": "True", "set_owner": "local", - "check_up_status": "False" + "check_up_status": "False", + "support_syslog_rate_limit": "true" }, { "name": "swss", @@ -21,7 +22,8 @@ "has_global_scope": "false", "has_per_asic_scope": "true", "set_owner": "local", - "check_up_status": "false" + "check_up_status": "false", + "support_syslog_rate_limit": "true" }, { "name": "syncd", @@ -31,7 +33,8 @@ "has_global_scope": "false", "has_per_asic_scope": "true", "set_owner": "local", - "check_up_status": "false" + "check_up_status": "false", + "support_syslog_rate_limit": "true" }, { "name": "snmp", @@ -41,7 +44,8 @@ "has_global_scope": "true", "has_per_asic_scope": "false", "set_owner": "kube", - "check_up_status": "false" + "check_up_status": "false", + "support_syslog_rate_limit": "true" }, { "name": "lldp", @@ -51,7 +55,8 @@ "has_global_scope": "false", "has_per_asic_scope": "{% if not DEVICE_RUNTIME_METADATA['ETHERNET_PORTS_PRESENT'] or ('CHASSIS_METADATA' in DEVICE_RUNTIME_METADATA and DEVICE_RUNTIME_METADATA['CHASSIS_METADATA']['module_type'] in ['supervisor']) %}False{% else %}True{% endif %}", "set_owner": "kube", - "check_up_status": "false" + "check_up_status": "false", + "support_syslog_rate_limit": "true" }, { "name": "dhcp_relay", @@ -61,7 +66,8 @@ "has_global_scope": "false", "has_per_asic_scope": "true", "set_owner": "kube", - "check_up_status": "false" + "check_up_status": "false", + "support_syslog_rate_limit": "true" } ] } @@ -79,7 +85,8 @@ "has_global_scope": "false", "has_per_asic_scope": "{% if not DEVICE_RUNTIME_METADATA['ETHERNET_PORTS_PRESENT'] or ('CHASSIS_METADATA' in DEVICE_RUNTIME_METADATA and DEVICE_RUNTIME_METADATA['CHASSIS_METADATA']['module_type'] in ['supervisor']) %}False{% else %}True{% endif %}", "set_owner": "invalid", - "check_up_status": "false" + "check_up_status": "false", + "support_syslog_rate_limit": "true" } ] } @@ -96,7 +103,9 @@ "has_timer": "false", "has_global_scope": "false", "has_per_asic_scope": "{% if not DEVICE_RUNTIME_METADATA['ETHERNET_PORTS_PRESENT'] or ('CHASSIS_METADATA' in DEVICE_RUNTIME_METADATA and DEVICE_RUNTIME_METADATA['CHASSIS_METADATA']['module_type'] in ['supervisor']) %}False{% else %}True{% endif %}", - "check_up_status": "false" + "check_up_status": "false", + "support_syslog_rate_limit": "true" + } ] } @@ -113,7 +122,8 @@ "has_timer": "FALSE", "has_global_scope": "TRUE", "has_per_asic_scope": "TRUE", - "check_up_status": "FALSE" + "check_up_status": "FALSE", + "support_syslog_rate_limit": "TRUE" } ] } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/flex_counter.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/flex_counter.json index 169a38ff6d7c..87ac2c6987eb 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/flex_counter.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/flex_counter.json @@ -43,6 +43,10 @@ "FLEX_COUNTER_STATUS": "enable", "POLL_INTERVAL": 10000 }, + "TUNNEL": { + "FLEX_COUNTER_STATUS": "enable", + "POLL_INTERVAL": 10000 + }, "FLOW_CNT_TRAP": { "FLEX_COUNTER_STATUS": "enable", "POLL_INTERVAL": 10000 @@ -98,6 +102,10 @@ "FLEX_COUNTER_STATUS": "enable", "POLL_INTERVAL": 99 }, + "TUNNEL": { + "FLEX_COUNTER_STATUS": "enable", + "POLL_INTERVAL": 99 + }, "FLOW_CNT_TRAP": { "FLEX_COUNTER_STATUS": "enable", "POLL_INTERVAL": 99 diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/mclag.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/mclag.json index fdb2661a973a..3d2ca3c92be6 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/mclag.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/mclag.json @@ -29,9 +29,6 @@ "PORTCHANNEL_LIST": [ { "admin_status": "up", - "members": [ - "Ethernet0" - ], "min_links": "1", "mtu": "9100", "lacp_key": "auto", @@ -39,9 +36,6 @@ }, { "admin_status": "up", - "members": [ - "Ethernet10" - ], "min_links": "1", "mtu": "9100", "lacp_key": "auto", @@ -151,9 +145,6 @@ "PORTCHANNEL_LIST": [ { "admin_status": "up", - "members": [ - "Ethernet0" - ], "min_links": "1", "mtu": "9100", "lacp_key": "auto", diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/port.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/port.json index 684caa2432b9..39b31dbb699b 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/port.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/port.json @@ -515,7 +515,60 @@ } } }, - + + "PORT_INVALID_CHANNEL_NUMBER": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet0", + "alias": "etp1a", + "lanes": "60, 61", + "speed": 100000, + "channel": 9 + } + ] + } + } + }, + + "PORT_VALID_CHANNEL_NUMBER": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet0", + "alias": "etp1a", + "lanes": "60, 61", + "speed": 100000, + "channel": 1 + }, + { + "name": "Ethernet2", + "alias": "etp1b", + "lanes": "62, 63", + "speed": 100000, + "channel": 2 + }, + { + "name": "Ethernet4", + "alias": "etp1c", + "lanes": "64, 65", + "speed": 100000, + "channel": 3 + }, + { + "name": "Ethernet6", + "alias": "etp1d", + "lanes": "66, 67", + "speed": 100000, + "channel": 4 + } + ] + } + } + }, + "PORT_VALID_MULTIASIC_TEST": { "sonic-port:sonic-port": { "sonic-port:PORT": { diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/portchannel.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/portchannel.json index 6c26e9ce83e6..36f2484fa3bf 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/portchannel.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/portchannel.json @@ -21,14 +21,13 @@ "PORTCHANNEL_LIST": [ { "admin_status": "up", - "members": [ - "Ethernet0" - ], "min_links": "1", "mtu": "9100", "tpid": "0x8100", "lacp_key": "auto", - "name": "PortChannel0001" + "name": "PortChannel0001", + "fast_rate": "false", + "fallback" : "false" } ] } @@ -55,9 +54,6 @@ "PORTCHANNEL_LIST": [ { "admin_status": "up", - "members": [ - "Ethernet0" - ], "min_links": "1024", "mtu": "9100", "name": "PortChannel0001" @@ -87,9 +83,6 @@ "PORTCHANNEL_LIST": [ { "admin_status": "up", - "members": [ - "Ethernet0" - ], "min_links": "1025", "mtu": "9100", "name": "PortChannel0001" @@ -125,6 +118,36 @@ } } }, + "PORT_CHANNEL_INVALID_FALLBACK": { + "sonic-portchannel:sonic-portchannel": { + "sonic-portchannel:PORTCHANNEL": { + "PORTCHANNEL_LIST": [ + { + "admin_status": "up", + "mtu": "9100", + "tpid": "0x9100", + "name": "PortChannel0001", + "fallback": "enabled" + } + ] + } + } + }, + "PORT_CHANNEL_INVALID_FAST_RATE": { + "sonic-portchannel:sonic-portchannel": { + "sonic-portchannel:PORTCHANNEL": { + "PORTCHANNEL_LIST": [ + { + "admin_status": "up", + "mtu": "9100", + "tpid": "0x9100", + "name": "PortChannel0001", + "fast_rate": "TRUE" + } + ] + } + } + }, "PORTCHANNEL_INTERFACE_IP_ADDR_TEST": { "sonic-portchannel:sonic-portchannel": { "sonic-portchannel:PORTCHANNEL": { @@ -303,9 +326,6 @@ "PORTCHANNEL_LIST": [ { "admin_status": "up", - "members": [ - "Ethernet0" - ], "min_links": "1", "mtu": "9100", "name": "PortChannel0001" @@ -350,9 +370,6 @@ "PORTCHANNEL_LIST": [ { "admin_status": "up", - "members": [ - "Ethernet0" - ], "min_links": "1", "mtu": "9100", "name": "PortChannel0001" @@ -396,9 +413,6 @@ "PORTCHANNEL_LIST": [ { "admin_status": "up", - "members": [ - "Ethernet0" - ], "min_links": "1", "mtu": "9100", "name": "PortChannel0001" diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/sflow.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/sflow.json index 5d1a561a9f66..07ef40b242a8 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/sflow.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/sflow.json @@ -59,6 +59,69 @@ } }, + "SFLOW_TEST_WITH_COLLECTOR_DEFAULT_VRF": { + "sonic-sflow:sonic-sflow": { + "sonic-sflow:SFLOW_COLLECTOR": { + "SFLOW_COLLECTOR_LIST": [ + { + "name": "collector1", + "collector_ip": "2001:1:2::23", + "collector_vrf": "default" + } + ] + } + } + }, + + "SFLOW_TEST_WITH_COLLECTOR_MGMT_VRF": { + "sonic-sflow:sonic-sflow": { + "sonic-sflow:SFLOW_COLLECTOR": { + "SFLOW_COLLECTOR_LIST": [ + { + "name": "collector1", + "collector_ip": "10.100.12.13", + "collector_vrf": "mgmt" + } + ] + } + }, + "sonic-mgmt_vrf:sonic-mgmt_vrf": { + "sonic-mgmt_vrf:MGMT_VRF_CONFIG": { + "sonic-mgmt_vrf:vrf_global": { + "mgmtVrfEnabled": "true" + } + } + } + }, + + "SFLOW_TEST_WITH_COLLECTOR_NON_EXISTING_MGMT_VRF": { + "sonic-sflow:sonic-sflow": { + "sonic-sflow:SFLOW_COLLECTOR": { + "SFLOW_COLLECTOR_LIST": [ + { + "name": "collector1", + "collector_ip": "10.100.12.13", + "collector_vrf": "mgmt" + } + ] + } + } + }, + + "SFLOW_TEST_WITH_COLLECTOR_INVALID_VRF": { + "sonic-sflow:sonic-sflow": { + "sonic-sflow:SFLOW_COLLECTOR": { + "SFLOW_COLLECTOR_LIST": [ + { + "name": "collector1", + "collector_ip": "10.100.12.13", + "collector_vrf": "Vrf1" + } + ] + } + } + }, + "SFLOW_SESSION_TEST": { "sonic-port:sonic-port": { "sonic-port:PORT": { diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/sonic-events-bgp.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/sonic-events-bgp.json index 2fa562f5efa6..ac747180f348 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/sonic-events-bgp.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/sonic-events-bgp.json @@ -38,10 +38,10 @@ "SONIC_EVENTS_BGP_NOTIFICATION_INCORRECT_MAJOR_CODE": { "sonic-events-bgp:sonic-events-bgp": { "sonic-events-bgp:notification": { - "major-code": "INCORRECT_MAJOR_CODE", - "minor-code": 2, + "major_code": "INCORRECT_MAJOR_CODE", + "minor_code": 2, "ip": "10.0.0.0", - "is-sent": true, + "is_sent": true, "timestamp": "1985-04-12T23:20:50.52Z" } } @@ -49,10 +49,10 @@ "SONIC_EVENTS_BGP_NOTIFICATION_INCORRECT_MINOR_CODE": { "sonic-events-bgp:sonic-events-bgp": { "sonic-events-bgp:notification": { - "major-code": 2, - "minor-code": "INCORRECT_MINOR_CODE", + "major_code": 2, + "minor_code": "INCORRECT_MINOR_CODE", "ip": "10.0.0.0", - "is-sent": true, + "is_sent": true, "timestamp": "1985-04-12T23:20:50.52Z" } } @@ -60,10 +60,10 @@ "SONIC_EVENTS_BGP_NOTIFICATION_INCORRECT_IP": { "sonic-events-bgp:sonic-events-bgp": { "sonic-events-bgp:notification": { - "major-code": 2, - "minor-code": 2, + "major_code": 2, + "minor_code": 2, "ip": "INCORRECT_IP", - "is-sent": true, + "is_sent": true, "timestamp": "1985-04-12T23:20:50.52Z" } } @@ -71,10 +71,10 @@ "SONIC_EVENTS_BGP_NOTIFICATION_INCORRECT_IS-SENT": { "sonic-events-bgp:sonic-events-bgp": { "sonic-events-bgp:notification": { - "major-code": 2, - "minor-code": 2, + "major_code": 2, + "minor_code": 2, "ip": "10.0.0.0", - "is-sent": "INCORRECT_VALUE", + "is_sent": "INCORRECT_VALUE", "timestamp": "1985-04-12T23:20:50.52Z" } } @@ -82,10 +82,10 @@ "SONIC_EVENTS_BGP_NOTIFICATION_INCORRECT_TIMESTAMP": { "sonic-events-bgp:sonic-events-bgp": { "sonic-events-bgp:notification": { - "major-code": 2, - "minor-code": 2, + "major_code": 2, + "minor_code": 2, "ip": "10.0.0.0", - "is-sent": true, + "is_sent": true, "timestamp": "INCORRECT_TIMESTAMP" } } @@ -93,10 +93,10 @@ "SONIC_EVENTS_BGP_NOTIFICATION_VALID": { "sonic-events-bgp:sonic-events-bgp": { "sonic-events-bgp:notification": { - "major-code": 2, - "minor-code": 2, + "major_code": 2, + "minor_code": 2, "ip": "10.0.0.0", - "is-sent": true, + "is_sent": true, "timestamp": "1985-04-12T23:20:50.52Z" } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/sonic-events-host.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/sonic-events-host.json index 5c771de041b3..98ee755b510a 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/sonic-events-host.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/sonic-events-host.json @@ -263,7 +263,7 @@ "sonic-events-host:sonic-events-host": { "sonic-events-host:mem-threshold-exceeded": { "ctr_name": "Invalid$", - "mem_usage": 123456, + "mem_usage": "123456.78", "threshold": 123456, "timestamp": "1985-04-12T23:20:50.52Z" } @@ -273,7 +273,7 @@ "sonic-events-host:sonic-events-host": { "sonic-events-host:mem-threshold-exceeded": { "ctr_name": "invalid-length-for-ctr-name-too-long", - "mem_usage": 123456, + "mem_usage": "123456.78", "threshold": 123456, "timestamp": "1985-04-12T23:20:50.52Z" } @@ -293,7 +293,7 @@ "sonic-events-host:sonic-events-host": { "sonic-events-host:mem-threshold-exceeded": { "ctr_name": "container_name", - "mem_usage": 123456, + "mem_usage": "123456.78", "threshold": "INCORRECT_THRESHOLD", "timestamp": "1985-04-12T23:20:50.52Z" } @@ -303,7 +303,7 @@ "sonic-events-host:sonic-events-host": { "sonic-events-host:mem-threshold-exceeded": { "ctr_name": "container_name", - "mem_usage": 123456, + "mem_usage": "123456.78", "threshold": 123456, "timestamp": "INCORRECT_TIMESTAMP" } @@ -313,7 +313,7 @@ "sonic-events-host:sonic-events-host": { "sonic-events-host:mem-threshold-exceeded": { "ctr_name": "container_name", - "mem_usage": 123456, + "mem_usage": "123456.78", "threshold": 123456, "timestamp": "1985-04-12T23:20:50.52Z" } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/syslog.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/syslog.json index 990fdcf85c72..0ebaddbc7044 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/syslog.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/syslog.json @@ -157,5 +157,113 @@ ] } } + }, + "SYSLOG_CONFIG_VALID": { + "sonic-syslog:sonic-syslog": { + "sonic-syslog:SYSLOG_CONFIG": { + "sonic-syslog:GLOBAL": { + "rate_limit_interval": "200", + "rate_limit_burst": "40000" + } + } + } + }, + "SYSLOG_CONFIG_INVALID_INTERVAL": { + "sonic-syslog:sonic-syslog": { + "sonic-syslog:SYSLOG_CONFIG": { + "sonic-syslog:GLOBAL": { + "rate_limit_interval": "-1" + } + } + } + }, + "SYSLOG_CONFIG_INVALID_BURST": { + "sonic-syslog:sonic-syslog": { + "sonic-syslog:SYSLOG_CONFIG": { + "sonic-syslog:GLOBAL": { + "rate_limit_burst": "-1" + } + } + } + }, + "SYSLOG_CONFIG_FEATURE_VALID": { + "sonic-syslog:sonic-syslog": { + "sonic-syslog:SYSLOG_CONFIG_FEATURE": { + "SYSLOG_CONFIG_FEATURE_LIST": [ + { + "service": "bgp", + "rate_limit_interval": "200", + "rate_limit_burst": "40000" + } + ] + } + }, + "sonic-feature:sonic-feature": { + "sonic-feature:FEATURE": { + "FEATURE_LIST": [ + { + "name": "bgp", + "support_syslog_rate_limit": "true" + } + ] + } + } + }, + "SYSLOG_CONFIG_FEATURE_INVALID_SERVICE_NAME": { + "sonic-syslog:sonic-syslog": { + "sonic-syslog:SYSLOG_CONFIG_FEATURE": { + "SYSLOG_CONFIG_FEATURE_LIST": [ + { + "service": "invalid", + "rate_limit_interval": "100", + "rate_limit_burst": "20000" + } + ] + } + } + }, + "SYSLOG_CONFIG_FEATURE_INVALID_INTERVAL": { + "sonic-syslog:sonic-syslog": { + "sonic-syslog:SYSLOG_CONFIG_FEATURE": { + "SYSLOG_CONFIG_FEATURE_LIST": [ + { + "service": "bgp", + "rate_limit_interval": "-1" + } + ] + } + }, + "sonic-feature:sonic-feature": { + "sonic-feature:FEATURE": { + "FEATURE_LIST": [ + { + "name": "bgp", + "support_syslog_rate_limit": "true" + } + ] + } + } + }, + "SYSLOG_CONFIG_FEATURE_INVALID_BURST": { + "sonic-syslog:sonic-syslog": { + "sonic-syslog:SYSLOG_CONFIG_FEATURE": { + "SYSLOG_CONFIG_FEATURE_LIST": [ + { + "service": "bgp", + "rate_limit_burst": "-1" + } + ] + } + }, + "sonic-feature:sonic-feature": { + "sonic-feature:FEATURE": { + "FEATURE_LIST": [ + { + "name": "bgp", + "support_syslog_rate_limit": "true" + } + ] + } + } } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/system_defaults.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/system_defaults.json index a8ccc13c099d..da9a3e752bf7 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/system_defaults.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/system_defaults.json @@ -6,6 +6,10 @@ { "name": "tunnel_qos_remap", "status": "enabled" + }, + { + "name": "mux_tunnel_egress_acl", + "status": "enabled" } ] } @@ -18,6 +22,10 @@ { "name": "tunnel_qos_remap", "status": "invalid_status" + }, + { + "name": "mux_tunnel_egress_acl", + "status": "invalid_status" } ] } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/vlan_sub_interface.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/vlan_sub_interface.json index b249510f4370..6f200ef4b7ea 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/vlan_sub_interface.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/vlan_sub_interface.json @@ -196,9 +196,6 @@ "PORTCHANNEL_LIST": [ { "admin_status": "up", - "members": [ - "Ethernet0" - ], "min_links": "1", "mtu": "9100", "tpid": "0x8100", @@ -246,9 +243,6 @@ "PORTCHANNEL_LIST": [ { "admin_status": "up", - "members": [ - "Ethernet0" - ], "min_links": "1", "mtu": "9100", "tpid": "0x8100", @@ -296,9 +290,6 @@ "PORTCHANNEL_LIST": [ { "admin_status": "up", - "members": [ - "Ethernet0" - ], "min_links": "1", "mtu": "9100", "tpid": "0x8100", @@ -346,9 +337,6 @@ "PORTCHANNEL_LIST": [ { "admin_status": "up", - "members": [ - "Ethernet0" - ], "min_links": "1", "mtu": "9100", "tpid": "0x8100", diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/vrf.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/vrf.json index f34d3fbdd52d..082ec022f81b 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/vrf.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/vrf.json @@ -28,5 +28,27 @@ }] } } + }, + + "VRF_TEST_WITH_VNI": { + "sonic-vrf:sonic-vrf": { + "sonic-vrf:VRF": { + "VRF_LIST": [{ + "name": "Vrf_blue", + "vni": "100" + }] + } + } + }, + + "VRF_TEST_WITH_VNI_OOR": { + "sonic-vrf:sonic-vrf": { + "sonic-vrf:VRF": { + "VRF_LIST": [{ + "name": "Vrf_blue", + "vni": "16777216" + }] + } + } } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/vxlan.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/vxlan.json index 90e71063cb24..117d626ca4c2 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/vxlan.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/vxlan.json @@ -38,6 +38,45 @@ } } }, + "VXLAN_VALID_V6_TUNNEL_TEST": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan100" + } + ] + } + }, + "sonic-vxlan:sonic-vxlan": { + "sonic-vxlan:VXLAN_TUNNEL": { + "VXLAN_TUNNEL_LIST": [ + { + "name": "vtep1", + "src_ip": "2001::1:2:3:4" + } + ] + }, + "sonic-vxlan:VXLAN_EVPN_NVO": { + "VXLAN_EVPN_NVO_LIST": [ + { + "name": "nvo1", + "source_vtep": "vtep1" + } + ] + }, + "sonic-vxlan:VXLAN_TUNNEL_MAP": { + "VXLAN_TUNNEL_MAP_LIST": [ + { + "name": "vtep1", + "mapname": "map_100_Vlan100", + "vlan": "Vlan100", + "vni": "100" + } + ] + } + } + }, "VXLAN_EVPN_NVO_WITHOUT_VTEP": { "sonic-vxlan:sonic-vxlan": { "sonic-vxlan:VXLAN_EVPN_NVO": { diff --git a/src/sonic-yang-models/yang-models/sonic-dhcpv6-relay.yang b/src/sonic-yang-models/yang-models/sonic-dhcpv6-relay.yang index 80794114e647..4a0bf60708c9 100644 --- a/src/sonic-yang-models/yang-models/sonic-dhcpv6-relay.yang +++ b/src/sonic-yang-models/yang-models/sonic-dhcpv6-relay.yang @@ -34,15 +34,24 @@ module sonic-dhcpv6-relay { type string; } - leaf-list dhcpv6_servers { - description "Configure the dhcp v6 servers"; - type inet:ipv6-address; - } - - leaf rfc6939_support { - description "Set rfc6939 for the relay"; - type boolean; - } + leaf-list dhcpv6_servers { + description "Configure the dhcp v6 servers"; + type inet:ipv6-address; + } + + leaf rfc6939_support { + description "Set rfc6939 for the relay"; + type string { + pattern "false|true"; + } + } + + leaf interface_id { + description "Enable interface ID insertion in relayed messages"; + type string { + pattern "false|true"; + } + } } /* end of VLAN_LIST */ } diff --git a/src/sonic-yang-models/yang-models/sonic-events-bgp.yang b/src/sonic-yang-models/yang-models/sonic-events-bgp.yang index 26d2b85e954f..df9945d783f9 100644 --- a/src/sonic-yang-models/yang-models/sonic-events-bgp.yang +++ b/src/sonic-yang-models/yang-models/sonic-events-bgp.yang @@ -57,12 +57,12 @@ module sonic-events-bgp { The error codes as per IANA. The other params are as in the message"; - leaf major-code { + leaf major_code { type uint8; description "Major IANA error code; [RFC4271][RFC7313]"; } - leaf minor-code { + leaf minor_code { type uint8; description "Minor IANA error code; [RFC4271][RFC7313]"; } @@ -72,7 +72,7 @@ module sonic-events-bgp { description "IP of neighbor associated with this notification"; } - leaf is-sent { + leaf is_sent { type boolean; description "true - if this notification was for sent messages; false if it was for received."; } diff --git a/src/sonic-yang-models/yang-models/sonic-events-host.yang b/src/sonic-yang-models/yang-models/sonic-events-host.yang index cbb129d9fe25..edd98d247c02 100644 --- a/src/sonic-yang-models/yang-models/sonic-events-host.yang +++ b/src/sonic-yang-models/yang-models/sonic-events-host.yang @@ -196,7 +196,9 @@ module sonic-events-host { } leaf mem_usage { - type uint64; + type decimal64 { + fraction-digits 2; + } description "Memory usage of process"; } diff --git a/src/sonic-yang-models/yang-models/sonic-feature.yang b/src/sonic-yang-models/yang-models/sonic-feature.yang index fb3c6d65209e..4e514ff2f0fc 100644 --- a/src/sonic-yang-models/yang-models/sonic-feature.yang +++ b/src/sonic-yang-models/yang-models/sonic-feature.yang @@ -98,6 +98,13 @@ module sonic-feature{ type stypes:boolean_type; default "false"; } + + leaf support_syslog_rate_limit { + description "This configuration indicates the feature support configuring + syslog rate limit"; + type stypes:boolean_type; + default "false"; + } } } } diff --git a/src/sonic-yang-models/yang-models/sonic-flex_counter.yang b/src/sonic-yang-models/yang-models/sonic-flex_counter.yang index e94aa76ccf42..96745fc5e4a6 100644 --- a/src/sonic-yang-models/yang-models/sonic-flex_counter.yang +++ b/src/sonic-yang-models/yang-models/sonic-flex_counter.yang @@ -228,6 +228,19 @@ module sonic-flex_counter { } } + container TUNNEL { + /* TUNNEL_STAT_COUNTER_FLEX_COUNTER_GROUP */ + leaf FLEX_COUNTER_STATUS { + type flex_status; + } + leaf FLEX_COUNTER_DELAY_STATUS { + type flex_delay_status; + } + leaf POLL_INTERVAL { + type poll_interval; + } + } + } /* end of container FLEX_COUNTER_TABLE */ diff --git a/src/sonic-yang-models/yang-models/sonic-port.yang b/src/sonic-yang-models/yang-models/sonic-port.yang index e2408d593ddb..667b3b1f359a 100644 --- a/src/sonic-yang-models/yang-models/sonic-port.yang +++ b/src/sonic-yang-models/yang-models/sonic-port.yang @@ -121,6 +121,13 @@ module sonic-port{ } } + leaf channel { + description "Logical channel(s) for physical port breakout"; + type uint8 { + range 0..8; + } + } + leaf index { type uint16; } diff --git a/src/sonic-yang-models/yang-models/sonic-portchannel.yang b/src/sonic-yang-models/yang-models/sonic-portchannel.yang index 31235a0d2277..717e3924c420 100644 --- a/src/sonic-yang-models/yang-models/sonic-portchannel.yang +++ b/src/sonic-yang-models/yang-models/sonic-portchannel.yang @@ -58,23 +58,6 @@ module sonic-portchannel { } } - leaf-list members { - /* leaf-list members are unique by default */ - type union { - type leafref { - path /port:sonic-port/port:PORT/port:PORT_LIST/port:name; - } - type string { - pattern ""; - } - } - /* Today in SONiC, we do not delete the list once - * created, instead we set to empty list. Due to that - * below default values are needed. - */ - default ""; - } - leaf min_links { type uint16 { range 1..1024; @@ -119,6 +102,15 @@ module sonic-portchannel { type stypes:tpid_type; } + leaf fallback { + description "Enable LACP fallback feature"; + type stypes:boolean_type; + } + leaf fast_rate { + description "Enable LACP fast rate"; + type stypes:boolean_type; + } + } /* end of list PORTCHANNEL_LIST */ } /* end of container PORTCHANNEL */ diff --git a/src/sonic-yang-models/yang-models/sonic-sflow.yang b/src/sonic-yang-models/yang-models/sonic-sflow.yang index adbeda80c4da..2865e05f34b9 100644 --- a/src/sonic-yang-models/yang-models/sonic-sflow.yang +++ b/src/sonic-yang-models/yang-models/sonic-sflow.yang @@ -25,6 +25,10 @@ module sonic-sflow{ import sonic-mgmt_port { prefix mgmt-port; } + import sonic-mgmt_vrf { + prefix mvrf; + } + description "SFLOW yang Module for SONiC OS"; @@ -43,17 +47,34 @@ module sonic-sflow{ type string { length 1..64; } + description "Name of the Sflow collector"; } leaf collector_ip { mandatory true; type inet:ip-address; + description "IPv4/IPv6 address of the Sflow collector"; } leaf collector_port { type inet:port-number; default 6343; + description "Destination L4 port of the Sflow collector"; + } + + leaf collector_vrf { + must "(current() != 'mgmt') or (/mvrf:sonic-mgmt_vrf/mvrf:MGMT_VRF_CONFIG/mvrf:vrf_global/mvrf:mgmtVrfEnabled = 'true')" { + error-message "Must condition not satisfied. Try enable Management VRF."; + } + + type string { + pattern "mgmt|default"; + } + + description + "Specify the Collector VRF. In this revision, it is either + default VRF or Management VRF."; } } /* end of list SFLOW_COLLECTOR_LIST */ @@ -78,6 +99,7 @@ module sonic-sflow{ leaf admin_state { type stypes:admin_status; default up; + description "Per port sflow admin state"; } leaf sample_rate { @@ -99,6 +121,7 @@ module sonic-sflow{ leaf admin_state { type stypes:admin_status; default down; + description "Global sflow admin state"; } leaf polling_interval { diff --git a/src/sonic-yang-models/yang-models/sonic-syslog.yang b/src/sonic-yang-models/yang-models/sonic-syslog.yang index dc1925f463fa..6a4750f708d7 100644 --- a/src/sonic-yang-models/yang-models/sonic-syslog.yang +++ b/src/sonic-yang-models/yang-models/sonic-syslog.yang @@ -17,6 +17,10 @@ module sonic-syslog { prefix vrf; } + import sonic-feature { + prefix feature; + } + description "Syslog YANG Module for SONiC OS: remote syslog logging"; revision 2022-04-18 { @@ -31,6 +35,20 @@ module sonic-syslog { } } + typedef syslog-rate-limit-interval { + description "Message rate limit interval in second"; + type uint32 { + range 0..2147483647; + } + } + + typedef syslog-rate-limit-burst { + description "Message rate limit burst in message count"; + type uint32 { + range 0..2147483647; + } + } + container sonic-syslog { container SYSLOG_SERVER { @@ -74,6 +92,50 @@ module sonic-syslog { /* end of list SYSLOG_SERVER_LIST */ } /* end of container SYSLOG_SERVER */ + + container SYSLOG_CONFIG { + + description "SYSLOG_CONFIG part of config_db.json"; + + container GLOBAL { + leaf rate_limit_interval { + type syslog-rate-limit-interval; + } + + leaf rate_limit_burst { + type syslog-rate-limit-burst; + } + } + /* end of list SYSLOG_CONFIG_LIST */ + } + /* end of container SYSLOG_CONFIG */ + + container SYSLOG_CONFIG_FEATURE { + + description "SYSLOG_CONFIG_FEATURE part of config_db.json"; + + list SYSLOG_CONFIG_FEATURE_LIST { + + key "service"; + + leaf service { + description "Service name"; + type leafref { + path "/feature:sonic-feature/feature:FEATURE/feature:FEATURE_LIST/feature:name"; + } + } + + leaf rate_limit_interval { + type syslog-rate-limit-interval; + } + + leaf rate_limit_burst { + type syslog-rate-limit-burst; + } + } + /* end of list SYSLOG_CONFIG_FEATURE_LIST */ + } + /* end of container SYSLOG_CONFIG_FEATURE */ } /* end of container sonic-syslog */ } diff --git a/src/sonic-yang-models/yang-models/sonic-vrf.yang b/src/sonic-yang-models/yang-models/sonic-vrf.yang index ff9fc5b5a4cc..5387aad2cc80 100644 --- a/src/sonic-yang-models/yang-models/sonic-vrf.yang +++ b/src/sonic-yang-models/yang-models/sonic-vrf.yang @@ -43,6 +43,14 @@ module sonic-vrf { "Enable/disable fallback feature which is useful for specified VRF user to access internet through global/main route."; } + leaf vni { + type uint32 { + range "0..16777215"; + } + default 0; + description + "VNI mapped to VRF"; + } } /* end of list VRF_LISt */ } /* end of container VRf */ } /* end of container sonic-vrf */ diff --git a/src/sonic-yang-models/yang-models/sonic-vxlan.yang b/src/sonic-yang-models/yang-models/sonic-vxlan.yang index fc23ea9141a0..bad6111b35a8 100644 --- a/src/sonic-yang-models/yang-models/sonic-vxlan.yang +++ b/src/sonic-yang-models/yang-models/sonic-vxlan.yang @@ -60,7 +60,7 @@ module sonic-vxlan { } leaf src_ip { - type inet:ipv4-address; + type inet:ip-address; } } } diff --git a/src/system-health/health_checker/hardware_checker.py b/src/system-health/health_checker/hardware_checker.py index 575564de8733..59e47fa26733 100644 --- a/src/system-health/health_checker/hardware_checker.py +++ b/src/system-health/health_checker/hardware_checker.py @@ -239,6 +239,18 @@ def _check_psu_status(self, config): voltage_min_th, voltage_max_th)) continue + + if not self._ignore_check(config.ignore_devices, 'psu', name, 'power_threshold'): + power_overload = data_dict.get('power_overload', None) + if power_overload == 'True': + try: + power = data_dict['power'] + power_critical_threshold = data_dict['power_critical_threshold'] + self.set_object_not_ok('PSU', name, 'power of {} ({}w) exceeds threshold ({}w)'.format(name, power, power_critical_threshold)) + except KeyError: + self.set_object_not_ok('PSU', name, 'power of {} exceeds threshold but power or power_critical_threshold is invalid'.format(name)) + continue + self.set_object_ok('PSU', name) def reset(self): diff --git a/src/system-health/health_checker/service_checker.py b/src/system-health/health_checker/service_checker.py index ed6c7296fde3..9a88a0851bc8 100644 --- a/src/system-health/health_checker/service_checker.py +++ b/src/system-health/health_checker/service_checker.py @@ -26,13 +26,13 @@ class ServiceChecker(HealthChecker): CRITICAL_PROCESSES_PATH = 'etc/supervisor/critical_processes' # Command to get merged directory of a container - GET_CONTAINER_FOLDER_CMD = ['docker', 'inspect', '', '--format', "{{.GraphDriver.Data.MergedDir}}"] + GET_CONTAINER_FOLDER_CMD = 'docker inspect {} --format "{{{{.GraphDriver.Data.MergedDir}}}}"' # Command to query the status of monit service. - CHECK_MONIT_SERVICE_CMD = ['systemctl', 'is-active', 'monit.service'] + CHECK_MONIT_SERVICE_CMD = 'systemctl is-active monit.service' # Command to get summary of critical system service. - CHECK_CMD = ['monit', 'summary', '-B'] + CHECK_CMD = 'monit summary -B' MIN_CHECK_CMD_LINES = 3 # Expect status for different system service category. @@ -71,6 +71,19 @@ def get_expected_running_containers(self, feature_table): """ expected_running_containers = set() container_feature_dict = {} + + # Get current asic presence list. For multi_asic system, multi instance containers + # should be checked only for asics present. + asics_id_presence = multi_asic.get_asic_presence_list() + + # Some services may run all the instances irrespective of asic presence. + # Add those to exception list. + # database service: Currently services have dependency on all database services to + # be up irrespective of asic presence. + # bgp service: Currently bgp runs all instances. Once this is fixed to be config driven, + # it will be removed from exception list. + run_all_instance_list = ['database', 'bgp'] + for feature_name, feature_entry in feature_table.items(): if feature_entry["state"] not in ["disabled", "always_disabled"]: if multi_asic.is_multi_asic(): @@ -80,8 +93,9 @@ def get_expected_running_containers(self, feature_table): if feature_entry["has_per_asic_scope"] == "True": num_asics = multi_asic.get_num_asics() for asic_id in range(num_asics): - expected_running_containers.add(feature_name + str(asic_id)) - container_feature_dict[feature_name + str(asic_id)] = feature_name + if asic_id in asics_id_presence or feature_name in run_all_instance_list: + expected_running_containers.add(feature_name + str(asic_id)) + container_feature_dict[feature_name + str(asic_id)] = feature_name else: expected_running_containers.add(feature_name) container_feature_dict[feature_name] = feature_name @@ -172,8 +186,7 @@ def _update_container_critical_processes(self, container, critical_process_list) self.need_save_cache = True def _get_container_folder(self, container): - ServiceChecker.GET_CONTAINER_FOLDER_CMD[2] = str(container) - container_folder = utils.run_command(ServiceChecker.GET_CONTAINER_FOLDER_CMD) + container_folder = utils.run_command(ServiceChecker.GET_CONTAINER_FOLDER_CMD.format(container)) if container_folder is None: return container_folder @@ -339,11 +352,11 @@ def check_process_existence(self, container_name, critical_process_list, config, # We are using supervisorctl status to check the critical process status. We cannot leverage psutil here because # it not always possible to get process cmdline in supervisor.conf. E.g, cmdline of orchagent is "/usr/bin/orchagent", # however, in supervisor.conf it is "/usr/bin/orchagent.sh" - cmd = ['docker', 'exec', str(container_name), 'bash', '-c', "supervisorctl status"] + cmd = 'docker exec {} bash -c "supervisorctl status"'.format(container_name) process_status = utils.run_command(cmd) if process_status is None: for process_name in critical_process_list: - self.set_object_not_ok('Process', '{}:{}'.format(container_name, process_name), "'{}' is not running".format(process_name)) + self.set_object_not_ok('Process', '{}:{}'.format(container_name, process_name), "Process '{}' in container '{}' is not running".format(process_name, container_name)) self.publish_events(container_name, critical_process_list) return @@ -356,6 +369,6 @@ def check_process_existence(self, container_name, critical_process_list, config, # and it is safe to ignore such process. E.g, radv. So here we only check those processes which are in process_status. if process_name in process_status: if process_status[process_name] != 'RUNNING': - self.set_object_not_ok('Process', '{}:{}'.format(container_name, process_name), "'{}' is not running".format(process_name)) + self.set_object_not_ok('Process', '{}:{}'.format(container_name, process_name), "Process '{}' in container '{}' is not running".format(process_name, container_name)) else: self.set_object_ok('Process', '{}:{}'.format(container_name, process_name)) diff --git a/src/system-health/health_checker/sysmonitor.py b/src/system-health/health_checker/sysmonitor.py index e4dbc68ebf1d..b3f43e447f7b 100755 --- a/src/system-health/health_checker/sysmonitor.py +++ b/src/system-health/health_checker/sysmonitor.py @@ -19,7 +19,6 @@ SELECT_TIMEOUT_MSECS = 1000 QUEUE_TIMEOUT = 15 TASK_STOP_TIMEOUT = 10 -mpmgr = multiprocessing.Manager() logger = Logger(log_identifier=SYSLOG_IDENTIFIER) @@ -235,7 +234,7 @@ def get_app_ready_status(self, service): #Gets the service properties def run_systemctl_show(self, service): - command = ['systemctl', 'show', str(service), '--property=Id,LoadState,UnitFileState,Type,ActiveState,SubState,Result'] + command = ('systemctl show {} --property=Id,LoadState,UnitFileState,Type,ActiveState,SubState,Result'.format(service)) output = utils.run_command(command) srv_properties = output.split('\n') prop_dict = {} @@ -274,7 +273,7 @@ def get_unit_status(self, event): sysctl_show = self.run_systemctl_show(event) - load_state = sysctl_show['LoadState'] + load_state = sysctl_show.get('LoadState') if load_state == "loaded": status = sysctl_show['UnitFileState'] fail_reason = sysctl_show['Result'] @@ -420,6 +419,7 @@ def system_service(self): self.state_db = swsscommon.SonicV2Connector(host='127.0.0.1') self.state_db.connect(self.state_db.STATE_DB) + mpmgr = multiprocessing.Manager() myQ = mpmgr.Queue() try: monitor_system_bus = MonitorSystemBusTask(myQ) diff --git a/src/system-health/health_checker/utils.py b/src/system-health/health_checker/utils.py index 338ef1d3afe5..00e7754e1ec2 100644 --- a/src/system-health/health_checker/utils.py +++ b/src/system-health/health_checker/utils.py @@ -8,7 +8,7 @@ def run_command(command): :return: Output of the shell command. """ try: - process = subprocess.Popen(command, universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + process = subprocess.Popen(command, shell=True, universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) return process.communicate()[0] except Exception: return None diff --git a/src/system-health/pytest.ini b/src/system-health/pytest.ini index a9c5a74860a3..b5b94c91c307 100644 --- a/src/system-health/pytest.ini +++ b/src/system-health/pytest.ini @@ -1,2 +1,2 @@ [pytest] -addopts = --cov=health_checker --cov-report html --cov-report term --cov-report xml +addopts = --cov=health_checker --cov=healthd --cov-report html --cov-report term --cov-report xml diff --git a/src/system-health/scripts/healthd b/src/system-health/scripts/healthd index df52969d3aff..cb404de29ee1 100644 --- a/src/system-health/scripts/healthd +++ b/src/system-health/scripts/healthd @@ -7,6 +7,7 @@ import signal import threading +import time from sonic_py_common.daemon_base import DaemonBase from swsscommon.swsscommon import SonicV2Connector @@ -79,18 +80,27 @@ class HealthDaemon(DaemonBase): return sysmon = Sysmonitor() sysmon.task_run() - while 1: - stat = manager.check(chassis) - self._process_stat(chassis, manager.config, stat) - - if self.stop_event.wait(manager.config.interval): - break + while self._run_checker(manager, chassis): + pass except ImportError: self.log_warning("sonic_platform package not installed. Cannot start system-health daemon") self.deinit() sysmon.task_stop() + def _run_checker(self, manager, chassis): + begin = time.time() + stat = manager.check(chassis) + self._process_stat(chassis, manager.config, stat) + elapse = time.time() - begin + sleep_time_in_sec = manager.config.interval - elapse + if sleep_time_in_sec < 0: + self.log_notice(f'System health takes {elapse} seconds for one iteration') + sleep_time_in_sec = 1 + if self.stop_event.wait(sleep_time_in_sec): + return False + return True + def _process_stat(self, chassis, config, stat): from health_checker.health_checker import HealthChecker self._clear_system_health_table() diff --git a/src/system-health/tests/test_system_health.py b/src/system-health/tests/test_system_health.py index ab0a3bcb1145..ee09b1624bff 100644 --- a/src/system-health/tests/test_system_health.py +++ b/src/system-health/tests/test_system_health.py @@ -12,6 +12,7 @@ import copy import os import sys +from imp import load_source from swsscommon import swsscommon from mock import Mock, MagicMock, patch @@ -23,7 +24,9 @@ test_path = os.path.dirname(os.path.abspath(__file__)) modules_path = os.path.dirname(test_path) +scripts_path = os.path.join(modules_path, 'scripts') sys.path.insert(0, modules_path) +sys.path.insert(0, scripts_path) from health_checker import utils from health_checker.config import Config from health_checker.hardware_checker import HardwareChecker @@ -35,6 +38,9 @@ from health_checker.sysmonitor import MonitorStateDbTask from health_checker.sysmonitor import MonitorSystemBusTask +load_source('healthd', os.path.join(scripts_path, 'healthd')) +from healthd import HealthDaemon + mock_supervisorctl_output = """ snmpd RUNNING pid 67, uptime 1:03:56 snmp-subagent EXITED Oct 19 01:53 AM @@ -362,6 +368,30 @@ def test_hardware_checker(): 'voltage': '10', 'voltage_min_threshold': '12', 'voltage_max_threshold': '15', + }, + 'PSU_INFO|PSU 6': { + 'presence': 'True', + 'status': 'True', + 'temp': '55', + 'temp_threshold': '100', + 'voltage': '12', + 'voltage_min_threshold': '12', + 'voltage_max_threshold': '15', + 'power_overload': 'True', + 'power': '101.0', + 'power_critical_threshold': '100.0', + 'power_warning_suppress_threshold': '90.0' + }, + 'PSU_INFO|PSU 7': { + 'presence': 'True', + 'status': 'True', + 'temp': '55', + 'temp_threshold': '100', + 'voltage': '12', + 'voltage_min_threshold': '12', + 'voltage_max_threshold': '15', + 'power_overload': 'True', + 'power': '101.0' } }) @@ -400,6 +430,14 @@ def test_hardware_checker(): assert 'PSU 5' in checker._info assert checker._info['PSU 5'][HealthChecker.INFO_FIELD_OBJECT_STATUS] == HealthChecker.STATUS_NOT_OK + assert 'PSU 6' in checker._info + assert checker._info['PSU 6'][HealthChecker.INFO_FIELD_OBJECT_MSG] == 'power of PSU 6 (101.0w) exceeds threshold (100.0w)' + assert checker._info['PSU 6'][HealthChecker.INFO_FIELD_OBJECT_STATUS] == HealthChecker.STATUS_NOT_OK + + assert 'PSU 7' in checker._info + assert checker._info['PSU 7'][HealthChecker.INFO_FIELD_OBJECT_STATUS] == HealthChecker.STATUS_NOT_OK + assert checker._info['PSU 7'][HealthChecker.INFO_FIELD_OBJECT_MSG] == 'power of PSU 7 exceeds threshold but power or power_critical_threshold is invalid' + def test_config(): config = Config() @@ -504,10 +542,10 @@ def test_manager(mock_hw_info, mock_service_info, mock_udc_info): manager._set_system_led(chassis, manager.config, 'normal') def test_utils(): - output = utils.run_command(['some', 'invalid', 'command']) + output = utils.run_command('some invalid command') assert not output - output = utils.run_command(['ls']) + output = utils.run_command('ls') assert output @@ -740,3 +778,26 @@ def test_get_service_from_feature_table(): sysmon.get_service_from_feature_table(dir_list) assert 'bgp.service' in dir_list assert 'swss.service' not in dir_list + + +@patch('healthd.time.time') +def test_healthd_check_interval(mock_time): + daemon = HealthDaemon() + manager = MagicMock() + manager.check = MagicMock() + manager.config = MagicMock() + chassis = MagicMock() + daemon._process_stat = MagicMock() + daemon.stop_event = MagicMock() + daemon.stop_event.wait = MagicMock() + + daemon.stop_event.wait.return_value = False + manager.config.interval = 60 + mock_time.side_effect = [0, 3, 0, 61, 0, 1] + assert daemon._run_checker(manager, chassis) + daemon.stop_event.wait.assert_called_with(57) + assert daemon._run_checker(manager, chassis) + daemon.stop_event.wait.assert_called_with(1) + + daemon.stop_event.wait.return_value = True + assert not daemon._run_checker(manager, chassis) diff --git a/src/systemd-sonic-generator/systemd-sonic-generator.c b/src/systemd-sonic-generator/systemd-sonic-generator.c index 9267a48aa4a6..fb82c41b7af8 100644 --- a/src/systemd-sonic-generator/systemd-sonic-generator.c +++ b/src/systemd-sonic-generator/systemd-sonic-generator.c @@ -592,11 +592,14 @@ int ssg_main(int argc, char **argv) { for (int i = 0; i < num_unit_files; i++) { unit_instance = strdup(unit_files[i]); if ((num_asics == 1) && strstr(unit_instance, "@") != NULL) { - prefix = strtok_r(unit_instance, "@", &saveptr); - suffix = strtok_r(NULL, "@", &saveptr); + prefix = strdup(strtok_r(unit_instance, "@", &saveptr)); + suffix = strdup(strtok_r(NULL, "@", &saveptr)); strcpy(unit_instance, prefix); strcat(unit_instance, suffix); + + free(prefix); + free(suffix); } num_targets = get_install_targets(unit_instance, targets); diff --git a/src/thrift_0_14_1/Makefile b/src/thrift_0_14_1/Makefile index 081aff3f34bd..02f44ea1202a 100644 --- a/src/thrift_0_14_1/Makefile +++ b/src/thrift_0_14_1/Makefile @@ -7,6 +7,7 @@ THRIFT_VERSION = 0.14.1 MAIN_TARGET = libthrift0_$(THRIFT_VERSION)_$(CONFIGURED_ARCH).deb DERIVED_TARGETS = libthrift-dev_$(THRIFT_VERSION)_$(CONFIGURED_ARCH).deb \ python3-thrift_$(THRIFT_VERSION)_$(CONFIGURED_ARCH).deb \ + python-thrift_$(THRIFT_VERSION)_$(CONFIGURED_ARCH).deb \ thrift-compiler_$(THRIFT_VERSION)_$(CONFIGURED_ARCH).deb THRIFT_LINK_PRE = https://archive.apache.org/dist/thrift