From 894fae92988266b471dcf3bc2311793e840615cd Mon Sep 17 00:00:00 2001 From: pettershao-ragilenetworks Date: Wed, 8 Feb 2023 15:42:40 +0800 Subject: [PATCH 1/2] ragile 6510 adapt to 202205 v1 --- .../azure-pipelines-image-template.yml | 3 +- .gitignore | 2 +- azure-pipelines.yml | 282 -- .../minigraph.xml | 63 - .../pddf/pddf-device.json | 112 +- .../RA-B6510-48V8C/port_config.ini | 114 +- .../RA-B6510-48V8C/port_config.ini_v1 | 57 + .../RA-B6510-48V8C/port_config.ini_v2 | 57 + .../RA-B6510-48V8C/sai.profile | 2 +- ...b6510-48vs8cq-48x25G+8x100G.config.bcm_v2} | 639 +-- ...d3-ra-b6510-48v8c-48x25G+8x100G.config.bcm | 574 +++ ...ra-b6510-48v8c-48x25G+8x100G.config.bcm_v1 | 402 ++ .../x86_64-ragile_ra-b6510-48v8c-r0/bcm.rc | 1 + .../custom_led.bin | Bin 300 -> 236 bytes .../custom_led.bin_v1 | Bin 0 -> 300 bytes .../custom_led.bin_v2.bin | Bin 0 -> 236 bytes .../installer.conf | 1 + .../led_proc_init.soc | 2 +- .../x86_64-ragile_ra-b6510-48v8c-r0/pcie.yaml | 21 +- .../pddf/pd-plugin.json | 3 +- .../pddf/pddf-device.json | 3528 ++++++++++------- .../plugins/eeprom.py | 25 + .../plugins/fanutil.py | 187 + .../plugins/ledutil.py | 59 + .../plugins/psuutil.py | 270 ++ .../plugins/sfputil.py | 236 ++ .../plugins/ssd_util.py | 309 ++ .../plugins/sysstatutil.py | 82 + .../plugins/thermalutil.py | 75 + .../pmon_daemon_control.json | 8 +- .../minigraph.xml | 63 - .../x86_64-ragile_ra-b6910-64c-r0/monitor.py | 1 + .../pddf/pddf-device.json | 134 +- .../plugins/fanutil.py | 16 +- .../pmon_daemon_control.json | 6 +- .../minigraph.xml | 63 - platform/broadcom/platform-modules-ragile.mk | 2 +- platform/broadcom/rules.mk | 2 +- .../common/Makefile | 5 +- .../common/lib/eepromutil/fantlv.py | 8 +- .../common/lib/eepromutil/fru.py | 6 +- .../common/modules/csu550.c | 47 +- .../common/modules/fpga_i2c_ocores.c | 11 +- .../common/modules/fpga_pcie_i2c.c | 47 +- .../common/modules/i2c-mux-pca954x.c | 438 +- .../common/modules/i2c-mux-pca9641.c | 16 +- .../common/modules/lpc_cpld_i2c_ocores.c | 22 +- .../common/modules/pmbus.h | 58 +- .../common/modules/ragile_common_module.c | 3 - .../common/modules/rg-i2c-algo-bit.c | 2 +- .../common/modules/rg_fan.c | 2 +- .../common/modules/rg_psu.c | 18 - .../common/script/avscontrol.py | 2 +- .../common/script/device_i2c.py | 2 +- .../common/script/fancontrol.py | 1352 ++----- .../common/script/interface.py | 88 + .../common/script/ragilecommon.py | 2 +- .../common/script/ragileutil.py | 16 +- .../common/service/device_i2c.service | 0 .../debian/compat | 2 +- ...atform-modules-ragile-ra-b6910-64c.install | 1 + ...tform-modules-ragile-ra-b6910-64c.postinst | 17 + .../ra-b6510-32c/Makefile | 5 +- .../ra-b6510-32c/config/fan_ctrl_cfg.json | 43 + .../x86_64_ragile_ra_b6510_32c_r0_config.py | 6 +- .../modules/driver/pddf_client_defs.h | 6 +- .../modules/driver/pddf_custom_led_module.c | 54 +- .../modules/driver/pddf_led_defs.h | 2 +- .../ra-b6510-32c/sonic_platform/api.py | 203 + .../ra-b6510-32c/sonic_platform/chassis.py | 119 +- .../ra-b6510-32c/sonic_platform/component.py | 72 +- .../ra-b6510-32c/sonic_platform/config.py | 5 + .../ra-b6510-32c/sonic_platform/fan.py | 3 +- .../ra-b6510-32c/sonic_platform/fan_drawer.py | 70 +- .../ra-b6510-32c/sonic_platform/hwaccess.py | 47 + .../ra-b6510-32c/sonic_platform/psu.py | 122 +- .../ra-b6510-32c/sonic_platform/sfp.py | 754 ++-- .../ra-b6510-32c/sonic_platform/sfp_config.py | 23 + .../ra-b6510-32c/sonic_platform/thermal.py | 4 +- .../ra-b6510-48v8c/Makefile | 5 +- .../ra-b6510-48v8c/config/fan_ctrl_cfg.json | 49 + .../x86_64_ragile_ra_b6510_48v8c_r0_config.py | 431 +- .../ra-b6510-48v8c/modules/driver/Makefile | 1 + .../ra-b6510-48v8c/modules/driver/ragile.h | 116 + .../ra-b6510-48v8c/modules/driver/rg_cpld.c | 746 ++-- .../modules/driver/rg_lpc_cpld.c | 235 ++ .../ra-b6510-48v8c/setup.py | 3 +- .../ra-b6510-48v8c/sonic_platform/__init__.py | 2 +- .../ra-b6510-48v8c/sonic_platform/api.py | 203 + .../ra-b6510-48v8c/sonic_platform/chassis.py | 146 +- .../sonic_platform/component.py | 78 +- .../ra-b6510-48v8c/sonic_platform/config.py | 7 +- .../ra-b6510-48v8c/sonic_platform/fan.py | 78 +- .../sonic_platform/fan_drawer.py | 72 +- .../ra-b6510-48v8c/sonic_platform/hwaccess.py | 47 + .../ra-b6510-48v8c/sonic_platform/pcie.py | 48 +- .../ra-b6510-48v8c/sonic_platform/psu.py | 122 +- .../ra-b6510-48v8c/sonic_platform/sfp.py | 526 ++- .../sonic_platform/sfp_config.py | 23 + .../sonic_platform/sfp_config_v1.py | 23 + .../sonic_platform/sfp_config_v2.py | 23 + .../ra-b6510-48v8c/sonic_platform/thermal.py | 4 +- .../ra-b6910-64c/Makefile | 5 +- .../ra-b6910-64c/config/fan_ctrl_cfg.json | 43 + .../x86_64_ragile_ra_b6910_64c_r0_config.py | 4 + .../ra-b6910-64c/setup.py | 3 +- .../sonic_pcie/__init__.py | 0 .../sonic_pcie/pcie_common.py | 0 .../ra-b6910-64c/sonic_platform/chassis.py | 44 +- .../ra-b6910-64c/sonic_platform/fan_drawer.py | 72 +- .../ra-b6910-64c/sonic_platform/pcie.py | 43 + .../ra-b6910-64c/sonic_platform/psu.py | 102 +- .../ra-b6910-64c/sonic_platform/sfp.py | 47 +- .../ra-b6910-64c/sonic_platform/thermal.py | 4 +- .../ra-b6920-4s/Makefile | 5 +- .../ra-b6920-4s/config/fan_ctrl_cfg.json | 43 + .../x86_64_ragile_ra_b6920_4s_r0_config.py | 4 +- .../ra-b6920-4s/modules/driver/Makefile | 16 +- .../modules/driver/pddf_custom_led_module.c | 42 +- .../ra-b6920-4s/modules/driver/rg_cpld.c | 2 +- .../ra-b6920-4s/sonic_platform/chassis.py | 15 +- .../ra-b6920-4s/sonic_platform/fan_drawer.py | 70 +- .../ra-b6920-4s/sonic_platform/psu.py | 94 + .../ra-b6920-4s/sonic_platform/sfp.py | 295 +- .../ra-b6920-4s/sonic_platform/thermal.py | 4 +- src/sonic-device-data/tests/permitted_list | 10 + 126 files changed, 9587 insertions(+), 5472 deletions(-) delete mode 100644 device/ragile/x86_64-ragile_ra-b6510-32c-r0/minigraph.xml create mode 100755 device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/RA-B6510-48V8C/port_config.ini_v1 create mode 100755 device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/RA-B6510-48V8C/port_config.ini_v2 rename device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/RA-B6510-48V8C/{td3-b6510-48vs8cq-48x25G+8x100G.config.bcm => td3-b6510-48vs8cq-48x25G+8x100G.config.bcm_v2} (67%) create mode 100644 device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/RA-B6510-48V8C/td3-ra-b6510-48v8c-48x25G+8x100G.config.bcm create mode 100644 device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/RA-B6510-48V8C/td3-ra-b6510-48v8c-48x25G+8x100G.config.bcm_v1 create mode 100644 device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/bcm.rc mode change 100644 => 100755 device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/custom_led.bin create mode 100644 device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/custom_led.bin_v1 create mode 100755 device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/custom_led.bin_v2.bin create mode 100755 device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/plugins/eeprom.py create mode 100755 device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/plugins/fanutil.py create mode 100755 device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/plugins/ledutil.py create mode 100755 device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/plugins/psuutil.py create mode 100755 device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/plugins/sfputil.py create mode 100755 device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/plugins/ssd_util.py create mode 100755 device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/plugins/sysstatutil.py create mode 100755 device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/plugins/thermalutil.py delete mode 100644 device/ragile/x86_64-ragile_ra-b6910-64c-r0/minigraph.xml delete mode 100644 device/ragile/x86_64-ragile_ra-b6920-4s-r0/minigraph.xml create mode 100644 platform/broadcom/sonic-platform-modules-ragile/common/script/interface.py mode change 100755 => 100644 platform/broadcom/sonic-platform-modules-ragile/common/service/device_i2c.service create mode 100644 platform/broadcom/sonic-platform-modules-ragile/debian/platform-modules-ragile-ra-b6910-64c.install create mode 100755 platform/broadcom/sonic-platform-modules-ragile/debian/platform-modules-ragile-ra-b6910-64c.postinst create mode 100644 platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/config/fan_ctrl_cfg.json create mode 100644 platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/api.py create mode 100644 platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/hwaccess.py create mode 100644 platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/sfp_config.py create mode 100644 platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/config/fan_ctrl_cfg.json create mode 100755 platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/modules/driver/ragile.h create mode 100755 platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/modules/driver/rg_lpc_cpld.c create mode 100755 platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/api.py create mode 100755 platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/hwaccess.py mode change 100644 => 100755 platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/pcie.py create mode 100644 platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/sfp_config.py create mode 100644 platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/sfp_config_v1.py create mode 100644 platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/sfp_config_v2.py create mode 100644 platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/config/fan_ctrl_cfg.json rename platform/broadcom/sonic-platform-modules-ragile/{ra-b6510-48v8c => ra-b6910-64c}/sonic_pcie/__init__.py (100%) rename platform/broadcom/sonic-platform-modules-ragile/{ra-b6510-48v8c => ra-b6910-64c}/sonic_pcie/pcie_common.py (100%) create mode 100644 platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/sonic_platform/pcie.py create mode 100644 platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/config/fan_ctrl_cfg.json diff --git a/.azure-pipelines/azure-pipelines-image-template.yml b/.azure-pipelines/azure-pipelines-image-template.yml index 67d75abc6887..f45cc54ed6cd 100644 --- a/.azure-pipelines/azure-pipelines-image-template.yml +++ b/.azure-pipelines/azure-pipelines-image-template.yml @@ -51,7 +51,8 @@ jobs: postSteps: - script: | mkdir -p $(Build.ArtifactStagingDirectory)/target - mv target/* $(Build.ArtifactStagingDirectory)/target/ + #mv target/* $(Build.ArtifactStagingDirectory)/target/ + mv target/*.bin $(Build.ArtifactStagingDirectory)/target/ displayName: Copy Artifacts condition: always() - publish: $(Build.ArtifactStagingDirectory) diff --git a/.gitignore b/.gitignore index 60c328d62289..090389701ba4 100644 --- a/.gitignore +++ b/.gitignore @@ -62,7 +62,7 @@ src/**/*.o platform/**/*.egg-info platform/**/*-none-any.whl platform/**/.pybuild -platform/**/debian/* +#platform/**/debian/* platform/**/build platform/**/*.ko platform/**/*.mod.c diff --git a/azure-pipelines.yml b/azure-pipelines.yml index b415bfb755c4..bb6e02917522 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -68,285 +68,3 @@ stages: - name: broadcom variables: swi_image: yes - - name: mellanox - - name: marvell-armhf - pool: sonicbld-armhf - timeoutInMinutes: 1200 - variables: - PLATFORM_ARCH: armhf - -- stage: Test - dependsOn: BuildVS - condition: and(succeeded(), and(ne(stageDependencies.BuildVS.outputs['vs.SetVar.SKIP_VSTEST'], 'YES'), in(dependencies.BuildVS.result, 'Succeeded', 'SucceededWithIssues'))) - variables: - - group: Testbed-Tools - - name: inventory - value: veos_vtb - - name: testbed_file - value: vtestbed.csv - - jobs: - - job: - pool: sonictest - displayName: "vstest" - timeoutInMinutes: 60 - steps: - - checkout: self - clean: true - submodules: recursive - displayName: 'Checkout code' - - - task: DownloadPipelineArtifact@2 - inputs: - source: specific - project: build - pipeline: 9 - artifact: sonic-swss-common.amd64.ubuntu20_04 - runVersion: 'latestFromBranch' - runBranch: 'refs/heads/master' - displayName: "Download sonic swss common deb packages" - - - task: DownloadPipelineArtifact@2 - inputs: - artifact: sonic-buildimage.vs - displayName: "Download sonic-buildimage.vs artifact" - - - script: | - set -x - sudo apt-get update - sudo apt-get install libyang0.16 -y - sudo dpkg -i --force-confask,confnew ../libswsscommon_1.0.0_amd64.deb - sudo dpkg -i ../python3-swsscommon_1.0.0_amd64.deb - sudo docker load -i ../target/docker-sonic-vs.gz - docker tag docker-sonic-vs:latest docker-sonic-vs:$(Build.BuildNumber) - username=$(id -un) - - trap "docker ps; docker images; ip netns list; \ - docker rmi docker-sonic-vs:$(Build.BuildNumber); \ - ip netns list | grep -E [-]srv[0-9]+ | awk '{print $1}' | xargs -I {} sudo ip netns delete {}; \ - sudo chown -R ${username}.${username} .; \ - sudo chown -R ${username}.${username} $(System.DefaultWorkingDirectory)" EXIT - pushd platform/vs/tests - sudo py.test -v --junitxml=tr.xml --imgname=docker-sonic-vs:$(Build.BuildNumber) - displayName: "Run vs tests" - - - task: PublishTestResults@2 - inputs: - testResultsFiles: '**/tr.xml' - testRunTitle: vstest - - - job: t0_part1 - pool: sonictest - displayName: "kvmtest-t0-part1" - timeoutInMinutes: 360 - condition: and(succeeded(), eq(variables.BUILD_IMG_RUN_CLASSICAL_TEST, 'YES')) - continueOnError: false - steps: - - template: .azure-pipelines/run-test-template.yml - parameters: - dut: vlab-01 - tbname: vms-kvm-t0 - ptf_name: ptf_vms6-1 - tbtype: t0 - section: part-1 - - - job: t0_part2 - pool: sonictest - displayName: "kvmtest-t0-part2" - timeoutInMinutes: 360 - condition: and(succeeded(), eq(variables.BUILD_IMG_RUN_CLASSICAL_TEST, 'YES')) - continueOnError: false - steps: - - template: .azure-pipelines/run-test-template.yml - parameters: - dut: vlab-01 - tbname: vms-kvm-t0 - ptf_name: ptf_vms6-1 - tbtype: t0 - section: part-2 - - - job: t0_testbedv2 - pool: - vmImage: 'ubuntu-20.04' - displayName: "kvmtest-t0 by TestbedV2" - 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: $(T0_INSTANCE_NUM) - MAX_WORKER: $(T0_INSTANCE_NUM) - MGMT_BRANCH: 202205 - - - job: t0_2vlans_testbedv2 - pool: - vmImage: 'ubuntu-20.04' - displayName: "kvmtest-t0-2vlans by TestbedV2" - 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 - TEST_SET: t0-2vlans - MIN_WORKER: $(T0_2VLANS_INSTANCE_NUM) - MAX_WORKER: $(T0_2VLANS_INSTANCE_NUM) - DEPLOY_MG_EXTRA_PARAMS: "-e vlan_config=two_vlan_a" - MGMT_BRANCH: 202205 - - - job: - pool: - vmImage: 'ubuntu-20.04' - displayName: "kvmtest-t0" - dependsOn: - - t0_part1 - - t0_part2 - - t0_testbedv2 - - t0_2vlans_testbedv2 - condition: always() - variables: - resultOfPart1: $[ dependencies.t0_part1.result ] - resultOfPart2: $[ dependencies.t0_part2.result ] - resultOfT0TestbedV2: $[ dependencies.t0_testbedv2.result ] - resultOfT02VlansTestbedV2: $[ dependencies.t0_2vlans_testbedv2.result ] - - steps: - - script: | - if [ $(resultOfT0TestbedV2) == "Succeeded" ] && [ $(resultOfT02VlansTestbedV2) == "Succeeded" ]; then - echo "TestbedV2 t0 passed." - exit 0 - fi - - if [ $(resultOfPart1) == "Succeeded" ] && [ $(resultOfPart2) == "Succeeded" ]; then - echo "Classic t0 jobs(both part1 and part2) passed." - exit 0 - fi - - echo "Both classic and TestbedV2 t0 jobs failed! Please check the detailed information. (Any of them passed, t0 will be considered as passed)" - exit 1 - - - job: t1_lag_classic - pool: sonictest-t1-lag - displayName: "kvmtest-t1-lag classic" - timeoutInMinutes: 360 - condition: and(succeeded(), eq(variables.BUILD_IMG_RUN_CLASSICAL_TEST, 'YES')) - continueOnError: false - steps: - - template: .azure-pipelines/run-test-template.yml - parameters: - dut: vlab-03 - tbname: vms-kvm-t1-lag - ptf_name: ptf_vms6-2 - tbtype: t1-lag - - - job: t1_lag_testbedv2 - pool: - vmImage: 'ubuntu-20.04' - displayName: "kvmtest-t1-lag by TestbedV2" - 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: $(T1_LAG_INSTANCE_NUM) - MAX_WORKER: $(T1_LAG_INSTANCE_NUM) - MGMT_BRANCH: 202205 - - - job: - pool: - vmImage: 'ubuntu-20.04' - displayName: "kvmtest-t1-lag" - dependsOn: - - t1_lag_classic - - t1_lag_testbedv2 - condition: always() - continueOnError: false - variables: - resultOfClassic: $[ dependencies.t1_lag_classic.result ] - resultOfTestbedV2: $[ dependencies.t1_lag_testbedv2.result ] - steps: - - script: | - if [ $(resultOfTestbedV2) == "Succeeded" ]; then - echo "TestbedV2 t1-lag passed." - exit 0 - fi - - if [ $(resultOfClassic) == "Succeeded" ]; then - echo "Classic t1-lag passed." - exit 0 - fi - - echo "Both classic and TestbedV2 t1-lag jobs failed! Please check the detailed information. (Any of them passed, t1-lag will be considered as passed)" - exit 1 - - - job: - pool: sonictest-sonic-t0 - displayName: "kvmtest-t0-sonic" - timeoutInMinutes: 360 - condition: and(succeeded(), eq(variables.BUILD_IMG_RUN_CLASSICAL_TEST, 'YES')) - - steps: - - template: .azure-pipelines/run-test-template.yml - parameters: - dut: vlab-02 - tbname: vms-kvm-t0-64-32 - ptf_name: ptf_vms6-1 - tbtype: t0-sonic - vmtype: vsonic - - - job: sonic_t0_testbedv2 - displayName: "kvmtest-t0-sonic by TestbedV2" - pool: - vmImage: 'ubuntu-20.04' - 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-64-32 - 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\"]}' - MGMT_BRANCH: 202205 - - - job: dualtor_testbedv2 - pool: - vmImage: 'ubuntu-20.04' - displayName: "kvmtest-dualtor-t0 by TestbedV2" - 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: $(T0_DUALTOR_INSTANCE_NUM) - MAX_WORKER: $(T0_DUALTOR_INSTANCE_NUM) - COMMON_EXTRA_PARAMS: "--disable_loganalyzer " - MGMT_BRANCH: 202205 - - - job: multi_asic_testbedv2 - displayName: "kvmtest-multi-asic-t1-lag by TestbedV2" - pool: - vmImage: 'ubuntu-20.04' - timeoutInMinutes: 1080 - 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-8-lag - TEST_SET: multi-asic-t1-lag - MIN_WORKER: 1 - MAX_WORKER: 1 - NUM_ASIC: 4 - MGMT_BRANCH: 202205 diff --git a/device/ragile/x86_64-ragile_ra-b6510-32c-r0/minigraph.xml b/device/ragile/x86_64-ragile_ra-b6510-32c-r0/minigraph.xml deleted file mode 100644 index d33d99d6e76f..000000000000 --- a/device/ragile/x86_64-ragile_ra-b6510-32c-r0/minigraph.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - - - switch2 - - - - - - - - - - - - - switch2 - RA-B6510-32C - - - - - - - switch2 - - - DhcpResources - - - - - NtpResources - - 0.debian.pool.ntp.org;1.debian.pool.ntp.org;2.debian.pool.ntp.org;3.debian.pool.ntp.org - - - SyslogResources - - - - - ErspanDestinationIpv4 - - 2.2.2.2 - - - - - - - switch2 - RA-B6510-32C - diff --git a/device/ragile/x86_64-ragile_ra-b6510-32c-r0/pddf/pddf-device.json b/device/ragile/x86_64-ragile_ra-b6510-32c-r0/pddf/pddf-device.json index 0f337006edad..dba51a48438e 100755 --- a/device/ragile/x86_64-ragile_ra-b6510-32c-r0/pddf/pddf-device.json +++ b/device/ragile/x86_64-ragile_ra-b6510-32c-r0/pddf/pddf-device.json @@ -33,7 +33,7 @@ "i2c_mux", "rg_gpio_xeon", "i2c_mux_pca9641", - "i2c_mux_pca954x force_create_bus=1", + "i2c_mux_pca954x force_create_bus=1 close_chan_force_reset=1 select_chan_check=1", "ragile_common dfd_my_type=0x404b", "fpga_pcie_i2c ocore_ctl_startbus=2", "lpc_dbg", @@ -882,15 +882,6 @@ "attr_cmpval": "0x0", "attr_len": "1" }, - { - "attr_name": "psu_model_name", - "attr_devaddr": "0x58", - "attr_devtype": "pmbus", - "attr_offset": "0x9a", - "attr_mask": "0x0", - "attr_cmpval": "0xff", - "attr_len": "12" - }, { "attr_name": "psu_power_good", "attr_devtype": "io", @@ -987,6 +978,15 @@ "attr_mask": "0x0", "attr_cmpval": "0xff", "attr_len": "20" + }, + { + "attr_name": "psu_model_name", + "attr_devaddr": "0x50", + "attr_devtype": "eeprom", + "attr_offset": "0x25", + "attr_mask": "0x0", + "attr_cmpval": "0xff", + "attr_len": "15" }] } }, @@ -1035,15 +1035,6 @@ "attr_cmpval": "0x0", "attr_len": "1" }, - { - "attr_name": "psu_model_name", - "attr_devaddr": "0x58", - "attr_devtype": "pmbus", - "attr_offset": "0x9a", - "attr_mask": "0x0", - "attr_cmpval": "0xff", - "attr_len": "12" - }, { "attr_name": "psu_power_good", "attr_devtype": "io", @@ -1140,6 +1131,15 @@ "attr_mask": "0x0", "attr_cmpval": "0xff", "attr_len": "20" + }, + { + "attr_name": "psu_model_name", + "attr_devaddr": "0x50", + "attr_devtype": "eeprom", + "attr_offset": "0x25", + "attr_mask": "0x0", + "attr_cmpval": "0xff", + "attr_len": "15" }] } }, @@ -1610,6 +1610,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1", "attr_devaddr": "0x30", "attr_devtype": "cpld", "attr_offset": "0x10", @@ -1618,6 +1619,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_reset", + "attr_devname": "MAC_BOARD_CPLD1", "attr_devaddr": "0x30", "attr_devtype": "cpld", "attr_offset": "0x14", @@ -1682,6 +1684,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1", "attr_devaddr": "0x30", "attr_devtype": "cpld", "attr_offset": "0x10", @@ -1690,6 +1693,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_reset", + "attr_devname": "MAC_BOARD_CPLD1", "attr_devaddr": "0x30", "attr_devtype": "cpld", "attr_offset": "0x14", @@ -1754,6 +1758,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1", "attr_devaddr": "0x30", "attr_devtype": "cpld", "attr_offset": "0x10", @@ -1762,6 +1767,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_reset", + "attr_devname": "MAC_BOARD_CPLD1", "attr_devaddr": "0x30", "attr_devtype": "cpld", "attr_offset": "0x14", @@ -1827,6 +1833,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1", "attr_devaddr": "0x30", "attr_devtype": "cpld", "attr_offset": "0x10", @@ -1835,6 +1842,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_reset", + "attr_devname": "MAC_BOARD_CPLD1", "attr_devaddr": "0x30", "attr_devtype": "cpld", "attr_offset": "0x14", @@ -1900,6 +1908,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1", "attr_devaddr": "0x30", "attr_devtype": "cpld", "attr_offset": "0x10", @@ -1908,6 +1917,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_reset", + "attr_devname": "MAC_BOARD_CPLD1", "attr_devaddr": "0x30", "attr_devtype": "cpld", "attr_offset": "0x14", @@ -1973,6 +1983,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1", "attr_devaddr": "0x30", "attr_devtype": "cpld", "attr_offset": "0x10", @@ -1981,6 +1992,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_reset", + "attr_devname": "MAC_BOARD_CPLD1", "attr_devaddr": "0x30", "attr_devtype": "cpld", "attr_offset": "0x14", @@ -2045,6 +2057,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1", "attr_devaddr": "0x30", "attr_devtype": "cpld", "attr_offset": "0x30", @@ -2053,6 +2066,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_reset", + "attr_devname": "MAC_BOARD_CPLD1", "attr_devaddr": "0x30", "attr_devtype": "cpld", "attr_offset": "0x14", @@ -2117,6 +2131,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1", "attr_devaddr": "0x30", "attr_devtype": "cpld", "attr_offset": "0x10", @@ -2125,6 +2140,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_reset", + "attr_devname": "MAC_BOARD_CPLD1", "attr_devaddr": "0x30", "attr_devtype": "cpld", "attr_offset": "0x14", @@ -2189,6 +2205,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1", "attr_devaddr": "0x30", "attr_devtype": "cpld", "attr_offset": "0x11", @@ -2197,6 +2214,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_reset", + "attr_devname": "MAC_BOARD_CPLD1", "attr_devaddr": "0x30", "attr_devtype": "cpld", "attr_offset": "0x15", @@ -2261,6 +2279,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1", "attr_devaddr": "0x30", "attr_devtype": "cpld", "attr_offset": "0x11", @@ -2269,6 +2288,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_reset", + "attr_devname": "MAC_BOARD_CPLD1", "attr_devaddr": "0x30", "attr_devtype": "cpld", "attr_offset": "0x15", @@ -2334,6 +2354,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1", "attr_devaddr": "0x30", "attr_devtype": "cpld", "attr_offset": "0x11", @@ -2342,6 +2363,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_reset", + "attr_devname": "MAC_BOARD_CPLD1", "attr_devaddr": "0x30", "attr_devtype": "cpld", "attr_offset": "0x15", @@ -2407,6 +2429,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1", "attr_devaddr": "0x30", "attr_devtype": "cpld", "attr_offset": "0x11", @@ -2415,6 +2438,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_reset", + "attr_devname": "MAC_BOARD_CPLD1", "attr_devaddr": "0x30", "attr_devtype": "cpld", "attr_offset": "0x15", @@ -2480,6 +2504,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1", "attr_devaddr": "0x30", "attr_devtype": "cpld", "attr_offset": "0x11", @@ -2488,6 +2513,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_reset", + "attr_devname": "MAC_BOARD_CPLD1", "attr_devaddr": "0x30", "attr_devtype": "cpld", "attr_offset": "0x15", @@ -2553,6 +2579,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1", "attr_devaddr": "0x30", "attr_devtype": "cpld", "attr_offset": "0x11", @@ -2561,6 +2588,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_reset", + "attr_devname": "MAC_BOARD_CPLD1", "attr_devaddr": "0x30", "attr_devtype": "cpld", "attr_offset": "0x15", @@ -2625,6 +2653,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1", "attr_devaddr": "0x30", "attr_devtype": "cpld", "attr_offset": "0x11", @@ -2633,6 +2662,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_reset", + "attr_devname": "MAC_BOARD_CPLD1", "attr_devaddr": "0x30", "attr_devtype": "cpld", "attr_offset": "0x15", @@ -2697,6 +2727,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1", "attr_devaddr": "0x30", "attr_devtype": "cpld", "attr_offset": "0x11", @@ -2705,6 +2736,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_reset", + "attr_devname": "MAC_BOARD_CPLD1", "attr_devaddr": "0x30", "attr_devtype": "cpld", "attr_offset": "0x15", @@ -2769,6 +2801,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2", "attr_devaddr": "0x31", "attr_devtype": "cpld", "attr_offset": "0x10", @@ -2777,6 +2810,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_reset", + "attr_devname": "MAC_BOARD_CPLD2", "attr_devaddr": "0x31", "attr_devtype": "cpld", "attr_offset": "0x14", @@ -2841,6 +2875,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2", "attr_devaddr": "0x31", "attr_devtype": "cpld", "attr_offset": "0x10", @@ -2849,6 +2884,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_reset", + "attr_devname": "MAC_BOARD_CPLD2", "attr_devaddr": "0x31", "attr_devtype": "cpld", "attr_offset": "0x14", @@ -2914,6 +2950,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2", "attr_devaddr": "0x31", "attr_devtype": "cpld", "attr_offset": "0x10", @@ -2922,6 +2959,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_reset", + "attr_devname": "MAC_BOARD_CPLD2", "attr_devaddr": "0x31", "attr_devtype": "cpld", "attr_offset": "0x14", @@ -2987,6 +3025,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2", "attr_devaddr": "0x31", "attr_devtype": "cpld", "attr_offset": "0x10", @@ -2995,6 +3034,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_reset", + "attr_devname": "MAC_BOARD_CPLD2", "attr_devaddr": "0x31", "attr_devtype": "cpld", "attr_offset": "0x14", @@ -3060,6 +3100,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2", "attr_devaddr": "0x31", "attr_devtype": "cpld", "attr_offset": "0x10", @@ -3068,6 +3109,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_reset", + "attr_devname": "MAC_BOARD_CPLD2", "attr_devaddr": "0x31", "attr_devtype": "cpld", "attr_offset": "0x14", @@ -3133,6 +3175,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2", "attr_devaddr": "0x31", "attr_devtype": "cpld", "attr_offset": "0x10", @@ -3141,6 +3184,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_reset", + "attr_devname": "MAC_BOARD_CPLD2", "attr_devaddr": "0x31", "attr_devtype": "cpld", "attr_offset": "0x14", @@ -3205,6 +3249,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2", "attr_devaddr": "0x31", "attr_devtype": "cpld", "attr_offset": "0x10", @@ -3213,6 +3258,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_reset", + "attr_devname": "MAC_BOARD_CPLD2", "attr_devaddr": "0x31", "attr_devtype": "cpld", "attr_offset": "0x14", @@ -3277,6 +3323,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2", "attr_devaddr": "0x31", "attr_devtype": "cpld", "attr_offset": "0x10", @@ -3285,6 +3332,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_reset", + "attr_devname": "MAC_BOARD_CPLD2", "attr_devaddr": "0x31", "attr_devtype": "cpld", "attr_offset": "0x14", @@ -3349,6 +3397,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2", "attr_devaddr": "0x31", "attr_devtype": "cpld", "attr_offset": "0x11", @@ -3357,6 +3406,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_reset", + "attr_devname": "MAC_BOARD_CPLD2", "attr_devaddr": "0x31", "attr_devtype": "cpld", "attr_offset": "0x15", @@ -3421,6 +3471,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2", "attr_devaddr": "0x31", "attr_devtype": "cpld", "attr_offset": "0x11", @@ -3429,6 +3480,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_reset", + "attr_devname": "MAC_BOARD_CPLD2", "attr_devaddr": "0x31", "attr_devtype": "cpld", "attr_offset": "0x15", @@ -3494,6 +3546,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2", "attr_devaddr": "0x31", "attr_devtype": "cpld", "attr_offset": "0x11", @@ -3502,6 +3555,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_reset", + "attr_devname": "MAC_BOARD_CPLD2", "attr_devaddr": "0x31", "attr_devtype": "cpld", "attr_offset": "0x15", @@ -3567,6 +3621,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2", "attr_devaddr": "0x31", "attr_devtype": "cpld", "attr_offset": "0x11", @@ -3575,6 +3630,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_reset", + "attr_devname": "MAC_BOARD_CPLD2", "attr_devaddr": "0x31", "attr_devtype": "cpld", "attr_offset": "0x15", @@ -3640,6 +3696,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2", "attr_devaddr": "0x31", "attr_devtype": "cpld", "attr_offset": "0x11", @@ -3648,6 +3705,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_reset", + "attr_devname": "MAC_BOARD_CPLD2", "attr_devaddr": "0x31", "attr_devtype": "cpld", "attr_offset": "0x15", @@ -3713,6 +3771,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2", "attr_devaddr": "0x31", "attr_devtype": "cpld", "attr_offset": "0x11", @@ -3721,6 +3780,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_reset", + "attr_devname": "MAC_BOARD_CPLD2", "attr_devaddr": "0x31", "attr_devtype": "cpld", "attr_offset": "0x15", @@ -3785,6 +3845,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2", "attr_devaddr": "0x31", "attr_devtype": "cpld", "attr_offset": "0x11", @@ -3793,6 +3854,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_reset", + "attr_devname": "MAC_BOARD_CPLD2", "attr_devaddr": "0x31", "attr_devtype": "cpld", "attr_offset": "0x15", @@ -3857,6 +3919,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2", "attr_devaddr": "0x31", "attr_devtype": "cpld", "attr_offset": "0x11", @@ -3865,6 +3928,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_reset", + "attr_devname": "MAC_BOARD_CPLD2", "attr_devaddr": "0x31", "attr_devtype": "cpld", "attr_offset": "0x15", @@ -4124,7 +4188,7 @@ } }, - "FANTRAY1_LED": { + "FAN1_LED": { "dev_info": { "device_type": "LED", "device_name": "FANTRAY_LED" @@ -4193,7 +4257,7 @@ } }, - "FANTRAY2_LED": { + "FAN2_LED": { "dev_info": { "device_type": "LED", "device_name": "FANTRAY_LED" @@ -4262,7 +4326,7 @@ } }, - "FANTRAY3_LED": { + "FAN3_LED": { "dev_info": { "device_type": "LED", "device_name": "FANTRAY_LED" @@ -4331,7 +4395,7 @@ } }, - "FANTRAY4_LED": { + "FAN4_LED": { "dev_info": { "device_type": "LED", "device_name": "FANTRAY_LED" @@ -4400,7 +4464,7 @@ } }, - "FANTRAY5_LED": { + "FAN5_LED": { "dev_info": { "device_type": "LED", "device_name": "FANTRAY_LED" diff --git a/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/RA-B6510-48V8C/port_config.ini b/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/RA-B6510-48V8C/port_config.ini index 823f53160c33..b71ad39648c9 100755 --- a/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/RA-B6510-48V8C/port_config.ini +++ b/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/RA-B6510-48V8C/port_config.ini @@ -1,57 +1,57 @@ -# name lanes alias index speed admin_status -Ethernet1 1 twentyfiveGigE0/1 0 25000 up -Ethernet2 2 twentyfiveGigE0/2 1 25000 up -Ethernet3 3 twentyfiveGigE0/3 2 25000 up -Ethernet4 4 twentyfiveGigE0/4 3 25000 up -Ethernet5 5 twentyfiveGigE0/5 4 25000 up -Ethernet6 6 twentyfiveGigE0/6 5 25000 up -Ethernet7 7 twentyfiveGigE0/7 6 25000 up -Ethernet8 8 twentyfiveGigE0/8 7 25000 up -Ethernet9 13 twentyfiveGigE0/9 8 25000 up -Ethernet10 14 twentyfiveGigE0/10 9 25000 up -Ethernet11 15 twentyfiveGigE0/11 10 25000 up -Ethernet12 16 twentyfiveGigE0/12 11 25000 up -Ethernet13 21 twentyfiveGigE0/13 12 25000 up -Ethernet14 22 twentyfiveGigE0/14 13 25000 up -Ethernet15 23 twentyfiveGigE0/15 14 25000 up -Ethernet16 24 twentyfiveGigE0/16 15 25000 up -Ethernet17 29 twentyfiveGigE0/17 16 25000 up -Ethernet18 30 twentyfiveGigE0/18 17 25000 up -Ethernet19 31 twentyfiveGigE0/19 18 25000 up -Ethernet20 32 twentyfiveGigE0/20 19 25000 up -Ethernet21 33 twentyfiveGigE0/21 20 25000 up -Ethernet22 34 twentyfiveGigE0/22 21 25000 up -Ethernet23 35 twentyfiveGigE0/23 22 25000 up -Ethernet24 36 twentyfiveGigE0/24 23 25000 up -Ethernet25 41 twentyfiveGigE0/25 24 25000 up -Ethernet26 42 twentyfiveGigE0/26 25 25000 up -Ethernet27 43 twentyfiveGigE0/27 26 25000 up -Ethernet28 44 twentyfiveGigE0/28 27 25000 up -Ethernet29 49 twentyfiveGigE0/29 28 25000 up -Ethernet30 50 twentyfiveGigE0/30 29 25000 up -Ethernet31 51 twentyfiveGigE0/31 30 25000 up -Ethernet32 52 twentyfiveGigE0/32 31 25000 up -Ethernet33 57 twentyfiveGigE0/33 32 25000 up -Ethernet34 58 twentyfiveGigE0/34 33 25000 up -Ethernet35 59 twentyfiveGigE0/35 34 25000 up -Ethernet36 60 twentyfiveGigE0/36 35 25000 up -Ethernet37 61 twentyfiveGigE0/37 36 25000 up -Ethernet38 62 twentyfiveGigE0/38 37 25000 up -Ethernet39 63 twentyfiveGigE0/39 38 25000 up -Ethernet40 64 twentyfiveGigE0/40 39 25000 up -Ethernet41 65 twentyfiveGigE0/41 40 25000 up -Ethernet42 66 twentyfiveGigE0/42 41 25000 up -Ethernet43 67 twentyfiveGigE0/43 42 25000 up -Ethernet44 68 twentyfiveGigE0/44 43 25000 up -Ethernet45 69 twentyfiveGigE0/45 44 25000 up -Ethernet46 70 twentyfiveGigE0/46 45 25000 up -Ethernet47 71 twentyfiveGigE0/47 46 25000 up -Ethernet48 72 twentyfiveGigE0/48 47 25000 up -Ethernet49 85,86,87,88 hundredGigE0/1 48 100000 up -Ethernet50 77,78,79,80 hundredGigE0/2 49 100000 up -Ethernet51 97,98,99,100 hundredGigE0/3 50 100000 up -Ethernet52 93,94,95,96 hundredGigE0/4 51 100000 up -Ethernet53 113,114,115,116 hundredGigE0/5 52 100000 up -Ethernet54 105,106,107,108 hundredGigE0/6 53 100000 up -Ethernet55 121,122,123,124 hundredGigE0/7 54 100000 up -Ethernet56 125,126,127,128 hundredGigE0/8 55 100000 up +# name lanes alias index speed admin_status +Ethernet1 57 twentyfiveGigE0/1 1 25000 up +Ethernet2 58 twentyfiveGigE0/2 2 25000 up +Ethernet3 59 twentyfiveGigE0/3 3 25000 up +Ethernet4 60 twentyfiveGigE0/4 4 25000 up +Ethernet5 61 twentyfiveGigE0/5 5 25000 up +Ethernet6 62 twentyfiveGigE0/6 6 25000 up +Ethernet7 63 twentyfiveGigE0/7 7 25000 up +Ethernet8 64 twentyfiveGigE0/8 8 25000 up +Ethernet9 1 twentyfiveGigE0/9 9 25000 up +Ethernet10 2 twentyfiveGigE0/10 10 25000 up +Ethernet11 3 twentyfiveGigE0/11 11 25000 up +Ethernet12 4 twentyfiveGigE0/12 12 25000 up +Ethernet13 5 twentyfiveGigE0/13 13 25000 up +Ethernet14 6 twentyfiveGigE0/14 14 25000 up +Ethernet15 7 twentyfiveGigE0/15 15 25000 up +Ethernet16 8 twentyfiveGigE0/16 16 25000 up +Ethernet17 13 twentyfiveGigE0/17 17 25000 up +Ethernet18 14 twentyfiveGigE0/18 18 25000 up +Ethernet19 15 twentyfiveGigE0/19 19 25000 up +Ethernet20 16 twentyfiveGigE0/20 20 25000 up +Ethernet21 21 twentyfiveGigE0/21 21 25000 up +Ethernet22 22 twentyfiveGigE0/22 22 25000 up +Ethernet23 23 twentyfiveGigE0/23 23 25000 up +Ethernet24 24 twentyfiveGigE0/24 24 25000 up +Ethernet25 29 twentyfiveGigE0/25 25 25000 up +Ethernet26 30 twentyfiveGigE0/26 26 25000 up +Ethernet27 31 twentyfiveGigE0/27 27 25000 up +Ethernet28 32 twentyfiveGigE0/28 28 25000 up +Ethernet29 33 twentyfiveGigE0/29 29 25000 up +Ethernet30 34 twentyfiveGigE0/30 30 25000 up +Ethernet31 35 twentyfiveGigE0/31 31 25000 up +Ethernet32 36 twentyfiveGigE0/32 32 25000 up +Ethernet33 41 twentyfiveGigE0/33 33 25000 up +Ethernet34 42 twentyfiveGigE0/34 34 25000 up +Ethernet35 43 twentyfiveGigE0/35 35 25000 up +Ethernet36 44 twentyfiveGigE0/36 36 25000 up +Ethernet37 49 twentyfiveGigE0/37 37 25000 up +Ethernet38 50 twentyfiveGigE0/38 38 25000 up +Ethernet39 51 twentyfiveGigE0/39 39 25000 up +Ethernet40 52 twentyfiveGigE0/40 40 25000 up +Ethernet41 65 twentyfiveGigE0/41 41 25000 up +Ethernet42 66 twentyfiveGigE0/42 42 25000 up +Ethernet43 67 twentyfiveGigE0/43 43 25000 up +Ethernet44 68 twentyfiveGigE0/44 44 25000 up +Ethernet45 69 twentyfiveGigE0/45 45 25000 up +Ethernet46 70 twentyfiveGigE0/46 46 25000 up +Ethernet47 71 twentyfiveGigE0/47 47 25000 up +Ethernet48 72 twentyfiveGigE0/48 48 25000 up +Ethernet49 85,86,87,88 hundredGigE0/1 49 100000 up +Ethernet50 77,78,79,80 hundredGigE0/2 50 100000 up +Ethernet51 97,98,99,100 hundredGigE0/3 51 100000 up +Ethernet52 93,94,95,96 hundredGigE0/4 52 100000 up +Ethernet53 113,114,115,116 hundredGigE0/5 53 100000 up +Ethernet54 105,106,107,108 hundredGigE0/6 54 100000 up +Ethernet55 121,122,123,124 hundredGigE0/7 55 100000 up +Ethernet56 125,126,127,128 hundredGigE0/8 56 100000 up diff --git a/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/RA-B6510-48V8C/port_config.ini_v1 b/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/RA-B6510-48V8C/port_config.ini_v1 new file mode 100755 index 000000000000..823f53160c33 --- /dev/null +++ b/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/RA-B6510-48V8C/port_config.ini_v1 @@ -0,0 +1,57 @@ +# name lanes alias index speed admin_status +Ethernet1 1 twentyfiveGigE0/1 0 25000 up +Ethernet2 2 twentyfiveGigE0/2 1 25000 up +Ethernet3 3 twentyfiveGigE0/3 2 25000 up +Ethernet4 4 twentyfiveGigE0/4 3 25000 up +Ethernet5 5 twentyfiveGigE0/5 4 25000 up +Ethernet6 6 twentyfiveGigE0/6 5 25000 up +Ethernet7 7 twentyfiveGigE0/7 6 25000 up +Ethernet8 8 twentyfiveGigE0/8 7 25000 up +Ethernet9 13 twentyfiveGigE0/9 8 25000 up +Ethernet10 14 twentyfiveGigE0/10 9 25000 up +Ethernet11 15 twentyfiveGigE0/11 10 25000 up +Ethernet12 16 twentyfiveGigE0/12 11 25000 up +Ethernet13 21 twentyfiveGigE0/13 12 25000 up +Ethernet14 22 twentyfiveGigE0/14 13 25000 up +Ethernet15 23 twentyfiveGigE0/15 14 25000 up +Ethernet16 24 twentyfiveGigE0/16 15 25000 up +Ethernet17 29 twentyfiveGigE0/17 16 25000 up +Ethernet18 30 twentyfiveGigE0/18 17 25000 up +Ethernet19 31 twentyfiveGigE0/19 18 25000 up +Ethernet20 32 twentyfiveGigE0/20 19 25000 up +Ethernet21 33 twentyfiveGigE0/21 20 25000 up +Ethernet22 34 twentyfiveGigE0/22 21 25000 up +Ethernet23 35 twentyfiveGigE0/23 22 25000 up +Ethernet24 36 twentyfiveGigE0/24 23 25000 up +Ethernet25 41 twentyfiveGigE0/25 24 25000 up +Ethernet26 42 twentyfiveGigE0/26 25 25000 up +Ethernet27 43 twentyfiveGigE0/27 26 25000 up +Ethernet28 44 twentyfiveGigE0/28 27 25000 up +Ethernet29 49 twentyfiveGigE0/29 28 25000 up +Ethernet30 50 twentyfiveGigE0/30 29 25000 up +Ethernet31 51 twentyfiveGigE0/31 30 25000 up +Ethernet32 52 twentyfiveGigE0/32 31 25000 up +Ethernet33 57 twentyfiveGigE0/33 32 25000 up +Ethernet34 58 twentyfiveGigE0/34 33 25000 up +Ethernet35 59 twentyfiveGigE0/35 34 25000 up +Ethernet36 60 twentyfiveGigE0/36 35 25000 up +Ethernet37 61 twentyfiveGigE0/37 36 25000 up +Ethernet38 62 twentyfiveGigE0/38 37 25000 up +Ethernet39 63 twentyfiveGigE0/39 38 25000 up +Ethernet40 64 twentyfiveGigE0/40 39 25000 up +Ethernet41 65 twentyfiveGigE0/41 40 25000 up +Ethernet42 66 twentyfiveGigE0/42 41 25000 up +Ethernet43 67 twentyfiveGigE0/43 42 25000 up +Ethernet44 68 twentyfiveGigE0/44 43 25000 up +Ethernet45 69 twentyfiveGigE0/45 44 25000 up +Ethernet46 70 twentyfiveGigE0/46 45 25000 up +Ethernet47 71 twentyfiveGigE0/47 46 25000 up +Ethernet48 72 twentyfiveGigE0/48 47 25000 up +Ethernet49 85,86,87,88 hundredGigE0/1 48 100000 up +Ethernet50 77,78,79,80 hundredGigE0/2 49 100000 up +Ethernet51 97,98,99,100 hundredGigE0/3 50 100000 up +Ethernet52 93,94,95,96 hundredGigE0/4 51 100000 up +Ethernet53 113,114,115,116 hundredGigE0/5 52 100000 up +Ethernet54 105,106,107,108 hundredGigE0/6 53 100000 up +Ethernet55 121,122,123,124 hundredGigE0/7 54 100000 up +Ethernet56 125,126,127,128 hundredGigE0/8 55 100000 up diff --git a/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/RA-B6510-48V8C/port_config.ini_v2 b/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/RA-B6510-48V8C/port_config.ini_v2 new file mode 100755 index 000000000000..b71ad39648c9 --- /dev/null +++ b/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/RA-B6510-48V8C/port_config.ini_v2 @@ -0,0 +1,57 @@ +# name lanes alias index speed admin_status +Ethernet1 57 twentyfiveGigE0/1 1 25000 up +Ethernet2 58 twentyfiveGigE0/2 2 25000 up +Ethernet3 59 twentyfiveGigE0/3 3 25000 up +Ethernet4 60 twentyfiveGigE0/4 4 25000 up +Ethernet5 61 twentyfiveGigE0/5 5 25000 up +Ethernet6 62 twentyfiveGigE0/6 6 25000 up +Ethernet7 63 twentyfiveGigE0/7 7 25000 up +Ethernet8 64 twentyfiveGigE0/8 8 25000 up +Ethernet9 1 twentyfiveGigE0/9 9 25000 up +Ethernet10 2 twentyfiveGigE0/10 10 25000 up +Ethernet11 3 twentyfiveGigE0/11 11 25000 up +Ethernet12 4 twentyfiveGigE0/12 12 25000 up +Ethernet13 5 twentyfiveGigE0/13 13 25000 up +Ethernet14 6 twentyfiveGigE0/14 14 25000 up +Ethernet15 7 twentyfiveGigE0/15 15 25000 up +Ethernet16 8 twentyfiveGigE0/16 16 25000 up +Ethernet17 13 twentyfiveGigE0/17 17 25000 up +Ethernet18 14 twentyfiveGigE0/18 18 25000 up +Ethernet19 15 twentyfiveGigE0/19 19 25000 up +Ethernet20 16 twentyfiveGigE0/20 20 25000 up +Ethernet21 21 twentyfiveGigE0/21 21 25000 up +Ethernet22 22 twentyfiveGigE0/22 22 25000 up +Ethernet23 23 twentyfiveGigE0/23 23 25000 up +Ethernet24 24 twentyfiveGigE0/24 24 25000 up +Ethernet25 29 twentyfiveGigE0/25 25 25000 up +Ethernet26 30 twentyfiveGigE0/26 26 25000 up +Ethernet27 31 twentyfiveGigE0/27 27 25000 up +Ethernet28 32 twentyfiveGigE0/28 28 25000 up +Ethernet29 33 twentyfiveGigE0/29 29 25000 up +Ethernet30 34 twentyfiveGigE0/30 30 25000 up +Ethernet31 35 twentyfiveGigE0/31 31 25000 up +Ethernet32 36 twentyfiveGigE0/32 32 25000 up +Ethernet33 41 twentyfiveGigE0/33 33 25000 up +Ethernet34 42 twentyfiveGigE0/34 34 25000 up +Ethernet35 43 twentyfiveGigE0/35 35 25000 up +Ethernet36 44 twentyfiveGigE0/36 36 25000 up +Ethernet37 49 twentyfiveGigE0/37 37 25000 up +Ethernet38 50 twentyfiveGigE0/38 38 25000 up +Ethernet39 51 twentyfiveGigE0/39 39 25000 up +Ethernet40 52 twentyfiveGigE0/40 40 25000 up +Ethernet41 65 twentyfiveGigE0/41 41 25000 up +Ethernet42 66 twentyfiveGigE0/42 42 25000 up +Ethernet43 67 twentyfiveGigE0/43 43 25000 up +Ethernet44 68 twentyfiveGigE0/44 44 25000 up +Ethernet45 69 twentyfiveGigE0/45 45 25000 up +Ethernet46 70 twentyfiveGigE0/46 46 25000 up +Ethernet47 71 twentyfiveGigE0/47 47 25000 up +Ethernet48 72 twentyfiveGigE0/48 48 25000 up +Ethernet49 85,86,87,88 hundredGigE0/1 49 100000 up +Ethernet50 77,78,79,80 hundredGigE0/2 50 100000 up +Ethernet51 97,98,99,100 hundredGigE0/3 51 100000 up +Ethernet52 93,94,95,96 hundredGigE0/4 52 100000 up +Ethernet53 113,114,115,116 hundredGigE0/5 53 100000 up +Ethernet54 105,106,107,108 hundredGigE0/6 54 100000 up +Ethernet55 121,122,123,124 hundredGigE0/7 55 100000 up +Ethernet56 125,126,127,128 hundredGigE0/8 56 100000 up diff --git a/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/RA-B6510-48V8C/sai.profile b/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/RA-B6510-48V8C/sai.profile index 042c8060d587..352e8c50b053 100755 --- a/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/RA-B6510-48V8C/sai.profile +++ b/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/RA-B6510-48V8C/sai.profile @@ -1 +1 @@ -SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/td3-b6510-48vs8cq-48x25G+8x100G.config.bcm +SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/td3-ra-b6510-48v8c-48x25G+8x100G.config.bcm diff --git a/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/RA-B6510-48V8C/td3-b6510-48vs8cq-48x25G+8x100G.config.bcm b/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/RA-B6510-48V8C/td3-b6510-48vs8cq-48x25G+8x100G.config.bcm_v2 similarity index 67% rename from device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/RA-B6510-48V8C/td3-b6510-48vs8cq-48x25G+8x100G.config.bcm rename to device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/RA-B6510-48V8C/td3-b6510-48vs8cq-48x25G+8x100G.config.bcm_v2 index 69fd8c362987..86f90570b3a8 100644 --- a/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/RA-B6510-48V8C/td3-b6510-48vs8cq-48x25G+8x100G.config.bcm +++ b/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/RA-B6510-48V8C/td3-b6510-48vs8cq-48x25G+8x100G.config.bcm_v2 @@ -18,211 +18,62 @@ memlist_enable=1 miim_intr_enable=0 module_64ports=1 oversubscribe_mode=1 +parity_correction=1 parity_enable=1 pbmp_gport_stack.0=0x0000000000000000000000000000000000000000000000000000000000000000 #pbmp_xport_xe.0=0x00000000000000000000000000000000888ffffffffffff9fffffffffffffffe -pbmp_xport_xe=0x488080808808087f9fe1e1e1fe1e1e1fe -phy_chain_rx_lane_map_physical{1.0}=0x1032 +pbmp_xport_xe=0xffffffffffffffffffffffffffffffffffffffffe +port_flex_enable=1 +phy_chain_tx_lane_map_physical{57.0}=0x0123 +phy_chain_tx_lane_map_physical{61.0}=0x0123 phy_chain_tx_lane_map_physical{1.0}=0x0123 -phy_chain_rx_lane_map_physical{5.0}=0x1032 phy_chain_tx_lane_map_physical{5.0}=0x0123 -phy_chain_rx_lane_map_physical{13.0}=0x1032 phy_chain_tx_lane_map_physical{13.0}=0x0123 -phy_chain_rx_lane_map_physical{21.0}=0x1032 phy_chain_tx_lane_map_physical{21.0}=0x0123 -phy_chain_rx_lane_map_physical{29.0}=0x1032 phy_chain_tx_lane_map_physical{29.0}=0x0123 -phy_chain_rx_lane_map_physical{33.0}=0x1032 phy_chain_tx_lane_map_physical{33.0}=0x0123 -phy_chain_rx_lane_map_physical{41.0}=0x1032 phy_chain_tx_lane_map_physical{41.0}=0x0123 -phy_chain_rx_lane_map_physical{49.0}=0x1032 phy_chain_tx_lane_map_physical{49.0}=0x0123 +phy_chain_tx_lane_map_physical{65.0}=0x3210 +phy_chain_tx_lane_map_physical{69.0}=0x3210 +phy_chain_tx_lane_map_physical{85.0}=0x3210 +phy_chain_tx_lane_map_physical{77.0}=0x0213 +phy_chain_tx_lane_map_physical{97.0}=0x3210 +phy_chain_tx_lane_map_physical{93.0}=0x0213 +phy_chain_tx_lane_map_physical{113.0}=0x3210 +phy_chain_tx_lane_map_physical{105.0}=0x0213 +phy_chain_tx_lane_map_physical{121.0}=0x3120 +phy_chain_tx_lane_map_physical{125.0}=0x1203 + phy_chain_rx_lane_map_physical{57.0}=0x1032 -phy_chain_tx_lane_map_physical{57.0}=0x0123 phy_chain_rx_lane_map_physical{61.0}=0x1032 -phy_chain_tx_lane_map_physical{61.0}=0x0123 +phy_chain_rx_lane_map_physical{1.0}=0x1032 +phy_chain_rx_lane_map_physical{5.0}=0x1032 +phy_chain_rx_lane_map_physical{13.0}=0x1032 +phy_chain_rx_lane_map_physical{21.0}=0x1032 +phy_chain_rx_lane_map_physical{29.0}=0x1032 +phy_chain_rx_lane_map_physical{33.0}=0x1032 +phy_chain_rx_lane_map_physical{41.0}=0x1032 +phy_chain_rx_lane_map_physical{49.0}=0x1032 phy_chain_rx_lane_map_physical{65.0}=0x2301 -phy_chain_tx_lane_map_physical{65.0}=0x3210 phy_chain_rx_lane_map_physical{69.0}=0x2301 -phy_chain_tx_lane_map_physical{69.0}=0x3210 -phy_chain_rx_lane_map_physical{77.0}=0x1032 -phy_chain_tx_lane_map_physical{77.0}=0x3210 phy_chain_rx_lane_map_physical{85.0}=0x1032 -phy_chain_tx_lane_map_physical{85.0}=0x3210 -phy_chain_rx_lane_map_physical{93.0}=0x1032 -phy_chain_tx_lane_map_physical{93.0}=0x3210 +phy_chain_rx_lane_map_physical{77.0}=0x1032 phy_chain_rx_lane_map_physical{97.0}=0x1032 -phy_chain_tx_lane_map_physical{97.0}=0x3210 -phy_chain_rx_lane_map_physical{105.0}=0x1032 -phy_chain_tx_lane_map_physical{105.0}=0x3210 +phy_chain_rx_lane_map_physical{93.0}=0x1032 phy_chain_rx_lane_map_physical{113.0}=0x1032 -phy_chain_tx_lane_map_physical{113.0}=0x3210 +phy_chain_rx_lane_map_physical{105.0}=0x1032 phy_chain_rx_lane_map_physical{121.0}=0x2031 -phy_chain_tx_lane_map_physical{121.0}=0x3210 -phy_chain_rx_lane_map_physical{125.0}=0x1032 -phy_chain_tx_lane_map_physical{125.0}=0x1203 -phy_chain_tx_polarity_flip_physical{1.0}=0x1 -phy_chain_rx_polarity_flip_physical{1.0}=0x0 -phy_chain_tx_polarity_flip_physical{2.0}=0x0 -phy_chain_rx_polarity_flip_physical{2.0}=0x0 -phy_chain_tx_polarity_flip_physical{3.0}=0x1 -phy_chain_rx_polarity_flip_physical{3.0}=0x0 -phy_chain_tx_polarity_flip_physical{4.0}=0x0 -phy_chain_rx_polarity_flip_physical{4.0}=0x0 -phy_chain_tx_polarity_flip_physical{5.0}=0x1 -phy_chain_rx_polarity_flip_physical{5.0}=0x0 -phy_chain_tx_polarity_flip_physical{6.0}=0x0 -phy_chain_rx_polarity_flip_physical{6.0}=0x0 -phy_chain_tx_polarity_flip_physical{7.0}=0x1 -phy_chain_rx_polarity_flip_physical{7.0}=0x0 -phy_chain_tx_polarity_flip_physical{8.0}=0x0 -phy_chain_rx_polarity_flip_physical{8.0}=0x0 -phy_chain_tx_polarity_flip_physical{13.0}=0x0 -phy_chain_rx_polarity_flip_physical{13.0}=0x0 -phy_chain_tx_polarity_flip_physical{14.0}=0x0 -phy_chain_rx_polarity_flip_physical{14.0}=0x0 -phy_chain_tx_polarity_flip_physical{15.0}=0x0 -phy_chain_rx_polarity_flip_physical{15.0}=0x0 -phy_chain_tx_polarity_flip_physical{16.0}=0x0 -phy_chain_rx_polarity_flip_physical{16.0}=0x0 -phy_chain_tx_polarity_flip_physical{21.0}=0x1 -phy_chain_rx_polarity_flip_physical{21.0}=0x0 -phy_chain_tx_polarity_flip_physical{22.0}=0x0 -phy_chain_rx_polarity_flip_physical{22.0}=0x0 -phy_chain_tx_polarity_flip_physical{23.0}=0x1 -phy_chain_rx_polarity_flip_physical{23.0}=0x0 -phy_chain_tx_polarity_flip_physical{24.0}=0x0 -phy_chain_rx_polarity_flip_physical{24.0}=0x0 -phy_chain_tx_polarity_flip_physical{29.0}=0x0 -phy_chain_rx_polarity_flip_physical{29.0}=0x1 -phy_chain_tx_polarity_flip_physical{30.0}=0x0 -phy_chain_rx_polarity_flip_physical{30.0}=0x1 -phy_chain_tx_polarity_flip_physical{31.0}=0x0 -phy_chain_rx_polarity_flip_physical{31.0}=0x1 -phy_chain_tx_polarity_flip_physical{32.0}=0x0 -phy_chain_rx_polarity_flip_physical{32.0}=0x1 -phy_chain_tx_polarity_flip_physical{33.0}=0x0 -phy_chain_rx_polarity_flip_physical{33.0}=0x0 -phy_chain_tx_polarity_flip_physical{34.0}=0x0 -phy_chain_rx_polarity_flip_physical{34.0}=0x0 -phy_chain_tx_polarity_flip_physical{35.0}=0x0 -phy_chain_rx_polarity_flip_physical{35.0}=0x0 -phy_chain_tx_polarity_flip_physical{36.0}=0x0 -phy_chain_rx_polarity_flip_physical{36.0}=0x0 -phy_chain_tx_polarity_flip_physical{41.0}=0x0 -phy_chain_rx_polarity_flip_physical{41.0}=0x0 -phy_chain_tx_polarity_flip_physical{42.0}=0x0 -phy_chain_rx_polarity_flip_physical{42.0}=0x0 -phy_chain_tx_polarity_flip_physical{43.0}=0x0 -phy_chain_rx_polarity_flip_physical{43.0}=0x0 -phy_chain_tx_polarity_flip_physical{44.0}=0x0 -phy_chain_rx_polarity_flip_physical{44.0}=0x0 -phy_chain_tx_polarity_flip_physical{49.0}=0x0 -phy_chain_rx_polarity_flip_physical{49.0}=0x0 -phy_chain_tx_polarity_flip_physical{50.0}=0x0 -phy_chain_rx_polarity_flip_physical{50.0}=0x0 -phy_chain_tx_polarity_flip_physical{51.0}=0x0 -phy_chain_rx_polarity_flip_physical{51.0}=0x0 -phy_chain_tx_polarity_flip_physical{52.0}=0x0 -phy_chain_rx_polarity_flip_physical{52.0}=0x0 -phy_chain_tx_polarity_flip_physical{57.0}=0x0 -phy_chain_rx_polarity_flip_physical{57.0}=0x0 -phy_chain_tx_polarity_flip_physical{58.0}=0x0 -phy_chain_rx_polarity_flip_physical{58.0}=0x0 -phy_chain_tx_polarity_flip_physical{59.0}=0x0 -phy_chain_rx_polarity_flip_physical{59.0}=0x0 -phy_chain_tx_polarity_flip_physical{60.0}=0x0 -phy_chain_rx_polarity_flip_physical{60.0}=0x0 -phy_chain_tx_polarity_flip_physical{61.0}=0x0 -phy_chain_rx_polarity_flip_physical{61.0}=0x1 -phy_chain_tx_polarity_flip_physical{62.0}=0x0 -phy_chain_rx_polarity_flip_physical{62.0}=0x1 -phy_chain_tx_polarity_flip_physical{63.0}=0x0 -phy_chain_rx_polarity_flip_physical{63.0}=0x1 -phy_chain_tx_polarity_flip_physical{64.0}=0x0 -phy_chain_rx_polarity_flip_physical{64.0}=0x1 -phy_chain_tx_polarity_flip_physical{65.0}=0x0 -phy_chain_rx_polarity_flip_physical{65.0}=0x1 -phy_chain_tx_polarity_flip_physical{66.0}=0x0 -phy_chain_rx_polarity_flip_physical{66.0}=0x1 -phy_chain_tx_polarity_flip_physical{67.0}=0x0 -phy_chain_rx_polarity_flip_physical{67.0}=0x1 -phy_chain_tx_polarity_flip_physical{68.0}=0x0 -phy_chain_rx_polarity_flip_physical{68.0}=0x1 -phy_chain_tx_polarity_flip_physical{69.0}=0x0 -phy_chain_rx_polarity_flip_physical{69.0}=0x0 -phy_chain_tx_polarity_flip_physical{70.0}=0x0 -phy_chain_rx_polarity_flip_physical{70.0}=0x0 -phy_chain_tx_polarity_flip_physical{71.0}=0x0 -phy_chain_rx_polarity_flip_physical{71.0}=0x0 -phy_chain_tx_polarity_flip_physical{72.0}=0x0 -phy_chain_rx_polarity_flip_physical{72.0}=0x0 -phy_chain_tx_polarity_flip_physical{85.0}=0x1 -phy_chain_rx_polarity_flip_physical{85.0}=0x1 -phy_chain_tx_polarity_flip_physical{86.0}=0x0 -phy_chain_rx_polarity_flip_physical{86.0}=0x1 -phy_chain_tx_polarity_flip_physical{87.0}=0x1 -phy_chain_rx_polarity_flip_physical{87.0}=0x1 -phy_chain_tx_polarity_flip_physical{88.0}=0x0 -phy_chain_rx_polarity_flip_physical{88.0}=0x1 -phy_chain_tx_polarity_flip_physical{77.0}=0x1 -phy_chain_rx_polarity_flip_physical{77.0}=0x1 -phy_chain_tx_polarity_flip_physical{78.0}=0x1 -phy_chain_rx_polarity_flip_physical{78.0}=0x0 -phy_chain_tx_polarity_flip_physical{79.0}=0x1 -phy_chain_rx_polarity_flip_physical{79.0}=0x1 -phy_chain_tx_polarity_flip_physical{80.0}=0x1 -phy_chain_rx_polarity_flip_physical{80.0}=0x1 -phy_chain_tx_polarity_flip_physical{97.0}=0x1 -phy_chain_rx_polarity_flip_physical{97.0}=0x0 -phy_chain_tx_polarity_flip_physical{98.0}=0x0 -phy_chain_rx_polarity_flip_physical{98.0}=0x0 -phy_chain_tx_polarity_flip_physical{99.0}=0x1 -phy_chain_rx_polarity_flip_physical{99.0}=0x0 -phy_chain_tx_polarity_flip_physical{100.0}=0x0 -phy_chain_rx_polarity_flip_physical{100.0}=0x0 -phy_chain_tx_polarity_flip_physical{93.0}=0x1 -phy_chain_rx_polarity_flip_physical{93.0}=0x1 -phy_chain_tx_polarity_flip_physical{94.0}=0x1 -phy_chain_rx_polarity_flip_physical{94.0}=0x0 -phy_chain_tx_polarity_flip_physical{95.0}=0x1 -phy_chain_rx_polarity_flip_physical{95.0}=0x1 -phy_chain_tx_polarity_flip_physical{96.0}=0x1 -phy_chain_rx_polarity_flip_physical{96.0}=0x1 -phy_chain_tx_polarity_flip_physical{113.0}=0x1 -phy_chain_rx_polarity_flip_physical{113.0}=0x1 -phy_chain_tx_polarity_flip_physical{114.0}=0x0 -phy_chain_rx_polarity_flip_physical{114.0}=0x1 -phy_chain_tx_polarity_flip_physical{115.0}=0x1 -phy_chain_rx_polarity_flip_physical{115.0}=0x1 -phy_chain_tx_polarity_flip_physical{116.0}=0x0 -phy_chain_rx_polarity_flip_physical{116.0}=0x1 -phy_chain_tx_polarity_flip_physical{105.0}=0x1 -phy_chain_rx_polarity_flip_physical{105.0}=0x1 -phy_chain_tx_polarity_flip_physical{106.0}=0x1 -phy_chain_rx_polarity_flip_physical{106.0}=0x0 -phy_chain_tx_polarity_flip_physical{107.0}=0x1 -phy_chain_rx_polarity_flip_physical{107.0}=0x1 -phy_chain_tx_polarity_flip_physical{108.0}=0x1 -phy_chain_rx_polarity_flip_physical{108.0}=0x1 -phy_chain_tx_polarity_flip_physical{121.0}=0x1 -phy_chain_rx_polarity_flip_physical{121.0}=0x1 -phy_chain_tx_polarity_flip_physical{122.0}=0x0 -phy_chain_rx_polarity_flip_physical{122.0}=0x0 -phy_chain_tx_polarity_flip_physical{123.0}=0x1 -phy_chain_rx_polarity_flip_physical{123.0}=0x0 -phy_chain_tx_polarity_flip_physical{124.0}=0x0 -phy_chain_rx_polarity_flip_physical{124.0}=0x1 -phy_chain_tx_polarity_flip_physical{125.0}=0x0 -phy_chain_rx_polarity_flip_physical{125.0}=0x0 -phy_chain_tx_polarity_flip_physical{126.0}=0x1 -phy_chain_rx_polarity_flip_physical{126.0}=0x1 -phy_chain_tx_polarity_flip_physical{127.0}=0x0 -phy_chain_rx_polarity_flip_physical{127.0}=0x0 -phy_chain_tx_polarity_flip_physical{128.0}=0x0 -phy_chain_rx_polarity_flip_physical{128.0}=0x0 -port_flex_enable=1 +phy_chain_rx_lane_map_physical{125.0}=0x1023 + +portmap_57=57:25 +portmap_58=58:25 +portmap_59=59:25 +portmap_60=60:25 +portmap_61=61:25 +portmap_62=62:25 +portmap_63=63:25 +portmap_64=64:25 portmap_1=1:25 portmap_2=2:25 portmap_3=3:25 @@ -255,14 +106,6 @@ portmap_49=49:25 portmap_50=50:25 portmap_51=51:25 portmap_52=52:25 -portmap_57=57:25 -portmap_58=58:25 -portmap_59=59:25 -portmap_60=60:25 -portmap_61=61:25 -portmap_62=62:25 -portmap_63=63:25 -portmap_64=64:25 portmap_67=65:25 portmap_68=66:25 portmap_69=67:25 @@ -271,55 +114,55 @@ portmap_71=69:25 portmap_72=70:25 portmap_73=71:25 portmap_74=72:25 -portmap_79=77:100 portmap_87=85:100 -portmap_95=93:100 +portmap_79=77:100 portmap_99=97:100 -portmap_107=105:100 +portmap_95=93:100 portmap_115=113:100 +portmap_107=105:100 portmap_123=121:100 portmap_127=125:100 -dport_map_port_1=1 -dport_map_port_2=2 -dport_map_port_3=3 -dport_map_port_4=4 -dport_map_port_5=5 -dport_map_port_6=6 -dport_map_port_7=7 -dport_map_port_8=8 -dport_map_port_13=9 -dport_map_port_14=10 -dport_map_port_15=11 -dport_map_port_16=12 -dport_map_port_21=13 -dport_map_port_22=14 -dport_map_port_23=15 -dport_map_port_24=16 -dport_map_port_29=17 -dport_map_port_30=18 -dport_map_port_31=19 -dport_map_port_32=20 -dport_map_port_33=21 -dport_map_port_34=22 -dport_map_port_35=23 -dport_map_port_36=24 -dport_map_port_41=25 -dport_map_port_42=26 -dport_map_port_43=27 -dport_map_port_44=28 -dport_map_port_49=29 -dport_map_port_50=30 -dport_map_port_51=31 -dport_map_port_52=32 -dport_map_port_57=33 -dport_map_port_58=34 -dport_map_port_59=35 -dport_map_port_60=36 -dport_map_port_61=37 -dport_map_port_62=38 -dport_map_port_63=39 -dport_map_port_64=40 +dport_map_port_57=1 +dport_map_port_58=2 +dport_map_port_59=3 +dport_map_port_60=4 +dport_map_port_61=5 +dport_map_port_62=6 +dport_map_port_63=7 +dport_map_port_64=8 +dport_map_port_1=9 +dport_map_port_2=10 +dport_map_port_3=11 +dport_map_port_4=12 +dport_map_port_5=13 +dport_map_port_6=14 +dport_map_port_7=15 +dport_map_port_8=16 +dport_map_port_13=17 +dport_map_port_14=18 +dport_map_port_15=19 +dport_map_port_16=20 +dport_map_port_21=21 +dport_map_port_22=22 +dport_map_port_23=23 +dport_map_port_24=24 +dport_map_port_29=25 +dport_map_port_30=26 +dport_map_port_31=27 +dport_map_port_32=28 +dport_map_port_33=29 +dport_map_port_34=30 +dport_map_port_35=31 +dport_map_port_36=32 +dport_map_port_41=33 +dport_map_port_42=34 +dport_map_port_43=35 +dport_map_port_44=36 +dport_map_port_49=37 +dport_map_port_50=38 +dport_map_port_51=39 +dport_map_port_52=40 dport_map_port_67=41 dport_map_port_68=42 dport_map_port_69=43 @@ -337,50 +180,244 @@ dport_map_port_107=54 dport_map_port_123=55 dport_map_port_127=56 +phy_chain_tx_polarity_flip_physical{57.0}=0x1 +phy_chain_tx_polarity_flip_physical{58.0}=0x0 +phy_chain_tx_polarity_flip_physical{59.0}=0x1 +phy_chain_tx_polarity_flip_physical{60.0}=0x0 +phy_chain_tx_polarity_flip_physical{61.0}=0x1 +phy_chain_tx_polarity_flip_physical{62.0}=0x0 +phy_chain_tx_polarity_flip_physical{63.0}=0x1 +phy_chain_tx_polarity_flip_physical{64.0}=0x0 +phy_chain_tx_polarity_flip_physical{1.0}=0x0 +phy_chain_tx_polarity_flip_physical{2.0}=0x0 +phy_chain_tx_polarity_flip_physical{3.0}=0x0 +phy_chain_tx_polarity_flip_physical{4.0}=0x0 +phy_chain_tx_polarity_flip_physical{5.0}=0x0 +phy_chain_tx_polarity_flip_physical{6.0}=0x0 +phy_chain_tx_polarity_flip_physical{7.0}=0x0 +phy_chain_tx_polarity_flip_physical{8.0}=0x0 +phy_chain_tx_polarity_flip_physical{13.0}=0x0 +phy_chain_tx_polarity_flip_physical{14.0}=0x0 +phy_chain_tx_polarity_flip_physical{15.0}=0x0 +phy_chain_tx_polarity_flip_physical{16.0}=0x0 +phy_chain_tx_polarity_flip_physical{21.0}=0x0 +phy_chain_tx_polarity_flip_physical{22.0}=0x0 +phy_chain_tx_polarity_flip_physical{23.0}=0x0 +phy_chain_tx_polarity_flip_physical{24.0}=0x0 +phy_chain_tx_polarity_flip_physical{29.0}=0x0 +phy_chain_tx_polarity_flip_physical{30.0}=0x0 +phy_chain_tx_polarity_flip_physical{31.0}=0x0 +phy_chain_tx_polarity_flip_physical{32.0}=0x0 +phy_chain_tx_polarity_flip_physical{33.0}=0x0 +phy_chain_tx_polarity_flip_physical{34.0}=0x0 +phy_chain_tx_polarity_flip_physical{35.0}=0x0 +phy_chain_tx_polarity_flip_physical{36.0}=0x0 +phy_chain_tx_polarity_flip_physical{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{49.0}=0x0 +phy_chain_tx_polarity_flip_physical{50.0}=0x0 +phy_chain_tx_polarity_flip_physical{51.0}=0x0 +phy_chain_tx_polarity_flip_physical{52.0}=0x0 +phy_chain_tx_polarity_flip_physical{65.0}=0x0 +phy_chain_tx_polarity_flip_physical{66.0}=0x0 +phy_chain_tx_polarity_flip_physical{67.0}=0x0 +phy_chain_tx_polarity_flip_physical{68.0}=0x0 +phy_chain_tx_polarity_flip_physical{69.0}=0x0 +phy_chain_tx_polarity_flip_physical{70.0}=0x0 +phy_chain_tx_polarity_flip_physical{71.0}=0x0 +phy_chain_tx_polarity_flip_physical{72.0}=0x0 +phy_chain_tx_polarity_flip_physical{85.0}=0x0 +phy_chain_tx_polarity_flip_physical{86.0}=0x0 +phy_chain_tx_polarity_flip_physical{87.0}=0x1 +phy_chain_tx_polarity_flip_physical{88.0}=0x0 +phy_chain_tx_polarity_flip_physical{77.0}=0x1 +phy_chain_tx_polarity_flip_physical{78.0}=0x0 +phy_chain_tx_polarity_flip_physical{79.0}=0x1 +phy_chain_tx_polarity_flip_physical{80.0}=0x0 +phy_chain_tx_polarity_flip_physical{97.0}=0x0 +phy_chain_tx_polarity_flip_physical{98.0}=0x0 +phy_chain_tx_polarity_flip_physical{99.0}=0x1 +phy_chain_tx_polarity_flip_physical{100.0}=0x0 +phy_chain_tx_polarity_flip_physical{93.0}=0x0 +phy_chain_tx_polarity_flip_physical{94.0}=0x1 +phy_chain_tx_polarity_flip_physical{95.0}=0x1 +phy_chain_tx_polarity_flip_physical{96.0}=0x0 +phy_chain_tx_polarity_flip_physical{113.0}=0x0 +phy_chain_tx_polarity_flip_physical{114.0}=0x0 +phy_chain_tx_polarity_flip_physical{115.0}=0x1 +phy_chain_tx_polarity_flip_physical{116.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}=0x0 +phy_chain_tx_polarity_flip_physical{121.0}=0x1 +phy_chain_tx_polarity_flip_physical{122.0}=0x0 +phy_chain_tx_polarity_flip_physical{123.0}=0x1 +phy_chain_tx_polarity_flip_physical{124.0}=0x0 +phy_chain_tx_polarity_flip_physical{125.0}=0x1 +phy_chain_tx_polarity_flip_physical{126.0}=0x0 +phy_chain_tx_polarity_flip_physical{127.0}=0x1 +phy_chain_tx_polarity_flip_physical{128.0}=0x1 + +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}=0x0 +phy_chain_rx_polarity_flip_physical{60.0}=0x0 +phy_chain_rx_polarity_flip_physical{61.0}=0x1 +phy_chain_rx_polarity_flip_physical{62.0}=0x1 +phy_chain_rx_polarity_flip_physical{63.0}=0x1 +phy_chain_rx_polarity_flip_physical{64.0}=0x1 +phy_chain_rx_polarity_flip_physical{1.0}=0x1 +phy_chain_rx_polarity_flip_physical{2.0}=0x1 +phy_chain_rx_polarity_flip_physical{3.0}=0x1 +phy_chain_rx_polarity_flip_physical{4.0}=0x1 +phy_chain_rx_polarity_flip_physical{5.0}=0x0 +phy_chain_rx_polarity_flip_physical{6.0}=0x0 +phy_chain_rx_polarity_flip_physical{7.0}=0x0 +phy_chain_rx_polarity_flip_physical{8.0}=0x0 +phy_chain_rx_polarity_flip_physical{13.0}=0x0 +phy_chain_rx_polarity_flip_physical{14.0}=0x0 +phy_chain_rx_polarity_flip_physical{15.0}=0x0 +phy_chain_rx_polarity_flip_physical{16.0}=0x0 +phy_chain_rx_polarity_flip_physical{21.0}=0x0 +phy_chain_rx_polarity_flip_physical{22.0}=0x0 +phy_chain_rx_polarity_flip_physical{23.0}=0x0 +phy_chain_rx_polarity_flip_physical{24.0}=0x0 +phy_chain_rx_polarity_flip_physical{29.0}=0x0 +phy_chain_rx_polarity_flip_physical{30.0}=0x1 +phy_chain_rx_polarity_flip_physical{31.0}=0x0 +phy_chain_rx_polarity_flip_physical{32.0}=0x0 +phy_chain_rx_polarity_flip_physical{33.0}=0x1 +phy_chain_rx_polarity_flip_physical{34.0}=0x1 +phy_chain_rx_polarity_flip_physical{35.0}=0x1 +phy_chain_rx_polarity_flip_physical{36.0}=0x1 +phy_chain_rx_polarity_flip_physical{41.0}=0x1 +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{49.0}=0x1 +phy_chain_rx_polarity_flip_physical{50.0}=0x1 +phy_chain_rx_polarity_flip_physical{51.0}=0x1 +phy_chain_rx_polarity_flip_physical{52.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}=0x1 +phy_chain_rx_polarity_flip_physical{68.0}=0x1 +phy_chain_rx_polarity_flip_physical{69.0}=0x0 +phy_chain_rx_polarity_flip_physical{70.0}=0x0 +phy_chain_rx_polarity_flip_physical{71.0}=0x0 +phy_chain_rx_polarity_flip_physical{72.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}=0x1 +phy_chain_rx_polarity_flip_physical{88.0}=0x1 +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}=0x0 +phy_chain_rx_polarity_flip_physical{80.0}=0x0 +phy_chain_rx_polarity_flip_physical{97.0}=0x0 +phy_chain_rx_polarity_flip_physical{98.0}=0x0 +phy_chain_rx_polarity_flip_physical{99.0}=0x0 +phy_chain_rx_polarity_flip_physical{100.0}=0x0 +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}=0x0 +phy_chain_rx_polarity_flip_physical{96.0}=0x0 +phy_chain_rx_polarity_flip_physical{113.0}=0x1 +phy_chain_rx_polarity_flip_physical{114.0}=0x1 +phy_chain_rx_polarity_flip_physical{115.0}=0x1 +phy_chain_rx_polarity_flip_physical{116.0}=0x1 +phy_chain_rx_polarity_flip_physical{105.0}=0x0 +phy_chain_rx_polarity_flip_physical{106.0}=0x0 +phy_chain_rx_polarity_flip_physical{107.0}=0x0 +phy_chain_rx_polarity_flip_physical{108.0}=0x0 +phy_chain_rx_polarity_flip_physical{121.0}=0x1 +phy_chain_rx_polarity_flip_physical{122.0}=0x1 +phy_chain_rx_polarity_flip_physical{123.0}=0x0 +phy_chain_rx_polarity_flip_physical{124.0}=0x1 +phy_chain_rx_polarity_flip_physical{125.0}=0x1 +phy_chain_rx_polarity_flip_physical{126.0}=0x0 +phy_chain_rx_polarity_flip_physical{127.0}=0x0 +phy_chain_rx_polarity_flip_physical{128.0}=0x0 + +serdes_preemphasis_lane0_57=0x0f480d +serdes_preemphasis_lane1_57=0x0f480d +serdes_preemphasis_lane2_57=0x0f480d +serdes_preemphasis_lane3_57=0x0f480d +serdes_preemphasis_lane0_58=0x0f480d +serdes_preemphasis_lane1_58=0x0f480d +serdes_preemphasis_lane2_58=0x0f480d +serdes_preemphasis_lane3_58=0x0f480d +serdes_preemphasis_lane0_59=0x0f480d +serdes_preemphasis_lane1_59=0x0f480d +serdes_preemphasis_lane2_59=0x0f480d +serdes_preemphasis_lane3_59=0x0f480d +serdes_preemphasis_lane0_60=0x0f480d +serdes_preemphasis_lane1_60=0x0f480d +serdes_preemphasis_lane2_60=0x0f480d +serdes_preemphasis_lane3_60=0x0f480d +serdes_preemphasis_lane0_61=0x0f480d +serdes_preemphasis_lane1_61=0x0f480d +serdes_preemphasis_lane2_61=0x0f480d +serdes_preemphasis_lane3_61=0x0f480d +serdes_preemphasis_lane0_62=0x0f480d +serdes_preemphasis_lane1_62=0x0f480d +serdes_preemphasis_lane2_62=0x0f480d +serdes_preemphasis_lane3_62=0x0f480d +serdes_preemphasis_lane0_63=0x0f480d +serdes_preemphasis_lane1_63=0x0f480d +serdes_preemphasis_lane2_63=0x0f480d +serdes_preemphasis_lane3_63=0x0f480d +serdes_preemphasis_lane0_64=0x0f480d +serdes_preemphasis_lane1_64=0x0f480d +serdes_preemphasis_lane2_64=0x0f480d +serdes_preemphasis_lane3_64=0x0f480d serdes_preemphasis_lane0_1=0x0f480d serdes_preemphasis_lane1_1=0x0f480d serdes_preemphasis_lane2_1=0x0f480d serdes_preemphasis_lane3_1=0x0f480d -serdes_preemphasis_lane0_2=0x0f480d -serdes_preemphasis_lane1_2=0x0f480d -serdes_preemphasis_lane2_2=0x0f480d -serdes_preemphasis_lane3_2=0x0f480d +serdes_preemphasis_lane0_2=0x0d4b0c +serdes_preemphasis_lane1_2=0x0d4b0c +serdes_preemphasis_lane2_2=0x0d4b0c +serdes_preemphasis_lane3_2=0x0d4b0c serdes_preemphasis_lane0_3=0x0f480d serdes_preemphasis_lane1_3=0x0f480d serdes_preemphasis_lane2_3=0x0f480d serdes_preemphasis_lane3_3=0x0f480d -serdes_preemphasis_lane0_4=0x0f480d -serdes_preemphasis_lane1_4=0x0f480d -serdes_preemphasis_lane2_4=0x0f480d -serdes_preemphasis_lane3_4=0x0f480d +serdes_preemphasis_lane0_4=0x0d4b0c +serdes_preemphasis_lane1_4=0x0d4b0c +serdes_preemphasis_lane2_4=0x0d4b0c +serdes_preemphasis_lane3_4=0x0d4b0c serdes_preemphasis_lane0_5=0x0f480d serdes_preemphasis_lane1_5=0x0f480d serdes_preemphasis_lane2_5=0x0f480d serdes_preemphasis_lane3_5=0x0f480d -serdes_preemphasis_lane0_6=0x0f480d -serdes_preemphasis_lane1_6=0x0f480d -serdes_preemphasis_lane2_6=0x0f480d -serdes_preemphasis_lane3_6=0x0f480d -serdes_preemphasis_lane0_7=0x0d4b0c -serdes_preemphasis_lane1_7=0x0d4b0c -serdes_preemphasis_lane2_7=0x0d4b0c -serdes_preemphasis_lane3_7=0x0d4b0c +serdes_preemphasis_lane0_6=0x0d4b0c +serdes_preemphasis_lane1_6=0x0d4b0c +serdes_preemphasis_lane2_6=0x0d4b0c +serdes_preemphasis_lane3_6=0x0d4b0c +serdes_preemphasis_lane0_7=0x0f480d +serdes_preemphasis_lane1_7=0x0f480d +serdes_preemphasis_lane2_7=0x0f480d +serdes_preemphasis_lane3_7=0x0f480d serdes_preemphasis_lane0_8=0x0d4b0c serdes_preemphasis_lane1_8=0x0d4b0c serdes_preemphasis_lane2_8=0x0d4b0c serdes_preemphasis_lane3_8=0x0d4b0c -serdes_preemphasis_lane0_13=0x0d4b0c -serdes_preemphasis_lane1_13=0x0d4b0c -serdes_preemphasis_lane2_13=0x0d4b0c -serdes_preemphasis_lane3_13=0x0d4b0c +serdes_preemphasis_lane0_13=0x0f480d +serdes_preemphasis_lane1_13=0x0f480d +serdes_preemphasis_lane2_13=0x0f480d +serdes_preemphasis_lane3_13=0x0f480d serdes_preemphasis_lane0_14=0x0d4b0c serdes_preemphasis_lane1_14=0x0d4b0c serdes_preemphasis_lane2_14=0x0d4b0c serdes_preemphasis_lane3_14=0x0d4b0c -serdes_preemphasis_lane0_15=0x0d4b0c -serdes_preemphasis_lane1_15=0x0d4b0c -serdes_preemphasis_lane2_15=0x0d4b0c -serdes_preemphasis_lane3_15=0x0d4b0c +serdes_preemphasis_lane0_15=0x0f480d +serdes_preemphasis_lane1_15=0x0f480d +serdes_preemphasis_lane2_15=0x0f480d +serdes_preemphasis_lane3_15=0x0f480d serdes_preemphasis_lane0_16=0x0d4b0c serdes_preemphasis_lane1_16=0x0d4b0c serdes_preemphasis_lane2_16=0x0d4b0c @@ -449,54 +486,22 @@ serdes_preemphasis_lane0_44=0x0d4b0c serdes_preemphasis_lane1_44=0x0d4b0c serdes_preemphasis_lane2_44=0x0d4b0c serdes_preemphasis_lane3_44=0x0d4b0c -serdes_preemphasis_lane0_49=0x0d4b0c -serdes_preemphasis_lane1_49=0x0d4b0c -serdes_preemphasis_lane2_49=0x0d4b0c -serdes_preemphasis_lane3_49=0x0d4b0c +serdes_preemphasis_lane0_49=0x0f480d +serdes_preemphasis_lane1_49=0x0f480d +serdes_preemphasis_lane2_49=0x0f480d +serdes_preemphasis_lane3_49=0x0f480d serdes_preemphasis_lane0_50=0x0d4b0c serdes_preemphasis_lane1_50=0x0d4b0c serdes_preemphasis_lane2_50=0x0d4b0c serdes_preemphasis_lane3_50=0x0d4b0c -serdes_preemphasis_lane0_51=0x0d4b0c -serdes_preemphasis_lane1_51=0x0d4b0c -serdes_preemphasis_lane2_51=0x0d4b0c -serdes_preemphasis_lane3_51=0x0d4b0c +serdes_preemphasis_lane0_51=0x0f480d +serdes_preemphasis_lane1_51=0x0f480d +serdes_preemphasis_lane2_51=0x0f480d +serdes_preemphasis_lane3_51=0x0f480d serdes_preemphasis_lane0_52=0x0d4b0c serdes_preemphasis_lane1_52=0x0d4b0c serdes_preemphasis_lane2_52=0x0d4b0c serdes_preemphasis_lane3_52=0x0d4b0c -serdes_preemphasis_lane0_57=0x0d4b0c -serdes_preemphasis_lane1_57=0x0d4b0c -serdes_preemphasis_lane2_57=0x0d4b0c -serdes_preemphasis_lane3_57=0x0d4b0c -serdes_preemphasis_lane0_58=0x0d4b0c -serdes_preemphasis_lane1_58=0x0d4b0c -serdes_preemphasis_lane2_58=0x0d4b0c -serdes_preemphasis_lane3_58=0x0d4b0c -serdes_preemphasis_lane0_59=0x0d4b0c -serdes_preemphasis_lane1_59=0x0d4b0c -serdes_preemphasis_lane2_59=0x0d4b0c -serdes_preemphasis_lane3_59=0x0d4b0c -serdes_preemphasis_lane0_60=0x0d4b0c -serdes_preemphasis_lane1_60=0x0d4b0c -serdes_preemphasis_lane2_60=0x0d4b0c -serdes_preemphasis_lane3_60=0x0d4b0c -serdes_preemphasis_lane0_61=0x0d4b0c -serdes_preemphasis_lane1_61=0x0d4b0c -serdes_preemphasis_lane2_61=0x0d4b0c -serdes_preemphasis_lane3_61=0x0d4b0c -serdes_preemphasis_lane0_62=0x0d4b0c -serdes_preemphasis_lane1_62=0x0d4b0c -serdes_preemphasis_lane2_62=0x0d4b0c -serdes_preemphasis_lane3_62=0x0d4b0c -serdes_preemphasis_lane0_63=0x0d4b0c -serdes_preemphasis_lane1_63=0x0d4b0c -serdes_preemphasis_lane2_63=0x0d4b0c -serdes_preemphasis_lane3_63=0x0d4b0c -serdes_preemphasis_lane0_64=0x0d4b0c -serdes_preemphasis_lane1_64=0x0d4b0c -serdes_preemphasis_lane2_64=0x0d4b0c -serdes_preemphasis_lane3_64=0x0d4b0c serdes_preemphasis_lane0_67=0x0d4b0c serdes_preemphasis_lane1_67=0x0d4b0c serdes_preemphasis_lane2_67=0x0d4b0c @@ -545,22 +550,22 @@ serdes_preemphasis_lane0_95=0x0d4b0c serdes_preemphasis_lane1_95=0x0d4b0c serdes_preemphasis_lane2_95=0x0d4b0c serdes_preemphasis_lane3_95=0x0d4b0c -serdes_preemphasis_lane0_115=0x0f480d -serdes_preemphasis_lane1_115=0x0f480d -serdes_preemphasis_lane2_115=0x0f480d -serdes_preemphasis_lane3_115=0x0f480d -serdes_preemphasis_lane0_107=0x0f480d -serdes_preemphasis_lane1_107=0x0f480d -serdes_preemphasis_lane2_107=0x0f480d -serdes_preemphasis_lane3_107=0x0f480d -serdes_preemphasis_lane0_123=0x0f480d -serdes_preemphasis_lane1_123=0x0f480d -serdes_preemphasis_lane2_123=0x0f480d -serdes_preemphasis_lane3_123=0x0f480d -serdes_preemphasis_lane0_127=0x0f480d -serdes_preemphasis_lane1_127=0x0f480d -serdes_preemphasis_lane2_127=0x0f480d -serdes_preemphasis_lane3_127=0x0f480d +serdes_preemphasis_lane0_115=0x0d4b0c +serdes_preemphasis_lane1_115=0x0d4b0c +serdes_preemphasis_lane2_115=0x0d4b0c +serdes_preemphasis_lane3_115=0x0d4b0c +serdes_preemphasis_lane0_107=0x0d4b0c +serdes_preemphasis_lane1_107=0x0d4b0c +serdes_preemphasis_lane2_107=0x0d4b0c +serdes_preemphasis_lane3_107=0x0d4b0c +serdes_preemphasis_lane0_123=0x14460a +serdes_preemphasis_lane1_123=0x14460a +serdes_preemphasis_lane2_123=0x14460a +serdes_preemphasis_lane3_123=0x14460a +serdes_preemphasis_lane0_127=0x14460a +serdes_preemphasis_lane1_127=0x14460a +serdes_preemphasis_lane2_127=0x14460a +serdes_preemphasis_lane3_127=0x14460a reglist_enable=1 scache_filename=/tmp/scache diff --git a/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/RA-B6510-48V8C/td3-ra-b6510-48v8c-48x25G+8x100G.config.bcm b/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/RA-B6510-48V8C/td3-ra-b6510-48v8c-48x25G+8x100G.config.bcm new file mode 100644 index 000000000000..86f90570b3a8 --- /dev/null +++ b/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/RA-B6510-48V8C/td3-ra-b6510-48v8c-48x25G+8x100G.config.bcm @@ -0,0 +1,574 @@ +l2_mem_entries=32768 +l2xmsg_mode=0 +l3_max_ecmp_mode=1 +l3_mem_entries=49152 +l3_alpm_enable=0 +bcm_num_cos=8 +bcm_stat_interval=2000000 +cdma_timeout_usec=3000000 +core_clock_frequency=1525 +dpp_clock_ratio=2:3 +help_cli_enable=1 +ifp_inports_support_enable=1 +ipv6_lpm_128b_enable=0x1 +#lpm_scaling_enable=1 +max_vp_lags=0 +mem_cache_enable=0 +memlist_enable=1 +miim_intr_enable=0 +module_64ports=1 +oversubscribe_mode=1 +parity_correction=1 +parity_enable=1 +pbmp_gport_stack.0=0x0000000000000000000000000000000000000000000000000000000000000000 +#pbmp_xport_xe.0=0x00000000000000000000000000000000888ffffffffffff9fffffffffffffffe +pbmp_xport_xe=0xffffffffffffffffffffffffffffffffffffffffe +port_flex_enable=1 +phy_chain_tx_lane_map_physical{57.0}=0x0123 +phy_chain_tx_lane_map_physical{61.0}=0x0123 +phy_chain_tx_lane_map_physical{1.0}=0x0123 +phy_chain_tx_lane_map_physical{5.0}=0x0123 +phy_chain_tx_lane_map_physical{13.0}=0x0123 +phy_chain_tx_lane_map_physical{21.0}=0x0123 +phy_chain_tx_lane_map_physical{29.0}=0x0123 +phy_chain_tx_lane_map_physical{33.0}=0x0123 +phy_chain_tx_lane_map_physical{41.0}=0x0123 +phy_chain_tx_lane_map_physical{49.0}=0x0123 +phy_chain_tx_lane_map_physical{65.0}=0x3210 +phy_chain_tx_lane_map_physical{69.0}=0x3210 +phy_chain_tx_lane_map_physical{85.0}=0x3210 +phy_chain_tx_lane_map_physical{77.0}=0x0213 +phy_chain_tx_lane_map_physical{97.0}=0x3210 +phy_chain_tx_lane_map_physical{93.0}=0x0213 +phy_chain_tx_lane_map_physical{113.0}=0x3210 +phy_chain_tx_lane_map_physical{105.0}=0x0213 +phy_chain_tx_lane_map_physical{121.0}=0x3120 +phy_chain_tx_lane_map_physical{125.0}=0x1203 + +phy_chain_rx_lane_map_physical{57.0}=0x1032 +phy_chain_rx_lane_map_physical{61.0}=0x1032 +phy_chain_rx_lane_map_physical{1.0}=0x1032 +phy_chain_rx_lane_map_physical{5.0}=0x1032 +phy_chain_rx_lane_map_physical{13.0}=0x1032 +phy_chain_rx_lane_map_physical{21.0}=0x1032 +phy_chain_rx_lane_map_physical{29.0}=0x1032 +phy_chain_rx_lane_map_physical{33.0}=0x1032 +phy_chain_rx_lane_map_physical{41.0}=0x1032 +phy_chain_rx_lane_map_physical{49.0}=0x1032 +phy_chain_rx_lane_map_physical{65.0}=0x2301 +phy_chain_rx_lane_map_physical{69.0}=0x2301 +phy_chain_rx_lane_map_physical{85.0}=0x1032 +phy_chain_rx_lane_map_physical{77.0}=0x1032 +phy_chain_rx_lane_map_physical{97.0}=0x1032 +phy_chain_rx_lane_map_physical{93.0}=0x1032 +phy_chain_rx_lane_map_physical{113.0}=0x1032 +phy_chain_rx_lane_map_physical{105.0}=0x1032 +phy_chain_rx_lane_map_physical{121.0}=0x2031 +phy_chain_rx_lane_map_physical{125.0}=0x1023 + +portmap_57=57:25 +portmap_58=58:25 +portmap_59=59:25 +portmap_60=60:25 +portmap_61=61:25 +portmap_62=62:25 +portmap_63=63:25 +portmap_64=64:25 +portmap_1=1:25 +portmap_2=2:25 +portmap_3=3:25 +portmap_4=4:25 +portmap_5=5:25 +portmap_6=6:25 +portmap_7=7:25 +portmap_8=8:25 +portmap_13=13:25 +portmap_14=14:25 +portmap_15=15:25 +portmap_16=16:25 +portmap_21=21:25 +portmap_22=22:25 +portmap_23=23:25 +portmap_24=24:25 +portmap_29=29:25 +portmap_30=30:25 +portmap_31=31:25 +portmap_32=32:25 +portmap_33=33:25 +portmap_34=34:25 +portmap_35=35:25 +portmap_36=36:25 +portmap_41=41:25 +portmap_42=42:25 +portmap_43=43:25 +portmap_44=44:25 +portmap_49=49:25 +portmap_50=50:25 +portmap_51=51:25 +portmap_52=52:25 +portmap_67=65:25 +portmap_68=66:25 +portmap_69=67:25 +portmap_70=68:25 +portmap_71=69:25 +portmap_72=70:25 +portmap_73=71:25 +portmap_74=72:25 +portmap_87=85:100 +portmap_79=77:100 +portmap_99=97:100 +portmap_95=93:100 +portmap_115=113:100 +portmap_107=105:100 +portmap_123=121:100 +portmap_127=125:100 + +dport_map_port_57=1 +dport_map_port_58=2 +dport_map_port_59=3 +dport_map_port_60=4 +dport_map_port_61=5 +dport_map_port_62=6 +dport_map_port_63=7 +dport_map_port_64=8 +dport_map_port_1=9 +dport_map_port_2=10 +dport_map_port_3=11 +dport_map_port_4=12 +dport_map_port_5=13 +dport_map_port_6=14 +dport_map_port_7=15 +dport_map_port_8=16 +dport_map_port_13=17 +dport_map_port_14=18 +dport_map_port_15=19 +dport_map_port_16=20 +dport_map_port_21=21 +dport_map_port_22=22 +dport_map_port_23=23 +dport_map_port_24=24 +dport_map_port_29=25 +dport_map_port_30=26 +dport_map_port_31=27 +dport_map_port_32=28 +dport_map_port_33=29 +dport_map_port_34=30 +dport_map_port_35=31 +dport_map_port_36=32 +dport_map_port_41=33 +dport_map_port_42=34 +dport_map_port_43=35 +dport_map_port_44=36 +dport_map_port_49=37 +dport_map_port_50=38 +dport_map_port_51=39 +dport_map_port_52=40 +dport_map_port_67=41 +dport_map_port_68=42 +dport_map_port_69=43 +dport_map_port_70=44 +dport_map_port_71=45 +dport_map_port_72=46 +dport_map_port_73=47 +dport_map_port_74=48 +dport_map_port_87=49 +dport_map_port_79=50 +dport_map_port_99=51 +dport_map_port_95=52 +dport_map_port_115=53 +dport_map_port_107=54 +dport_map_port_123=55 +dport_map_port_127=56 + +phy_chain_tx_polarity_flip_physical{57.0}=0x1 +phy_chain_tx_polarity_flip_physical{58.0}=0x0 +phy_chain_tx_polarity_flip_physical{59.0}=0x1 +phy_chain_tx_polarity_flip_physical{60.0}=0x0 +phy_chain_tx_polarity_flip_physical{61.0}=0x1 +phy_chain_tx_polarity_flip_physical{62.0}=0x0 +phy_chain_tx_polarity_flip_physical{63.0}=0x1 +phy_chain_tx_polarity_flip_physical{64.0}=0x0 +phy_chain_tx_polarity_flip_physical{1.0}=0x0 +phy_chain_tx_polarity_flip_physical{2.0}=0x0 +phy_chain_tx_polarity_flip_physical{3.0}=0x0 +phy_chain_tx_polarity_flip_physical{4.0}=0x0 +phy_chain_tx_polarity_flip_physical{5.0}=0x0 +phy_chain_tx_polarity_flip_physical{6.0}=0x0 +phy_chain_tx_polarity_flip_physical{7.0}=0x0 +phy_chain_tx_polarity_flip_physical{8.0}=0x0 +phy_chain_tx_polarity_flip_physical{13.0}=0x0 +phy_chain_tx_polarity_flip_physical{14.0}=0x0 +phy_chain_tx_polarity_flip_physical{15.0}=0x0 +phy_chain_tx_polarity_flip_physical{16.0}=0x0 +phy_chain_tx_polarity_flip_physical{21.0}=0x0 +phy_chain_tx_polarity_flip_physical{22.0}=0x0 +phy_chain_tx_polarity_flip_physical{23.0}=0x0 +phy_chain_tx_polarity_flip_physical{24.0}=0x0 +phy_chain_tx_polarity_flip_physical{29.0}=0x0 +phy_chain_tx_polarity_flip_physical{30.0}=0x0 +phy_chain_tx_polarity_flip_physical{31.0}=0x0 +phy_chain_tx_polarity_flip_physical{32.0}=0x0 +phy_chain_tx_polarity_flip_physical{33.0}=0x0 +phy_chain_tx_polarity_flip_physical{34.0}=0x0 +phy_chain_tx_polarity_flip_physical{35.0}=0x0 +phy_chain_tx_polarity_flip_physical{36.0}=0x0 +phy_chain_tx_polarity_flip_physical{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{49.0}=0x0 +phy_chain_tx_polarity_flip_physical{50.0}=0x0 +phy_chain_tx_polarity_flip_physical{51.0}=0x0 +phy_chain_tx_polarity_flip_physical{52.0}=0x0 +phy_chain_tx_polarity_flip_physical{65.0}=0x0 +phy_chain_tx_polarity_flip_physical{66.0}=0x0 +phy_chain_tx_polarity_flip_physical{67.0}=0x0 +phy_chain_tx_polarity_flip_physical{68.0}=0x0 +phy_chain_tx_polarity_flip_physical{69.0}=0x0 +phy_chain_tx_polarity_flip_physical{70.0}=0x0 +phy_chain_tx_polarity_flip_physical{71.0}=0x0 +phy_chain_tx_polarity_flip_physical{72.0}=0x0 +phy_chain_tx_polarity_flip_physical{85.0}=0x0 +phy_chain_tx_polarity_flip_physical{86.0}=0x0 +phy_chain_tx_polarity_flip_physical{87.0}=0x1 +phy_chain_tx_polarity_flip_physical{88.0}=0x0 +phy_chain_tx_polarity_flip_physical{77.0}=0x1 +phy_chain_tx_polarity_flip_physical{78.0}=0x0 +phy_chain_tx_polarity_flip_physical{79.0}=0x1 +phy_chain_tx_polarity_flip_physical{80.0}=0x0 +phy_chain_tx_polarity_flip_physical{97.0}=0x0 +phy_chain_tx_polarity_flip_physical{98.0}=0x0 +phy_chain_tx_polarity_flip_physical{99.0}=0x1 +phy_chain_tx_polarity_flip_physical{100.0}=0x0 +phy_chain_tx_polarity_flip_physical{93.0}=0x0 +phy_chain_tx_polarity_flip_physical{94.0}=0x1 +phy_chain_tx_polarity_flip_physical{95.0}=0x1 +phy_chain_tx_polarity_flip_physical{96.0}=0x0 +phy_chain_tx_polarity_flip_physical{113.0}=0x0 +phy_chain_tx_polarity_flip_physical{114.0}=0x0 +phy_chain_tx_polarity_flip_physical{115.0}=0x1 +phy_chain_tx_polarity_flip_physical{116.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}=0x0 +phy_chain_tx_polarity_flip_physical{121.0}=0x1 +phy_chain_tx_polarity_flip_physical{122.0}=0x0 +phy_chain_tx_polarity_flip_physical{123.0}=0x1 +phy_chain_tx_polarity_flip_physical{124.0}=0x0 +phy_chain_tx_polarity_flip_physical{125.0}=0x1 +phy_chain_tx_polarity_flip_physical{126.0}=0x0 +phy_chain_tx_polarity_flip_physical{127.0}=0x1 +phy_chain_tx_polarity_flip_physical{128.0}=0x1 + +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}=0x0 +phy_chain_rx_polarity_flip_physical{60.0}=0x0 +phy_chain_rx_polarity_flip_physical{61.0}=0x1 +phy_chain_rx_polarity_flip_physical{62.0}=0x1 +phy_chain_rx_polarity_flip_physical{63.0}=0x1 +phy_chain_rx_polarity_flip_physical{64.0}=0x1 +phy_chain_rx_polarity_flip_physical{1.0}=0x1 +phy_chain_rx_polarity_flip_physical{2.0}=0x1 +phy_chain_rx_polarity_flip_physical{3.0}=0x1 +phy_chain_rx_polarity_flip_physical{4.0}=0x1 +phy_chain_rx_polarity_flip_physical{5.0}=0x0 +phy_chain_rx_polarity_flip_physical{6.0}=0x0 +phy_chain_rx_polarity_flip_physical{7.0}=0x0 +phy_chain_rx_polarity_flip_physical{8.0}=0x0 +phy_chain_rx_polarity_flip_physical{13.0}=0x0 +phy_chain_rx_polarity_flip_physical{14.0}=0x0 +phy_chain_rx_polarity_flip_physical{15.0}=0x0 +phy_chain_rx_polarity_flip_physical{16.0}=0x0 +phy_chain_rx_polarity_flip_physical{21.0}=0x0 +phy_chain_rx_polarity_flip_physical{22.0}=0x0 +phy_chain_rx_polarity_flip_physical{23.0}=0x0 +phy_chain_rx_polarity_flip_physical{24.0}=0x0 +phy_chain_rx_polarity_flip_physical{29.0}=0x0 +phy_chain_rx_polarity_flip_physical{30.0}=0x1 +phy_chain_rx_polarity_flip_physical{31.0}=0x0 +phy_chain_rx_polarity_flip_physical{32.0}=0x0 +phy_chain_rx_polarity_flip_physical{33.0}=0x1 +phy_chain_rx_polarity_flip_physical{34.0}=0x1 +phy_chain_rx_polarity_flip_physical{35.0}=0x1 +phy_chain_rx_polarity_flip_physical{36.0}=0x1 +phy_chain_rx_polarity_flip_physical{41.0}=0x1 +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{49.0}=0x1 +phy_chain_rx_polarity_flip_physical{50.0}=0x1 +phy_chain_rx_polarity_flip_physical{51.0}=0x1 +phy_chain_rx_polarity_flip_physical{52.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}=0x1 +phy_chain_rx_polarity_flip_physical{68.0}=0x1 +phy_chain_rx_polarity_flip_physical{69.0}=0x0 +phy_chain_rx_polarity_flip_physical{70.0}=0x0 +phy_chain_rx_polarity_flip_physical{71.0}=0x0 +phy_chain_rx_polarity_flip_physical{72.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}=0x1 +phy_chain_rx_polarity_flip_physical{88.0}=0x1 +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}=0x0 +phy_chain_rx_polarity_flip_physical{80.0}=0x0 +phy_chain_rx_polarity_flip_physical{97.0}=0x0 +phy_chain_rx_polarity_flip_physical{98.0}=0x0 +phy_chain_rx_polarity_flip_physical{99.0}=0x0 +phy_chain_rx_polarity_flip_physical{100.0}=0x0 +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}=0x0 +phy_chain_rx_polarity_flip_physical{96.0}=0x0 +phy_chain_rx_polarity_flip_physical{113.0}=0x1 +phy_chain_rx_polarity_flip_physical{114.0}=0x1 +phy_chain_rx_polarity_flip_physical{115.0}=0x1 +phy_chain_rx_polarity_flip_physical{116.0}=0x1 +phy_chain_rx_polarity_flip_physical{105.0}=0x0 +phy_chain_rx_polarity_flip_physical{106.0}=0x0 +phy_chain_rx_polarity_flip_physical{107.0}=0x0 +phy_chain_rx_polarity_flip_physical{108.0}=0x0 +phy_chain_rx_polarity_flip_physical{121.0}=0x1 +phy_chain_rx_polarity_flip_physical{122.0}=0x1 +phy_chain_rx_polarity_flip_physical{123.0}=0x0 +phy_chain_rx_polarity_flip_physical{124.0}=0x1 +phy_chain_rx_polarity_flip_physical{125.0}=0x1 +phy_chain_rx_polarity_flip_physical{126.0}=0x0 +phy_chain_rx_polarity_flip_physical{127.0}=0x0 +phy_chain_rx_polarity_flip_physical{128.0}=0x0 + +serdes_preemphasis_lane0_57=0x0f480d +serdes_preemphasis_lane1_57=0x0f480d +serdes_preemphasis_lane2_57=0x0f480d +serdes_preemphasis_lane3_57=0x0f480d +serdes_preemphasis_lane0_58=0x0f480d +serdes_preemphasis_lane1_58=0x0f480d +serdes_preemphasis_lane2_58=0x0f480d +serdes_preemphasis_lane3_58=0x0f480d +serdes_preemphasis_lane0_59=0x0f480d +serdes_preemphasis_lane1_59=0x0f480d +serdes_preemphasis_lane2_59=0x0f480d +serdes_preemphasis_lane3_59=0x0f480d +serdes_preemphasis_lane0_60=0x0f480d +serdes_preemphasis_lane1_60=0x0f480d +serdes_preemphasis_lane2_60=0x0f480d +serdes_preemphasis_lane3_60=0x0f480d +serdes_preemphasis_lane0_61=0x0f480d +serdes_preemphasis_lane1_61=0x0f480d +serdes_preemphasis_lane2_61=0x0f480d +serdes_preemphasis_lane3_61=0x0f480d +serdes_preemphasis_lane0_62=0x0f480d +serdes_preemphasis_lane1_62=0x0f480d +serdes_preemphasis_lane2_62=0x0f480d +serdes_preemphasis_lane3_62=0x0f480d +serdes_preemphasis_lane0_63=0x0f480d +serdes_preemphasis_lane1_63=0x0f480d +serdes_preemphasis_lane2_63=0x0f480d +serdes_preemphasis_lane3_63=0x0f480d +serdes_preemphasis_lane0_64=0x0f480d +serdes_preemphasis_lane1_64=0x0f480d +serdes_preemphasis_lane2_64=0x0f480d +serdes_preemphasis_lane3_64=0x0f480d +serdes_preemphasis_lane0_1=0x0f480d +serdes_preemphasis_lane1_1=0x0f480d +serdes_preemphasis_lane2_1=0x0f480d +serdes_preemphasis_lane3_1=0x0f480d +serdes_preemphasis_lane0_2=0x0d4b0c +serdes_preemphasis_lane1_2=0x0d4b0c +serdes_preemphasis_lane2_2=0x0d4b0c +serdes_preemphasis_lane3_2=0x0d4b0c +serdes_preemphasis_lane0_3=0x0f480d +serdes_preemphasis_lane1_3=0x0f480d +serdes_preemphasis_lane2_3=0x0f480d +serdes_preemphasis_lane3_3=0x0f480d +serdes_preemphasis_lane0_4=0x0d4b0c +serdes_preemphasis_lane1_4=0x0d4b0c +serdes_preemphasis_lane2_4=0x0d4b0c +serdes_preemphasis_lane3_4=0x0d4b0c +serdes_preemphasis_lane0_5=0x0f480d +serdes_preemphasis_lane1_5=0x0f480d +serdes_preemphasis_lane2_5=0x0f480d +serdes_preemphasis_lane3_5=0x0f480d +serdes_preemphasis_lane0_6=0x0d4b0c +serdes_preemphasis_lane1_6=0x0d4b0c +serdes_preemphasis_lane2_6=0x0d4b0c +serdes_preemphasis_lane3_6=0x0d4b0c +serdes_preemphasis_lane0_7=0x0f480d +serdes_preemphasis_lane1_7=0x0f480d +serdes_preemphasis_lane2_7=0x0f480d +serdes_preemphasis_lane3_7=0x0f480d +serdes_preemphasis_lane0_8=0x0d4b0c +serdes_preemphasis_lane1_8=0x0d4b0c +serdes_preemphasis_lane2_8=0x0d4b0c +serdes_preemphasis_lane3_8=0x0d4b0c +serdes_preemphasis_lane0_13=0x0f480d +serdes_preemphasis_lane1_13=0x0f480d +serdes_preemphasis_lane2_13=0x0f480d +serdes_preemphasis_lane3_13=0x0f480d +serdes_preemphasis_lane0_14=0x0d4b0c +serdes_preemphasis_lane1_14=0x0d4b0c +serdes_preemphasis_lane2_14=0x0d4b0c +serdes_preemphasis_lane3_14=0x0d4b0c +serdes_preemphasis_lane0_15=0x0f480d +serdes_preemphasis_lane1_15=0x0f480d +serdes_preemphasis_lane2_15=0x0f480d +serdes_preemphasis_lane3_15=0x0f480d +serdes_preemphasis_lane0_16=0x0d4b0c +serdes_preemphasis_lane1_16=0x0d4b0c +serdes_preemphasis_lane2_16=0x0d4b0c +serdes_preemphasis_lane3_16=0x0d4b0c +serdes_preemphasis_lane0_21=0x0d4b0c +serdes_preemphasis_lane1_21=0x0d4b0c +serdes_preemphasis_lane2_21=0x0d4b0c +serdes_preemphasis_lane3_21=0x0d4b0c +serdes_preemphasis_lane0_22=0x0d4b0c +serdes_preemphasis_lane1_22=0x0d4b0c +serdes_preemphasis_lane2_22=0x0d4b0c +serdes_preemphasis_lane3_22=0x0d4b0c +serdes_preemphasis_lane0_23=0x0d4b0c +serdes_preemphasis_lane1_23=0x0d4b0c +serdes_preemphasis_lane2_23=0x0d4b0c +serdes_preemphasis_lane3_23=0x0d4b0c +serdes_preemphasis_lane0_24=0x0d4b0c +serdes_preemphasis_lane1_24=0x0d4b0c +serdes_preemphasis_lane2_24=0x0d4b0c +serdes_preemphasis_lane3_24=0x0d4b0c +serdes_preemphasis_lane0_29=0x0d4b0c +serdes_preemphasis_lane1_29=0x0d4b0c +serdes_preemphasis_lane2_29=0x0d4b0c +serdes_preemphasis_lane3_29=0x0d4b0c +serdes_preemphasis_lane0_30=0x0d4b0c +serdes_preemphasis_lane1_30=0x0d4b0c +serdes_preemphasis_lane2_30=0x0d4b0c +serdes_preemphasis_lane3_30=0x0d4b0c +serdes_preemphasis_lane0_31=0x0d4b0c +serdes_preemphasis_lane1_31=0x0d4b0c +serdes_preemphasis_lane2_31=0x0d4b0c +serdes_preemphasis_lane3_31=0x0d4b0c +serdes_preemphasis_lane0_32=0x0d4b0c +serdes_preemphasis_lane1_32=0x0d4b0c +serdes_preemphasis_lane2_32=0x0d4b0c +serdes_preemphasis_lane3_32=0x0d4b0c +serdes_preemphasis_lane0_33=0x0d4b0c +serdes_preemphasis_lane1_33=0x0d4b0c +serdes_preemphasis_lane2_33=0x0d4b0c +serdes_preemphasis_lane3_33=0x0d4b0c +serdes_preemphasis_lane0_34=0x0d4b0c +serdes_preemphasis_lane1_34=0x0d4b0c +serdes_preemphasis_lane2_34=0x0d4b0c +serdes_preemphasis_lane3_34=0x0d4b0c +serdes_preemphasis_lane0_35=0x0d4b0c +serdes_preemphasis_lane1_35=0x0d4b0c +serdes_preemphasis_lane2_35=0x0d4b0c +serdes_preemphasis_lane3_35=0x0d4b0c +serdes_preemphasis_lane0_36=0x0d4b0c +serdes_preemphasis_lane1_36=0x0d4b0c +serdes_preemphasis_lane2_36=0x0d4b0c +serdes_preemphasis_lane3_36=0x0d4b0c +serdes_preemphasis_lane0_41=0x0d4b0c +serdes_preemphasis_lane1_41=0x0d4b0c +serdes_preemphasis_lane2_41=0x0d4b0c +serdes_preemphasis_lane3_41=0x0d4b0c +serdes_preemphasis_lane0_42=0x0d4b0c +serdes_preemphasis_lane1_42=0x0d4b0c +serdes_preemphasis_lane2_42=0x0d4b0c +serdes_preemphasis_lane3_42=0x0d4b0c +serdes_preemphasis_lane0_43=0x0d4b0c +serdes_preemphasis_lane1_43=0x0d4b0c +serdes_preemphasis_lane2_43=0x0d4b0c +serdes_preemphasis_lane3_43=0x0d4b0c +serdes_preemphasis_lane0_44=0x0d4b0c +serdes_preemphasis_lane1_44=0x0d4b0c +serdes_preemphasis_lane2_44=0x0d4b0c +serdes_preemphasis_lane3_44=0x0d4b0c +serdes_preemphasis_lane0_49=0x0f480d +serdes_preemphasis_lane1_49=0x0f480d +serdes_preemphasis_lane2_49=0x0f480d +serdes_preemphasis_lane3_49=0x0f480d +serdes_preemphasis_lane0_50=0x0d4b0c +serdes_preemphasis_lane1_50=0x0d4b0c +serdes_preemphasis_lane2_50=0x0d4b0c +serdes_preemphasis_lane3_50=0x0d4b0c +serdes_preemphasis_lane0_51=0x0f480d +serdes_preemphasis_lane1_51=0x0f480d +serdes_preemphasis_lane2_51=0x0f480d +serdes_preemphasis_lane3_51=0x0f480d +serdes_preemphasis_lane0_52=0x0d4b0c +serdes_preemphasis_lane1_52=0x0d4b0c +serdes_preemphasis_lane2_52=0x0d4b0c +serdes_preemphasis_lane3_52=0x0d4b0c +serdes_preemphasis_lane0_67=0x0d4b0c +serdes_preemphasis_lane1_67=0x0d4b0c +serdes_preemphasis_lane2_67=0x0d4b0c +serdes_preemphasis_lane3_67=0x0d4b0c +serdes_preemphasis_lane0_68=0x0d4b0c +serdes_preemphasis_lane1_68=0x0d4b0c +serdes_preemphasis_lane2_68=0x0d4b0c +serdes_preemphasis_lane3_68=0x0d4b0c +serdes_preemphasis_lane0_69=0x0d4b0c +serdes_preemphasis_lane1_69=0x0d4b0c +serdes_preemphasis_lane2_69=0x0d4b0c +serdes_preemphasis_lane3_69=0x0d4b0c +serdes_preemphasis_lane0_70=0x0d4b0c +serdes_preemphasis_lane1_70=0x0d4b0c +serdes_preemphasis_lane2_70=0x0d4b0c +serdes_preemphasis_lane3_70=0x0d4b0c +serdes_preemphasis_lane0_71=0x0d4b0c +serdes_preemphasis_lane1_71=0x0d4b0c +serdes_preemphasis_lane2_71=0x0d4b0c +serdes_preemphasis_lane3_71=0x0d4b0c +serdes_preemphasis_lane0_72=0x0d4b0c +serdes_preemphasis_lane1_72=0x0d4b0c +serdes_preemphasis_lane2_72=0x0d4b0c +serdes_preemphasis_lane3_72=0x0d4b0c +serdes_preemphasis_lane0_73=0x0d4b0c +serdes_preemphasis_lane1_73=0x0d4b0c +serdes_preemphasis_lane2_73=0x0d4b0c +serdes_preemphasis_lane3_73=0x0d4b0c +serdes_preemphasis_lane0_74=0x0d4b0c +serdes_preemphasis_lane1_74=0x0d4b0c +serdes_preemphasis_lane2_74=0x0d4b0c +serdes_preemphasis_lane3_74=0x0d4b0c +serdes_preemphasis_lane0_87=0x0d4b0c +serdes_preemphasis_lane1_87=0x0d4b0c +serdes_preemphasis_lane2_87=0x0d4b0c +serdes_preemphasis_lane3_87=0x0d4b0c +serdes_preemphasis_lane0_79=0x0d4b0c +serdes_preemphasis_lane1_79=0x0d4b0c +serdes_preemphasis_lane2_79=0x0d4b0c +serdes_preemphasis_lane3_79=0x0d4b0c +serdes_preemphasis_lane0_99=0x0d4b0c +serdes_preemphasis_lane1_99=0x0d4b0c +serdes_preemphasis_lane2_99=0x0d4b0c +serdes_preemphasis_lane3_99=0x0d4b0c +serdes_preemphasis_lane0_95=0x0d4b0c +serdes_preemphasis_lane1_95=0x0d4b0c +serdes_preemphasis_lane2_95=0x0d4b0c +serdes_preemphasis_lane3_95=0x0d4b0c +serdes_preemphasis_lane0_115=0x0d4b0c +serdes_preemphasis_lane1_115=0x0d4b0c +serdes_preemphasis_lane2_115=0x0d4b0c +serdes_preemphasis_lane3_115=0x0d4b0c +serdes_preemphasis_lane0_107=0x0d4b0c +serdes_preemphasis_lane1_107=0x0d4b0c +serdes_preemphasis_lane2_107=0x0d4b0c +serdes_preemphasis_lane3_107=0x0d4b0c +serdes_preemphasis_lane0_123=0x14460a +serdes_preemphasis_lane1_123=0x14460a +serdes_preemphasis_lane2_123=0x14460a +serdes_preemphasis_lane3_123=0x14460a +serdes_preemphasis_lane0_127=0x14460a +serdes_preemphasis_lane1_127=0x14460a +serdes_preemphasis_lane2_127=0x14460a +serdes_preemphasis_lane3_127=0x14460a + +reglist_enable=1 +scache_filename=/tmp/scache +schan_intr_enable=0 +stable_size=0x5500000 +tdma_timeout_usec=3000000 diff --git a/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/RA-B6510-48V8C/td3-ra-b6510-48v8c-48x25G+8x100G.config.bcm_v1 b/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/RA-B6510-48V8C/td3-ra-b6510-48v8c-48x25G+8x100G.config.bcm_v1 new file mode 100644 index 000000000000..27656bd3d466 --- /dev/null +++ b/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/RA-B6510-48V8C/td3-ra-b6510-48v8c-48x25G+8x100G.config.bcm_v1 @@ -0,0 +1,402 @@ +cancun_dir=/usr/share/sonic/platform/cancun/sdk_6.5.16/ +l2_mem_entries=32768 +l3_mem_entries=16384 +l3_alpm_enable=2 +ipv6_lpm_128b_enable=0x1 +l2xmsg_mode=0 +l3_max_ecmp_mode=1 +bcm_num_cos=8 +bcm_stat_interval=2000000 +cdma_timeout_usec=3000000 +core_clock_frequency=1525 +dpp_clock_ratio=2:3 +help_cli_enable=1 +ifp_inports_support_enable=1 +#lpm_scaling_enable=1 +max_vp_lags=0 +mem_cache_enable=0 +memlist_enable=1 +miim_intr_enable=0 +module_64ports=1 +oversubscribe_mode=1 +parity_enable=1 +pbmp_gport_stack.0=0x0000000000000000000000000000000000000000000000000000000000000000 +#pbmp_xport_xe.0=0x00000000000000000000000000000000888ffffffffffff9fffffffffffffffe +pbmp_xport_xe=0x488080808808087f9fe1e1e1fe1e1e1fe +phy_chain_rx_lane_map_physical{1.0}=0x1032 +phy_chain_tx_lane_map_physical{1.0}=0x0123 +phy_chain_rx_lane_map_physical{5.0}=0x1032 +phy_chain_tx_lane_map_physical{5.0}=0x0123 +phy_chain_rx_lane_map_physical{13.0}=0x1032 +phy_chain_tx_lane_map_physical{13.0}=0x0123 +phy_chain_rx_lane_map_physical{21.0}=0x1032 +phy_chain_tx_lane_map_physical{21.0}=0x0123 +phy_chain_rx_lane_map_physical{29.0}=0x1032 +phy_chain_tx_lane_map_physical{29.0}=0x0123 +phy_chain_rx_lane_map_physical{33.0}=0x1032 +phy_chain_tx_lane_map_physical{33.0}=0x0123 +phy_chain_rx_lane_map_physical{41.0}=0x1032 +phy_chain_tx_lane_map_physical{41.0}=0x0123 +phy_chain_rx_lane_map_physical{49.0}=0x1032 +phy_chain_tx_lane_map_physical{49.0}=0x0123 +phy_chain_rx_lane_map_physical{57.0}=0x1032 +phy_chain_tx_lane_map_physical{57.0}=0x0123 +phy_chain_rx_lane_map_physical{61.0}=0x1032 +phy_chain_tx_lane_map_physical{61.0}=0x0123 +phy_chain_rx_lane_map_physical{65.0}=0x2301 +phy_chain_tx_lane_map_physical{65.0}=0x3210 +phy_chain_rx_lane_map_physical{69.0}=0x2301 +phy_chain_tx_lane_map_physical{69.0}=0x3210 +phy_chain_rx_lane_map_physical{77.0}=0x1032 +phy_chain_tx_lane_map_physical{77.0}=0x3210 +phy_chain_rx_lane_map_physical{85.0}=0x1032 +phy_chain_tx_lane_map_physical{85.0}=0x3210 +phy_chain_rx_lane_map_physical{93.0}=0x1032 +phy_chain_tx_lane_map_physical{93.0}=0x3210 +phy_chain_rx_lane_map_physical{97.0}=0x1032 +phy_chain_tx_lane_map_physical{97.0}=0x3210 +phy_chain_rx_lane_map_physical{105.0}=0x1032 +phy_chain_tx_lane_map_physical{105.0}=0x3210 +phy_chain_rx_lane_map_physical{113.0}=0x1032 +phy_chain_tx_lane_map_physical{113.0}=0x3210 +phy_chain_rx_lane_map_physical{121.0}=0x2031 +phy_chain_tx_lane_map_physical{121.0}=0x3210 +phy_chain_rx_lane_map_physical{125.0}=0x1032 +phy_chain_tx_lane_map_physical{125.0}=0x1203 +phy_chain_tx_polarity_flip_physical{1.0}=0x1 +phy_chain_rx_polarity_flip_physical{1.0}=0x0 +phy_chain_tx_polarity_flip_physical{2.0}=0x0 +phy_chain_rx_polarity_flip_physical{2.0}=0x0 +phy_chain_tx_polarity_flip_physical{3.0}=0x1 +phy_chain_rx_polarity_flip_physical{3.0}=0x0 +phy_chain_tx_polarity_flip_physical{4.0}=0x0 +phy_chain_rx_polarity_flip_physical{4.0}=0x0 +phy_chain_tx_polarity_flip_physical{5.0}=0x1 +phy_chain_rx_polarity_flip_physical{5.0}=0x0 +phy_chain_tx_polarity_flip_physical{6.0}=0x0 +phy_chain_rx_polarity_flip_physical{6.0}=0x0 +phy_chain_tx_polarity_flip_physical{7.0}=0x1 +phy_chain_rx_polarity_flip_physical{7.0}=0x0 +phy_chain_tx_polarity_flip_physical{8.0}=0x0 +phy_chain_rx_polarity_flip_physical{8.0}=0x0 +phy_chain_tx_polarity_flip_physical{13.0}=0x0 +phy_chain_rx_polarity_flip_physical{13.0}=0x0 +phy_chain_tx_polarity_flip_physical{14.0}=0x0 +phy_chain_rx_polarity_flip_physical{14.0}=0x0 +phy_chain_tx_polarity_flip_physical{15.0}=0x0 +phy_chain_rx_polarity_flip_physical{15.0}=0x0 +phy_chain_tx_polarity_flip_physical{16.0}=0x0 +phy_chain_rx_polarity_flip_physical{16.0}=0x0 +phy_chain_tx_polarity_flip_physical{21.0}=0x1 +phy_chain_rx_polarity_flip_physical{21.0}=0x0 +phy_chain_tx_polarity_flip_physical{22.0}=0x0 +phy_chain_rx_polarity_flip_physical{22.0}=0x0 +phy_chain_tx_polarity_flip_physical{23.0}=0x1 +phy_chain_rx_polarity_flip_physical{23.0}=0x0 +phy_chain_tx_polarity_flip_physical{24.0}=0x0 +phy_chain_rx_polarity_flip_physical{24.0}=0x0 +phy_chain_tx_polarity_flip_physical{29.0}=0x0 +phy_chain_rx_polarity_flip_physical{29.0}=0x1 +phy_chain_tx_polarity_flip_physical{30.0}=0x0 +phy_chain_rx_polarity_flip_physical{30.0}=0x1 +phy_chain_tx_polarity_flip_physical{31.0}=0x0 +phy_chain_rx_polarity_flip_physical{31.0}=0x1 +phy_chain_tx_polarity_flip_physical{32.0}=0x0 +phy_chain_rx_polarity_flip_physical{32.0}=0x1 +phy_chain_tx_polarity_flip_physical{33.0}=0x0 +phy_chain_rx_polarity_flip_physical{33.0}=0x0 +phy_chain_tx_polarity_flip_physical{34.0}=0x0 +phy_chain_rx_polarity_flip_physical{34.0}=0x0 +phy_chain_tx_polarity_flip_physical{35.0}=0x0 +phy_chain_rx_polarity_flip_physical{35.0}=0x0 +phy_chain_tx_polarity_flip_physical{36.0}=0x0 +phy_chain_rx_polarity_flip_physical{36.0}=0x0 +phy_chain_tx_polarity_flip_physical{41.0}=0x0 +phy_chain_rx_polarity_flip_physical{41.0}=0x0 +phy_chain_tx_polarity_flip_physical{42.0}=0x0 +phy_chain_rx_polarity_flip_physical{42.0}=0x0 +phy_chain_tx_polarity_flip_physical{43.0}=0x0 +phy_chain_rx_polarity_flip_physical{43.0}=0x0 +phy_chain_tx_polarity_flip_physical{44.0}=0x0 +phy_chain_rx_polarity_flip_physical{44.0}=0x0 +phy_chain_tx_polarity_flip_physical{49.0}=0x0 +phy_chain_rx_polarity_flip_physical{49.0}=0x0 +phy_chain_tx_polarity_flip_physical{50.0}=0x0 +phy_chain_rx_polarity_flip_physical{50.0}=0x0 +phy_chain_tx_polarity_flip_physical{51.0}=0x0 +phy_chain_rx_polarity_flip_physical{51.0}=0x0 +phy_chain_tx_polarity_flip_physical{52.0}=0x0 +phy_chain_rx_polarity_flip_physical{52.0}=0x0 +phy_chain_tx_polarity_flip_physical{57.0}=0x0 +phy_chain_rx_polarity_flip_physical{57.0}=0x0 +phy_chain_tx_polarity_flip_physical{58.0}=0x0 +phy_chain_rx_polarity_flip_physical{58.0}=0x0 +phy_chain_tx_polarity_flip_physical{59.0}=0x0 +phy_chain_rx_polarity_flip_physical{59.0}=0x0 +phy_chain_tx_polarity_flip_physical{60.0}=0x0 +phy_chain_rx_polarity_flip_physical{60.0}=0x0 +phy_chain_tx_polarity_flip_physical{61.0}=0x0 +phy_chain_rx_polarity_flip_physical{61.0}=0x1 +phy_chain_tx_polarity_flip_physical{62.0}=0x0 +phy_chain_rx_polarity_flip_physical{62.0}=0x1 +phy_chain_tx_polarity_flip_physical{63.0}=0x0 +phy_chain_rx_polarity_flip_physical{63.0}=0x1 +phy_chain_tx_polarity_flip_physical{64.0}=0x0 +phy_chain_rx_polarity_flip_physical{64.0}=0x1 +phy_chain_tx_polarity_flip_physical{65.0}=0x0 +phy_chain_rx_polarity_flip_physical{65.0}=0x1 +phy_chain_tx_polarity_flip_physical{66.0}=0x0 +phy_chain_rx_polarity_flip_physical{66.0}=0x1 +phy_chain_tx_polarity_flip_physical{67.0}=0x0 +phy_chain_rx_polarity_flip_physical{67.0}=0x1 +phy_chain_tx_polarity_flip_physical{68.0}=0x0 +phy_chain_rx_polarity_flip_physical{68.0}=0x1 +phy_chain_tx_polarity_flip_physical{69.0}=0x0 +phy_chain_rx_polarity_flip_physical{69.0}=0x0 +phy_chain_tx_polarity_flip_physical{70.0}=0x0 +phy_chain_rx_polarity_flip_physical{70.0}=0x0 +phy_chain_tx_polarity_flip_physical{71.0}=0x0 +phy_chain_rx_polarity_flip_physical{71.0}=0x0 +phy_chain_tx_polarity_flip_physical{72.0}=0x0 +phy_chain_rx_polarity_flip_physical{72.0}=0x0 +phy_chain_tx_polarity_flip_physical{85.0}=0x1 +phy_chain_rx_polarity_flip_physical{85.0}=0x1 +phy_chain_tx_polarity_flip_physical{86.0}=0x0 +phy_chain_rx_polarity_flip_physical{86.0}=0x1 +phy_chain_tx_polarity_flip_physical{87.0}=0x1 +phy_chain_rx_polarity_flip_physical{87.0}=0x1 +phy_chain_tx_polarity_flip_physical{88.0}=0x0 +phy_chain_rx_polarity_flip_physical{88.0}=0x1 +phy_chain_tx_polarity_flip_physical{77.0}=0x1 +phy_chain_rx_polarity_flip_physical{77.0}=0x1 +phy_chain_tx_polarity_flip_physical{78.0}=0x1 +phy_chain_rx_polarity_flip_physical{78.0}=0x0 +phy_chain_tx_polarity_flip_physical{79.0}=0x1 +phy_chain_rx_polarity_flip_physical{79.0}=0x1 +phy_chain_tx_polarity_flip_physical{80.0}=0x1 +phy_chain_rx_polarity_flip_physical{80.0}=0x1 +phy_chain_tx_polarity_flip_physical{97.0}=0x1 +phy_chain_rx_polarity_flip_physical{97.0}=0x0 +phy_chain_tx_polarity_flip_physical{98.0}=0x0 +phy_chain_rx_polarity_flip_physical{98.0}=0x0 +phy_chain_tx_polarity_flip_physical{99.0}=0x1 +phy_chain_rx_polarity_flip_physical{99.0}=0x0 +phy_chain_tx_polarity_flip_physical{100.0}=0x0 +phy_chain_rx_polarity_flip_physical{100.0}=0x0 +phy_chain_tx_polarity_flip_physical{93.0}=0x1 +phy_chain_rx_polarity_flip_physical{93.0}=0x1 +phy_chain_tx_polarity_flip_physical{94.0}=0x1 +phy_chain_rx_polarity_flip_physical{94.0}=0x0 +phy_chain_tx_polarity_flip_physical{95.0}=0x1 +phy_chain_rx_polarity_flip_physical{95.0}=0x1 +phy_chain_tx_polarity_flip_physical{96.0}=0x1 +phy_chain_rx_polarity_flip_physical{96.0}=0x1 +phy_chain_tx_polarity_flip_physical{113.0}=0x1 +phy_chain_rx_polarity_flip_physical{113.0}=0x1 +phy_chain_tx_polarity_flip_physical{114.0}=0x0 +phy_chain_rx_polarity_flip_physical{114.0}=0x1 +phy_chain_tx_polarity_flip_physical{115.0}=0x1 +phy_chain_rx_polarity_flip_physical{115.0}=0x1 +phy_chain_tx_polarity_flip_physical{116.0}=0x0 +phy_chain_rx_polarity_flip_physical{116.0}=0x1 +phy_chain_tx_polarity_flip_physical{105.0}=0x1 +phy_chain_rx_polarity_flip_physical{105.0}=0x1 +phy_chain_tx_polarity_flip_physical{106.0}=0x1 +phy_chain_rx_polarity_flip_physical{106.0}=0x0 +phy_chain_tx_polarity_flip_physical{107.0}=0x1 +phy_chain_rx_polarity_flip_physical{107.0}=0x1 +phy_chain_tx_polarity_flip_physical{108.0}=0x1 +phy_chain_rx_polarity_flip_physical{108.0}=0x1 +phy_chain_tx_polarity_flip_physical{121.0}=0x1 +phy_chain_rx_polarity_flip_physical{121.0}=0x1 +phy_chain_tx_polarity_flip_physical{122.0}=0x0 +phy_chain_rx_polarity_flip_physical{122.0}=0x0 +phy_chain_tx_polarity_flip_physical{123.0}=0x1 +phy_chain_rx_polarity_flip_physical{123.0}=0x0 +phy_chain_tx_polarity_flip_physical{124.0}=0x0 +phy_chain_rx_polarity_flip_physical{124.0}=0x1 +phy_chain_tx_polarity_flip_physical{125.0}=0x0 +phy_chain_rx_polarity_flip_physical{125.0}=0x0 +phy_chain_tx_polarity_flip_physical{126.0}=0x1 +phy_chain_rx_polarity_flip_physical{126.0}=0x1 +phy_chain_tx_polarity_flip_physical{127.0}=0x0 +phy_chain_rx_polarity_flip_physical{127.0}=0x0 +phy_chain_tx_polarity_flip_physical{128.0}=0x0 +phy_chain_rx_polarity_flip_physical{128.0}=0x0 +port_flex_enable=1 +portmap_1=1:25 +portmap_2=2:25 +portmap_3=3:25 +portmap_4=4:25 +portmap_5=5:25 +portmap_6=6:25 +portmap_7=7:25 +portmap_8=8:25 +portmap_13=13:25 +portmap_14=14:25 +portmap_15=15:25 +portmap_16=16:25 +portmap_21=21:25 +portmap_22=22:25 +portmap_23=23:25 +portmap_24=24:25 +portmap_29=29:25 +portmap_30=30:25 +portmap_31=31:25 +portmap_32=32:25 +portmap_33=33:25 +portmap_34=34:25 +portmap_35=35:25 +portmap_36=36:25 +portmap_41=41:25 +portmap_42=42:25 +portmap_43=43:25 +portmap_44=44:25 +portmap_49=49:25 +portmap_50=50:25 +portmap_51=51:25 +portmap_52=52:25 +portmap_57=57:25 +portmap_58=58:25 +portmap_59=59:25 +portmap_60=60:25 +portmap_61=61:25 +portmap_62=62:25 +portmap_63=63:25 +portmap_64=64:25 +portmap_67=65:25 +portmap_68=66:25 +portmap_69=67:25 +portmap_70=68:25 +portmap_71=69:25 +portmap_72=70:25 +portmap_73=71:25 +portmap_74=72:25 +portmap_79=77:100 +portmap_87=85:100 +portmap_95=93:100 +portmap_99=97:100 +portmap_107=105:100 +portmap_115=113:100 +portmap_123=121:100 +portmap_127=125:100 + +dport_map_port_1=1 +dport_map_port_2=2 +dport_map_port_3=3 +dport_map_port_4=4 +dport_map_port_5=5 +dport_map_port_6=6 +dport_map_port_7=7 +dport_map_port_8=8 +dport_map_port_13=9 +dport_map_port_14=10 +dport_map_port_15=11 +dport_map_port_16=12 +dport_map_port_21=13 +dport_map_port_22=14 +dport_map_port_23=15 +dport_map_port_24=16 +dport_map_port_29=17 +dport_map_port_30=18 +dport_map_port_31=19 +dport_map_port_32=20 +dport_map_port_33=21 +dport_map_port_34=22 +dport_map_port_35=23 +dport_map_port_36=24 +dport_map_port_41=25 +dport_map_port_42=26 +dport_map_port_43=27 +dport_map_port_44=28 +dport_map_port_49=29 +dport_map_port_50=30 +dport_map_port_51=31 +dport_map_port_52=32 +dport_map_port_57=33 +dport_map_port_58=34 +dport_map_port_59=35 +dport_map_port_60=36 +dport_map_port_61=37 +dport_map_port_62=38 +dport_map_port_63=39 +dport_map_port_64=40 +dport_map_port_67=41 +dport_map_port_68=42 +dport_map_port_69=43 +dport_map_port_70=44 +dport_map_port_71=45 +dport_map_port_72=46 +dport_map_port_73=47 +dport_map_port_74=48 +dport_map_port_87=49 +dport_map_port_79=50 +dport_map_port_99=51 +dport_map_port_95=52 +dport_map_port_115=53 +dport_map_port_107=54 +dport_map_port_123=55 +dport_map_port_127=56 + +serdes_if_type_1=13 +serdes_if_type_2=13 +serdes_if_type_3=13 +serdes_if_type_4=13 +serdes_if_type_5=13 +serdes_if_type_6=13 +serdes_if_type_7=13 +serdes_if_type_8=13 +serdes_if_type_13=13 +serdes_if_type_14=13 +serdes_if_type_15=13 +serdes_if_type_16=13 +serdes_if_type_21=13 +serdes_if_type_22=13 +serdes_if_type_23=13 +serdes_if_type_24=13 +serdes_if_type_29=13 +serdes_if_type_30=13 +serdes_if_type_31=13 +serdes_if_type_32=13 +serdes_if_type_33=13 +serdes_if_type_34=13 +serdes_if_type_35=13 +serdes_if_type_36=13 +serdes_if_type_41=13 +serdes_if_type_42=13 +serdes_if_type_43=13 +serdes_if_type_44=13 +serdes_if_type_49=13 +serdes_if_type_50=13 +serdes_if_type_51=13 +serdes_if_type_52=13 +serdes_if_type_57=13 +serdes_if_type_58=13 +serdes_if_type_59=13 +serdes_if_type_60=13 +serdes_if_type_61=13 +serdes_if_type_62=13 +serdes_if_type_63=13 +serdes_if_type_64=13 +serdes_if_type_67=13 +serdes_if_type_68=13 +serdes_if_type_69=13 +serdes_if_type_70=13 +serdes_if_type_71=13 +serdes_if_type_72=13 +serdes_if_type_73=13 +serdes_if_type_74=13 +serdes_if_type_87=14 +serdes_if_type_79=14 +serdes_if_type_99=14 +serdes_if_type_95=14 +serdes_if_type_115=14 +serdes_if_type_107=14 +serdes_if_type_123=14 +serdes_if_type_127=14 + +reglist_enable=1 +scache_filename=/tmp/scache +schan_intr_enable=0 +stable_size=0x5500000 +tdma_timeout_usec=3000000 diff --git a/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/bcm.rc b/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/bcm.rc new file mode 100644 index 000000000000..7f69f10d3bda --- /dev/null +++ b/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/bcm.rc @@ -0,0 +1 @@ +rcload /usr/share/sonic/platform/led_proc_init.soc diff --git a/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/custom_led.bin b/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/custom_led.bin old mode 100644 new mode 100755 index 1fe5585e07796a7e30facd1faf391c9969ab8b08..e02f94e7ed87ffe60524721f4aec68d661880e7c GIT binary patch delta 152 zcmV;J0B8TK0_*{Q@U>S)Mn=H23jiBR765QI03?7X10je;0wo7m zf?>j80Wkq$A2C5q?Rz^)mL`LwmgRlw!DNAr6j7FS903-q@5HW~GeK|TnlSUN) zY95tAsvQB6*+v?ORvxwh1!#6#g=nfqQbYkd5_q~p1u6v5LPjz|Cea5X4B$mZH9%@Y zYC)2+04)X3F+u~-O-2AM0MG#zlh diff --git a/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/custom_led.bin_v1 b/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/custom_led.bin_v1 new file mode 100644 index 0000000000000000000000000000000000000000..1fe5585e07796a7e30facd1faf391c9969ab8b08 GIT binary patch literal 300 zcmV~$Jxc-s9Khk<`5MuS6lMfjo>FKzoEp^irsw%D2$v$4h&pXBr&^+h79((Ih@zor zYP3b78lr~q3wUEq5<#mUq37wm>_|cKVoK-vtkF$$?I3g^_a+g?q))5K>71Uv7C)8X zO{PAoTz$z%tq^?0T|U}6FV|(=RP=%4x2!wnvJFWX6Si0FY3F1nT`?+|t0&^_mS#9x zc_B_qQFG(dHoN^wlf6syH%u~};Fx!TH|X8hV7 z_23qD;f`S7lF5GzV(nT+Q^y9f=LVkf$CZeDzh_uF%kr>I`FYKD`eLmXf;U;{tHuD;Ze7>$f@av% zgCSlz(c*=6Vg!#wxw@UXuqvtQF#P>drO^$pZE}t_Ju@=OS5eW|Q7?+4_%^r@%5rR&XfcQvT1^*_present +#- fan_direction +#- fan_input +#- fan_pwm +#- fan_fault +# where idx is in the range [1-12] +# + + +import os.path +import sys +sys.path.append('/usr/share/sonic/platform/plugins') +import pddfparse +import json + +try: + from sonic_fan.fan_base import FanBase +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class FanUtil(FanBase): + """PDDF generic FAN util class""" + + def __init__(self): + FanBase.__init__(self) + global pddf_obj + global plugin_data + with open(os.path.join(os.path.dirname(os.path.realpath(__file__)) + '/../pddf/pd-plugin.json')) as pd: + plugin_data = json.load(pd) + + pddf_obj = pddfparse.PddfParse() + self.platform = pddf_obj.get_platform() + + self.num_fans = (self.platform['num_fantrays'] * self.platform['num_fans_pertray']) + + def get_num_fans(self): + return self.num_fans + + def get_presence(self, idx): + # 1 based fan index + if idx < 1 or idx > self.num_fans: + print("Invalid fan index %d\n" % idx) + return False + + attr_name = "fan" + str(idx) + "_present" + output = pddf_obj.get_attr_name_output("FAN-CTRL", attr_name) + if not output: + return False + + mode = output['mode'] + presence = output['status'].rstrip() + + vmap = plugin_data['FAN']['present'][mode]['valmap'] + + if presence in vmap: + status = vmap[presence] + else: + status = False + + return status + + def get_status(self, idx): + # 1 based fan index + if idx < 1 or idx > self.num_fans: + print("Invalid fan index %d\n" % idx) + return False + + speed = self.get_speed(idx) + status = True if (speed != 0) else False + return status + + def get_direction(self, idx): + # 1 based fan index + if idx < 1 or idx > self.num_fans: + print("Invalid fan index %d\n" % idx) + return None + + attr = "fan" + str(idx) + "_direction" + output = pddf_obj.get_attr_name_output("FAN-CTRL", attr) + if not output: + return None + + mode = output['mode'] + val = output['status'] + + val = val.rstrip() + vmap = plugin_data['FAN']['direction'][mode]['valmap'] + + if val in vmap: + direction = vmap[val] + else: + direction = val + + return direction + + def get_directions(self): + num_fan = self.get_num_fan() + + for i in range(1, num_fan+1): + attr = "fan" + str(i) + "_direction" + output = pddf_obj.get_attr_name_output("FAN-CTRL", attr) + if not output: + return None + + mode = output['mode'] + val = output['status'] + + val = val.rstrip() + vmap = plugin_data['FAN']['direction'][mode]['valmap'] + + direction = vmap[str(val)] + + print("FAN-%d direction is %s" % (i, direction)) + + return 0 + + def get_speed(self, idx): + # 1 based fan index + if idx < 1 or idx > self.num_fans: + print("Invalid fan index %d\n" % idx) + return 0 + + attr = "fan" + str(idx) + "_input" + output = pddf_obj.get_attr_name_output("FAN-CTRL", attr) + if not output: + return 0 + + #mode = output['mode'] + val = output['status'].rstrip() + + if val.isalpha(): + return 0 + else: + rpm_speed = int(float(val)) + + return rpm_speed + + def get_speeds(self): + num_fan = self.get_num_fan() + ret = "FAN_INDEX\t\tRPM\n" + + for i in range(1, num_fan+1): + attr1 = "fan" + str(i) + "_input" + output = pddf_obj.get_attr_name_output("FAN-CTRL", attr1) + if not output: + return "" + + #mode = output['mode'] + val = output['status'].rstrip() + + if val.isalpha(): + frpm = 0 + else: + frpm = int(val) + + ret += "FAN-%d\t\t\t%d\n" % (i, frpm) + + return ret + + def set_speed(self, val): + if val < 0 or val > 100: + print("Error: Invalid speed %d. Please provide a valid speed percentage" % val) + return False + + num_fan = self.num_fans + if 'duty_cycle_to_pwm' not in plugin_data['FAN']: + print("Setting fan speed is not allowed !") + return False + else: + print("setspeed nothing to do") + return False + + return True + + def dump_sysfs(self): + return pddf_obj.cli_dump_dsysfs('fan') + + def get_change_event(self): + """ + TODO: This function need to be implemented + when decide to support monitoring FAN(fand) + on this platform. + """ + raise NotImplementedError diff --git a/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/plugins/ledutil.py b/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/plugins/ledutil.py new file mode 100755 index 000000000000..5f9e2e99dbfa --- /dev/null +++ b/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/plugins/ledutil.py @@ -0,0 +1,59 @@ +import sys +sys.path.append('/usr/share/sonic/platform/plugins') +import pddfparse + + +class LedUtil: + color_map = { + "STATUS_LED_COLOR_GREEN": "on", + "STATUS_LED_COLOR_RED": "faulty", + "STATUS_LED_COLOR_OFF": "off" + } + + def __init__(self): + global pddf_obj + pddf_obj = pddfparse.PddfParse() + self.path = "pddf/devices/led" + self.cur_state_path = "pddf/devices/led/cur_state" + + def set_status_led(self, led_device_name, color, color_state="SOLID"): + if (not led_device_name in list(pddf_obj.data.keys())): + status = "ERROR: " + led_device_name + " is not configured" + return (status) + + if (not color in list(self.color_map.keys())): + status = "ERROR: Invalid color" + return (status) + + index = pddf_obj.data[led_device_name]['dev_attr']['index'] + pddf_obj.create_attr('device_name', led_device_name, self.path) + pddf_obj.create_attr('index', index, self.path) + pddf_obj.create_attr( + 'color', self.color_map[color], self.cur_state_path) + pddf_obj.create_attr('color_state', color_state, self.cur_state_path) + pddf_obj.create_attr('dev_ops', 'set_status', self.path) + return ("Executed") + + def get_status_led(self, led_device_name): + if (not led_device_name in list(pddf_obj.data.keys())): + status = "ERROR: " + led_device_name + " is not configured" + return (status) + + index = pddf_obj.data[led_device_name]['dev_attr']['index'] + pddf_obj.create_attr('device_name', led_device_name, self.path) + pddf_obj.create_attr('index', index, self.path) + pddf_obj.create_attr('dev_ops', 'get_status', self.path) + color_f = "/sys/kernel/" + self.cur_state_path + "/color" + color_state_f = "/sys/kernel/" + self.cur_state_path + "/color_state" + + try: + with open(color_f, 'r') as f: + color = f.read().strip("\r\n") + with open(color_state_f, 'r') as f: + color_state = f.read().strip("\r\n") + except IOError: + status = "ERROR :" + color_f + " open failed" + return (status) + status = "%s-%s:\t%s %s\n" % (led_device_name, + index, color, color_state) + return (status) diff --git a/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/plugins/psuutil.py b/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/plugins/psuutil.py new file mode 100755 index 000000000000..dccb1ac1a155 --- /dev/null +++ b/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/plugins/psuutil.py @@ -0,0 +1,270 @@ +# +# Sample pddf_psuutil file +# +# All the supported PSU SysFS aattributes are +#- psu_present +#- psu_model_name +#- psu_power_good +#- psu_mfr_id +#- psu_serial_num +#- psu_fan_dir +#- psu_v_out +#- psu_i_out +#- psu_p_out +#- psu_fan1_speed_rpm +# + +import os.path +import sys +sys.path.append('/usr/share/sonic/platform/plugins') +import pddfparse +import json + +try: + from sonic_psu.psu_base import PsuBase +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class PsuUtil(PsuBase): + """PDDF generic PSU util class""" + + def __init__(self): + PsuBase.__init__(self) + global pddf_obj + global plugin_data + with open(os.path.join(os.path.dirname(os.path.realpath(__file__)) + '/../pddf/pd-plugin.json')) as pd: + plugin_data = json.load(pd) + + pddf_obj = pddfparse.PddfParse() + self.platform = pddf_obj.get_platform() + + def get_num_psus(self): + return int(self.platform['num_psus']) + + def get_psu_status(self, index): + if index is None: + return False + + device = "PSU" + "%d" % index + output = pddf_obj.get_attr_name_output(device, "psu_power_good") + if not output: + return False + + mode = output['mode'] + val = output['status'] + + val = val.rstrip() + vmap = plugin_data['PSU']['psu_power_good'][mode]['valmap'] + + if val in vmap: + return vmap[val] + else: + return False + + def get_psu_presence(self, index): + if index is None: + return False + + status = 0 + device = "PSU" + "%d" % index + output = pddf_obj.get_attr_name_output(device, "psu_present") + if not output: + return False + + mode = output['mode'] + status = output['status'] + + vmap = plugin_data['PSU']['psu_present'][mode]['valmap'] + + if status.rstrip('\n') in vmap: + return vmap[status.rstrip('\n')] + else: + return False + + def get_powergood_status(self, idx): + if idx is None: + return False + + if idx < 1 or idx > self.platform['num_psus']: + print("Invalid index %d\n" % idx) + return False + + device = "PSU"+"%d" % (idx) + output = pddf_obj.get_attr_name_output(device, "psu_power_good") + if not output: + return False + + mode = output['mode'] + status = output['status'] + + vmap = plugin_data['PSU']['psu_power_good'][mode]['valmap'] + + if status.rstrip('\n') in vmap: + return vmap[status.rstrip('\n')] + else: + return False + + def get_model(self, idx): + if idx is None: + return None + + if idx < 1 or idx > self.platform['num_psus']: + print("Invalid index %d\n" % idx) + return None + + device = "PSU"+"%d" % (idx) + output = pddf_obj.get_attr_name_output(device, "psu_model_name") + if not output: + return None + + model = output['status'] + + # strip_non_ascii + stripped = (c for c in model if 0 < ord(c) < 127) + model = ''.join(stripped) + + return model.rstrip('\n') + + def get_mfr_id(self, idx): + if idx is None: + return None + + if idx < 1 or idx > self.platform['num_psus']: + print("Invalid index %d\n" % idx) + return None + + device = "PSU"+"%d" % (idx) + output = pddf_obj.get_attr_name_output(device, "psu_mfr_id") + if not output: + return None + + mfr = output['status'] + + return mfr.rstrip('\n') + + def get_serial(self, idx): + if idx is None: + return None + + if idx < 1 or idx > self.platform['num_psus']: + print("Invalid index %d\n" % idx) + return None + + device = "PSU"+"%d" % (idx) + output = pddf_obj.get_attr_name_output(device, "psu_serial_num") + if not output: + return None + + serial = output['status'] + + return serial.rstrip('\n') + + def get_direction(self, idx): + if idx is None: + return None + + if idx < 1 or idx > self.platform['num_psus']: + print("Invalid index %d\n" % idx) + return None + + device = "PSU"+"%d" % (idx) + output = pddf_obj.get_attr_name_output(device, "psu_fan_dir") + if not output: + return None + + mode = output['mode'] + direction = output['status'].rstrip('\n') + + vmap = plugin_data['PSU']['psu_fan_dir'][mode]['valmap'] + if direction in vmap: + airflow_dir_real = vmap[direction] + else: + airflow_dir_real = direction + + return airflow_dir_real + + def get_output_voltage(self, idx): + if idx is None: + return 0.0 + + if idx < 1 or idx > self.platform['num_psus']: + print("Invalid index %d\n" % idx) + return 0.0 + + device = "PSU"+"%d" % (idx) + output = pddf_obj.get_attr_name_output(device, "psu_v_out") + if not output: + return 0.0 + + v_out = output['status'] + + # value returned by the psu driver is in mV + return float(v_out)/1000 + + def get_output_current(self, idx): + if idx is None: + return 0.0 + + if idx < 1 or idx > self.platform['num_psus']: + print("Invalid index %d\n" % idx) + return 0.0 + + device = "PSU"+"%d" % (idx) + output = pddf_obj.get_attr_name_output(device, "psu_i_out") + if not output: + return 0.0 + + i_out = output['status'] + + # current in mA + return float(i_out)/1000 + + def get_output_power(self, idx): + if idx is None: + return 0.0 + + if idx < 1 or idx > self.platform['num_psus']: + print("Invalid index %d\n" % idx) + return 0.0 + + device = "PSU"+"%d" % (idx) + output = pddf_obj.get_attr_name_output(device, "psu_p_out") + if not output: + return 0.0 + + p_out = output['status'] + + # power is returned in micro watts + return float(p_out)/1000000 + + def get_fan_rpm(self, idx, fan_idx): + if idx is None or fan_idx is None: + return 0 + + if idx < 1 or idx > self.platform['num_psus']: + print("Invalid index %d\n" % idx) + return 0 + + device = "PSU"+"%d" % (idx) + num_fans = pddf_obj.get_num_psu_fans(device) + + if fan_idx < 1 or fan_idx > num_fans: + print("Invalid PSU-fan index %d\n" % fan_idx) + return 0 + + output = pddf_obj.get_attr_name_output(device, "psu_fan"+str(fan_idx)+"_speed_rpm") + if not output: + return 0 + + #mode = output['mode'] + output['status'] = output['status'].rstrip() + if output['status'].isalpha(): + return 0 + else: + speed = int(output['status']) + + return speed + + def dump_sysfs(self): + return pddf_obj.cli_dump_dsysfs('psu') diff --git a/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/plugins/sfputil.py b/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/plugins/sfputil.py new file mode 100755 index 000000000000..1ca925610822 --- /dev/null +++ b/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/plugins/sfputil.py @@ -0,0 +1,236 @@ +import os.path +import sys +sys.path.append('/usr/share/sonic/platform/plugins') +import pddfparse +import json + +try: + import time + from ctypes import create_string_buffer + from sonic_sfp.sfputilbase import SfpUtilBase +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class SfpUtil(SfpUtilBase): + """Platform generic PDDF SfpUtil class""" + + _port_to_eeprom_mapping = {} + _port_start = 0 + _port_end = 0 + _port_to_type_mapping = {} + _qsfp_ports = [] + _sfp_ports = [] + + def __init__(self): + SfpUtilBase.__init__(self) + global pddf_obj + global plugin_data + with open(os.path.join(os.path.dirname(os.path.realpath(__file__)) + '/../pddf/pd-plugin.json')) as pd: + plugin_data = json.load(pd) + + pddf_obj = pddfparse.PddfParse() + self.platform = pddf_obj.get_platform() + self._port_start = 0 + self._port_end = self.get_num_ports() + + for port_num in range(self._port_start, self._port_end): + device = "PORT" + "%d" % (port_num+1) + port_eeprom_path = pddf_obj.get_path(device, "eeprom") + self._port_to_eeprom_mapping[port_num] = port_eeprom_path + port_type = pddf_obj.get_device_type(device) + self._port_to_type_mapping[port_num] = port_type + self.populate_port_type(port_num) + + def get_num_ports(self): + return int(self.platform['num_ports']) + + def is_valid_port(self, port_num): + if port_num < self._port_start or port_num > self._port_end: + return False + else: + return True + + def get_presence(self, port_num): + if port_num < self._port_start or port_num > self._port_end: + return False + + device = "PORT" + "%d" % (port_num+1) + output = pddf_obj.get_attr_name_output(device, 'xcvr_present') + if not output: + return False + + #mode = output['mode'] + modpres = output['status'].rstrip() + if 'XCVR' in plugin_data: + if 'xcvr_present' in plugin_data['XCVR']: + ptype = self._port_to_type_mapping[port_num] + vtype = 'valmap-'+ptype + if vtype in plugin_data['XCVR']['xcvr_present']: + vmap = plugin_data['XCVR']['xcvr_present'][vtype] + if modpres in vmap: + return vmap[modpres] + else: + return False + # if plugin_data doesn't specify anything regarding Transceivers + if modpres == '1': + return True + + return False + + def populate_port_type(self, port): + if self._port_to_type_mapping[port] == 'QSFP' or self._port_to_type_mapping[port] == 'QSFP28': + self._qsfp_ports.append(port) + elif self._port_to_type_mapping[port] == 'SFP' or self._port_to_type_mapping[port] == 'SFP28': + self._sfp_ports.append(port) + + @property + def port_start(self): + return self._port_start + + @property + def port_end(self): + return (self._port_end - 1) + + @property + def port_to_eeprom_mapping(self): + return self._port_to_eeprom_mapping + + @property + def qsfp_ports(self): + return self._qsfp_ports + + def reset(self, port_num): + if port_num < self._port_start or port_num > self._port_end: + return False + + device = "PORT" + "%d" % (port_num+1) + port_ps = pddf_obj.get_path(device, "xcvr_reset") + if port_ps is None: + return False + + try: + reg_file = open(port_ps, 'w') + except IOError as e: + print("Error: unable to open file: %s" % str(e)) + return False + + try: + reg_file.seek(0) + reg_file.write('1') + time.sleep(1) + reg_file.seek(0) + reg_file.write('0') + reg_file.close() + return True + except IOError as e: + return False + + def get_low_power_mode(self, port_num): + # Check for invalid port_num + if port_num < self._port_start or port_num > self._port_end: + return False + + if not self.get_presence(port_num): + return False + + device = "PORT" + "%d" % (port_num+1) + output = pddf_obj.get_attr_name_output(device, 'xcvr_lpmode') + if not output: + if port_num not in self.qsfp_ports: + return False # Read from eeprom only for QSFP ports + try: + eeprom = None + eeprom = open(self.port_to_eeprom_mapping[port_num], "rb") + # check for valid connector type + eeprom.seek(2) + ctype = eeprom.read(1) + if ctype in ['21', '23']: + return False + + eeprom.seek(93) + lpmode = ord(eeprom.read(1)) + + if ((lpmode & 0x3) == 0x3): + return True # Low Power Mode if "Power override" bit is 1 and "Power set" bit is 1 + else: + # High Power Mode if one of the following conditions is matched: + # 1. "Power override" bit is 0 + # 2. "Power override" bit is 1 and "Power set" bit is 0 + return False + except IOError as e: + print("Error: unable to open file: %s" % str(e)) + return False + finally: + if eeprom is not None: + eeprom.close() + time.sleep(0.01) + else: + #mode = output['mode'] + status = int(output['status'].rstrip()) + + if status == 1: + return True + else: + return False + + def set_low_power_mode(self, port_num, lpmode): + # Check for invalid port_num + if port_num < self._port_start or port_num > self._port_end: + return False + + if not self.get_presence(port_num): + return False # Port is not present, unable to set the eeprom + + device = "PORT" + "%d" % (port_num+1) + port_ps = pddf_obj.get_path(device, "xcvr_lpmode") + if port_ps is None: + if port_num not in self.qsfp_ports: + return False # Write to eeprom only for QSFP ports + try: + eeprom = None + eeprom = open(self.port_to_eeprom_mapping[port_num], "r+b") + # check for valid connector type + eeprom.seek(2) + ctype = eeprom.read(1) + if ctype in ['21', '23']: + return False + + # Fill in write buffer + regval = 0x3 if lpmode else 0x1 # 0x3:Low Power Mode, 0x1:High Power Mode + buffer = create_string_buffer(1) + buffer[0] = chr(regval) + + # Write to eeprom + eeprom.seek(93) + eeprom.write(buffer[0]) + return True + except IOError as e: + print("Error: unable to open file: %s" % str(e)) + return False + finally: + if eeprom is not None: + eeprom.close() + time.sleep(0.01) + else: + try: + f = open(port_ps, 'w') + if lpmode: + f.write('1') + else: + f.write('0') + f.close() + return True + except IOError as e: + return False + + def get_transceiver_change_event(self): + """ + TODO: This function need to be implemented + when decide to support monitoring SFP(Xcvrd) + on this platform. + """ + raise NotImplementedError + + def dump_sysfs(self): + return pddf_obj.cli_dump_dsysfs('xcvr') diff --git a/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/plugins/ssd_util.py b/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/plugins/ssd_util.py new file mode 100755 index 000000000000..c532804f66c7 --- /dev/null +++ b/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/plugins/ssd_util.py @@ -0,0 +1,309 @@ +# +# ssd_util.py +# +# Generic implementation of the SSD health API +# SSD models supported: +# - InnoDisk +# - StorFly +# - Virtium + +try: + import re + import os + import subprocess + from sonic_platform_base.sonic_ssd.ssd_base import SsdBase +except ImportError as e: + raise ImportError (str(e) + "- required module not found") + +SMARTCTL = "smartctl {} -a" +INNODISK = "iSmart -d {}" +VIRTIUM = "SmartCmd -m {}" +DISK_LIST_CMD = "fdisk -l -o Device" +DISK_FREE_CMD = "df -h" +MOUNT_CMD = "mount" + +NOT_AVAILABLE = "N/A" +PE_CYCLE = 3000 +FAIL_PERCENT = 95 + +# Set Vendor Specific IDs +INNODISK_HEALTH_ID = 169 +INNODISK_TEMPERATURE_ID = 194 + +class SsdUtil(SsdBase): + """ + Generic implementation of the SSD health API + """ + model = NOT_AVAILABLE + serial = NOT_AVAILABLE + firmware = NOT_AVAILABLE + temperature = NOT_AVAILABLE + health = NOT_AVAILABLE + remaining_life = NOT_AVAILABLE + sata_rate = NOT_AVAILABLE + ssd_info = NOT_AVAILABLE + vendor_ssd_info = NOT_AVAILABLE + + def __init__(self, diskdev): + self.vendor_ssd_utility = { + "Generic" : { "utility" : SMARTCTL, "parser" : self.parse_generic_ssd_info }, + "InnoDisk" : { "utility" : INNODISK, "parser" : self.parse_innodisk_info }, + "M.2" : { "utility" : INNODISK, "parser" : self.parse_innodisk_info }, + "StorFly" : { "utility" : VIRTIUM, "parser" : self.parse_virtium_info }, + "Virtium" : { "utility" : VIRTIUM, "parser" : self.parse_virtium_info } + } + + """ + The dict model_attr keys relate the vendors + LITEON : "ER2-GD","AF2MA31DTDLT" + Intel : "SSDSCKKB" + SMI : "SM619GXC" + samsung: "MZNLH" + ADATA : "IM2S3134N" + """ + self.model_attr = { + "ER2-GD" : { "temperature" : "\n190\s+(.+?)\n", "remainingLife" : "\n202\s+(.+?)\n" }, + "AF2MA31DTDLT" : { "temperature" : "\n194\s+(.+?)\n", "remainingLife" : "\n202\s+(.+?)\n" }, + "SSDSCKKB" : { "temperature" : "\n194\s+(.+?)\n", "remainingLife" : "\n233\s+(.+?)\n" }, + "SM619GXC" : { "temperature" : "\n194\s+(.+?)\n", "remainingLife" : "\n169\s+(.+?)\n" }, + "MZNLH" : { "temperature" : "\n190\s+(.+?)\n", "remainingLife" : "\n245\s+(.+?)\n" }, + "IM2S3134N" : { "temperature" : "\n194\s+(.+?)\n", "remainingLife" : "\n231\s+(.+?)\n" } + } + + self.key_list = list(self.model_attr.keys()) + self.attr_info_rule = "[\s\S]*SMART Attributes Data Structure revision number: 1|SMART Error Log Version[\s\S]*" + self.dev = diskdev + # Generic part + self.fetch_generic_ssd_info(diskdev) + self.parse_generic_ssd_info() + self.fetch_vendor_ssd_info(diskdev, "Generic") + + # Known vendor part + if self.model: + model_short = self.model.split()[0] + if model_short in self.vendor_ssd_utility: + self.fetch_vendor_ssd_info(diskdev, model_short) + self.parse_vendor_ssd_info(model_short) + else: + # No handler registered for this disk model + pass + else: + # Failed to get disk model + self.model = "Unknown" + + def _execute_shell(self, cmd): + process = subprocess.Popen(cmd.split(), universal_newlines=True, stdout=subprocess.PIPE) + output, error = process.communicate() + exit_code = process.returncode + if exit_code: + return None + return output + + def _parse_re(self, pattern, buffer): + res_list = re.findall(pattern, str(buffer)) + return res_list[0] if res_list else NOT_AVAILABLE + + def fetch_generic_ssd_info(self, diskdev): + self.ssd_info = self._execute_shell(self.vendor_ssd_utility["Generic"]["utility"].format(diskdev)) + + # Health and temperature values may be overwritten with vendor specific data + def parse_generic_ssd_info(self): + if "nvme" in self.dev: + self.model = self._parse_re('Model Number:\s*(.+?)\n', self.ssd_info) + + health_raw = self._parse_re('Percentage Used\s*(.+?)\n', self.ssd_info) + if health_raw == NOT_AVAILABLE: + self.health = NOT_AVAILABLE + else: + health_raw = health_raw.split()[-1] + self.health = 100 - float(health_raw.strip('%')) + + temp_raw = self._parse_re('Temperature\s*(.+?)\n', self.ssd_info) + if temp_raw == NOT_AVAILABLE: + self.temperature = NOT_AVAILABLE + else: + temp_raw = temp_raw.split()[-2] + self.temperature = float(temp_raw) + else: + self.model = self._parse_re('Device Model:\s*(.+?)\n', self.ssd_info) + model_key = "" + for key in self.key_list: + if re.search(key, self.model): + model_key = key + break + if model_key != "": + self.remaining_life = self._parse_re(self.model_attr[model_key]["remainingLife"], re.sub(self.attr_info_rule,"",self.ssd_info)).split()[2] + self.temperature = self._parse_re(self.model_attr[model_key]["temperature"], re.sub(self.attr_info_rule,"",self.ssd_info)).split()[8] + self.health = self.remaining_life + # Get the LITEON ssd health value by (PE CYCLE - AVG ERASE CYCLE )/(PE CYCLE) + if model_key in ["ER2-GD", "AF2MA31DTDLT"]: + avg_erase = int(self._parse_re('\n173\s+(.+?)\n' ,re.sub(self.attr_info_rule,"",self.ssd_info)).split()[-1]) + self.health = int(round((PE_CYCLE - avg_erase)/PE_CYCLE*100,0)) + if self.remaining_life != NOT_AVAILABLE and int(self.remaining_life) < FAIL_PERCENT: + self.remaining_life = "Fail" + self.sata_rate = self._parse_re('SATA Version is:.*current: (.+?)\)\n', self.ssd_info) + self.serial = self._parse_re('Serial Number:\s*(.+?)\n', self.ssd_info) + self.firmware = self._parse_re('Firmware Version:\s*(.+?)\n', self.ssd_info) + + def parse_innodisk_info(self): + if self.vendor_ssd_info: + self.health = self._parse_re('Health:\s*(.+?)%', self.vendor_ssd_info) + self.temperature = self._parse_re('Temperature\s*\[\s*(.+?)\]', self.vendor_ssd_info) + else: + if self.health == NOT_AVAILABLE: + health_raw = self.parse_id_number(INNODISK_HEALTH_ID) + self.health = health_raw.split()[-1] + if self.temperature == NOT_AVAILABLE: + temp_raw = self.parse_id_number(INNODISK_TEMPERATURE_ID) + self.temperature = temp_raw.split()[-6] + + def parse_virtium_info(self): + if self.vendor_ssd_info: + self.temperature = self._parse_re('Temperature_Celsius\s*\d*\s*(\d+?)\s+', self.vendor_ssd_info) + nand_endurance = self._parse_re('NAND_Endurance\s*\d*\s*(\d+?)\s+', self.vendor_ssd_info) + avg_erase_count = self._parse_re('Average_Erase_Count\s*\d*\s*(\d+?)\s+', self.vendor_ssd_info) + try: + self.health = 100 - (float(avg_erase_count) * 100 / float(nand_endurance)) + except (ValueError, ZeroDivisionError): + pass + + def fetch_vendor_ssd_info(self, diskdev, model): + self.vendor_ssd_info = self._execute_shell(self.vendor_ssd_utility[model]["utility"].format(diskdev)) + + def parse_vendor_ssd_info(self, model): + self.vendor_ssd_utility[model]["parser"]() + + def check_readonly2(self, partition, filesystem): + # parse mount cmd output info + mount_info = self._execute_shell(MOUNT_CMD) + for line in mount_info.split('\n'): + column_list = line.split() + if line == '': + continue + if column_list[0] == partition and column_list[2] == filesystem: + if column_list[5].split(',')[0][1:] == "ro": + return partition + else: + return NOT_AVAILABLE + + def check_readonly(self, partition, filesystem): + ret = os.access(filesystem, os.W_OK) + if ret == False: + return partition + else: + return NOT_AVAILABLE + + def get_health(self): + """ + Retrieves current disk health in percentages + + Returns: + A float number of current ssd health + e.g. 83.5 + """ + return float(self.health) + + def get_temperature(self): + """ + Retrieves current disk temperature in Celsius + + Returns: + A float number of current temperature in Celsius + e.g. 40.1 + """ + return float(self.temperature) + + def get_model(self): + """ + Retrieves model for the given disk device + + Returns: + A string holding disk model as provided by the manufacturer + """ + return self.model + + def get_firmware(self): + """ + Retrieves firmware version for the given disk device + + Returns: + A string holding disk firmware version as provided by the manufacturer + """ + return self.firmware + + def get_serial(self): + """ + Retrieves serial number for the given disk device + + Returns: + A string holding disk serial number as provided by the manufacturer + """ + return self.serial + def get_sata_rate(self): + """ + Retrieves SATA rate for the given disk device + Returns: + A string holding current SATA rate as provided by the manufacturer + """ + return self.sata_rate + def get_remaining_life(self): + """ + Retrieves remaining life for the given disk device + Returns: + A string holding disk remaining life as provided by the manufacturer + """ + return self.remaining_life + def get_vendor_output(self): + """ + Retrieves vendor specific data for the given disk device + + Returns: + A string holding some vendor specific disk information + """ + return self.vendor_ssd_info + + def parse_id_number(self, id): + return self._parse_re('{}\s*(.+?)\n'.format(id), self.ssd_info) + + def get_readonly_partition(self): + """ + Check the partition mount filesystem is readonly status,then output the result. + Returns: + The readonly partition list + """ + + ro_partition_list = [] + partition_list = [] + + # parse fdisk cmd output info + disk_info = self._execute_shell(DISK_LIST_CMD) + begin_flag = False + for line in disk_info.split('\n'): + if line == "Device": + begin_flag = True + continue + if begin_flag: + if line != "": + partition_list.append(line) + else: + break + + # parse df cmd output info + disk_free = self._execute_shell(DISK_FREE_CMD) + disk_dict = {} + line_num = 0 + for line in disk_free.split('\n'): + line_num = line_num + 1 + if line_num == 1 or line == "": + continue + column_list = line.split() + disk_dict[column_list[0]] = column_list[5] + + # get partition which is readonly + for partition in partition_list: + if partition in disk_dict: + ret = self.check_readonly(partition, disk_dict[partition]) + if (ret != NOT_AVAILABLE): + ro_partition_list.append(ret) + + return ro_partition_list diff --git a/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/plugins/sysstatutil.py b/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/plugins/sysstatutil.py new file mode 100755 index 000000000000..af4dd5915361 --- /dev/null +++ b/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/plugins/sysstatutil.py @@ -0,0 +1,82 @@ +import os.path +import sys +sys.path.append('/usr/share/sonic/platform/plugins') +import pddfparse +import json + + +class SYSStatusUtil(): + """Platform-specific SYSStatus class""" + + def __init__(self): + global pddf_obj + global plugin_data + with open(os.path.join(os.path.dirname(os.path.realpath(__file__)) + '/../pddf/pd-plugin.json')) as pd: + plugin_data = json.load(pd) + + pddf_obj = pddfparse.PddfParse() + + def get_board_info(self): + device = "SYSSTATUS" + node = pddf_obj.get_path(device, "board_info") + if node is None: + return False + try: + with open(node, 'r') as f: + status = f.read() + print("board_info : %s" % status) + except IOError: + return False + + def get_cpld_versio(self): + device = "SYSSTATUS" + node = pddf_obj.get_path(device, "cpld1_version") + if node is None: + return False + try: + with open(node, 'r') as f: + status = f.read() + print("cpld1_version : %s" % status) + except IOError: + return False + + def get_power_module_status(self): + device = "SYSSTATUS" + node = pddf_obj.get_path(device, "power_module_status") + if node is None: + return False + try: + with open(node, 'r') as f: + status = f.read() + print("power_module_status : %s" % status) + except IOError: + return False + + def get_system_reset_status(self): + device = "SYSSTATUS" + for i in range(1, 8): + node = pddf_obj.get_path(device, "system_reset"+str(i)) + if node is None: + return False + try: + with open(node, 'r') as f: + status = f.read() + print("system_reset%s : %s" % (i, status)) + except IOError: + print("system_reset%s not supported" % i) + + def get_misc_status(self): + device = "SYSSTATUS" + for i in range(1, 3): + node = pddf_obj.get_path(device, "misc"+str(i)) + if node is None: + return False + try: + with open(node, 'r') as f: + status = f.read() + print("misc%s : %s" % (i, status)) + except IOError: + print("system_reset%s not supported" % i) + + def dump_sysfs(self): + return pddf_obj.cli_dump_dsysfs('sys-status') diff --git a/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/plugins/thermalutil.py b/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/plugins/thermalutil.py new file mode 100755 index 000000000000..6aef47b7e924 --- /dev/null +++ b/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/plugins/thermalutil.py @@ -0,0 +1,75 @@ +import os.path +import sys +import json +sys.path.append('/usr/share/sonic/platform/plugins') +import pddfparse + + +class ThermalUtil: + def __init__(self): + global pddf_obj + global plugin_data + with open(os.path.join(os.path.dirname(os.path.realpath(__file__)) + '/../pddf/pd-plugin.json')) as pd: + plugin_data = json.load(pd) + + pddf_obj = pddfparse.PddfParse() + self.platform = pddf_obj.get_platform() + self.num_thermals = self.platform['num_temps'] + self.info = [] + + def get_num_thermals(self): + return (self.num_thermals) + + def get_thermal_info(self): + list = [] + pddf_obj.get_device_list(list, "TEMP_SENSOR") + list.sort() + for dev in list: + data = {} + device_name = dev['dev_info']['device_name'] + topo_info = dev['i2c']['topo_info'] + label = "%s-i2c-%d-%x" % (topo_info['dev_type'], + int(topo_info['parent_bus'], 0), int(topo_info['dev_addr'], 0)) + attr_list = dev['i2c']['attr_list'] + data['device_name'] = device_name + data['label'] = label + for attr in attr_list: + attr_name = attr['attr_name'] + node = pddf_obj.get_path(device_name, attr_name) + if node is None: + return False + try: + with open(node, 'r') as f: + attr_value = int(f.read()) + except IOError: + return False + data[attr_name] = attr_value/float(1000) + self.info.append(data) + + def show_thermal_temp_values(self, idx): + if idx < 1 or idx > self.num_thermals: + print("Invalid temperature sensor idx %d" % idx) + return None + self.get_thermal_info() + thermal_name = "TEMP"+"%d" % idx + label = "" + value = "" + for temp in self.info: + if thermal_name == temp['device_name']: + label = temp['label'] + value = "temp1\t %+.1f C (high = %+.1f C, hyst = %+.1f C)" % ( + temp['temp1_input'], temp['temp1_max'], temp['temp1_max_hyst']) + else: + continue + + return (label, value) + + def show_temp_values(self): + self.get_thermal_info() + for temp in self.info: + print(temp['label']) + print("temp1\t %+.1f C (high = %+.1f C, hyst = %+.1f C)" % + (temp['temp1_input'], temp['temp1_max'], temp['temp1_max_hyst'])) + + def dump_sysfs(self): + return pddf_obj.cli_dump_dsysfs('temp-sensors') diff --git a/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/pmon_daemon_control.json b/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/pmon_daemon_control.json index 590def37b276..94592fa8cebc 100644 --- a/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/pmon_daemon_control.json +++ b/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/pmon_daemon_control.json @@ -1,5 +1,3 @@ -{ - "skip_ledd": true, - "skip_xcvrd": false, - "skip_psud": false -} \ No newline at end of file +{ + "skip_ledd": true +} diff --git a/device/ragile/x86_64-ragile_ra-b6910-64c-r0/minigraph.xml b/device/ragile/x86_64-ragile_ra-b6910-64c-r0/minigraph.xml deleted file mode 100644 index e6b05e400606..000000000000 --- a/device/ragile/x86_64-ragile_ra-b6910-64c-r0/minigraph.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - - - switch2 - - - - - - - - - - - - - switch2 - RA-B6910-64C - - - - - - - switch2 - - - DhcpResources - - - - - NtpResources - - 0.debian.pool.ntp.org;1.debian.pool.ntp.org;2.debian.pool.ntp.org;3.debian.pool.ntp.org - - - SyslogResources - - - - - ErspanDestinationIpv4 - - 2.2.2.2 - - - - - - - switch2 - RA-B6910-64C - 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..ec0929bce90f 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,6 +5,7 @@ # * PSU # import os +import commands import xml.etree.ElementTree as ET import glob diff --git a/device/ragile/x86_64-ragile_ra-b6910-64c-r0/pddf/pddf-device.json b/device/ragile/x86_64-ragile_ra-b6910-64c-r0/pddf/pddf-device.json index 3f5aae68c544..a5cf533a7f90 100644 --- a/device/ragile/x86_64-ragile_ra-b6910-64c-r0/pddf/pddf-device.json +++ b/device/ragile/x86_64-ragile_ra-b6910-64c-r0/pddf/pddf-device.json @@ -73,12 +73,12 @@ "CONTROLLERS": [{ "dev_name": "i2c-0", "dev": "SMBUS0" - }, { - "dev_name": "i2c-1", - "dev": "I2C-GPIO0" }, { "dev_name": "i2c-2", "dev": "SMBUS1" + }, { + "dev_name": "i2c-1", + "dev": "I2C-GPIO0" }] } }, @@ -1370,6 +1370,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x30", @@ -1378,6 +1379,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x40", @@ -1451,6 +1453,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x30", @@ -1459,6 +1462,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x40", @@ -1532,6 +1536,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x30", @@ -1540,6 +1545,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x40", @@ -1614,6 +1620,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x30", @@ -1622,6 +1629,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x40", @@ -1696,6 +1704,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x30", @@ -1704,6 +1713,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x40", @@ -1778,6 +1788,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x30", @@ -1786,6 +1797,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x40", @@ -1859,6 +1871,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x30", @@ -1867,6 +1880,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x40", @@ -1940,6 +1954,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x30", @@ -1948,6 +1963,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x40", @@ -2021,6 +2037,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x31", @@ -2029,6 +2046,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x41", @@ -2102,6 +2120,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x31", @@ -2110,6 +2129,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x41", @@ -2184,6 +2204,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x31", @@ -2192,6 +2213,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x41", @@ -2266,6 +2288,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x31", @@ -2274,6 +2297,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x41", @@ -2348,6 +2372,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x31", @@ -2356,6 +2381,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x41", @@ -2430,6 +2456,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x31", @@ -2438,6 +2465,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x41", @@ -2511,6 +2539,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x31", @@ -2519,6 +2548,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x41", @@ -2592,6 +2622,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x31", @@ -2600,6 +2631,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x41", @@ -2673,6 +2705,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x30", @@ -2681,6 +2714,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x40", @@ -2754,6 +2788,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x30", @@ -2762,6 +2797,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x40", @@ -2836,6 +2872,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x30", @@ -2844,6 +2881,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x40", @@ -2918,6 +2956,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x30", @@ -2926,6 +2965,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x40", @@ -3000,6 +3040,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x30", @@ -3008,6 +3049,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x40", @@ -3082,6 +3124,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x30", @@ -3090,6 +3133,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x40", @@ -3163,6 +3207,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x30", @@ -3171,6 +3216,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x40", @@ -3244,6 +3290,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x30", @@ -3252,6 +3299,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x40", @@ -3325,6 +3373,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x31", @@ -3333,6 +3382,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x41", @@ -3406,6 +3456,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x31", @@ -3414,6 +3465,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x41", @@ -3488,6 +3540,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x31", @@ -3496,6 +3549,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x41", @@ -3570,6 +3624,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x31", @@ -3578,6 +3633,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x41", @@ -3652,6 +3708,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x31", @@ -3660,6 +3717,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x41", @@ -3734,6 +3792,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x31", @@ -3742,6 +3801,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x41", @@ -3815,6 +3875,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x31", @@ -3823,6 +3884,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x41", @@ -3896,6 +3958,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x31", @@ -3904,6 +3967,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x41", @@ -3977,6 +4041,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x32", @@ -3985,6 +4050,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x42", @@ -4058,6 +4124,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x32", @@ -4066,6 +4133,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x42", @@ -4140,6 +4208,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x32", @@ -4148,6 +4217,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x42", @@ -4222,6 +4292,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x32", @@ -4230,6 +4301,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x42", @@ -4304,6 +4376,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x32", @@ -4312,6 +4385,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x42", @@ -4386,6 +4460,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x32", @@ -4394,6 +4469,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x42", @@ -4467,6 +4543,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x32", @@ -4475,6 +4552,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x42", @@ -4548,6 +4626,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x32", @@ -4556,6 +4635,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x42", @@ -4629,6 +4709,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x33", @@ -4637,6 +4718,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x43", @@ -4710,6 +4792,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x33", @@ -4718,6 +4801,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x43", @@ -4792,6 +4876,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x33", @@ -4800,6 +4885,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x43", @@ -4874,6 +4960,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x33", @@ -4882,6 +4969,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x43", @@ -4956,6 +5044,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x33", @@ -4964,6 +5053,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x43", @@ -5038,6 +5128,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x33", @@ -5046,6 +5137,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x43", @@ -5119,6 +5211,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x33", @@ -5127,6 +5220,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x43", @@ -5200,6 +5294,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x33", @@ -5208,6 +5303,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD1_B", "attr_devaddr": "0x34", "attr_devtype": "cpld", "attr_offset": "0x43", @@ -5281,6 +5377,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x32", @@ -5289,6 +5386,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x42", @@ -5362,6 +5460,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x32", @@ -5370,6 +5469,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x42", @@ -5444,6 +5544,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x32", @@ -5452,6 +5553,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x42", @@ -5526,6 +5628,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x32", @@ -5534,6 +5637,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x42", @@ -5608,6 +5712,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x32", @@ -5616,6 +5721,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x42", @@ -5690,6 +5796,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x32", @@ -5698,6 +5805,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x42", @@ -5771,6 +5879,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x32", @@ -5779,6 +5888,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x42", @@ -5852,6 +5962,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x32", @@ -5860,6 +5971,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x42", @@ -5933,6 +6045,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x33", @@ -5941,6 +6054,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x43", @@ -6014,6 +6128,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x33", @@ -6022,6 +6137,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x43", @@ -6095,6 +6211,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x33", @@ -6103,6 +6220,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x43", @@ -6176,6 +6294,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x33", @@ -6184,6 +6303,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x43", @@ -6257,6 +6377,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x33", @@ -6265,6 +6386,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x43", @@ -6338,6 +6460,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x33", @@ -6346,6 +6469,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x43", @@ -6419,6 +6543,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x33", @@ -6427,6 +6552,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x43", @@ -6500,6 +6626,7 @@ }, "attr_list": [{ "attr_name": "xcvr_present", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x33", @@ -6508,6 +6635,7 @@ "attr_len": "1" }, { "attr_name": "xcvr_intr_status", + "attr_devname": "MAC_BOARD_CPLD2_B", "attr_devaddr": "0x36", "attr_devtype": "cpld", "attr_offset": "0x43", 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..ac8069d38a27 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 @@ -170,20 +170,8 @@ 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']) - pwm = duty_cycle_to_pwm(val) - print("New Speed: %d%% - PWM value to be set is %d\n" % (val, pwm)) - - for i in range(1, num_fan+1): - attr = "fan" + str(i) + "_pwm" - node = pddf_obj.get_path("FAN-CTRL", attr) - if node is None: - return False - try: - with open(node, 'w') as f: - f.write(str(pwm)) - except IOError: - return False + print("setspeed nothing to do") + return False return True diff --git a/device/ragile/x86_64-ragile_ra-b6910-64c-r0/pmon_daemon_control.json b/device/ragile/x86_64-ragile_ra-b6910-64c-r0/pmon_daemon_control.json index b8d554f3a8b8..94592fa8cebc 100644 --- a/device/ragile/x86_64-ragile_ra-b6910-64c-r0/pmon_daemon_control.json +++ b/device/ragile/x86_64-ragile_ra-b6910-64c-r0/pmon_daemon_control.json @@ -1,5 +1,3 @@ { - "skip_ledd": true, - "skip_xcvrd": false, - "skip_psud": false -} \ No newline at end of file + "skip_ledd": true +} diff --git a/device/ragile/x86_64-ragile_ra-b6920-4s-r0/minigraph.xml b/device/ragile/x86_64-ragile_ra-b6920-4s-r0/minigraph.xml deleted file mode 100644 index 4aa22016c11a..000000000000 --- a/device/ragile/x86_64-ragile_ra-b6920-4s-r0/minigraph.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - - - switch2 - - - - - - - - - - - - - switch2 - RA-B6920-4S - - - - - - - switch2 - - - DhcpResources - - - - - NtpResources - - 0.debian.pool.ntp.org;1.debian.pool.ntp.org;2.debian.pool.ntp.org;3.debian.pool.ntp.org - - - SyslogResources - - - - - ErspanDestinationIpv4 - - 2.2.2.2 - - - - - - - switch2 - RA-B6920-4S - diff --git a/platform/broadcom/platform-modules-ragile.mk b/platform/broadcom/platform-modules-ragile.mk index 74ce1b04f475..12236b1e72ce 100644 --- a/platform/broadcom/platform-modules-ragile.mk +++ b/platform/broadcom/platform-modules-ragile.mk @@ -4,7 +4,7 @@ export RAGILE_RA_B6510_48V8C_PLATFORM_MODULE_VERSION RAGILE_RA_B6510_48V8C_PLATFORM_MODULE = platform-modules-ragile-ra-b6510-48v8c_$(RAGILE_RA_B6510_48V8C_PLATFORM_MODULE_VERSION)_amd64.deb $(RAGILE_RA_B6510_48V8C_PLATFORM_MODULE)_SRC_PATH = $(PLATFORM_PATH)/sonic-platform-modules-ragile -$(RAGILE_RA_B6510_48V8C_PLATFORM_MODULE)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON) +$(RAGILE_RA_B6510_48V8C_PLATFORM_MODULE)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON) $(PDDF_PLATFORM_MODULE) $(RAGILE_RA_B6510_48V8C_PLATFORM_MODULE)_PLATFORM = x86_64-ragile_ra-b6510-48v8c-r0 SONIC_DPKG_DEBS += $(RAGILE_RA_B6510_48V8C_PLATFORM_MODULE) SONIC_STRETCH_DEBS += $(RAGILE_RA_B6510_48V8C_PLATFORM_MODULE) diff --git a/platform/broadcom/rules.mk b/platform/broadcom/rules.mk index c43a66ee43e3..96ed76c97edf 100644 --- a/platform/broadcom/rules.mk +++ b/platform/broadcom/rules.mk @@ -14,7 +14,7 @@ include $(PLATFORM_PATH)/platform-modules-cel.mk 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-ragile.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/sonic-platform-modules-ragile/common/Makefile b/platform/broadcom/sonic-platform-modules-ragile/common/Makefile index 6daf3d2b2fd1..5b682c06c01b 100755 --- a/platform/broadcom/sonic-platform-modules-ragile/common/Makefile +++ b/platform/broadcom/sonic-platform-modules-ragile/common/Makefile @@ -11,13 +11,10 @@ SCRIPT_DIR = $(PWD)/script SERVICE_DIR = $(PWD)/service DEPMOD_CONF_DIR = $(PWD)/depmod_conf -KBUILD_EXTRA_SYMBOLS += $(DIR_KERNEL_SRC)/Module.symvers -export KBUILD_EXTRA_SYMBOLS - 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.7/dist-packages +INSTALL_LIB_DIR = $(SUB_BUILD_DIR)/usr/lib/python3.9/dist-packages INSTALL_DEPMOD_CONF = $(SUB_BUILD_DIR)/etc/depmod.d all: diff --git a/platform/broadcom/sonic-platform-modules-ragile/common/lib/eepromutil/fantlv.py b/platform/broadcom/sonic-platform-modules-ragile/common/lib/eepromutil/fantlv.py index 38beb068f44c..36f2c3b97652 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/common/lib/eepromutil/fantlv.py +++ b/platform/broadcom/sonic-platform-modules-ragile/common/lib/eepromutil/fantlv.py @@ -9,11 +9,11 @@ def __init__(self, message='fantlverror', code=-100): class fan_tlv(object): HEAD_INFO = "\x01\x7e\x01\xf1" - VERSION = 0x01 # E2PROM file init version is 0x01 - FLAG = 0x7E #new version E2PROM mark as 0x7E - HW_VER = 0X01 # consists of master version and revised version + VERSION = 0x01 # E2PROM file init version is 0x01 + FLAG = 0x7E # new version E2PROM mark as 0x7E + HW_VER = 0X01 # consists of master version and revised version TYPE = 0xf1 # hardware type define - TLV_LEN = 00 # vaild data length(16bit) + TLV_LEN = 00 # vaild data length(16bit) _FAN_TLV_HDR_LEN = 6 _FAN_TLV_CRC_LEN = 2 diff --git a/platform/broadcom/sonic-platform-modules-ragile/common/lib/eepromutil/fru.py b/platform/broadcom/sonic-platform-modules-ragile/common/lib/eepromutil/fru.py index 90a690a19edd..853d7abd0913 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/common/lib/eepromutil/fru.py +++ b/platform/broadcom/sonic-platform-modules-ragile/common/lib/eepromutil/fru.py @@ -229,8 +229,8 @@ def decodedata(self): 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): @@ -483,7 +483,7 @@ def decodedata(self): 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: diff --git a/platform/broadcom/sonic-platform-modules-ragile/common/modules/csu550.c b/platform/broadcom/sonic-platform-modules-ragile/common/modules/csu550.c index 3df7c73ecad0..b1d1a9847218 100755 --- a/platform/broadcom/sonic-platform-modules-ragile/common/modules/csu550.c +++ b/platform/broadcom/sonic-platform-modules-ragile/common/modules/csu550.c @@ -29,8 +29,15 @@ #include #include #include +#include #include "pmbus.h" +struct pmbus_device_info { + int pages; + u32 flags; +}; + +static const struct i2c_device_id pmbus_id[]; /* * Find sensor groups and status registers on each page. @@ -114,7 +121,7 @@ static int pmbus_identify(struct i2c_client *client, } if (pmbus_check_byte_register(client, 0, PMBUS_VOUT_MODE)) { - int vout_mode; + int vout_mode, i; vout_mode = pmbus_read_byte_data(client, 0, PMBUS_VOUT_MODE); if (vout_mode >= 0 && vout_mode != 0xff) { @@ -123,6 +130,11 @@ static int pmbus_identify(struct i2c_client *client, break; case 1: info->format[PSC_VOLTAGE_OUT] = vid; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) + for (i = 0; i < info->pages; i++) { + info->vrm_version[i] = vr11; + } +#endif break; case 2: info->format[PSC_VOLTAGE_OUT] = direct; @@ -156,6 +168,7 @@ static int pmbus_identify(struct i2c_client *client, return ret; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) static int pmbus_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct pmbus_driver_info *info; @@ -182,7 +195,34 @@ static int pmbus_probe(struct i2c_client *client, const struct i2c_device_id *id return pmbus_do_probe(client, id, info); } +#else +static int pmbus_probe(struct i2c_client *client) +{ + struct pmbus_driver_info *info; + struct pmbus_platform_data *pdata = NULL; + struct device *dev = &client->dev; + struct pmbus_device_info *device_info; + info = devm_kzalloc(dev, sizeof(struct pmbus_driver_info), GFP_KERNEL); + if (!info) + return -ENOMEM; + + device_info = (struct pmbus_device_info *)i2c_match_id(pmbus_id, client)->driver_data; + if (device_info->flags & PMBUS_SKIP_STATUS_CHECK) { + pdata = devm_kzalloc(dev, sizeof(struct pmbus_platform_data), GFP_KERNEL); + if (!pdata) { + return -ENOMEM; + } + pdata->flags = PMBUS_SKIP_STATUS_CHECK; + } + + info->pages = device_info->pages; + info->identify = pmbus_identify; + dev->platform_data = pdata; + + return pmbus_do_probe(client, info); +} +#endif static const struct i2c_device_id pmbus_id[] = { {"csu550", 0}, {"csu800", 1}, @@ -194,8 +234,11 @@ MODULE_DEVICE_TABLE(i2c, pmbus_id); /* This is the driver that will be inserted */ static struct i2c_driver pmbus_driver = { +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) .probe = pmbus_probe, - .remove = pmbus_do_remove, +#else + .probe_new = pmbus_probe, +#endif .id_table = pmbus_id, .driver = { .name = "pmbus", diff --git a/platform/broadcom/sonic-platform-modules-ragile/common/modules/fpga_i2c_ocores.c b/platform/broadcom/sonic-platform-modules-ragile/common/modules/fpga_i2c_ocores.c index 81068a14029e..7857f854d60e 100755 --- a/platform/broadcom/sonic-platform-modules-ragile/common/modules/fpga_i2c_ocores.c +++ b/platform/broadcom/sonic-platform-modules-ragile/common/modules/fpga_i2c_ocores.c @@ -25,10 +25,10 @@ #include #include #include -#include +#include "fpga_i2c_ocores.h" #include #include - +#include struct ocores_i2c { void __iomem *base; @@ -835,8 +835,13 @@ static int rg_ocores_i2c_probe(struct platform_device *pdev) /* add in known devices to the bus */ if (pdata) { - for (i = 0; i < pdata->num_devices; i++) + for (i = 0; i < pdata->num_devices; i++) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) + i2c_new_client_device(&i2c->adap, pdata->devices + i); +#else i2c_new_device(&i2c->adap, pdata->devices + i); +#endif + } } oc_debug_sysfs_init(pdev); diff --git a/platform/broadcom/sonic-platform-modules-ragile/common/modules/fpga_pcie_i2c.c b/platform/broadcom/sonic-platform-modules-ragile/common/modules/fpga_pcie_i2c.c index 82ae9f558f50..ff26c29643c9 100755 --- a/platform/broadcom/sonic-platform-modules-ragile/common/modules/fpga_pcie_i2c.c +++ b/platform/broadcom/sonic-platform-modules-ragile/common/modules/fpga_pcie_i2c.c @@ -11,9 +11,9 @@ #include #include -#include -#include -#include +#include "fpga_i2c_ocores.h" +#include "fpga_pcie_i2c.h" +#include "fpga_reg_defs.h" #include #include @@ -746,6 +746,47 @@ static fpga_pcie_card_info_t g_fpga_pcie_card_info[] = { }, }, }, + /* RA-B6510-48V8C */ + { + .dev_type = 0x404a, + .pca9548_cfg_info = { + { + .pca9548_bus = 12, + .pca9548_addr = 0x70, + .cfg_offset = 0x20, + }, + { + .pca9548_bus = 12, + .pca9548_addr = 0x71, + .cfg_offset = 0x20, + }, + { + .pca9548_bus = 12, + .pca9548_addr = 0x72, + .cfg_offset = 0x20, + }, + { + .pca9548_bus = 12, + .pca9548_addr = 0x73, + .cfg_offset = 0x20, + }, + { + .pca9548_bus = 13, + .pca9548_addr = 0x70, + .cfg_offset = 0x20, + }, + { + .pca9548_bus = 13, + .pca9548_addr = 0x71, + .cfg_offset = 0x20, + }, + { + .pca9548_bus = 13, + .pca9548_addr = 0x72, + .cfg_offset = 0x20, + }, + }, + }, }; extern void pca954x_hw_do_reset_func_register(void* func); diff --git a/platform/broadcom/sonic-platform-modules-ragile/common/modules/i2c-mux-pca954x.c b/platform/broadcom/sonic-platform-modules-ragile/common/modules/i2c-mux-pca954x.c index f7b6bb952bf9..44875828bf56 100755 --- a/platform/broadcom/sonic-platform-modules-ragile/common/modules/i2c-mux-pca954x.c +++ b/platform/broadcom/sonic-platform-modules-ragile/common/modules/i2c-mux-pca954x.c @@ -40,7 +40,13 @@ #include #include #include +#include +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) +#include +#include +#else #include +#endif #include #include #include @@ -63,7 +69,12 @@ extern int pca9641_setmuxflag(int nr, int flag); int force_create_bus = 0; +static int close_chan_force_reset = 0; +static int select_chan_check = 0; + module_param(force_create_bus, int, S_IRUGO | S_IWUSR); +module_param(close_chan_force_reset, int, S_IRUGO | S_IWUSR); +module_param(select_chan_check, int, S_IRUGO | S_IWUSR); enum pca_type { pca_9540, @@ -86,14 +97,15 @@ struct chip_desc { } muxtype; }; - - - struct pca954x { const struct chip_desc *chip; u8 last_chan; /* last register value */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) + s32 idle_state; +#else u8 deselect; +#endif struct i2c_client *client; struct irq_domain *irq; @@ -157,7 +169,20 @@ static const struct i2c_device_id pca954x_id[] = { { } }; MODULE_DEVICE_TABLE(i2c, pca954x_id); - +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) +static const struct of_device_id pca954x_of_match[] = { + { .compatible = "nxp,pca9540", .data = &chips[pca_9540] }, + { .compatible = "nxp,pca9542", .data = &chips[pca_9542] }, + { .compatible = "nxp,pca9543", .data = &chips[pca_9543] }, + { .compatible = "nxp,pca9544", .data = &chips[pca_9544] }, + { .compatible = "nxp,pca9545", .data = &chips[pca_9545] }, + { .compatible = "nxp,pca9546", .data = &chips[pca_9546] }, + { .compatible = "nxp,pca9547", .data = &chips[pca_9547] }, + { .compatible = "nxp,pca9548", .data = &chips[pca_9548] }, + {} +}; +MODULE_DEVICE_TABLE(of, pca954x_of_match); +#else #ifdef CONFIG_OF static const struct of_device_id pca954x_of_match[] = { { .compatible = "nxp,pca9540", .data = &chips[pca_9540] }, @@ -172,6 +197,7 @@ static const struct of_device_id pca954x_of_match[] = { }; MODULE_DEVICE_TABLE(of, pca954x_of_match); #endif +#endif /* Write to mux register. Don't use i2c_transfer()/i2c_smbus_xfer() for this as they will try to lock adapter a second time */ @@ -204,37 +230,59 @@ static int pca954x_reg_write(struct i2c_adapter *adap, return ret; } -static int pca954x_setmuxflag(struct i2c_client *client, int flag) +static int pca954x_reg_read(struct i2c_adapter *adap, + struct i2c_client *client, u8 *val) { - struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent); - pca9641_setmuxflag(adap->nr, flag); - return 0; -} + int ret = -ENODEV; + u8 tmp_val; -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; - const struct chip_desc *chip = data->chip; - u8 regval; - int ret = 0; + if (adap->algo->master_xfer) { + struct i2c_msg msg; - /* we make switches look like muxes, not sure how to be smarter */ - if (chip->muxtype == pca954x_ismux) - regval = chan | chip->enable; - else - regval = 1 << chan; + msg.addr = client->addr; + msg.flags = I2C_M_RD; + msg.len = 1; + msg.buf = &tmp_val; + ret = __i2c_transfer(adap, &msg, 1); - /* Only select the channel if its different from the last channel */ - if (data->last_chan != regval) { - pca954x_setmuxflag(client, 0); - ret = pca954x_reg_write(muxc->parent, client, regval); - data->last_chan = ret < 0 ? 0 : regval; + if (ret >= 0 && ret != 1) { + ret = -EREMOTEIO; + } else { + *val = tmp_val; + } + } else { + union i2c_smbus_data data; + ret = adap->algo->smbus_xfer(adap, client->addr, + client->flags, + I2C_SMBUS_READ, + 0, I2C_SMBUS_BYTE, &data); + + if (!ret) { + tmp_val = data.byte; + *val = tmp_val; + } } return ret; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) +static u8 pca954x_regval(struct pca954x *data, u8 chan) +{ + /* We make switches look like muxes, not sure how to be smarter. */ + if (data->chip->muxtype == pca954x_ismux) + return chan | data->chip->enable; + else + return 1 << chan; +} +#endif + +static int pca954x_setmuxflag(struct i2c_client *client, int flag) +{ + struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent); + pca9641_setmuxflag(adap->nr, flag); + return 0; +} typedef void (*pca954x_hw_do_reset_func_t)(int busid, int addr); pca954x_hw_do_reset_func_t g_notify_to_do_reset = NULL; @@ -328,124 +376,34 @@ static pca9548_card_info_t g_pca9548_card_info[] = { { .dev_type = {0x404a}, /* RA-B6510-48V8C */ .pca9548_cfg_info = { - /* psu fan */ - { - .pca9548_reset_type = PCA9548_RESET_GPIO, - .pca9548_bus = 2, - .pca9548_addr = 0x70, - .rst_delay_b = 0, - .rst_delay = 1000, - .rst_delay_a = 1000, - .attr = { - .gpio_attr.gpio = 7, - .gpio_attr.gpio_init = 0, - .gpio_attr.reset_on = 1, - .gpio_attr.reset_off = 0, - }, - }, - /* sff1 */ - { - .pca9548_reset_type = PCA9548_RESET_FUNC, - .pca9548_bus = 1, - .pca9548_addr = 0x70, - .rst_delay_b = 0, - .rst_delay = 1000, - .rst_delay_a = 1000, - .attr = { - .func_attr.reset_func = pca954x_hw_do_reset_by_i2c, - .func_attr.get_umask_func = pca954x_get_umask_by_i2c, - .func_attr.cfg_offset = {CPLD_PCA9548_RESET, -1}, - .func_attr.umask = {BIT(0), -1}, - }, - }, - /* sff2 */ + /* fan */ { .pca9548_reset_type = PCA9548_RESET_FUNC, - .pca9548_bus = 1, - .pca9548_addr = 0x71, + .pca9548_bus = 2, + .pca9548_addr = 0x77, .rst_delay_b = 0, .rst_delay = 1000, .rst_delay_a = 1000, .attr = { .func_attr.reset_func = pca954x_hw_do_reset_by_i2c, .func_attr.get_umask_func = pca954x_get_umask_by_i2c, - .func_attr.cfg_offset = {CPLD_PCA9548_RESET, -1}, + .func_attr.cfg_offset = {0x060d0060, -1}, /* bus:6, addr:0x0d, offset:0x60 */ .func_attr.umask = {BIT(1), -1}, }, }, - /* sff3 */ - { - .pca9548_reset_type = PCA9548_RESET_FUNC, - .pca9548_bus = 1, - .pca9548_addr = 0x72, - .rst_delay_b = 0, - .rst_delay = 1000, - .rst_delay_a = 1000, - .attr = { - .func_attr.reset_func = pca954x_hw_do_reset_by_i2c, - .func_attr.get_umask_func = pca954x_get_umask_by_i2c, - .func_attr.cfg_offset = {CPLD_PCA9548_RESET, -1}, - .func_attr.umask = {BIT(2), -1}, - }, - }, - /* sff4 */ - { - .pca9548_reset_type = PCA9548_RESET_FUNC, - .pca9548_bus = 1, - .pca9548_addr = 0x73, - .rst_delay_b = 0, - .rst_delay = 1000, - .rst_delay_a = 1000, - .attr = { - .func_attr.reset_func = pca954x_hw_do_reset_by_i2c, - .func_attr.get_umask_func = pca954x_get_umask_by_i2c, - .func_attr.cfg_offset = {CPLD_PCA9548_RESET, -1}, - .func_attr.umask = {BIT(3), -1}, - }, - }, - /* sff5 */ - { - .pca9548_reset_type = PCA9548_RESET_FUNC, - .pca9548_bus = 1, - .pca9548_addr = 0x74, - .rst_delay_b = 0, - .rst_delay = 1000, - .rst_delay_a = 1000, - .attr = { - .func_attr.reset_func = pca954x_hw_do_reset_by_i2c, - .func_attr.get_umask_func = pca954x_get_umask_by_i2c, - .func_attr.cfg_offset = {CPLD_PCA9548_RESET, -1}, - .func_attr.umask = {BIT(4), -1}, - }, - }, - /* sff6 */ - { - .pca9548_reset_type = PCA9548_RESET_FUNC, - .pca9548_bus = 1, - .pca9548_addr = 0x75, - .rst_delay_b = 0, - .rst_delay = 1000, - .rst_delay_a = 1000, - .attr = { - .func_attr.reset_func = pca954x_hw_do_reset_by_i2c, - .func_attr.get_umask_func = pca954x_get_umask_by_i2c, - .func_attr.cfg_offset = {CPLD_PCA9548_RESET, -1}, - .func_attr.umask = {BIT(5), -1}, - }, - }, - /* sff7 */ + /* psu */ { .pca9548_reset_type = PCA9548_RESET_FUNC, - .pca9548_bus = 1, - .pca9548_addr = 0x76, + .pca9548_bus = 4, + .pca9548_addr = 0x77, .rst_delay_b = 0, .rst_delay = 1000, .rst_delay_a = 1000, .attr = { .func_attr.reset_func = pca954x_hw_do_reset_by_i2c, .func_attr.get_umask_func = pca954x_get_umask_by_i2c, - .func_attr.cfg_offset = {CPLD_PCA9548_RESET, -1}, - .func_attr.umask = {BIT(6), -1}, + .func_attr.cfg_offset = {0x060d0060, -1}, /* bus:6, addr:0x0d, offset:0x60 */ + .func_attr.umask = {BIT(0), -1}, }, }, }, @@ -1132,6 +1090,179 @@ static int pca954x_do_reset(struct i2c_adapter *adap, ret = 0; return ret; } + +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; + u8 regval; + int ret = 0; + u8 read_val; + int rv; + + read_val = 0; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) + regval = pca954x_regval(data, chan); +#else + const struct chip_desc *chip = data->chip; + /* we make switches look like muxes, not sure how to be smarter */ + if (chip->muxtype == pca954x_ismux) + regval = chan | chip->enable; + else + regval = 1 << chan; +#endif + + /* Only select the channel if its different from the last channel */ + if (data->last_chan != regval) { + pca954x_setmuxflag(client, 0); + ret = pca954x_reg_write(muxc->parent, client, regval); + data->last_chan = ret < 0 ? 0 : regval; + } + + if (select_chan_check) { /* check chan */ + ret = pca954x_reg_read(muxc->parent, client, &read_val); + /* read failed or chan not open, reset pca9548 */ + if ((ret < 0) || (read_val != data->last_chan)) { + dev_warn(&client->dev, "pca954x open channle %u failed, do reset.\n", chan); + PCA954X_DEBUG("ret = %d, read_val = %d, last_chan = %d.\n", ret, read_val, data->last_chan); + rv = pca954x_do_reset(client->adapter, client, chan); + if (rv >= 0) { + PCA954X_DEBUG("pca954x_do_reset success, rv = %d.\n", rv); + } else { + PCA954X_DEBUG("pca954x_do_reset failed, rv = %d.\n", rv); + } + if (ret >= 0) { + ret = -EIO; /* chan not match, return IO error */ + } + } + } + + return ret; +} + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) +static int pca954x_deselect_mux(struct i2c_mux_core *muxc, u32 chan) +{ + struct pca954x *data = i2c_mux_priv(muxc); + struct i2c_client *client = data->client; + s32 idle_state; + int ret, rv; + struct i2c_client * new_client; + + if (close_chan_force_reset) { + data->last_chan = 0; + ret = pca954x_do_reset(client->adapter, client, chan); + if (ret < 0) { + dev_warn(&client->dev, "pca954x do reset failed %d.\n", ret); + } + return ret; + } else { + idle_state = READ_ONCE(data->idle_state); + if (idle_state >= 0) + /* Set the mux back to a predetermined channel */ + return pca954x_select_chan(muxc, idle_state); + if (idle_state == MUX_IDLE_DISCONNECT) { + /* Deselect active channel */ + data->last_chan = 0; + ret = pca954x_reg_write(muxc->parent, client, + data->last_chan); + if (ret < 0) { + new_client =(struct i2c_client *) client; + dev_warn(&new_client->dev, "pca954x close chn failed, do reset.\n"); + rv = pca954x_do_reset(client->adapter, client, chan); + if (rv == 0) { + ret = 0; + } + } + return ret; + } + } + + /* otherwise leave as-is */ + + return 0; +} + +static ssize_t idle_state_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct i2c_mux_core *muxc = i2c_get_clientdata(client); + struct pca954x *data = i2c_mux_priv(muxc); + + return sprintf(buf, "%d\n", READ_ONCE(data->idle_state)); +} + +static ssize_t idle_state_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct i2c_client *client = to_i2c_client(dev); + struct i2c_mux_core *muxc = i2c_get_clientdata(client); + struct pca954x *data = i2c_mux_priv(muxc); + int val; + int ret; + + ret = kstrtoint(buf, 0, &val); + if (ret < 0) + return ret; + + if (val != MUX_IDLE_AS_IS && val != MUX_IDLE_DISCONNECT && + (val < 0 || val >= data->chip->nchans)) + return -EINVAL; + + i2c_lock_bus(muxc->parent, I2C_LOCK_SEGMENT); + + WRITE_ONCE(data->idle_state, val); + /* + * Set the mux into a state consistent with the new + * idle_state. + */ + if (data->last_chan || val != MUX_IDLE_DISCONNECT) + ret = pca954x_deselect_mux(muxc, 0); + + i2c_unlock_bus(muxc->parent, I2C_LOCK_SEGMENT); + + return ret < 0 ? ret : count; +} + +static DEVICE_ATTR_RW(idle_state); + +static irqreturn_t pca954x_irq_handler(int irq, void *dev_id) +{ + struct pca954x *data = dev_id; + unsigned long pending; + int ret, i; + + ret = i2c_smbus_read_byte(data->client); + if (ret < 0) + return IRQ_NONE; + + pending = (ret >> PCA954X_IRQ_OFFSET) & (BIT(data->chip->nchans) - 1); + for_each_set_bit(i, &pending, data->chip->nchans) + handle_nested_irq(irq_linear_revmap(data->irq, i)); + + return IRQ_RETVAL(pending); +} + +static int pca954x_init(struct i2c_client *client, struct pca954x *data) +{ + int ret; + + if (data->idle_state >= 0) + data->last_chan = pca954x_regval(data, data->idle_state); + else + data->last_chan = 0; /* Disconnect multiplexer */ + + ret = i2c_smbus_write_byte(client, data->last_chan); + if (ret < 0) + data->last_chan = 0; + + return ret; +} + +#else static int pca954x_deselect_mux(struct i2c_mux_core *muxc, u32 chan) { struct pca954x *data = i2c_mux_priv(muxc); @@ -1178,6 +1309,7 @@ static irqreturn_t pca954x_irq_handler(int irq, void *dev_id) } return handled ? IRQ_HANDLED : IRQ_NONE; } +#endif static void pca954x_irq_mask(struct irq_data *idata) { @@ -1274,11 +1406,13 @@ static int pca954x_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent); +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) struct pca954x_platform_data *pdata = dev_get_platdata(&client->dev); +#endif struct device_node *of_node = client->dev.of_node; bool idle_disconnect_dt; struct gpio_desc *gpio; - int num, force, class; + int num; struct i2c_mux_core *muxc; struct pca954x *data; const struct of_device_id *match; @@ -1302,7 +1436,25 @@ static int pca954x_probe(struct i2c_client *client, gpio = devm_gpiod_get_optional(&client->dev, "reset", GPIOD_OUT_LOW); if (IS_ERR(gpio)) return PTR_ERR(gpio); - +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) + data->idle_state = MUX_IDLE_DISCONNECT; + if (device_property_read_u32(&client->dev, "idle-state", &data->idle_state)) { + if (device_property_read_bool(&client->dev, "i2c-mux-idle-disconnect")) + data->idle_state = MUX_IDLE_DISCONNECT; + } + + /* + * Write the mux register at addr to verify + * that the mux is in fact present. This also + * initializes the mux to a channel + * or disconnected state. + */ + ret = pca954x_init(client, data); + if (ret < 0) { + dev_warn(&client->dev, "probe failed\n"); + return -ENODEV; + } +#else /* Write the mux register at addr to verify * that the mux is in fact present. This also * initializes the mux to disconnected state. @@ -1311,7 +1463,7 @@ static int pca954x_probe(struct i2c_client *client, dev_warn(&client->dev, "probe failed\n"); return -ENODEV; } - +#endif match = of_match_device(of_match_ptr(pca954x_of_match), &client->dev); if (match) data->chip = of_device_get_match_data(&client->dev); @@ -1329,10 +1481,12 @@ static int pca954x_probe(struct i2c_client *client, /* Now create an adapter for each channel */ for (num = 0; num < data->chip->nchans; num++) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) + ret = i2c_mux_add_adapter(muxc, 0, num, 0); +#else bool idle_disconnect_pd = false; - - force = 0; /* dynamic adap number */ - class = 0; /* no class by default */ + int force = 0; /* dynamic adap number */ + int class = 0; /* no class by default */ if (pdata) { if (num < pdata->num_modes) { /* force static number */ @@ -1347,10 +1501,17 @@ static int pca954x_probe(struct i2c_client *client, idle_disconnect_dt) << num; ret = i2c_mux_add_adapter(muxc, force, num, class); +#endif if (ret) goto fail_del_adapters; } - +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) + /* + * The attr probably isn't going to be needed in most cases, + * so don't fail completely on error. + */ + device_create_file(&client->dev, &dev_attr_idle_state); +#endif dev_info(&client->dev, "registered %d multiplexed busses for I2C %s %s\n", num, data->chip->muxtype == pca954x_ismux @@ -1376,7 +1537,9 @@ static int pca954x_remove(struct i2c_client *client) } irq_domain_remove(data->irq); } - +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) + device_remove_file(&client->dev, &dev_attr_idle_state); +#endif i2c_mux_del_adapters(muxc); return 0; } @@ -1387,9 +1550,18 @@ static int pca954x_resume(struct device *dev) struct i2c_client *client = to_i2c_client(dev); struct i2c_mux_core *muxc = i2c_get_clientdata(client); struct pca954x *data = i2c_mux_priv(muxc); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) + int ret; + ret = pca954x_init(client, data); + if (ret < 0) + dev_err(&client->dev, "failed to verify mux presence\n"); + + return ret; +#else data->last_chan = 0; return i2c_smbus_write_byte(client, 0); +#endif } #endif diff --git a/platform/broadcom/sonic-platform-modules-ragile/common/modules/i2c-mux-pca9641.c b/platform/broadcom/sonic-platform-modules-ragile/common/modules/i2c-mux-pca9641.c index 501cfef8a91b..4988fcc7f2c3 100755 --- a/platform/broadcom/sonic-platform-modules-ragile/common/modules/i2c-mux-pca9641.c +++ b/platform/broadcom/sonic-platform-modules-ragile/common/modules/i2c-mux-pca9641.c @@ -23,7 +23,12 @@ #include #include #include +#include +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) +#include +#else #include +#endif /* * The PCA9541 is a bus master selector. It supports two I2C masters connected @@ -546,7 +551,9 @@ static int pca9541_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct i2c_adapter *adap = client->adapter; +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) struct pca954x_platform_data *pdata = dev_get_platdata(&client->dev); +#endif struct i2c_mux_core *muxc; struct pca9541 *data; int force; @@ -573,11 +580,11 @@ static int pca9541_probe(struct i2c_client *client, } /* Create mux adapter */ - +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) force = 0; if (pdata) force = pdata->modes[0].adap_id; - +#endif if (detect_id == 0) { muxc = i2c_mux_alloc(adap, &client->dev, 1, sizeof(*data), I2C_MUX_ARBITRATOR, @@ -589,8 +596,11 @@ static int pca9541_probe(struct i2c_client *client, data->client = client; i2c_set_clientdata(client, muxc); - +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) + ret = i2c_mux_add_adapter(muxc, 0, 0, 0); +#else ret = i2c_mux_add_adapter(muxc, force, 0, 0); +#endif if (ret) return ret; } else { diff --git a/platform/broadcom/sonic-platform-modules-ragile/common/modules/lpc_cpld_i2c_ocores.c b/platform/broadcom/sonic-platform-modules-ragile/common/modules/lpc_cpld_i2c_ocores.c index 7115fdabec1d..fe805c10c4ce 100755 --- a/platform/broadcom/sonic-platform-modules-ragile/common/modules/lpc_cpld_i2c_ocores.c +++ b/platform/broadcom/sonic-platform-modules-ragile/common/modules/lpc_cpld_i2c_ocores.c @@ -25,10 +25,11 @@ #include #include #include -#include +#include "lpc_cpld_i2c_ocores.h" #include #include #include +#include #define OCORES_FLAG_POLL BIT(0) @@ -245,8 +246,8 @@ static void ocores_process(struct ocores_i2c *i2c, u8 stat) static irqreturn_t ocores_isr(int irq, void *dev_id) { - struct ocores_i2c *i2c = dev_id; - unsigned long flags; + struct ocores_i2c *i2c = dev_id; + unsigned long flags; u8 stat; if (!i2c) { return IRQ_NONE; @@ -394,8 +395,8 @@ static int ocores_xfer_core(struct ocores_i2c *i2c, unsigned long flags; u8 ctrl; - LPC_CPLD_I2C_DEBUG_XFER("Enter.polling %d\n", polling); - LPC_CPLD_I2C_SPIN_LOCK(i2c->process_lock, flags); + LPC_CPLD_I2C_DEBUG_XFER("Enter.polling %d\n", polling); + LPC_CPLD_I2C_SPIN_LOCK(i2c->process_lock, flags); ctrl = oc_getreg(i2c, OCI2C_CONTROL); if (polling) oc_setreg(i2c, OCI2C_CONTROL, ctrl & ~OCI2C_CTRL_IEN); @@ -590,7 +591,7 @@ static void oc_debug_dump_reg(struct ocores_i2c *i2c) LPC_CPLD_I2C_DEBUG_DUMP("msg->buf: %p.\n", i2c->msg->buf); LPC_CPLD_I2C_DEBUG_DUMP("msg->addr: 0x%x.\n", i2c->msg->addr); LPC_CPLD_I2C_DEBUG_DUMP("msg->flags: 0x%x.\n", i2c->msg->flags); - LPC_CPLD_I2C_DEBUG_DUMP("msg->len: %d.\n", i2c->msg->len); + LPC_CPLD_I2C_DEBUG_DUMP("msg->len: %d.\n", i2c->msg->len); } else { LPC_CPLD_I2C_DEBUG_DUMP("msg: %p is null.\n", i2c->msg); } @@ -711,7 +712,7 @@ static int rg_ocores_i2c_probe(struct platform_device *pdev) return ret; } - LPC_CPLD_I2C_DEBUG_VERBOSE("data: shift[%d], width[%d], clock_khz[%d] i2c_irq_flag=%d\n", + LPC_CPLD_I2C_DEBUG_VERBOSE("data: shift[%d], width[%d], clock_khz[%d] i2c_irq_flag=%d\n", pdata->reg_shift, pdata->reg_io_width, pdata->clock_khz, pdata->i2c_irq_flag); if (i2c->reg_io_width == 0) @@ -768,8 +769,13 @@ static int rg_ocores_i2c_probe(struct platform_device *pdev) /* add in known devices to the bus */ if (pdata) { LPC_CPLD_I2C_DEBUG_VERBOSE("i2c device %d.\n", pdata->num_devices); - for (i = 0; i < pdata->num_devices; i++) + for (i = 0; i < pdata->num_devices; i++) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) + i2c_new_client_device(&i2c->adap, pdata->devices + i); +#else i2c_new_device(&i2c->adap, pdata->devices + i); +#endif + } } oc_debug_sysfs_init(pdev); diff --git a/platform/broadcom/sonic-platform-modules-ragile/common/modules/pmbus.h b/platform/broadcom/sonic-platform-modules-ragile/common/modules/pmbus.h index 39b778a4734b..cd5550ab41b3 100755 --- a/platform/broadcom/sonic-platform-modules-ragile/common/modules/pmbus.h +++ b/platform/broadcom/sonic-platform-modules-ragile/common/modules/pmbus.h @@ -24,6 +24,7 @@ #include #include +#include /* * Registers @@ -35,6 +36,8 @@ enum pmbus_regs { PMBUS_CLEAR_FAULTS = 0x03, PMBUS_PHASE = 0x04, + PMBUS_WRITE_PROTECT = 0x10, + PMBUS_CAPABILITY = 0x19, PMBUS_QUERY = 0x1A, @@ -130,6 +133,23 @@ enum pmbus_regs { PMBUS_MFR_DATE = 0x9D, PMBUS_MFR_SERIAL = 0x9E, + PMBUS_MFR_VIN_MIN = 0xA0, + PMBUS_MFR_VIN_MAX = 0xA1, + PMBUS_MFR_IIN_MAX = 0xA2, + PMBUS_MFR_PIN_MAX = 0xA3, + PMBUS_MFR_VOUT_MIN = 0xA4, + PMBUS_MFR_VOUT_MAX = 0xA5, + PMBUS_MFR_IOUT_MAX = 0xA6, + PMBUS_MFR_POUT_MAX = 0xA7, + + PMBUS_IC_DEVICE_ID = 0xAD, + PMBUS_IC_DEVICE_REV = 0xAE, + + PMBUS_MFR_MAX_TEMP_1 = 0xC0, + PMBUS_MFR_MAX_TEMP_2 = 0xC1, + PMBUS_MFR_MAX_TEMP_3 = 0xC2, + + /* * Virtual registers. * Useful to support attributes which are not supported by standard PMBus @@ -217,6 +237,19 @@ enum pmbus_regs { PMBUS_VIRT_PWM_ENABLE_2, PMBUS_VIRT_PWM_ENABLE_3, PMBUS_VIRT_PWM_ENABLE_4, + /* Samples for average + * + * Drivers wanting to expose functionality for changing the number of + * samples used for average values should implement support in + * {read,write}_word_data callback for either PMBUS_VIRT_SAMPLES if it + * applies to all types of measurements, or any number of specific + * PMBUS_VIRT_*_SAMPLES registers to allow for individual control. + */ + PMBUS_VIRT_SAMPLES, + PMBUS_VIRT_IN_SAMPLES, + PMBUS_VIRT_CURR_SAMPLES, + PMBUS_VIRT_POWER_SAMPLES, + PMBUS_VIRT_TEMP_SAMPLES, }; /* @@ -224,6 +257,15 @@ enum pmbus_regs { */ #define PB_OPERATION_CONTROL_ON BIT(7) +/* + * WRITE_PROTECT + */ +#define PB_WP_ALL BIT(7) /* all but WRITE_PROTECT */ +#define PB_WP_OP BIT(6) /* all but WP, OPERATION, PAGE */ +#define PB_WP_VOUT BIT(5) /* all but WP, OPERATION, PAGE, VOUT, ON_OFF */ + +#define PB_WP_ANY (PB_WP_ALL | PB_WP_OP | PB_WP_VOUT) + /* * CAPABILITY */ @@ -347,7 +389,7 @@ enum pmbus_sensor_classes { }; #define PMBUS_PAGES 32 /* Per PMBus specification */ - +#define PMBUS_PHASES 8 /* Maximum number of phases per page */ /* Functionality bit mask */ #define PMBUS_HAVE_VIN BIT(0) #define PMBUS_HAVE_VCAP BIT(1) @@ -371,16 +413,23 @@ enum pmbus_sensor_classes { #define PMBUS_HAVE_STATUS_VMON BIT(19) #define PMBUS_HAVE_PWM12 BIT(20) #define PMBUS_HAVE_PWM34 BIT(21) - +#define PMBUS_HAVE_SAMPLES BIT(22) +#define PMBUS_PHASE_VIRTUAL BIT(30) #define PMBUS_PAGE_VIRTUAL BIT(31) enum pmbus_data_format { linear = 0, direct, vid }; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) +enum vrm_version { vr11 = 0, vr12, vr13, imvp9, amd625mv }; +#else enum vrm_version { vr11 = 0, vr12, vr13 }; +#endif 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]; + u8 phases[PMBUS_PAGES];/* Number of phases per page */ + u32 pfunc[PMBUS_PHASES];/* Functionality, per phase */ /* * Support one set of coefficients for each sensor type * Used for chips providing data in direct mode. @@ -417,6 +466,7 @@ struct pmbus_driver_info { /* Regulator functionality, if supported by this chip driver. */ int num_regulators; const struct regulator_desc *reg_desc; + const struct attribute_group **groups; }; /* Regulator ops */ @@ -450,8 +500,12 @@ int pmbus_update_byte_data(struct i2c_client *client, int page, u8 reg, void pmbus_clear_faults(struct i2c_client *client); bool pmbus_check_byte_register(struct i2c_client *client, int page, int reg); bool pmbus_check_word_register(struct i2c_client *client, int page, int reg); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) +int pmbus_do_probe(struct i2c_client *client, struct pmbus_driver_info *info); +#else int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id, struct pmbus_driver_info *info); +#endif int pmbus_do_remove(struct i2c_client *client); const struct pmbus_driver_info *pmbus_get_driver_info(struct i2c_client *client); diff --git a/platform/broadcom/sonic-platform-modules-ragile/common/modules/ragile_common_module.c b/platform/broadcom/sonic-platform-modules-ragile/common/modules/ragile_common_module.c index e4fc735643dd..f28852ec3317 100755 --- a/platform/broadcom/sonic-platform-modules-ragile/common/modules/ragile_common_module.c +++ b/platform/broadcom/sonic-platform-modules-ragile/common/modules/ragile_common_module.c @@ -37,9 +37,6 @@ module_param(g_common_debug_verbose, int, S_IRUGO | S_IWUSR); int dfd_get_my_card_type(void) { - int type; - int cnt; - if (dfd_my_type != 0) { RAGILE_COMMON_DEBUG_VERBOSE("my_type = 0x%x\r\n", dfd_my_type); return dfd_my_type; diff --git a/platform/broadcom/sonic-platform-modules-ragile/common/modules/rg-i2c-algo-bit.c b/platform/broadcom/sonic-platform-modules-ragile/common/modules/rg-i2c-algo-bit.c index 5e8f2c29d2a0..b8deebd913ca 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/common/modules/rg-i2c-algo-bit.c +++ b/platform/broadcom/sonic-platform-modules-ragile/common/modules/rg-i2c-algo-bit.c @@ -14,7 +14,7 @@ GNU General Public License for more details. * ------------------------------------------------------------------------- */ -/* With some changes from Frodo Looijaard , Kyösti Mälkki +/* With some changes from Frodo Looijaard , Kyosti Malkki and Jean Delvare */ #include diff --git a/platform/broadcom/sonic-platform-modules-ragile/common/modules/rg_fan.c b/platform/broadcom/sonic-platform-modules-ragile/common/modules/rg_fan.c index f8a70adeee27..ffdf7002afde 100755 --- a/platform/broadcom/sonic-platform-modules-ragile/common/modules/rg_fan.c +++ b/platform/broadcom/sonic-platform-modules-ragile/common/modules/rg_fan.c @@ -78,7 +78,7 @@ typedef enum dfd_dev_info_type_e { } dfd_dev_tlv_type_t; typedef struct dfd_dev_head_info_s { - uint8_t ver; /* define E2PROM version,default is 0x01 */ + uint8_t ver; /* define E2PROM version, default is 0x01 */ uint8_t flag; /* flag is 0x7E in new version E2PROM */ uint8_t hw_ver; /* consists of main version and revise version */ uint8_t type; /* HW type */ diff --git a/platform/broadcom/sonic-platform-modules-ragile/common/modules/rg_psu.c b/platform/broadcom/sonic-platform-modules-ragile/common/modules/rg_psu.c index 78abd41cf525..8d73fe92398c 100755 --- a/platform/broadcom/sonic-platform-modules-ragile/common/modules/rg_psu.c +++ b/platform/broadcom/sonic-platform-modules-ragile/common/modules/rg_psu.c @@ -225,24 +225,6 @@ static ssize_t show_sysfs_15_value(struct device *dev, return snprintf(buf, PSU_SIZE, "%s\n", smbud_buf); } -static ssize_t show_sysfs_13_value(struct device *dev, struct device_attribute *da, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct psu_data *data = i2c_get_clientdata(client); - int ret; - u8 smbud_buf[PSU_SIZE]; - - memset(smbud_buf, 0, PSU_SIZE); - mutex_lock(&data->update_lock); - ret = platform_i2c_smbus_read_i2c_block_data(client, attr->index, 13, smbud_buf); - if (ret < 0) { - DBG_ERROR("Failed to read psu \n"); - } - mutex_unlock(&data->update_lock); - return snprintf(buf, PSU_SIZE, "%s\n", smbud_buf); -} - static int psu_detect(struct i2c_client *new_client, struct i2c_board_info *info) { diff --git a/platform/broadcom/sonic-platform-modules-ragile/common/script/avscontrol.py b/platform/broadcom/sonic-platform-modules-ragile/common/script/avscontrol.py index 25874ddb8219..f8d1d49464a1 100755 --- a/platform/broadcom/sonic-platform-modules-ragile/common/script/avscontrol.py +++ b/platform/broadcom/sonic-platform-modules-ragile/common/script/avscontrol.py @@ -37,7 +37,7 @@ def do_avs_ctrl(): and STARTMODULE["avscontrol_restful"] == 1 ): try: - # for alibmc rest.py has define get_macrov_value function + # for rest.py has define get_macrov_value function get_macrov_value = getattr(BMCMessage(), "get_macrov_value", None) if callable(get_macrov_value): macrov_value = int(get_macrov_value()) 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..d4915fb5a0bb 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 @@ -154,7 +154,7 @@ 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 + for i in range(1, 100):#wait for mother-bus generation, maximum wait time is 10s if os.path.exists(pdevpath) == True: break time.sleep(0.1) 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..bee2ee719ae6 100755 --- a/platform/broadcom/sonic-platform-modules-ragile/common/script/fancontrol.py +++ b/platform/broadcom/sonic-platform-modules-ragile/common/script/fancontrol.py @@ -1,993 +1,485 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python3.9 # -*- coding: UTF-8 -*- +import sys import click import os +import subprocess import time +import json +import syslog import traceback import glob -from rgutil.logutil import Logger -from ragileutil import wait_docker - -from ragileconfig 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, -) - -from ragileutil import ( - rgi2cget, - get_mac_temp_sysfs, - get_mac_temp, - write_sysfs_value, - get_sysfs_value, - strtoint, - rgi2cset, - io_rd, - rgsysset, -) - - -CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"]) - -DEBUG_COMMON = 0x01 -DEBUG_LEDCONTROL = 0x02 -DEBUG_FANCONTROL = 0x04 - -LOG_PREFIX = "FANCONTROL" -logger = Logger(LOG_PREFIX, syslog=True, dbg_mask=FANCTROLDEBUG) - +from interface import Interface +import logging.handlers +from ragileutil import CompressedRotatingFileHandler, rgi2cset + +CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help']) + +FILE_NAME = "/var/log/fancontrol.log" +MAX_LOG_BYTES = 20*1024*1024 +BACKUP_COUNT = 9 + +logger = logging.getLogger("fancontrol") +logger.setLevel(logging.DEBUG) +fanctrl_log = CompressedRotatingFileHandler(FILE_NAME, mode='a', maxBytes=MAX_LOG_BYTES, backupCount=BACKUP_COUNT, encoding=None, delay=0) +formatter = logging.Formatter("%(asctime)s - %(levelname)s - %(message)s") +fanctrl_log.setFormatter(formatter) +logger.addHandler(fanctrl_log) + +DEBUG_FILE = "/etc/fancontrol_debug" +FAN_CTRL_CFG_FILE = "/usr/local/bin/fan_ctrl_cfg.json" +KEY_THERMAL = "Thermal" +KEY_FAN = "Fans" +KEY_FAN_LED = "FanLed" +KEY_PID = "PID" +KEY_OPEN_LOOP = "OpenLoop" +KEY_DEVICE = "Device" + +KEY_INLET_TEMP = "INLET_TEMP" +KEY_OUTLET_TEMP = "OUTLET_TEMP" +KEY_SWITCH_TEMP = "SWITCH_TEMP" +KEY_TEMP = [KEY_INLET_TEMP, KEY_OUTLET_TEMP, KEY_SWITCH_TEMP] + +KEY_PID_PWM_MAX = "Pwm_Max" +KEY_PID_PWM_MIN = "Pwm_Min" +KEY_PID_SETPOINT = "SetPoint" +KEY_PID_P = "P" +KEY_PID_I = "I" +KEY_PID_D = "D" +KEY_PID_TEMP_MIN = "Temp_Min" +KEY_PID_TEMP_MAX = "Temp_Max" + +KEY_OPENLOOP_A = "a" +KEY_OPENLOOP_B = "b" +KEY_OPENLOOP_C = "c" +KEY_OPENLOOP_FIXUP = "fix_up" +KEY_OPENLOOP_PWM_MAX = "pwmMax" +KEY_OPENLOOP_PWM_MIN = "pwmMin" +KEY_OPENLOOP_TEMP_MIN = "tempMin" + +STATUS_HIGH_CRIT = 1 +STATUS_MISS_CRIT = 2 +STATUS_BAD_FAN = 4 +STATUS_LOW_FAN = 8 +STATUS_MISS_ERR = 16 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)] + 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))) - + ctx.fail('Too many matches: %s' % ', '.join(sorted(matches))) -class FanControl(object): - critnum = 0 +def fanctrl_debug_log(s): + # s = s.decode('utf-8').encode('gb2312') + if os.path.isfile(DEBUG_FILE): + logger.debug(s) +class OpenLoop(): def __init__(self): - self._normal_fans = 0 - self._normal_psus = 0 - self._intemp = -100.0 - self._mac_aver = -100.0 - self._mac_max = -100.0 - # previous temperature - self._pre_intemp = -100 - self._outtemp = -100 - self._boardtemp = -100 - self._cputemp = -1000 - - @property - def normal_fans(self): - return self._normal_fans - - @property - def normal_psus(self): - return self._normal_psus - - @property - def cputemp(self): - return self._cputemp - - @property - def intemp(self): - return self._intemp - - @property - def outtemp(self): - return self._outtemp - - @property - def boardtemp(self): - return self._boardtemp - - @property - def mac_aver(self): - return self._mac_aver - - @property - def preIntemp(self): - return self._pre_intemp - - @property - def mac_max(self): - return self._mac_max - - def sortCallback(self, element): - return element["id"] - - def gettemp(self, ret): - u"""get inlet, outlet, hot-point and cpu temperature""" - temp_conf = MONITOR_DEV_STATUS.get("temperature", None) - - if temp_conf is None: - logger.error("gettemp: config error") - return False - for item_temp in temp_conf: - try: - retval = "" - rval = None - name = item_temp.get("name") - location = item_temp.get("location") - if name == "cpu": - 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)): - nameloc = "%s/temp%d_label" % (location, i + 1) - valloc = "%s/temp%d_input" % (location, i + 1) - with open(nameloc, "r") as fd1: - retval2 = fd1.read() - with open(valloc, "r") as fd2: - retval3 = fd2.read() - ret_t = {} - ret_t["name"] = retval2.strip() - ret_t["value"] = float(retval3) / 1000 - ret.append(ret_t) - logger.debug( - DEBUG_COMMON, - "gettemp %s : %f" % (ret_t["name"], ret_t["value"]), - ) - else: - locations = glob.glob(location) - with open(locations[0], "r") as fd1: - retval = fd1.read() - rval = float(retval) / 1000 - ret_t = {} - ret_t["name"] = name - ret_t["value"] = rval - ret.append(ret_t) - logger.debug( - DEBUG_COMMON, - "gettemp %s : %f" % (ret_t["name"], ret_t["value"]), - ) - except Exception as e: - logger.error("gettemp error:name:%s" % name) - logger.error(str(e)) - return True - - def checkslot(self, ret): - u"""get slot present status""" - slots_conf = MONITOR_DEV_STATUS.get("slots", None) - slotpresent = MONITOR_DEV_STATUS_DECODE.get("slotpresent", None) - - if slots_conf is None or slotpresent is None: - return False - for item_slot in slots_conf: - totalerr = 0 - try: - ret_t = {} - ret_t["id"] = item_slot.get("name") - ret_t["status"] = "" - gettype = item_slot.get("gettype") - presentbit = item_slot.get("presentbit") - if gettype == "io": - io_addr = item_slot.get("io_addr") - val = io_rd(io_addr) - if val is not None: - retval = val - else: - totalerr -= 1 - logger.error( - " %s %s" % (item_slot.get("name"), "lpc read failed"), - ) - else: - bus = item_slot.get("bus") - loc = item_slot.get("loc") - offset = item_slot.get("offset") - ind, val = rgi2cget(bus, loc, offset) - if ind == True: - retval = val - else: - totalerr -= 1 - logger.error( - " %s %s" % (item_slot.get("name"), "i2c read failed"), - ) - if totalerr < 0: - ret_t["status"] = "NOT OK" - ret.append(ret_t) - continue - val_t = (int(retval, 16) & (1 << presentbit)) >> presentbit - logger.debug( - DEBUG_COMMON, - "%s present:%s" % (item_slot.get("name"), slotpresent.get(val_t)), - ) - if val_t != slotpresent.get("okval"): - ret_t["status"] = "ABSENT" - else: - ret_t["status"] = "PRESENT" - except Exception as e: - ret_t["status"] = "NOT OK" - totalerr -= 1 - logger.error("checkslot error") - logger.error(str(e)) - ret.append(ret_t) - return True - - def checkpsu(self, ret): - u"""get psu status present, output and warning""" - psus_conf = MONITOR_DEV_STATUS.get("psus", None) - psupresent = MONITOR_DEV_STATUS_DECODE.get("psupresent", None) - psuoutput = MONITOR_DEV_STATUS_DECODE.get("psuoutput", None) - psualert = MONITOR_DEV_STATUS_DECODE.get("psualert", None) + self.a = 0 + self.b = 0 + self.c = 0 + self.fix_up = 0 + self.pwmMax = 0 + self.pwmMin = 0 + self.temp = 0 + self.tempMin = 0 + self.sensor = KEY_INLET_TEMP + + def calcPwm(self): + if self.temp < self.tempMin: + return self.pwmMin + pwm = self.a * self.temp * self.temp + self.b * self.temp + self.c + pwm = (pwm / 2.56) + pwm = min(pwm, self.pwmMax) + pwm = max(pwm, self.pwmMin) + return pwm + + +class FanPid(): + def __init__(self): + self.pwmMin = 30 + self.pwmMax = 100 + self.SetPoint = 89 + self.D = 0.196 + self.I = 0.196 + self.P = 1.176 + self.tempMin = 28.0 + self.tempMax = 45.0 + self.pwms = [30, 30] + self.temps = [-1, -1, -1] + self.last_temp = -1 + self.sensor = KEY_SWITCH_TEMP + + def calcPwm(self): + temp_delta = self.temps[2] - self.last_temp + temp_sp_delta = self.temps[2] - self.SetPoint + temp_last_delta = ((self.temps[2] - self.temps[1]) - (self.temps[1] - self.temps[0])) + + delta_pwm = self.P * temp_delta + self.I * temp_sp_delta + self.D * temp_last_delta + + self.temps[0] = self.temps[1] + self.temps[1] = self.temps[2] + self.last_temp = self.temps[2] + + self.pwms[0] = self.pwms[1] + self.pwms[1] = self.pwms[0] + delta_pwm + self.pwms[1] = max(self.pwms[1], self.pwmMin) + self.pwms[1] = min(self.pwms[1], self.pwmMax) + + return self.pwms[1] + +class FanControl(): - if psus_conf is None or psupresent is None or psuoutput is None: - logger.error("checkpsu: config error") - return False - for item_psu in psus_conf: - totalerr = 0 - try: - ret_t = {} - ret_t["id"] = item_psu.get("name") - ret_t["status"] = "" - gettype = item_psu.get("gettype") - presentbit = item_psu.get("presentbit") - statusbit = item_psu.get("statusbit") - alertbit = item_psu.get("alertbit") - if gettype == "io": - io_addr = item_psu.get("io_addr") - val = io_rd(io_addr) - if val is not None: - retval = val - else: - totalerr -= 1 - logger.error( - " %s %s" % (item_psu.get("name"), "lpc read failed"), - ) + def __init__(self): + self.status = 0 + self.fan_status = 0 + self.error_time = 0 + self.low_time = 0 + self.fan_pwm = 40 + self.interface = Interface() + self.temps = {} + self.tempsMax = {} + self.tempStatus = {} + self.tempCritTime = {} + self.tempMissTime = {} + + self.fans = {} + self.fanStatus = {} + self.fanStatusNokCnt = {} + self.fanLedStatus = {} + self.fanTrayLedStatus = {} + self.fan_led_json = {} + + self.fanPid = None + self.openloop = None + + self.isBuildin = 0 + self.isLiquid = 0 + self.eeproms = {} + self.airflow = "" + self.pid_switch = 1 + self.openloop_switch = 1 + pass + + def doGetAirFlow(self): + if self.isLiquid == 1: + return "Liquid" + # PSU and Fan is buildin using Tlve2 + if self.isBuildin == 1: + productName = self.interface.get_productname() + if productName != "": + tmp = productName.split("-") + fanairflow = tmp[-1] + if fanairflow == "R": + return "intake" else: - bus = item_psu.get("bus") - loc = item_psu.get("loc") - offset = item_psu.get("offset") - ind, val = rgi2cget(bus, loc, offset) - if ind == True: - retval = val - else: - totalerr -= 1 - logger.error( - " %s %s" % (item_psu.get("name"), "i2c read failed"), - ) - if totalerr < 0: - ret_t["status"] = "NOT OK" - ret.append(ret_t) - continue - val_t = (int(retval, 16) & (1 << presentbit)) >> presentbit - val_status = (int(retval, 16) & (1 << statusbit)) >> statusbit - val_alert = (int(retval, 16) & (1 << alertbit)) >> alertbit - logger.debug( - DEBUG_COMMON, - "%s present:%s output:%s alert:%s" - % ( - item_psu.get("name"), - psupresent.get(val_t), - psuoutput.get(val_status), - psualert.get(val_alert), - ), - ) - if ( - val_t != psupresent.get("okval") - or val_status != psuoutput.get("okval") - or val_alert != psualert.get("okval") - ): - totalerr -= 1 - except Exception as e: - totalerr -= 1 - logger.error("checkpsu error") - logger.error(str(e)) - if totalerr < 0: - ret_t["status"] = "NOT OK" - else: - ret_t["status"] = "OK" - ret.append(ret_t) - return True + return "exhaust" + elif self.isBuildin == 0: + return self.interface.get_airflow() + + return "" + + def doFanCtrlInit(self): + if os.path.isfile(FAN_CTRL_CFG_FILE): + fh = open(FAN_CTRL_CFG_FILE) + if not fh: + logger.error("Config file %s doesn't exist" % FAN_CTRL_CFG_FILE) + return + cfg_json = json.load(fh) + if not cfg_json: + logger.error('Load config file %s failed' % FAN_CTRL_CFG_FILE) + return False + + cfg_keys = [KEY_THERMAL, KEY_FAN, KEY_PID, KEY_OPEN_LOOP, KEY_DEVICE] + for key in cfg_keys: + if key not in cfg_json: + logger.error('Key %s not present in cfg file' % key) + return False + thermal_json = cfg_json[KEY_THERMAL] + fan_json = cfg_json[KEY_FAN] + self.fan_led_json = cfg_json[KEY_FAN_LED] + pid_json = cfg_json[KEY_PID] + openloop_json = cfg_json[KEY_OPEN_LOOP] + device_json = cfg_json[KEY_DEVICE] + # Get Airflow + self.isBuildin = device_json["Buildin"] + self.isLiquid = device_json["Liquid"] + self.airflow = self.doGetAirFlow() + if self.airflow == "": + logger.warning("Cannot get airflow from device!") + self.pid_switch = device_json["PID"] + self.openloop_switch = device_json["OpenLoop"] + if self.pid_switch == 0 and self.openloop_switch == 0: + logger.warning("No PID and OpenLoop found!") + # Init openloop + self.openloop = OpenLoop() + self.openloop.a = openloop_json[KEY_OPENLOOP_A] + self.openloop.b = openloop_json[KEY_OPENLOOP_B] + self.openloop.c = openloop_json[KEY_OPENLOOP_C] + self.openloop.fix_up = openloop_json[KEY_OPENLOOP_FIXUP] + self.openloop.pwmMax = openloop_json[KEY_OPENLOOP_PWM_MAX] + self.openloop.pwmMin = openloop_json[KEY_OPENLOOP_PWM_MIN] + self.openloop.tempMin = openloop_json[KEY_OPENLOOP_TEMP_MIN] + # Init PID + self.fanPid = FanPid() + self.fanPid.pwmMax = pid_json[KEY_PID_PWM_MAX] + self.fanPid.pwmMin = pid_json[KEY_PID_PWM_MIN] + self.fanPid.SetPoint = pid_json[KEY_PID_SETPOINT] + self.fanPid.P = pid_json[KEY_PID_P] + self.fanPid.I = pid_json[KEY_PID_I] + self.fanPid.D = pid_json[KEY_PID_D] + self.fanPid.tempMin = pid_json[KEY_PID_TEMP_MIN] + self.fanPid.tempMax = pid_json[KEY_PID_TEMP_MAX] + # Init thermal setting + for key, item in list(thermal_json.items()): + fanctrl_debug_log("%s %s " % (key,item)) + if key not in KEY_TEMP: + logger.error('Key %s not present in cfg file' % key) + return False + self.temps[item] = -1.0 + self.tempsMax[item] = self.interface.get_thermal_temp_max(item) + self.tempStatus[item] = 0 + self.tempMissTime[item] = [0, 0] + self.tempCritTime[item] = [0, 0] + if key == self.fanPid.sensor: + self.fanPid.sensor = item + if key == self.openloop.sensor: + self.openloop.sensor = item + + # Init fans setting + for key, item in list(fan_json.items()): + self.fans[key] = item + self.fanStatus[key] = 0 + self.fanStatusNokCnt[key] = 0 + self.fanLedStatus[item] = "green" - def checkfan(self, ret): - u"""get fan status present and roll""" - fans_conf = MONITOR_DEV_STATUS.get("fans", None) - fanpresent = MONITOR_DEV_STATUS_DECODE.get("fanpresent", None) - fanroll = MONITOR_DEV_STATUS_DECODE.get("fanroll", None) - - if fans_conf is None or fanpresent is None or fanroll is None: - logger.error("checkfan: config error") + else: + logger.error('%s is not a file' % FAN_CTRL_CFG_FILE) return False - for item_fan in fans_conf: - totalerr = 0 - try: - ret_t = {} - ret_t["id"] = item_fan.get("name") - ret_t["status"] = "" - presentstatus = item_fan.get("presentstatus") - presentbus = presentstatus.get("bus") - presentloc = presentstatus.get("loc") - presentaddr = presentstatus.get("offset") - presentbit = presentstatus.get("bit") - ind, val = rgi2cget(presentbus, presentloc, presentaddr) - if ind == True: - val_t = (int(val, 16) & (1 << presentbit)) >> presentbit - logger.debug( - DEBUG_COMMON, - "checkfan:%s present status:%s" - % (item_fan.get("name"), fanpresent.get(val_t)), - ) - if val_t != fanpresent.get("okval"): - ret_t["status"] = "ABSENT" - ret.append(ret_t) - continue - else: - logger.error( - "checkfan: %s get present status error." % item_fan.get("name"), - ) - motors = item_fan.get("rollstatus") - for motor in motors: - statusbus = motor.get("bus", None) - statusloc = motor.get("loc", None) - statusaddr = motor.get("offset", None) - statusbit = motor.get("bit", None) - ind, val = rgi2cget(statusbus, statusloc, statusaddr) - if ind == True: - val_t = (int(val, 16) & (1 << statusbit)) >> statusbit - logger.debug( - DEBUG_COMMON, - "checkfan:%s roll status:%s" - % (motor.get("name"), fanroll.get(val_t)), - ) - if val_t != fanroll.get("okval"): - totalerr -= 1 - else: - totalerr -= 1 - logger.error("checkfan: %s " % item_fan.get("name")) - logger.error("get %s status error." % motor["name"]) - except Exception as e: - totalerr -= 1 - logger.error("checkfan error") - logger.error(str(e)) - if totalerr < 0: - ret_t["status"] = "NOT OK" - else: - ret_t["status"] = "OK" - ret.append(ret_t) - return True - - def get_curr_speed(self): - try: - loc = fanloc[0].get("location", "") - sped = get_sysfs_value(loc) - value = strtoint(sped) - return value - except Exception as e: - logger.error("%%policy: get current speedlevel error") - logger.error(str(e)) - return None - - # guarantee the speed is lowest when speed lower than lowest value after speed-adjustment - def check_curr_speed(self): - logger.debug( - DEBUG_FANCONTROL, - "%%policy: guarantee the lowest speed after speed-adjustment", - ) - value = self.get_curr_speed() - if value is None or value == 0: - raise Exception("%%policy: get_curr_speed None") - elif value < MONITOR_CONST.MIN_SPEED: - self.set_fan_speed(MONITOR_CONST.MIN_SPEED) - - def set_fan_speed(self, level): - if level >= MONITOR_CONST.MAX_SPEED: - level = MONITOR_CONST.MAX_SPEED - for item in fanloc: - try: - loc = item.get("location", "") - # write_sysfs_value(loc, "0x%02x" % level) - # pddf support dicimal number - write_sysfs_value(loc, "%d" % level) - except Exception as e: - logger.error(str(e)) - logger.error("%%policy: config fan runlevel error") - self.check_curr_speed() # guaranteed minimum - - def set_fan_max_speed(self): - try: - self.set_fan_speed(MONITOR_CONST.MAX_SPEED) - except Exception as e: - logger.error("%%policy:set_fan_max_speed failed") - logger.error(str(e)) - def detect_fan_status(self): - """ - fan status check , max speed if fan error - """ - if self.normal_fans < MONITOR_CONST.FAN_TOTAL_NUM: - logger.warn( - "%%DEV_MONITOR-FAN: Normal fan number: %d" % (self.normal_fans), - ) - self.set_fan_max_speed() - return False + fanctrl_debug_log("Device AirFlow: %s" % (self.airflow)) + self.updateThermal() + self.fanPid.last_temp = self.temps[self.fanPid.sensor] + for i in range(3): + self.fanPid.temps[i] = self.temps[self.fanPid.sensor] return True - def set_fan_attr(self, val): - u"""set status of each fan""" - for item in val: - fanid = item.get("id") - fanattr = fanid + "status" - fanstatus = item.get("status") - setattr(FanControl, fanattr, fanstatus) - logger.debug( - DEBUG_COMMON, "fanattr:%s,fanstatus:%s" % (fanattr, fanstatus), - ) - - def fan_present_num(self, cur_fan_status): - fanoknum = 0 - for item in cur_fan_status: - if item["status"] == "OK": - fanoknum += 1 - self._normal_fans = fanoknum - logger.debug(DEBUG_COMMON, "normal_fans = %d" % self._normal_fans) - - def get_fan_status(self): - try: - cur_fan_status = [] - ret = self.checkfan(cur_fan_status) - if ret == True: - self.set_fan_attr(cur_fan_status) - self.fan_present_num(cur_fan_status) - logger.debug(DEBUG_COMMON, "%%policy:get_fan_status success") - return 0 - except AttributeError as e: - logger.error(str(e)) - except Exception as e: - logger.error(str(e)) - return -1 - - def normal_psu_num(self, curPsuStatus): - psuoknum = 0 - for item in curPsuStatus: - if item.get("status") == "OK": - psuoknum += 1 - self._normal_psus = psuoknum - logger.debug(DEBUG_COMMON, "normal_psus = %d" % self._normal_psus) - - def get_psu_status(self): - try: - curPsuStatus = [] - ret = self.checkpsu(curPsuStatus) - if ret == True: - self.normal_psu_num(curPsuStatus) - logger.debug(DEBUG_COMMON, "%%policy:get_psu_status success") - return 0 - except AttributeError as e: - logger.error(str(e)) - except Exception as e: - logger.error(str(e)) - return -1 - - def get_monitor_temp(self, temp): - for item in temp: - if item.get("name") == "lm75in": - self._intemp = item.get("value", self._intemp) - if item.get("name") == "lm75out": - self._outtemp = item.get("value", self._outtemp) - if item.get("name") == "lm75hot": - self._boardtemp = item.get("value", self._boardtemp) - if item.get("name") == "Physical id 0": - self._cputemp = item.get("value", self._cputemp) - logger.debug( - DEBUG_COMMON, - "intemp:%f, outtemp:%f, boadrtemp:%f, cputemp:%f" - % (self._intemp, self._outtemp, self._boardtemp, self._cputemp), - ) - - def get_temp_status(self): - try: - monitortemp = [] - ret = self.gettemp(monitortemp) - if ret == True: - self.get_monitor_temp(monitortemp) - logger.debug(DEBUG_COMMON, "%%policy:get_temp_status success") - return 0 - except AttributeError as e: - logger.error(str(e)) - except Exception as e: - logger.error(str(e)) - return -1 - - def get_mac_status_bcmcmd(self): - try: - if wait_docker(timeout=0) == True: - sta, ret = get_mac_temp() - if sta == True: - self._mac_aver = float(ret.get("average", self._mac_aver)) - self._mac_max = float(ret.get("maximum", self._mac_max)) - logger.debug( - DEBUG_COMMON, - "mac_aver:%f, mac_max:%f" % (self.mac_aver, self._mac_max), - ) - else: - logger.debug(DEBUG_COMMON, "%%policy:get_mac_status_bcmcmd failed") - else: - logger.debug(DEBUG_COMMON, "%%policy:get_mac_status_bcmcmd SDK not OK") - return 0 - except AttributeError as e: - logger.error(str(e)) - return -1 + def setFanSpeed(self, speed): + return self.interface.set_fan_speed_pwm(speed) - def get_mac_status_sysfs(self, conf): - try: - sta, ret = get_mac_temp_sysfs(conf) - if sta == True: - self._mac_aver = float(ret) / 1000 - self._mac_max = float(ret) / 1000 - logger.debug( - DEBUG_COMMON, - "mac_aver:%f, mac_max:%f" % (self.mac_aver, self._mac_max), - ) - elif conf.get("try_bcmcmd", 0) == 1: - logger.debug( - DEBUG_COMMON, "get sysfs mac temp failed.try to use bcmcmd", - ) - self.get_mac_status_bcmcmd() - else: - logger.debug(DEBUG_COMMON, "%%policy:get_mac_status_sysfs failed") - return 0 - except AttributeError as e: - logger.error(str(e)) - return -1 - - def get_mac_status(self): - try: - mactempconf = MONITOR_DEV_STATUS.get("mac_temp", None) - if mactempconf is not None: - self.get_mac_status_sysfs(mactempconf) - else: - self.get_mac_status_bcmcmd() - return 0 - except AttributeError as e: - logger.error(str(e)) - return -1 - - def set_slot_attr(self, val): - u"""set each slot present status attribute""" - for item in val: - slotid = item.get("id") - slotattr = slotid + "status" - slotstatus = item.get("status") - setattr(FanControl, slotattr, slotstatus) - logger.debug( - DEBUG_COMMON, "slotattr:%s,slotstatus:%s" % (slotattr, slotstatus), - ) - - def get_slot_status(self): - try: - curSlotStatus = [] - ret = self.checkslot(curSlotStatus) - if ret == True: - self.set_slot_attr(curSlotStatus) - logger.debug(DEBUG_COMMON, "%%policy:get_slot_status success") - except AttributeError as e: - logger.error(str(e)) - return 0 + def updateThermal(self): + for key in self.temps: + self.temps[key] = self.interface.get_thermal_temp(key) + fanctrl_debug_log("%s temps %d C" % (key, self.temps[key])) - def fanctrol(self): # fan speed-adjustment - try: - if self.preIntemp <= -1000: - self.preIntemp = self.intemp - logger.debug( - DEBUG_FANCONTROL, - "%%policy:previous temperature[%.2f] , current temperature[%.2f]" - % (self.preIntemp, self.intemp), - ) - if self.intemp < MONITOR_CONST.TEMP_MIN: - logger.debug( - DEBUG_FANCONTROL, - "%%policy:inlet %.2f minimum temperature: %.2f" - % (self.intemp, MONITOR_CONST.TEMP_MIN), - ) - self.set_fan_speed(MONITOR_CONST.DEFAULT_SPEED) # default level - elif self.intemp >= MONITOR_CONST.TEMP_MIN and self.intemp > self.preIntemp: - logger.debug(DEBUG_FANCONTROL, "%%policy:increase temperature") - self.policy_speed(self.intemp) - elif ( - self.intemp >= MONITOR_CONST.TEMP_MIN - and (self.preIntemp - self.intemp) > MONITOR_CONST.MONITOR_FALL_TEMP - ): - logger.debug( - DEBUG_FANCONTROL, - "%%policy:temperature reduce over %d degree" - % MONITOR_CONST.MONITOR_FALL_TEMP, - ) - self.policy_speed(self.intemp) - else: - speed = ( - self.get_curr_speed() - ) # set according to current speed, prevent fan watch-dog - if speed is not None: - self.set_fan_speed(speed) - logger.debug(DEBUG_FANCONTROL, "%%policy:change nothing") - except Exception as e: - logger.error("%%policy: fancontrol error") - - def start_fan_ctrl(self): - """ - start speed-adjustment - """ - self.check_crit() - if ( - self.critnum == 0 - and self.check_warn() == False - and self.detect_fan_status() == True - ): - self.fanctrol() - self.check_dev_err() - logger.debug( - DEBUG_FANCONTROL, - "%%policy: speed after speed-adjustment is %0x" % (self.get_curr_speed()), - ) - - def policy_speed(self, temp): # fan speed-adjustment algorithm - logger.debug(DEBUG_FANCONTROL, "%%policy:fan speed-adjustment algorithm") - sped_level = MONITOR_CONST.DEFAULT_SPEED + MONITOR_CONST.K * ( - temp - MONITOR_CONST.TEMP_MIN - ) - self.set_fan_speed(sped_level) - self.preIntemp = self.intemp - - def board_moni_msg(self, ledcontrol=False): - ret_t = 0 - try: - ret_t += ( - self.get_fan_status() - ) # get fan status, get number of fan which status is OK - ret_t += ( - self.get_temp_status() - ) # get inlet, outlet, hot-point temperature, CPU temperature - ret_t += self.get_mac_status() # get MAC highest and average temperature - if ledcontrol == True: - ret_t += self.get_slot_status() # get slot present status - ret_t += self.get_psu_status() # get psu status - if ret_t == 0: - return True - except Exception as e: - logger.error(str(e)) - return False + self.openloop.temp = self.temps[self.openloop.sensor] + self.fanPid.temps[2] = self.temps[self.fanPid.sensor] - # device error algorithm Tmac-Tin≥50℃, or Tmac-Tin≤-50℃ - def check_dev_err(self): - try: - if (self.mac_aver - self.intemp) >= MONITOR_CONST.MAC_UP_TEMP or ( - self.mac_aver - self.intemp - ) <= MONITOR_CONST.MAC_LOWER_TEMP: - logger.debug( - DEBUG_FANCONTROL, "%%DEV_MONITOR-TEMP: MAC temp get failed.", - ) - value = self.get_curr_speed() - if MONITOR_CONST.MAC_ERROR_SPEED >= value: - self.set_fan_speed(MONITOR_CONST.MAC_ERROR_SPEED) + def checkThermal(self): + thermal_cnt = 0 + for key in self.temps: + if self.temps[key] <= -9999: + if self.tempStatus[key] & STATUS_MISS_CRIT != 0: + self.tempMissTime[key][0] = time.time() else: - self.set_fan_max_speed() + self.tempMissTime[key][1] = time.time() + self.tempStatus[key] = self.tempStatus[key] | STATUS_MISS_CRIT + if self.tempMissTime[key][1] - self.tempMissTime[key][0] > 15: + logger.warning("%s Read Invaild Temperautre %d " % (key, self.temps[key])) + self.tempStatus[key] = self.tempStatus[key] | STATUS_MISS_ERR else: - pass - except Exception as e: - logger.error("%%policy:check_dev_err failed") - logger.error(str(e)) - - def check_temp_warn(self): - u"""check whether temperature above the normal alarm value""" - try: - if ( - self._mac_aver >= MONITOR_CONST.MAC_WARNING_THRESHOLD - or self._outtemp >= MONITOR_CONST.OUTTEMP_WARNING_THRESHOLD - or self._boardtemp >= MONITOR_CONST.BOARDTEMP_WARNING_THRESHOLD - or self._cputemp >= MONITOR_CONST.CPUTEMP_WARNING_THRESHOLD - or self._intemp >= MONITOR_CONST.INTEMP_WARNING_THRESHOLD - ): - logger.debug( - DEBUG_COMMON, - "check whether temperature above the normal alarm value", - ) - return True - except Exception as e: - logger.error("%%policy: check_temp_warn failed") - logger.error(str(e)) - return False - - def check_temp_crit(self): - u"""check whether temperature above the critical alarm value""" - try: - if self._mac_aver >= MONITOR_CONST.MAC_CRITICAL_THRESHOLD or ( - self._outtemp >= MONITOR_CONST.OUTTEMP_CRITICAL_THRESHOLD - and self._boardtemp >= MONITOR_CONST.BOARDTEMP_CRITICAL_THRESHOLD - and self._cputemp >= MONITOR_CONST.CPUTEMP_CRITICAL_THRESHOLD - and self._intemp >= MONITOR_CONST.INTEMP_CRITICAL_THRESHOLD - ): - logger.debug( - DEBUG_COMMON, "temperature above the critical alarm value", - ) - return True - except Exception as e: - logger.error("%%policy: check_temp_crit failed") - logger.error(str(e)) - return False - - def check_fan_status(self): - u"""check fan status""" - for item in MONITOR_FAN_STATUS: - maxoknum = item.get("maxOkNum") - minoknum = item.get("minOkNum") - status = item.get("status") - if self.normal_fans >= minoknum and self.normal_fans <= maxoknum: - logger.debug( - DEBUG_COMMON, - "check_fan_status:normal_fans:%d,status:%s" - % (self.normal_fans, status), - ) - return status - logger.debug( - DEBUG_COMMON, "check_fan_status Error:normal_fans:%d" % (self.normal_fans), - ) - return None - - def check_psu_status(self): - u"""check psu status""" - for item in MONITOR_PSU_STATUS: - maxoknum = item.get("maxOkNum") - minoknum = item.get("minOkNum") - status = item.get("status") - if self.normal_psus >= minoknum and self.normal_psus <= maxoknum: - logger.debug( - DEBUG_COMMON, - "check_psu_status:normal_psus:%d,status:%s" - % (self.normal_psus, status), - ) - return status - logger.debug( - DEBUG_COMMON, "check_psu_status Error:normal_psus:%d" % (self.normal_psus), - ) - return None - - def deal_sys_led_status(self): - u"""set up SYSLED according to temperature, fan and psu status""" - try: - fanstatus = self.check_fan_status() - psustatus = self.check_psu_status() - if ( - self.check_temp_crit() == True - or fanstatus == "red" - or psustatus == "red" - ): - status = "red" - elif ( - self.check_temp_warn() == True - or fanstatus == "yellow" - or psustatus == "yellow" - ): - status = "yellow" + self.tempStatus[key] = self.tempStatus[key] & ~(STATUS_MISS_CRIT | STATUS_MISS_ERR) + + if self.temps[key] >= self.tempsMax[key]: + self.tempCritTime[key][0] = time.time() + self.tempStatus[key] = self.tempStatus[key] | STATUS_HIGH_CRIT + logger.warning("%s Temperautre %d >= High Threshold %d" % (key, self.temps[key], self.tempsMax[key])) + elif self.tempStatus[key] & (STATUS_HIGH_CRIT) != 0: + self.tempCritTime[key][1] = time.time() + logger.warning("%s Temperautre %d Recovery" % (key, self.temps[key])) + if self.tempCritTime[key][1] - self.tempCritTime[key][0] > 300: + self.tempStatus[key] = self.tempStatus[key] & ~(STATUS_HIGH_CRIT) + + if self.tempStatus[key] & ~(STATUS_MISS_CRIT) != 0: + thermal_cnt = thermal_cnt + 1 + + self.status = thermal_cnt + fanctrl_debug_log("Thermal error num %d" % self.status) + + def checkFanSpeed(self): + fan_error_cnt = 0 + for key, item in list(self.fans.items()): + speed = self.interface.get_fan_speed_rpm(item) + if speed < 1000: + self.fanStatus[key] = self.fanStatus[key] | STATUS_LOW_FAN + self.fanStatusNokCnt[key] += 1 + if self.fanStatusNokCnt[key] > 6: + self.fanLedStatus[item] = "red" + logger.warning("%s Speed %d <= %d RPM" % (item, speed, 1000)) else: - status = "green" - self.set_sys_leds(status) - logger.debug( - DEBUG_LEDCONTROL, - "%%ledcontrol:deal_sys_led_status success, status:%s," % status, - ) - except Exception as e: - logger.error(str(e)) - - def deal_sys_fan_led_status(self): - u"""light panel fan led according to status""" - try: - status = self.check_fan_status() - if status is not None: - self.set_sys_fan_leds(status) - logger.debug( - DEBUG_LEDCONTROL, - "%%ledcontrol:deal_sys_fan_led_status success, status:%s," % status, - ) - except Exception as e: - logger.error("%%ledcontrol:deal_sys_led_status error") - logger.error(str(e)) - - def deal_psu_led_status(self): - u"""set up PSU-LED according to psu status""" - try: - status = self.check_psu_status() - if status is not None: - self.set_sys_psu_leds(status) - logger.debug( - DEBUG_LEDCONTROL, - "%%ledcontrol:deal_psu_led_status success, status:%s," % status, - ) - except Exception as e: - logger.error("%%ledcontrol:deal_psu_led_status error") - logger.error(str(e)) + self.fanStatus[key] = self.fanStatus[key] & ~(STATUS_LOW_FAN) + self.fanStatusNokCnt[key] = 0 + self.fanLedStatus[item] = "green" + + fanctrl_debug_log("%s speed %d RPM, led status %s" % (key, speed, self.fanLedStatus[item])) + + if self.fanStatus[key] != 0: + fan_error_cnt = fan_error_cnt + 1 + self.fan_status = fan_error_cnt + fanctrl_debug_log("Fan error num %d" % fan_error_cnt) + + def doApplyPolicy(self): + if self.isLiquid == 1: + return + + self.fan_pwm = 0 + if self.openloop_switch == 1: + openloop_pwm = int(self.openloop.calcPwm()) + fanctrl_debug_log("OpenLoop pwm %d" % (openloop_pwm)) + self.fan_pwm = max(self.fan_pwm, openloop_pwm) + + if self.pid_switch == 1: + pid_pwm = int(self.fanPid.calcPwm()) + fanctrl_debug_log("PID pwm %d" % (pid_pwm)) + self.fan_pwm = max(self.fan_pwm, pid_pwm) + + # Check fan presence + if self.interface.get_fan_presence() == False: + logger.warning("Fan presence check false, set fan pwm to 100") + self.fan_pwm = 100 + if self.fan_status != 0 or self.status != 0: + self.fan_pwm = 100 + fanctrl_debug_log("Fan Speed set to %d pwm" % self.fan_pwm) + for i in range(3): + ret = self.setFanSpeed(self.fan_pwm) + if ret == False: + logger.warning("Fan speed set %d pwm failed, retry %d times" % (self.fan_pwm, i + 1)) + continue + break + + def doBoardFanLedCtrl(self): + if self.interface.get_fan_status() != False and self.interface.get_fan_presence() != False and self.fan_status == 0: + fanctrl_debug_log("Fan status good setting LED to green") + self.interface.set_fan_board_led("green") + else: + fanctrl_debug_log("Fan status error setting LED to red") + self.interface.set_fan_board_led("red") - def deal_fan_led_status(self): - u"""light fan led according to fan status""" - for item in MONITOR_FANS_LED: - try: - index = MONITOR_FANS_LED.index(item) + 1 - fanattr = "fan%dstatus" % index - val_t = getattr(FanControl, fanattr, None) - if val_t == "NOT OK": - rgi2cset(item["bus"], item["devno"], item["addr"], item["red"]) - elif val_t == "OK": - rgi2cset(item["bus"], item["devno"], item["addr"], item["green"]) - else: - pass - logger.debug( - DEBUG_LEDCONTROL, - "%%ledcontrol:dealLocFanLed success.fanattr:%s, status:%s" - % (fanattr, val_t), - ) - except Exception as e: - logger.error("%%ledcontrol:deal_fan_led_status error") - logger.error(str(e)) - - def dealSlotLedStatus(self): - u"""light slot status led according to slot present status""" - slotLedList = DEV_LEDS.get("SLOTLED", []) - for item in slotLedList: - try: - index = slotLedList.index(item) + 1 - slotattr = "slot%dstatus" % index - val_t = getattr(FanControl, slotattr, None) - if val_t == "PRESENT": - rgi2cset(item["bus"], item["devno"], item["addr"], item["green"]) - logger.debug( - DEBUG_LEDCONTROL, - "%%ledcontrol:dealSlotLedStatus success.slotattr:%s, status:%s" - % (slotattr, val_t), - ) - except Exception as e: - logger.error("%%ledcontrol:dealSlotLedStatus error") - logger.error(str(e)) - - def setled(self, item, color): - if item.get("type", "i2c") == "sysfs": - rgsysset(item["cmdstr"], item.get(color)) + def doBoardPsuLedCtrl(self): + if self.interface.get_psu_status() != False: + fanctrl_debug_log("PSU status good setting LED to green") + self.interface.set_psu_board_led("green") else: - mask = item.get("mask", 0xFF) - ind, val = rgi2cget(item["bus"], item["devno"], item["addr"]) - if ind == True: - setval = (int(val, 16) & ~mask) | item.get(color) - rgi2cset(item["bus"], item["devno"], item["addr"], setval) - else: - logger.error("led %s" % "i2c read failed") + fanctrl_debug_log("PSU status error setting LED to red") + self.interface.set_psu_board_led("red") - def set_sys_leds(self, color): - for item in MONITOR_SYS_LED: - self.setled(item, color) + def doFanLocLedCtrl(self): + # Init fan led setting + for key, item in list(self.fan_led_json.items()): + self.fanTrayLedStatus[key] = "green" - def set_sys_fan_leds(self, color): - for item in MONITOR_SYS_FAN_LED: - self.setled(item, color) + for key, item in list(self.fans.items()): + fantray = item.split("_")[0] + if self.fanLedStatus[item] == "red": + self.fanTrayLedStatus[fantray] = "red" - def set_sys_psu_leds(self, color): - for item in MONITOR_SYS_PSU_LED: - self.setled(item, color) + for key, item in list(self.fan_led_json.items()): + rgi2cset(item.get("bus"), item.get("devno"), + item.get("addr"), item.get(self.fanTrayLedStatus[key])) + fanctrl_debug_log("fanTray:%s, rgi2cset %d 0x%02x 0x%02x 0x%02x" % + (key, item.get("bus"), item.get("devno"), item.get("addr"), + item.get(self.fanTrayLedStatus[key]))) - def check_warn(self): - try: - if self.check_temp_warn() == 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: - logger.warn("%%DEV_MONITOR-TEMP:The temperature of device is over warning value.") - self.set_fan_max_speed() # fan full speed - return True - except Exception as e: - logger.error("%%policy: check_warn failed") - logger.error(str(e)) - return False - def check_crit(self): +def run(interval, fanCtrol): + loop = 0 + # waitForDocker() + fanCtrol.setFanSpeed(fanCtrol.fan_pwm) #init set fan speed to 50 pwm + fanCtrol.doFanCtrlInit() + if fanCtrol.airflow == "Liquid": + logger.warning('Liquid device stopping fancontrol') + return True + while True: try: - if self.check_temp_crit() == 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: - 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") - logger.debug(DEBUG_FANCONTROL, "crit times:%d" % self.critnum) - else: - self.critnum = 0 - else: - self.critnum = 0 - except Exception as e: - logger.error("%%policy: check_crit failed") - logger.error(str(e)) - - -def callback(): - pass + if loop % 5 == 0: # Fan speed control + try: + fanCtrol.updateThermal() + except Exception as e: + logger.error('Failed: Update Thermal, %s' % str(e)) + logger.error('%s' % traceback.format_exc()) + time.sleep(3) + continue + try: + fanCtrol.checkThermal() + except Exception as e: + logger.error('Failed: Check Thermal, %s' % str(e)) + logger.error('%s' % traceback.format_exc()) + time.sleep(3) + continue -def do_fan_ctrl(fanctrl): - ret = fanctrl.board_moni_msg() - if ret == True: - logger.debug(DEBUG_FANCONTROL, "%%policy:start_fan_ctrl") - fanctrl.start_fan_ctrl() - else: - fanctrl.set_fan_max_speed() - logger.debug(DEBUG_FANCONTROL, "%%policy:board_moni_msg error") + try: + fanCtrol.checkFanSpeed() + except Exception as e: + logger.error('Failed: Check Fan Speed, %s' % str(e)) + logger.error('%s' % traceback.format_exc()) + time.sleep(3) + continue + try: + fanCtrol.doApplyPolicy() + except Exception as e: + logger.error('Failed: Apply Policy, %s' % str(e)) + logger.error('%s' % traceback.format_exc()) + time.sleep(3) + continue -def do_led_ctrl(fanctrl): - fanctrl.board_moni_msg(ledcontrol=True) # get status - fanctrl.deal_sys_led_status() # light system led - fanctrl.deal_sys_fan_led_status() # light panel fan led - fanctrl.deal_fan_led_status() # light fan led - fanctrl.deal_psu_led_status() # light psu led - fanctrl.dealSlotLedStatus() # light slot status led - logger.debug(DEBUG_LEDCONTROL, "%%ledcontrol:do_led_ctrl success") + try: + fanCtrol.doFanLocLedCtrl() + except Exception as e: + logger.error('Failed: Led Control, %s' % str(e)) + logger.error('%s' % traceback.format_exc()) -def run(interval, fanctrl): - loop = 0 - # waitForDocker() - while True: - try: - if loop % MONITOR_CONST.MONITOR_INTERVAL == 0: # fan speed-adjustment - logger.debug(DEBUG_FANCONTROL, "%%policy:fanctrl") - do_fan_ctrl(fanctrl) - else: - logger.debug( - DEBUG_LEDCONTROL, "%%ledcontrol:start ledctrol" - ) # LED control - do_led_ctrl(fanctrl) + # try: + # fanCtrol.doBoardPsuLedCtrl() + # except Exception as e: + # logger.error('Failed: Led Control, %s' % str(e)) + # logger.error('%s' % traceback.format_exc()) + # time.sleep(3) + # continue time.sleep(interval) loop += interval except Exception as e: traceback.print_exc() logger.error(str(e)) - @click.group(cls=AliasedGroup, context_settings=CONTEXT_SETTINGS) def main(): - """device operator""" + '''device operator''' pass - @main.command() def start(): - """start fan control""" - logger.info("FAN CTRL START") - fanctrl = FanControl() - interval = MONITOR_CONST.MONITOR_INTERVAL / 30 - run(interval, fanctrl) - + '''start fan control''' + logger.info("FANCTROL start") + fanCtrol = FanControl() + interval = 1 + run(interval, fanCtrol) @main.command() def stop(): - """stop fan control """ - logger.info("FAN CTRL STOP") - + '''stop fan control ''' + logger.info("FANCTROL stop") -##device_i2c operation -if __name__ == "__main__": +# device_i2c operation +if __name__ == '__main__': main() diff --git a/platform/broadcom/sonic-platform-modules-ragile/common/script/interface.py b/platform/broadcom/sonic-platform-modules-ragile/common/script/interface.py new file mode 100644 index 000000000000..3f65a22580be --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-ragile/common/script/interface.py @@ -0,0 +1,88 @@ +import sonic_platform + +class Interface(): + def __init__(self): + self.chassis = sonic_platform.platform.Platform().get_chassis() + self.fan_list = self.chassis.get_all_fans() + self.thermal_list = self.chassis.get_all_thermals() + self.psu_list = self.chassis.get_all_psus() + + # Device + def get_productname(self): + return self.chassis.get_name() + + # Thermal + def get_thermal_temp_max(self, name): + for thermal in self.thermal_list: + if name == thermal.get_name(): + return thermal.get_high_threshold() + + def get_thermal_temp_min(self, name): + for thermal in self.thermal_list: + if name == thermal.get_name(): + return thermal.get_low_threshold() + + def get_thermal_temp(self, name): + for thermal in self.thermal_list: + if name == thermal.get_name(): + return thermal.get_temperature() + # Fans + def set_fan_speed_pwm(self, speed): + for fan in self.fan_list: + fan.set_speed(speed) + + def get_fan_status(self): + for fan in self.fan_list: + if fan.get_status() == False: + return False + return True + + def get_fan_presence(self): + for fan in self.fan_list: + if fan.get_presence() == False: + return False + return True + + def set_fan_board_led(self, color): + for fan in self.fan_list: + if fan.set_status_led(color) == False: + return False + return True + + def get_fan_speed_rpm(self, name): + for fan in self.fan_list: + if name == fan.get_name(): + return fan.get_speed_rpm() + return 0 + + # def get_fan_rpm_max(self): + # for fan in self.fan_list: + # if name == fan.get_name(): + # return fan.get_speed_rpm() + # return 0 + + def get_airflow(self): + tmp1 = self.fan_list[0].get_direction() + tmp2 = self.fan_list[0].get_direction() + for fan in self.fan_list: + tmp1 = fan.get_direction() + if tmp1 != tmp2: + return "exhaust" + tmp2 = tmp1 + return tmp2 + # Psus + def get_psu_status(self): + for psu in self.psu_list: + if psu.get_status() == False: + return False + if psu.get_powergood_status() == False: + return False + + return True + + def set_psu_board_led(self, color): + for psu in self.psu_list: + if psu.set_status_led(color) == False: + return False + return True + diff --git a/platform/broadcom/sonic-platform-modules-ragile/common/script/ragilecommon.py b/platform/broadcom/sonic-platform-modules-ragile/common/script/ragilecommon.py index 0adad9d74659..769427d679d0 100755 --- a/platform/broadcom/sonic-platform-modules-ragile/common/script/ragilecommon.py +++ b/platform/broadcom/sonic-platform-modules-ragile/common/script/ragilecommon.py @@ -304,7 +304,7 @@ ####================================Adaption-Area================================ #### RAGILE_COMMON common configuration head -#### “platform” specific configuration head +#### "platform" specific configuration head #### PCA9548START = 11 PCA9548BUSEND = 74 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..8fb4568bfbd4 100755 --- a/platform/broadcom/sonic-platform-modules-ragile/common/script/ragileutil.py +++ b/platform/broadcom/sonic-platform-modules-ragile/common/script/ragileutil.py @@ -382,11 +382,11 @@ def getInputSetmac(val): class fan_tlv(object): - VERSION = 0x01 # E2PROM Version,start from 0x01 - FLAG = 0x7E # New E2PROM version flag is 0x7E - HW_VER = 0x01 # compose by master version and fixed version - TYPE = 0xF1 # hw type defination - TLV_LEN = 00 # data length (16bit) + VERSION = 0x01 # E2PROM Version, start from 0x01 + FLAG = 0x7E # New E2PROM version flag is 0x7E + HW_VER = 0x01 # compose by master version and fixed version + TYPE = 0xF1 # hw type defination + TLV_LEN = 00 # data length (16bit) _FAN_TLV_HDR_LEN = 6 _FAN_TLV_CRC_LEN = 2 @@ -1295,10 +1295,10 @@ def fan_setmac(): def checkfansninput(fan_sn, fansntemp): if fan_sn in fansntemp: - RJPRINTERR("exist same Serial Number,please input again") + RJPRINTERR("exist same Serial Number, please input again") return False if len(fan_sn) != 13: - RJPRINTERR("Serial Number length incorrect,please input again") + RJPRINTERR("Serial Number length incorrect, please input again") return False return True @@ -1416,7 +1416,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):") == True: for fan in fans: log_debug("ouput fan") fac_fan_setmac(fan) diff --git a/platform/broadcom/sonic-platform-modules-ragile/common/service/device_i2c.service b/platform/broadcom/sonic-platform-modules-ragile/common/service/device_i2c.service old mode 100755 new mode 100644 diff --git a/platform/broadcom/sonic-platform-modules-ragile/debian/compat b/platform/broadcom/sonic-platform-modules-ragile/debian/compat index 45a4fb75db86..f599e28b8ab0 100755 --- a/platform/broadcom/sonic-platform-modules-ragile/debian/compat +++ b/platform/broadcom/sonic-platform-modules-ragile/debian/compat @@ -1 +1 @@ -8 +10 diff --git a/platform/broadcom/sonic-platform-modules-ragile/debian/platform-modules-ragile-ra-b6910-64c.install b/platform/broadcom/sonic-platform-modules-ragile/debian/platform-modules-ragile-ra-b6910-64c.install new file mode 100644 index 000000000000..770cabc331e5 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-ragile/debian/platform-modules-ragile-ra-b6910-64c.install @@ -0,0 +1 @@ +ra-b6910-64c/scripts/pddf_post_driver_install.sh /usr/local/bin diff --git a/platform/broadcom/sonic-platform-modules-ragile/debian/platform-modules-ragile-ra-b6910-64c.postinst b/platform/broadcom/sonic-platform-modules-ragile/debian/platform-modules-ragile-ra-b6910-64c.postinst new file mode 100755 index 000000000000..0d9d6a34d2a5 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-ragile/debian/platform-modules-ragile-ra-b6910-64c.postinst @@ -0,0 +1,17 @@ +#!/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 + +# enable platform-service +depmod -a +# systemctl enable platform-modules-ra-b6510-48v8c.service +# systemctl start platform-modules-ra-b6510-48v8c.service +systemctl enable pddf-platform-init.service +systemctl start pddf-platform-init.service + +#DEBHELPER# diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/Makefile b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/Makefile index 46415e74ab7d..49bf43c08c9b 100755 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/Makefile +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/Makefile @@ -7,8 +7,11 @@ INSTALL_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/ -KBUILD_EXTRA_SYMBOLS += $(DIR_KERNEL_SRC)/Module.symvers +ifeq "5.10.0" "$(word 1, $(sort 5.10.0 $(KERNEL_VERSION)))" +KBUILD_EXTRA_SYMBOLS += $(PWD)/../../../pddf/i2c/Module.symvers.PDDF export KBUILD_EXTRA_SYMBOLS +endif + all: $(MAKE) -C $(KBUILD_OUTPUT) M=$(DIR_KERNEL_SRC) modules diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/config/fan_ctrl_cfg.json b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/config/fan_ctrl_cfg.json new file mode 100644 index 000000000000..3e1e46bf927b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/config/fan_ctrl_cfg.json @@ -0,0 +1,43 @@ +{ + "Device": { + "Liquid": 0, + "Buildin": 0, + "PID": 0, + "OpenLoop": 1 + }, + "Thermal": { + "INLET_TEMP": "Temp_MAC_INLET_F", + "OUTLET_TEMP": "Temp_MAC_INLET_R", + "SWITCH_TEMP": "Temp_MAC_INLET_B" + }, + "Fans": { + "Fan1" : "Fantray1_1", + "Fan2" : "Fantray1_2", + "Fan3" : "Fantray2_1", + "Fan4" : "Fantray2_2", + "Fan5" : "Fantray3_1", + "Fan6" : "Fantray3_2", + "Fan7" : "Fantray4_1", + "Fan8" : "Fantray4_2" + }, + "PID": { + "Pwm_Max": 100, + "Pwm_Min": 30, + "SetPoint" : 90, + "P": 1.5, + "I": 1, + "D": 0.3, + "Temp_Min": 28.0, + "Temp_Max": 45.0, + "Sensor": "INLET_TEMP" + }, + "OpenLoop": { + "a": -0.06, + "b": 10.3, + "c": -142.0, + "fix_up": -8, + "pwmMax": 100, + "pwmMin": 30, + "tempMin": 25 + } +} \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/config/x86_64_ragile_ra_b6510_32c_r0_config.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/config/x86_64_ragile_ra_b6510_32c_r0_config.py index 2806615277a7..5cbe571388b0 100755 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/config/x86_64_ragile_ra_b6510_32c_r0_config.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/config/x86_64_ragile_ra_b6510_32c_r0_config.py @@ -99,7 +99,7 @@ MONITOR_FAN_TOTAL_NUM = 5 MONITOR_MAC_UP_TEMP = 50 MONITOR_MAC_LOWER_TEMP = -50 -MONITOR_MAC_MAX_TEMP = 100 # +MONITOR_MAC_MAX_TEMP = 100 # MONITOR_FALL_TEMP = 4 MONITOR_MAC_WARNING_THRESHOLD = 100 #100 @@ -112,7 +112,7 @@ MONITOR_OUTTEMP_CRITICAL_THRESHOLD = 90 #90 MONITOR_BOARDTEMP_CRITICAL_THRESHOLD = 90 #90 MONITOR_CPUTEMP_CRITICAL_THRESHOLD = 100 #100 -MONITOR_INTEMP_CRITICAL_THRESHOLD = 80 # 80 +MONITOR_INTEMP_CRITICAL_THRESHOLD = 80 # 80 MONITOR_CRITICAL_NUM = 3 MONITOR_SHAKE_TIME = 20 MONITOR_INTERVAL = 60 @@ -308,4 +308,6 @@ ] INIT_COMMAND = [ + "i2cset -y -f 6 0x0d 0x92 0x01", + "i2cset -y -f 6 0x0d 0x94 0x01" ] diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/modules/driver/pddf_client_defs.h b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/modules/driver/pddf_client_defs.h index 1c98a73e6eb6..210b4049ca41 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/modules/driver/pddf_client_defs.h +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/modules/driver/pddf_client_defs.h @@ -1,6 +1,6 @@ /* * Copyright 2019 Broadcom. - * The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. + * The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -37,7 +37,7 @@ #ifdef PDDF_DEBUG #define pddf_dbg(filter,...) printk("%s\t", filter); printk(KERN_CONT __VA_ARGS__) #else -#define pddf_dbg(...) +#define pddf_dbg(...) #endif @@ -104,7 +104,7 @@ void traverse_device_table(void ); /*Various Ops hook which can be used by vendors to provide some deviation from usual pddf functionality*/ -struct pddf_ops_t +struct pddf_ops_t { /*Module init ops*/ int (*pre_init)(void); diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/modules/driver/pddf_custom_led_module.c b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/modules/driver/pddf_custom_led_module.c index 5776735ef4fa..055b504f8084 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/modules/driver/pddf_custom_led_module.c +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/modules/driver/pddf_custom_led_module.c @@ -1,6 +1,6 @@ /* * Copyright 2019 Broadcom. - * The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. + * The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,12 +22,13 @@ #include #include #include -#include "pddf_led_defs.h" -#include "pddf_client_defs.h" #include #include #include +#include #include +#include "../../../../../pddf/i2c/modules/include/pddf_led_defs.h" +#include "../../../../../pddf/i2c/modules/include/pddf_client_defs.h" #define DEBUG 0 LED_OPS_DATA sys_led_ops_data[1]={0}; @@ -48,11 +49,16 @@ LED_OPS_DATA* dev_list[LED_TYPE_MAX] = { int num_psus = 0; int num_fantrays = 0; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) +extern int board_i2c_cpld_read_new(unsigned short cpld_addr, char *name, u8 reg); +extern int board_i2c_cpld_write_new(unsigned short cpld_addr, char *name, u8 reg, u8 value); +#else extern int board_i2c_cpld_read(unsigned short cpld_addr, u8 reg); extern int board_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); +extern void *get_device_table(char *name); +#endif extern ssize_t show_pddf_data(struct device *dev, struct device_attribute *da, char *buf); extern ssize_t store_pddf_data(struct device *dev, struct device_attribute *da, const char *buf, size_t count); -extern void *get_device_table(char *name); static LED_STATUS find_state_index(const char* state_str) { int index; @@ -151,6 +157,7 @@ static void print_led_data(LED_OPS_DATA *ptr, LED_STATUS state) } } +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) int get_sys_val(LED_OPS_DATA *ops_ptr, uint32_t *sys_val) { int ret; @@ -184,7 +191,7 @@ int get_sys_val(LED_OPS_DATA *ops_ptr, uint32_t *sys_val) return ret; } - +#endif ssize_t get_status_led(struct device_attribute *da) { @@ -203,6 +210,7 @@ ssize_t get_status_led(struct device_attribute *da) temp_data_ptr->device_name, temp_data_ptr->index); return (-1); } +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) ret = get_sys_val(ops_ptr, &sys_val); if (ret < 0) { pddf_dbg(LED, KERN_ERR "ERROR %s: Cannot get sys val\n", __func__); @@ -210,7 +218,11 @@ ssize_t get_status_led(struct device_attribute *da) } /* keep ret as old value */ ret = 0; - +#else + sys_val = board_i2c_cpld_read_new(ops_ptr->swpld_addr, ops_ptr->device_name, ops_ptr->swpld_addr_offset); + if (sys_val < 0) + return sys_val; +#endif strcpy(temp_data.cur_state.color, "None"); for (state=0; statedata[state].bits.mask_bits); @@ -228,6 +240,7 @@ ssize_t get_status_led(struct device_attribute *da) return(ret); } +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) int set_sys_val(LED_OPS_DATA *ops_ptr, uint32_t new_val) { int ret; @@ -257,6 +270,7 @@ int set_sys_val(LED_OPS_DATA *ops_ptr, uint32_t new_val) return ret; } +#endif ssize_t set_status_led(struct device_attribute *da) { @@ -288,12 +302,18 @@ ssize_t set_status_led(struct device_attribute *da) } if(ops_ptr->data[cur_state].swpld_addr != 0x0) { - ret = get_sys_val(ops_ptr, &sys_val); - if (ret < 0) { - pddf_dbg(LED, KERN_ERR "ERROR %s: Cannot get sys val\n", __func__); - return (-1); - } - +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) + ret = get_sys_val(ops_ptr, &sys_val); + if (ret < 0) { + pddf_dbg(LED, KERN_ERR "ERROR %s: Cannot get sys val\n", __func__); + return (-1); + } +#else + sys_val = board_i2c_cpld_read_new(ops_ptr->swpld_addr, ops_ptr->device_name, ops_ptr->swpld_addr_offset); + if (sys_val < 0) { + return sys_val; + } +#endif new_val = (sys_val & ops_ptr->data[cur_state].bits.mask_bits) | (ops_ptr->data[cur_state].value << ops_ptr->data[cur_state].bits.pos); @@ -303,16 +323,24 @@ ssize_t set_status_led(struct device_attribute *da) return (-1); } +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) ret = set_sys_val(ops_ptr, new_val); if (ret < 0) { pddf_dbg(LED, KERN_ERR "ERROR %s: Cannot set sys val\n", __func__); return (-1); } +#else + board_i2c_cpld_write_new(ops_ptr->swpld_addr, ops_ptr->device_name, ops_ptr->swpld_addr_offset, new_val); +#endif pddf_dbg(LED, KERN_INFO "Set color:%s; 0x%x:0x%x sys_val:0x%x new_val:0x%x read:0x%x\n", LED_STATUS_STR[cur_state], ops_ptr->swpld_addr, ops_ptr->swpld_addr_offset, sys_val, new_val, - ret = board_i2c_cpld_read(ops_ptr->swpld_addr, ops_ptr->swpld_addr_offset)); +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) + ret = board_i2c_cpld_read(ops_ptr->swpld_addr, ops_ptr->swpld_addr_offset)); +#else + ret = board_i2c_cpld_read_new(ops_ptr->swpld_addr, ops_ptr->device_name, ops_ptr->swpld_addr_offset)); +#endif if (ret < 0) { pddf_dbg(LED, KERN_ERR "PDDF_LED ERROR %s: Error %d in reading from cpld(0x%x) offset 0x%x\n", __FUNCTION__, ret, ops_ptr->swpld_addr, ops_ptr->swpld_addr_offset); diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/modules/driver/pddf_led_defs.h b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/modules/driver/pddf_led_defs.h index 1603f8c5af8e..3530ca585d0b 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/modules/driver/pddf_led_defs.h +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/modules/driver/pddf_led_defs.h @@ -1,6 +1,6 @@ /* * Copyright 2019 Broadcom. - * The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. + * The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/api.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/api.py new file mode 100644 index 000000000000..134e3a9872e0 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/api.py @@ -0,0 +1,203 @@ +############################################################################# +# PDDF +# Module contains an implementation of SONiC pddfapi Base API and +# provides the pddfpai information +# +############################################################################# + + +try: + from sonic_platform_pddf_base.pddfapi import PddfApi +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class newapi(PddfApi): + """ + PDDF Platform-Specific pddfapi Class + """ + + def __init__(self): + PddfApi.__init__(self) + + + def show_attr_eeprom_device(self, dev, ops): + ret = [] + attr_name = ops['attr'] + attr_list = dev['i2c']['attr_list'] + KEY = "eeprom" + dsysfs_path = "" + + if KEY not in self.data_sysfs_obj: + self.data_sysfs_obj[KEY] = [] + + for attr in attr_list: + if attr_name == attr['attr_name'] or attr_name == 'all': + if 'drv_attr_name' in attr.keys(): + real_name = attr['drv_attr_name'] + else: + real_name = attr['attr_name'] + + dsysfs_path = self.show_device_sysfs(dev, ops) + \ + "/%d-00%02x" % (int(dev['i2c']['topo_info']['parent_bus'], 0), + int(dev['i2c']['topo_info']['dev_addr'], 0)) + \ + "/%s" % real_name + if dsysfs_path not in self.data_sysfs_obj[KEY]: + self.data_sysfs_obj[KEY].append(dsysfs_path) + ret.append(dsysfs_path) + return ret + + def show_attr_psu_i2c_device(self, dev, ops): + target = ops['target'] + attr_name = ops['attr'] + ret = [] + KEY = "psu" + dsysfs_path = "" + + if KEY not in self.data_sysfs_obj: + self.data_sysfs_obj[KEY] = [] + + if target == 'all' or target == dev['dev_info']['virt_parent']: + attr_list = dev['i2c']['attr_list'] if 'i2c' in dev else [] + for attr in attr_list: + if attr_name == attr['attr_name'] or attr_name == 'all': + if 'attr_devtype' in attr.keys() and attr['attr_devtype'] == "gpio": + # Check and enable the gpio from class + attr_path = self.get_gpio_attr_path(self.data[attr['attr_devname']], attr['attr_offset']) + if (os.path.exists(attr_path)): + if attr_path not in self.data_sysfs_obj[KEY]: + self.data_sysfs_obj[KEY].append(attr_path) + ret.append(attr_path) + else: + if 'drv_attr_name' in attr.keys(): + real_name = attr['drv_attr_name'] + real_dev = dev + elif 'attr_devattr' in attr.keys(): + real_name = attr['attr_devattr'] + real_devname = attr['attr_devname'] if 'attr_devname' in attr.keys() else '' + real_dev = self.data[real_devname] + else: + real_name = attr['attr_name'] + real_dev = dev + + dsysfs_path = self.show_device_sysfs(real_dev, ops) + \ + "/%d-00%02x" % (int(real_dev['i2c']['topo_info']['parent_bus'], 0), + int(real_dev['i2c']['topo_info']['dev_addr'], 0)) + \ + "/%s" % real_name + if dsysfs_path not in self.data_sysfs_obj[KEY]: + self.data_sysfs_obj[KEY].append(dsysfs_path) + ret.append(dsysfs_path) + return ret + + + def show_attr_fan_device(self, dev, ops): + ret = [] + attr_name = ops['attr'] + attr_list = dev['i2c']['attr_list'] if 'i2c' in dev else [] + KEY = "fan" + dsysfs_path = "" + + if KEY not in self.data_sysfs_obj: + self.data_sysfs_obj[KEY] = [] + + for attr in attr_list: + if attr_name == attr['attr_name'] or attr_name == 'all': + if 'attr_devtype' in attr.keys() and attr['attr_devtype'] == "gpio": + # Check and enable the gpio from class + attr_path = self.get_gpio_attr_path(self.data[attr['attr_devname']], attr['attr_offset']) + if (os.path.exists(attr_path)): + if attr_path not in self.data_sysfs_obj[KEY]: + self.data_sysfs_obj[KEY].append(attr_path) + ret.append(attr_path) + else: + if 'drv_attr_name' in attr.keys(): + real_name = attr['drv_attr_name'] + real_dev = dev + elif 'attr_devattr' in attr.keys(): + real_name = attr['attr_devattr'] + real_devname = attr['attr_devname'] if 'attr_devname' in attr.keys() else '' + real_dev = self.data[real_devname] + else: + real_name = attr['attr_name'] + real_dev = dev + + dsysfs_path = self.show_device_sysfs(real_dev, ops) + \ + "/%d-00%02x" % (int(real_dev['i2c']['topo_info']['parent_bus'], 0), + int(real_dev['i2c']['topo_info']['dev_addr'], 0)) + \ + "/%s" % real_name + if dsysfs_path not in self.data_sysfs_obj[KEY]: + self.data_sysfs_obj[KEY].append(dsysfs_path) + ret.append(dsysfs_path) + return ret + + # This is only valid for LM75 + def show_attr_temp_sensor_device(self, dev, ops): + ret = [] + if 'i2c' not in dev.keys(): + return ret + attr_name = ops['attr'] + attr_list = dev['i2c']['attr_list'] if 'i2c' in dev else [] + KEY = "temp-sensors" + dsysfs_path = "" + + if KEY not in self.data_sysfs_obj: + self.data_sysfs_obj[KEY] = [] + + for attr in attr_list: + if attr_name == attr['attr_name'] or attr_name == 'all': + path = self.show_device_sysfs(dev, ops)+"/%d-00%02x/" % (int(dev['i2c']['topo_info']['parent_bus'], 0), + int(dev['i2c']['topo_info']['dev_addr'], 0)) + if 'drv_attr_name' in attr.keys(): + real_name = attr['drv_attr_name'] + else: + real_name = attr['attr_name'] + + if (os.path.exists(path)): + full_path = glob.glob(path + 'hwmon/hwmon*/' + real_name)[0] + dsysfs_path = full_path + if dsysfs_path not in self.data_sysfs_obj[KEY]: + self.data_sysfs_obj[KEY].append(dsysfs_path) + ret.append(full_path) + return ret + + def show_attr_xcvr_i2c_device(self, dev, ops): + target = ops['target'] + attr_name = ops['attr'] + ret = [] + dsysfs_path = "" + KEY = "xcvr" + if KEY not in self.data_sysfs_obj: + self.data_sysfs_obj[KEY] = [] + + if target == 'all' or target == dev['dev_info']['virt_parent']: + attr_list = dev['i2c']['attr_list'] + for attr in attr_list: + if attr_name == attr['attr_name'] or attr_name == 'all': + if 'attr_devtype' in attr.keys() and attr['attr_devtype'] == "gpio": + # Check and enable the gpio from class + attr_path = self.get_gpio_attr_path(self.data[attr['attr_devname']], attr['attr_offset']) + if (os.path.exists(attr_path)): + if attr_path not in self.data_sysfs_obj[KEY]: + self.data_sysfs_obj[KEY].append(attr_path) + ret.append(attr_path) + else: + if 'drv_attr_name' in attr.keys(): + real_name = attr['drv_attr_name'] + real_dev = dev + elif 'attr_devattr' in attr.keys(): + real_name = attr['attr_devattr'] + real_devname = attr['attr_devname'] if 'attr_devname' in attr.keys() else '' + real_dev = self.data[real_devname] + else: + real_name = attr['attr_name'] + real_dev = dev + + dsysfs_path = self.show_device_sysfs(real_dev, ops) + \ + "/%d-00%02x" % (int(real_dev['i2c']['topo_info']['parent_bus'], 0), + int(real_dev['i2c']['topo_info']['dev_addr'], 0)) + \ + "/%s" % real_name + if dsysfs_path not in self.data_sysfs_obj[KEY]: + self.data_sysfs_obj[KEY].append(dsysfs_path) + ret.append(dsysfs_path) + return ret + diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/chassis.py index ae8e74186825..6205b3ad717c 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/chassis.py @@ -7,36 +7,48 @@ try: import time from sonic_platform_pddf_base.pddf_chassis import PddfChassis - from sonic_platform.fan_drawer import FanDrawer + from .component import Component + from sonic_platform.sfp import * except ImportError as e: raise ImportError(str(e) + "- required module not found") -PORT_START = 0 -PORTS_IN_BLOCK = 32 -FAN_NUM_PER_DRAWER = 2 - class Chassis(PddfChassis): """ PDDF Platform-specific Chassis class """ - SFP_STATUS_INSERTED = "1" - SFP_STATUS_REMOVED = "0" - port_dict = {} + STATUS_INSERTED = "1" + STATUS_REMOVED = "0" + sfp_present_dict = {} def __init__(self, pddf_data=None, pddf_plugin_data=None): PddfChassis.__init__(self, pddf_data, pddf_plugin_data) + for i in range(0,5): + self._component_list.append(Component(i)) + + try: + self._sfp_list = [] + sfp_config = get_sfp_config() + self.port_start_index = sfp_config.get("port_index_start", 0) + self.port_num = sfp_config.get("port_num", 0) + # fix problem with first index is 1, we add a fake sfp node + if self.port_start_index == 1: + self._sfp_list.append(Sfp(1)) + + # sfp id always start at 1 + for index in range(1, self.port_num + 1): + self._sfp_list.append(Sfp(index)) + + for i in range(self.port_start_index, self.port_start_index + self.port_num): + self.sfp_present_dict[i] = self.STATUS_REMOVED - # fan drawer - temp = [] - drawer_index = 0 - for idx, fan in enumerate(self.get_all_fans()): - temp.append(fan) - if (idx + 1) % FAN_NUM_PER_DRAWER == 0: - drawer = FanDrawer(drawer_index + 1, temp) - self.get_all_fan_drawers().append(drawer) - temp = [] - drawer_index += 1 + except Exception as err: + print("SFP init error: %s" % str(err)) + + def get_revision(self): + val = ord(self._eeprom.revision_str()) + test = "{}".format(val) + return test def get_reboot_cause(self): """ @@ -52,17 +64,9 @@ def get_reboot_cause(self): return (self.REBOOT_CAUSE_NON_HARDWARE, None) def get_change_event(self, timeout=0): - change_event_dict = {"fan": {}, "sfp": {}} - sfp_status, sfp_change_dict = self.get_transceiver_change_event(timeout) - change_event_dict["sfp"] = sfp_change_dict - if sfp_status is True: - return True, change_event_dict - - return False, {} + change_event_dict = {"sfp": {}} - def get_transceiver_change_event(self, timeout=0): start_time = time.time() - currernt_port_dict = {} forever = False if timeout == 0: @@ -70,25 +74,23 @@ def get_transceiver_change_event(self, timeout=0): elif timeout > 0: timeout = timeout / float(1000) # Convert to secs else: - print("get_transceiver_change_event:Invalid timeout value", timeout) - return False, {} + 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_transceiver_change_event:" "time wrap / invalid timeout value", + "get_change_event:" "time wrap / invalid timeout value", timeout, ) - return False, {} # Time wrap or possibly incorrect timeout - - while timeout >= 0: - # Check for OIR events and return updated port_dict - for index in range(PORT_START, PORTS_IN_BLOCK): - if self._sfp_list[index].get_presence(): - currernt_port_dict[index] = self.SFP_STATUS_INSERTED - else: - currernt_port_dict[index] = self.SFP_STATUS_REMOVED - if currernt_port_dict == self.port_dict: + 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() + if sfp_change_dict : + change_event_dict["sfp"] = sfp_change_dict + return True, change_event_dict if forever: time.sleep(1) else: @@ -98,11 +100,34 @@ def get_transceiver_change_event(self, timeout=0): else: if timeout > 0: time.sleep(timeout) - return True, {} + return True, change_event_dict + except Exception as e: + print(e) + print("get_change_event: Should not reach here.") + return False, change_event_dict + + def get_transceiver_change_event(self): + cur_sfp_present_dict = {} + ret_dict = {} + + # Check for OIR events and return ret_dict + for i in range(self.port_start_index, self.port_start_index + self.port_num): + sfp = self._sfp_list[i] + if sfp.get_presence(): + cur_sfp_present_dict[i] = self.STATUS_INSERTED + else: - # Update reg value - self.port_dict = currernt_port_dict - print(self.port_dict) - return True, self.port_dict - print("get_transceiver_change_event: Should not reach here.") - return False, {} + cur_sfp_present_dict[i] = self.STATUS_REMOVED + + # Update reg value + if cur_sfp_present_dict == self.sfp_present_dict: + return ret_dict + + for index, status in cur_sfp_present_dict.items(): + if self.sfp_present_dict[index] != status: + ret_dict[index] = status + + self.sfp_present_dict = cur_sfp_present_dict + + return ret_dict + 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..b74f1f2c238d 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 @@ -10,21 +10,66 @@ try: import subprocess from sonic_platform_base.component_base import ComponentBase - from sonic_platform.regutil import Reg - from sonic_platform.logger import logger + import sonic_platform.hwaccess as hwaccess except ImportError as e: raise ImportError(str(e) + "- required module not found") +def get_cpld_version(bus, i2caddr): + return '{}{}{}{}'.format(hwaccess.i2c_get(bus, i2caddr, 1), + hwaccess.i2c_get(bus, i2caddr, 2), + hwaccess.i2c_get(bus, i2caddr, 3), + hwaccess.i2c_get(bus, i2caddr, 0) + ) + +def get_cpu_cpld_version(): + return get_cpld_version(6, 0x0d) + +def get_fan_cpld_version(): + return get_cpld_version(2, 0x0d) + +def get_cpld1_version(): + return get_cpld_version(8, 0x30) + +def get_cpld2_version(): + return get_cpld_version(8, 0x31) + +def get_fpga_version(): + version = hwaccess.pci_get_value('/sys/bus/pci/devices/0000:08:00.0/resource0', 0) + datetime = hwaccess.pci_get_value('/sys/bus/pci/devices/0000:08:00.0/resource0',4) + return "%08x-%08x"%(version,datetime) + +COMPONENT_LIST= [ + ['CPU CPLD', + 'cpu board', + get_cpu_cpld_version + ], + + ['CPU FAN CPLD', + 'cpu fan', + get_fan_cpld_version + ], + + ['MAC1 CPLD', + 'mac1 board', + get_cpld1_version + ], + + ['MAC2 CPLD', + 'mac2 board', + get_cpld2_version + ], + ['FPGA', + 'fpga version', + get_fpga_version + ] + ] class Component(ComponentBase): """ Ragile Platform-specific Component class""" - def __init__(self, index, config=None): - self.index = index - self.name = config.get("name") - self._reg_fm_ver = Reg(config.get("firmware_version")) - self.description = config.get("desc") - self.slot = config.get("slot") + def __init__(self, component_index=0): + ComponentBase.__init__(self) + self.index = component_index def get_name(self): """ @@ -33,7 +78,7 @@ def get_name(self): Returns: A string containing the name of the component """ - return self.name + return COMPONENT_LIST[self.index][0] def get_description(self): """ @@ -42,7 +87,7 @@ def get_description(self): Returns: A string containing the description of the component """ - return self.description + return COMPONENT_LIST[self.index][1] def get_firmware_version(self): """ @@ -51,12 +96,7 @@ def get_firmware_version(self): Returns: A string containing the firmware version of the component """ - try: - return self._reg_fm_ver.decode() - except Exception as e: - logger.error(str(e)) - - return "" + return COMPONENT_LIST[self.index][2]() def install_firmware(self, image_path): """ diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/config.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/config.py index 7d3064163b30..5649b9ebfb86 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/config.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/config.py @@ -11,6 +11,11 @@ "DPS-550AB-40 A": "B2F", } +FAN_AIRFLOW = { + "M1HFAN I-F": "F2B", + "M1HFAN I-R": "B2F", +} + psutypedecode = { 0x00: "N/A", 0x01: "AC", diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/fan.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/fan.py index b3dd67ed52cb..9e9cb04064b2 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/fan.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/fan.py @@ -1,5 +1,6 @@ try: from sonic_platform_pddf_base.pddf_fan import PddfFan + from . import api except ImportError as e: raise ImportError(str(e) + "- required module not found") @@ -10,7 +11,7 @@ class Fan(PddfFan): def __init__(self, tray_idx, fan_idx=0, pddf_data=None, pddf_plugin_data=None, is_psu_fan=False, psu_index=0): # idx is 0-based PddfFan.__init__(self, tray_idx, fan_idx, pddf_data, pddf_plugin_data, is_psu_fan, psu_index) - + self.pddf_obj = api.newapi() # Provide the functions/variables below for which implementation is to be overwritten # Since psu_fan airflow direction cant be read from sysfs, it is fixed as 'F2B' or 'intake' def get_direction(self): diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/fan_drawer.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/fan_drawer.py index 2f83b66df94a..d03fd656f4d7 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/fan_drawer.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/fan_drawer.py @@ -1,69 +1,17 @@ -# -# fan_drawer -# +#!/usr/bin/env python + try: - from sonic_platform_base.fan_drawer_base import FanDrawerBase + from sonic_platform_pddf_base.pddf_fan_drawer import PddfFanDrawer except ImportError as e: raise ImportError(str(e) + "- required module not found") -class FanDrawer(FanDrawerBase): - # 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 drawer {}".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 - """ - if self.get_num_fans() > 0: - return self._fan_list[0].set_status_led(color) - return False +class FanDrawer(PddfFanDrawer): + """PDDF Platform-Specific Fan-Drawer class""" - def get_status_led(self): - """ - Gets the state of the fan drawer LED - Returns: - A string, one of the predefined STATUS_LED_COLOR_* strings above - """ - if self.get_num_fans() > 0: - return self._fan_list[0].get_status_led() - return "N/A" + def __init__(self, tray_idx, pddf_data=None, pddf_plugin_data=None): + # idx is 0-based + PddfFanDrawer.__init__(self, tray_idx, pddf_data, pddf_plugin_data) + # Provide the functions/variables below for which implementation is to be overwritten \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/hwaccess.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/hwaccess.py new file mode 100644 index 000000000000..c604d9c61164 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/hwaccess.py @@ -0,0 +1,47 @@ +# Helper functions to access hardware + +import os +import struct +import mmap +import subprocess + +# Read PCI device + +def pci_mem_read(mm, offset): + mm.seek(offset) + read_data_stream = mm.read(4) + return struct.unpack('I',read_data_stream)[0] + +def pci_get_value(resource, offset): + with open(resource, 'r+b') as fd: + mm = mmap.mmap(fd.fileno(), 0) + val = pci_mem_read(mm, offset) + mm.close() + return val + +def pci_mem_write(memmap, offset, data): + """ Write PCI device """ + memmap.seek(offset) + memmap.write(struct.pack('I', data)) + +def pci_set_value(resource, val, offset): + """ Set a value to PCI device """ + with open(resource, 'w+b') as filed: + memmap = None + try: + memmap = mmap.mmap(filed.fileno(), 0) + pci_mem_write(memmap, offset, val) + except EnvironmentError: + pass + if memmap is not None: + memmap.close() + +# Read I2C device + +def i2c_get(bus, i2caddr, ofs): + try: + valx = int(subprocess.check_output(['/usr/sbin/i2cget','-f', '-y', str(bus), str(i2caddr), str(ofs)]), 16) + return "{:02x}".format(valx) + except (FileNotFoundError, subprocess.CalledProcessError): + return -1 + diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/psu.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/psu.py index 240af5d2d1b5..f25b24f145a5 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/psu.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/psu.py @@ -1,17 +1,19 @@ try: from sonic_platform_pddf_base.pddf_psu import PddfPsu + import subprocess + import time except ImportError as e: raise ImportError (str(e) + "- required module not found") class Psu(PddfPsu): """PDDF Platform-Specific PSU class""" - + PLATFORM_PSU_CAPACITY = 1200 def __init__(self, index, pddf_data=None, pddf_plugin_data=None): PddfPsu.__init__(self, index, pddf_data, pddf_plugin_data) - + # Provide the functions/variables below for which implementation is to be overwritten def get_maximum_supplied_power(self): """ @@ -30,3 +32,119 @@ def get_type(self): """ return "DC" + def get_model(self): + """ + Retrieves the model number (or part number) of the device + + Returns: + string: Model/part number of device + """ + model = super().get_model() + + psu_model_map = { + # -F + "CSU550AP-3-500": "PA550II-F", + "DPS-550AB-39 A": "PA550II-F", + "GW-CRPS550N2C": "PA550II-F", + "CSU550AP-3-300": "PA550II-F", + "DPS-550AB-39 B": "PA550II-F", + # -R + "CSU550AP-3-501": "PA550II-R", + "DPS-550AB-40 A": "PA550II-R", + "GW-CRPS550N2RC": "PA550II-R", + } + + return psu_model_map.get(model, model) + + def runcmd(self, cmd): + time_retry = 6 + result_msg = "" + time_delay = 0.01 + while time_retry: + try: + val, result_msg = subprocess.getstatusoutput(cmd) + 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, result_msg + + def get_voltage(self): + """ + Retrieves current PSU voltage output + + Returns: + A float number, the output voltage in volts, + e.g. 12.1 + """ + + v_out = 0 + label_t = "psu_v_out" + device = "PSU{}".format(self.psu_index) + #print(device) + pddf_obj_data = self.pddf_obj.data + + if device in pddf_obj_data.keys(): + pmbusloc = pddf_obj_data[device]['i2c']['interface'] + + for val in pmbusloc: + dev_name = val['dev'] + pmbus_loc = pddf_obj_data[dev_name] + i2cloc = pmbus_loc['i2c']['attr_list'] + parentbus = pmbus_loc['i2c']['topo_info'] + + for item_t in i2cloc: + if item_t['attr_name'] == label_t: + parentbus_id = int(parentbus['parent_bus'], 16) + vout_mode_cmd = "i2cget -f -y {} {} 0x20 bp".format(parentbus_id, parentbus['dev_addr']) + ret_t, val_voutmode = self.runcmd(vout_mode_cmd) + if ret_t is False: + return 0.0 + v_out_cmd = "i2cget -f -y {} {} {} wp".format(parentbus_id, parentbus['dev_addr'], item_t['attr_offset']) + ret_t, val_p_out = self.runcmd(v_out_cmd) + if ret_t is False: + return 0.0 + val_voutmode_t = int(val_voutmode, 16) + val_p_out_t = int(val_p_out, 16) * 1000 + + import ctypes + val_voutmode_t_t = ctypes.c_int8(val_voutmode_t << 3).value >>3 + + if (val_voutmode_t_t) < 0: + val_p_out_t_f = val_p_out_t>> (-val_voutmode_t_t) + else: + val_p_out_t_f = val_p_out_t << val_voutmode_t_t + + return float(val_p_out_t_f)/1000 + + return float(v_out)/1000 + + def get_revision(self): + """ + Retrieves the hardware revision of the device + + Returns: + string: Revision value of device + """ + device_eeprom = "PSU{}-EEPROM".format(self.psu_index) + pddf_obj_data = self.pddf_obj.data + + if device_eeprom not in pddf_obj_data.keys(): + return "N/A" + + i2cloc = pddf_obj_data[device_eeprom]['i2c']['topo_info'] + i2cbus = int(i2cloc['parent_bus'], 16) + get_revision_cmd = "i2cget -f -y {} {} 0x35 w".format(i2cbus, i2cloc['dev_addr']) + ret_t, revision = self.runcmd(get_revision_cmd) + if ret_t is False: + return "N/A" + revision = int(revision, 16) + revision_str = "%s%s" % (chr(revision&0xff), chr((revision >> 8)&0xff)) + return revision_str diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/sfp.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/sfp.py index ea8e256fe6ef..9009c3440275 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/sfp.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/sfp.py @@ -1,287 +1,525 @@ -#!/usr/bin/env python +#!/usr/bin/python +# -*- coding: UTF-8 -*- + +############################################################################# +# +# Module contains an implementation of SONiC Platform Base API and +# provides the platform information +# +# +# *_device.py config version instruction: +# ver 1.0 - platform api: +# "presence_cpld": { +# "dev_id": { +# [dev_id]: { +# "offset": { +# [offset]: [port_id] +# } +# } +# } +# } +# "reset_cpld": { +# "dev_id": { +# [dev_id]: { +# "offset": { +# [offset]: [port_id] +# } +# } +# } +# } +# ver 2.0 - rg_plat: +# "presence_path": "/xx/rg_plat/xx[port_id]/present" +# "eeprom_path": "/sys/bus/i2c/devices/i2c-[bus]/[bus]-0050/eeprom" +# "reset_path": "/xx/rg_plat/xx[port_id]/reset" +############################################################################# +import sys +import time +import syslog +import traceback +from abc import abstractmethod try: - #from sonic_platform_pddf_base.pddf_sfp import * - from sonic_platform_base.sonic_sfp.sff8436 import sff8436InterfaceId - from sonic_platform_base.sonic_sfp.sff8436 import sff8436Dom - from sonic_platform_base.sonic_sfp.sff8472 import sff8472InterfaceId - from sonic_platform_base.sonic_sfp.sff8472 import sff8472Dom - from sonic_platform_pddf_base.pddf_sfp import PddfSfp - from sonic_platform_pddf_base.pddf_sfp import SFP_VOLT_OFFSET - from sonic_platform_pddf_base.pddf_sfp import SFP_VOLT_WIDTH - from sonic_platform_pddf_base.pddf_sfp import SFP_CHANNL_MON_OFFSET - from sonic_platform_pddf_base.pddf_sfp import SFP_CHANNL_MON_WIDTH - from sonic_platform_pddf_base.pddf_sfp import SFP_TEMPE_OFFSET - from sonic_platform_pddf_base.pddf_sfp import SFP_TEMPE_WIDTH - from sonic_platform_pddf_base.pddf_sfp import QSFP_DOM_REV_OFFSET - from sonic_platform_pddf_base.pddf_sfp import QSFP_DOM_REV_WIDTH - from sonic_platform_pddf_base.pddf_sfp import QSFP_CHANNL_MON_OFFSET - from sonic_platform_pddf_base.pddf_sfp import QSFP_CHANNL_MON_WITH_TX_POWER_WIDTH + import os + from sonic_platform_base.sonic_xcvr.sfp_optoe_base import SfpOptoeBase + from sonic_platform.sfp_config import * + except ImportError as e: raise ImportError (str(e) + "- required module not found") -XCVR_DOM_CAPABILITY_OFFSET = 92 -XCVR_DOM_CAPABILITY_WIDTH = 2 -QSFP_VERSION_COMPLIANCE_OFFSET = 1 -QSFP_VERSION_COMPLIANCE_WIDTH = 2 -QSFP_OPTION_VALUE_OFFSET = 192 -QSFP_OPTION_VALUE_WIDTH = 4 - -class Sfp(PddfSfp): - """ - PDDF Platform-Specific Sfp class - """ - - def __init__(self, index, pddf_data=None, pddf_plugin_data=None): - PddfSfp.__init__(self, index, pddf_data, pddf_plugin_data) - self.dom_supported = False - self.__dom_capability_detect() - - def __dom_capability_detect(self): - self.dom_supported = False - self.dom_temp_supported = False - self.dom_volt_supported = False - self.dom_rx_power_supported = False - self.dom_tx_power_supported = False - self.qsfp_page3_available = False - self.calibration = 0 - if not self.get_presence(): - return - - if self.is_osfp_port: - # Not implement - return - elif self.is_qsfp_port: - self.calibration = 1 - sfpi_obj = sff8436InterfaceId() - if sfpi_obj is None: - self.dom_supported = False - offset = 128 - - # QSFP capability byte parse, through this byte can know whether it support tx_power or not. - # TODO: in the future when decided to migrate to support SFF-8636 instead of SFF-8436, - # need to add more code for determining the capability and version compliance - # in SFF-8636 dom capability definitions evolving with the versions. - qsfp_dom_capability_raw = self.__read_eeprom_specific_bytes( - (offset + XCVR_DOM_CAPABILITY_OFFSET), XCVR_DOM_CAPABILITY_WIDTH) - if qsfp_dom_capability_raw is not None: - qsfp_version_compliance_raw = self.__read_eeprom_specific_bytes( - QSFP_VERSION_COMPLIANCE_OFFSET, QSFP_VERSION_COMPLIANCE_WIDTH) - qsfp_version_compliance = int( - qsfp_version_compliance_raw[0], 16) - dom_capability = sfpi_obj.parse_dom_capability( - qsfp_dom_capability_raw, 0) - if qsfp_version_compliance >= 0x08: - self.dom_temp_supported = dom_capability['data']['Temp_support']['value'] == 'On' - self.dom_volt_supported = dom_capability['data']['Voltage_support']['value'] == 'On' - self.dom_rx_power_supported = dom_capability['data']['Rx_power_support']['value'] == 'On' - self.dom_tx_power_supported = dom_capability['data']['Tx_power_support']['value'] == 'On' - else: - self.dom_temp_supported = True - self.dom_volt_supported = True - self.dom_rx_power_supported = dom_capability['data']['Rx_power_support']['value'] == 'On' - self.dom_tx_power_supported = True - - self.dom_supported = True - self.calibration = 1 - sfpd_obj = sff8436Dom() - if sfpd_obj is None: - return None - qsfp_option_value_raw = self.__read_eeprom_specific_bytes( - QSFP_OPTION_VALUE_OFFSET, QSFP_OPTION_VALUE_WIDTH) - if qsfp_option_value_raw is not None: - optional_capability = sfpd_obj.parse_option_params( - qsfp_option_value_raw, 0) - self.dom_tx_disable_supported = optional_capability[ - 'data']['TxDisable']['value'] == 'On' - dom_status_indicator = sfpd_obj.parse_dom_status_indicator( - qsfp_version_compliance_raw, 1) - self.qsfp_page3_available = dom_status_indicator['data']['FlatMem']['value'] == 'Off' - else: - self.dom_supported = False - self.dom_temp_supported = False - self.dom_volt_supported = False - self.dom_rx_power_supported = False - self.dom_tx_power_supported = False - self.calibration = 0 - self.qsfp_page3_available = False +LOG_DEBUG_LEVEL = 1 +LOG_WARNING_LEVEL = 2 +LOG_ERROR_LEVEL = 3 + +CONFIG_DB_PATH = "/etc/sonic/config_db.json" + +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 get_sfp_config(): + dev = getplatform_name() + return cust_sfp_cfg.get(dev, None) + +class Sfp(SfpOptoeBase): + + OPTOE_DRV_TYPE1 = 1 + OPTOE_DRV_TYPE2 = 2 + OPTOE_DRV_TYPE3 = 3 + + # index must start at 1 + def __init__(self, index, a=None, b=None): + SfpOptoeBase.__init__(self) + self.sfp_type = None + sfp_config = get_sfp_config() + self.log_level_config = sfp_config.get("log_level", LOG_WARNING_LEVEL) + # Init instance of SfpCust + ver = sfp_config.get("ver", None) + if ver is None: + self._sfplog(LOG_ERROR_LEVEL, "Get Ver Config Error!") + vers = int(float(ver)) + if vers == 1: + self._sfp_api = SfpV1(index) + elif vers == 2: + self._sfp_api = SfpV2(index) else: - sfpi_obj = sff8472InterfaceId() - if sfpi_obj is None: - return None - sfp_dom_capability_raw = self.__read_eeprom_specific_bytes( - XCVR_DOM_CAPABILITY_OFFSET, XCVR_DOM_CAPABILITY_WIDTH) - if sfp_dom_capability_raw is not None: - sfp_dom_capability = int(sfp_dom_capability_raw[0], 16) - self.dom_supported = (sfp_dom_capability & 0x40 != 0) - if self.dom_supported: - self.dom_temp_supported = True - self.dom_volt_supported = True - self.dom_rx_power_supported = True - self.dom_tx_power_supported = True - if sfp_dom_capability & 0x20 != 0: - self.calibration = 1 - elif sfp_dom_capability & 0x10 != 0: - self.calibration = 2 - else: - self.calibration = 0 - else: - self.dom_temp_supported = False - self.dom_volt_supported = False - self.dom_rx_power_supported = False - self.dom_tx_power_supported = False - self.calibration = 0 - self.dom_tx_disable_supported = ( - int(sfp_dom_capability_raw[1], 16) & 0x40 != 0) - - # Provide the functions/variables below for which implementation is to be overwritten - - def __read_eeprom_specific_bytes(self, offset, num_bytes): - eeprom_raw = [] - if not self.get_presence(): - return None - for i in range(0, num_bytes): - eeprom_raw.append("0x00") + self._sfplog(LOG_ERROR_LEVEL, "Get SfpVer Error!") - try: - with open(self.eeprom_path, mode="rb", buffering=0) as eeprom: - eeprom.seek(offset) - raw = eeprom.read(num_bytes) - except Exception as e: - print("Error: Unable to open eeprom_path: %s" % (str(e))) - return None + def get_eeprom_path(self): + return self._sfp_api._get_eeprom_path() + + def read_eeprom(self, offset, num_bytes): + return self._sfp_api.read_eeprom(offset, num_bytes) + + def write_eeprom(self, offset, num_bytes, write_buffer): + return self._sfp_api.write_eeprom(offset, num_bytes, write_buffer) + def get_presence(self): + return self._sfp_api.get_presence() + + def get_transceiver_info(self): + # temporary solution for a sonic202111 bug + transceiver_info = super().get_transceiver_info() try: - if len(raw) == 0: - return None - for n in range(0, num_bytes): - eeprom_raw[n] = hex(raw[n])[2:].zfill(2) + if transceiver_info["vendor_rev"] is not None: + transceiver_info["hardware_rev"] = transceiver_info["vendor_rev"] + return transceiver_info except Exception as e: - print("Error: Exception info: %s" % (str(e))) - return None + print(traceback.format_exc()) - return eeprom_raw + def reset(self): + if self.get_presence() is False: + return False - def get_transceiver_bulk_status(self): - # check present status - if not self.get_presence(): - return None - self.__dom_capability_detect() + if self.sfp_type is None: + self.refresh_xcvr_api() - xcvr_dom_info_dict = dict.fromkeys(self.dom_dict_keys, 'N/A') + if self.sfp_type == 'SFP': + self._sfplog(LOG_ERROR_LEVEL, 'SFP does not support reset') + return False - if self.is_osfp_port: - # Below part is added to avoid fail xcvrd, shall be implemented later - pass - elif self.is_qsfp_port: - # QSFPs - xcvr_dom_info_dict = super(Sfp, self).get_transceiver_bulk_status() + self._sfplog(LOG_DEBUG_LEVEL, 'resetting...') + ret = self._sfp_api.set_reset(True) + if ret: + time.sleep(0.5) + ret = self._sfp_api.set_reset(False) - # pddf_sfp "qsfp_tx_power_support != 'on'" is wrong + return ret - offset = 0 - sfpd_obj = sff8436Dom() - if sfpd_obj is None: - return None + def get_lpmode(self): + if self.get_presence() is False: + return False - qsfp_dom_rev_raw = self.__read_eeprom_specific_bytes((offset + QSFP_DOM_REV_OFFSET), QSFP_DOM_REV_WIDTH) - if qsfp_dom_rev_raw is not None: - qsfp_dom_rev_data = sfpd_obj.parse_sfp_dom_rev(qsfp_dom_rev_raw, 0) - else: - return None + if self.sfp_type is None: + self.refresh_xcvr_api() - dom_channel_monitor_data = {} - qsfp_dom_rev = qsfp_dom_rev_data['data']['dom_rev']['value'] + if self.sfp_type == 'SFP': + self._sfplog(LOG_WARNING_LEVEL, 'SFP does not support lpmode') + return False - if (qsfp_dom_rev[0:8] == 'SFF-8636' and self.dom_tx_power_supported is True): - dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( - (offset + QSFP_CHANNL_MON_OFFSET), QSFP_CHANNL_MON_WITH_TX_POWER_WIDTH) - if dom_channel_monitor_raw is not None: - dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params_with_tx_power( - dom_channel_monitor_raw, 0) - else: - return None + #implement in future - xcvr_dom_info_dict['tx1power'] = dom_channel_monitor_data['data']['TX1Power']['value'] - xcvr_dom_info_dict['tx2power'] = dom_channel_monitor_data['data']['TX2Power']['value'] - xcvr_dom_info_dict['tx3power'] = dom_channel_monitor_data['data']['TX3Power']['value'] - xcvr_dom_info_dict['tx4power'] = dom_channel_monitor_data['data']['TX4Power']['value'] - else: - # SFPs - offset = 256 - if not self.dom_supported: - return xcvr_dom_info_dict + return False - sfpd_obj = sff8472Dom() - if sfpd_obj is None: - return None + def set_lpmode(self, lpmode): + if self.get_presence() is False: + return False - sfpd_obj._calibration_type = self.calibration + if self.sfp_type is None or self._xcvr_api is None: + self.refresh_xcvr_api() - dom_temperature_raw = self.__read_eeprom_specific_bytes((offset + SFP_TEMPE_OFFSET), SFP_TEMPE_WIDTH) - if dom_temperature_raw is not None: - dom_temperature_data = sfpd_obj.parse_temperature(dom_temperature_raw, 0) + 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 None + return self._xcvr_api.set_power_override(False, lpmode) + else: + self._sfplog(LOG_WARNING_LEVEL, 'SFP does not support lpmode') + 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._sfplog(LOG_DEBUG_LEVEL, "set_optoe_write_max NotImplemented") + pass + + 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__ + optoe_type = None + # set sfp_type + if (class_name == 'CmisApi'): + self.sfp_type = 'QSFP-DD' + optoe_type = self.OPTOE_DRV_TYPE3 + elif (class_name == 'Sff8472Api'): + self.sfp_type = 'SFP' + optoe_type = self.OPTOE_DRV_TYPE2 + elif (class_name == 'Sff8636Api' or class_name == 'Sff8436Api'): + self.sfp_type = 'QSFP' + optoe_type = self.OPTOE_DRV_TYPE1 + + if optoe_type is not None: + # set optoe driver + self._sfp_api.set_optoe_type(optoe_type) + + def _sfplog(self, log_level, msg): + if log_level >= self.log_level_config: + try: + syslog.openlog("Sfp") + if log_level == LOG_DEBUG_LEVEL: + syslog.syslog(syslog.LOG_DEBUG, msg) + elif log_level == LOG_WARNING_LEVEL: + syslog.syslog(syslog.LOG_DEBUG, msg) + elif log_level == LOG_ERROR_LEVEL: + syslog.syslog(syslog.LOG_ERR, msg) + syslog.closelog() + + except Exception as e: + print(traceback.format_exc()) + +class SfpCust(): + def __init__(self, index): + self.eeprom_path = None + self._init_config(index) + + def _init_config(self, index): + sfp_config = get_sfp_config() + self.log_level_config = sfp_config.get("log_level", LOG_WARNING_LEVEL) + self._port_id = index + self.eeprom_retry_times = sfp_config.get("eeprom_retry_times", 0) + self.eeprom_retry_break_sec = sfp_config.get("eeprom_retry_break_sec", 0) + + def combine_format_str(self, str, key): + count_format = str.count('%') + if count_format > 0: + args_k = [] + for i in range(count_format): + args_k.append(key) + return str % (tuple(args_k)) + else: + return str - dom_voltage_raw = self.__read_eeprom_specific_bytes((offset + SFP_VOLT_OFFSET), SFP_VOLT_WIDTH) - if dom_voltage_raw is not None: - dom_voltage_data = sfpd_obj.parse_voltage(dom_voltage_raw, 0) - else: - return None + def _get_eeprom_path(self): + return self.eeprom_path or None - dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( - (offset + SFP_CHANNL_MON_OFFSET), SFP_CHANNL_MON_WIDTH) - if dom_channel_monitor_raw is not None: - dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params(dom_channel_monitor_raw, 0) - else: - return None - - xcvr_dom_info_dict['temperature'] = dom_temperature_data['data']['Temperature']['value'] - xcvr_dom_info_dict['voltage'] = dom_voltage_data['data']['Vcc']['value'] - xcvr_dom_info_dict['rx1power'] = dom_channel_monitor_data['data']['RXPower']['value'] - xcvr_dom_info_dict['rx2power'] = 'N/A' - xcvr_dom_info_dict['rx3power'] = 'N/A' - xcvr_dom_info_dict['rx4power'] = 'N/A' - xcvr_dom_info_dict['tx1bias'] = dom_channel_monitor_data['data']['TXBias']['value'] - xcvr_dom_info_dict['tx2bias'] = 'N/A' - xcvr_dom_info_dict['tx3bias'] = 'N/A' - xcvr_dom_info_dict['tx4bias'] = 'N/A' - xcvr_dom_info_dict['tx1power'] = dom_channel_monitor_data['data']['TXPower']['value'] - xcvr_dom_info_dict['tx2power'] = 'N/A' - xcvr_dom_info_dict['tx3power'] = 'N/A' - xcvr_dom_info_dict['tx4power'] = 'N/A' - - xcvr_dom_info_dict['rx_los'] = self.get_rx_los() - xcvr_dom_info_dict['tx_fault'] = self.get_tx_fault() - xcvr_dom_info_dict['reset_status'] = self.get_reset_status() - xcvr_dom_info_dict['lp_mode'] = self.get_lpmode() - - return xcvr_dom_info_dict - - def get_transceiver_threshold_info(self): - # check present status - if not self.get_presence(): - return None - self.__dom_capability_detect() - - xcvr_dom_threshold_info_dict = dict.fromkeys(self.threshold_dict_keys, 'N/A') - - if self.is_osfp_port: - # Below part is added to avoid fail xcvrd, shall be implemented later - pass - elif self.is_qsfp_port: - # QSFPs - if not self.dom_supported or not self.qsfp_page3_available: - return xcvr_dom_threshold_info_dict - - return super(Sfp, self).get_transceiver_threshold_info() + @abstractmethod + def get_presence(self): + pass - else: - # SFPs - if not self.dom_supported: - return xcvr_dom_threshold_info_dict + def read_eeprom(self, offset, num_bytes): + try: + for i in range(self.eeprom_retry_times): + with open(self._get_eeprom_path(), mode='rb', buffering=0) as f: + f.seek(offset) + result = f.read(num_bytes) + # temporary solution for a sonic202111 bug + if len(result) < num_bytes: + result = result[::-1].zfill(num_bytes)[::-1] + if result != None: + return bytearray(result) + else: + time.sleep(self.eeprom_retry_break_sec) + continue + + except Exception as e: + self._sfplog(LOG_ERROR_LEVEL, traceback.format_exc()) + + return None - return super(Sfp, self).get_transceiver_threshold_info() - return xcvr_dom_threshold_info_dict + def write_eeprom(self, offset, num_bytes, write_buffer): + try: + for i in range(self.eeprom_retry_times): + ret = SfpOptoeBase.write_eeprom(self, offset, num_bytes, write_buffer) + if ret is False: + time.sleep(self.eeprom_retry_break_sec) + continue + break + + return ret + + except Exception as e: + self._sfplog(LOG_ERROR_LEVEL, traceback.format_exc()) + + + @abstractmethod + def set_optoe_type(self, class_name): + pass + + @abstractmethod + def set_reset(self, reset): + pass + + def _convert_str_range_to_int_arr(self, range_str): + if not range_str: + return [] + + int_range_strs = range_str.split(',') + range_res = [] + for int_range_str in int_range_strs: + if '-' in int_range_str: + range_s = int(int_range_str.split('-')[0]) + range_e = int(int_range_str.split('-')[1]) + 1 + else: + range_s = int(int_range_str) + range_e = int(int_range_str) + 1 + + range_res = range_res + list(range(range_s, range_e)) + + return range_res + + def _sfplog(self, log_level, msg): + if log_level >= self.log_level_config: + try: + syslog.openlog("SfpCust") + if log_level == LOG_DEBUG_LEVEL: + syslog.syslog(syslog.LOG_DEBUG, msg) + elif log_level == LOG_WARNING_LEVEL: + syslog.syslog(syslog.LOG_DEBUG, msg) + elif log_level == LOG_ERROR_LEVEL: + syslog.syslog(syslog.LOG_ERR, msg) + syslog.closelog() + + except Exception as e: + print(traceback.format_exc()) + +class SfpV1(SfpCust): + def _init_config(self, index): + super()._init_config(index) + sfp_config = get_sfp_config() + + # init presence path + self.presence_cpld = sfp_config.get("presence_cpld", None) + self.presence_val_is_present = sfp_config.get("presence_val_is_present", 0) + self._sfplog(LOG_DEBUG_LEVEL, "Done init presence path") + + # init reset path + self.reset_cpld = sfp_config.get("reset_cpld", None) + self.reset_val_is_reset = sfp_config.get("reset_val_is_reset", 0) + self._sfplog(LOG_DEBUG_LEVEL, "Done init cpld path") + + def get_presence(self): + if self.presence_cpld is None: + self._sfplog(LOG_ERROR_LEVEL, "presence_cpld is None!") + return False + try: + dev_id, offset, offset_bit = self._get_sfp_cpld_info(self.presence_cpld) + ret, info = platform_reg_read(0, dev_id, offset, 1) + return (info[0] & (1 << offset_bit) == self.presence_val_is_present) + except Exception as err: + self._sfplog(LOG_ERROR_LEVEL, traceback.format_exc()) + + def read_eeprom(self, offset, num_bytes): + try: + for i in range(self.eeprom_retry_times): + ret, info = platform_sfp_read(self._port_id, offset, num_bytes) + if (ret is False + or info is None): + time.sleep(self.eeprom_retry_break_sec) + continue + eeprom_raw = [] + for i in range(0, num_bytes): + eeprom_raw.append("0x00") + for n in range(0, len(info)): + eeprom_raw[n] = info[n] + # temporary solution for a sonic202111 bug + if len(eeprom_raw) < num_bytes: + eeprom_raw = eeprom_raw[::-1].zfill(num_bytes)[::-1] + return bytearray(eeprom_raw) + except Exception as e: + self._sfplog(LOG_ERROR_LEVEL, traceback.format_exc()) + return None + + def write_eeprom(self, offset, num_bytes, write_buffer): + try: + for i in range(self.eeprom_retry_times): + # TODO: write_buffer is bytearray, need to convert to int array + val_list = [] + if isinstance(write_buffer, list): + val_list = write_buffer + else: + val_list.append(write_buffer) + ret, info = platform_sfp_write(self._port_id, offset, val_list) + if ret is False: + time.sleep(self.eeprom_retry_break_sec) + continue + return True + except Exception as e: + self._sfplog(LOG_ERROR_LEVEL, traceback.format_exc()) + + return False + + def set_optoe_type(self, optoe_type): + ret, info = platform_get_optoe_type(self._port_id) + if info != optoe_type: + try: + ret, _ = platform_set_optoe_type(self._port_id, optoe_type) + except Exception as err: + self._sfplog(LOG_ERROR_LEVEL, "Set optoe err %s" % err) + + def set_reset(self, reset): + if self.reset_cpld is None: + self._sfplog(LOG_ERROR_LEVEL, "reset_cpld is None!") + return False + try: + val = [] + dev_id, offset, offset_bit = self._get_sfp_cpld_info(self.reset_cpld) + ret, info = platform_reg_read(0, dev_id, offset, 1) + if self.reset_val_is_reset == 0: + if reset: + val.append(info[0] & (~(1 << offset_bit))) + else: + val.append(info[0] | (1 << offset_bit)) + else: + if reset: + val.append(info[0] | (1 << offset_bit)) + else: + val.append(info[0] & (~(1 << offset_bit))) + + ret, info = platform_reg_write(0, dev_id, offset, val) + if ret is False: + self._sfplog(LOG_ERROR_LEVEL, "platform_reg_write error!") + return False + + except Exception as err: + self._sfplog(LOG_ERROR_LEVEL, traceback.format_exc()) + return False + + return True + + def _get_sfp_cpld_info(self, cpld_config): + dev_id = 0 + offset = 0 + + for dev_id_temp in cpld_config["dev_id"]: + for offset_temp in cpld_config["dev_id"][dev_id_temp]["offset"]: + port_range_str = cpld_config["dev_id"][dev_id_temp]["offset"][offset_temp] + port_range_int = self._convert_str_range_to_int_arr(port_range_str) + if self._port_id in port_range_int: + dev_id = dev_id_temp + offset = offset_temp + offset_bit = port_range_int.index(self._port_id) + break + + return dev_id, offset, offset_bit + +class SfpV2(SfpCust): + def _init_config(self, index): + super()._init_config(index) + sfp_config = get_sfp_config() + + # init eeprom path + eeprom_path_config = sfp_config.get("eeprom_path", None) + eeprom_path_key = sfp_config.get("eeprom_path_key")[self._port_id - 1] + self.eeprom_path = self.combine_format_str(eeprom_path_config, eeprom_path_key) + self._sfplog(LOG_DEBUG_LEVEL, "Done init eeprom path: %s" % self.eeprom_path) + + # init presence path + presence_path_config = sfp_config.get("presence_path", None) + presence_path_key = sfp_config.get("presence_path_key")[self._port_id - 1] + self.presence_path = self.combine_format_str(presence_path_config, presence_path_key) + self.presence_val_is_present = sfp_config.get("presence_val_is_present", 0) + self._sfplog(LOG_DEBUG_LEVEL, "Done init presence path: %s" % self.presence_path) + + # init optoe driver path + optoe_driver_path_config = sfp_config.get("optoe_driver_path", None) + optoe_driver_key = sfp_config.get("optoe_driver_key")[self._port_id - 1] + self.dev_class_path = self.combine_format_str(optoe_driver_path_config, optoe_driver_key) + self._sfplog(LOG_DEBUG_LEVEL, "Done init optoe driver path: %s" % self.dev_class_path) + + # init txdisable path + txdisable_path_config = sfp_config.get("txdisable_path", None) + if txdisable_path_config is not None: + txdisable_path_key = sfp_config.get("txdisable_path_key")[self._port_id - 1] + self.txdisable_path = self.combine_format_str(txdisable_path_config, txdisable_path_key) + self.txdisable_val_is_on = sfp_config.get("txdisable_val_is_on", 0) + self._sfplog(LOG_DEBUG_LEVEL, "Done init optoe driver path: %s" % self.dev_class_path) + + # init reset path + reset_path_config = sfp_config.get("reset_path", None) + if reset_path_config is not None: + reset_path_key = sfp_config.get("reset_path_key")[self._port_id - 1] + self.reset_path = self.combine_format_str(reset_path_config, reset_path_key) + self.reset_val_is_on = sfp_config.get("reset_val_is_on", 0) + self._sfplog(LOG_DEBUG_LEVEL, "Done init reset path: %s" % self.reset_path) + + def get_presence(self): + if self.presence_path is None: + self._sfplog(LOG_ERROR_LEVEL, "presence_path is None!") + return False + try: + with open(self.presence_path, "rb") as data: + sysfs_data = data.read(1) + if sysfs_data != "": + result = int(sysfs_data, 16) + return result == self.presence_val_is_present + except Exception as err: + self._sfplog(LOG_ERROR_LEVEL, traceback.format_exc()) + + def set_reset(self, reset): + return True + + def set_optoe_type(self, optoe_type): + if self.dev_class_path is None: + self._sfplog(LOG_ERROR_LEVEL, "dev_class_path is None!") + return False + try: + dc_file = open(self.dev_class_path, "r+") + dc_file_val = dc_file.read(1) + if int(dc_file_val) != optoe_type: + dc_str = "%s" % str(optoe_type) + dc_file.write(dc_str) + dc_file.close() + except Exception as err: + self._sfplog(LOG_ERROR_LEVEL, traceback.format_exc()) diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/sfp_config.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/sfp_config.py new file mode 100644 index 000000000000..1bac5e80c719 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/sfp_config.py @@ -0,0 +1,23 @@ +cust_sfp_cfg = { + 'x86_64-ragile_ra-b6510-32c-r0': { + "ver": '2.1', + "port_index_start": 0, + "port_num": 32, + "log_level": 2, + "eeprom_retry_times": 5, + "eeprom_retry_break_sec": 0.2, + "presence_path": "/sys/bus/i2c/devices/%d-0053/xcvr_present", + "presence_path_key": list(range(32, 64)), + "presence_val_is_present": 1, + "eeprom_path": "/sys/bus/i2c/devices/%d-0050/eeprom", + "eeprom_path_key": list(range(32, 64)), + "optoe_driver_path": "/sys/bus/i2c/devices/%d-0050/dev_class", + "optoe_driver_key": list(range(32, 64)), + "txdisable_path": "/sys/bus/i2c/devices/%d-0053/xcvr_txdisable", + "txdisable_path_key": list(range(32, 64)) , + "txdisable_val_is_on": 0, + "reset_path": "/sys/bus/i2c/devices/%d-0053/xcvr_reset", + "reset_path_key": list(range(32, 64)), + "reset_val_is_on": 0, + }, +} diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/thermal.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/thermal.py index 99b743c6d343..f2a73e5f5db8 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/thermal.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-32c/sonic_platform/thermal.py @@ -8,7 +8,7 @@ class Thermal(PddfThermal): """PDDF Platform-Specific Thermal class""" - def __init__(self, index, pddf_data=None, pddf_plugin_data=None): - PddfThermal.__init__(self, index, pddf_data, pddf_plugin_data) + def __init__(self, index, pddf_data=None, pddf_plugin_data=None, is_psu_thermal=False, psu_index=0): + PddfThermal.__init__(self, index, pddf_data, pddf_plugin_data, is_psu_thermal, psu_index) # Provide the functions/variables below for which implementation is to be overwritten diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/Makefile b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/Makefile index 9e262d7c095e..e32f4eeae9d5 100755 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/Makefile +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/Makefile @@ -7,8 +7,11 @@ INSTALL_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/ -KBUILD_EXTRA_SYMBOLS += $(DIR_KERNEL_SRC)/Module.symvers +ifeq "5.10.0" "$(word 1, $(sort 5.10.0 $(KERNEL_VERSION)))" +KBUILD_EXTRA_SYMBOLS += $(PWD)/../../../pddf/i2c/Module.symvers.PDDF export KBUILD_EXTRA_SYMBOLS +endif + all: $(MAKE) -C $(KBUILD_OUTPUT) M=$(DIR_KERNEL_SRC) modules diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/config/fan_ctrl_cfg.json b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/config/fan_ctrl_cfg.json new file mode 100644 index 000000000000..c2afe07c082e --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/config/fan_ctrl_cfg.json @@ -0,0 +1,49 @@ +{ + "Device": { + "Liquid": 0, + "Buildin": 0, + "PID": 0, + "OpenLoop": 1 + }, + "Thermal": { + "INLET_TEMP": "Temp_MAC_INLET_F", + "OUTLET_TEMP": "Temp_MAC_INLET_R", + "SWITCH_TEMP": "Temp_MAC_INLET_B" + }, + "Fans": { + "Fan1" : "Fantray1_1", + "Fan2" : "Fantray1_2", + "Fan3" : "Fantray2_1", + "Fan4" : "Fantray2_2", + "Fan5" : "Fantray3_1", + "Fan6" : "Fantray3_2", + "Fan7" : "Fantray4_1", + "Fan8" : "Fantray4_2" + }, + "PID": { + "Pwm_Max": 100, + "Pwm_Min": 30, + "SetPoint" : 90, + "P": 1.5, + "I": 1, + "D": 0.3, + "Temp_Min": 28.0, + "Temp_Max": 45.0, + "Sensor": "INLET_TEMP" + }, + "OpenLoop": { + "a": -0.06, + "b": 10.3, + "c": -142.0, + "fix_up": -8, + "pwmMax": 100, + "pwmMin": 30, + "tempMin": 25 + }, + "FanLed": { + "Fantray1": {"bus":2, "devno":13, "addr":59, "green":9, "red":10}, + "Fantray2": {"bus":2, "devno":13, "addr":60, "green":9, "red":10}, + "Fantray3": {"bus":2, "devno":13, "addr":61, "green":9, "red":10}, + "Fantray4": {"bus":2, "devno":13, "addr":62, "green":9, "red":10} + } +} \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/config/x86_64_ragile_ra_b6510_48v8c_r0_config.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/config/x86_64_ragile_ra_b6510_48v8c_r0_config.py index 5fe30ea12848..73043d8cdd74 100755 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/config/x86_64_ragile_ra_b6510_48v8c_r0_config.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/config/x86_64_ragile_ra_b6510_48v8c_r0_config.py @@ -1,217 +1,19 @@ #!/usr/bin/python # -*- coding: UTF-8 -*- -from ragilecommon import * +from ragilecommon import * PCA9548START = -1 PCA9548BUSEND = -2 - RAGILE_CARDID = 0x0000404a RAGILE_PRODUCTNAME = "RA-B6510-48V8C" STARTMODULE = { "fancontrol":1, "avscontrol":1, - "dev_monitor":1 -} - -i2ccheck_params = {"busend":"i2c-66","retrytime":6} - -DEV_MONITOR_PARAM = { - "polling_time": 10, - "psus": [ - { - "name": "psu1", - "present": { - "gettype": "i2c", - "bus": 2, - "loc": 0x37, - "offset": 0x51, - "presentbit": 0, - "okval": 0, - }, - "device": [ - { - "id": "psu1pmbus", - "name": "dps550", - "bus": 7, - "loc": 0x58, - "attr": "hwmon", - }, - ], - }, - { - "name": "psu2", - "present": { - "gettype": "i2c", - "bus": 2, - "loc": 0x37, - "offset": 0x51, - "presentbit": 4, - "okval": 0, - }, - "device": [ - { - "id": "psu2pmbus", - "name": "dps550", - "bus": 8, - "loc": 0x5B, - "attr": "hwmon", - }, - ], - }, - ], -} - -fanlevel = { - "tips":["LOW","MEDIUM","HIGH"], - "level":[51,150,255], - "low_speed":[500,7500,17000], - "high_speed":[11000,22500,28500] -} - -# fit with pddf -fanloc = [ - { - "name": "FAN1/FAN2/FAN3/FAN4", - "location": "2-0066/fan1_pwm", - "childfans": [ - {"name": "FAN1", "location": "2-0066/fan1_input"}, - {"name": "FAN2", "location": "2-0066/fan2_input"}, - {"name": "FAN3", "location": "2-0066/fan3_input"}, - {"name": "FAN4", "location": "2-0066/fan4_input"}, - ], - }, -] - - - -MONITOR_TEMP_MIN = 38 -MONITOR_K = 11 -MONITOR_MAC_IN = 35 -MONITOR_DEFAULT_SPEED = 0x60 -MONITOR_MAX_SPEED = 0xFF -MONITOR_MIN_SPEED = 0x33 -MONITOR_MAC_ERROR_SPEED = 0XBB -MONITOR_FAN_TOTAL_NUM = 4 -MONITOR_MAC_UP_TEMP = 50 -MONITOR_MAC_LOWER_TEMP = -50 -MONITOR_MAC_MAX_TEMP = 100 - -MONITOR_FALL_TEMP = 4 -MONITOR_MAC_WARNING_THRESHOLD = 100 -MONITOR_OUTTEMP_WARNING_THRESHOLD = 85 -MONITOR_BOARDTEMP_WARNING_THRESHOLD = 85 -MONITOR_CPUTEMP_WARNING_THRESHOLD = 85 -MONITOR_INTEMP_WARNING_THRESHOLD = 70 - -MONITOR_MAC_CRITICAL_THRESHOLD = 105 -MONITOR_OUTTEMP_CRITICAL_THRESHOLD = 90 -MONITOR_BOARDTEMP_CRITICAL_THRESHOLD = 90 -MONITOR_CPUTEMP_CRITICAL_THRESHOLD = 100 -MONITOR_INTEMP_CRITICAL_THRESHOLD = 80 -MONITOR_CRITICAL_NUM = 3 -MONITOR_SHAKE_TIME = 20 -MONITOR_INTERVAL = 60 - -MONITOR_SYS_LED = [ - {"bus":2,"devno":0x33, "addr":0xb2, "yellow":0x03, "red":0x02,"green":0x01}, - {"bus":2,"devno":0x37, "addr":0xb2, "yellow":0x03, "red":0x02,"green":0x01}] - -MONITOR_SYS_FAN_LED =[ - {"bus":2,"devno":0x33, "addr":0xb4, "yellow":0x06, "red":0x02,"green":0x04}, - ] -MONITOR_FANS_LED = [ - {"bus":2,"devno":0x32, "addr":0x23, "green":0x09, "red":0x0a}, - {"bus":2,"devno":0x32, "addr":0x24, "green":0x09, "red":0x0a}, - {"bus":2,"devno":0x32, "addr":0x25, "green":0x09, "red":0x0a}, - {"bus":2,"devno":0x32, "addr":0x26, "green":0x09, "red":0x0a}] - - -CPLDVERSIONS = [ - {"bus":2, "devno":0x33, "name":"MAC BOARD CPLD-A"}, - {"bus":2, "devno":0x35, "name":"MAC BOARD CPLD-B"}, - {"bus":2, "devno":0x37, "name":"CONNECT BOARD CPLD-A"}, - {"bus":0, "devno":0x0d, "name":"CPU BOARD CPLD"}, -] - -MONITOR_SYS_PSU_LED =[ - {"bus":2,"devno":0x33, "addr":0xb3, "yellow":0x06, "red":0x02,"green":0x04}, - ] - -MONITOR_FAN_STATUS = [ - {'status':'green' , 'minOkNum':4,'maxOkNum':4}, - {'status':'yellow', 'minOkNum':3,'maxOkNum':3}, - {'status':'red' , 'minOkNum':0,'maxOkNum':2}, - ] - -MONITOR_PSU_STATUS = [ - {'status':'green' , 'minOkNum':2,'maxOkNum':2}, - {'status':'yellow', 'minOkNum':1,'maxOkNum':1}, - {'status':'red' , 'minOkNum':0,'maxOkNum':0}, - ] - - -MONITOR_DEV_STATUS = { - "temperature": [ - {"name":"lm75in", "location":"/sys/bus/i2c/devices/2-0048/hwmon/*/temp1_input"}, - {"name":"lm75out", "location":"/sys/bus/i2c/devices/2-0049/hwmon/*/temp1_input"}, - {"name":"lm75hot", "location":"/sys/bus/i2c/devices/2-004a/hwmon/*/temp1_input"}, - {"name":"cpu", "location":"/sys/class/hwmon/hwmon0"}, - ], - "fans": [ - { - "name":"fan1", - "presentstatus":{"bus":2, "loc":0x37, "offset":0x30, 'bit':0}, - "rollstatus": [ - {"name":"motor1","bus":2, "loc":0x37, "offset":0x31, 'bit':0}, - ] - }, - { - "name":"fan2", - "presentstatus":{"bus":2, "loc":0x37, "offset":0x30, 'bit':1}, - "rollstatus":[ - {"name":"motor1","bus":2, "loc":0x37, "offset":0x31, 'bit':1}, - ] - }, - { - "name":"fan3", - "presentstatus":{"bus":2, "loc":0x37, "offset":0x30, 'bit':2}, - "rollstatus":[ - {"name":"motor1","bus":2, "loc":0x37, "offset":0x31, 'bit':2}, - ] - }, - { - "name":"fan4", - "presentstatus":{"bus":2, "loc":0x37, "offset":0x30, 'bit':3}, - "rollstatus":[ - {"name":"motor1","bus":2, "loc":0x37, "offset":0x31, 'bit':3}, - ] - }, - ], - "psus": [ - {"name":"psu1", "bus":2, "loc":0x37, "offset":0x51, "gettype":"i2c", 'presentbit': 0, 'statusbit':1,'alertbit':2}, - {"name":"psu2", "bus":2, "loc":0x37, "offset":0x51, "gettype":"i2c", 'presentbit': 4, 'statusbit':5,'alertbit':6}, - ], - "mac_temp" : { - "flag" : {"bus":2, "loc":0x33, "offset":0xd4, "gettype":"i2c", 'okbit': 0, 'okval':1}, - "loc" : [ - "2-0035/mac_temp_input", - ], - "try_bcmcmd" : 0, - }, + "macledreset":1, } -MONITOR_DEV_STATUS_DECODE = { - 'fanpresent': {0:'PRESENT', 1:'ABSENT', 'okval':0}, - 'fanroll' : {0:'STALL' , 1:'ROLL', 'okval':1}, - 'psupresent': {0:'PRESENT', 1:'ABSENT', 'okval':0}, - 'psuoutput' : {0:'FAULT' , 1:'NORMAL', 'okval':1}, - 'psualert' : {0:'FAULT' , 1:'NORMAL', 'okval':1}, -} ################################################################### - - - MAC_AVS_PARAM ={ 0x72:0x0384, 0x73:0x037e, @@ -259,226 +61,13 @@ "mask": 0xff } - - DEVICE = [] DRIVERLISTS = [] - -""" -## -DRIVERLISTS = [ - {"name":"i2c_dev", "delay":0}, - {"name":"i2c_algo_bit","delay":0}, - {"name":"i2c_gpio", "delay":0}, - {"name":"i2c_mux", "delay":0}, - {"name":"i2c_mux_pca9641", "delay":0}, - {"name":"i2c_mux_pca954x force_create_bus=1", "delay":0},# force_deselect_on_exit=1 - {"name":"lm75", "delay":0}, - {"name":"optoe", "delay":0}, - {"name":"at24", "delay":0}, - {"name":"rg_sff", "delay":0}, - {"name":"ragile_b6510_platform", "delay":0}, - {"name":"ragile_platform", "delay":0}, - {"name":"rg_avs", "delay":0}, - {"name":"rg_cpld", "delay":0}, - {"name":"rg_fan", "delay":0}, - {"name":"rg_psu", "delay":0}, - {"name":"pmbus_core", "delay":0}, - {"name":"csu550", "delay":0}, - {"name":"rg_gpio_xeon", "delay":0}, - {"name":"firmware_driver", "delay":0}, - {"name":"firmware_bin", "delay":0}, - {"name":"ragile_b6510_sfputil", "delay":0}, - {"name":"ragile_common dfd_my_type=0x404a", "delay":0}, - {"name":"lpc_dbg", "delay":0}, -] - -DEVICE = [ - {"name":"pca9641","bus":0 ,"loc":0x10 }, - {"name":"pca9548","bus":2 ,"loc":0x70 }, - {"name":"lm75","bus": 2, "loc":0x48 }, - {"name":"lm75","bus": 2, "loc":0x49 }, - {"name":"lm75","bus": 2, "loc":0x4a }, - {"name":"24c02","bus":2 , "loc":0x57 }, - {"name":"rg_cpld","bus":0 ,"loc":0x32 }, - {"name":"rg_cpld","bus":1 ,"loc":0x34 }, - {"name":"rg_cpld","bus":1 ,"loc":0x36 }, - {"name":"rg_cpld","bus":2 ,"loc":0x33 }, - {"name":"rg_cpld","bus":2 ,"loc":0x35 }, - {"name":"rg_cpld","bus":2 ,"loc":0x37 }, - {"name":"rg_avs","bus": 2 ,"loc":0x60 }, - {"name":"pca9548","bus":1,"loc":0x70 }, - {"name":"pca9548","bus":1,"loc":0x71 }, - {"name":"pca9548","bus":1,"loc":0x72 }, - {"name":"pca9548","bus":1,"loc":0x73 }, - {"name":"pca9548","bus":1,"loc":0x74 }, - {"name":"pca9548","bus":1,"loc":0x75 }, - {"name":"pca9548","bus":1,"loc":0x76 }, - {"name":"rg_fan","bus":3,"loc":0x53 }, - {"name":"rg_fan","bus":4,"loc":0x53 }, - {"name":"rg_fan","bus":5,"loc":0x53 }, - {"name":"rg_fan","bus":6,"loc":0x53 }, - {"name":"rg_psu","bus":7 ,"loc":0x50 }, - {"name":"dps550","bus":7 ,"loc":0x58 }, - {"name":"rg_psu","bus":8 ,"loc":0x53 }, - {"name":"dps550","bus":8 ,"loc":0x5b }, - {"name": "optoe2", "bus": 11, "loc": 0x50}, - {"name": "optoe2", "bus": 12, "loc": 0x50}, - {"name": "optoe2", "bus": 13, "loc": 0x50}, - {"name": "optoe2", "bus": 14, "loc": 0x50}, - {"name": "optoe2", "bus": 15, "loc": 0x50}, - {"name": "optoe2", "bus": 16, "loc": 0x50}, - {"name": "optoe2", "bus": 17, "loc": 0x50}, - {"name": "optoe2", "bus": 18, "loc": 0x50}, - {"name": "optoe2", "bus": 19, "loc": 0x50}, - {"name": "optoe2", "bus": 20, "loc": 0x50}, - {"name": "optoe2", "bus": 21, "loc": 0x50}, - {"name": "optoe2", "bus": 22, "loc": 0x50}, - {"name": "optoe2", "bus": 23, "loc": 0x50}, - {"name": "optoe2", "bus": 24, "loc": 0x50}, - {"name": "optoe2", "bus": 25, "loc": 0x50}, - {"name": "optoe2", "bus": 26, "loc": 0x50}, - {"name": "optoe2", "bus": 27, "loc": 0x50}, - {"name": "optoe2", "bus": 28, "loc": 0x50}, - {"name": "optoe2", "bus": 29, "loc": 0x50}, - {"name": "optoe2", "bus": 30, "loc": 0x50}, - {"name": "optoe2", "bus": 31, "loc": 0x50}, - {"name": "optoe2", "bus": 32, "loc": 0x50}, - {"name": "optoe2", "bus": 33, "loc": 0x50}, - {"name": "optoe2", "bus": 34, "loc": 0x50}, - {"name": "optoe2", "bus": 35, "loc": 0x50}, - {"name": "optoe2", "bus": 36, "loc": 0x50}, - {"name": "optoe2", "bus": 37, "loc": 0x50}, - {"name": "optoe2", "bus": 38, "loc": 0x50}, - {"name": "optoe2", "bus": 39, "loc": 0x50}, - {"name": "optoe2", "bus": 40, "loc": 0x50}, - {"name": "optoe2", "bus": 41, "loc": 0x50}, - {"name": "optoe2", "bus": 42, "loc": 0x50}, - {"name": "optoe2", "bus": 43, "loc": 0x50}, - {"name": "optoe2", "bus": 44, "loc": 0x50}, - {"name": "optoe2", "bus": 45, "loc": 0x50}, - {"name": "optoe2", "bus": 46, "loc": 0x50}, - {"name": "optoe2", "bus": 47, "loc": 0x50}, - {"name": "optoe2", "bus": 48, "loc": 0x50}, - {"name": "optoe2", "bus": 49, "loc": 0x50}, - {"name": "optoe2", "bus": 50, "loc": 0x50}, - {"name": "optoe2", "bus": 51, "loc": 0x50}, - {"name": "optoe2", "bus": 52, "loc": 0x50}, - {"name": "optoe2", "bus": 53, "loc": 0x50}, - {"name": "optoe2", "bus": 54, "loc": 0x50}, - {"name": "optoe2", "bus": 55, "loc": 0x50}, - {"name": "optoe2", "bus": 56, "loc": 0x50}, - {"name": "optoe2", "bus": 57, "loc": 0x50}, - {"name": "optoe2", "bus": 58, "loc": 0x50}, - {"name": "optoe1", "bus": 59, "loc": 0x50}, - {"name": "optoe1", "bus": 60, "loc": 0x50}, - {"name": "optoe1", "bus": 61, "loc": 0x50}, - {"name": "optoe1", "bus": 62, "loc": 0x50}, - {"name": "optoe1", "bus": 63, "loc": 0x50}, - {"name": "optoe1", "bus": 64, "loc": 0x50}, - {"name": "optoe1", "bus": 65, "loc": 0x50}, - {"name": "optoe1", "bus": 66, "loc": 0x50}, -] - -INIT_PARAM = [ - {"loc":"1-0034/sfp_enable","value": "01"}, - {"loc":"2-0035/sfp_enable2","value":"ff"}, - {"loc":"2-0033/mac_led", "value":"ff"}, - {"loc":"1-0034/sfp_txdis1","value":"00"}, - {"loc":"1-0034/sfp_txdis2","value":"00"}, - {"loc":"1-0034/sfp_txdis3","value":"00"}, - {"loc":"1-0036/sfp_txdis4","value":"00"}, - {"loc":"1-0036/sfp_txdis5","value":"00"}, - {"loc":"1-0036/sfp_txdis6","value":"00"}, - {"loc":fanloc[0]["location"], "value":"80"}, - {"loc":"2-0033/sfp_led1_yellow","value":"ad"}, - {"loc":"2-0035/sfp_led2_yellow","value":"ad"}, -] -""" - -INIT_PARAM = [ - { - "name": "sfp_enable", - "bus": 1, - "devaddr": 0x34, - "offset": 0xa1, - "val": 0x01, - }, - { - "name": "sfp_eanble2", - "bus": 2, - "devaddr": 0x35, - "offset": 0xa0, - "val": 0xff, - }, - { - "name": "mac_led", - "bus": 2, - "devaddr": 0x33, - "offset": 0xa0, - "val": 0xff, - }, - { - "name": "sfp_txdis1", - "bus": 1, - "devaddr": 0x34, - "offset": 0x60, - "val": 0x00, - }, - { - "name": "sfp_txdis2", - "bus": 1, - "devaddr": 0x34, - "offset": 0x61, - "val": 0x00, - }, - { - "name": "sfp_txdis3", - "bus": 1, - "devaddr": 0x34, - "offset": 0x62, - "val": 0x00, - }, - { - "name": "sfp_txdis4", - "bus": 1, - "devaddr": 0x36, - "offset": 0x60, - "val": 0x00, - }, - { - "name": "sfp_txdis5", - "bus": 1, - "devaddr": 0x36, - "offset": 0x61, - "val": 0x00, - }, - { - "name": "sfp_txdis6", - "bus": 1, - "devaddr": 0x36, - "offset": 0x62, - "val": 0x00, - }, - { - "name": "sfp_led1_yellow", - "bus": 2, - "devaddr": 0x33, - "offset": 0xad, - "val": 0xad, - }, - { - "name": "sfp_led2_yellow", - "bus": 2, - "devaddr": 0x35, - "offset": 0xad, - "val": 0xad, - }, - { - "name": "fan_speed_set", - "bus": 0, - "devaddr": 0x32, - "offset": 0x15, - "val": 0x80, - }, -] +MAC_LED_RESET = {"pcibus":8, "slot":0, "fn":0, "bar":0, "offset":64, "reset":0x98} +INIT_PARAM = [] +INIT_COMMAND = [ + "i2cset -y -f 6 0x0d 0x91 0x48", + "i2cset -y -f 6 0x0d 0x72 0x04", + "i2cset -y -f 6 0x0d 0x92 0x01", + "i2cset -y -f 6 0x0d 0x94 0x01" +] \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/modules/driver/Makefile b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/modules/driver/Makefile index f10216ec4d5a..72ba59368635 100755 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/modules/driver/Makefile +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/modules/driver/Makefile @@ -1 +1,2 @@ obj-m := rg_cpld.o +obj-m += rg_lpc_cpld.o diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/modules/driver/ragile.h b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/modules/driver/ragile.h new file mode 100755 index 000000000000..338874297e55 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/modules/driver/ragile.h @@ -0,0 +1,116 @@ +#ifndef __RAGILE_H__ +#define __RAGILE_H__ + +#include +#include + +typedef enum { + DBG_START, + DBG_VERBOSE, + DBG_KEY, + DBG_WARN, + DBG_ERROR, + DBG_END, +} dbg_level_t; + +typedef enum dfd_cpld_id { + BCM_CPLD0 = 0, + BCM_CPLD1, + CPLD0_MAC0, + CPLD0_MAC1, + CPLD1_MAC0, + CPLD2_MAC1, +} dfd_cpld_id_t; + +typedef enum dfd_cpld_bus { + SMBUS_BUS = 0 , + PCA9641_BUS = 1, + GPIO_BUS = 2, +} dfd_cpld_bus_t; + +typedef struct dfd_i2c_dev_s { + int bus; + int addr; +} dfd_i2c_dev_t; + + typedef enum dfd_cpld_addr { + CPLD_ADDR_MIN = 0x31, + BCM_CPLD0_ADDR = 0x32, + CPLD0_MAC0_ADDR = 0x33, + CPLD0_MAC1_ADDR = 0x34, + CPLD1_MAC0_ADDR = 0x35, + CPLD2_MAC1_ADDR = 0x36, + BCM_CPLD1_ADDR = 0x37, + CPLD_ADDR_MAX, +} dfd_cpld_addr_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 enum dfd_intf_e{ + DFD_INTF_GET_FAN_HW_VERSION, + DFD_INTF_GET_FAN_STATUS, + DFD_INTF_GET_FAN_SPEED_LEVEL, + DFD_INTF_GET_FAN_SPEED, + DFD_INTF_GET_FAN_ATTRIBUTE, + DFD_INTF_GET_FAN_SN, + DFD_INTF_GET_FAN_TYPE, + DFD_INTF_SET_FAN_SPEED_LEVEL, + DFD_INTF_GET_FAN_SUB_NUM, + DFD_INTF_GET_FAN_FAIL_BITMAP, +}dfd_intf_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; + +typedef struct i2c_muxs_struct_flag +{ + int nr; + char name[48]; + struct mutex update_lock; + int flag; +}i2c_mux_flag; + +extern int setpca9641_muxflag(i2c_mux_flag i2c); +extern i2c_mux_flag getpca9641_muxflag(void) ; + +extern int debuglevel; +extern int dfd_cpld_read_chipid(int cpldid , uint32_t addr, int32_t size, unsigned char *buf); +extern int dfd_cpld_read(int32_t addr, uint8_t *val); +extern int dfd_cpld_write(int32_t addr, uint8_t val); +extern int ragile_setdebug(int val); + +#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) + +#define COMMON_STR_LEN (256) + +#endif diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/modules/driver/rg_cpld.c b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/modules/driver/rg_cpld.c index 885a727be683..65e6bf872e25 100755 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/modules/driver/rg_cpld.c +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/modules/driver/rg_cpld.c @@ -1,7 +1,8 @@ /* - * rg_cpld.c - A driver for cpld + * rg_cpld.c - A driver for control rg_cpld base on rg_cpld.c * - * Copyright (c) 2019 + * Copyright (c) 1998, 1999 Frodo Looijaard + * Copyright (c) 2018 support * * 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 @@ -29,473 +30,431 @@ #include #include #include +#include - -/* debug level */ typedef enum { - DBG_START, - DBG_VERBOSE, - DBG_KEY, - DBG_WARN, - DBG_ERROR, - DBG_END, + DBG_START, + DBG_VERBOSE, + DBG_KEY, + DBG_WARN, + DBG_ERROR, + DBG_END, } dbg_level_t; static int debuglevel = 0; -module_param(debuglevel, int, S_IRUGO); +module_param(debuglevel, 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 { } \ + 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) + if ( debuglevel > DBG_START) { \ + printk(KERN_ERR "[ERROR]:<%s, %d>:"fmt, __FUNCTION__, __LINE__, ##arg); \ + } \ + } while (0) static const unsigned short rg_i2c_cpld[] = { 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, I2C_CLIENT_END }; #define CPLD_SIZE 256 -#define CPLD_I2C_RETRY_TIMES 3 -#define READ_TEMP_FAIL 1000000 +#define CPLD_I2C_RETRY_TIMES 5 +#define CPLD_I2C_RETRY_WAIT_TIME 10 struct cpld_data { - struct i2c_client *client; - struct device *hwmon_dev; - struct mutex update_lock; - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u8 data[CPLD_SIZE]; /* Register value */ + struct i2c_client *client; + struct device *hwmon_dev; + struct mutex update_lock; + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 data[CPLD_SIZE]; /* Register value */ }; static s32 cpld_i2c_smbus_read_byte_data(const struct i2c_client *client, u8 command) { - int try; - s32 ret; - - ret = -1; - for (try = 0; try < CPLD_I2C_RETRY_TIMES; try++) { - if ((ret = i2c_smbus_read_byte_data(client, command) ) >= 0 ) - break; - } - return ret; + int try; + s32 ret; + + ret = -1; + for (try = 0; try < CPLD_I2C_RETRY_TIMES; try++) { + if ((ret = i2c_smbus_read_byte_data(client, command) ) >= 0 ) + break; + msleep(CPLD_I2C_RETRY_WAIT_TIME); + } + return ret; } static s32 cpld_i2c_smbus_read_i2c_block_data(const struct i2c_client *client, - u8 command, u8 length, u8 *values) + u8 command, u8 length, u8 *values) { - int try; - s32 ret; - - ret = -1; - for (try = 0; try < CPLD_I2C_RETRY_TIMES; try++) { - if ((ret = i2c_smbus_read_i2c_block_data(client, command, length, values) ) >= 0 ) - break; - } - return ret; + int try; + s32 ret; + + ret = -1; + for (try = 0; try < CPLD_I2C_RETRY_TIMES; try++) { + if ((ret = i2c_smbus_read_i2c_block_data(client, command, length, values) ) >= 0 ) + break; + msleep(CPLD_I2C_RETRY_WAIT_TIME); + } + return ret; } - + static ssize_t show_fan_rpm_value(struct device *dev, struct device_attribute *da, char *buf) -{ - struct cpld_data *data = dev_get_drvdata(dev); - struct i2c_client *client = data->client; - int index = to_sensor_dev_attr_2(da)->index; - uint8_t size; - s32 status; - s32 ret_t; - - ret_t = 0; - status = -1; - size = 0; - mutex_lock(&data->update_lock); - status = cpld_i2c_smbus_read_byte_data(client, index); - if (status < 0) { - mutex_unlock(&data->update_lock); - return 0; - } - data->data[0] = status; - status = cpld_i2c_smbus_read_byte_data(client, index + 1); - if (status < 0) { - mutex_unlock(&data->update_lock); - return 0; - } - data->data[1] = status; - DBG_DEBUG("cpld reg pos:0x%x value:0x%x\n", index, data->data[0]); - DBG_DEBUG("cpld reg pos:0x%x value:0x%x\n", index + 1, data->data[1]); - ret_t = (data->data[1] << 8) + data->data[0] ; - if (ret_t == 0 ) { - size = snprintf(buf, CPLD_SIZE, "%d\n", ret_t); - } else if (ret_t == 0xffff) { - size = snprintf(buf, CPLD_SIZE, "%d\n", 0); - } else { - size = snprintf(buf, CPLD_SIZE, "%d\n", 15000000 / ret_t); - } - mutex_unlock(&data->update_lock); - return size; -} - -static ssize_t set_cpld_sysfs_value(struct device *dev, struct device_attribute *da, const char *buf, size_t -count) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - unsigned long val; - int err; - - err = kstrtoul(buf, 16, &val); - if (err) - return err; - if ((val < 0) || (val > 0xff)) { - DBG_ERROR("please enter 0x00 ~ 0xff\n"); - return -1; - } - mutex_lock(&data->update_lock); - data->data[0] = (u8)val; - DBG_DEBUG("pos: 0x%02x count = %ld, data = 0x%02x\n", attr->index, count, data->data[0]); - i2c_smbus_write_byte_data(client, attr->index, data->data[0]); - mutex_unlock(&data->update_lock); - - return count; -} - -static ssize_t show_cpld_version(struct device *dev, struct device_attribute *da, char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - s32 status; - - status = -1; - mutex_lock(&data->update_lock); - status = cpld_i2c_smbus_read_i2c_block_data(client, 0, 4, data->data); - if (status < 0) { - mutex_unlock(&data->update_lock); - return 0; - } - mutex_unlock(&data->update_lock); - return sprintf(buf, "%02x %02x %02x %02x \n", data->data[0], data->data[1], data->data[2], - data->data[3]); -} - -static ssize_t show_cpld_sysfs_value(struct device *dev, struct device_attribute *da, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - s32 status; - - status = -1; - mutex_lock(&data->update_lock); - status = cpld_i2c_smbus_read_byte_data(client, attr->index); - if (status < 0) { - mutex_unlock(&data->update_lock); - return 0; - } - data->data[0] = status; - DBG_DEBUG("cpld reg pos:0x%x value:0x%02x\n", attr->index, data->data[0]); - mutex_unlock(&data->update_lock); - return sprintf(buf, "%02x\n", data->data[0]); -} - -static ssize_t show_mac_temp_value(struct device *dev, struct device_attribute *da, char *buf) { struct cpld_data *data = dev_get_drvdata(dev); struct i2c_client *client = data->client; int index = to_sensor_dev_attr_2(da)->index; - int tmp_value, value; + uint8_t size; s32 status; + s32 ret_t; + ret_t = 0; status = -1; + size = 0; mutex_lock(&data->update_lock); - status = cpld_i2c_smbus_read_byte_data(client, index); if (status < 0) { mutex_unlock(&data->update_lock); - return snprintf(buf, CPLD_SIZE, "%d\n", -READ_TEMP_FAIL); + return 0; } data->data[0] = status; status = cpld_i2c_smbus_read_byte_data(client, index + 1); if (status < 0) { mutex_unlock(&data->update_lock); - return snprintf(buf, CPLD_SIZE, "%d\n", -READ_TEMP_FAIL); + return 0; } data->data[1] = status; - DBG_DEBUG("cpld reg pos:0x%x value:0x%x\n", index, data->data[0]); - DBG_DEBUG("cpld reg pos:0x%x value:0x%x\n", index + 1, data->data[1]); + DBG_DEBUG("cpld reg pos:0x%x value:0x%x\n", index, data->data[0]); + DBG_DEBUG("cpld reg pos:0x%x value:0x%x\n", index + 1, data->data[1]); + ret_t = (data->data[1] << 8) + data->data[0] ; + if (ret_t == 0 ) { + size = snprintf(buf, CPLD_SIZE, "%d\n", ret_t); + } else if (ret_t == 0xffff) { + size = snprintf(buf, CPLD_SIZE, "%d\n", 0); + } else { + size = snprintf(buf, CPLD_SIZE, "%d\n", 15000000 / ret_t); + } mutex_unlock(&data->update_lock); + return size; +} - tmp_value = (data->data[1] << 8) + data->data[0]; - if (tmp_value == 0) { - DBG_ERROR("invalid cpld value : %d.\n", tmp_value); - return snprintf(buf, CPLD_SIZE, "%d\n", -READ_TEMP_FAIL); - } +static ssize_t set_cpld_sysfs_value(struct device *dev, struct device_attribute *da, const char *buf, size_t +count) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct cpld_data *data = i2c_get_clientdata(client); + unsigned long val; + int err; - DBG_DEBUG("tmp_value = 0x%x\n", tmp_value); - value = 434100 - (12500000 / (tmp_value * 100 - 1) *535); - if ((value / 1000 < -70) || (value / 1000 > 200)) { - return snprintf(buf, CPLD_SIZE, "%d\n", -READ_TEMP_FAIL); + err = kstrtoul(buf, 16, &val); + if (err) + return err; + if ((val < 0) || (val > 0xff)) { + DBG_ERROR("please enter 0x00 ~ 0xff\n"); + return -1; } + mutex_lock(&data->update_lock); + data->data[0] = (u8)val; + DBG_DEBUG("pos: 0x%02x count = %ld, data = 0x%02x\n", attr->index, count, data->data[0]); + i2c_smbus_write_byte_data(client, attr->index, data->data[0]); + mutex_unlock(&data->update_lock); - return snprintf(buf, CPLD_SIZE, "%d\n", value); + return count; +} + +static ssize_t show_cpld_version(struct device *dev, struct device_attribute *da, char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct cpld_data *data = i2c_get_clientdata(client); + s32 status; + int size; + + status = -1; + size = 0; + mutex_lock(&data->update_lock); + status = cpld_i2c_smbus_read_i2c_block_data(client, 0, 4, data->data); + if (status < 0) { + mutex_unlock(&data->update_lock); + return 0; + } + size = snprintf(buf, CPLD_SIZE, "%02x %02x %02x %02x \n", data->data[0], data->data[1], data->data[2], + data->data[3]); + mutex_unlock(&data->update_lock); + return size; +} + +static ssize_t show_cpld_sysfs_value(struct device *dev, struct device_attribute *da, char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct cpld_data *data = i2c_get_clientdata(client); + s32 status; + int size; + status = -1; + size = 0; + mutex_lock(&data->update_lock); + status = cpld_i2c_smbus_read_byte_data(client, attr->index); + if (status < 0) { + mutex_unlock(&data->update_lock); + return 0; + } + data->data[0] = status; + DBG_DEBUG("cpld reg pos:0x%x value:0x%02x\n", attr->index, data->data[0]); + size = snprintf(buf, CPLD_SIZE, "%02x\n", data->data[0]); + mutex_unlock(&data->update_lock); + return size; } -/* common */ -static SENSOR_DEVICE_ATTR(cpld_version, S_IRUGO | S_IWUSR, show_cpld_version, NULL, 0); - -/*0x37 hwmon*/ -static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO | S_IWUSR ,show_fan_rpm_value, NULL, 0x1B); -static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO | S_IWUSR ,show_fan_rpm_value, NULL, 0x1D); -static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO | S_IWUSR ,show_fan_rpm_value, NULL, 0x1F); -static SENSOR_DEVICE_ATTR(fan4_input, S_IRUGO | S_IWUSR ,show_fan_rpm_value, NULL, 0x21); - -/* 0x32 */ -static SENSOR_DEVICE_ATTR(fan_speed_set, S_IRUGO | S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0x15); -static SENSOR_DEVICE_ATTR(fan0_led, S_IRUGO | S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0x23); -static SENSOR_DEVICE_ATTR(fan1_led, S_IRUGO | S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0x24); -static SENSOR_DEVICE_ATTR(fan2_led, S_IRUGO | S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0x25); -static SENSOR_DEVICE_ATTR(fan3_led, S_IRUGO | S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0x26); - -/* 0x37 */ -static SENSOR_DEVICE_ATTR(fan_present, S_IRUGO | S_IWUSR, show_cpld_sysfs_value, NULL, 0x30); -static SENSOR_DEVICE_ATTR(fan_status, S_IRUGO | S_IWUSR, show_cpld_sysfs_value, NULL, 0x31); -static SENSOR_DEVICE_ATTR(psu_status, S_IRUGO | S_IWUSR, show_cpld_sysfs_value, NULL, 0x51); -static SENSOR_DEVICE_ATTR(broad_back_lct, S_IRUGO | S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0x2a); -static SENSOR_DEVICE_ATTR(broad_back_sys, S_IRUGO | S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0xb2); - -/* 0x33 */ +/* sys */ +static SENSOR_DEVICE_ATTR(cpld_version, S_IRUGO, show_cpld_version, NULL, 0); static SENSOR_DEVICE_ATTR(mac_led, S_IRUGO | S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0xa0); -static SENSOR_DEVICE_ATTR(broad_front_lct, S_IRUGO | S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0x2a); -static SENSOR_DEVICE_ATTR(broad_front_bmc, S_IRUGO| S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0xb1); -static SENSOR_DEVICE_ATTR(broad_front_cpu, S_IRUGO| S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0xb2); -static SENSOR_DEVICE_ATTR(broad_front_pwr, S_IRUGO| S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0xb3); -static SENSOR_DEVICE_ATTR(broad_front_fan, S_IRUGO| S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0xb4); -static SENSOR_DEVICE_ATTR(sfp_led1_yellow, S_IRUGO| S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0xad); -static SENSOR_DEVICE_ATTR(mac_temp_flag, S_IRUGO, show_cpld_sysfs_value, NULL, 0xd4); - -/* 0x34 */ -static SENSOR_DEVICE_ATTR(sfp_presence1, S_IRUGO| S_IWUSR, show_cpld_sysfs_value, NULL, 0x30); -static SENSOR_DEVICE_ATTR(sfp_presence2, S_IRUGO| S_IWUSR, show_cpld_sysfs_value, NULL, 0x31); -static SENSOR_DEVICE_ATTR(sfp_presence3, S_IRUGO| S_IWUSR, show_cpld_sysfs_value, NULL, 0x32); - -static SENSOR_DEVICE_ATTR(sfp_enable, S_IRUGO| S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0xa1); +static SENSOR_DEVICE_ATTR(broad_back_lct, S_IRUGO | S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0x64); +static SENSOR_DEVICE_ATTR(broad_back_sys, S_IRUGO | S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0x72); +static SENSOR_DEVICE_ATTR(psu_status, S_IRUGO, show_cpld_sysfs_value, NULL, 0x51); +static SENSOR_DEVICE_ATTR(broad_front_bmc, S_IRUGO| S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0x71); +static SENSOR_DEVICE_ATTR(broad_front_pwr, S_IRUGO| S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0x73); +static SENSOR_DEVICE_ATTR(broad_front_fan, S_IRUGO| S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0x74); + + +/* fan */ +static SENSOR_DEVICE_ATTR(fan_present, S_IRUGO, show_cpld_sysfs_value, NULL, 0x30); +static SENSOR_DEVICE_ATTR(fan_status, S_IRUGO, show_cpld_sysfs_value, NULL, 0x31); + +static SENSOR_DEVICE_ATTR(fan1_speed_set, S_IRUGO | S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0x14); +static SENSOR_DEVICE_ATTR(fan1_1_real_speed, S_IRUGO, show_fan_rpm_value, NULL, 0x1B); +static SENSOR_DEVICE_ATTR(fan1_2_real_speed, S_IRUGO, show_fan_rpm_value, NULL, 0x25); +static SENSOR_DEVICE_ATTR(fan1_led, S_IRUGO | S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0x3b); + + +static SENSOR_DEVICE_ATTR(fan2_speed_set, S_IRUGO | S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0x15); +static SENSOR_DEVICE_ATTR(fan2_1_real_speed, S_IRUGO, show_fan_rpm_value, NULL, 0x1D); +static SENSOR_DEVICE_ATTR(fan2_2_real_speed, S_IRUGO, show_fan_rpm_value, NULL, 0x27); +static SENSOR_DEVICE_ATTR(fan2_led, S_IRUGO | S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0x3c); + + +static SENSOR_DEVICE_ATTR(fan3_speed_set, S_IRUGO | S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0x16); +static SENSOR_DEVICE_ATTR(fan3_1_real_speed, S_IRUGO, show_fan_rpm_value, NULL, 0x1F); +static SENSOR_DEVICE_ATTR(fan3_2_real_speed, S_IRUGO, show_fan_rpm_value, NULL, 0x29); +static SENSOR_DEVICE_ATTR(fan3_led, S_IRUGO | S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0x3d); + + +static SENSOR_DEVICE_ATTR(fan4_speed_set, S_IRUGO | S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0x17); +static SENSOR_DEVICE_ATTR(fan4_1_real_speed, S_IRUGO, show_fan_rpm_value, NULL, 0x21); +static SENSOR_DEVICE_ATTR(fan4_2_real_speed, S_IRUGO, show_fan_rpm_value, NULL, 0x2b); +static SENSOR_DEVICE_ATTR(fan4_led, S_IRUGO | S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0x3e); + +/* sfp */ +static SENSOR_DEVICE_ATTR(sfp_enable, S_IRUGO| S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, +0x94); +static SENSOR_DEVICE_ATTR(sfp_presence1, S_IRUGO, show_cpld_sysfs_value, NULL, 0x30); +static SENSOR_DEVICE_ATTR(sfp_presence2, S_IRUGO, show_cpld_sysfs_value, NULL, 0x31); +static SENSOR_DEVICE_ATTR(sfp_presence3, S_IRUGO, show_cpld_sysfs_value, NULL, 0x32); +static SENSOR_DEVICE_ATTR(sfp_presence4, S_IRUGO, show_cpld_sysfs_value, NULL, 0x30); +static SENSOR_DEVICE_ATTR(sfp_presence5, S_IRUGO, show_cpld_sysfs_value, NULL, 0x31); +static SENSOR_DEVICE_ATTR(sfp_presence6, S_IRUGO, show_cpld_sysfs_value, NULL, 0x32); +static SENSOR_DEVICE_ATTR(sfp_presence7, S_IRUGO, show_cpld_sysfs_value, NULL, 0x33); static SENSOR_DEVICE_ATTR(sfp_led1, S_IRUGO | S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0xa2); static SENSOR_DEVICE_ATTR(sfp_led2, S_IRUGO | S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0xa3); static SENSOR_DEVICE_ATTR(sfp_led3, S_IRUGO | S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0xa4); -static SENSOR_DEVICE_ATTR(sfp_led_flash1, S_IRUGO | S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0xa5); -static SENSOR_DEVICE_ATTR(sfp_led_flash2, S_IRUGO | S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0xa6); -static SENSOR_DEVICE_ATTR(sfp_led_flash3, S_IRUGO | S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0xa7); -static SENSOR_DEVICE_ATTR(sfp_txdis1, S_IRUGO| S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0x60); -static SENSOR_DEVICE_ATTR(sfp_txdis2, S_IRUGO| S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0x61); -static SENSOR_DEVICE_ATTR(sfp_txdis3, S_IRUGO| S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0x62); - -static SENSOR_DEVICE_ATTR(port_speed1, S_IRUGO| S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0xc0); -static SENSOR_DEVICE_ATTR(port_speed2, S_IRUGO| S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0xc1); -static SENSOR_DEVICE_ATTR(port_speed3, S_IRUGO| S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0xc2); -static SENSOR_DEVICE_ATTR(port_speed4, S_IRUGO| S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0xc3); -static SENSOR_DEVICE_ATTR(port_speed5, S_IRUGO| S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0xc4); -static SENSOR_DEVICE_ATTR(port_speed6, S_IRUGO| S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0xc5); - -/* 0x35 */ -static SENSOR_DEVICE_ATTR(sfp_enable2, S_IRUGO | S_IWUSR ,show_cpld_sysfs_value, set_cpld_sysfs_value, 0xa0); -static SENSOR_DEVICE_ATTR(sfp_led2_yellow, S_IRUGO| S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0xad); -static SENSOR_DEVICE_ATTR(mac_temp_input, S_IRUGO, show_mac_temp_value, NULL, 0xca); - -/* 0x36 */ -static SENSOR_DEVICE_ATTR(sfp_presence4, S_IRUGO | S_IWUSR ,show_cpld_sysfs_value, NULL, 0x30); -static SENSOR_DEVICE_ATTR(sfp_presence5, S_IRUGO | S_IWUSR ,show_cpld_sysfs_value, NULL, 0x31); -static SENSOR_DEVICE_ATTR(sfp_presence6, S_IRUGO | S_IWUSR ,show_cpld_sysfs_value, NULL, 0x32); -static SENSOR_DEVICE_ATTR(sfp_presence7, S_IRUGO | S_IWUSR ,show_cpld_sysfs_value, NULL, 0x33); static SENSOR_DEVICE_ATTR(sfp_led4, S_IRUGO | S_IWUSR ,show_cpld_sysfs_value, set_cpld_sysfs_value, 0xa2); static SENSOR_DEVICE_ATTR(sfp_led5, S_IRUGO | S_IWUSR ,show_cpld_sysfs_value, set_cpld_sysfs_value, 0xa3); static SENSOR_DEVICE_ATTR(sfp_led6, S_IRUGO | S_IWUSR ,show_cpld_sysfs_value, set_cpld_sysfs_value, 0xa4); static SENSOR_DEVICE_ATTR(sfp_led7, S_IRUGO | S_IWUSR ,show_cpld_sysfs_value, set_cpld_sysfs_value, 0xa5); -static SENSOR_DEVICE_ATTR(sfp_led_flash4, S_IRUGO | S_IWUSR ,show_cpld_sysfs_value, set_cpld_sysfs_value, 0xa6); -static SENSOR_DEVICE_ATTR(sfp_led_flash5, S_IRUGO | S_IWUSR ,show_cpld_sysfs_value, set_cpld_sysfs_value, 0xa7); -static SENSOR_DEVICE_ATTR(sfp_led_flash6, S_IRUGO | S_IWUSR ,show_cpld_sysfs_value, set_cpld_sysfs_value, 0xa8); -static SENSOR_DEVICE_ATTR(sfp_led_flash7, S_IRUGO | S_IWUSR ,show_cpld_sysfs_value, set_cpld_sysfs_value, 0xa9); - +static SENSOR_DEVICE_ATTR(sfp_txdis1, S_IRUGO| S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0x60); +static SENSOR_DEVICE_ATTR(sfp_txdis2, S_IRUGO| S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0x61); +static SENSOR_DEVICE_ATTR(sfp_txdis3, S_IRUGO| S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0x62); static SENSOR_DEVICE_ATTR(sfp_txdis4, S_IRUGO | S_IWUSR ,show_cpld_sysfs_value, set_cpld_sysfs_value, 0x60); static SENSOR_DEVICE_ATTR(sfp_txdis5, S_IRUGO | S_IWUSR ,show_cpld_sysfs_value, set_cpld_sysfs_value, 0x61); static SENSOR_DEVICE_ATTR(sfp_txdis6, S_IRUGO | S_IWUSR ,show_cpld_sysfs_value, set_cpld_sysfs_value, 0x62); - -static SENSOR_DEVICE_ATTR(port_speed7, S_IRUGO| S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0xc0); -static SENSOR_DEVICE_ATTR(port_speed8, S_IRUGO| S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0xc1); -static SENSOR_DEVICE_ATTR(port_speed9, S_IRUGO| S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0xc2); -static SENSOR_DEVICE_ATTR(port_speed10, S_IRUGO| S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0xc3); -static SENSOR_DEVICE_ATTR(port_speed11, S_IRUGO| S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0xc4); -static SENSOR_DEVICE_ATTR(port_speed12, S_IRUGO| S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0xc5); -static SENSOR_DEVICE_ATTR(port_speed13, S_IRUGO| S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0xc6); -static SENSOR_DEVICE_ATTR(port_speed14, S_IRUGO| S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0xc7); - -static struct attribute *cpld32_sysfs_attrs[] = { - &sensor_dev_attr_fan_speed_set.dev_attr.attr, - &sensor_dev_attr_fan0_led.dev_attr.attr, - &sensor_dev_attr_fan1_led.dev_attr.attr, - &sensor_dev_attr_fan2_led.dev_attr.attr, - &sensor_dev_attr_fan3_led.dev_attr.attr, - NULL -}; - -static struct attribute *cpld37_sysfs_attrs[] = { - &sensor_dev_attr_fan_present.dev_attr.attr, - &sensor_dev_attr_fan_status.dev_attr.attr, - &sensor_dev_attr_psu_status.dev_attr.attr, - &sensor_dev_attr_broad_back_lct.dev_attr.attr, - &sensor_dev_attr_broad_back_sys.dev_attr.attr, - &sensor_dev_attr_cpld_version.dev_attr.attr, - NULL -}; - -static struct attribute *cpld33_sysfs_attrs[] = { - &sensor_dev_attr_mac_led.dev_attr.attr, - &sensor_dev_attr_broad_front_lct.dev_attr.attr, - &sensor_dev_attr_broad_front_bmc.dev_attr.attr, - &sensor_dev_attr_broad_front_cpu.dev_attr.attr, - &sensor_dev_attr_broad_front_pwr.dev_attr.attr, - &sensor_dev_attr_broad_front_fan.dev_attr.attr, - &sensor_dev_attr_sfp_led1_yellow.dev_attr.attr, - &sensor_dev_attr_mac_temp_flag.dev_attr.attr, - &sensor_dev_attr_cpld_version.dev_attr.attr, - NULL -}; - -static struct attribute *cpld34_sysfs_attrs[] = { - &sensor_dev_attr_sfp_presence1.dev_attr.attr, - &sensor_dev_attr_sfp_presence2.dev_attr.attr, - &sensor_dev_attr_sfp_presence3.dev_attr.attr, - &sensor_dev_attr_sfp_enable.dev_attr.attr, - &sensor_dev_attr_sfp_led1.dev_attr.attr, - &sensor_dev_attr_sfp_led2.dev_attr.attr, - &sensor_dev_attr_sfp_led3.dev_attr.attr, - &sensor_dev_attr_sfp_led_flash1.dev_attr.attr, - &sensor_dev_attr_sfp_led_flash2.dev_attr.attr, - &sensor_dev_attr_sfp_led_flash3.dev_attr.attr, - &sensor_dev_attr_sfp_txdis1.dev_attr.attr, - &sensor_dev_attr_sfp_txdis2.dev_attr.attr, - &sensor_dev_attr_sfp_txdis3.dev_attr.attr, - &sensor_dev_attr_port_speed1.dev_attr.attr, - &sensor_dev_attr_port_speed2.dev_attr.attr, - &sensor_dev_attr_port_speed3.dev_attr.attr, - &sensor_dev_attr_port_speed4.dev_attr.attr, - &sensor_dev_attr_port_speed5.dev_attr.attr, - &sensor_dev_attr_port_speed6.dev_attr.attr, - NULL -}; - -static struct attribute *cpld36_sysfs_attrs[] = { - &sensor_dev_attr_sfp_presence4.dev_attr.attr, - &sensor_dev_attr_sfp_presence5.dev_attr.attr, - &sensor_dev_attr_sfp_presence6.dev_attr.attr, - &sensor_dev_attr_sfp_presence7.dev_attr.attr, - &sensor_dev_attr_sfp_led4.dev_attr.attr, - &sensor_dev_attr_sfp_led5.dev_attr.attr, - &sensor_dev_attr_sfp_led6.dev_attr.attr, - &sensor_dev_attr_sfp_led7.dev_attr.attr, - &sensor_dev_attr_sfp_led_flash4.dev_attr.attr, - &sensor_dev_attr_sfp_led_flash5.dev_attr.attr, - &sensor_dev_attr_sfp_led_flash6.dev_attr.attr, - &sensor_dev_attr_sfp_led_flash7.dev_attr.attr, - &sensor_dev_attr_sfp_txdis4.dev_attr.attr, - &sensor_dev_attr_sfp_txdis5.dev_attr.attr, - &sensor_dev_attr_sfp_txdis6.dev_attr.attr, - &sensor_dev_attr_port_speed7.dev_attr.attr, - &sensor_dev_attr_port_speed8.dev_attr.attr, - &sensor_dev_attr_port_speed9.dev_attr.attr, - &sensor_dev_attr_port_speed10.dev_attr.attr, - &sensor_dev_attr_port_speed11.dev_attr.attr, - &sensor_dev_attr_port_speed12.dev_attr.attr, - &sensor_dev_attr_port_speed13.dev_attr.attr, - &sensor_dev_attr_port_speed14.dev_attr.attr, - NULL -}; - -static struct attribute *cpld35_sysfs_attrs[] = { - &sensor_dev_attr_sfp_enable2.dev_attr.attr, - &sensor_dev_attr_broad_front_lct.dev_attr.attr, - &sensor_dev_attr_broad_front_bmc.dev_attr.attr, - &sensor_dev_attr_broad_front_cpu.dev_attr.attr, - &sensor_dev_attr_broad_front_pwr.dev_attr.attr, - &sensor_dev_attr_broad_front_fan.dev_attr.attr, - &sensor_dev_attr_sfp_led2_yellow.dev_attr.attr, - &sensor_dev_attr_mac_temp_input.dev_attr.attr, - &sensor_dev_attr_cpld_version.dev_attr.attr, - NULL +static SENSOR_DEVICE_ATTR(sfp_reset1, S_IRUGO | S_IWUSR ,show_cpld_sysfs_value, set_cpld_sysfs_value, 0xb9); +static SENSOR_DEVICE_ATTR(sfp_led_ctrl1, S_IRUGO | S_IWUSR ,show_cpld_sysfs_value, set_cpld_sysfs_value, 0x90); +static SENSOR_DEVICE_ATTR(sfp_led_ctrl2, S_IRUGO | S_IWUSR ,show_cpld_sysfs_value, set_cpld_sysfs_value, 0x91); +static SENSOR_DEVICE_ATTR(sfp_led_ctrl3, S_IRUGO | S_IWUSR ,show_cpld_sysfs_value, set_cpld_sysfs_value, 0x92); +static SENSOR_DEVICE_ATTR(sfp_led_ctrl4, S_IRUGO | S_IWUSR ,show_cpld_sysfs_value, set_cpld_sysfs_value, 0x93); +static SENSOR_DEVICE_ATTR(sfp_led_ctrl5, S_IRUGO | S_IWUSR ,show_cpld_sysfs_value, set_cpld_sysfs_value, 0x94); +static SENSOR_DEVICE_ATTR(sfp_led_ctrl6, S_IRUGO | S_IWUSR ,show_cpld_sysfs_value, set_cpld_sysfs_value, 0x95); +static SENSOR_DEVICE_ATTR(sfp_led_ctrl7, S_IRUGO | S_IWUSR ,show_cpld_sysfs_value, set_cpld_sysfs_value, 0x96); +static SENSOR_DEVICE_ATTR(sfp_led_ctrl8, S_IRUGO | S_IWUSR ,show_cpld_sysfs_value, set_cpld_sysfs_value, 0x97); +static SENSOR_DEVICE_ATTR(sfp_led_ctrl9, S_IRUGO | S_IWUSR ,show_cpld_sysfs_value, set_cpld_sysfs_value, 0x98); +static SENSOR_DEVICE_ATTR(sfp_led_ctrl10, S_IRUGO | S_IWUSR ,show_cpld_sysfs_value, set_cpld_sysfs_value, 0x99); +static SENSOR_DEVICE_ATTR(sfp_led_ctrl11, S_IRUGO | S_IWUSR ,show_cpld_sysfs_value, set_cpld_sysfs_value, 0x9a); +static SENSOR_DEVICE_ATTR(sfp_led_ctrl12, S_IRUGO | S_IWUSR ,show_cpld_sysfs_value, set_cpld_sysfs_value, 0x9b); +static SENSOR_DEVICE_ATTR(sfp_led_ctrl13, S_IRUGO | S_IWUSR ,show_cpld_sysfs_value, set_cpld_sysfs_value, 0x9c); +static SENSOR_DEVICE_ATTR(sfp_led_ctrl14, S_IRUGO | S_IWUSR ,show_cpld_sysfs_value, set_cpld_sysfs_value, 0x9d); +static SENSOR_DEVICE_ATTR(sfp_led_ctrl15, S_IRUGO | S_IWUSR ,show_cpld_sysfs_value, set_cpld_sysfs_value, 0x9e); +static SENSOR_DEVICE_ATTR(sfp_led_ctrl16, S_IRUGO | S_IWUSR ,show_cpld_sysfs_value, set_cpld_sysfs_value, 0x9f); + + +static struct attribute *cpld_bus1_addr_0x0d_sysfs_attrs[] = { + &sensor_dev_attr_cpld_version.dev_attr.attr, + &sensor_dev_attr_fan_present.dev_attr.attr, + &sensor_dev_attr_fan_status.dev_attr.attr, + + &sensor_dev_attr_fan1_speed_set.dev_attr.attr, + &sensor_dev_attr_fan1_1_real_speed.dev_attr.attr, + &sensor_dev_attr_fan1_2_real_speed.dev_attr.attr, + &sensor_dev_attr_fan1_led.dev_attr.attr, + + &sensor_dev_attr_fan2_speed_set.dev_attr.attr, + &sensor_dev_attr_fan2_1_real_speed.dev_attr.attr, + &sensor_dev_attr_fan2_2_real_speed.dev_attr.attr, + &sensor_dev_attr_fan2_led.dev_attr.attr, + + &sensor_dev_attr_fan3_speed_set.dev_attr.attr, + &sensor_dev_attr_fan3_1_real_speed.dev_attr.attr, + &sensor_dev_attr_fan3_2_real_speed.dev_attr.attr, + &sensor_dev_attr_fan3_led.dev_attr.attr, + + &sensor_dev_attr_fan4_speed_set.dev_attr.attr, + &sensor_dev_attr_fan4_1_real_speed.dev_attr.attr, + &sensor_dev_attr_fan4_2_real_speed.dev_attr.attr, + &sensor_dev_attr_fan4_led.dev_attr.attr, + NULL }; -static const struct attribute_group cpld32_sysfs_group = { - .attrs = cpld32_sysfs_attrs, +static struct attribute *cpld_bus5_addr_0x0d_sysfs_attrs[] = { + &sensor_dev_attr_cpld_version.dev_attr.attr, + &sensor_dev_attr_broad_back_lct.dev_attr.attr, + &sensor_dev_attr_broad_back_sys.dev_attr.attr, + &sensor_dev_attr_psu_status.dev_attr.attr, + &sensor_dev_attr_broad_front_bmc.dev_attr.attr, + &sensor_dev_attr_broad_front_pwr.dev_attr.attr, + &sensor_dev_attr_broad_front_fan.dev_attr.attr, + &sensor_dev_attr_sfp_enable.dev_attr.attr, + NULL }; -static const struct attribute_group cpld37_sysfs_group = { - .attrs = cpld37_sysfs_attrs, +static struct attribute *cpld_bus7_addr_0x30_sysfs_attrs[] = { + &sensor_dev_attr_mac_led.dev_attr.attr, + &sensor_dev_attr_sfp_presence1.dev_attr.attr, + &sensor_dev_attr_sfp_presence2.dev_attr.attr, + &sensor_dev_attr_sfp_presence3.dev_attr.attr, + &sensor_dev_attr_sfp_led1.dev_attr.attr, + &sensor_dev_attr_sfp_led2.dev_attr.attr, + &sensor_dev_attr_sfp_led3.dev_attr.attr, + &sensor_dev_attr_sfp_txdis1.dev_attr.attr, + &sensor_dev_attr_sfp_txdis2.dev_attr.attr, + &sensor_dev_attr_sfp_txdis3.dev_attr.attr, + &sensor_dev_attr_sfp_led_ctrl1.dev_attr.attr, + &sensor_dev_attr_sfp_led_ctrl2.dev_attr.attr, + &sensor_dev_attr_sfp_led_ctrl3.dev_attr.attr, + &sensor_dev_attr_sfp_led_ctrl4.dev_attr.attr, + &sensor_dev_attr_sfp_led_ctrl5.dev_attr.attr, + &sensor_dev_attr_sfp_led_ctrl6.dev_attr.attr, + &sensor_dev_attr_sfp_led_ctrl7.dev_attr.attr, + &sensor_dev_attr_sfp_led_ctrl8.dev_attr.attr, + &sensor_dev_attr_sfp_led_ctrl9.dev_attr.attr, + &sensor_dev_attr_sfp_led_ctrl10.dev_attr.attr, + &sensor_dev_attr_sfp_led_ctrl11.dev_attr.attr, + &sensor_dev_attr_sfp_led_ctrl12.dev_attr.attr, + NULL }; -static const struct attribute_group cpld33_sysfs_group = { - .attrs = cpld33_sysfs_attrs, +static struct attribute *cpld_bus7_addr_0x31_sysfs_attrs[] = { + &sensor_dev_attr_mac_led.dev_attr.attr, + &sensor_dev_attr_sfp_presence4.dev_attr.attr, + &sensor_dev_attr_sfp_presence5.dev_attr.attr, + &sensor_dev_attr_sfp_presence6.dev_attr.attr, + &sensor_dev_attr_sfp_presence7.dev_attr.attr, + &sensor_dev_attr_sfp_led4.dev_attr.attr, + &sensor_dev_attr_sfp_led5.dev_attr.attr, + &sensor_dev_attr_sfp_led6.dev_attr.attr, + &sensor_dev_attr_sfp_led7.dev_attr.attr, + &sensor_dev_attr_sfp_txdis4.dev_attr.attr, + &sensor_dev_attr_sfp_txdis5.dev_attr.attr, + &sensor_dev_attr_sfp_txdis6.dev_attr.attr, + &sensor_dev_attr_sfp_reset1.dev_attr.attr, + &sensor_dev_attr_sfp_led_ctrl1.dev_attr.attr, + &sensor_dev_attr_sfp_led_ctrl2.dev_attr.attr, + &sensor_dev_attr_sfp_led_ctrl3.dev_attr.attr, + &sensor_dev_attr_sfp_led_ctrl4.dev_attr.attr, + &sensor_dev_attr_sfp_led_ctrl5.dev_attr.attr, + &sensor_dev_attr_sfp_led_ctrl6.dev_attr.attr, + &sensor_dev_attr_sfp_led_ctrl7.dev_attr.attr, + &sensor_dev_attr_sfp_led_ctrl8.dev_attr.attr, + &sensor_dev_attr_sfp_led_ctrl9.dev_attr.attr, + &sensor_dev_attr_sfp_led_ctrl10.dev_attr.attr, + &sensor_dev_attr_sfp_led_ctrl11.dev_attr.attr, + &sensor_dev_attr_sfp_led_ctrl12.dev_attr.attr, + &sensor_dev_attr_sfp_led_ctrl13.dev_attr.attr, + &sensor_dev_attr_sfp_led_ctrl14.dev_attr.attr, + &sensor_dev_attr_sfp_led_ctrl15.dev_attr.attr, + &sensor_dev_attr_sfp_led_ctrl16.dev_attr.attr, + NULL }; -static const struct attribute_group cpld34_sysfs_group = { - .attrs = cpld34_sysfs_attrs, +static const struct attribute_group cpld_bus1_addr_0x0d_sysfs_group = { + .attrs = cpld_bus1_addr_0x0d_sysfs_attrs, }; -static const struct attribute_group cpld36_sysfs_group = { - .attrs = cpld36_sysfs_attrs, +static const struct attribute_group cpld_bus5_addr_0x0d_sysfs_group = { + .attrs = cpld_bus5_addr_0x0d_sysfs_attrs, }; -static const struct attribute_group cpld35_sysfs_group = { - .attrs = cpld35_sysfs_attrs, +static const struct attribute_group cpld_bus7_addr_0x30_sysfs_group = { + .attrs = cpld_bus7_addr_0x30_sysfs_attrs, }; -static struct attribute *cpld_hwmon_attrs[] = { - &sensor_dev_attr_fan1_input.dev_attr.attr, - &sensor_dev_attr_fan2_input.dev_attr.attr, - &sensor_dev_attr_fan3_input.dev_attr.attr, - &sensor_dev_attr_fan4_input.dev_attr.attr, - NULL +static const struct attribute_group cpld_bus7_addr_0x31_sysfs_group = { + .attrs = cpld_bus7_addr_0x31_sysfs_attrs, }; -ATTRIBUTE_GROUPS(cpld_hwmon); struct cpld_attr_match_group { - int bus_nr; /* I2C BUS */ - unsigned short addr; /* slave addr*/ - const struct attribute_group *attr_group_ptr; - const struct attribute_group *attr_hwmon_ptr; + int bus_nr; + unsigned short addr; + const struct attribute_group *attr_group_ptr; + const struct attribute_group *attr_hwmon_ptr; }; + static struct cpld_attr_match_group g_cpld_attr_match[] = { - {0, 0x32, &cpld32_sysfs_group, NULL}, - {2, 0x37, &cpld37_sysfs_group, (struct attribute_group *)cpld_hwmon_groups}, - {2, 0x33, &cpld33_sysfs_group, NULL}, - {1, 0x34, &cpld34_sysfs_group, NULL}, - {1, 0x36, &cpld36_sysfs_group, NULL}, - {2, 0x35, &cpld35_sysfs_group, NULL}, + {1, 0x0d, &cpld_bus1_addr_0x0d_sysfs_group, NULL}, + {5, 0x0d, &cpld_bus5_addr_0x0d_sysfs_group, NULL}, + {7, 0x30, &cpld_bus7_addr_0x30_sysfs_group, NULL}, + {7, 0x31, &cpld_bus7_addr_0x31_sysfs_group, NULL}, }; static const struct attribute_group *cpld_get_attr_group(struct i2c_client *client, int is_hwmon) { - int i; - struct cpld_attr_match_group *group; - - for (i = 0; i < ARRAY_SIZE(g_cpld_attr_match); i++) { - group = &g_cpld_attr_match[i]; - DBG_DEBUG("is_hwmon %d i %d client(nr:%d,addr:0x%x), group(nr:%d,addr:0x0%x).\n", is_hwmon, - i, client->adapter->nr, client->addr, group->bus_nr, group->addr); - if ((client->addr == group->addr) && (client->adapter->nr == group->bus_nr)) { - DBG_DEBUG("is_hwmon %d i %d nr %d addr %d .\n", is_hwmon, i, client->adapter->nr, client->addr); - return (is_hwmon) ? (group->attr_hwmon_ptr) : (group->attr_group_ptr); - } - } - - DBG_DEBUG("is_hwmon %d nr %d addr %d dismatch, return NULL.\n", is_hwmon, client->adapter->nr, client->addr); - return NULL; + int i; + struct cpld_attr_match_group *group; + + for (i = 0; i < ARRAY_SIZE(g_cpld_attr_match); i++) { + group = &g_cpld_attr_match[i]; + DBG_DEBUG("is_hwmon %d i %d client(nr:%d,addr:0x%x), group(nr:%d,addr:0x0%x) .\n", is_hwmon, + i, client->adapter->nr, client->addr, group->bus_nr, group->addr); + if ((client->addr == group->addr) && (client->adapter->nr == group->bus_nr)) { + DBG_DEBUG("is_hwmon %d i %d nr %d addr %d .\n", is_hwmon, i, client->adapter->nr, client->addr); + return (is_hwmon) ? (group->attr_hwmon_ptr) : (group->attr_group_ptr); + } + } + + DBG_DEBUG("is_hwmon %d nr %d addr %d dismatch, return NULL.\n", is_hwmon, client->adapter->nr, client->addr); + return NULL; } +#if 0 +static int cpld_detect(struct i2c_client *new_client, struct i2c_board_info *info) +{ + struct i2c_adapter *adapter = new_client->adapter; + int conf; + DBG_DEBUG("=========cpld_detect(0x%x)===========\n", new_client->addr); + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | + I2C_FUNC_SMBUS_WORD_DATA)) + return -ENODEV; + conf = i2c_smbus_read_byte_data(new_client, 0); + if (!conf) + return -ENODEV; + strlcpy(info->type, "rg_cpld", I2C_NAME_SIZE); + return 0; +} +#endif + static int cpld_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct cpld_data *data; @@ -531,7 +490,9 @@ static int cpld_probe(struct i2c_client *client, const struct i2c_device_id *id) if (hwmon_group) { data->hwmon_dev = hwmon_device_register_with_groups(&client->dev, client->name, data, (const struct attribute_group **)hwmon_group); if (IS_ERR(data->hwmon_dev)) { - sysfs_remove_group(&client->dev.kobj, (const struct attribute_group *)sysfs_group); + if (sysfs_group) { + sysfs_remove_group(&client->dev.kobj, (const struct attribute_group *)sysfs_group); + } DBG_ERROR("hwmon_device_register_with_groups failed ret %ld.\n", PTR_ERR(data->hwmon_dev)); return PTR_ERR(data->hwmon_dev); } @@ -577,26 +538,25 @@ static int cpld_remove(struct i2c_client *client) return 0; } - static const struct i2c_device_id cpld_id[] = { - { "rg_cpld", 0 }, - {} + { "rg_cpld", 0 }, + {} }; - MODULE_DEVICE_TABLE(i2c, cpld_id); static struct i2c_driver rg_cpld_driver = { - .class = I2C_CLASS_HWMON, - .driver = { - .name = "rg_cpld", - }, - .probe = cpld_probe, - .remove = cpld_remove, - .id_table = cpld_id, + .class = I2C_CLASS_HWMON, + .driver = { + .name = "rg_cpld", + }, + .probe = cpld_probe, + .remove = cpld_remove, + .id_table = cpld_id, + //.detect = cpld_detect, + // .address_list = rg_i2c_cpld, }; module_i2c_driver(rg_cpld_driver); - MODULE_AUTHOR("support "); MODULE_DESCRIPTION("ragile CPLD driver"); MODULE_LICENSE("GPL"); diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/modules/driver/rg_lpc_cpld.c b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/modules/driver/rg_lpc_cpld.c new file mode 100755 index 000000000000..e155f9e58575 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/modules/driver/rg_lpc_cpld.c @@ -0,0 +1,235 @@ +#include /* Wd're doing kernel work */ +#include /* specifically, a module */ +#include +#include /* Need for the macros */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "ragile.h" + +int lpc_cpld_verbose = 0; +int lpc_cpld_error = 0; +module_param(lpc_cpld_verbose, int, S_IRUGO | S_IWUSR); +module_param(lpc_cpld_error, int, S_IRUGO | S_IWUSR); + + +#define LPC_CPLD_VERBOSE(fmt, args...) do { \ + if (lpc_cpld_verbose) { \ + printk(KERN_ERR "[LPC_CPLD_I2C_DEVICE][VERBOSE][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define LPC_CPLD_ERROR(fmt, args...) do { \ + if (lpc_cpld_error) { \ + printk(KERN_ERR "[LPC_CPLD_I2C_DEVICE][ERROR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ + } while (0) + +#define PCI_VENDOR_ID_D1527_LPC (0x8c54) +#define PCI_VENDOR_ID_C3000_LPC (0x19dc) + +#define MAX_CPLD_REG_SIZE (0x100) +#define LPC_GET_CPLD_ID(addr) ((addr >> 16) & 0xff) +#define LPC_GET_CPLD_OFFSET(addr) ((addr) & 0xff) +typedef struct rg_lpc_device_s { + u16 base; + u16 size; + u8 type; + u8 id; +} rg_lpc_device_t; + +typedef enum rg_lpc_dev_type_s { + LPC_DEVICE_CPLD = 1, + LPC_DEVICE_FPGA = 2, +} rg_lpc_dev_type_t; + +static rg_lpc_device_t g_rg_lpc_dev[] = { + {.base = 0x700, .size = MAX_CPLD_REG_SIZE, .type = LPC_DEVICE_CPLD, .id = 0}, + {.base = 0x900, .size = MAX_CPLD_REG_SIZE, .type = LPC_DEVICE_CPLD, .id = 1}, + {.base = 0xb00, .size = MAX_CPLD_REG_SIZE, .type = LPC_DEVICE_CPLD, .id = 2}, + /*{.base = 0x900, .size = MAX_FPGA_REG_SIZE, .type = LPC_DEVICE_FPGA, .id = 0},*/ +}; + +static rg_lpc_device_t* lpc_get_device_info(int type, int id) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(g_rg_lpc_dev); i++) { + if ((g_rg_lpc_dev[i].type == type) && (g_rg_lpc_dev[i].id == id)) { + return &g_rg_lpc_dev[i]; + } + } + + return NULL; +} + +static int lpc_cpld_read(int address, u8 *val) +{ + int cpld_id; + rg_lpc_device_t *info; + + LPC_CPLD_ERROR("Enter\n"); + cpld_id = LPC_GET_CPLD_ID(address); + LPC_CPLD_ERROR("icpld_id=%d\n", cpld_id); + info = lpc_get_device_info(LPC_DEVICE_CPLD, cpld_id); + if (info == NULL) { + LPC_CPLD_ERROR("lpc_get_device_info addr 0x%x id %d failed.\r\n", address, cpld_id); + return -1; + } + + *val = inb(info->base + LPC_GET_CPLD_OFFSET(address)); + LPC_CPLD_VERBOSE("Leave info->base 0x%x, addr 0x%x, cpld_id %d, val 0x%x.\r\n", info->base, address, cpld_id, *val); + return 0; +} + +static int lpc_cpld_write(int address, u8 reg_val) +{ + int cpld_id; + rg_lpc_device_t *info; + + cpld_id = LPC_GET_CPLD_ID(address); + info = lpc_get_device_info(LPC_DEVICE_CPLD, cpld_id); + if (info == NULL) { + LPC_CPLD_ERROR("lpc_get_device_info addr 0x%x id %d failed.\r\n", address, cpld_id); + return -1; + } + + outb(reg_val, info->base + LPC_GET_CPLD_OFFSET(address)); + LPC_CPLD_VERBOSE("Leave info->base 0x%x, addr 0x%x, cpld_id %d, val 0x%x.\r\n", info->base, address, cpld_id, reg_val); + return 0; +} + +static ssize_t show_cpld_version(struct device *dev, struct device_attribute *da, char *buf) +{ + int ret, i; + u8 data[4] = {0}; + u32 index = to_sensor_dev_attr(da)->index; + + for (i = 0; i < 4; i++) { + ret = lpc_cpld_read(index + i, &data[i]); + if (ret != 0) { + LPC_CPLD_ERROR("get cpld version failed, ret: %d\n", ret); + return -EIO; + } + } + + return snprintf(buf, COMMON_STR_LEN, "%02x %02x %02x %02x \n", data[0], data[1], data[2], data[3]); + +} + +static ssize_t show_cpld_sysfs_value(struct device *dev, struct device_attribute *da, char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + u8 data; + int ret; + + ret = lpc_cpld_read(attr->index, &data); + if (ret != 0) { + LPC_CPLD_ERROR("get cpld[0x%x] value failed!\n", attr->index); + data = 0; + } + return snprintf(buf, COMMON_STR_LEN, "%02x\n", data); +} + +static ssize_t set_cpld_sysfs_value(struct device *dev, struct device_attribute *da, const char *buf, size_t +count) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + u8 data; + unsigned long val; + int err; + + err = kstrtoul(buf, 16, &val); + if (err) + return err; + if ((val < 0) || (val > 0xff)) { + LPC_CPLD_ERROR("please enter 0x00 ~ 0xff\n"); + return -1; + } + + data = (u8)val; + LPC_CPLD_VERBOSE("pos: 0x%02x count = %ld, data = 0x%02x\n", attr->index, count, data); + err = lpc_cpld_write(attr->index, data); + if (err != 0) { + LPC_CPLD_ERROR("set cpld[0x%x] value[0x%x] failed!\n", attr->index, data); + count = 0; + } + + return count; +} + +/* connect board cpld 0x900 id=1 */ +static SENSOR_DEVICE_ATTR(connect_cpld_version, S_IRUGO, show_cpld_version, NULL, 0x10000); +static SENSOR_DEVICE_ATTR(broad_front_sys, S_IRUGO | S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0x10072); +static SENSOR_DEVICE_ATTR(psu_status, S_IRUGO, show_cpld_sysfs_value, NULL, 0x10051); +static SENSOR_DEVICE_ATTR(broad_front_pwr, S_IRUGO| S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0x10073); +static SENSOR_DEVICE_ATTR(broad_front_fan, S_IRUGO| S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0x10074); +static SENSOR_DEVICE_ATTR(sfp_enable, S_IRUGO| S_IWUSR, show_cpld_sysfs_value, set_cpld_sysfs_value, 0x10094); + +static struct attribute *lpc_cpld_base_sysfs_attrs[] = { + &sensor_dev_attr_connect_cpld_version.dev_attr.attr, + &sensor_dev_attr_broad_front_sys.dev_attr.attr, + &sensor_dev_attr_psu_status.dev_attr.attr, + &sensor_dev_attr_broad_front_pwr.dev_attr.attr, + &sensor_dev_attr_broad_front_fan.dev_attr.attr, + &sensor_dev_attr_sfp_enable.dev_attr.attr, + NULL +}; + +static const struct attribute_group lpc_cpld_base_sysfs_group = { + .attrs = lpc_cpld_base_sysfs_attrs, +}; + +static int __init rg_lpc_cpld_init(void) +{ + struct pci_dev *pdev = NULL; + int status; + + pdev = pci_get_device(PCI_VENDOR_ID_INTEL, PCI_VENDOR_ID_D1527_LPC, pdev); + if (!pdev) { + LPC_CPLD_ERROR("pci_get_device(0x8086, 0x8c54) failed!\n"); + return -1; + } + + status = -1; + status = sysfs_create_group(&pdev->dev.kobj, &lpc_cpld_base_sysfs_group); + if (status) { + LPC_CPLD_ERROR("sysfs_create_group failed!\n"); + return -1; + } + + LPC_CPLD_VERBOSE("Leave success\n"); + return 0; +} + +static void __exit rg_lpc_cpld_exit(void) +{ + struct pci_dev *pdev = NULL; + + pdev = pci_get_device(PCI_VENDOR_ID_INTEL, PCI_VENDOR_ID_D1527_LPC, pdev); + if (!pdev) { + LPC_CPLD_ERROR("pci_get_device(0x8086, 0x8c54) failed!\n"); + return ; + } + + sysfs_remove_group(&pdev->dev.kobj, &lpc_cpld_base_sysfs_group); + + LPC_CPLD_VERBOSE("Leave.\n"); +} + +module_init(rg_lpc_cpld_init); +module_exit(rg_lpc_cpld_exit); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("support "); diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/setup.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/setup.py index f36055fb4e6d..13d250ba9baf 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/setup.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/setup.py @@ -14,7 +14,6 @@ 'sonic_platform', 'rgutil', 'eepromutil', - 'sonic_pcie', ], classifiers=[ 'Development Status :: 3 - Alpha', @@ -25,7 +24,7 @@ 'License :: OSI Approved :: Apache Software License', 'Natural Language :: English', 'Operating System :: POSIX :: Linux', - 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.9', 'Topic :: Utilities', ], keywords='sonic SONiC platform PLATFORM', diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/__init__.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/__init__.py index 593867d31c9d..d49ca9b48bbf 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/__init__.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/__init__.py @@ -1,4 +1,4 @@ # All the derived classes for PDDF -__all__ = ["platform", "chassis", "sfp", "psu", "thermal", "fan"] +__all__ = ["platform", "chassis", "sfp", "psu", "thermal", "fan", "fan_drawer"] from . import platform diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/api.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/api.py new file mode 100755 index 000000000000..134e3a9872e0 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/api.py @@ -0,0 +1,203 @@ +############################################################################# +# PDDF +# Module contains an implementation of SONiC pddfapi Base API and +# provides the pddfpai information +# +############################################################################# + + +try: + from sonic_platform_pddf_base.pddfapi import PddfApi +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class newapi(PddfApi): + """ + PDDF Platform-Specific pddfapi Class + """ + + def __init__(self): + PddfApi.__init__(self) + + + def show_attr_eeprom_device(self, dev, ops): + ret = [] + attr_name = ops['attr'] + attr_list = dev['i2c']['attr_list'] + KEY = "eeprom" + dsysfs_path = "" + + if KEY not in self.data_sysfs_obj: + self.data_sysfs_obj[KEY] = [] + + for attr in attr_list: + if attr_name == attr['attr_name'] or attr_name == 'all': + if 'drv_attr_name' in attr.keys(): + real_name = attr['drv_attr_name'] + else: + real_name = attr['attr_name'] + + dsysfs_path = self.show_device_sysfs(dev, ops) + \ + "/%d-00%02x" % (int(dev['i2c']['topo_info']['parent_bus'], 0), + int(dev['i2c']['topo_info']['dev_addr'], 0)) + \ + "/%s" % real_name + if dsysfs_path not in self.data_sysfs_obj[KEY]: + self.data_sysfs_obj[KEY].append(dsysfs_path) + ret.append(dsysfs_path) + return ret + + def show_attr_psu_i2c_device(self, dev, ops): + target = ops['target'] + attr_name = ops['attr'] + ret = [] + KEY = "psu" + dsysfs_path = "" + + if KEY not in self.data_sysfs_obj: + self.data_sysfs_obj[KEY] = [] + + if target == 'all' or target == dev['dev_info']['virt_parent']: + attr_list = dev['i2c']['attr_list'] if 'i2c' in dev else [] + for attr in attr_list: + if attr_name == attr['attr_name'] or attr_name == 'all': + if 'attr_devtype' in attr.keys() and attr['attr_devtype'] == "gpio": + # Check and enable the gpio from class + attr_path = self.get_gpio_attr_path(self.data[attr['attr_devname']], attr['attr_offset']) + if (os.path.exists(attr_path)): + if attr_path not in self.data_sysfs_obj[KEY]: + self.data_sysfs_obj[KEY].append(attr_path) + ret.append(attr_path) + else: + if 'drv_attr_name' in attr.keys(): + real_name = attr['drv_attr_name'] + real_dev = dev + elif 'attr_devattr' in attr.keys(): + real_name = attr['attr_devattr'] + real_devname = attr['attr_devname'] if 'attr_devname' in attr.keys() else '' + real_dev = self.data[real_devname] + else: + real_name = attr['attr_name'] + real_dev = dev + + dsysfs_path = self.show_device_sysfs(real_dev, ops) + \ + "/%d-00%02x" % (int(real_dev['i2c']['topo_info']['parent_bus'], 0), + int(real_dev['i2c']['topo_info']['dev_addr'], 0)) + \ + "/%s" % real_name + if dsysfs_path not in self.data_sysfs_obj[KEY]: + self.data_sysfs_obj[KEY].append(dsysfs_path) + ret.append(dsysfs_path) + return ret + + + def show_attr_fan_device(self, dev, ops): + ret = [] + attr_name = ops['attr'] + attr_list = dev['i2c']['attr_list'] if 'i2c' in dev else [] + KEY = "fan" + dsysfs_path = "" + + if KEY not in self.data_sysfs_obj: + self.data_sysfs_obj[KEY] = [] + + for attr in attr_list: + if attr_name == attr['attr_name'] or attr_name == 'all': + if 'attr_devtype' in attr.keys() and attr['attr_devtype'] == "gpio": + # Check and enable the gpio from class + attr_path = self.get_gpio_attr_path(self.data[attr['attr_devname']], attr['attr_offset']) + if (os.path.exists(attr_path)): + if attr_path not in self.data_sysfs_obj[KEY]: + self.data_sysfs_obj[KEY].append(attr_path) + ret.append(attr_path) + else: + if 'drv_attr_name' in attr.keys(): + real_name = attr['drv_attr_name'] + real_dev = dev + elif 'attr_devattr' in attr.keys(): + real_name = attr['attr_devattr'] + real_devname = attr['attr_devname'] if 'attr_devname' in attr.keys() else '' + real_dev = self.data[real_devname] + else: + real_name = attr['attr_name'] + real_dev = dev + + dsysfs_path = self.show_device_sysfs(real_dev, ops) + \ + "/%d-00%02x" % (int(real_dev['i2c']['topo_info']['parent_bus'], 0), + int(real_dev['i2c']['topo_info']['dev_addr'], 0)) + \ + "/%s" % real_name + if dsysfs_path not in self.data_sysfs_obj[KEY]: + self.data_sysfs_obj[KEY].append(dsysfs_path) + ret.append(dsysfs_path) + return ret + + # This is only valid for LM75 + def show_attr_temp_sensor_device(self, dev, ops): + ret = [] + if 'i2c' not in dev.keys(): + return ret + attr_name = ops['attr'] + attr_list = dev['i2c']['attr_list'] if 'i2c' in dev else [] + KEY = "temp-sensors" + dsysfs_path = "" + + if KEY not in self.data_sysfs_obj: + self.data_sysfs_obj[KEY] = [] + + for attr in attr_list: + if attr_name == attr['attr_name'] or attr_name == 'all': + path = self.show_device_sysfs(dev, ops)+"/%d-00%02x/" % (int(dev['i2c']['topo_info']['parent_bus'], 0), + int(dev['i2c']['topo_info']['dev_addr'], 0)) + if 'drv_attr_name' in attr.keys(): + real_name = attr['drv_attr_name'] + else: + real_name = attr['attr_name'] + + if (os.path.exists(path)): + full_path = glob.glob(path + 'hwmon/hwmon*/' + real_name)[0] + dsysfs_path = full_path + if dsysfs_path not in self.data_sysfs_obj[KEY]: + self.data_sysfs_obj[KEY].append(dsysfs_path) + ret.append(full_path) + return ret + + def show_attr_xcvr_i2c_device(self, dev, ops): + target = ops['target'] + attr_name = ops['attr'] + ret = [] + dsysfs_path = "" + KEY = "xcvr" + if KEY not in self.data_sysfs_obj: + self.data_sysfs_obj[KEY] = [] + + if target == 'all' or target == dev['dev_info']['virt_parent']: + attr_list = dev['i2c']['attr_list'] + for attr in attr_list: + if attr_name == attr['attr_name'] or attr_name == 'all': + if 'attr_devtype' in attr.keys() and attr['attr_devtype'] == "gpio": + # Check and enable the gpio from class + attr_path = self.get_gpio_attr_path(self.data[attr['attr_devname']], attr['attr_offset']) + if (os.path.exists(attr_path)): + if attr_path not in self.data_sysfs_obj[KEY]: + self.data_sysfs_obj[KEY].append(attr_path) + ret.append(attr_path) + else: + if 'drv_attr_name' in attr.keys(): + real_name = attr['drv_attr_name'] + real_dev = dev + elif 'attr_devattr' in attr.keys(): + real_name = attr['attr_devattr'] + real_devname = attr['attr_devname'] if 'attr_devname' in attr.keys() else '' + real_dev = self.data[real_devname] + else: + real_name = attr['attr_name'] + real_dev = dev + + dsysfs_path = self.show_device_sysfs(real_dev, ops) + \ + "/%d-00%02x" % (int(real_dev['i2c']['topo_info']['parent_bus'], 0), + int(real_dev['i2c']['topo_info']['dev_addr'], 0)) + \ + "/%s" % real_name + if dsysfs_path not in self.data_sysfs_obj[KEY]: + self.data_sysfs_obj[KEY].append(dsysfs_path) + ret.append(dsysfs_path) + return ret + 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..6205b3ad717c 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,38 +6,49 @@ try: import time - import subprocess from sonic_platform_pddf_base.pddf_chassis import PddfChassis - from rgutil.logutil import Logger + from .component import Component + from sonic_platform.sfp import * except ImportError as e: raise ImportError(str(e) + "- required module not found") -PORT_START = 0 -PORT_END = 55 -PORTS_IN_BLOCK = 56 - -logger = Logger("CHASSIS", syslog=True) - class Chassis(PddfChassis): """ PDDF Platform-specific Chassis class """ - SFP_STATUS_INSERTED = "1" - SFP_STATUS_REMOVED = "0" - port_dict = {} + STATUS_INSERTED = "1" + STATUS_REMOVED = "0" + sfp_present_dict = {} def __init__(self, pddf_data=None, pddf_plugin_data=None): PddfChassis.__init__(self, pddf_data, pddf_plugin_data) + for i in range(0,5): + self._component_list.append(Component(i)) + + try: + self._sfp_list = [] + sfp_config = get_sfp_config() + self.port_start_index = sfp_config.get("port_index_start", 0) + self.port_num = sfp_config.get("port_num", 0) + # fix problem with first index is 1, we add a fake sfp node + if self.port_start_index == 1: + self._sfp_list.append(Sfp(1)) + + # sfp id always start at 1 + for index in range(1, self.port_num + 1): + self._sfp_list.append(Sfp(index)) + + for i in range(self.port_start_index, self.port_start_index + self.port_num): + self.sfp_present_dict[i] = self.STATUS_REMOVED - 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" + except Exception as err: + print("SFP init error: %s" % str(err)) + + def get_revision(self): + val = ord(self._eeprom.revision_str()) + test = "{}".format(val) + return test def get_reboot_cause(self): """ @@ -49,47 +60,13 @@ def get_reboot_cause(self): is "REBOOT_CAUSE_HARDWARE_OTHER", the second string can be used to pass a description of the reboot cause. """ - try: - is_power_loss = False - # enable read - subprocess.getstatusoutput(self.disable_write) - subprocess.getstatusoutput(self.enable_read) - ret, log = subprocess.getstatusoutput(self.read_value) - if ret == 0 and "0x0a" in log: - is_power_loss = True - - # erase i2c and e2 - subprocess.getstatusoutput(self.enable_erase) - time.sleep(1) - subprocess.getstatusoutput(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) - # enable write and set data - subprocess.getstatusoutput(self.enable_write) - subprocess.getstatusoutput(self.disable_read) - subprocess.getstatusoutput(self.write_value) - if is_power_loss: - return(self.REBOOT_CAUSE_POWER_LOSS, None) - except Exception as e: - logger.error(str(e)) return (self.REBOOT_CAUSE_NON_HARDWARE, None) def get_change_event(self, timeout=0): - change_event_dict = {"fan": {}, "sfp": {}} - sfp_status, sfp_change_dict = self.get_transceiver_change_event(timeout) - change_event_dict["sfp"] = sfp_change_dict - if sfp_status is True: - return True, change_event_dict + change_event_dict = {"sfp": {}} - return False, {} - - def get_transceiver_change_event(self, timeout=0): start_time = time.time() - currernt_port_dict = {} forever = False if timeout == 0: @@ -97,25 +74,23 @@ def get_transceiver_change_event(self, timeout=0): elif timeout > 0: timeout = timeout / float(1000) # Convert to secs else: - print("get_transceiver_change_event:Invalid timeout value", timeout) - return False, {} + 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_transceiver_change_event:" "time wrap / invalid timeout value", + "get_change_event:" "time wrap / invalid timeout value", timeout, ) - return False, {} # Time wrap or possibly incorrect timeout - - while timeout >= 0: - # Check for OIR events and return updated port_dict - for index in range(PORT_START, PORTS_IN_BLOCK): - if self._sfp_list[index].get_presence(): - currernt_port_dict[index] = self.SFP_STATUS_INSERTED - else: - currernt_port_dict[index] = self.SFP_STATUS_REMOVED - if currernt_port_dict == self.port_dict: + 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() + if sfp_change_dict : + change_event_dict["sfp"] = sfp_change_dict + return True, change_event_dict if forever: time.sleep(1) else: @@ -125,11 +100,34 @@ def get_transceiver_change_event(self, timeout=0): else: if timeout > 0: time.sleep(timeout) - return True, {} + return True, change_event_dict + except Exception as e: + print(e) + print("get_change_event: Should not reach here.") + return False, change_event_dict + + def get_transceiver_change_event(self): + cur_sfp_present_dict = {} + ret_dict = {} + + # Check for OIR events and return ret_dict + for i in range(self.port_start_index, self.port_start_index + self.port_num): + sfp = self._sfp_list[i] + if sfp.get_presence(): + cur_sfp_present_dict[i] = self.STATUS_INSERTED + else: - # Update reg value - self.port_dict = currernt_port_dict - print(self.port_dict) - return True, self.port_dict - print("get_transceiver_change_event: Should not reach here.") - return False, {} + cur_sfp_present_dict[i] = self.STATUS_REMOVED + + # Update reg value + if cur_sfp_present_dict == self.sfp_present_dict: + return ret_dict + + for index, status in cur_sfp_present_dict.items(): + if self.sfp_present_dict[index] != status: + ret_dict[index] = status + + self.sfp_present_dict = cur_sfp_present_dict + + return ret_dict + 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..233fce5bbe4d 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,23 +8,68 @@ ######################################################################## try: - import subprocess from sonic_platform_base.component_base import ComponentBase - from sonic_platform.regutil import Reg - from sonic_platform.logger import logger + import subprocess + import sonic_platform.hwaccess as hwaccess except ImportError as e: raise ImportError(str(e) + "- required module not found") +def get_cpld_version(bus, i2caddr): + return '{}{}{}{}'.format(hwaccess.i2c_get(bus, i2caddr, 1), + hwaccess.i2c_get(bus, i2caddr, 2), + hwaccess.i2c_get(bus, i2caddr, 3), + hwaccess.i2c_get(bus, i2caddr, 0) + ) + +def get_cpu_cpld_version(): + return get_cpld_version(6, 0x0d) + +def get_fan_cpld_version(): + return get_cpld_version(2, 0x0d) + +def get_cpld1_version(): + return get_cpld_version(8, 0x30) + +def get_cpld2_version(): + return get_cpld_version(8, 0x31) + +def get_fpga_version(): + version = hwaccess.pci_get_value('/sys/bus/pci/devices/0000:08:00.0/resource0', 0) + datetime = hwaccess.pci_get_value('/sys/bus/pci/devices/0000:08:00.0/resource0',4) + return "%08x-%08x"%(version,datetime) + +COMPONENT_LIST= [ + ['CPU CPLD', + 'cpu board', + get_cpu_cpld_version + ], + + ['CPU FAN CPLD', + 'cpu fan', + get_fan_cpld_version + ], + + ['MAC1 CPLD', + 'mac1 board', + get_cpld1_version + ], + + ['MAC2 CPLD', + 'mac2 board', + get_cpld2_version + ], + ['FPGA', + 'fpga version', + get_fpga_version + ] + ] class Component(ComponentBase): """ Ragile Platform-specific Component class""" - def __init__(self, index, config=None): - self.index = index - self.name = config.get("name") - self._reg_fm_ver = Reg(config.get("firmware_version")) - self.description = config.get("desc") - self.slot = config.get("slot") + def __init__(self, component_index=0): + ComponentBase.__init__(self) + self.index = component_index def get_name(self): """ @@ -33,7 +78,7 @@ def get_name(self): Returns: A string containing the name of the component """ - return self.name + return COMPONENT_LIST[self.index][0] def get_description(self): """ @@ -42,7 +87,7 @@ def get_description(self): Returns: A string containing the description of the component """ - return self.description + return COMPONENT_LIST[self.index][1] def get_firmware_version(self): """ @@ -51,12 +96,7 @@ def get_firmware_version(self): Returns: A string containing the firmware version of the component """ - try: - return self._reg_fm_ver.decode() - except Exception as e: - logger.error(str(e)) - - return "" + return COMPONENT_LIST[self.index][2]() def install_firmware(self, image_path): """ @@ -74,7 +114,7 @@ def install_firmware(self, image_path): if status or len(output) <= 0: logger.error("no upgrade tool.") return False - cmdstr = "%s %s cpld %d cpld"%(output,image_path,self.slot) + cmdstr = "%s %s %s %s" % (output, image_path, "cpld", str(self.slot), "cpld") ret, log = subprocess.getstatusoutput(cmdstr) if ret == 0 and successtips in log: return True @@ -82,4 +122,4 @@ def install_firmware(self, image_path): except Exception as e: logger.error(str(e)) return False - + diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/config.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/config.py index 162f01680ad0..86b37f8bf1de 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/config.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/config.py @@ -2,7 +2,6 @@ PSU_FAN_AIRFLOW = { "CSU550AP-3-300": "F2B", - "AS-40FAN-01-F-RJ": "F2B", "CSU550AP-3-500": "F2B", "DPS-550AB-39 A": "F2B", "DPS-1300AB-6 S": "F2B", @@ -13,10 +12,8 @@ } FAN_AIRFLOW = { - "AS-80FAN-01-F-RJ": "F2B", - "AS-40FAN-01-F-RJ": "F2B", - "AS-80FAN-01-R-RJ": "B2F", - "AS-40FAN-01-R-RJ": "B2F", + "M1HFAN I-F": "F2B", + "M1HFAN I-R": "B2F", } psutypedecode = { diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/fan.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/fan.py index 47b5a9629c46..f37900d28dbf 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/fan.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/fan.py @@ -1,5 +1,6 @@ try: from sonic_platform_pddf_base.pddf_fan import PddfFan + from . import api except ImportError as e: raise ImportError(str(e) + "- required module not found") @@ -8,9 +9,9 @@ class Fan(PddfFan): """PDDF Platform-Specific Fan class""" def __init__(self, tray_idx, fan_idx=0, pddf_data=None, pddf_plugin_data=None, is_psu_fan=False, psu_index=0): - # idx is 0-based + # idx is 0-based PddfFan.__init__(self, tray_idx, fan_idx, pddf_data, pddf_plugin_data, is_psu_fan, psu_index) - + self.pddf_obj = api.newapi() # Provide the functions/variables below for which implementation is to be overwritten # Since psu_fan airflow direction cant be read from sysfs, it is fixed as 'F2B' or 'intake' def get_direction(self): @@ -27,10 +28,81 @@ def get_speed_rpm(self): if self.is_psu_fan: return super().get_speed_rpm() else: + ret = super().get_speed_rpm() + if ret == 0 or ret == 0xffff: + return 0 divisor = 15000000 mask_low = 0xff - ret = super().get_speed_rpm() # revert ret ret = (ret >> 8) + ((ret & mask_low) << 8) return int(divisor/ret) + def get_target_speed(self): + if self.is_psu_fan: + return None + + return super().get_target_speed() + + def get_speed_tolerance(self): + """ + Retrieves the speed tolerance of the fan + + Returns: + An integer, the percentage of variance from target speed which is + considered tolerable + """ + # Fix the speed vairance to 10 percent. If it changes based on platforms, overwrite + # this value in derived pddf fan class + return 30 + + + 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 self.is_psu_fan: + return super().get_speed() + # TODO This calculation should change based on MAX FAN SPEED + speed_rpm = self.get_speed_rpm() + max_speed = int(self.plugin_data['FAN']['FAN_MAX_SPEED']) + speed_percentage = round((speed_rpm*100)/max_speed) + if speed_percentage > 100: + speed_percentage = 100 + return speed_percentage + + def get_status(self): + if self.is_psu_fan: + return super().get_status() + + speed_rpm = self.get_speed_rpm() + status = True if (speed_rpm >= 1000) else False + return status + + def get_status_led(self): + if self.is_psu_fan: + return "N/A" + + presence_status = self.get_presence() + if presence_status is False: + return "N/A" + + led_device_name = "FANTRAY{}".format(self.fantray_index) + "_LED" + + if led_device_name not in self.pddf_obj.data.keys(): + # Implement a generic status_led color scheme + if self.get_status(): + return self.STATUS_LED_COLOR_GREEN + else: + return self.STATUS_LED_COLOR_RED + + 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', str(self.fantray_index-1), self.pddf_obj.get_led_path()) + self.pddf_obj.create_attr('dev_ops', 'get_status', self.pddf_obj.get_led_path()) + color = self.pddf_obj.get_led_color() + return (color) + diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/fan_drawer.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/fan_drawer.py index 4ff45cb81297..d03fd656f4d7 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/fan_drawer.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/fan_drawer.py @@ -1,71 +1,17 @@ -# -# fan_drawer_base.py -# -# Abstract base class for implementing a platform-specific class with which -# to interact with a fan drawer module in SONiC -# +#!/usr/bin/env python + try: - from sonic_platform_base.fan_drawer_base import FanDrawerBase + from sonic_platform_pddf_base.pddf_fan_drawer import PddfFanDrawer 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 - """ - return self._fan_list[self._index].set_status_led(color) +class FanDrawer(PddfFanDrawer): + """PDDF Platform-Specific Fan-Drawer class""" - 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 - """ - return self._fan_list[self._index].get_status_led(color) + def __init__(self, tray_idx, pddf_data=None, pddf_plugin_data=None): + # idx is 0-based + PddfFanDrawer.__init__(self, tray_idx, pddf_data, pddf_plugin_data) + # Provide the functions/variables below for which implementation is to be overwritten \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/hwaccess.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/hwaccess.py new file mode 100755 index 000000000000..c604d9c61164 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/hwaccess.py @@ -0,0 +1,47 @@ +# Helper functions to access hardware + +import os +import struct +import mmap +import subprocess + +# Read PCI device + +def pci_mem_read(mm, offset): + mm.seek(offset) + read_data_stream = mm.read(4) + return struct.unpack('I',read_data_stream)[0] + +def pci_get_value(resource, offset): + with open(resource, 'r+b') as fd: + mm = mmap.mmap(fd.fileno(), 0) + val = pci_mem_read(mm, offset) + mm.close() + return val + +def pci_mem_write(memmap, offset, data): + """ Write PCI device """ + memmap.seek(offset) + memmap.write(struct.pack('I', data)) + +def pci_set_value(resource, val, offset): + """ Set a value to PCI device """ + with open(resource, 'w+b') as filed: + memmap = None + try: + memmap = mmap.mmap(filed.fileno(), 0) + pci_mem_write(memmap, offset, val) + except EnvironmentError: + pass + if memmap is not None: + memmap.close() + +# Read I2C device + +def i2c_get(bus, i2caddr, ofs): + try: + valx = int(subprocess.check_output(['/usr/sbin/i2cget','-f', '-y', str(bus), str(i2caddr), str(ofs)]), 16) + return "{:02x}".format(valx) + except (FileNotFoundError, subprocess.CalledProcessError): + return -1 + diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/pcie.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/pcie.py old mode 100644 new mode 100755 index 5a66997d33d0..1e99f2c1e34b --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/pcie.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/pcie.py @@ -1,43 +1,23 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +######################################################################## +# Ragile # -# pcie_base.py -# -# Abstract base class for implementing platform-specific -# PCIE functionality for SONiC +# Module contains a platform specific implementation of SONiC Platform +# Base PCIe class # +######################################################################## try: - import abc - from sonic_pcie import PcieUtil + from sonic_platform_base.sonic_pcie.pcie_common import PcieUtil except ImportError as e: - raise ImportError (str(e) + " - required module not found") - -class PcieBase(object): - def __init__(self, path): - """ - Constructor - Args: - pcieutil file and config file path - """ - self.pcie_util = PcieUtil(path) - + raise ImportError(str(e) + "- required module not found") - @abc.abstractmethod - def get_pcie_device(self): - """ - get current device pcie info - - Returns: - A list including pcie device info - """ - return self.pcie_util.get_pcie_device() +class Pcie(PcieUtil): + """Ragile Platform-specific Pcie class""" - @abc.abstractmethod - def get_pcie_check(self): - """ - Check Pcie device with config file - Returns: - A list including pcie device and test result info - """ - return self.pcie_util.get_pcie_check() + def __init__(self, platform_path): + PcieUtil.__init__(self, platform_path) diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/psu.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/psu.py index 240af5d2d1b5..f25b24f145a5 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/psu.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/psu.py @@ -1,17 +1,19 @@ try: from sonic_platform_pddf_base.pddf_psu import PddfPsu + import subprocess + import time except ImportError as e: raise ImportError (str(e) + "- required module not found") class Psu(PddfPsu): """PDDF Platform-Specific PSU class""" - + PLATFORM_PSU_CAPACITY = 1200 def __init__(self, index, pddf_data=None, pddf_plugin_data=None): PddfPsu.__init__(self, index, pddf_data, pddf_plugin_data) - + # Provide the functions/variables below for which implementation is to be overwritten def get_maximum_supplied_power(self): """ @@ -30,3 +32,119 @@ def get_type(self): """ return "DC" + def get_model(self): + """ + Retrieves the model number (or part number) of the device + + Returns: + string: Model/part number of device + """ + model = super().get_model() + + psu_model_map = { + # -F + "CSU550AP-3-500": "PA550II-F", + "DPS-550AB-39 A": "PA550II-F", + "GW-CRPS550N2C": "PA550II-F", + "CSU550AP-3-300": "PA550II-F", + "DPS-550AB-39 B": "PA550II-F", + # -R + "CSU550AP-3-501": "PA550II-R", + "DPS-550AB-40 A": "PA550II-R", + "GW-CRPS550N2RC": "PA550II-R", + } + + return psu_model_map.get(model, model) + + def runcmd(self, cmd): + time_retry = 6 + result_msg = "" + time_delay = 0.01 + while time_retry: + try: + val, result_msg = subprocess.getstatusoutput(cmd) + 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, result_msg + + def get_voltage(self): + """ + Retrieves current PSU voltage output + + Returns: + A float number, the output voltage in volts, + e.g. 12.1 + """ + + v_out = 0 + label_t = "psu_v_out" + device = "PSU{}".format(self.psu_index) + #print(device) + pddf_obj_data = self.pddf_obj.data + + if device in pddf_obj_data.keys(): + pmbusloc = pddf_obj_data[device]['i2c']['interface'] + + for val in pmbusloc: + dev_name = val['dev'] + pmbus_loc = pddf_obj_data[dev_name] + i2cloc = pmbus_loc['i2c']['attr_list'] + parentbus = pmbus_loc['i2c']['topo_info'] + + for item_t in i2cloc: + if item_t['attr_name'] == label_t: + parentbus_id = int(parentbus['parent_bus'], 16) + vout_mode_cmd = "i2cget -f -y {} {} 0x20 bp".format(parentbus_id, parentbus['dev_addr']) + ret_t, val_voutmode = self.runcmd(vout_mode_cmd) + if ret_t is False: + return 0.0 + v_out_cmd = "i2cget -f -y {} {} {} wp".format(parentbus_id, parentbus['dev_addr'], item_t['attr_offset']) + ret_t, val_p_out = self.runcmd(v_out_cmd) + if ret_t is False: + return 0.0 + val_voutmode_t = int(val_voutmode, 16) + val_p_out_t = int(val_p_out, 16) * 1000 + + import ctypes + val_voutmode_t_t = ctypes.c_int8(val_voutmode_t << 3).value >>3 + + if (val_voutmode_t_t) < 0: + val_p_out_t_f = val_p_out_t>> (-val_voutmode_t_t) + else: + val_p_out_t_f = val_p_out_t << val_voutmode_t_t + + return float(val_p_out_t_f)/1000 + + return float(v_out)/1000 + + def get_revision(self): + """ + Retrieves the hardware revision of the device + + Returns: + string: Revision value of device + """ + device_eeprom = "PSU{}-EEPROM".format(self.psu_index) + pddf_obj_data = self.pddf_obj.data + + if device_eeprom not in pddf_obj_data.keys(): + return "N/A" + + i2cloc = pddf_obj_data[device_eeprom]['i2c']['topo_info'] + i2cbus = int(i2cloc['parent_bus'], 16) + get_revision_cmd = "i2cget -f -y {} {} 0x35 w".format(i2cbus, i2cloc['dev_addr']) + ret_t, revision = self.runcmd(get_revision_cmd) + if ret_t is False: + return "N/A" + revision = int(revision, 16) + revision_str = "%s%s" % (chr(revision&0xff), chr((revision >> 8)&0xff)) + return revision_str diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/sfp.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/sfp.py index a216a37afcf8..9009c3440275 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/sfp.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/sfp.py @@ -1,15 +1,525 @@ +#!/usr/bin/python +# -*- coding: UTF-8 -*- + +############################################################################# +# +# Module contains an implementation of SONiC Platform Base API and +# provides the platform information +# +# +# *_device.py config version instruction: +# ver 1.0 - platform api: +# "presence_cpld": { +# "dev_id": { +# [dev_id]: { +# "offset": { +# [offset]: [port_id] +# } +# } +# } +# } +# "reset_cpld": { +# "dev_id": { +# [dev_id]: { +# "offset": { +# [offset]: [port_id] +# } +# } +# } +# } +# ver 2.0 - rg_plat: +# "presence_path": "/xx/rg_plat/xx[port_id]/present" +# "eeprom_path": "/sys/bus/i2c/devices/i2c-[bus]/[bus]-0050/eeprom" +# "reset_path": "/xx/rg_plat/xx[port_id]/reset" +############################################################################# +import sys +import time +import syslog +import traceback +from abc import abstractmethod + try: - from sonic_platform_pddf_base.pddf_sfp import PddfSfp + import os + from sonic_platform_base.sonic_xcvr.sfp_optoe_base import SfpOptoeBase + from sonic_platform.sfp_config import * + except ImportError as e: raise ImportError (str(e) + "- required module not found") +LOG_DEBUG_LEVEL = 1 +LOG_WARNING_LEVEL = 2 +LOG_ERROR_LEVEL = 3 + +CONFIG_DB_PATH = "/etc/sonic/config_db.json" + +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 get_sfp_config(): + dev = getplatform_name() + return cust_sfp_cfg.get(dev, None) + +class Sfp(SfpOptoeBase): + + OPTOE_DRV_TYPE1 = 1 + OPTOE_DRV_TYPE2 = 2 + OPTOE_DRV_TYPE3 = 3 + + # index must start at 1 + def __init__(self, index, a=None, b=None): + SfpOptoeBase.__init__(self) + self.sfp_type = None + sfp_config = get_sfp_config() + self.log_level_config = sfp_config.get("log_level", LOG_WARNING_LEVEL) + # Init instance of SfpCust + ver = sfp_config.get("ver", None) + if ver is None: + self._sfplog(LOG_ERROR_LEVEL, "Get Ver Config Error!") + vers = int(float(ver)) + if vers == 1: + self._sfp_api = SfpV1(index) + elif vers == 2: + self._sfp_api = SfpV2(index) + else: + self._sfplog(LOG_ERROR_LEVEL, "Get SfpVer Error!") + + def get_eeprom_path(self): + return self._sfp_api._get_eeprom_path() + + def read_eeprom(self, offset, num_bytes): + return self._sfp_api.read_eeprom(offset, num_bytes) + + def write_eeprom(self, offset, num_bytes, write_buffer): + return self._sfp_api.write_eeprom(offset, num_bytes, write_buffer) + + def get_presence(self): + return self._sfp_api.get_presence() + + def get_transceiver_info(self): + # temporary solution for a sonic202111 bug + transceiver_info = super().get_transceiver_info() + try: + if transceiver_info["vendor_rev"] is not None: + transceiver_info["hardware_rev"] = transceiver_info["vendor_rev"] + return transceiver_info + except Exception as e: + print(traceback.format_exc()) + + 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._sfplog(LOG_ERROR_LEVEL, 'SFP does not support reset') + return False + + self._sfplog(LOG_DEBUG_LEVEL, 'resetting...') + ret = self._sfp_api.set_reset(True) + if ret: + time.sleep(0.5) + ret = self._sfp_api.set_reset(False) + + return ret + + def get_lpmode(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._sfplog(LOG_WARNING_LEVEL, 'SFP does not support lpmode') + return False + + #implement in future + + return False + + def set_lpmode(self, lpmode): + if self.get_presence() is False: + 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._sfplog(LOG_WARNING_LEVEL, 'SFP does not support lpmode') + 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._sfplog(LOG_DEBUG_LEVEL, "set_optoe_write_max NotImplemented") + pass + + 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__ + optoe_type = None + # set sfp_type + if (class_name == 'CmisApi'): + self.sfp_type = 'QSFP-DD' + optoe_type = self.OPTOE_DRV_TYPE3 + elif (class_name == 'Sff8472Api'): + self.sfp_type = 'SFP' + optoe_type = self.OPTOE_DRV_TYPE2 + elif (class_name == 'Sff8636Api' or class_name == 'Sff8436Api'): + self.sfp_type = 'QSFP' + optoe_type = self.OPTOE_DRV_TYPE1 + + if optoe_type is not None: + # set optoe driver + self._sfp_api.set_optoe_type(optoe_type) + + def _sfplog(self, log_level, msg): + if log_level >= self.log_level_config: + try: + syslog.openlog("Sfp") + if log_level == LOG_DEBUG_LEVEL: + syslog.syslog(syslog.LOG_DEBUG, msg) + elif log_level == LOG_WARNING_LEVEL: + syslog.syslog(syslog.LOG_DEBUG, msg) + elif log_level == LOG_ERROR_LEVEL: + syslog.syslog(syslog.LOG_ERR, msg) + syslog.closelog() + + except Exception as e: + print(traceback.format_exc()) + +class SfpCust(): + def __init__(self, index): + self.eeprom_path = None + self._init_config(index) + + def _init_config(self, index): + sfp_config = get_sfp_config() + self.log_level_config = sfp_config.get("log_level", LOG_WARNING_LEVEL) + self._port_id = index + self.eeprom_retry_times = sfp_config.get("eeprom_retry_times", 0) + self.eeprom_retry_break_sec = sfp_config.get("eeprom_retry_break_sec", 0) + + def combine_format_str(self, str, key): + count_format = str.count('%') + if count_format > 0: + args_k = [] + for i in range(count_format): + args_k.append(key) + return str % (tuple(args_k)) + else: + return str + + def _get_eeprom_path(self): + return self.eeprom_path or None + + @abstractmethod + def get_presence(self): + pass + + def read_eeprom(self, offset, num_bytes): + try: + for i in range(self.eeprom_retry_times): + with open(self._get_eeprom_path(), mode='rb', buffering=0) as f: + f.seek(offset) + result = f.read(num_bytes) + # temporary solution for a sonic202111 bug + if len(result) < num_bytes: + result = result[::-1].zfill(num_bytes)[::-1] + if result != None: + return bytearray(result) + else: + time.sleep(self.eeprom_retry_break_sec) + continue + + except Exception as e: + self._sfplog(LOG_ERROR_LEVEL, traceback.format_exc()) + + return None + + + def write_eeprom(self, offset, num_bytes, write_buffer): + try: + for i in range(self.eeprom_retry_times): + ret = SfpOptoeBase.write_eeprom(self, offset, num_bytes, write_buffer) + if ret is False: + time.sleep(self.eeprom_retry_break_sec) + continue + break + + return ret + + except Exception as e: + self._sfplog(LOG_ERROR_LEVEL, traceback.format_exc()) + + + @abstractmethod + def set_optoe_type(self, class_name): + pass + + @abstractmethod + def set_reset(self, reset): + pass + + def _convert_str_range_to_int_arr(self, range_str): + if not range_str: + return [] + + int_range_strs = range_str.split(',') + range_res = [] + for int_range_str in int_range_strs: + if '-' in int_range_str: + range_s = int(int_range_str.split('-')[0]) + range_e = int(int_range_str.split('-')[1]) + 1 + else: + range_s = int(int_range_str) + range_e = int(int_range_str) + 1 + + range_res = range_res + list(range(range_s, range_e)) + + return range_res + + def _sfplog(self, log_level, msg): + if log_level >= self.log_level_config: + try: + syslog.openlog("SfpCust") + if log_level == LOG_DEBUG_LEVEL: + syslog.syslog(syslog.LOG_DEBUG, msg) + elif log_level == LOG_WARNING_LEVEL: + syslog.syslog(syslog.LOG_DEBUG, msg) + elif log_level == LOG_ERROR_LEVEL: + syslog.syslog(syslog.LOG_ERR, msg) + syslog.closelog() + + except Exception as e: + print(traceback.format_exc()) + +class SfpV1(SfpCust): + def _init_config(self, index): + super()._init_config(index) + sfp_config = get_sfp_config() + + # init presence path + self.presence_cpld = sfp_config.get("presence_cpld", None) + self.presence_val_is_present = sfp_config.get("presence_val_is_present", 0) + self._sfplog(LOG_DEBUG_LEVEL, "Done init presence path") + + # init reset path + self.reset_cpld = sfp_config.get("reset_cpld", None) + self.reset_val_is_reset = sfp_config.get("reset_val_is_reset", 0) + self._sfplog(LOG_DEBUG_LEVEL, "Done init cpld path") + + def get_presence(self): + if self.presence_cpld is None: + self._sfplog(LOG_ERROR_LEVEL, "presence_cpld is None!") + return False + try: + dev_id, offset, offset_bit = self._get_sfp_cpld_info(self.presence_cpld) + ret, info = platform_reg_read(0, dev_id, offset, 1) + return (info[0] & (1 << offset_bit) == self.presence_val_is_present) + except Exception as err: + self._sfplog(LOG_ERROR_LEVEL, traceback.format_exc()) + + def read_eeprom(self, offset, num_bytes): + try: + for i in range(self.eeprom_retry_times): + ret, info = platform_sfp_read(self._port_id, offset, num_bytes) + if (ret is False + or info is None): + time.sleep(self.eeprom_retry_break_sec) + continue + eeprom_raw = [] + for i in range(0, num_bytes): + eeprom_raw.append("0x00") + for n in range(0, len(info)): + eeprom_raw[n] = info[n] + # temporary solution for a sonic202111 bug + if len(eeprom_raw) < num_bytes: + eeprom_raw = eeprom_raw[::-1].zfill(num_bytes)[::-1] + return bytearray(eeprom_raw) + except Exception as e: + self._sfplog(LOG_ERROR_LEVEL, traceback.format_exc()) + return None + + def write_eeprom(self, offset, num_bytes, write_buffer): + try: + for i in range(self.eeprom_retry_times): + # TODO: write_buffer is bytearray, need to convert to int array + val_list = [] + if isinstance(write_buffer, list): + val_list = write_buffer + else: + val_list.append(write_buffer) + ret, info = platform_sfp_write(self._port_id, offset, val_list) + if ret is False: + time.sleep(self.eeprom_retry_break_sec) + continue + return True + except Exception as e: + self._sfplog(LOG_ERROR_LEVEL, traceback.format_exc()) + + return False + + def set_optoe_type(self, optoe_type): + ret, info = platform_get_optoe_type(self._port_id) + if info != optoe_type: + try: + ret, _ = platform_set_optoe_type(self._port_id, optoe_type) + except Exception as err: + self._sfplog(LOG_ERROR_LEVEL, "Set optoe err %s" % err) + + def set_reset(self, reset): + if self.reset_cpld is None: + self._sfplog(LOG_ERROR_LEVEL, "reset_cpld is None!") + return False + try: + val = [] + dev_id, offset, offset_bit = self._get_sfp_cpld_info(self.reset_cpld) + ret, info = platform_reg_read(0, dev_id, offset, 1) + if self.reset_val_is_reset == 0: + if reset: + val.append(info[0] & (~(1 << offset_bit))) + else: + val.append(info[0] | (1 << offset_bit)) + else: + if reset: + val.append(info[0] | (1 << offset_bit)) + else: + val.append(info[0] & (~(1 << offset_bit))) + + ret, info = platform_reg_write(0, dev_id, offset, val) + if ret is False: + self._sfplog(LOG_ERROR_LEVEL, "platform_reg_write error!") + return False + + except Exception as err: + self._sfplog(LOG_ERROR_LEVEL, traceback.format_exc()) + return False + + return True + + def _get_sfp_cpld_info(self, cpld_config): + dev_id = 0 + offset = 0 + + for dev_id_temp in cpld_config["dev_id"]: + for offset_temp in cpld_config["dev_id"][dev_id_temp]["offset"]: + port_range_str = cpld_config["dev_id"][dev_id_temp]["offset"][offset_temp] + port_range_int = self._convert_str_range_to_int_arr(port_range_str) + if self._port_id in port_range_int: + dev_id = dev_id_temp + offset = offset_temp + offset_bit = port_range_int.index(self._port_id) + break + + return dev_id, offset, offset_bit + +class SfpV2(SfpCust): + def _init_config(self, index): + super()._init_config(index) + sfp_config = get_sfp_config() + + # init eeprom path + eeprom_path_config = sfp_config.get("eeprom_path", None) + eeprom_path_key = sfp_config.get("eeprom_path_key")[self._port_id - 1] + self.eeprom_path = self.combine_format_str(eeprom_path_config, eeprom_path_key) + self._sfplog(LOG_DEBUG_LEVEL, "Done init eeprom path: %s" % self.eeprom_path) + + # init presence path + presence_path_config = sfp_config.get("presence_path", None) + presence_path_key = sfp_config.get("presence_path_key")[self._port_id - 1] + self.presence_path = self.combine_format_str(presence_path_config, presence_path_key) + self.presence_val_is_present = sfp_config.get("presence_val_is_present", 0) + self._sfplog(LOG_DEBUG_LEVEL, "Done init presence path: %s" % self.presence_path) + + # init optoe driver path + optoe_driver_path_config = sfp_config.get("optoe_driver_path", None) + optoe_driver_key = sfp_config.get("optoe_driver_key")[self._port_id - 1] + self.dev_class_path = self.combine_format_str(optoe_driver_path_config, optoe_driver_key) + self._sfplog(LOG_DEBUG_LEVEL, "Done init optoe driver path: %s" % self.dev_class_path) + + # init txdisable path + txdisable_path_config = sfp_config.get("txdisable_path", None) + if txdisable_path_config is not None: + txdisable_path_key = sfp_config.get("txdisable_path_key")[self._port_id - 1] + self.txdisable_path = self.combine_format_str(txdisable_path_config, txdisable_path_key) + self.txdisable_val_is_on = sfp_config.get("txdisable_val_is_on", 0) + self._sfplog(LOG_DEBUG_LEVEL, "Done init optoe driver path: %s" % self.dev_class_path) + + # init reset path + reset_path_config = sfp_config.get("reset_path", None) + if reset_path_config is not None: + reset_path_key = sfp_config.get("reset_path_key")[self._port_id - 1] + self.reset_path = self.combine_format_str(reset_path_config, reset_path_key) + self.reset_val_is_on = sfp_config.get("reset_val_is_on", 0) + self._sfplog(LOG_DEBUG_LEVEL, "Done init reset path: %s" % self.reset_path) -class Sfp(PddfSfp): - """ - PDDF Platform-Specific Sfp class - """ + def get_presence(self): + if self.presence_path is None: + self._sfplog(LOG_ERROR_LEVEL, "presence_path is None!") + return False + try: + with open(self.presence_path, "rb") as data: + sysfs_data = data.read(1) + if sysfs_data != "": + result = int(sysfs_data, 16) + return result == self.presence_val_is_present + except Exception as err: + self._sfplog(LOG_ERROR_LEVEL, traceback.format_exc()) - def __init__(self, index, pddf_data=None, pddf_plugin_data=None): - PddfSfp.__init__(self, index, pddf_data, pddf_plugin_data) + def set_reset(self, reset): + return True - # Provide the functions/variables below for which implementation is to be overwritten + def set_optoe_type(self, optoe_type): + if self.dev_class_path is None: + self._sfplog(LOG_ERROR_LEVEL, "dev_class_path is None!") + return False + try: + dc_file = open(self.dev_class_path, "r+") + dc_file_val = dc_file.read(1) + if int(dc_file_val) != optoe_type: + dc_str = "%s" % str(optoe_type) + dc_file.write(dc_str) + dc_file.close() + except Exception as err: + self._sfplog(LOG_ERROR_LEVEL, traceback.format_exc()) diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/sfp_config.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/sfp_config.py new file mode 100644 index 000000000000..c6df4f5aca8b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/sfp_config.py @@ -0,0 +1,23 @@ +cust_sfp_cfg = { + 'x86_64-ragile_ra-b6510-48v8c-r0': { + "ver": '2.1', + "port_index_start": 1, + "port_num": 56, + "log_level": 2, + "eeprom_retry_times": 5, + "eeprom_retry_break_sec": 0.2, + "presence_path": "/sys/bus/i2c/devices/%d-0053/xcvr_present", + "presence_path_key": list(range(32, 88)), + "presence_val_is_present": 1, + "eeprom_path": "/sys/bus/i2c/devices/%d-0050/eeprom", + "eeprom_path_key": list(range(32, 88)), + "optoe_driver_path": "/sys/bus/i2c/devices/%d-0050/dev_class", + "optoe_driver_key": list(range(32, 88)), + "txdisable_path": "/sys/bus/i2c/devices/%d-0053/xcvr_txdisable", + "txdisable_path_key": list(range(32, 80)) + [0] * 8, + "txdisable_val_is_on": 0, + "reset_path": "/sys/bus/i2c/devices/%d-0053/xcvr_reset", + "reset_path_key": [0]* 48 + list(range(80, 88)), + "reset_val_is_on": 0, + }, +} diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/sfp_config_v1.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/sfp_config_v1.py new file mode 100644 index 000000000000..d468912fdda3 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/sfp_config_v1.py @@ -0,0 +1,23 @@ +cust_sfp_cfg = { + 'x86_64-ragile_ra-b6510-48v8c-r0': { + "ver": '2.1', + "port_index_start": 0, + "port_num": 56, + "log_level": 2, + "eeprom_retry_times": 5, + "eeprom_retry_break_sec": 0.2, + "presence_path": "/sys/bus/i2c/devices/%d-0053/xcvr_present", + "presence_path_key": list(range(11, 67)), + "presence_val_is_present": 1, + "eeprom_path": "/sys/bus/i2c/devices/%d-0050/eeprom", + "eeprom_path_key": list(range(11, 67)), + "optoe_driver_path": "/sys/bus/i2c/devices/%d-0050/dev_class", + "optoe_driver_key": list(range(11, 67)), + "txdisable_path": "/sys/bus/i2c/devices/%d-0053/xcvr_txdisable", + "txdisable_path_key": list(range(11, 59)) + [0] * 8, + "txdisable_val_is_on": 0, + "reset_path": "/sys/bus/i2c/devices/%d-0053/xcvr_reset", + "reset_path_key": [0]* 48 + list(range(59, 67)), + "reset_val_is_on": 0, + }, +} diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/sfp_config_v2.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/sfp_config_v2.py new file mode 100644 index 000000000000..c6df4f5aca8b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/sfp_config_v2.py @@ -0,0 +1,23 @@ +cust_sfp_cfg = { + 'x86_64-ragile_ra-b6510-48v8c-r0': { + "ver": '2.1', + "port_index_start": 1, + "port_num": 56, + "log_level": 2, + "eeprom_retry_times": 5, + "eeprom_retry_break_sec": 0.2, + "presence_path": "/sys/bus/i2c/devices/%d-0053/xcvr_present", + "presence_path_key": list(range(32, 88)), + "presence_val_is_present": 1, + "eeprom_path": "/sys/bus/i2c/devices/%d-0050/eeprom", + "eeprom_path_key": list(range(32, 88)), + "optoe_driver_path": "/sys/bus/i2c/devices/%d-0050/dev_class", + "optoe_driver_key": list(range(32, 88)), + "txdisable_path": "/sys/bus/i2c/devices/%d-0053/xcvr_txdisable", + "txdisable_path_key": list(range(32, 80)) + [0] * 8, + "txdisable_val_is_on": 0, + "reset_path": "/sys/bus/i2c/devices/%d-0053/xcvr_reset", + "reset_path_key": [0]* 48 + list(range(80, 88)), + "reset_val_is_on": 0, + }, +} diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/thermal.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/thermal.py index 99b743c6d343..f2a73e5f5db8 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/thermal.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/thermal.py @@ -8,7 +8,7 @@ class Thermal(PddfThermal): """PDDF Platform-Specific Thermal class""" - def __init__(self, index, pddf_data=None, pddf_plugin_data=None): - PddfThermal.__init__(self, index, pddf_data, pddf_plugin_data) + def __init__(self, index, pddf_data=None, pddf_plugin_data=None, is_psu_thermal=False, psu_index=0): + PddfThermal.__init__(self, index, pddf_data, pddf_plugin_data, is_psu_thermal, psu_index) # Provide the functions/variables below for which implementation is to be overwritten diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/Makefile b/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/Makefile index 9e262d7c095e..e32f4eeae9d5 100755 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/Makefile +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/Makefile @@ -7,8 +7,11 @@ INSTALL_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/ -KBUILD_EXTRA_SYMBOLS += $(DIR_KERNEL_SRC)/Module.symvers +ifeq "5.10.0" "$(word 1, $(sort 5.10.0 $(KERNEL_VERSION)))" +KBUILD_EXTRA_SYMBOLS += $(PWD)/../../../pddf/i2c/Module.symvers.PDDF export KBUILD_EXTRA_SYMBOLS +endif + all: $(MAKE) -C $(KBUILD_OUTPUT) M=$(DIR_KERNEL_SRC) modules diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/config/fan_ctrl_cfg.json b/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/config/fan_ctrl_cfg.json new file mode 100644 index 000000000000..3e1e46bf927b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/config/fan_ctrl_cfg.json @@ -0,0 +1,43 @@ +{ + "Device": { + "Liquid": 0, + "Buildin": 0, + "PID": 0, + "OpenLoop": 1 + }, + "Thermal": { + "INLET_TEMP": "Temp_MAC_INLET_F", + "OUTLET_TEMP": "Temp_MAC_INLET_R", + "SWITCH_TEMP": "Temp_MAC_INLET_B" + }, + "Fans": { + "Fan1" : "Fantray1_1", + "Fan2" : "Fantray1_2", + "Fan3" : "Fantray2_1", + "Fan4" : "Fantray2_2", + "Fan5" : "Fantray3_1", + "Fan6" : "Fantray3_2", + "Fan7" : "Fantray4_1", + "Fan8" : "Fantray4_2" + }, + "PID": { + "Pwm_Max": 100, + "Pwm_Min": 30, + "SetPoint" : 90, + "P": 1.5, + "I": 1, + "D": 0.3, + "Temp_Min": 28.0, + "Temp_Max": 45.0, + "Sensor": "INLET_TEMP" + }, + "OpenLoop": { + "a": -0.06, + "b": 10.3, + "c": -142.0, + "fix_up": -8, + "pwmMax": 100, + "pwmMin": 30, + "tempMin": 25 + } +} \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/config/x86_64_ragile_ra_b6910_64c_r0_config.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/config/x86_64_ragile_ra_b6910_64c_r0_config.py index a25852068fe5..dd21fe3e4ffb 100755 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/config/x86_64_ragile_ra_b6910_64c_r0_config.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/config/x86_64_ragile_ra_b6910_64c_r0_config.py @@ -7,6 +7,10 @@ RAGILE_CARDID = 0x0000404c RAGILE_PRODUCTNAME = "RA-B6910-64C" +STARTMODULE = { + "fancontrol":1, +} + fanlevel = { "tips": ["LOW", "MEDIUM", "HIGH"], "level": [75, 150, 255], diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/setup.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/setup.py index 0ed22d770626..f36055fb4e6d 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/setup.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/setup.py @@ -13,7 +13,8 @@ packages=[ 'sonic_platform', 'rgutil', - 'eepromutil' + 'eepromutil', + 'sonic_pcie', ], classifiers=[ 'Development Status :: 3 - Alpha', diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_pcie/__init__.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/sonic_pcie/__init__.py similarity index 100% rename from platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_pcie/__init__.py rename to platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/sonic_pcie/__init__.py 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-b6910-64c/sonic_pcie/pcie_common.py similarity index 100% rename from platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_pcie/pcie_common.py rename to platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/sonic_pcie/pcie_common.py 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..91dcd55c2ad7 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,17 +8,13 @@ try: import time - import subprocess from sonic_platform_pddf_base.pddf_chassis import PddfChassis - from rgutil.logutil import Logger except ImportError as e: raise ImportError(str(e) + "- required module not found") PORT_START = 0 -PORT_END = 55 PORTS_IN_BLOCK = 56 - -logger = Logger("CHASSIS", syslog=True) +FAN_NUM_PER_DRAWER = 1 class Chassis(PddfChassis): """ @@ -32,14 +28,10 @@ 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" + def get_revision(self): + val = ord(self._eeprom.revision_str()) + test = "{}".format(val) + return test def get_reboot_cause(self): """ @@ -51,32 +43,6 @@ def get_reboot_cause(self): is "REBOOT_CAUSE_HARDWARE_OTHER", the second string can be used to pass a description of the reboot cause. """ - try: - is_power_loss = False - # enable read - subprocess.getstatusoutput(self.disable_write) - subprocess.getstatusoutput(self.enable_read) - ret, log = subprocess.getstatusoutput(self.read_value) - if ret == 0 and "0x0a" in log: - is_power_loss = True - - # erase i2c and e2 - subprocess.getstatusoutput(self.enable_erase) - time.sleep(1) - subprocess.getstatusoutput(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) - # enable write and set data - subprocess.getstatusoutput(self.enable_write) - subprocess.getstatusoutput(self.disable_read) - subprocess.getstatusoutput(self.write_value) - if is_power_loss: - return(self.REBOOT_CAUSE_POWER_LOSS, None) - except Exception as e: - logger.error(str(e)) return (self.REBOOT_CAUSE_NON_HARDWARE, None) diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/sonic_platform/fan_drawer.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/sonic_platform/fan_drawer.py index 4ff45cb81297..d03fd656f4d7 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/sonic_platform/fan_drawer.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/sonic_platform/fan_drawer.py @@ -1,71 +1,17 @@ -# -# fan_drawer_base.py -# -# Abstract base class for implementing a platform-specific class with which -# to interact with a fan drawer module in SONiC -# +#!/usr/bin/env python + try: - from sonic_platform_base.fan_drawer_base import FanDrawerBase + from sonic_platform_pddf_base.pddf_fan_drawer import PddfFanDrawer 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 - """ - return self._fan_list[self._index].set_status_led(color) +class FanDrawer(PddfFanDrawer): + """PDDF Platform-Specific Fan-Drawer class""" - 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 - """ - return self._fan_list[self._index].get_status_led(color) + def __init__(self, tray_idx, pddf_data=None, pddf_plugin_data=None): + # idx is 0-based + PddfFanDrawer.__init__(self, tray_idx, pddf_data, pddf_plugin_data) + # Provide the functions/variables below for which implementation is to be overwritten \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/sonic_platform/pcie.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/sonic_platform/pcie.py new file mode 100644 index 000000000000..d61925e5ff8c --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/sonic_platform/pcie.py @@ -0,0 +1,43 @@ +# +# pcie_base.py +# +# Abstract base class for implementing platform-specific +# PCIE functionality for SONiC +# + +try: + import abc + from sonic_pcie import PcieUtil +except ImportError as e: + raise ImportError (str(e) + " - required module not found") + +class PcieBase(object): + def __init__(self, path): + """ + Constructor + Args: + pcieutil file and config file path + """ + self.pcie_util = PcieUtil(path) + + + @abc.abstractmethod + def get_pcie_device(self): + """ + get current device pcie info + + Returns: + A list including pcie device info + """ + return self.pcie_util.get_pcie_device() + + + @abc.abstractmethod + def get_pcie_check(self): + """ + Check Pcie device with config file + + Returns: + A list including pcie device and test result info + """ + return self.pcie_util.get_pcie_check() diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/sonic_platform/psu.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/sonic_platform/psu.py index 72a6d8f0825b..baba1812845b 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/sonic_platform/psu.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/sonic_platform/psu.py @@ -1,21 +1,19 @@ -#!/usr/bin/env python -# - - try: from sonic_platform_pddf_base.pddf_psu import PddfPsu + import subprocess + import time except ImportError as e: raise ImportError (str(e) + "- required module not found") class Psu(PddfPsu): """PDDF Platform-Specific PSU class""" - + PLATFORM_PSU_CAPACITY = 1200 def __init__(self, index, pddf_data=None, pddf_plugin_data=None): PddfPsu.__init__(self, index, pddf_data, pddf_plugin_data) - + # Provide the functions/variables below for which implementation is to be overwritten def get_maximum_supplied_power(self): """ @@ -33,4 +31,96 @@ def get_type(self): A string, the type of PSU (AC/DC) """ return "DC" + + def runcmd(self, cmd): + time_retry = 6 + result_msg = "" + time_delay = 0.01 + while time_retry: + try: + val, result_msg = subprocess.getstatusoutput(cmd) + 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, result_msg + + def get_voltage(self): + """ + Retrieves current PSU voltage output + + Returns: + A float number, the output voltage in volts, + e.g. 12.1 + """ + + v_out = 0 + label_t = "psu_v_out" + device = "PSU{}".format(self.psu_index) + #print(device) + pddf_obj_data = self.pddf_obj.data + + if device in pddf_obj_data.keys(): + pmbusloc = pddf_obj_data[device]['i2c']['interface'] + + for val in pmbusloc: + dev_name = val['dev'] + pmbus_loc = pddf_obj_data[dev_name] + i2cloc = pmbus_loc['i2c']['attr_list'] + parentbus = pmbus_loc['i2c']['topo_info'] + + for item_t in i2cloc: + if item_t['attr_name'] == label_t: + parentbus_id = int(parentbus['parent_bus'], 16) + vout_mode_cmd = "i2cget -f -y {} {} 0x20 bp".format(parentbus_id, parentbus['dev_addr']) + ret_t, val_voutmode = self.runcmd(vout_mode_cmd) + if ret_t is False: + return 0.0 + v_out_cmd = "i2cget -f -y {} {} {} wp".format(parentbus_id, parentbus['dev_addr'], item_t['attr_offset']) + ret_t, val_p_out = self.runcmd(v_out_cmd) + if ret_t is False: + return 0.0 + val_voutmode_t = int(val_voutmode, 16) + val_p_out_t = int(val_p_out, 16) * 1000 + + import ctypes + val_voutmode_t_t = ctypes.c_int8(val_voutmode_t << 3).value >>3 + + if (val_voutmode_t_t) < 0: + val_p_out_t_f = val_p_out_t>> (-val_voutmode_t_t) + else: + val_p_out_t_f = val_p_out_t << val_voutmode_t_t + + return float(val_p_out_t_f)/1000 + + return float(v_out)/1000 + + def get_revision(self): + """ + Retrieves the hardware revision of the device + + Returns: + string: Revision value of device + """ + device_eeprom = "PSU{}-EEPROM".format(self.psu_index) + pddf_obj_data = self.pddf_obj.data + + if device_eeprom not in pddf_obj_data.keys(): + return "N/A" + i2cloc = pddf_obj_data[device_eeprom]['i2c']['topo_info'] + i2cbus = int(i2cloc['parent_bus'], 16) + get_revision_cmd = "i2cget -f -y {} {} 0x35 w".format(i2cbus, i2cloc['dev_addr']) + ret_t, revision = self.runcmd(get_revision_cmd) + if ret_t is False: + return "N/A" + revision = int(revision, 16) + revision_str = "%s%s" % (chr(revision&0xff), chr((revision >> 8)&0xff)) + return revision_str diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/sonic_platform/sfp.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/sonic_platform/sfp.py index d9b6e491bef4..c577544a664e 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/sonic_platform/sfp.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/sonic_platform/sfp.py @@ -1,10 +1,12 @@ #!/usr/bin/env python - +import time try: from sonic_platform_pddf_base.pddf_sfp import PddfSfp except ImportError as e: raise ImportError (str(e) + "- required module not found") +EEPROM_RETRY = 5 +EEPROM_RETRY_BREAK_SEC = 0.2 class Sfp(PddfSfp): """ @@ -13,5 +15,46 @@ class Sfp(PddfSfp): def __init__(self, index, pddf_data=None, pddf_plugin_data=None): PddfSfp.__init__(self, index, pddf_data, pddf_plugin_data) + self._xcvr_api = self.get_xcvr_api() + + def get_eeprom_path(self): + return self.eeprom_path + + def read_eeprom(self, offset, num_bytes): + eeprom_raw = None + try: + for i in range(EEPROM_RETRY): + eeprom_raw = PddfSfp.read_eeprom(self, offset, num_bytes) + if eeprom_raw is None: + time.sleep(EEPROM_RETRY_BREAK_SEC) + continue + break + except Exception as e: + print("Error: Unable to read eeprom_path: %s" % (str(e))) + return None + + return eeprom_raw + + def write_eeprom(self, offset, num_bytes, write_buffer): + try: + for i in range(EEPROM_RETRY): + ret = PddfSfp.write_eeprom(self, offset, num_bytes, write_buffer) + if ret is False: + time.sleep(EEPROM_RETRY_BREAK_SEC) + continue + break + except Exception as e: + print("Error: Unable to write eeprom_path: %s" % (str(e))) + return None + + return ret + + def get_power_set(self): + if not self._xcvr_api.get_lpmode_support(): + return False + return self._xcvr_api.get_power_set() - # Provide the functions/variables below for which implementation is to be overwritten + def get_power_override(self): + if not self._xcvr_api.get_power_override_support() or not self._xcvr_api.get_lpmode_support(): + return False + return self._xcvr_api.get_power_override() diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/sonic_platform/thermal.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/sonic_platform/thermal.py index 5b829fc26caa..77d6ec7ae886 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/sonic_platform/thermal.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6910-64c/sonic_platform/thermal.py @@ -11,7 +11,7 @@ class Thermal(PddfThermal): """PDDF Platform-Specific Thermal class""" - def __init__(self, index, pddf_data=None, pddf_plugin_data=None): - PddfThermal.__init__(self, index, pddf_data, pddf_plugin_data) + def __init__(self, index, pddf_data=None, pddf_plugin_data=None, is_psu_thermal=False, psu_index=0): + PddfThermal.__init__(self, index, pddf_data, pddf_plugin_data, is_psu_thermal, psu_index) # Provide the functions/variables below for which implementation is to be overwritten diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/Makefile b/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/Makefile index 46415e74ab7d..49bf43c08c9b 100755 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/Makefile +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/Makefile @@ -7,8 +7,11 @@ INSTALL_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/ -KBUILD_EXTRA_SYMBOLS += $(DIR_KERNEL_SRC)/Module.symvers +ifeq "5.10.0" "$(word 1, $(sort 5.10.0 $(KERNEL_VERSION)))" +KBUILD_EXTRA_SYMBOLS += $(PWD)/../../../pddf/i2c/Module.symvers.PDDF export KBUILD_EXTRA_SYMBOLS +endif + all: $(MAKE) -C $(KBUILD_OUTPUT) M=$(DIR_KERNEL_SRC) modules diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/config/fan_ctrl_cfg.json b/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/config/fan_ctrl_cfg.json new file mode 100644 index 000000000000..3e1e46bf927b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/config/fan_ctrl_cfg.json @@ -0,0 +1,43 @@ +{ + "Device": { + "Liquid": 0, + "Buildin": 0, + "PID": 0, + "OpenLoop": 1 + }, + "Thermal": { + "INLET_TEMP": "Temp_MAC_INLET_F", + "OUTLET_TEMP": "Temp_MAC_INLET_R", + "SWITCH_TEMP": "Temp_MAC_INLET_B" + }, + "Fans": { + "Fan1" : "Fantray1_1", + "Fan2" : "Fantray1_2", + "Fan3" : "Fantray2_1", + "Fan4" : "Fantray2_2", + "Fan5" : "Fantray3_1", + "Fan6" : "Fantray3_2", + "Fan7" : "Fantray4_1", + "Fan8" : "Fantray4_2" + }, + "PID": { + "Pwm_Max": 100, + "Pwm_Min": 30, + "SetPoint" : 90, + "P": 1.5, + "I": 1, + "D": 0.3, + "Temp_Min": 28.0, + "Temp_Max": 45.0, + "Sensor": "INLET_TEMP" + }, + "OpenLoop": { + "a": -0.06, + "b": 10.3, + "c": -142.0, + "fix_up": -8, + "pwmMax": 100, + "pwmMin": 30, + "tempMin": 25 + } +} \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/config/x86_64_ragile_ra_b6920_4s_r0_config.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/config/x86_64_ragile_ra_b6920_4s_r0_config.py index 51cb6992a0a0..9cf8aecc7771 100755 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/config/x86_64_ragile_ra_b6920_4s_r0_config.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/config/x86_64_ragile_ra_b6920_4s_r0_config.py @@ -297,7 +297,7 @@ E2_LOC = {"bus":1, "devno":0x56} E2_PROTECT = {"io_addr":0xb45, "gettype":"io", "open":0, "close":1} -CPLDVERSIONS = [ +CPLDVERSIONS = [ {"bus":13, "devno":0x0d, "name":"FAN_CPLD_B"}, {"bus":14, "devno":0x0d, "name":"FAN_CPLD_A"}, {"bus":3, "devno":0x30, "name":"LC1_CPLD_1"}, @@ -601,7 +601,7 @@ 0x87:0x0301 , 0x88:0x02fb , 0x89:0x02f5 , - 0x8A:0x02ee + 0x8A:0x02ee } diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/modules/driver/Makefile b/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/modules/driver/Makefile index 2b5ac6c5aadb..802aee4a6726 100755 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/modules/driver/Makefile +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/modules/driver/Makefile @@ -1,8 +1,8 @@ -obj-m := rg_cpld.o - -obj-m += lpc_cpld_i2c.o -obj-m += rg_lpc_cpld.o -obj-m += pddf_custom_fan.o -obj-m += pddf_custom_psu.o -obj-m += pddf_custom_xcvr.o -obj-m += pddf_custom_led_module.o +obj-m := rg_cpld.o + +obj-m += lpc_cpld_i2c.o +obj-m += rg_lpc_cpld.o +obj-m += pddf_custom_fan.o +obj-m += pddf_custom_psu.o +obj-m += pddf_custom_xcvr.o +obj-m += pddf_custom_led_module.o diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/modules/driver/pddf_custom_led_module.c b/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/modules/driver/pddf_custom_led_module.c index 97ca23a92324..f21aca464806 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/modules/driver/pddf_custom_led_module.c +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/modules/driver/pddf_custom_led_module.c @@ -1,6 +1,6 @@ /* * Copyright 2019 Broadcom. - * The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. + * The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,6 +27,7 @@ #include #include #include +#include #include #define DEBUG 0 @@ -48,11 +49,16 @@ LED_OPS_DATA* dev_list[LED_TYPE_MAX] = { int num_psus = 0; int num_fantrays = 0; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) +extern int board_i2c_cpld_read_new(unsigned short cpld_addr, char *name, u8 reg); +extern int board_i2c_cpld_write_new(unsigned short cpld_addr, char *name, u8 reg, u8 value); +#else extern int board_i2c_cpld_read(unsigned short cpld_addr, u8 reg); extern int board_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); +extern void *get_device_table(char *name); +#endif extern ssize_t show_pddf_data(struct device *dev, struct device_attribute *da, char *buf); extern ssize_t store_pddf_data(struct device *dev, struct device_attribute *da, const char *buf, size_t count); -extern void *get_device_table(char *name); static LED_STATUS find_state_index(const char* state_str) { int index; @@ -151,6 +157,7 @@ static void print_led_data(LED_OPS_DATA *ptr, LED_STATUS state) } } +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) int get_sys_val(LED_OPS_DATA *ops_ptr, uint32_t *sys_val) { int ret; @@ -187,8 +194,8 @@ int get_sys_val(LED_OPS_DATA *ops_ptr, uint32_t *sys_val) return ret; } - - +#endif + ssize_t get_status_led(struct device_attribute *da) { int ret=0; @@ -206,6 +213,7 @@ ssize_t get_status_led(struct device_attribute *da) temp_data_ptr->device_name, temp_data_ptr->index); return (-1); } +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) ret = get_sys_val(ops_ptr, &sys_val); if (ret < 0) { pddf_dbg(LED, KERN_ERR "ERROR %s: Cannot get sys val\n", __func__); @@ -213,7 +221,11 @@ ssize_t get_status_led(struct device_attribute *da) } /* keep ret as old value */ ret = 0; - +#else + sys_val = board_i2c_cpld_read_new(ops_ptr->swpld_addr, ops_ptr->device_name, ops_ptr->swpld_addr_offset); + if (sys_val < 0) + return sys_val; +#endif strcpy(temp_data.cur_state.color, "None"); for (state=0; statedata[state].bits.mask_bits); @@ -232,6 +244,7 @@ ssize_t get_status_led(struct device_attribute *da) return(ret); } +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) int set_sys_val(LED_OPS_DATA *ops_ptr, uint32_t new_val) { int ret; @@ -266,6 +279,7 @@ int set_sys_val(LED_OPS_DATA *ops_ptr, uint32_t new_val) return ret; } +#endif ssize_t set_status_led(struct device_attribute *da) { @@ -297,12 +311,18 @@ ssize_t set_status_led(struct device_attribute *da) } if(ops_ptr->data[cur_state].swpld_addr != 0x0) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) ret = get_sys_val(ops_ptr, &sys_val); if (ret < 0) { pddf_dbg(LED, KERN_ERR "ERROR %s: Cannot get sys val\n", __func__); return (-1); } - +#else + sys_val = board_i2c_cpld_read_new(ops_ptr->swpld_addr, ops_ptr->device_name, ops_ptr->swpld_addr_offset); + if (sys_val < 0) { + return sys_val; + } +#endif new_val = (sys_val & ops_ptr->data[cur_state].bits.mask_bits) | (ops_ptr->data[cur_state].value << ops_ptr->data[cur_state].bits.pos); @@ -312,16 +332,24 @@ ssize_t set_status_led(struct device_attribute *da) return (-1); } +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) ret = set_sys_val(ops_ptr, new_val); if (ret < 0) { pddf_dbg(LED, KERN_ERR "ERROR %s: Cannot set sys val\n", __func__); return (-1); } +#else + board_i2c_cpld_write_new(ops_ptr->swpld_addr, ops_ptr->device_name, ops_ptr->swpld_addr_offset, new_val); +#endif pddf_dbg(LED, KERN_INFO "Set color:%s; 0x%x:0x%x sys_val:0x%x new_val:0x%x read:0x%x\n", LED_STATUS_STR[cur_state], ops_ptr->swpld_addr, ops_ptr->swpld_addr_offset, sys_val, new_val, - ret = board_i2c_cpld_read(ops_ptr->swpld_addr, ops_ptr->swpld_addr_offset)); +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) + ret = board_i2c_cpld_read(ops_ptr->swpld_addr, ops_ptr->swpld_addr_offset)); +#else + ret = board_i2c_cpld_read_new(ops_ptr->swpld_addr, ops_ptr->device_name, ops_ptr->swpld_addr_offset)); +#endif if (ret < 0) { pddf_dbg(LED, KERN_ERR "PDDF_LED ERROR %s: Error %d in reading from cpld(0x%x) offset 0x%x\n", __FUNCTION__, ret, ops_ptr->swpld_addr, ops_ptr->swpld_addr_offset); diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/modules/driver/rg_cpld.c b/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/modules/driver/rg_cpld.c index 7d9fc82a6933..dd0f850591e9 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/modules/driver/rg_cpld.c +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/modules/driver/rg_cpld.c @@ -161,7 +161,7 @@ count) } mutex_lock(&data->update_lock); val = (u8)val; - DBG_DEBUG("pos: 0x%02x count = %ld, data = 0x%02x\n", attr->index, count, val); + DBG_DEBUG("pos: 0x%02x count = %ld, data = 0x%02lx\n", attr->index, count, val); i2c_smbus_write_byte_data(client, attr->index, val); mutex_unlock(&data->update_lock); diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/sonic_platform/chassis.py index 5d428f668567..efbb8859f71a 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/sonic_platform/chassis.py @@ -7,7 +7,6 @@ try: import time from sonic_platform_pddf_base.pddf_chassis import PddfChassis - from sonic_platform.fan_drawer import FanDrawer except ImportError as e: raise ImportError(str(e) + "- required module not found") @@ -27,16 +26,10 @@ class Chassis(PddfChassis): def __init__(self, pddf_data=None, pddf_plugin_data=None): PddfChassis.__init__(self, pddf_data, pddf_plugin_data) - # fan drawer - temp = [] - drawer_index = 0 - for idx, fan in enumerate(self.get_all_fans()): - temp.append(fan) - if (idx + 1) % FAN_NUM_PER_DRAWER == 0: - drawer = FanDrawer(drawer_index + 1, temp) - self.get_all_fan_drawers().append(drawer) - temp = [] - drawer_index += 1 + def get_revision(self): + val = ord(self._eeprom.revision_str()) + test = "{}".format(val) + return test def get_reboot_cause(self): """ diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/sonic_platform/fan_drawer.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/sonic_platform/fan_drawer.py index 2f83b66df94a..d03fd656f4d7 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/sonic_platform/fan_drawer.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/sonic_platform/fan_drawer.py @@ -1,69 +1,17 @@ -# -# fan_drawer -# +#!/usr/bin/env python + try: - from sonic_platform_base.fan_drawer_base import FanDrawerBase + from sonic_platform_pddf_base.pddf_fan_drawer import PddfFanDrawer except ImportError as e: raise ImportError(str(e) + "- required module not found") -class FanDrawer(FanDrawerBase): - # 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 drawer {}".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 - """ - if self.get_num_fans() > 0: - return self._fan_list[0].set_status_led(color) - return False +class FanDrawer(PddfFanDrawer): + """PDDF Platform-Specific Fan-Drawer class""" - def get_status_led(self): - """ - Gets the state of the fan drawer LED - Returns: - A string, one of the predefined STATUS_LED_COLOR_* strings above - """ - if self.get_num_fans() > 0: - return self._fan_list[0].get_status_led() - return "N/A" + def __init__(self, tray_idx, pddf_data=None, pddf_plugin_data=None): + # idx is 0-based + PddfFanDrawer.__init__(self, tray_idx, pddf_data, pddf_plugin_data) + # Provide the functions/variables below for which implementation is to be overwritten \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/sonic_platform/psu.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/sonic_platform/psu.py index 57dd5117a2c4..baba1812845b 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/sonic_platform/psu.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/sonic_platform/psu.py @@ -1,5 +1,7 @@ try: from sonic_platform_pddf_base.pddf_psu import PddfPsu + import subprocess + import time except ImportError as e: raise ImportError (str(e) + "- required module not found") @@ -29,4 +31,96 @@ def get_type(self): A string, the type of PSU (AC/DC) """ return "DC" + + def runcmd(self, cmd): + time_retry = 6 + result_msg = "" + time_delay = 0.01 + while time_retry: + try: + val, result_msg = subprocess.getstatusoutput(cmd) + 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, result_msg + + def get_voltage(self): + """ + Retrieves current PSU voltage output + + Returns: + A float number, the output voltage in volts, + e.g. 12.1 + """ + + v_out = 0 + label_t = "psu_v_out" + device = "PSU{}".format(self.psu_index) + #print(device) + pddf_obj_data = self.pddf_obj.data + + if device in pddf_obj_data.keys(): + pmbusloc = pddf_obj_data[device]['i2c']['interface'] + + for val in pmbusloc: + dev_name = val['dev'] + pmbus_loc = pddf_obj_data[dev_name] + i2cloc = pmbus_loc['i2c']['attr_list'] + parentbus = pmbus_loc['i2c']['topo_info'] + + for item_t in i2cloc: + if item_t['attr_name'] == label_t: + parentbus_id = int(parentbus['parent_bus'], 16) + vout_mode_cmd = "i2cget -f -y {} {} 0x20 bp".format(parentbus_id, parentbus['dev_addr']) + ret_t, val_voutmode = self.runcmd(vout_mode_cmd) + if ret_t is False: + return 0.0 + v_out_cmd = "i2cget -f -y {} {} {} wp".format(parentbus_id, parentbus['dev_addr'], item_t['attr_offset']) + ret_t, val_p_out = self.runcmd(v_out_cmd) + if ret_t is False: + return 0.0 + val_voutmode_t = int(val_voutmode, 16) + val_p_out_t = int(val_p_out, 16) * 1000 + + import ctypes + val_voutmode_t_t = ctypes.c_int8(val_voutmode_t << 3).value >>3 + + if (val_voutmode_t_t) < 0: + val_p_out_t_f = val_p_out_t>> (-val_voutmode_t_t) + else: + val_p_out_t_f = val_p_out_t << val_voutmode_t_t + + return float(val_p_out_t_f)/1000 + + return float(v_out)/1000 + + def get_revision(self): + """ + Retrieves the hardware revision of the device + + Returns: + string: Revision value of device + """ + device_eeprom = "PSU{}-EEPROM".format(self.psu_index) + pddf_obj_data = self.pddf_obj.data + + if device_eeprom not in pddf_obj_data.keys(): + return "N/A" + + i2cloc = pddf_obj_data[device_eeprom]['i2c']['topo_info'] + i2cbus = int(i2cloc['parent_bus'], 16) + get_revision_cmd = "i2cget -f -y {} {} 0x35 w".format(i2cbus, i2cloc['dev_addr']) + ret_t, revision = self.runcmd(get_revision_cmd) + if ret_t is False: + return "N/A" + revision = int(revision, 16) + revision_str = "%s%s" % (chr(revision&0xff), chr((revision >> 8)&0xff)) + return revision_str diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/sonic_platform/sfp.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/sonic_platform/sfp.py index ea8e256fe6ef..c577544a664e 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/sonic_platform/sfp.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/sonic_platform/sfp.py @@ -1,31 +1,12 @@ #!/usr/bin/env python - +import time try: - #from sonic_platform_pddf_base.pddf_sfp import * - from sonic_platform_base.sonic_sfp.sff8436 import sff8436InterfaceId - from sonic_platform_base.sonic_sfp.sff8436 import sff8436Dom - from sonic_platform_base.sonic_sfp.sff8472 import sff8472InterfaceId - from sonic_platform_base.sonic_sfp.sff8472 import sff8472Dom from sonic_platform_pddf_base.pddf_sfp import PddfSfp - from sonic_platform_pddf_base.pddf_sfp import SFP_VOLT_OFFSET - from sonic_platform_pddf_base.pddf_sfp import SFP_VOLT_WIDTH - from sonic_platform_pddf_base.pddf_sfp import SFP_CHANNL_MON_OFFSET - from sonic_platform_pddf_base.pddf_sfp import SFP_CHANNL_MON_WIDTH - from sonic_platform_pddf_base.pddf_sfp import SFP_TEMPE_OFFSET - from sonic_platform_pddf_base.pddf_sfp import SFP_TEMPE_WIDTH - from sonic_platform_pddf_base.pddf_sfp import QSFP_DOM_REV_OFFSET - from sonic_platform_pddf_base.pddf_sfp import QSFP_DOM_REV_WIDTH - from sonic_platform_pddf_base.pddf_sfp import QSFP_CHANNL_MON_OFFSET - from sonic_platform_pddf_base.pddf_sfp import QSFP_CHANNL_MON_WITH_TX_POWER_WIDTH except ImportError as e: raise ImportError (str(e) + "- required module not found") -XCVR_DOM_CAPABILITY_OFFSET = 92 -XCVR_DOM_CAPABILITY_WIDTH = 2 -QSFP_VERSION_COMPLIANCE_OFFSET = 1 -QSFP_VERSION_COMPLIANCE_WIDTH = 2 -QSFP_OPTION_VALUE_OFFSET = 192 -QSFP_OPTION_VALUE_WIDTH = 4 +EEPROM_RETRY = 5 +EEPROM_RETRY_BREAK_SEC = 0.2 class Sfp(PddfSfp): """ @@ -34,254 +15,46 @@ class Sfp(PddfSfp): def __init__(self, index, pddf_data=None, pddf_plugin_data=None): PddfSfp.__init__(self, index, pddf_data, pddf_plugin_data) - self.dom_supported = False - self.__dom_capability_detect() - - def __dom_capability_detect(self): - self.dom_supported = False - self.dom_temp_supported = False - self.dom_volt_supported = False - self.dom_rx_power_supported = False - self.dom_tx_power_supported = False - self.qsfp_page3_available = False - self.calibration = 0 - if not self.get_presence(): - return - - if self.is_osfp_port: - # Not implement - return - elif self.is_qsfp_port: - self.calibration = 1 - sfpi_obj = sff8436InterfaceId() - if sfpi_obj is None: - self.dom_supported = False - offset = 128 - - # QSFP capability byte parse, through this byte can know whether it support tx_power or not. - # TODO: in the future when decided to migrate to support SFF-8636 instead of SFF-8436, - # need to add more code for determining the capability and version compliance - # in SFF-8636 dom capability definitions evolving with the versions. - qsfp_dom_capability_raw = self.__read_eeprom_specific_bytes( - (offset + XCVR_DOM_CAPABILITY_OFFSET), XCVR_DOM_CAPABILITY_WIDTH) - if qsfp_dom_capability_raw is not None: - qsfp_version_compliance_raw = self.__read_eeprom_specific_bytes( - QSFP_VERSION_COMPLIANCE_OFFSET, QSFP_VERSION_COMPLIANCE_WIDTH) - qsfp_version_compliance = int( - qsfp_version_compliance_raw[0], 16) - dom_capability = sfpi_obj.parse_dom_capability( - qsfp_dom_capability_raw, 0) - if qsfp_version_compliance >= 0x08: - self.dom_temp_supported = dom_capability['data']['Temp_support']['value'] == 'On' - self.dom_volt_supported = dom_capability['data']['Voltage_support']['value'] == 'On' - self.dom_rx_power_supported = dom_capability['data']['Rx_power_support']['value'] == 'On' - self.dom_tx_power_supported = dom_capability['data']['Tx_power_support']['value'] == 'On' - else: - self.dom_temp_supported = True - self.dom_volt_supported = True - self.dom_rx_power_supported = dom_capability['data']['Rx_power_support']['value'] == 'On' - self.dom_tx_power_supported = True + self._xcvr_api = self.get_xcvr_api() - self.dom_supported = True - self.calibration = 1 - sfpd_obj = sff8436Dom() - if sfpd_obj is None: - return None - qsfp_option_value_raw = self.__read_eeprom_specific_bytes( - QSFP_OPTION_VALUE_OFFSET, QSFP_OPTION_VALUE_WIDTH) - if qsfp_option_value_raw is not None: - optional_capability = sfpd_obj.parse_option_params( - qsfp_option_value_raw, 0) - self.dom_tx_disable_supported = optional_capability[ - 'data']['TxDisable']['value'] == 'On' - dom_status_indicator = sfpd_obj.parse_dom_status_indicator( - qsfp_version_compliance_raw, 1) - self.qsfp_page3_available = dom_status_indicator['data']['FlatMem']['value'] == 'Off' - else: - self.dom_supported = False - self.dom_temp_supported = False - self.dom_volt_supported = False - self.dom_rx_power_supported = False - self.dom_tx_power_supported = False - self.calibration = 0 - self.qsfp_page3_available = False - else: - sfpi_obj = sff8472InterfaceId() - if sfpi_obj is None: - return None - sfp_dom_capability_raw = self.__read_eeprom_specific_bytes( - XCVR_DOM_CAPABILITY_OFFSET, XCVR_DOM_CAPABILITY_WIDTH) - if sfp_dom_capability_raw is not None: - sfp_dom_capability = int(sfp_dom_capability_raw[0], 16) - self.dom_supported = (sfp_dom_capability & 0x40 != 0) - if self.dom_supported: - self.dom_temp_supported = True - self.dom_volt_supported = True - self.dom_rx_power_supported = True - self.dom_tx_power_supported = True - if sfp_dom_capability & 0x20 != 0: - self.calibration = 1 - elif sfp_dom_capability & 0x10 != 0: - self.calibration = 2 - else: - self.calibration = 0 - else: - self.dom_temp_supported = False - self.dom_volt_supported = False - self.dom_rx_power_supported = False - self.dom_tx_power_supported = False - self.calibration = 0 - self.dom_tx_disable_supported = ( - int(sfp_dom_capability_raw[1], 16) & 0x40 != 0) - - # Provide the functions/variables below for which implementation is to be overwritten - - def __read_eeprom_specific_bytes(self, offset, num_bytes): - eeprom_raw = [] - if not self.get_presence(): - return None - for i in range(0, num_bytes): - eeprom_raw.append("0x00") + def get_eeprom_path(self): + return self.eeprom_path + def read_eeprom(self, offset, num_bytes): + eeprom_raw = None try: - with open(self.eeprom_path, mode="rb", buffering=0) as eeprom: - eeprom.seek(offset) - raw = eeprom.read(num_bytes) + for i in range(EEPROM_RETRY): + eeprom_raw = PddfSfp.read_eeprom(self, offset, num_bytes) + if eeprom_raw is None: + time.sleep(EEPROM_RETRY_BREAK_SEC) + continue + break except Exception as e: - print("Error: Unable to open eeprom_path: %s" % (str(e))) + print("Error: Unable to read eeprom_path: %s" % (str(e))) return None + return eeprom_raw + + def write_eeprom(self, offset, num_bytes, write_buffer): try: - if len(raw) == 0: - return None - for n in range(0, num_bytes): - eeprom_raw[n] = hex(raw[n])[2:].zfill(2) + for i in range(EEPROM_RETRY): + ret = PddfSfp.write_eeprom(self, offset, num_bytes, write_buffer) + if ret is False: + time.sleep(EEPROM_RETRY_BREAK_SEC) + continue + break except Exception as e: - print("Error: Exception info: %s" % (str(e))) - return None - - return eeprom_raw - - def get_transceiver_bulk_status(self): - # check present status - if not self.get_presence(): + print("Error: Unable to write eeprom_path: %s" % (str(e))) return None - self.__dom_capability_detect() - - xcvr_dom_info_dict = dict.fromkeys(self.dom_dict_keys, 'N/A') - - if self.is_osfp_port: - # Below part is added to avoid fail xcvrd, shall be implemented later - pass - elif self.is_qsfp_port: - # QSFPs - xcvr_dom_info_dict = super(Sfp, self).get_transceiver_bulk_status() - - # pddf_sfp "qsfp_tx_power_support != 'on'" is wrong - - offset = 0 - sfpd_obj = sff8436Dom() - if sfpd_obj is None: - return None - - qsfp_dom_rev_raw = self.__read_eeprom_specific_bytes((offset + QSFP_DOM_REV_OFFSET), QSFP_DOM_REV_WIDTH) - if qsfp_dom_rev_raw is not None: - qsfp_dom_rev_data = sfpd_obj.parse_sfp_dom_rev(qsfp_dom_rev_raw, 0) - else: - return None - - dom_channel_monitor_data = {} - qsfp_dom_rev = qsfp_dom_rev_data['data']['dom_rev']['value'] - - if (qsfp_dom_rev[0:8] == 'SFF-8636' and self.dom_tx_power_supported is True): - dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( - (offset + QSFP_CHANNL_MON_OFFSET), QSFP_CHANNL_MON_WITH_TX_POWER_WIDTH) - if dom_channel_monitor_raw is not None: - dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params_with_tx_power( - dom_channel_monitor_raw, 0) - else: - return None - - xcvr_dom_info_dict['tx1power'] = dom_channel_monitor_data['data']['TX1Power']['value'] - xcvr_dom_info_dict['tx2power'] = dom_channel_monitor_data['data']['TX2Power']['value'] - xcvr_dom_info_dict['tx3power'] = dom_channel_monitor_data['data']['TX3Power']['value'] - xcvr_dom_info_dict['tx4power'] = dom_channel_monitor_data['data']['TX4Power']['value'] - else: - # SFPs - offset = 256 - if not self.dom_supported: - return xcvr_dom_info_dict - - sfpd_obj = sff8472Dom() - if sfpd_obj is None: - return None - - sfpd_obj._calibration_type = self.calibration - - dom_temperature_raw = self.__read_eeprom_specific_bytes((offset + SFP_TEMPE_OFFSET), SFP_TEMPE_WIDTH) - if dom_temperature_raw is not None: - dom_temperature_data = sfpd_obj.parse_temperature(dom_temperature_raw, 0) - else: - return None - - dom_voltage_raw = self.__read_eeprom_specific_bytes((offset + SFP_VOLT_OFFSET), SFP_VOLT_WIDTH) - if dom_voltage_raw is not None: - dom_voltage_data = sfpd_obj.parse_voltage(dom_voltage_raw, 0) - else: - return None - - dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( - (offset + SFP_CHANNL_MON_OFFSET), SFP_CHANNL_MON_WIDTH) - if dom_channel_monitor_raw is not None: - dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params(dom_channel_monitor_raw, 0) - else: - return None - - xcvr_dom_info_dict['temperature'] = dom_temperature_data['data']['Temperature']['value'] - xcvr_dom_info_dict['voltage'] = dom_voltage_data['data']['Vcc']['value'] - xcvr_dom_info_dict['rx1power'] = dom_channel_monitor_data['data']['RXPower']['value'] - xcvr_dom_info_dict['rx2power'] = 'N/A' - xcvr_dom_info_dict['rx3power'] = 'N/A' - xcvr_dom_info_dict['rx4power'] = 'N/A' - xcvr_dom_info_dict['tx1bias'] = dom_channel_monitor_data['data']['TXBias']['value'] - xcvr_dom_info_dict['tx2bias'] = 'N/A' - xcvr_dom_info_dict['tx3bias'] = 'N/A' - xcvr_dom_info_dict['tx4bias'] = 'N/A' - xcvr_dom_info_dict['tx1power'] = dom_channel_monitor_data['data']['TXPower']['value'] - xcvr_dom_info_dict['tx2power'] = 'N/A' - xcvr_dom_info_dict['tx3power'] = 'N/A' - xcvr_dom_info_dict['tx4power'] = 'N/A' - - xcvr_dom_info_dict['rx_los'] = self.get_rx_los() - xcvr_dom_info_dict['tx_fault'] = self.get_tx_fault() - xcvr_dom_info_dict['reset_status'] = self.get_reset_status() - xcvr_dom_info_dict['lp_mode'] = self.get_lpmode() - - return xcvr_dom_info_dict - - def get_transceiver_threshold_info(self): - # check present status - if not self.get_presence(): - return None - self.__dom_capability_detect() - - xcvr_dom_threshold_info_dict = dict.fromkeys(self.threshold_dict_keys, 'N/A') - - if self.is_osfp_port: - # Below part is added to avoid fail xcvrd, shall be implemented later - pass - elif self.is_qsfp_port: - # QSFPs - if not self.dom_supported or not self.qsfp_page3_available: - return xcvr_dom_threshold_info_dict - - return super(Sfp, self).get_transceiver_threshold_info() - else: - # SFPs - if not self.dom_supported: - return xcvr_dom_threshold_info_dict + return ret - return super(Sfp, self).get_transceiver_threshold_info() + def get_power_set(self): + if not self._xcvr_api.get_lpmode_support(): + return False + return self._xcvr_api.get_power_set() - return xcvr_dom_threshold_info_dict + def get_power_override(self): + if not self._xcvr_api.get_power_override_support() or not self._xcvr_api.get_lpmode_support(): + return False + return self._xcvr_api.get_power_override() diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/sonic_platform/thermal.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/sonic_platform/thermal.py index 99b743c6d343..f2a73e5f5db8 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/sonic_platform/thermal.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6920-4s/sonic_platform/thermal.py @@ -8,7 +8,7 @@ class Thermal(PddfThermal): """PDDF Platform-Specific Thermal class""" - def __init__(self, index, pddf_data=None, pddf_plugin_data=None): - PddfThermal.__init__(self, index, pddf_data, pddf_plugin_data) + def __init__(self, index, pddf_data=None, pddf_plugin_data=None, is_psu_thermal=False, psu_index=0): + PddfThermal.__init__(self, index, pddf_data, pddf_plugin_data, is_psu_thermal, psu_index) # Provide the functions/variables below for which implementation is to be overwritten diff --git a/src/sonic-device-data/tests/permitted_list b/src/sonic-device-data/tests/permitted_list index 6324a441d681..266d7e6728de 100644 --- a/src/sonic-device-data/tests/permitted_list +++ b/src/sonic-device-data/tests/permitted_list @@ -308,6 +308,16 @@ sap_rx_polarity_flip sap_tx_polarity_flip sap_mdio_num dport_map_port_9 +cancun_dir +pcie_file +capi_level +phy_pin_compatibility_enable +cfg_int_phy_ctrl +stand_alone_phy_init +sap_rx_polarity_flip +sap_tx_polarity_flip +sap_mdio_num +dport_map_port_9 ifa_enable port_gmii_mode phy_force_firmware_load From 7ec250977ac68eacac65885761112cdbc0f72117 Mon Sep 17 00:00:00 2001 From: pettershao-ragilenetworks Date: Wed, 8 Feb 2023 15:50:23 +0800 Subject: [PATCH 2/2] fix psu get_model fix show platform fan/psustatus modify RA 6510-48 ssdhealth --- .../plugins/ssd_util.py | 2 +- .../ra-b6510-48v8c/sonic_platform/fan.py | 21 +++++++++++++++++ .../ra-b6510-48v8c/sonic_platform/psu.py | 23 +++++++++++++++++-- 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/plugins/ssd_util.py b/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/plugins/ssd_util.py index c532804f66c7..e92782a0969b 100755 --- a/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/plugins/ssd_util.py +++ b/device/ragile/x86_64-ragile_ra-b6510-48v8c-r0/plugins/ssd_util.py @@ -64,7 +64,7 @@ def __init__(self, diskdev): self.model_attr = { "ER2-GD" : { "temperature" : "\n190\s+(.+?)\n", "remainingLife" : "\n202\s+(.+?)\n" }, "AF2MA31DTDLT" : { "temperature" : "\n194\s+(.+?)\n", "remainingLife" : "\n202\s+(.+?)\n" }, - "SSDSCKKB" : { "temperature" : "\n194\s+(.+?)\n", "remainingLife" : "\n233\s+(.+?)\n" }, + "SSDSCK" : { "temperature" : "\n194\s+(.+?)\n", "remainingLife" : "\n233\s+(.+?)\n" }, "SM619GXC" : { "temperature" : "\n194\s+(.+?)\n", "remainingLife" : "\n169\s+(.+?)\n" }, "MZNLH" : { "temperature" : "\n190\s+(.+?)\n", "remainingLife" : "\n245\s+(.+?)\n" }, "IM2S3134N" : { "temperature" : "\n194\s+(.+?)\n", "remainingLife" : "\n231\s+(.+?)\n" } diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/fan.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/fan.py index f37900d28dbf..ea8c4cb6bcc9 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/fan.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/fan.py @@ -24,6 +24,27 @@ def get_direction(self): """ return self.FAN_DIRECTION_EXHAUST + def get_presence(self): + if not self.is_psu_fan: + return super().get_presence() + # psu-fan get_presence + status = 0 + device = "PSU{}".format(self.fans_psu_index) + output = self.pddf_obj.get_attr_name_output(device, "psu_present") + if not output: + return False + + mode = output['mode'] + status = output['status'] + + vmap = self.plugin_data['PSU']['psu_present'][mode]['valmap'] + + if status.rstrip('\n') in vmap: + return vmap[status.rstrip('\n')] + else: + return False + + def get_speed_rpm(self): if self.is_psu_fan: return super().get_speed_rpm() diff --git a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/psu.py b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/psu.py index f25b24f145a5..89eaf4898bd1 100644 --- a/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/psu.py +++ b/platform/broadcom/sonic-platform-modules-ragile/ra-b6510-48v8c/sonic_platform/psu.py @@ -39,6 +39,9 @@ def get_model(self): Returns: string: Model/part number of device """ + if self.get_presence() is False: + return "N/A" + model = super().get_model() psu_model_map = { @@ -63,12 +66,12 @@ def runcmd(self, cmd): while time_retry: try: val, result_msg = subprocess.getstatusoutput(cmd) - if val is False: + if val != 0: time_retry -=1 time.sleep(time_delay) continue else: - return val, result_msg + return True, result_msg except Exception as e: time_retry -= 1 result_msg = str(e) @@ -126,6 +129,20 @@ def get_voltage(self): return float(v_out)/1000 + + def get_serial(self): + """ + Retrieves the serial number of the device + + Returns: + string: Serial number of device + """ + if self.get_presence() is False: + return "N/A" + + return super().get_serial() + + def get_revision(self): """ Retrieves the hardware revision of the device @@ -133,6 +150,8 @@ def get_revision(self): Returns: string: Revision value of device """ + if self.get_presence() is False: + return "N/A" device_eeprom = "PSU{}-EEPROM".format(self.psu_index) pddf_obj_data = self.pddf_obj.data